GitPedia

Metarocq

Metaprogramming, verified meta-theory and implementation of Rocq in Rocq

From MetaRocq·Updated June 9, 2026·View on GitHub·

MetaRocq is a project formalizing Rocq in Rocq and providing tools for manipulating Rocq terms and developing certified plugins (i.e. translations, compilers or tactics) in Rocq. The project is written primarily in Rocq Prover, distributed under the MIT License license, first published in 2017. Key topics include: coq, coq-formalization, metaprogramming, rocq.

Latest release: v1.5.1-9.1MetaRocq 1.5.1 for Rocq 9.1
March 11, 2026View Changelog →

MetaRocq

<p align="center"> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/LOGO.png" alt="MetaRocq" width="50px"/> </p>

Build status MetaRocq Chat
Open in Visual Studio Code

MetaRocq is a project formalizing Rocq in Rocq and providing tools for
manipulating Rocq terms and developing certified plugins
(i.e. translations, compilers or tactics) in Rocq.

Quick jump

Getting started

Installation instructions

See INSTALL.md

Documentation

See DOC.md

Overview of the project

At the center of this project is the Template-Rocq quoting library for
Rocq. The project currently has a single repository extending
Template-Rocq with additional features. Each extension is in a dedicated folder.
The dependency graph
might be useful to navigate the project.
Statistics: ~300kLoC of Rocq, ~30kLoC of OCaml.

Template-Rocq

Template-Rocq is a quoting library for Rocq. It
takes Rocq terms and constructs a representation of their syntax tree as
an inductive data type. The representation is based on the kernel's
term representation.

After importing MetaRocq.Template.Loader there are commands MetaRocq Test Quote t.,
MetaRocq Quote Definition name := (t). and MetaRocq Quote Recursively Definition name := (t). as
well as a tactic quote_term t k,
where in all cases t is a term and k a continuation tactic.

In addition to this representation of terms, Template Rocq includes:

  • Reification of the environment structures, for constant and inductive
    declarations along with their universe structures.

  • Denotation of terms and global declarations.

  • A monad for querying the environment, manipulating global declarations, calling the type
    checker, and inserting them in the global environment, in
    the style of MTac. Monadic programs p : TemplateMonad A can be run using MetaRocq Run p.

  • A formalization of the typing rules reflecting the ones of Rocq, covering all of Rocq
    except eta-expansion and template polymorphism.

PCUIC

PCUIC, the Polymorphic Cumulative Calculus of Inductive Constructions is
a cleaned up version of the term language of Rocq and its associated
type system, shown equivalent to the one of Rocq. This version of the
calculus has proofs of standard metatheoretical results:

  • Weakening for global declarations, weakening and substitution for
    local contexts.

  • Confluence of reduction using a notion of parallel reduction

  • Context cumulativity / conversion and validity of typing.

  • Subject Reduction (case/cofix reduction excluded)

  • Principality: every typeable term has a smallest type.

  • Bidirectional presentation: an equivalent presentation of the system
    that enforces directionality of the typing rules. Strengthening follows
    from this presentation.

  • Elimination restrictions: the elimination restrictions ensure
    that singleton elimination (from Prop to Type) is only allowed
    on singleton inductives in Prop.

  • Canonicity: The weak head normal form of a term of inductive type is a constructor application.

  • Consistency under the assumption of strong normalization

  • Weak call-by-value standardization: Normal forms of terms of first-order inductive type
    can be found via weak call-by-value evaluation.

See the PCUIC README for
a detailed view of the development.

Safe Checker

Implementation of a fuel-free and verified reduction machine, conversion
checker and type checker for PCUIC. This relies on a postulate of
strong normalization of the reduction relation of PCUIC on well-typed terms.
The checker is shown to be correct and complete w.r.t. the PCUIC specification.
The extracted safe checker is available in Rocq through a new vernacular command:

MetaRocq SafeCheck <term>

After importing MetaRocq.SafeChecker.Loader.

To roughly compare the time used to check a definition with Rocq's vanilla
type-checker, one can use:

MetaRocq RocqCheck <term>

This also includes a verified, efficient re-typing procedure (useful in tactics) in
MetaRocq.SafeChecker.PCUICSafeRetyping.

See the SafeChecker README for
a detailed view of the development.

Erasure

An erasure procedure to untyped lambda-calculus accomplishing the
same as the type and proof erasure phase of the Extraction plugin of Rocq.
The extracted safe erasure is available in Rocq through a new vernacular command:

MetaRocq Erase <term>

After importing MetaRocq.Erasure.Loader.

