Rocq

From Vero - Wikipedia
Jump to navigation Jump to search

Template:Short description Template:Use dmy dates Template:Infobox software

File:Coq 8.5 stdlib proof.png
An interactive proof session in CoqIDE, showing the proof script on the left and the proof state on the right.

The Rocq Prover (formerly named Coq) is an interactive theorem prover first released in 1989. It allows the expression of mathematical assertions, mechanical checking of proofs of these assertions, assists in finding formal proofs using proof automation routines and extraction of a certified program from the constructive proof of its formal specification.

Rocq works within the theory of the calculus of inductive constructions, a derivative of the calculus of constructions. Rocq is not an automated theorem prover but includes automatic theorem proving tactics (procedures) and various decision procedures.

The Association for Computing Machinery awarded Thierry Coquand, Gérard Huet, Christine Paulin-Mohring, Bruno Barras, Jean-Christophe Filliâtre, Hugo Herbelin, Chetan Murthy, Yves Bertot, and Pierre Castéran with the 2013 ACM Software System Award for Rocq (when it was named Coq).

Overview

When viewed as a programming language, Rocq implements a dependently typed functional programming model;<ref>A Tour of Rocq</ref> when viewed as a logical system, it implements a higher-order type theory. The development of Rocq has been supported since 1984 by French Institute for Research in Computer Science and Automation (INRIA), in collaboration with many other French and international research institutions. The development of Rocq was initiated by Gérard Huet and Thierry Coquand, and more than 200 people,<ref>A Brief History</ref> mainly researchers, have contributed features to the core system since its inception. The implementation team has successively been coordinated by Gérard Huet, Christine Paulin-Mohring, Hugo Herbelin, and Matthieu Sozeau. Rocq is mainly implemented in OCaml with a bit of C. The core system can be extended by way of a plug-in mechanism.<ref>Template:Cite book</ref>

Rocq provides a specification language named Gallina.<ref> Template:Cite book</ref> Programs written in Gallina have the weak normalization property, implying that they always terminate. This is a distinctive property of the language, since infinite loops (non-terminating programs) are common in other programming languages.<ref> Adam Chlipala. "Certified Programming with Dependent Types": "Library GeneralRec". "Library InductiveTypes". </ref>

As an example of a proof written in Rocq, consider a proof of a lemma which states that taking the successor of a natural number flips its parity. The fold-unfold tactic introduced by Danvy<ref>Template:Cite journal</ref> is used to help keep the proof simple.<syntaxhighlight lang="coq" style="width:80%;"> Ltac fold_unfold_tactic name := intros; unfold name; fold name; reflexivity.

Require Import Arith Nat Bool.

Fixpoint is_even (n : nat) : bool :=

 match n with
 | 0 =>
   true
 | S n' =>
   eqb (is_even n') false
 end.

Lemma fold_unfold_is_even_0:

 is_even 0 = true.

Proof.

 fold_unfold_tactic is_even.

Qed.

Lemma fold_unfold_is_even_S:

 forall n' : nat,
   is_even (S n') = eqb (is_even n') false.

Proof.

 fold_unfold_tactic is_even.

Qed.

Lemma successor_flips_evenness:

 forall n : nat,
   is_even n = negb (is_even (S n)).

Proof.

 intro n.
 rewrite -> (fold_unfold_is_even_S n).
 destruct (is_even n).
 * simpl.
   reflexivity.
 * simpl.
   reflexivity.

Qed.

</syntaxhighlight>

Notable uses

Four color theorem and SSReflect extension

Georges Gonthier of Microsoft Research in Cambridge, England and Benjamin Werner of INRIA used Rocq to create a surveyable proof of the four color theorem, which was completed in 2002.<ref name=":0">Template:Cite journal</ref> Their work led to the development of the SSReflect ("Small Scale Reflection") package, which was a significant extension to Rocq.<ref>Template:Cite journal</ref> Despite its name, most of the features added to Rocq by SSReflect are general-purpose features and are not limited to the computational reflective programming style of proof. These features include:

  • Added convenient notations for irrefutable and refutable pattern matching, on inductive types with one or two constructors
  • Implicit arguments for functions applied to zero arguments, which is useful when programming with higher-order functions
  • Concise anonymous arguments
  • An improved set tactic with more powerful matching
  • Support for reflection

SSReflect is distributed as part of the main Rocq distribution since Coq 8.7.<ref>Template:Cite web</ref>

Other applications

Template:See also

Tactic language

In addition to constructing Gallina terms explicitly, Rocq supports the use of tactics written in the built-in language Ltac or in OCaml. These tactics automate the construction of proofs, carrying out trivial or obvious steps in proofs.<ref>Template:Cite journal</ref> Several tactics implement decision procedures for various theories. For example, the "ring" tactic decides the theory of equality modulo ring or semiring axioms via associative-commutative rewriting.<ref>Template:Cite book</ref> For example, the following proof establishes a complex equality in the ring of integers in just one line of proof:<ref>Template:Cite web</ref>

<syntaxhighlight lang="coq"> Require Import ZArith. Open Scope Z_scope. Goal forall a b c:Z,

   (a + b + c) ^ 2 =
    a * a + b ^ 2 + c * c + 2 * a * b + 2 * a * c + 2 * b * c.
 intros; ring.

Qed. </syntaxhighlight>

Built-in decision procedures are also available for the empty theory ("congruence"), propositional logic ("tauto"), quantifier-free linear integer arithmetic ("lia"), and linear rational/real arithmetic ("lra").<ref>Template:Cite book</ref><ref>Template:Cite web</ref> Further decision procedures have been developed as libraries, including one for Kleene algebras<ref>Template:Cite conference</ref> and another for certain geometric goals.<ref>Template:Cite book</ref>

Name

File:Coq logo.png
Former logo

The old name Template:Lang means 'rooster' in French and is a wordplay on the name of Thierry Coquand, calculus of constructions or CoC, and stems from a French tradition of naming research development tools after animals.<ref>Template:Cite web</ref> Until 1991, Coquand was implementing a language named the calculus of constructions and it was simply called CoC then. In 1991, a new implementation based on the extended calculus of inductive constructions was begun and the name changed from CoC to Coq in an indirect reference to Coquand, who developed the calculus of constructions along with Gérard Huet and contributed to the calculus of inductive constructions with Christine Paulin-Mohring.<ref>Template:Cite web</ref>

On October 11, 2023, the development team announced that Coq would be renamed The Rocq Prover in coming months, and began updating the code base, website, and related tools.<ref>Template:Cite web</ref> The official renaming happened with the release of Rocq 9.0 in March 2025.<ref>Template:Cite web</ref>

The new name refers to Inria Rocquencourt, where the system was developed first, and is related to the mythical bird Roc, which allows keeping the bird references from the prior name.<ref>Template:Cite web</ref>

See also

Template:Portal

References

Template:Reflist

Template:Commons category

Textbooks
Tutorials

Template:ML programming