Coq (Rocq) — Reference
Source: https://rocq-prover.org/
Coq (Rocq) — Reference
2025 rename: The project formerly known as Coq (1989-2025) was renamed to The Rocq Prover. Timeline: rename announced 2023-10-11 by the dev team; officially completed with the Rocq 9.0.0 release on 2025-03-12 (https://rocq-prover.org/releases/9.0.0). Subsequent releases (9.1, 9.2) carry the Rocq name natively. The kernel, language, and tactic system are unchanged — this is a rebranding, not a fork. The new name honors Inria Rocquencourt, the original development site. The canonical slug for this note remains
coqfor backward compatibility; the current project URL is https://rocq-prover.org/ (legacy https://coq.inria.fr/ now redirects there).
- Created: 1984 (initial development by Thierry Coquand and Gérard Huet at INRIA); first public release as “Coq” 1989. Renamed Rocq 2025.
- Latest stable: Rocq 9.2.0 (per https://rocq-prover.org/, 2025); the Rocq Platform 2025.08 bundles the prover with curated libraries.
- Owner / steward: Inria (national lead) plus a distributed core team across academic institutions; community governance via the Rocq Team and an enhancement-process (CEP) model. https://rocq-prover.org/about
- Paradigms: Dependently-typed functional language plus interactive tactic-based proof assistant; dual-purpose like Lean and Agda but with much heavier emphasis on the proof side.
- Typing: pCuIC — Polymorphic Cumulative Calculus of Inductive Constructions (impredicative
Prop, predicative cumulativeTypehierarchy). - Memory: Implemented in OCaml; proofs and terms live on the OCaml heap with OCaml’s GC. Extracted code uses the target language’s runtime.
- Compilation: The kernel checks proofs; user proofs are normally interpreted, but
vm_computeandnative_compute(via OCaml’s native compiler) provide fast reduction. Code is extracted to OCaml/Haskell/Scheme for execution. - Primary domains: Formal verification (CompCert, certified compilers, cryptographic protocols), formalized mathematics (Four-Color, Feit-Thompson), program logic research, type-theory research itself.
- Official docs: https://rocq-prover.org/ • https://rocq-prover.org/docs/ • Reference manual: https://rocq-prover.org/refman/
At a glance
Rocq (née Coq) is the oldest of the four dependently-typed assistants and the source of much of the type theory the others reuse. Its strengths are a tiny trusted kernel, a very mature Ltac/Ltac2 tactic ecosystem, and decades of accumulated formalizations. Its weaknesses (compared to Lean 4) are a slower elaborator, awkward dependent pattern matching without the Equations plugin, and a more arcane module system. Source: https://rocq-prover.org/about, https://rocq-prover.org/docs/.
Getting started
-
Install: Use opam (the OCaml package manager):
opam install rocq-prover # or: opam install coq (legacy alias)Or install the Rocq Platform for a curated bundle (https://github.com/rocq-prover/platform). Windows users: the Platform installer is the easy path.
-
Editor: VsRocq (VS Code, https://github.com/rocq-prover/vsrocq), Proof General (Emacs, https://proofgeneral.github.io/), CoqIDE (ships with the prover; will be renamed RocqIDE).
-
Hello world:
Definition hello : string := "Hello, Rocq!".Or a smallest proof:
Theorem identity : forall (A : Type) (a : A), a = a. Proof. intros. reflexivity. Qed. -
Project layout: A
_CoqProjectfile lists source files and module roots:-Q theories MyProj theories/Foo.v theories/Bar.vBuild with
coq_makefile -f _CoqProject -o Makefile && make, or usedune(https://github.com/rocq-prover/rocq/wiki/Dune). -
REPL / proof env:
rocq top(orcoqtop) is the interactive toplevel; in practice everyone uses Proof General or VsRocq, which keep the proof state visible and stepped.
Basics
-
Types & literals:
nat,Z(BinInt.Z— binary integers),bool,string,list A,option A,prod A B. Numeric literals are notation;Open Scope nat_scope.etc. -
Variables / scoping:
let x := e in body.Section/Endfor shared parameters;Variable,Hypothesis,Context. -
Control flow: Pure functional.
if cond then a else bworks on any 2-constructor inductive (most commonlybool).match e with ... end. -
Functions:
Fixpoint length {A} (xs : list A) : nat := match xs with | nil => 0 | _ :: rest => S (length rest) end.All
Fixpoints must be syntactically structurally recursive; otherwise useFunction,Program Fixpoint, orEquations. -
Strings:
String(cons-cell strings of bytes — surprisingly inefficient; usebytestringlibs for real work). -
Collections:
list,option,Vector.t n A(length-indexed),Ensemble,FSet/FMap(functorial sets/maps from the stdlib’s module system).Coq.MSetsandCoq.FSetsare the practical interfaces.
Intermediate
- Type system depth: pCuIC.
Propis impredicative (you can quantify over all ofPropinProp);Typeis predicative with cumulative universes (Type@{i} ⊆ Type@{i+1}). SProp (definitionally proof-irrelevant Prop) added in 8.10. Inductive types include indexed families, mutual blocks, and (with extensions) coinductive types viaCoFixpoint. - Modules: Module system is a separate language layer with functors (parameterized modules),
Module Typesignatures, refinement, and inclusion. Powerful but syntactically heavy. (https://rocq-prover.org/refman/language/core/modules.html) - Error handling: Pure programs use
option/sum. Tactics that fail are caught withtry,;,||,first [...]. Extracted code maps to the target language’s exceptions. - Concurrency primitives: None at the language level — Rocq is a checker, not a runtime. Extracted programs inherit the target language’s concurrency.
- I/O: None in the kernel. Extracted code does I/O via the target language. The
coq-extractiontoolchain emits OCaml/Haskell/Scheme. - Stdlib highlights:
Coq.Init,Coq.Arith,Coq.ZArith,Coq.Reals(classical reals),Coq.Lists,Coq.MSets,Coq.Strings,Coq.Logic. Most “real” math users prefer mathcomp (https://math-comp.github.io/) — Gonthier’s small-scale-reflection library powering the Feit-Thompson formalization.
Advanced
- Memory / GC: OCaml-runtime; not user-controlled.
- Concurrency: N/A (see above).
- FFI: No direct FFI in the language. Plugins extend the toplevel via the OCaml plugin API (https://rocq-prover.org/refman/using/tools/plugin.html). For verified-and-runnable code, write the program in Rocq, prove it, then
Extractionto OCaml/Haskell. - Reflection:
Ltacreflection — pattern-match on terms inside tactics.MetaCoq(https://metacoq.github.io/) — Coq formalized in Coq. Lets you reify terms, manipulate them as data, then unquote. Used to build verified plugins and certifying type-checkers.
- Performance tools:
vm_compute— bytecode VM reduction (fast).native_compute— compiles the term via OCaml’s native compiler then runs it (fastest).Time,Time Eval,Profilecommands.coqchk— re-checks a compiled.vofrom scratch using only the kernel.
- Tactics & proof automation:
auto,eauto,intuition,tauto,congruence,lia(linear integer arithmetic),nia,lra,nra,ring,field,omega(deprecated, replaced bylia).- Hint databases (
Hint Resolve,Hint Rewrite,Hint Constructors). SearchPattern,Search,SearchAbout— lemma discovery.firstorder— first-order proof search.Equationsplugin (https://mattam82.github.io/Coq-Equations/) — dependent pattern matching withwithclauses, eliminator generation, well-founded recursion. Almost mandatory for serious dependently-typed programming in Rocq.
God mode
- Ltac vs Ltac2: Ltac is the legacy untyped tactic language — flexible, infamous for surprising failure modes (it backtracks unpredictably and has no static checking). Ltac2 (https://rocq-prover.org/refman/proof-engine/ltac2.html, shipped 8.11) is a typed, OCaml-flavored replacement with first-class tactics,
match!for syntactic patterns, and proper exceptions. Use Ltac2 for new tactic libraries. - Definitional vs propositional equality:
=(eq) is propositional — you prove it. Definitional equality is what the kernel decides automatically (beta/iota/delta/zeta + UIP forSProp). The gap is a constant source of subtle bugs and the reasonrewriteexists. PropvsSetvsType:Prop(impredicative, eliminates only intoPropmodulo singleton elimination),Set(predicativeType@{0}, basically deprecated as a separate concept — most code usesType),Type@{i}(predicative hierarchy). Universe polymorphism (Polymorphic Definition foo ...) is opt-in but increasingly common.Programmode + obligations:Program Definition/Program Fixpointlets you write a definition with_holes that get turned into proof obligations. Useful for sigma-type-laden code.- MetaCoq: A Coq plugin that defines Coq’s term language as a Coq inductive type, providing
quoteandunquoteplus a verified type-checker (SafeChecker) and a verified erasure pipeline. The basis for trusted reflection. https://metacoq.github.io/ - Module system + functors: Parametrize a
Moduleby aModule Type. Used heavily byMSets/FMaps. Notation:Module Foo (X : ORDERED) <: SET. ... End Foo. - Notation system:
NotationandReserved Notationdefine mixfix operators with precedence and associativity, scoped viaOpen Scope/Bind Scope. Powerful (mathcomp leans on it) and infamous for parsing-conflict errors. Equationsplugin: Industrial-strength dependent pattern matching withwith/rec/by, eliminator generation (funelim), and graph reasoning. https://mattam82.github.io/Coq-Equations/native_computevsvm_compute:vm_computereduces via Coq’s bytecode interpreter (always available, ~100× faster thansimpl).native_computecompiles to native via OCaml — another 10-50× on heavy proofs but pulls OCaml at proof time.- 2025 Rocq rename + governance: The “Coq” name had grown awkward in international and modern contexts (multiple languages, multiple connotations). After a community poll the Core team chose Rocq (homophone of “rock”, honoring Rocquencourt, the original Inria site). Renaming touched binary names (
coqtop→rocq top,coqc→rocq compile) and the file extensions remain.v. Backward-compat aliases retained for one major release. (https://rocq-prover.org/news/2025-05-14-rename-rocq.html, https://rocq-prover.org/about) - Famous formalizations:
- CompCert (Leroy et al., 2006-) — verified optimizing C compiler. https://compcert.org/
- Four-Color Theorem (Gonthier, 2005) — first major proof done in Coq with reflection.
- Feit-Thompson Odd Order Theorem (Gonthier et al., 2012) — 170,000 lines of Coq across mathcomp.
- VST (Verified Software Toolchain) — Hoare-logic verification for C. https://vst.cs.princeton.edu/
- Iris (https://iris-project.org/) — concurrent separation logic framework.
Idioms & style
- Naming:
lowerCamelCasefor definitions in core (addn,subnin mathcomp); some libraries usesnake_case. Theorems read like sentences:Nat.add_comm. Tactics named with terse mnemonics by convention. - Formatter / linter: No standard formatter. The Rocq Platform CI enforces compile-clean across versions; mathcomp imposes its own style (“small-scale reflection”) with a strong preference for
Booleanpropositions overProppropositions (so they’re decidable andapply-able withcase/elim). - Idiomatic patterns: Use
Propfor specifications; reflect toboolfor computation (mathcomp’s==,<=returningboolis canonical). Prefersimpl in *; auto with arithstyle chains; tag lemmas into hint dbs early; structure proofs with;(sequential),;[ t1 | t2 ](per-goal). - What experts look for: Short reflective proofs; absence of
Admitted/Axiom; correct use ofPolymorphic/Universe Polymorphic; careful kernel-checked extraction; mathcomp-style modules/sections.
Ecosystem
- mathcomp (https://math-comp.github.io/) — small-scale reflection library; the standard for serious algebra/combinatorics.
- stdpp + Iris (https://iris-project.org/) — concurrent separation logic + a productivity layer over the stdlib.
- CompCert — verified C compiler (https://compcert.org/).
- VST — Verified Software Toolchain.
- Equations — practical dependent pattern matching.
- MetaCoq — Coq-in-Coq.
- Coq-Elpi (https://github.com/LPCIC/coq-elpi) — λProlog inside Coq for writing tactics and elaboration extensions; powers HB (Hierarchy Builder) for class hierarchies.
- HB / Hierarchy Builder — algebra/type-class hierarchy construction (https://math-comp.github.io/hierarchy-builder/).
- Rocq Platform — curated distribution.
Gotchas
Qed.vsDefined.:Qed.makes the proof opaque (kernel checks but body becomes inaccessible).Defined.keeps it transparent (necessary for proofs you’ll compute on later, e.g., dependent definitions).Admitted.: Records the goal as an axiom — the proof is incomplete. Easy to miss in a large project; CI should grep for it.- Universe inconsistencies: Cryptic errors when two stacks of
Typecollide. AddSet Universe Polymorphism.or use explicit universe annotations. - Dependent pattern matching is painful without
Equations. The built-inmatchhas the “convoy pattern” trap and limited support for indexed types. Ltacis dynamically typed. A typo in a tactic name only fails at proof time. Ltac2 fixes this — migrate when possible.simplis inscrutable: Its reduction strategy is heuristic and version-dependent. Usecbn(more predictable) orvm_compute/native_computefor closed terms.- Notation conflicts: Two libraries that both
Open Scopesomething can produce parse errors that look unrelated. Fix with explicit scope keys ((x + y)%nat). - Module-system performance cliff: Heavy use of functors slows everything. Mathcomp uses canonical structures + HB instead.
- The 2025 rename does not change
.vfiles, but tooling (coq_makefile,coqdep, IDE configs) may need updating to therocqbinaries. Old documentation undercoq.inria.frredirects torocq-prover.org.
Citations
- https://rocq-prover.org/ — Official Rocq Prover site.
- https://rocq-prover.org/news/2025-05-14-rename-rocq.html — 2025 rename announcement.
- https://rocq-prover.org/about — governance and history.
- https://rocq-prover.org/refman/ — reference manual.
- https://rocq-prover.org/refman/proof-engine/ltac2.html — Ltac2 reference.
- https://rocq-prover.org/refman/using/tools/plugin.html — plugin / OCaml extension API.
- https://metacoq.github.io/ — MetaCoq.
- https://mattam82.github.io/Coq-Equations/ — Equations plugin.
- https://math-comp.github.io/ — Mathematical Components / mathcomp.
- https://compcert.org/ — CompCert verified C compiler.
- https://iris-project.org/ — Iris separation logic.
- https://github.com/rocq-prover/rocq/releases — release history (Rocq 9.x onward).
- Coquand & Huet, The Calculus of Constructions, INRIA RR-0530, 1986. https://hal.inria.fr/inria-00076024