Coq (software) explained

Coq (software)
Developer:The Coq development team
Released: (version 4.10)
Operating System:Cross-platform
Language:English
Programming Language:OCaml
Genre:Proof assistant
License:LGPLv2.1

Coq is an interactive theorem prover first released in 1989. It allows for expressing mathematical assertions, mechanically checks proofs of these assertions, helps find formal proofs, and extracts a certified program from the constructive proof of its formal specification. Coq works within the theory of the calculus of inductive constructions, a derivative of the calculus of constructions. Coq 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 Coq.

The name "Coq" is a wordplay on the name of Thierry Coquand, Calculus of Constructions or "CoC" and follows the French computer science tradition of naming software after animals (coq in French meaning rooster).[1] On October 11th, 2023, the development team announced that Coq will be renamed "The Rocq Prover" in the coming months, and has started updating the code base, website and associated tools.[2]

Overview

When viewed as a programming language, Coq implements a dependently typed functional programming language;[3] when viewed as a logical system, it implements a higher-order type theory. The development of Coq has been supported since 1984 by INRIA, now in collaboration with École Polytechnique, University of Paris-Sud, Paris Diderot University, and CNRS. In the 1990s, ENS Lyon was also part of the project. The development of Coq was initiated by Gérard Huet and Thierry Coquand, and more than 40 people, 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. Coq is mainly implemented in OCaml with a bit of C. The core system can be extended by way of a plug-in mechanism.[4]

The name means 'rooster' in French and stems from a French tradition of naming research development tools after animals.[5] Up until 1991, Coquand was implementing a language called the Calculus of Constructions and it was simply called CoC at this time. In 1991, a new implementation based on the extended Calculus of Inductive Constructions was started and the name was 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.[6]

Coq provides a specification language called Gallina[7] ("hen" in Latin, Spanish, Italian and Catalan).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,[8] and is one way to avoid the halting problem.

As an example, a proof of commutativity of addition on natural numbers in Coq:

plus_comm =fun n m : nat =>nat_ind (fun n0 : nat => n0 + m = m + n0) (plus_n_0 m) (fun (y : nat) (H : y + m = m + y) => eq_ind (S (m + y)) (fun n0 : nat => S (y + m) = n0) (f_equal S H) (m + S y) (plus_n_Sm m y)) n : forall n m : nat, n + m = m + n

stands for mathematical induction, for substitution of equals, and for taking the same function on both sides of the equality. Earlier theorems are referenced showing

m=m+0

and

S(m+y)=m+Sy

.

Notable uses

Four color theorem and SSReflect extension

Georges Gonthier of Microsoft Research in Cambridge, England and Benjamin Werner of INRIA used Coq to create a surveyable proof of the four color theorem, which was completed in 2002.[9] Their work led to the development of the SSReflect ("Small Scale Reflection") package, which was a significant extension to Coq.[10] Despite its name, most of the features added to Coq by SSReflect are general-purpose features and are not limited to the computational reflection style of proof. These features include:

SSReflect 1.11 is freely available, dual-licensed under the open source CeCILL-B or CeCILL-2.0 license, and compatible with Coq 8.11.[11]

Other applications

an optimizing compiler for almost all of the C programming language which is largely programmed and proven correct in Coq.

correctness proof in Coq was published in 2007.[12]

formal proof using Coq was completed in September 2012.[13]

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 Coq.[14] [15]

Tactic language

In addition to constructing Gallina terms explicitly, Coq 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.[16] 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.[17] For example, the following proof establishes a complex equality in the ring of integers in just one line of proof:[18]

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

See also

External links

Textbooks
Tutorials

