(credits: Pierre Letouzey and Pierre Casteran)
In this class, we shall present how the type system of Coq allows us to express properties of programs
and/or mathematical objects. We will try to show the great expressive power of
this formalism, mostly by examples.e and
e'.
Some
very basic Propositions
Let e and e' be two expressions of
the same type. We can build a proposition
which expresses the equality between e and
e'.
Building
Propositions from Predicates
A predicate is a function returning
a proposition.
Propositions
vs. boolean values
Do not be
mistaken :
A proposition (in Prop) usually cannot be computed much, but can
be a Coq statement that we can (try to) prove.
Example of
propositions :True, False, 1=2, ...
A boolean (in bool ) is a Coq expression
that can be computed to the values true or false. A boolean can be used in programs
but not directly in statements.
Notice that the
following examples are well formed propositions :
Quantifiers
and Connectives
The following
are well-formed propositions :
There exists some useful notations
for nested quantifiers, which we shall present in further examples.
Negation (not, ∼)
Implication
(→, -> in ascii)
Disjunction
(or, \/)
Conjunction (and, /\)
Logical
Equivalence (iff, ↔, <-> in ascii)
Building
new predicates
The is_square_root can be used to specify a square root function : If you
build a sqrt function,
you will want to prove that :
Predicates can be built either
directly, or inductively, or recursively. For instance, given a type A, membership in a (list
A) can be written :
Specifying
a merge function
Quantifying
over propositions and predicates
Quantification
over types
A
Little Case Study