(edits are also saved when you close the window). Finally you can
Roadmap for lessons 3 and 4
- finite types
- big operators
Lesson 3
- The math-comp library gives some support for finite types.
- 'I_n is the the set of natural numbers smaller than n.
- a : 'I_n is composed of a value m and a proof that m < n.
- Example : oid modifies the proof part with an equivalent one.
Note
- nat_of_ord is a coercion (see H)
- 'I_0 is an empty type
Equality
- Every finite type is also an equality type.
- For 'I_n, only the numeric value matters (the proof is irrelevant)
- This characteristic comes with the notion of subtype.
together with a function val (injection from the subtype to the
larger type)
An optimistic map from nat to ordinal : inord
- Takes a natural number as input and return an element of 'I_n.+1
- The same number if it is small enough, otherwise 0.
- The expected type has to have the shape 'I_n.+1 because 'I_0 is empty
Note
- The equality in inordK is in type nat
- The equality in inord_val is in type 'I_n.+1
Sequence
- a finite type can be seen as a sequence
- if T is a finite type, enum T gives this sequence.
- it is duplicate free.
- it relates to the cardinal of a finite type
Note
- None of the lines before by [] are needed for the proof
- mem_enum et enum_uniq are generic theorems for any predicate
on the finite type (practically: subsets)
- In this excerpt, we start a habit of making some theorems appear
in the context, under the same or a similar name, just for
scrutiny (here mem_enum, enum_uniq, cardT, and cardE
Boolean theory of finite types.
- for finite type, boolean reflection can be extended to quantifiers
- getting closer to classical logic!
Note
- Small scale reflection is used in several places here.
- The equality in inord_val is in type 'I_n.+1
Selecting an element
- pick selects an element that has a given property
- pickP triggers the reflection
Building finite types
- The property of finiteness is inherited through a large variety of
type constructors
- For instance, when constructing a cartesian product of finite types
- For functions there is an explicit construction ffun x => body
Note
- Equipping an arbitrary type that is provably finite with
the finType structure will be done in a later lesson
Big operators
- Big operators provide a library to manipulate iterations in math-comp
- this is an encapsulation of the fold function
Notation
- iteration is provided by the \big notation
- the basic operation is on list
- special notations are introduced for usual case (\sum, \prod, \bigcap ..)
Range
- different ranges are provided
Filtering
- it is possible to filter elements from the range
Switching range
- it is possible to change representation (big_nth, big_mkord).
Big operators and equality
- one can exchange function and/or predicate
Monoid structure
- one can use associativity to reorganize the bigop
Abelian Monoid structure
- one can use communitativity to massage the bigop
Distributivity
- one can exchange sum and product
Property, Relation and Morphism