Coq is a formal proof management system. It provides
The land of formal methods includes
Formalization of mathematics:
Education: it's a proof assistant.
Language | files | code |
---|---|---|
OCaml | 949 | 203230 |
Coq | 1970 | 196057 |
TeX | 26 | 5270 |
Markdown | 22 | 3362 |
Bourne Shell | 107 | 2839 |
… |
Language | files | code |
---|---|---|
HTML :) | 377 | 299260 |
Coq | 92 | 83726 |
JavaScript | 13 | 34363 |
CSS | 6 | 1199 |
… |
@vj_chidambaram
: Even verified file systems have unverified parts :)Language | files | code |
---|---|---|
Coq | 98 | 81049 |
C | 36 | 4132 |
Haskell | 8 | 1091 |
OCaml | 10 | 687 |
Python | 9 | 643 |
… |
Language | files | code |
---|---|---|
Coq | 223 | 146226 |
C | 223 | 65053 |
OCaml | 147 | 28381 |
C/C++ Header | 86 | 7834 |
Assembly | 59 | 1542 |
… |
Calculus of Inductive Constructions
Just some keywords:
toychain - A Coq implementation of a minimalistic blockchain-based consensus protocol
containers
library against specs derived from
Inductive le : nat -> nat -> Prop := | Le0 : forall n, le 0 n | LeSS : forall {n m}, le n m -> le (S n) (S m). Definition four_le_five : le 4 5 := LeSS (LeSS (LeSS (LeSS (Le0 1)))).
Fixpoint leb (n m : nat) : bool := match n, m with | O, _ => true | _, O => false | S n', S m' => le n' m' end. Coercion is_true b := b = true. Definition four_le_five : leb 4 5 := eq_refl.
Fixpoint leb (n m : nat) : bool := match n, m with | O, _ => true | _, O => false | S n', S m' => le n' m' end. Coercion is_true b := b = true. Definition four_le_five : is_true (leb 4 5) := eq_refl.
Inductive reflect (P : Prop) : bool -> Set := | ReflectT : P -> reflect P true | ReflectF : ~ P -> reflect P false
Variant cmp_nat m n : bool -> bool -> bool -> bool -> bool -> bool -> Set := | CompareNatLt of m < n : cmp_nat m n true false true false false false | CompareNatGt of m > n : cmp_nat m n false true false true false false | CompareNatEq of m = n : cmp_nat m n true true false false true true. Lemma ltngtP m n : cmp_nat m n (m <= n) (n <= m) (m < n) (n < m) (n == m) (m == n).
eq_op : (T : Type) -> (x y : T) -> bool Notation "x == y" := (eq_op _ x y).
eq_op
is not possible to implement in generalStructure eqType := Pack { sort : Type; eq_op : sort -> sort -> bool; spec : forall x y, eq_op x y = true <-> x = y }.
Structure eqType := Pack { sort : Type; eq_op : sort -> sort -> bool; spec : forall x y, eq_op x y = true <-> x = y }. Coercion sort : eqType >-> Sortclass.
Structure eqType := Pack { sort : Type; eq_op : sort -> sort -> bool; spec : forall x y, eq_op x y = true <-> x = y }. Coercion sort : eqType >-> Sortclass. Lemma eq_sym (T : eqType) (x y : T) : x == y -> y == x.
Structure eqType := Pack { sort : Type; eq_op : sort -> sort -> bool; spec : forall x y, eq_op x y = true <-> x = y }.
eq_op : (T : eqType) -> (x y : sort T) -> bool
initially we have
1 == 2
unfold notation
eq_op _ 1 2
add types and names
eq_op (?s : eqType) (1 : sort ?s) (2 : sort ?s)
add types and names
eq_op (?s : eqType) (1 : sort ?s) (2 : sort ?s)
add types and names
eq_op (?s : eqType) (1 : sort ?s) (2 : sort ?s) eq_op (?s : eqType) (1 : nat) (2 : nat)
so we need to be able to solve equations like
sort (?s : eqType) = nat
Canonical nat_eqType := Pack nat eqn proof.
Print Canonical Projections.
...
nat <- sort ( nat_eqType )
...
eq_op (?s : eqType) (1 : sort ?s) (2 : sort ?s) eq_op (?s : eqType) (1 : nat) (2 : nat)
nat <- sort ( nat_eqType ) eq_op (?s : eqType) (1 : sort ?s) (2 : sort ?s) | | v v eq_op (?s : eqType) (1 : nat) (2 : nat)
nat <- sort ( nat_eqType ) eq_op (nat_eqType : eqType) (1 : sort nat_eqType) (2 : sort nat_eqType)
Definition pair_eq (A B : eqType) (u v : A * B) := (u.1 == v.1) && (u.2 == v.2).
Definition pair_eq (A B : eqType) (u v : A * B) := (u.1 == v.1) && (u.2 == v.2). Canonical prod_eqType A B := Pack (A * B) pair_eq proof.
Definition pair_eq (A B : eqType) (u v : sort A * sort B) := (u.1 == v.1) && (u.2 == v.2). Canonical prod_eqType A B := Pack (sort A * sort B) pair_eq proof.
Definition pair_eq (A B : eqType) (u v : sort A * sort B) := (u.1 == v.1) && (u.2 == v.2). Canonical prod_eqType A B := Pack (sort A * sort B) pair_eq proof. Print Canonical Projections. ... prod <- sort ( prod_eqType ) ...
Compute (1, true) == (1, true).
Compute (1, true) == (1, true). true
(1, true) == (1, true)
desugars into
eq_op _ (1, true) (1, true)
eq_op : (?T : eqType) -> (x y : sort T) -> bool eq_op _ (1, true) .. nat * bool
eq_op : (?T : eqType) -> (x y : sort T) -> bool eq_op _ (1, true) .. nat * bool sort ?T ≡ nat * bool
eq_op : (?T : eqType) -> (x y : sort T) -> bool eq_op _ (1, true) .. nat * bool sort ?T ≡ prod nat bool
eq_op : (?T : eqType) -> (x y : sort T) -> bool eq_op _ (1, true) .. nat * bool sort ?T ≡ prod nat bool prod <- sort ( prod_eqType )
eq_op : (?T : eqType) -> (x y : sort T) -> bool eq_op _ (1, true) .. nat * bool sort ?T ≡ prod nat bool prod <- sort ( prod_eqType ) sort (prod_eqType ?A ?B) ≡ prod nat bool
eq_op : (?T : eqType) -> (x y : sort T) -> bool eq_op _ (1, true) .. nat * bool sort ?T ≡ prod nat bool prod <- sort ( prod_eqType ) sort (prod_eqType ?A ?B) ≡ prod nat bool (sort ?A) * (sort ?B) ≡ prod nat bool
eq_op : (?T : eqType) -> (x y : sort T) -> bool eq_op _ (1, true) .. nat * bool sort ?T ≡ prod nat bool prod <- sort ( prod_eqType ) sort (prod_eqType ?A ?B) ≡ prod nat bool prod (sort ?A) (sort ?B) ≡ prod nat bool
eq_op : (?T : eqType) -> (x y : sort T) -> bool eq_op _ (1, true) .. nat * bool sort ?T ≡ prod nat bool prod <- sort ( prod_eqType ) sort (prod_eqType ?A ?B) ≡ prod nat bool prod (sort ?A) (sort ?B) ≡ prod nat bool (sort ?A) = nat and (sort ?B) = bool
eauto
-like proof search
Mathcomp's bigop
module has the following:
Canonical addn_monoid := Law addnA add0n addn0. Canonical muln_monoid := Law mulnA mul1n muln1. Canonical maxn_monoid := Law maxnA max0n maxn0.