Notes and References

  1. Web site: Alternative names · coq/coq Wiki. 3 March 2023. GitHub. en.
  2. Web site: Coq roadmap 069 . .
  3. http://coq.inria.fr/a-short-introduction-to-coq A short introduction to Coq
  4. Book: Avigad . Jeremy . Mahboubi . Assia . Interactive Theorem Proving: 9th International Conference, ITP 2018, Held as ... . 3 July 2018 . Springer . 9783319948218 . 21 October 2018.
  5. Web site: Frequently Asked Questions. . 2019-05-08.
  6. Web site: Introduction to the Calculus of Inductive Constructions . 21 May 2019.
  7. Adam Chlipala."Certified Programming with Dependent Types":"Library Universes".
  8. Adam Chlipala."Certified Programming with Dependent Types":"Library GeneralRec"."Library InductiveTypes".
  9. Gonthier . Georges . Formal Proof—The Four-Color Theorem . . 55 . 2008. 11 . 1382–1393 . 2463991.
  10. Gonthier . Georges . Mahboubi . Assia . 10.6092/ISSN.1972-5787/1979 . 2 . Journal of Formalized Reasoning . 95–152 . An introduction to small scale reflection in Coq . 3 . 2010.
  11. Web site: The Mathematical Components Library 1.11.0. .
  12. Conchon . Sylvain . Filliâtre . Jean-Christophe . Russo . Claudio V. . Dreyer . Derek . A persistent union-find data structure . 10.1145/1292535.1292541 . 37–46 . Association for Computing Machinery . Proceedings of the ACM Workshop on ML, 2007, Freiburg, Germany, October 5, 2007 . 2007.
  13. Web site: Feit-Thompson theorem has been totally checked in Coq . Msr-inria.inria.fr . 2012-09-20 . 2012-09-25 . https://web.archive.org/web/20161119094854/http://www.msr-inria.fr/news/feit-thomson-proved-in-coq/ . 2016-11-19 . dead .
  14. Web site: 2024-07-02 . [July 2nd 2024] We have proved "BB(5) = 47,176,870" ]. 2024-07-02 . The Busy Beaver Challenge . en.
  15. Web site: The Busy Beaver Challenge . 2024-07-02 . bbchallenge.org . en.
  16. Kaiser . Jan-Oliver . Ziliani . Beta . Krebbers . Robbert . Régis-Gianas . Yann . Dreyer . Derek . 2018-07-30 . Mtac2: typed tactics for backward reasoning in Coq . Proceedings of the ACM on Programming Languages . 2 . ICFP . 78:1–78:31 . 10.1145/3236773. free . 21.11116/0000-0003-2E8E-B . free .
  17. Book: Grégoire . Benjamin . Mahboubi . Assia . 2005 . Hurd . Joe . Melham . Tom . Proving Equalities in a Commutative Ring Done Right in Coq . Theorem Proving in Higher Order Logics: 18th International Conference, TPHOLs 2005, Oxford, UK, August 22–25, 2005, Proceedings . Lecture Notes in Computer Science . en . Berlin, Heidelberg . Springer . 98–113 . 10.1007/11541868_7 . 978-3-540-31820-0.
  18. Web site: The ring and field tactic families — Coq 8.11.1 documentation . 2023-12-04 . coq.inria.fr.
  19. Book: Besson, Frédéric . 2007 . Altenkirch . Thorsten . McBride . Conor . Fast Reflexive Arithmetic Tactics the Linear Case and Beyond . https://link.springer.com/chapter/10.1007/978-3-540-74464-1_4 . Types for Proofs and Programs: International Workshop, TYPES 2006, Nottingham, UK, April 18–21, 2006, Revised Selected Papers . Lecture Notes in Computer Science . 4502 . en . Berlin, Heidelberg . Springer . 48–62 . 10.1007/978-3-540-74464-1_4 . 978-3-540-74464-1.
  20. Web site: Micromega: solvers for arithmetic goals over ordered rings — Coq 8.18.0 documentation . 2023-12-04 . coq.inria.fr.
  21. Braibant . Thomas . Pous . Damien . 2010 . Kaufmann . Matt . Paulson . Lawrence C. . An Efficient Coq Tactic for Deciding Kleene Algebras . Interactive Theorem Proving: First International Conference, ITP 2010 Edinburgh, UK, July 11-14, 2010, Proceedings. Lecture Notes in Computer Science . en . Berlin, Heidelberg . Springer . 163–178 . 10.1007/978-3-642-14052-5_13 . 978-3-642-14052-5. 3566183 .
  22. Book: Narboux, Julien . 2004 . Slind . Konrad . Bunker . Annette . Gopalakrishnan . Ganesh . A Decision Procedure for Geometry in Coq . https://link.springer.com/chapter/10.1007/978-3-540-30142-4_17 . Theorem Proving in Higher Order Logics: 17th International Conference, TPHOLS 2004, Park City, Utah, USA, September 14–17, 2004, Proceedings . Lecture Notes in Computer Science . 3223 . en . Berlin, Heidelberg . Springer . 225–240 . 10.1007/978-3-540-30142-4_17 . 978-3-540-30142-4. 11238876 .