discrete: they all have decidable equality: the operator (_ == _) is available on all of them.
Extensive documentation in the header of:
This is how mathematical structures are defined in the library.
We define structures as sets of mixins
(they look more like traits
in object oriented slang)
Adding a structure is adding more mixins and packaging them into structures.
We need a factory and builders
Hierarchy Builder (HB) now automatically recognizes that hasPredOnC can define a Funny.type and only that, hence the failing structure definition. Now, one can use the factory hasPredOnC instead of hasFunnyPred to define a Funny.type.
We provide an injection with explicit partial inverse, from int to nat + nat, this will be enough to provide the mixins for equality, countable and choice types.
We create the mixins for equality, countable and choice types from this injection, and gradually inhabit the hierarchy.
We now create the abelian group structure of integers (here called Z-module), from scratch, introducing the operators and proving exactly the required properties.
Remark: we may develop here a piece of abelian group theory which is specific to the theory of integers. E.g.
This time, we will build directly a rich commutative ring factory first and use it to instanciate both the ring structure and the commutative ring struture at the same time. This is not only an economy of space, but an economy of proofs, since the commutativity property reduces the number of ring axioms to prove.
The two most important things to get your way out of a situation:
For that you have the ssreflect Search command. To use its full power, one should combine seach by identifier (Coq definition), pattern (partial terms) and name (a string contained in the name of the theorem).
The two first methods are straightforward to use (except if you instanciate your patterns more than necessary), but searching by name requires to be aware of naming conventions.
(condition_)?mainSymbol_suffixes
mainSymbol_suffixes(_condition)?
Or in the presence of a property denoted by a nary or unary predicate:
naryPredicate_mainSymbol+
mainSymbol_unaryPredicate
mainSymbolis the most meaningful part of the lemma. It generally is the head symbol of the right-hand side of an equation or the head symbol of a theorem. It can also simply be the main object of study, head symbol or not. It is usually either
opp
, add
, mul
, etc...
canonicaloperation, such as a ring morphism or a subtype predicate. e.g.
linear
, raddf
, rmorph
, rpred
, etc ...
conditionis used when the lemma applies under some hypothesis.
suffixesare there to refine what shape and/or what other symbols the lemma has. It can either be the name of a symbol (
add,
mul, etc...), or the (short) name of a predicate (
inj
for injectivity
, id
for identity, ...) or an abbreviation.
Abbreviations are in the header of the file which introduce them. We list here the main abbreviations.
andbA : associative andb.
orbACA : (a || b) || (c || d) = (a || c) || (b || d).
andbb : idempotent andb.
andbC : commutative andb
,
or predicate complement, as in predC.
predD.
negbFE : ~~ b = false -> b
.
andbF : b && false = false.
addbI : right_injective addb
or predicate intersection, as in predI.
andb_orl : left_distributive andb orb.
andbN : a && (~~ a) = false.
andP : reflect (a /\ b) (a && b)
.
orb_andr : right_distributive orb andb.
andbT: right_id true andb.
predU
.
in1W : {in D, forall x, P} -> forall x, P.
addr0 : x + 0 = x.
mulr1 : x * 1 = x.
linearD : f (u + v) = f u + f v.
opprB : - (x - y) = y - x.
invfM : (x * y)^-1 = x^-1 * y^-1.
raddfMn : f (x *+ n) = f x *+ n.
mulNr : (- x) * y = - (x * y).
mulVr : x^-1 * x = 1.
rmorphX : f (x ^+ n) = f x ^+ n.
linearZ : f (a *: v) = s *: f v.
Search "prefix" "suffix"* (symbol|pattern)* in library.
Instead of reasonning using (_ %| _) and (_ %% _), we switch to 'Z_p
There is a notion of subobject for a few algebraic concepts.
sT := {x : T | P x}
is a way to form a
sigma-type. We say it is a subtype if there is only one
element it sT
for each element in
T
. This happens when P
is a boolean
predicate. Another way to form a subtype is to create a record :
Record sT := ST {x : T; px : P x}
.
val : sT -> T
, insub : T -> option sT
and
insubd : sT -> T -> sT
.
val_inj, val_eqE, val_insubd, insubdK
and insub
Substructures are subtypes that happen to have the same structure as their base type.
There are special factories to instantiate them easily.
Moreover, when a predicate is declared as a structure preserving predicate, we can use it to declare a substructure automatically (see exercise session).