(*D
-Matita Tutorial: inductively generated formal topologies
-========================================================
+Inductively generated formal topologies in Matita
+=================================================
This is a not so short introduction to [Matita][2], based on
the formalization of the paper
> inductive generation of formal topologies
by Stefano Berardi and Silvio Valentini.
-The tutorial is by Enrico Tassi.
-The tutorial spends a considerable amount of effort in defining
+The tutorial and the formalization are by Enrico Tassi.
+
+The reader should be familiar with inductively generated
+formal topologies and have some basic knowledge of type theory and Ξ»-calculus.
+
+A considerable part of this tutorial is devoted to explain how to define
notations that resemble the ones used in the original paper. We believe
-this is a important part of every formalization, not only from the aesthetic
+this is an important part of every formalization, not only from the aesthetic
point of view, but also from the practical point of view. Being
consistent allows to follow the paper in a pedantic way, and hopefully
to make the formalization (at least the definitions and proved
statements) readable to the author of the paper.
+The formalization uses the "new generation" version of Matita
+(that will be named 1.x when finally released).
+Last stable release of the "old" system is named 0.5.7; the ng system
+is coexisting with the old one in all development release
+(named "nightly builds" in the download page of Matita)
+with a version strictly greater than 0.5.7.
+
+To read this tutorial in HTML format, you need a decent browser
+equipped with a unicode capable font. Use the PDF format if some
+symbols are not displayed correctly.
+
Orienteering
------------
example W has Ξ©, π and π, L has Ξ, π, and π, F has Ξ¦, β¦
Variants are listed in the aforementioned TeX/UTF-8 table.
+The syntax of terms (and types) is the one of the Ξ»-calculus CIC
+on which Matita is based. The main syntactical difference w.r.t.
+the usual mathematical notation is the function application, written
+`(f x y)` in place of `f(x,y)`.
+
Pressing `F1` opens the Matita manual.
CIC (as [implemented in Matita][3]) in a nutshell
-------------------------------------------------
CIC is a full and functional Pure Type System (all products do exist,
-and their sort is is determined by the target) with an impedicative sort
+and their sort is is determined by the target) with an impredicative sort
Prop and a predicative sort Type. It features both dependent types and
polymorphism like the [Calculus of Constructions][4]. Proofs and terms share
-the same syntax, and they can occurr in types.
+the same syntax, and they can occur in types.
The environment used for in the typing judgement can be populated with
well typed definitions or theorems, (co)inductive types validating positivity
The CIC Ξ»-calculus is equipped with a pattern matching construct (match) on inductive
types defined in the environment. This construct, together with the possibility to
definable total recursive functions, allows to define eliminators (or constructors)
-for (co)inductive types. The Ξ»-calculus is also equipped with explicitly typed
-local definitions (let in) that in the degenerate case work as casts (i.e.
-the type annotation `(t : T)` is implemented as `let x : T β t in x`).
+for (co)inductive types.
Types are compare up to conversion. Since types may depend on terms, conversion
involves Ξ²-reduction, Ξ΄-reduction (definition unfolding), ΞΆ-reduction (local
Since we are going to formalize constructive and predicative mathematics
in an intensional type theory like CIC, we try to establish some terminology.
-Type is the sort of sets equipped with the `Id `equality (i.e. an intensional,
-not quotiented set). We will avoid using `Id` (Leibnitz equality),
-thus we will explicitly equip a set with an equivalence relation when needed.
-We will call this structure a _setoid_. Note that we will
-attach the infix `=` symbol only to the equality of a setoid,
-not to Id.
+Type is the sort of sets equipped with the `Id` equality (i.e. an intensional,
+not quotiented set).
We write `Type[i]` to mention a Type in the predicative hierarchy
of types. To ease the comprehension we will use `Type[0]` for sets,
-and `Type[1]` for classes. The index `i` is just a lable: constraints among
+and `Type[1]` for classes. The index `i` is just a label: constraints among
universes are declared by the user. The standard library defines
> Type[0] < Type[1] < Type[2]
+Matita implements a variant of CIC in which constructive and predicative proposition
+are distinguished from predicative data types.
+
+<object class="img" data="igft-CIC-universes.svg" type="image/svg+xml" width="400px"/>
+
For every `Type[i]` there is a corresponding level of predicative
-propositions `CProp[i]`. A predicative proposition cannot be eliminated toward
-`Type[j]` unless it holds no computational content (i.e. it is an inductive type
+propositions `CProp[i]` (the C initial is due to historical reasons, and
+stands for constructive).
+A predicative proposition cannot be eliminated toward
+`Type[j]` unless it holds no computational content (i.e. it is an inductive proposition
with 0 or 1 constructors with propositional arguments, like `Id` and `And`
but not like `Or`).
+The distinction between predicative propositions and predicative data types
+is a peculiarity of Matita (for example in CIC as implemented by Coq they are the
+same). The additional restriction of not allowing the elimination of a CProp
+toward a Type makes the theory of Matita minimal in the following sense:
+
+<object class="img" data="igft-minimality-CIC.svg" type="image/svg+xml" width="600px"/>
+
+Theorems proved in CIC as implemented in Matita can be reused in a classical
+and impredicative framework (i.e. forcing Matita to collapse the hierarchy of
+constructive propositions and assuming the excluded middle on them).
+Alternatively, one can decide to collapse predicative propositions and
+predicative data types recovering the Axiom of Choice in the sense of Martin LΓΆf
+(i.e. β really holds a witness and can be eliminated to inhabit a type).
+
+This implementation of CIC is the result of the collaboration with Maietti M.,
+Sambin G. and Valentini S. of the University of Padua.
+
+Formalization choices
+---------------------
+
+There are many different ways of formalizing the same piece of mathematics
+in CIC, depending on what our interests are. There is usually a trade-off
+between the possibility of reuse the formalization we did and its complexity.
+
+In this work, our decisions mainly regarded the following two areas
+
+- Axiom of Choice: controlled use or not
+- Equality: Id or not
+
+### Axiom of Choice
+
+In this paper it is clear that the author is interested in using the Axiom
+of Choice, thus choosing to identify β and Ξ£ (i.e. working in the
+leftmost box of the graph "Coq's CIC (work in CProp)") would be a safe decision
+(that is, the author of the paper would not complain we formalized something
+different from what he had in mind).
+
+Anyway, we may benefit from the minimality of CIC as implemented in Matita,
+"asking" the type system to ensure we do no use the Axiom of Choice elsewhere
+in the proof (by mistake or as a shortcut). If we identify β and Ξ£ from the
+very beginning, the system will not complain if we use the Axiom of Choice at all.
+Moreover, the elimination of an inductive type (like β) is a so common operation
+that the syntax chosen for the elimination command is very compact and non
+informative, hard to spot for a human being
+(in fact it is just two characters long!).
+
+We decided to formalize the whole paper without identifying
+CProp and Type and assuming the Axiom of Choice as a real axiom
+(i.e. a black hole with no computational content, a function with no body).
+
+It is clear that this approach give us full control on when/where we really use
+the Axiom of Choice. But, what are we loosing? What happens to the computational
+content of the proofs if the Axiom of Choice gives no content back?
+
+It really
+depends on when we actually look at the computational content of the proof and
+we "run" that program. We can extract the content and run it before or after
+informing the system that our propositions are actually code (i.e. identifying
+β and Ξ£). If we run the program before, as soon as the computation reaches the
+Axiom of Choice it stops, giving no output. If we tell the system that CProp and
+Type are the same, we can exhibit a body for the Axiom of Choice (i.e. a projection)
+and the extracted code would compute an output.
+
+Note that the computational
+content is there even if the Axiom of Choice is an axiom, the difference is
+just that we cannot use it (the typing rules inhibit the elimination of the
+existential). This is possible only thanks to the minimality of CIC as implemented
+in Matita.
+
+### Equality
+
+What we have to decide here is which models we admit. The paper does not
+mention quotiented sets, thus using an intensional equality is enough
+to capture the intended content of the paper. Nevertheless, the formalization
+cannot be reused in a concrete example where the (families of) sets
+that will build the axiom set are quotiented.
+
+Matita gives support for setoid rewriting under a context built with
+non dependent morphisms. As we will detail later, if we assume a generic
+equality over the carrier of our axiom set, a non trivial inductive
+construction over the ordinals has to be proved to respect extensionality
+(i.e. if the input is an extensional set, also the output is).
+The proof requires to rewrite under the context formed by the family of sets
+`I` and `D`, that have a dependent type. Declaring them as dependently typed
+morphisms is possible, but Matita does not provide an adequate support for them,
+and would thus need more effort than formalizing the whole paper.
+
+Anyway, in a preliminary attempt of formalization, we tried the setoid approach,
+reaching the end of the formalization, but we had to assume the proof
+of the extensionality of the `U_x` construction (while there is no
+need to assume the same property for `F_x`!).
+
+The current version of the formalization uses `Id`.
The standard library and the `include` command
----------------------------------------------
Defining Axiom set
------------------
-A set of axioms is made of a set(oid) `S`, a family of sets `I` and a
+A set of axioms is made of a set `S`, a family of sets `I` and a
family `C` of subsets of `S` indexed by elements `a` of `S`
and elements of `I(a)`.
D*)
nrecord Ax : Type[1] β {
- S :> setoid;
+ S :> Type[0];
I : S β Type[0];
- C : βa:S. I a β Ξ© ^ S
+ C : βa:S. I a β Ξ©^S
}.
(*D
by `:` and the its type. It is a dependently typed tuple, thus
already defined names (fields) can be used in the types that follow.
-Note that `S` is declared to be a `setoid` and not a Type. The original
-paper probably also considers I to generate setoids, and both I and C
-to be (dependent) morphisms. For the sake of simplicity, we will "cheat" and use
-setoids only when strictly needed (i.e. where we want to talk about
-equality). Setoids will play a role only when we will define
-the alternative version of the axiom set.
-
Note that the field `S` was declared with `:>` instead of a simple `:`.
This declares the `S` projection to be a coercion. A coercion is
-a function case the system automatically inserts when it is needed.
+a "cast" function the system automatically inserts when it is needed.
In that case, the projection `S` has type `Ax β setoid`, and whenever
the expected type of a term is `setoid` while its type is `Ax`, the
-system inserts the coercion around it, to make the whole term well types.
+system inserts the coercion around it, to make the whole term well typed.
When formalizing an algebraic structure, declaring the carrier as a
coercion is a common practice, since it allows to write statements like
The quantification over `x` of type `G` is ill-typed, since `G` is a term
(of type `Group`) and thus not a type. Since the carrier projection
-`carr` of `G` is a coercion, that maps a `Group` into the type of
+`carr` is a coercion, that maps a `Group` into the type of
its elements, the system automatically inserts `carr` around `G`,
-obtaining `β¦βx: carr G.β¦`. Coercions are also hidden by the system
-when it displays a term.
+obtaining `β¦βx: carr G.β¦`.
-In this particular case, the coercion `S` allows to write
+Coercions are hidden by the system when it displays a term.
+In this particular case, the coercion `S` allows to write (and read):
βA:Ax.βa:A.β¦
D*)
-(* ncheck I. *)
-(* ncheck C. *)
+(** ncheck I. *) (* shows: βA:Ax.A β Type[0] *)
+(** ncheck C. *) (* shows: βA:Ax.βa:A.A β I A a β Ξ©^A *)
(*D
`A` is an axiom set and `a` has type `S A` (or thanks to the coercion
mechanism simply `A`). In Matita, a question mark represents an implicit
argument, i.e. a missing piece of information the system is asked to
-infer. Matita performs some sort of type inference, thus writing
+infer. Matita performs Hindley-Milner-style type inference, thus writing
`I ? a` is enough: since the second argument of `I` is typed by the
-first one, the first one can be inferred just computing the type of `a`.
+first one, the first (omitted) argument can be inferred just
+computing the type of `a` (that is `A`).
D*)
-(* ncheck (βA:Ax.βa:A.I ? a). *)
+(** ncheck (βA:Ax.βa:A.I ? a). *) (* shows: βA:Ax.βa:A.I A a *)
(*D
-This is still not completely satisfactory, since you have always type
+This is still not completely satisfactory, since you have always to type
`?`; to fix this minor issue we have to introduce the notational
support built in Matita.
cover relation between two subsets, while the inductive predicate
we are going to define relates an element and a subset.
+ a β U i β I(a) C(a,i) β U
+ (reflexivity) βΌβΌβΌβΌβΌβΌβΌβΌβΌ (infinity) βΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌ
+ a β U a β U
+
An option would be to unfold the definition of cover between subsets,
but we prefer to define the abstract notion of cover between subsets
(so that we can attach a (ambiguous) notation to it).
The syntax separates with `:` abstractions that are fixed for every
constructor (introduction rule) and abstractions that can change. In that
-case the parameter `U` is abstracted once and forall in front of every
+case the parameter `U` is abstracted once and for all in front of every
constructor, and every occurrence of the inductive predicate is applied to
`U` in a consistent way. Arguments abstracted on the right of `:` are not
constant, for example the xcinfinity constructor introduces `a β U`,
had side of the predicate changes, thus it has to be abstracted (in the arity
of the inductive predicate) on the right of `:`.
+The intuition Valentini suggests is that we are defining the unary predicate
+"being covered by U" (i.e. `_ β U`) and not "being covered" (i.e. `_ β _`).
+Unluckily, the syntax of Matita forces us to abstract `U` first, and
+we will make it the second argument of the predicate using
+the notational support Matita offers.
+
D*)
-(* ncheck xcreflexivity. *)
+(** ncheck xcreflexivity. *) (* shows: βA:Ax.βU:Ξ©^A.βa:A.aβU β xcover A U a *)
(*D
type is the arity of the inductive `xcover` predicate just defined).
Then it has to be abstracted over the arguments of that cover relation,
-i.e. the axiom set and the set U, and the subset (in that case `π a i`)
+i.e. the axiom set and the set `U`, and the subset (in that case `π a i`)
sitting on the left hand side of `β`.
D*)
We now define the notation `a β b`. Here the keywork `hvbox`
and `break` tell the system how to wrap text when it does not
-fit the screen (they can be safely ignore for the scope of
+fit the screen (they can be safely ignored for the scope of
this tutorial). We also add an interpretation for that notation,
where the (abstracted) cover relation is implicit. The system
will not be able to infer it from the other arguments `C` and `U`
D*)
ninductive cover (A : Ax) (U : Ξ©^A) : A β CProp[0] β
-| creflexivity : βa. a β U β cover ? U a
-| cinfinity : βa. βi. π a i β U β cover ? U a.
+| creflexivity : βa. a β U β cover A U a
+| cinfinity : βa. βi. π a i β U β cover A U a.
(** screenshot "cover". *)
napply cover;
nqed.
ends a definition or proof.
We can now define the interpretation for the cover relation between an
-element and a subset fist, then between two subsets (but this time
-we fixed the relation `cover_set` is abstracted on).
+element and a subset first, then between two subsets (but this time
+we fix the relation `cover_set` is abstracted on).
D*)
We will proceed similarly for the fish relation, but before going
on it is better to give a short introduction to the proof mode of Matita.
-We define again the `cover_set` term, but this time we will build
+We define again the `cover_set` term, but this time we build
its body interactively. In the Ξ»-calculus Matita is based on, CIC, proofs
and terms share the same syntax, and it is thus possible to use the
-commands devoted to build proof term to build regular definitions.
+commands devoted to build proof term also to build regular definitions.
A tentative semantics for the proof mode commands (called tactics)
in terms of sequent calculus rules are given in the
<a href="#appendix">appendix</a>.
D[xcover-set-2]
We have now to provide a proposition, and we exhibit it. We left
a part of it implicit; since the system cannot infer it it will
-ask it later. Note that the type of `βy:A.y β C β ?` is a proposition
-whenever `?` is.
+ask for it later.
+Note that the type of `βy:A.y β C β ?` is a proposition
+whenever `?` is a proposition.
D[xcover-set-3]
The proposition we want to provide is an application of the
The system will now ask in turn the three implicit arguments
passed to cover. The syntax `##[` allows to start a branching
to tackle every sub proof individually, otherwise every command
-is applied to every subrpoof. The command `##|` switches to the next
+is applied to every subproof. The command `##|` switches to the next
subproof and `##]` ends the branching.
D*)
(*D
-Introction rule for fish
-------------------------
-
-Matita is able to generate elimination rules for inductive types,
-but not introduction rules for the coinductive case.
+Introduction rule for fish
+---------------------------
+Matita is able to generate elimination rules for inductive types
D*)
-(* ncheck cover_rect_CProp0. *)
+(** ncheck cover_rect_CProp0. *)
(*D
-We thus have to define the introduction rule for fish by corecursion.
+but not introduction rules for the coinductive case.
+
+ P β U (βx,j.x β P β C(x,j) β¬ P) a β P
+ (fish intro) βΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌ
+ a β U
+
+We thus have to define the introduction rule for fish by co-recursion.
Here we again use the proof mode of Matita to exhibit the body of the
corecursive function.
(P: Ξ©^A) (H1: P β U)
(H2: βa:A. a β P β βj: π a. π a j β¬ P): βa:A. βp: a β P. a β U β ?.
(** screenshot "def-fish-rec-1". *)
-#a; #p; napply cfish; (** screenshot "def-fish-rec-2". *)
+#a; #a_in_P; napply cfish; (** screenshot "def-fish-rec-2". *)
##[ nchange in H1 with (βb.bβP β bβU); (** screenshot "def-fish-rec-2-1". *)
napply H1; (** screenshot "def-fish-rec-3". *)
nassumption;
-##| #i; ncases (H2 a p i); (** screenshot "def-fish-rec-5". *)
+##| #i; ncases (H2 a a_in_P i); (** screenshot "def-fish-rec-5". *)
#x; *; #xC; #xP; (** screenshot "def-fish-rec-5-1". *)
@; (** screenshot "def-fish-rec-6". *)
##[ napply x
D[def-fish-rec-5]
We then introduce `x`, break the conjunction (the `*;` command is the
equivalent of `ncases` but operates on the first hypothesis that can
-be introduced. We then introduce the two sides of the conjunction.
+be introduced). We then introduce the two sides of the conjunction.
D[def-fish-rec-5-1]
-The goal is now the existence of an a point in `π a i` fished by `U`.
+The goal is now the existence of a point in `π a i` fished by `U`.
We thus need to use the introduction rule for the existential quantifier.
In CIC it is a defined notion, that is an inductive type with just
one constructor (one introduction rule) holding the witness and the proof
that the witness satisfies a proposition.
-> ncheck Ex.
+> ncheck Ex.
Instead of trying to remember the name of the constructor, that should
be used as the argument of `napply`, we can ask the system to find by
the co-recursive call.
D[def-fish-rec-9]
-The co-recursive call needs some arguments, but all of them live
+The co-recursive call needs some arguments, but all of them are
in the context. Instead of explicitly mention them, we use the
`nassumption` tactic, that simply tries to apply every context item.
We now have to define the subset of `S` of points covered by `U`.
We also define a prefix notation for it. Remember that the precedence
-of the prefix form of a symbol has to be lower than the precedence
+of the prefix form of a symbol has to be higher than the precedence
of its infix form.
D*)
(*D
Here we define the equation characterizing the cover relation.
-In the igft.ma file we proved that `βU` is the minimum solution for
+Even if it is not part of the paper, we proved that `β(U)` is
+the minimum solution for
such equation, the interested reader should be able to reply the proof
with Matita.
(*D
-We similarly define the subset of point fished by `F`, the
-equation characterizing `βF` and prove that fish is
+We similarly define the subset of points "fished" by `F`, the
+equation characterizing `β(F)` and prove that fish is
the biggest solution for such equation.
D*)
Part 2, the new set of axioms
-----------------------------
-Since the name of objects (record included) has to unique
-within the same script, we prefix every field name
+Since the name of defined objects (record included) has to be unique
+within the same file, we prefix every field name
in the new definition of the axiom set with `n`.
D*)
-nrecord nAx : Type[2] β {
- nS:> setoid;
+nrecord nAx : Type[1] β {
+ nS:> Type[0];
nI: nS β Type[0];
nD: βa:nS. nI a β Type[0];
nd: βa:nS. βi:nI a. nD a i β nS
(*D
We again define a notation for the projections, making the
-projected record an implicit argument. Note that since we already have
-a notation for `π` we just add another interpretation for it. The
-system, looking at the argument of `π`, will be able to use
+projected record an implicit argument. Note that, since we already have
+a notation for `π`, we just add another interpretation for it. The
+system, looking at the argument of `π`, will be able to choose
the correct interpretation.
D*)
(*D
+The first result the paper presents to motivate the new formulation
+of the axiom set is the possibility to define and old axiom set
+starting from a new one and vice versa. The key definition for
+such construction is the image of d(a,i).
The paper defines the image as
> Im[d(a,i)] = { d(a,i,j) | j : D(a,i) }
> βj:D(a,i). d(a,i,j) β V
-If we need to use the image to define π (a subset of S) we are obliged to
-form a subset, i.e. to place a single variable `{ here | β¦ }`.
+If we need to use the image to define `π ` (a subset of `S`) we are obliged to
+form a subset, i.e. to place a single variable `{ here | β¦ }` of type `S`.
> Im[d(a,i)] = { y | βj:D(a,i). y = d(a,i,j) }
-This poses no theoretical problems, since `S` is a setoid and thus equipped
-with an equality.
+This poses no theoretical problems, since `S` is a Type and thus
+equipped with the `Id` equality. If `S` was a setoid, here the equality
+would have been the one of the setoid.
-Unless we difene two different images, one for stating the image is β of
-something and another one to define π, we end up using always the latter.
+Unless we define two different images, one for stating that the image is β of
+something and another one to define `π`, we end up using always the latter.
Thus the statement `Im[d(a,i)] β V` unfolds to
> βx:S. ( βj.x = d(a,i,j) ) β x β V
-That up to rewriting with the equation defining `x` is what we mean. The
-technical problem arises when `V` is a complex construction that has to
-be proved extensional (i.e. βx,y. x = y β x β V β y β V).
+That, up to rewriting with the equation defining `x`, is what we mean.
+Since we decided to use `Id` the rewriting always work (the elimination
+principle for `Id` is Leibnitz's equality, that is quantified over
+the context.
+
+The problem that arises if we decide to make `S` a setoid is that
+`V` has to be extensional w.r.t. the equality of `S` (i.e. the characteristic
+functional proposition has to quotient its input with a relation bigger
+than the one of `S`.
+
+> βx,y:S. x = y β x β V β y β V
+
+If `V` is a complex construction, the proof may not be trivial.
D*)
+include "logic/equality.ma".
+
ndefinition image β Ξ»A:nAx.Ξ»a:A.Ξ»i. { x | βj:π a i. x = π a i j }.
notation > "ππ¦ [π term 90 a term 90 i]" non associative with precedence 70 for @{ 'Im $a $i }.
-notation "ππ¦ [π \sub ( β¨a,\emsp iβ© )]" non associative with precedence 70 for @{ 'Im $a $i }.
+notation < "ππ¦ [π \sub ( β¨a,\emsp iβ© )]" non associative with precedence 70 for @{ 'Im $a $i }.
interpretation "image" 'Im a i = (image ? a i).
(*D
-Thanks to our definition of image, we ca trivially a function mapping a
-new axiom set to an old one and viceversa. Note that in the second
-definition, when defining π, the projection of the Ξ£ type is inlined
-(constructed on the fly by `*;`) while in the paper it was named `fst`.
+Thanks to our definition of image, we can define a function mapping a
+new axiom set to an old one and vice versa. Note that in the second
+definition, when we give the `π` component, the projection of the
+Ξ£-type is inlined (constructed on the fly by `*;`)
+while in the paper it was named `fst`.
D*)
(*D
+We now prove that the two function above form a retraction pair for
+the `C` component of the axiom set. To prove that we face a little
+problem since CIC is not equipped with Ξ·-conversion. This means that
+the followin does not hold (where `A` is an axiom set).
+
+> A = (S A, I A, C A)
+
+This can be proved only under a pattern mach over `A`, that means
+that the resulting computation content of the proof is a program
+that computes something only if `A` is a concrete axiom set.
+
+To state the lemma we have to drop notation, and explicitly
+give the axiom set in input to the `C` projection.
+
+D*)
+
+nlemma Ax_nAx_equiv :
+ βA:Ax. βa,i. C (Ax_of_nAx (nAx_of_Ax A)) a i β C A a i β§
+ C A a i β C (Ax_of_nAx (nAx_of_Ax A)) a i.
+#A; #a; #i; @; #b; #H; (** screenshot "retr-1". *)
+##[ ncases A in a i b H; #S; #I; #C; #a; #i; #b; #H;(** screenshot "retr-2". *)
+ nchange in a with S; nwhd in H; (** screenshot "retr-3". *)
+ ncases H; #x; #E; nrewrite > E; nwhd in x; (** screenshot "retr-4". *)
+ ncases x; #b; #Hb; nnormalize; nassumption;
+##| ncases A in a i b H; #S; #I; #C; #a; #i; #b; #H; @;
+ ##[ @ b; nassumption;
+ ##| nnormalize; @; ##]
+##]
+nqed.
+
+(*D
+D[retr-1]
+Look for example the type of `a`. The command `nchange in a with A`
+would fail because of the missing Ξ·-conversion rule. We have thus
+to pattern match over `A` and introduce its pieces.
+
+D[retr-2]
+Now the system accepts that the type of `a` is the fist component
+of the axiom set, now called `S`. Unfolding definitions in `H` we discover
+there is still some work to do.
+
+D[retr-3]
+To use the equation defining `b` we have to eliminate `H`. Unfolding
+definitions in `x` tell us there is still something to do. The `nrewrite`
+tactic is a shortcut for the elimination principle of the equality.
+It accepts an additional argument `<` or `>` to rewrite left-to-right
+or right-to-left.
+
+D[retr-4]
+We defined `π` to be the first projection of `x`, thus we have to
+eliminate `x` to actually compute `π`.
+
+The remaining part of the proof it not interesting and poses no
+new problems.
+
+D*)
+
+(*D
+
We then define the inductive type of ordinals, parametrized over an axiom
set. We also attach some notations to the constructors.
| oL : βa:A.βi.βf:π a i β Ord A. Ord A.
notation "0" non associative with precedence 90 for @{ 'oO }.
-notation "Ξ term 90 f" non associative with precedence 50 for @{ 'oL $f }.
notation "x+1" non associative with precedence 50 for @{'oS $x }.
+notation "Ξ term 90 f" non associative with precedence 50 for @{ 'oL $f }.
interpretation "ordinals Zero" 'oO = (oO ?).
-interpretation "ordinals Lambda" 'oL f = (oL ? ? ? f).
interpretation "ordinals Succ" 'oS x = (oS ? x).
+interpretation "ordinals Lambda" 'oL f = (oL ? ? ? f).
(*D
-The dfinition of `U_x` is by recursion over the ordinal `x`.
-We thus define a recursive function. The `on x` directive tells
+The definition of `Uβ½x` is by recursion over the ordinal `x`.
+We thus define a recursive function using the `nlet rec` command.
+The `on x` directive tells
the system on which argument the function is (structurally) recursive.
In the `oS` case we use a local definition to name the recursive call
not. The symbol `β½` can act as a separator, and can be typed as an alternative
for `_` (i.e. pressing ALT-L after `_`).
-The notion β(U) has to be defined as the subset of of y
-belonging to U_x for some x. Moreover, we have to define the notion
+The notion β(U) has to be defined as the subset of elements `y`
+belonging to `Uβ½x` for some `x`. Moreover, we have to define the notion
of cover between sets again, since the one defined at the beginning
-of the tutorial works only for the old axiom set definition.
+of the tutorial works only for the old axiom set.
D*)
-ndefinition ord_coverage : βA:nAx.βU:Ξ©^A.Ξ©^A β Ξ»A,U.{ y | βx:Ord A. y β famU ? U x }.
+ndefinition ord_coverage : βA:nAx.βU:Ξ©^A.Ξ©^A β
+ Ξ»A,U.{ y | βx:Ord A. y β famU ? U x }.
ndefinition ord_cover_set β Ξ»c:βA:nAx.Ξ©^A β Ξ©^A.Ξ»A,C,U.
βy.y β C β y β c A U.
(*D
-The proof of infinity uses the following form of the Axiom of choice,
-that cannot be prove inside Matita, since the existential quantifier
+The proof of infinity uses the following form of the Axiom of Choice,
+that cannot be proved inside Matita, since the existential quantifier
lives in the sort of predicative propositions while the sigma in the conclusion
lives in the sort of data types, and thus the former cannot be eliminated
-to provide the second.
+to provide the witness for the second.
D*)
(*D
-In the proof of infinity, we have to rewrite under the β predicate.
-It is clearly possible to show that Uβ½x is an extensional set:
+Note that, if we will decide later to identify β and Ξ£, `AC` is
+trivially provable
+
+D*)
+
+nlemma AC_exists_is_sigma : βA,a,i,U.
+ (βj:π a i.Ξ£x:Ord A.π a i j β Uβ½x) β (Ξ£f.βj:π a i.π a i j β Uβ½(f j)).
+#A; #a; #i; #U; #H; @;
+##[ #j; ncases (H j); #x; #_; napply x;
+##| #j; ncases (H j); #x; #Hx; napply Hx; ##]
+nqed.
+
+(*D
+
+In case we made `S` a setoid, the following property has to be proved
-> a = b β a β Uβ½x β b β Uβ½x
+> nlemma U_x_is_ext: βA:nAx.βa,b:A.βx.βU. a = b β b β Uβ½x β a β Uβ½x.
-Anyway this proof in non trivial induction over x, that requires π and π to be
-declared as morphisms. This poses to problem, but goes out of the scope of the
-tutorial and we thus assume it.
+Anyway this proof is a non trivial induction over x, that requires `π` and `π` to be
+declared as morphisms.
D*)
-naxiom U_x_is_ext: βA:nAx.βa,b:A.βx.βU. a = b β b β Uβ½x β a β Uβ½x.
(*D
-The reflexivity proof is trivial, it is enough to provide the ordinal 0
-as a witness, then β(U) reduces to U by definition, hence the conclusion.
+The reflexivity proof is trivial, it is enough to provide the ordinal `0`
+as a witness, then `β(U)` reduces to `U` by definition,
+hence the conclusion. Note that `0` is between `(` and `)` to
+make it clear that it is a term (an ordinal) and not the number
+of the constructor we want to apply (that is the first and only one
+of the existential inductive type).
D*)
ntheorem new_coverage_reflexive: βA:nAx.βU:Ξ©^A.βa. a β U β a β U.
D*)
-alias symbol "covers" = "new covers set".
-alias symbol "covers" = "new covers".
-alias symbol "covers" = "new covers set".
-alias symbol "covers" = "new covers".
-alias symbol "covers" = "new covers set".
-alias symbol "covers" = "new covers".
-alias symbol "covers" = "new covers set".
-alias symbol "covers" = "new covers".
+alias symbol "covers" (instance 3) = "new covers set".
ntheorem new_coverage_infinity:
βA:nAx.βU:Ξ©^A.βa:A. (βi:π a. ππ¦[π a i] β U) β a β U.
#A; #U; #a; (** screenshot "n-cov-inf-1". *)
*; #i; #H; nnormalize in H; (** screenshot "n-cov-inf-2". *)
ncut (βy:π a i.βx:Ord A.π a i y β Uβ½x); ##[ (** screenshot "n-cov-inf-3". *)
- #z; napply H; @ z; napply #; ##] #H'; (** screenshot "n-cov-inf-4". *)
+ #z; napply H; @ z; @; ##] #H'; (** screenshot "n-cov-inf-4". *)
ncases (AC β¦ H'); #f; #Hf; (** screenshot "n-cov-inf-5". *)
ncut (βj.π a i j β Uβ½(Ξ f));
##[ #j; napply (ord_subset β¦ f β¦ (Hf j));##] #Hf';(** screenshot "n-cov-inf-6". *)
@ (Ξ f+1); (** screenshot "n-cov-inf-7". *)
@2; (** screenshot "n-cov-inf-8". *)
@i; #x; *; #d; #Hd; (** screenshot "n-cov-inf-9". *)
-napply (U_x_is_ext β¦ Hd); napply Hf';
+nrewrite > Hd; napply Hf';
nqed.
(*D
D[n-cov-inf-1]
We eliminate the existential, obtaining an `i` and a proof that the
-image of d(a,i) is covered by U. The `nnormalize` tactic computes the normal
+image of `π a i` is covered by U. The `nnormalize` tactic computes the normal
form of `H`, thus expands the definition of cover between sets.
D[n-cov-inf-2]
-The paper proof considers `H` implicitly substitutes the equation assumed
-by `H` in its conclusion. In Matita this step is not completely trivia.
-We thus assert (`ncut`) the nicer form of `H`.
+When the paper proof considers `H`, it implicitly substitutes assumed
+equation defining `y` in its conclusion.
+In Matita this step is not completely trivial.
+We thus assert (`ncut`) the nicer form of `H` and prove it.
D[n-cov-inf-3]
After introducing `z`, `H` can be applied (choosing `π a i z` as `y`).
What is the left to prove is that `βj: π a j. π a i z = π a i j`, that
-becomes trivial is `j` is chosen to be `z`. In the command `napply #`,
-the `#` is a standard notation for the reflexivity property of the equality.
+becomes trivial if `j` is chosen to be `z`.
D[n-cov-inf-4]
Under `H'` the axiom of choice `AC` can be eliminated, obtaining the `f` and
D[n-cov-inf-7]
The definition of `Uβ½(β¦+1)` expands to the union of two sets, and proving
-that `a β X βͺ Y` is defined as proving that `a` is in `X` or `Y`. Applying
-the second constructor `@2;` of the disjunction, we are left to prove that `a`
-belongs to the right hand side.
+that `a β X βͺ Y` is, by definition, equivalent to prove that `a` is in `X` or `Y`.
+Applying the second constructor `@2;` of the disjunction,
+we are left to prove that `a` belongs to the right hand side of the union.
D[n-cov-inf-8]
-We thus provide `i`, introduce the element being in the image and we are
-left to prove that it belongs to `U_(Ξf)`. In the meanwhile, since belonging
-to the image means that there exists an object in the domain⦠we eliminate the
+We thus provide `i` as the witness of the existential, introduce the
+element being in the image and we are
+left to prove that it belongs to `Uβ½(Ξf)`. In the meanwhile, since belonging
+to the image means that there exists an object in the domain β¦, we eliminate the
existential, obtaining `d` (of type `π a i`) and the equation defining `x`.
D[n-cov-inf-9]
(*D
-The next proof is that β(U) is mininal. The hardest part of the proof
+The next proof is that β(U) is minimal. The hardest part of the proof
is to prepare the goal for the induction. The desiderata is to prove
`Uβ½o β V` by induction on `o`, but the conclusion of the lemma is,
unfolding all definitions:
*; #o; (** screenshot "n-cov-min-3". *)
ngeneralize in match b; nchange with (Uβ½o β V); (** screenshot "n-cov-min-4". *)
nelim o; (** screenshot "n-cov-min-5". *)
-##[ #b; #bU0; napply HUV; napply bU0;
+##[ napply HUV;
##| #p; #IH; napply subseteq_union_l; ##[ nassumption; ##]
#x; *; #i; #H; napply (Im ? i); napply (subseteq_trans β¦ IH); napply H;
##| #a; #i; #f; #IH; #x; *; #d; napply IH; ##]
(*D
The proof of compatibility uses this little result, that we
-proved outside the mail proof.
+proved outside the main proof.
D*)
nlemma co_ord_subset: βA:nAx.βF:Ξ©^A.βa,i.βf:π a i β Ord A.βj. Fβ½(Ξ f) β Fβ½(f j).
D*)
naxiom AC_dual: βA:nAx.βa:A.βi,F.
- (βf:π a i β Ord A.βx:π a i.π a i x β Fβ½(f x)) β βj:π a i.βx:Ord A.π a i j β Fβ½x.
+ (βf:π a i β Ord A.βx:π a i.π a i x β Fβ½(f x))
+ β βj:π a i.βx:Ord A.π a i j β Fβ½x.
(*D
Proving the anti-reflexivity property is simple, since the
assumption `a β F` states that for every ordinal `x` (and thus also 0)
-`a β Fβ½x`. If `x` is choosen to be `0`, we obtain the thesis.
+`a β Fβ½x`. If `x` is choose to be `0`, we obtain the thesis.
D*)
ntheorem new_fish_antirefl: βA:nAx.βF:Ξ©^A.βa. a β F β a β F.
(*D
D[n-f-compat-1]
-After reducing to normal form the goal, we obseve it is exactly the conlusion of
+After reducing to normal form the goal, we observe it is exactly the conclusion of
the dual axiom of choice we just assumed. We thus apply it ad introduce the
fcuntion `f`.
D[n-f-compat-3]
Since F_(Ξf+1) is defined by recursion and we actually have a concrete input
-`Ξf+1` for that recursive function, it can compute. Anyway, using the `nnormalize`
-tactic would reduce too much (both the `+1` and the `Ξf` steps would be prformed);
+`Ξf+1` for that recursive function, it can be computed.
+Anyway, using the `nnormalize`
+tactic would reduce too much (both the `+1` and the `Ξf` steps would be performed);
we thus explicitly give a convertible type for that hypothesis, corresponding
-the computation of the `+1` step, plus the unfolding of `β©`.
+the computation of the `+1` step, plus the unfolding the definition of
+the intersection.
D[n-f-compat-4]
We are interested in the right hand side of `aLf`, an in particular to
minimality of `β(U)`. Thus the main problem is to obtain `G β Fβ½o`
before doing the induction over `o`.
-Note that `G` is assumed to be of type `π^A`, that means an extensional
-subset of `S`, while `Ξ©^A` means just a subset (note that the former is bold).
-
D*)
ntheorem max_new_fished:
- βA:nAx.βG:π^A.βF:Ξ©^A.G β F β (βa.a β G β βi.ππ¦[π a i] β¬ G) β G β βF.
+ βA:nAx.βG:Ξ©^A.βF:Ξ©^A.G β F β (βa.a β G β βi.ππ¦[π a i] β¬ G) β G β βF.
#A; #G; #F; #GF; #H; #b; #HbG; #o;
ngeneralize in match HbG; ngeneralize in match b;
nchange with (G β Fβ½o);
##[ napply GF;
##| #p; #IH; napply (subseteq_intersection_r β¦ IH);
#x; #Hx; #i; ncases (H β¦ Hx i); #c; *; *; #d; #Ed; #cG;
- @d; napply IH; (** screenshot "n-f-max-1". *)
- alias symbol "prop2" = "prop21".
- napply (. Ed^-1β‘#); napply cG;
+ @d; napply IH; (** screenshot "n-f-max-1". *)
+ nrewrite < Ed; napply cG;
##| #a; #i; #f; #Hf; nchange with (G β { y | βx. y β Fβ½(f x) });
#b; #Hb; #d; napply (Hf d); napply Hb;
##]
nqed.
-(*D
-D[n-f-max-1]
-Here the situacion look really similar to the one of the dual proof where
-we had to apply the assumption `U_x_is_ext`, but here the set is just `G`
-not `F_x`. Since we assumed `G` to be extensional we can employ the facilities
-Matita provides to perform rewriting in the general setting of setoids.
-
-The lemma `.` simply triggers the mechanism, and the given argument has to
-mimick the context under which the rewriting has to happen. In that case
-we want to rewrite to the left of the binary morphism `β`. The infix notation
-to represent the context of a binary morphism is `β‘`. The right hand side
-has to be left untouched, and the identity rewriting step is represented with
-`#` (actually a reflexivity proof for the subterm identified by the context).
-
-We want to rewrite the left hand side using `Ed` right-to-left (the default
-is left-to-right). We thus write `Ed^-1`, that is a proof that `π x i d = c`.
-The complete command is `napply (. Ed^-1β‘#)` that has to be read like:
-
-> perform some rewritings under a binary morphism,
-> on the right do nothing,
-> on the left rewrite with Ed right-to-left.
-
-After the rewriting step the goal is exactly the `cG` assumption.
-
-D*)
+(*D
+D[n-f-max-1]
+Note that here the right hand side of `β` is `G` and not `Fβ½p` as
+in the dual proof. If `S` was declare to be a setoid, to finish this proof
+would be enough to assume `G` extensional, and no proof of the
+extensionality of `Fβ½p` is required.
-(*D
<div id="appendix" class="anchor"></div>
Appendix: tactics explanation
-----------------------------
The `:` separator has to be read as _is a proof of_, in the spirit
of the Curry-Howard isomorphism.
- Ξ β’ f : A1 β β¦ β An β B Ξ β’ ?1 : A1 β¦ ?n : An
+ Ξ β’ f : A_1 β β¦ β A_n β B Ξ β’ ?_i : A_i
napply f; βΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌ
- Ξ β’ (f ?1 β¦ ?n ) : B
+ Ξ β’ (f ?_1 β¦ ?_n ) : B
Ξ β’ ? : F β B Ξ β’ f : F
nlapply f; βΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌβΌ