Rocq

From Wikipedia, the free encyclopedia
(Redirected from Coq (software))
Jump to navigation Jump to search

The Rocq Prover
Original authorsThierry Coquand, Gérard Huet, Christine Paulin-Mohring, Bruno Barras, Jean-Christophe Filliâtre, Hugo Herbelin, Chetan Murthy, Yves Bertot, Pierre Castéran
DevelopersINRIA, École Polytechnique, University of Paris-Sud, Paris Diderot University, CNRS, ENS Lyon
Initial release1 May 1989; 37 years ago (1989-05-01) (version 4.10)
Repositorygithub.com/rocq-prover/rocq
Written inOCaml
Engine
    Lua error in Module:EditAtWikidata at line 29: attempt to index field 'wikibase' (a nil value).
    Operating systemCross-platform
    Available inEnglish
    TypeProof assistant
    LicenseLGPLv2.1
    Websiterocq-prover.org
    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

    [edit | edit source]

    When viewed as a programming language, Rocq implements a dependently typed functional programming model;[1] 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,[2] 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.[3]

    Rocq provides a specification language named Gallina.[4] 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.[5]

    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[6] is used to help keep the proof simple.

    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.
    

    Notable uses

    [edit | edit source]

    Four color theorem and SSReflect extension

    [edit | edit source]

    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.[7] Their work led to the development of the SSReflect ("Small Scale Reflection") package, which was a significant extension to Rocq.[8] 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.[9]

    Other applications

    [edit | edit source]
    • CompCert: an optimizing compiler for almost all of the C programming language which is largely programmed and proven correct in Rocq.
    • Disjoint-set data structure: correctness proof in Rocq was published in 2007.[10]
    • Feit–Thompson theorem: formal proof using Rocq was completed in September 2012.[11]
    • Busy beaver: The value of the 5-state winning busy beaver was discovered by Heiner Marxen and Jürgen Buntrock in 1989, but only proved to be the winning fifth busy beaver — stylized as BB(5) — in 2024 using a proof in Rocq.[12][13]

    Tactic language

    [edit | edit source]

    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.[14] 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.[15] For example, the following proof establishes a complex equality in the ring of integers in just one line of proof:[16]

    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.
    

    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").[17][18] Further decision procedures have been developed as libraries, including one for Kleene algebras[19] and another for certain geometric goals.[20]

    File:Coq logo.png
    Former logo

    The old name Coq 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.[21] 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.[22] 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.[23] The official renaming happened with the release of Rocq 9.0 in March 2025.[24] 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.[25]

    Awards

    [edit | edit source]

    See also

    [edit | edit source]

    Lua error in mw.title.lua at line 392: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').

    References

    [edit | edit source]
    1. ^ A Tour of Rocq
    2. ^ A Brief History
    3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    5. ^ Adam Chlipala. "Certified Programming with Dependent Types": "Library GeneralRec". "Library InductiveTypes".
    6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    8. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    9. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    10. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    11. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    12. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    13. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    14. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    15. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    16. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    17. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    18. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    19. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    20. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    21. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    22. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    23. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    24. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    25. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    26. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
    [edit | edit source]
    • Lua error in Module:Official_website at line 94: attempt to index field 'wikibase' (a nil value).