The erasure pipeline includes verified optimizations to remove lets in constructors,
remove cases on propositional terms, switch to an unguarded fixpoint reduction rule and
transform the higher-order constructor applications to first-order blocks for easier
translation to usual programming languages. See the erasure
README for
a detailed view of the development.

Translations

Examples of translations built on top of this:

Quotation

The Quotation module is geared at providing functions □T → □□T for
□T := Ast.term (currently implemented) and for □T := { t : Ast.term & Σ ;;; [] |- t : T } (still in the works).

Ultimately the goal of this development is to prove that is a lax monoidal
semicomonad (a functor with cojoin : □T → □□T that codistributes over unit
and ×), which is sufficient for proving Löb's theorem.

The public-facing interface of this development is provided in MetaRocq.Quotation.ToTemplate.All and MetaRocq.Quotation.ToPCUIC.All.

See the Quotation README for a more detailed view of the development.

Examples

Papers

  • The CertiCoq project develops a certified compiler from the output of verified erasure down
    to CompCert C-light. It provides in particular OCaml and fully foundationally verified plugins
    for the whole compilation pipeline from Gallina to Clight and the verified type-checker of MetaRocq.

  • The ConCert project develops certified or certifying compilers from Gallina to smart contract languages (Liquidity and
    CameLIGO), the functional language Elm, and a subset of the Rust programming languages. It uses the typed erasure variant to
    gather more type information about erased terms and perform optimizations based on this information.
    The project focuses in particular on the verification and safe extraction of smart contracts for blockchains.

Team & Credits

<p align="center"> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/abhishek-anand.jpg" alt="Abhishek Anand" width="150px"/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/danil-annenkov.jpeg" alt="Danil Annenkov" width="150px"/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/simon-boulier.jpg" alt="Simon Boulier" width="150px"/><br/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/cyril-cohen.png" alt="Cyril Cohen" width="150px"/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/yannick-forster.jpg" alt="Yannick Forster" width="150px"/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/jason-gross.jpg" alt="Jason Gross" width="150px"/><br/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/meven-lennon-bertrand.jpeg" alt="Meven Lennon-Bertrand" width="150px"/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/kenji-maillard.jpg" alt="Kenji Maillard" width="150px"/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/gregory-malecha.jpg" alt="Gregory Malecha" width="150px"/><br/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/jakob-botsch-nielsen.png" alt="Jakob Botsch Nielsen" width="150px"/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/matthieu-sozeau.png" alt="Matthieu Sozeau" width="150px"/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/nicolas-tabareau.jpg" alt="Nicolas Tabareau" width="150px"/><br/> <img src="https://github.com/MetaRocq/metarocq.github.io/raw/master/assets/theo-winterhalter.jpg" alt="Théo Winterhalter" width="150px"/> <br/>

MetaRocq is developed by (left to right)
<a href="https://github.com/aa755">Abhishek Anand</a>,
<a href="https://github.com/annenkov">Danil Annenkov</a>,
<a href="https://github.com/SimonBoulier">Simon Boulier</a>,
<a href="https://github.com/CohenCyril">Cyril Cohen</a>,
<a href="https://github.com/yforster">Yannick Forster</a>,
<a href="https://jasongross.github.io">Jason Gross</a>,
<a href="https://www.meven.ac">Meven Lennon-Bertrand</a>,
<a href="https://github.com/kyoDralliam">Kenji Maillard</a>,
<a href="https://github.com/gmalecha">Gregory Malecha</a>,
<a href="https://github.com/jakobbotsch">Jakob Botsch Nielsen</a>,
<a href="https://github.com/mattam82">Matthieu Sozeau</a>,
<a href="https://github.com/Tabareau">Nicolas Tabareau</a> and
<a href="https://github.com/TheoWinterhalter">Théo Winterhalter</a>.

</p>
Copyright (c) 2014-2023 Gregory Malecha
Copyright (c) 2015-2025 Abhishek Anand, Matthieu Sozeau
Copyright (c) 2017-2023 Simon Boulier, Cyril Cohen
Copyright (c) 2017-2025 Nicolas Tabareau, Yannick Forster, Théo Winterhalter
Copyright (c) 2018-2023 Danil Annenkov
Copyright (c) 2020-2023 Jakob Botsch Nielsen, Meven Lennon-Bertrand
Copyright (c) 2022-2025 Kenji Maillard
Copyright (c) 2023      Jason Gross

This software is distributed under the terms of the MIT license.
See LICENSE for details.

Bugs

Please report any bugs or feature requests on the github issue tracker.

Contributors

Showing top 12 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from MetaRocq/metarocq via the GitHub API.Last fetched: 6/13/2026