]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/nlibrary/topology/igft.ma
f1795462b29f2e7a0f70a885ba81266a35f6bf2a
[helm.git] / helm / software / matita / nlibrary / topology / igft.ma
1 (*D
2
3 Matita Tutorial: inductively generated formal topologies
4 ======================================================== 
5
6 This is a not so short introduction to Matita, based on
7 the formalization of the paper
8
9 > Between formal topology and game theory: an
10 > explicit solution for the conditions for an
11 > inductive generation of formal topologies
12
13 by S.Berardi and S. Valentini. The tutorial is by Enrico Tassi. 
14
15 The tutorial spends a considerable amount of effort in defining 
16 notations that resemble the ones used in the original paper. We believe
17 this is a important part of every formalization, not only from the aesthetic 
18 point of view, but also from the practical point of view. Being 
19 consistent allows to follow the paper in a pedantic way, and hopefully
20 to make the formalization (at least the definitions and proved
21 statements) readable to the author of the paper. 
22
23 Orienteering
24 ------------
25
26 The graphical interface of Matita is composed of three windows:
27 the script window, on the left, is where you type; the sequent
28 window on the top right is where the system shows you the ongoing proof;
29 the error window, on the bottom right, is where the system complains.
30 On the top of the script window five buttons drive the processing of
31 the proof script. From left to right the requesting the system to:
32
33 - go back to the beginning of the script
34 - go back one step
35 - go to the current cursor position
36 - advance one step
37 - advance to the end of the script
38
39 When the system processes a command, it locks the part of the script
40 corresponding to the command, such that you cannot edit it anymore 
41 (without to go back). Locked parts are coloured in blue.
42
43 The sequent window is hyper textual, i.e. you can click on symbols
44 to jump to their definition, or switch between different notation
45 for the same expression (for example, equality has two notations,
46 one of them makes the type of the arguments explicit).  
47
48 Everywhere in the script you can use the `ncheck (term).` command to
49 ask for the type a given term. If you that in the middle of a proof,
50 the term is assumed to live in the current proof context (i.e. can use
51 variables introduced so far).
52
53 To ease the typing of mathematical symbols, the script window
54 implements two unusual input facilities:
55
56 - some TeX symbols can be typed using their TeX names, and are 
57   automatically converted to UTF-8 characters. For a list of 
58   the supported TeX names, see the menu: View ▹ TeX/UTF-8 Table.
59   Moreover some ASCII-art is understood as well, like `=>` and `->`
60   to mean double or single arrows.
61   Here we recall some of these "shortcuts":
62
63   - ∀ can be typed with `\Forall`
64   - λ can be typed with `\lambda`
65   - ≝ can be typed with `\def` or `:=`
66   - → can be typed with `\to` or `->`
67   
68 - some symbols have variants, like the ≤ relation and ≼, ≰, ⋠.
69   The user can cycle between variants typing one of them and then
70   pressing ALT-L. Note that also letters do have variants, for
71   example W has Ω, 𝕎 and 𝐖, L has Λ, 𝕃, and 𝐋, F has Φ, … 
72   Variants are listed in the aforementioned TeX/UTF-8 table. 
73
74 Pressing `F1` opens the Matita manual.
75
76 CIC (as implemented in Matita) in a nutshell
77 -------------------------------------------- 
78
79 CIC is a full and functional Pure Type System (all products do exist,
80 and their sort is is determined by the target) with an impedicative sort
81 Prop and a predicative sort Type. The environment can be populated with
82 well typed definitions or theorems, (co)inductive types validating positivity
83 conditions and recursive functions provably total by simple syntactical 
84 analysis (recursive call on structurally smaller subterms). Co-recursive 
85 functions can be defined as well, and must satisfy a dual condition, that is
86 performing the recursive call only after having generated a constructor (a piece
87 of output).
88
89 The λ-calculus is equipped with a pattern matching construct (match) on inductive
90 types defined in the environment that combined with the definable total 
91 structural recursive functions allows to define eliminators (or constructors)
92 for (co)inductive types. The λ-calculus is also equipped with explicitly types 
93 local definitions (let in) that in the degenerate case work as casts (i.e.
94 the type annotation `(t : T)`  is implemented as `let x : T ≝ t in x`). 
95
96 Types are compare up to conversion. Since types may depend on terms, conversion
97 involves β-reduction, δ-reduction (definition unfolding), ζ-reduction (local
98 definition unfolding), ι-reduction (pattern matching simplification),
99 μ-reduction (recursive function computation) and ν-reduction (co-fixpoint
100 computation).
101
102 Since we are going to formalize constructive and predicative mathematics
103 in an intensional type theory like CIC, we try to establish some terminology. 
104 Type is the sort of sets equipped with the Id equality (i.e. an intensional,
105 not quotiented set). We will avoid using Leibnitz equality Id, 
106 thus we will explicitly equip a set with an equality when needed.
107 We will call this structure `setoid`. Note that we will
108 attach the infix = symbol only to the equality of a setoid,
109 not to Id.
110
111 We write Type[i] to mention a Type in the predicative hierarchy 
112 of types. To ease the comprehension we will use Type[0] for sets, 
113 and Type[1] for classes.
114
115 For every Type[i] there is a corresponding level of predicative
116 propositions CProp[i].
117
118
119 The standard library and the `include` command
120 ----------------------------------------------
121
122 Some basic notions, like subset, membership, intersection and union
123 are part of the standard library of Matita.
124
125 These notions come with some standard notation attached to them:
126
127 - A ∪ B can be typed with `A \cup B`
128 - A ∩ B can be typed with `A \cap B` 
129 - A ≬ B can be typed with `A \between B`
130 - x ∈ A can be typed with `x \in A` 
131 - Ω^A, that is the type of the subsets of A, can be typed with `\Omega ^ A` 
132
133 The `include` command tells Matita to load a part of the library, 
134 in particular the part that we will use can be loaded as follows: 
135
136 D*)
137
138 include "sets/sets.ma".
139
140 (*D
141
142 Some basic results that we will use are also part of the sets library:
143
144 - subseteq\_union\_l: ∀A.∀U,V,W:Ω^A.U ⊆ W → V ⊆ W → U ∪ V ⊆ W
145 - subseteq\_intersection\_r: ∀A.∀U,V,W:Ω^A.W ⊆ U → W ⊆ V → W ⊆ U ∩ V
146
147 Defining Axiom set
148 ------------------
149
150 A set of axioms is made of a set S, a family of sets I and a 
151 family C of subsets of S indexed by elements a of S and I(a).
152
153 It is desirable to state theorems like "for every set of axioms, …"
154 without explicitly mentioning S, I and C. To do that, the three 
155 components have to be grouped into a record (essentially a dependently
156 typed tuple). The system is able to generate the projections
157 of the record for free, and they are named as the fields of
158 the record. So, given a axiom set `A` we can obtain the set
159 with `S A`, the family of sets with `I A` and the family of subsets
160 with `C A`.
161
162 D*)
163
164 nrecord Ax : Type[1] ≝ { 
165   S :> setoid;
166   I :  S → Type[0];
167   C :  ∀a:S. I a → Ω ^ S
168 }.
169
170 (*D
171
172 Forget for a moment the `:>` that will be detailed later, and focus on
173 the record definition. It is made of a list of pairs: a name, followed
174 by `:` and the its type. It is a dependently typed tuple, thus
175 already defined names (fields) can be used in the types that follow. 
176
177 Note that `S` is declared to be a `setoid` and not a Type. The original
178 paper probably also considers I to generate setoids, and both I and C
179 to be morphisms. For the sake of simplicity, we will "cheat" and use
180 setoids only when strictly needed (i.e. where we want to talk about 
181 equality). Setoids will play a role only when we will define
182 the alternative version of the axiom set.
183
184 Note that the field `S` was declared with `:>` instead of a simple `:`.
185 This declares the `S` projection to be a coercion. A coercion is 
186 a function case the system automatically inserts when it is needed.
187 In that case, the projection `S` has type `Ax → setoid`, and whenever
188 the expected type of a term is `setoid` while its type is `Ax`, the 
189 system inserts the coercion around it, to make the whole term well types.
190
191 When formalizing an algebraic structure, declaring the carrier as a 
192 coercion is a common practice, since it allows to write statements like
193
194     ∀G:Group.∀x:G.x * x^-1 = 1 
195
196 The quantification over `x` of type `G` is ill-typed, since `G` is a term
197 (of type `Group`) and thus not a type. Since the carrier projection 
198 `carr` of `G` is a coercion, that maps a `Group` into the type of 
199 its elements, the system automatically inserts `carr` around `G`, 
200 obtaining `…∀x: carr G.…`. Coercions are also hidden by the system
201 when it displays a term.
202
203 In this particular case, the coercion `S` allows to write
204
205     ∀A:Ax.∀a:A.…
206
207 Since `A` is not a type, but it can be turned into a `setoid` by `S`
208 and a `setoid` can be turned into a type by its `carr` projection, the 
209 composed coercion `carr ∘ S` is silently inserted.
210
211 Implicit arguments
212 ------------------
213
214 Something that is not still satisfactory, is that the dependent type
215 of `I` and `C` are abstracted over the Axiom set. To obtain the
216 precise type of a term, you can use the `ncheck` command as follows.
217
218 D*) 
219
220 (* ncheck I. *)
221 (* ncheck C. *)
222
223 (*D
224
225 One would like to write `I a` and not `I A a` under a context where
226 `A` is an axiom set and `a` has type `S A` (or thanks to the coercion
227 mechanism simply `A`). In Matita, a question mark represents an implicit
228 argument, i.e. a missing piece of information the system is asked to
229 infer. Matita performs some sort of type inference, thus writing
230 `I ? a` is enough: since the second argument of `I` is typed by the 
231 first one, the first one can be inferred just computing the type of `a`.
232
233 D*) 
234
235 (* ncheck (∀A:Ax.∀a:A.I ? a). *)
236
237 (*D
238
239 This is still not completely satisfactory, since you have always type 
240 `?`; to fix this minor issue we have to introduce the notational
241 support built in Matita.
242
243 Notation for I and C
244 --------------------
245
246 Matita is quipped with a quite complex notational support,
247 allowing the user to define and use mathematical notations 
248 ([From Notation to Semantics: There and Back Again][1]). 
249
250 Since notations are usually ambiguous (e.g. the frequent overloading of 
251 symbols) Matita distinguishes between the term level, the 
252 content level, and the presentation level, allowing multiple 
253 mappings between the content and the term level. 
254
255 The mapping between the presentation level (i.e. what is typed on the 
256 keyboard and what is displayed in the sequent window) and the content
257 level is defined with the `notation` command. When followed by
258 `>`, it defines an input (only) notation.   
259
260 D*)
261
262 notation > "𝐈 term 90 a" non associative with precedence 70 for @{ 'I $a }.
263 notation > "𝐂 term 90 a term 90 i" non associative with precedence 70 for @{ 'C $a $i }.
264
265 (*D
266
267 The first notation defines the writing `𝐈 a` where `a` is a generic
268 term of precedence 90, the maximum one. This high precedence forces
269 parentheses around any term of a lower precedence. For example `𝐈 x`
270 would be accepted, since identifiers have precedence 90, but
271 `𝐈 f x` would be interpreted as `(𝐈 f) x`. In the latter case, parentheses
272 have to be put around `f x`, thus the accepted writing would be `𝐈 (f x)`.
273
274 To obtain the `𝐈` is enough to type `I` and then cycle between its
275 similar symbols with ALT-L. The same for `𝐂`. Notations cannot use
276 regular letters or the round parentheses, thus their variants (like the 
277 bold ones) have to be used.
278
279 The first notation associates `𝐈 a` with `'I $a` where `'I` is a 
280 new content element to which a term `$a` is passed.
281
282 Content elements have to be interpreted, and possibly multiple, 
283 incompatible, interpretations can be defined.
284
285 D*)
286
287 interpretation "I" 'I a = (I ? a).
288 interpretation "C" 'C a i = (C ? a i).
289
290 (*D
291
292 The `interpretation` command allows to define the mapping between
293 the content level and the terms level. Here we associate the `I` and
294 `C` projections of the Axiom set record, where the Axiom set is an implicit 
295 argument `?` to be inferred by the system.
296
297 Interpretation are bi-directional, thus when displaying a term like 
298 `C _ a i`, the system looks for a presentation for the content element
299 `'C a i`. 
300
301 D*)
302
303 notation < "𝐈  \sub( ❨a❩ )" non associative with precedence 70 for @{ 'I $a }.
304 notation < "𝐂 \sub( ❨a,\emsp i❩ )" non associative with precedence 70 for @{ 'C $a $i }.
305
306 (*D
307
308 For output purposes we can define more complex notations, for example
309 we can put bold parentheses around the arguments of `𝐈` and `𝐂`, decreasing
310 the size of the arguments and lowering their baseline (i.e. putting them
311 as subscript), separating them with a comma followed by a little space.
312
313 The first (technical) definition
314 --------------------------------
315
316 Before defining the cover relation as an inductive predicate, one
317 has to notice that the infinity rule uses, in its hypotheses, the 
318 cover relation between two subsets, while the inductive predicate 
319 we are going to define relates an element and a subset.
320
321 An option would be to unfold the definition of cover between subsets,
322 but we prefer to define the abstract notion of cover between subsets
323 (so that we can attach a (ambiguous) notation to it).
324
325 Anyway, to ease the understanding of the definition of the cover relation 
326 between subsets, we first define the inductive predicate unfolding the 
327 definition, and we later refine it with.
328
329 D*)
330
331 ninductive xcover (A : Ax) (U : Ω^A) : A → CProp[0] ≝ 
332 | xcreflexivity : ∀a:A. a ∈ U → xcover A U a
333 | xcinfinity    : ∀a:A.∀i:𝐈 a. (∀y.y ∈ 𝐂 a i → xcover A U y) → xcover A U a.
334
335 (*D
336
337 We defined the xcover (x will be removed in the final version of the 
338 definition) as an inductive predicate. The arity of the inductive
339 predicate has to be carefully analyzed:
340
341 >  (A : Ax) (U : Ω^A) : A → CProp[0]
342
343 The syntax separates with `:` abstractions that are fixed for every
344 constructor (introduction rule) and abstractions that can change. In that 
345 case the parameter `U` is abstracted once and forall in front of every 
346 constructor, and every occurrence of the inductive predicate is applied to
347 `U` in a consistent way. Arguments abstracted on the right of `:` are not
348 constant, for example the xcinfinity constructor introduces `a ◃ U`,
349 but under the assumption that (for every y) `y ◃ U`. In that rule, the left
350 had side of the predicate changes, thus it has to be abstracted (in the arity
351 of the inductive predicate) on the right of `:`.
352
353 D*)
354
355 (* ncheck xcreflexivity. *)
356
357 (*D
358
359 We want now to abstract out `(∀y.y ∈ 𝐂 a i → xcover A U y)` and define
360 a notion `cover_set` to which a notation `𝐂 a i ◃ U` can be attached.
361
362 This notion has to be abstracted over the cover relation (whose
363 type is the arity of the inductive `xcover` predicate just defined).
364
365 Then it has to be abstracted over the arguments of that cover relation,
366 i.e. the axiom set and the set U, and the subset (in that case `𝐂 a i`)
367 sitting on the left hand side of `◃`. 
368
369 D*)
370
371 ndefinition cover_set : 
372   ∀cover: ∀A:Ax.Ω^A → A → CProp[0]. ∀A:Ax.∀C,U:Ω^A. CProp[0] 
373 ≝ 
374   λcover.                           λA,    C,U.     ∀y.y ∈ C → cover A U y.
375
376 (*D
377
378 The `ndefinition` command takes a name, a type and body (of that type).
379 The type can be omitted, and in that case it is inferred by the system.
380 If the type is given, the system uses it to infer implicit arguments
381 of the body. In that case all types are left implicit in the body.
382
383 We now define the notation `a ◃ b`. Here the keywork `hvbox`
384 and `break` tell the system how to wrap text when it does not
385 fit the screen (they can be safely ignore for the scope of
386 this tutorial). We also add an interpretation for that notation, 
387 where the (abstracted) cover relation is implicit. The system
388 will not be able to infer it from the other arguments `C` and `U`
389 and will thus prompt the user for it. This is also why we named this 
390 interpretation `covers set temp`: we will later define another 
391 interpretation in which the cover relation is the one we are going to 
392 define.
393
394 D*)
395
396 notation "hvbox(a break ◃ b)" non associative with precedence 45
397 for @{ 'covers $a $b }.
398
399 interpretation "covers set temp" 'covers C U = (cover_set ?? C U).
400
401 (*D
402
403 The cover relation
404 ------------------
405
406 We can now define the cover relation using the `◃` notation for 
407 the premise of infinity. 
408
409 D*)
410
411 ninductive cover (A : Ax) (U : Ω^A) : A → CProp[0] ≝ 
412 | creflexivity : ∀a. a ∈ U → cover ? U a
413 | cinfinity    : ∀a. ∀i. 𝐂 a i ◃ U → cover ? U a.
414 (** screenshot "cover". *) 
415 napply cover;
416 nqed.
417
418 (*D
419
420 Note that the system accepts the definition
421 but prompts the user for the relation the `cover_set` notion is
422 abstracted on.
423
424
425
426 The horizontal line separates the hypotheses from the conclusion.
427 The `napply cover` command tells the system that the relation
428 it is looking for is exactly our first context entry (i.e. the inductive
429 predicate we are defining, up to α-conversion); while the `nqed` command
430 ends a definition or proof.
431
432 We can now define the interpretation for the cover relation between an
433 element and a subset fist, then between two subsets (but this time
434 we fixed the relation `cover_set` is abstracted on).
435
436 D*)
437
438 interpretation "covers" 'covers a U = (cover ? U a).
439 interpretation "covers set" 'covers a U = (cover_set cover ? a U).
440
441 (*D
442
443 We will proceed similarly for the fish relation, but before going
444 on it is better to give a short introduction to the proof mode of Matita.
445 We define again the `cover_set` term, but this time we will build
446 its body interactively. In the λ-calculus Matita is based on, CIC, proofs
447 and terms share the same syntax, and it is thus possible to use the
448 commands devoted to build proof term to build regular definitions.
449 A tentative semantics for the proof mode commands (called tactics)
450 in terms of sequent calculus rules are given in the
451 <a href="#appendix">appendix</a>.
452
453 D*)
454
455 ndefinition xcover_set : 
456   ∀c: ∀A:Ax.Ω^A → A → CProp[0]. ∀A:Ax.∀C,U:Ω^A. CProp[0]. 
457                          (** screenshot "xcover-set-1". *)
458 #cover; #A; #C; #U;      (** screenshot "xcover-set-2". *) 
459 napply (∀y:A.y ∈ C → ?); (** screenshot "xcover-set-3". *)
460 napply cover;            (** screenshot "xcover-set-4". *)
461 ##[ napply A;
462 ##| napply U;
463 ##| napply y;
464 ##]
465 nqed.
466
467 (*D[xcover-set-1]
468 The system asks for a proof of the full statement, in an empty context.
469
470 The `#` command is the ∀-introduction rule, it gives a name to an 
471 assumption putting it in the context, and generates a λ-abstraction
472 in the proof term.
473
474 D[xcover-set-2]
475 We have now to provide a proposition, and we exhibit it. We left
476 a part of it implicit; since the system cannot infer it it will
477 ask it later. Note that the type of `∀y:A.y ∈ C → ?` is a proposition
478 whenever `?` is.
479
480 D[xcover-set-3]
481 The proposition we want to provide is an application of the
482 cover relation we have abstracted in the context. The command
483 `napply`, if the given term has not the expected type (in that
484 case it is a product versus a proposition) it applies it to as many 
485 implicit arguments as necessary (in that case `? ? ?`).
486
487 D[xcover-set-4]
488 The system will now ask in turn the three implicit arguments 
489 passed to cover. The syntax `##[` allows to start a branching
490 to tackle every sub proof individually, otherwise every command
491 is applied to every subrpoof. The command `##|` switches to the next
492 subproof and `##]` ends the branching.  
493 D*)
494
495 (*D
496
497 The fish relation
498 -----------------
499
500 The definition of fish works exactly the same way as for cover, except 
501 that it is defined as a coinductive proposition.
502 D*)
503
504 ndefinition fish_set ≝ λf:∀A:Ax.Ω^A → A → CProp[0].
505  λA,U,V.
506   ∃a.a ∈ V ∧ f A U a.
507
508 (* a \ltimes b *)
509 notation "hvbox(a break ⋉ b)" non associative with precedence 45
510 for @{ 'fish $a $b }. 
511
512 interpretation "fish set temp" 'fish A U = (fish_set ?? U A).
513
514 ncoinductive fish (A : Ax) (F : Ω^A) : A → CProp[0] ≝ 
515 | cfish : ∀a. a ∈ F → (∀i:𝐈 a .𝐂  a i ⋉ F) → fish A F a.
516 napply fish;
517 nqed.
518
519 interpretation "fish set" 'fish A U = (fish_set fish ? U A).
520 interpretation "fish" 'fish a U = (fish ? U a).
521
522 (*D
523
524 Introction rule for fish
525 ------------------------
526
527 Matita is able to generate elimination rules for inductive types,
528 but not introduction rules for the coinductive case. 
529
530 D*)
531
532 (* ncheck cover_rect_CProp0. *) 
533
534 (*D
535
536 We thus have to define the introduction rule for fish by corecursion.
537 Here we again use the proof mode of Matita to exhibit the body of the
538 corecursive function.
539
540 D*)
541
542 nlet corec fish_rec (A:Ax) (U: Ω^A)
543  (P: Ω^A) (H1: P ⊆ U)
544   (H2: ∀a:A. a ∈ P → ∀j: 𝐈 a. 𝐂 a j ≬ P): ∀a:A. ∀p: a ∈ P. a ⋉ U ≝ ?.
545                                        (** screenshot "def-fish-rec-1".   *)
546 #a; #p; napply cfish;                  (** screenshot "def-fish-rec-2".   *)
547 ##[ nchange in H1 with (∀b.b∈P → b∈U); (** screenshot "def-fish-rec-2-1". *) 
548     napply H1;                         (** screenshot "def-fish-rec-3".   *) 
549     nassumption;
550 ##| #i; ncases (H2 a p i);             (** screenshot "def-fish-rec-5".   *) 
551     #x; *; #xC; #xP;                   (** screenshot "def-fish-rec-5-1". *) 
552     @;                                 (** screenshot "def-fish-rec-6".   *)
553     ##[ napply x
554     ##| @;                             (** screenshot "def-fish-rec-7".   *)
555         ##[ napply xC; 
556         ##| napply (fish_rec ? U P);   (** screenshot "def-fish-rec-9".   *)
557             nassumption;
558         ##]
559     ##]
560 ##]
561 nqed.
562
563 (*D
564 D[def-fish-rec-1]
565 Note the first item of the context, it is the corecursive function we are 
566 defining. This item allows to perform the recursive call, but we will be
567 allowed to do such call only after having generated a constructor of
568 the fish coinductive type.
569
570 We introduce `a` and `p`, and then return the fish constructor `cfish`.
571 Since the constructor accepts two arguments, the system asks for them.
572
573 D[def-fish-rec-2]
574 The first one is a proof that `a ∈ U`. This can be proved using `H1` and `p`.
575 With the `nchange` tactic we change `H1` into an equivalent form (this step
576 can be skipped, since the system would be able to unfold the definition
577 of inclusion by itself)
578
579 D[def-fish-rec-2-1]
580 It is now clear that `H1` can be applied. Again `napply` adds two 
581 implicit arguments to `H1 ? ?`, obtaining a proof of `? ∈ U` given a proof
582 that `? ∈ P`. Thanks to unification, the system understands that `?` is actually
583 `a`, and it asks a proof that `a ∈ P`.
584
585 D[def-fish-rec-3]
586 The `nassumption` tactic looks for the required proof in the context, and in
587 that cases finds it in the last context position. 
588
589 We move now to the second branch of the proof, corresponding to the second
590 argument of the `cfish` constructor.
591
592 We introduce `i` and then we destruct `H2 a p i`, that being a proof
593 of an overlap predicate, give as an element and a proof that it is 
594 both in `𝐂 a i` and `P`.
595
596 D[def-fish-rec-5]
597 We then introduce `x`, break the conjunction (the `*;` command is the
598 equivalent of `ncases` but operates on the first hypothesis that can
599 be introduced. We then introduce the two sides of the conjunction.
600
601 D[def-fish-rec-5-1]
602 The goal is now the existence of an a point in `𝐂 a i` fished by `U`.
603 We thus need to use the introduction rule for the existential quantifier.
604 In CIC it is a defined notion, that is an inductive type with just
605 one constructor (one introduction rule) holding the witness and the proof
606 that the witness satisfies a proposition.
607
608 > ncheck Ex.
609
610 Instead of trying to remember the name of the constructor, that should
611 be used as the argument of `napply`, we can ask the system to find by
612 itself the constructor name and apply it with the `@` tactic. 
613 Note that some inductive predicates, like the disjunction, have multiple
614 introduction rules, and thus `@` can be followed by a number identifying
615 the constructor.
616
617 D[def-fish-rec-6]
618 After choosing `x` as the witness, we have to prove a conjunction,
619 and we again apply the introduction rule for the inductively defined
620 predicate `∧`.
621
622 D[def-fish-rec-7]
623 The left hand side of the conjunction is trivial to prove, since it 
624 is already in the context. The right hand side needs to perform
625 the co-recursive call.
626
627 D[def-fish-rec-9]
628 The co-recursive call needs some arguments, but all of them live
629 in the context. Instead of explicitly mention them, we use the
630 `nassumption` tactic, that simply tries to apply every context item.
631
632 D*)
633
634 (*D
635
636 Subset of covered/fished points
637 -------------------------------
638
639 We now have to define the subset of `S` of points covered by `U`.
640 We also define a prefix notation for it. Remember that the precedence
641 of the prefix form of a symbol has to be lower than the precedence 
642 of its infix form.
643
644 D*)
645
646 ndefinition coverage : ∀A:Ax.∀U:Ω^A.Ω^A ≝ λA,U.{ a | a ◃ U }.
647
648 notation "◃U" non associative with precedence 55 for @{ 'coverage $U }.
649
650 interpretation "coverage cover" 'coverage U = (coverage ? U).
651
652 (*D
653
654 Here we define the equation characterizing the cover relation. 
655 In the igft.ma file we proved that `◃U` is the minimum solution for
656 such equation, the interested reader should be able to reply the proof
657 with Matita.
658
659 D*)
660
661 ndefinition cover_equation : ∀A:Ax.∀U,X:Ω^A.CProp[0] ≝  λA,U,X. 
662   ∀a.a ∈ X ↔ (a ∈ U ∨ ∃i:𝐈 a.∀y.y ∈ 𝐂 a i → y ∈ X).  
663
664 ntheorem coverage_cover_equation : ∀A,U. cover_equation A U (◃U).
665 #A; #U; #a; @; #H;
666 ##[ nelim H; #b; 
667     ##[ #bU; @1; nassumption;
668     ##| #i; #CaiU; #IH; @2; @ i; #c; #cCbi; ncases (IH ? cCbi);
669         ##[ #E; @; napply E;
670         ##| #_; napply CaiU; nassumption; ##] ##]
671 ##| ncases H; ##[ #E; @; nassumption]
672     *; #j; #Hj; @2 j; #w; #wC; napply Hj; nassumption;
673 ##]
674 nqed. 
675
676 ntheorem coverage_min_cover_equation : 
677   ∀A,U,W. cover_equation A U W → ◃U ⊆ W.
678 #A; #U; #W; #H; #a; #aU; nelim aU; #b;
679 ##[ #bU; ncases (H b); #_; #H1; napply H1; @1; nassumption;
680 ##| #i; #CbiU; #IH; ncases (H b); #_; #H1; napply H1; @2; @i; napply IH;
681 ##]
682 nqed.
683
684 (*D
685
686 We similarly define the subset of point fished by `F`, the 
687 equation characterizing `⋉F` and prove that fish is
688 the biggest solution for such equation.
689
690 D*) 
691
692 notation "⋉F" non associative with precedence 55
693 for @{ 'fished $F }.
694
695 ndefinition fished : ∀A:Ax.∀F:Ω^A.Ω^A ≝ λA,F.{ a | a ⋉ F }.
696
697 interpretation "fished fish" 'fished F = (fished ? F).
698
699 ndefinition fish_equation : ∀A:Ax.∀F,X:Ω^A.CProp[0] ≝ λA,F,X.
700   ∀a. a ∈ X ↔ a ∈ F ∧ ∀i:𝐈 a.∃y.y ∈ 𝐂 a i ∧ y ∈ X. 
701   
702 ntheorem fished_fish_equation : ∀A,F. fish_equation A F (⋉F).
703 #A; #F; #a; @; (* *; non genera outtype che lega a *) #H; ncases H;
704 ##[ #b; #bF; #H2; @ bF; #i; ncases (H2 i); #c; *; #cC; #cF; @c; @ cC;
705     napply cF;  
706 ##| #aF; #H1; @ aF; napply H1;
707 ##]
708 nqed.
709
710 ntheorem fished_max_fish_equation : ∀A,F,G. fish_equation A F G → G ⊆ ⋉F.
711 #A; #F; #G; #H; #a; #aG; napply (fish_rec … aG);
712 #b; ncases (H b); #H1; #_; #bG; ncases (H1 bG); #E1; #E2; nassumption; 
713 nqed. 
714
715 (*D
716
717 Part 2, the new set of axioms
718 -----------------------------
719
720 Since the name of objects (record included) has to unique
721 within the same script, we prefix every field name
722 in the new definition of the axiom set with `n`.
723
724 D*)
725
726 nrecord nAx : Type[2] ≝ { 
727   nS:> setoid; 
728   nI: nS → Type[0];
729   nD: ∀a:nS. nI a → Type[0];
730   nd: ∀a:nS. ∀i:nI a. nD a i → nS
731 }.
732
733 (*D
734
735 We again define a notation for the projections, making the 
736 projected record an implicit argument. Note that since we already have
737 a notation for `𝐈` we just add another interpretation for it. The
738 system, looking at the argument of `𝐈`, will be able to use
739 the correct interpretation. 
740
741 D*)
742
743 notation "𝐃 \sub ( ❨a,\emsp i❩ )" non associative with precedence 70 for @{ 'D $a $i }.
744 notation "𝐝 \sub ( ❨a,\emsp i,\emsp j❩ )" non associative with precedence 70 for @{ 'd $a $i $j}.
745
746 notation > "𝐃 term 90 a term 90 i" non associative with precedence 70 for @{ 'D $a $i }.
747 notation > "𝐝 term 90 a term 90 i term 90 j" non associative with precedence 70 for @{ 'd $a $i $j}.
748
749 interpretation "D" 'D a i = (nD ? a i).
750 interpretation "d" 'd a i j = (nd ? a i j).
751 interpretation "new I" 'I a = (nI ? a).
752
753 (*D
754
755 The paper defines the image as
756
757 > Im[d(a,i)] = { d(a,i,j) | j : D(a,i) }
758
759 but this not so formal notation poses some problems. The image is
760 often used as the left hand side of the ⊆ predicate
761
762 > Im[d(a,i)] ⊆ V
763
764 Of course this writing is interpreted by the authors as follows 
765
766 > ∀j:D(a,i). d(a,i,j) ∈ V
767
768 If we need to use the image to define 𝐂 (a subset of S) we are obliged to
769 form a subset, i.e. to place a single variable `{ here | … }`.
770
771 > Im[d(a,i)] = { y | ∃j:D(a,i). y = d(a,i,j) }
772
773 This poses no theoretical problems, since `S` is a setoid and thus equipped
774 with an equality.
775
776 Unless we difene two different images, one for stating the image is ⊆ of
777 something and another one to define 𝐂, we end up using always the latter.
778 Thus the statement `Im[d(a,i)] ⊆ V` unfolds to
779
780 > ∀x:S. ( ∃j.x = d(a,i,j) ) → x ∈ V
781
782 That up to rewriting with the equation defining `x` is what we mean. The 
783 technical problem arises when `V` is a complex construction that has to
784 be proved extensional (i.e. ∀x,y. x = y → x ∈ V → y ∈ V).
785
786 D*)
787
788 ndefinition image ≝ λA:nAx.λa:A.λi. { x | ∃j:𝐃 a i. x = 𝐝 a i j }.
789
790 notation > "𝐈𝐦  [𝐝 term 90 a term 90 i]" non associative with precedence 70 for @{ 'Im $a $i }.
791 notation "𝐈𝐦  [𝐝 \sub ( ❨a,\emsp i❩ )]" non associative with precedence 70 for @{ 'Im $a $i }.
792
793 interpretation "image" 'Im a i = (image ? a i).
794
795 (*D
796
797 Thanks to our definition of image, we ca trivially a function mapping a
798 new axiom set to an old one and viceversa. Note that in the second
799 definition, when defining 𝐝, the projection of the Σ type is inlined
800 (constructed on the fly by `*;`) while in the paper it was named `fst`.
801
802 D*)
803
804 ndefinition Ax_of_nAx : nAx → Ax.
805 #A; @ A (nI ?); #a; #i; napply (𝐈𝐦 [𝐝 a i]);
806 nqed.
807
808 ndefinition nAx_of_Ax : Ax → nAx.
809 #A; @ A (I ?);
810 ##[ #a; #i; napply (Σx:A.x ∈ 𝐂 a i);
811 ##| #a; #i; *; #x; #_; napply x;
812 ##]
813 nqed.
814
815 (*D
816
817 We then define the inductive type of ordinals, parametrized over an axiom
818 set. We also attach some notations to the constructors.
819
820 D*)
821
822 ninductive Ord (A : nAx) : Type[0] ≝ 
823  | oO : Ord A
824  | oS : Ord A → Ord A
825  | oL : ∀a:A.∀i.∀f:𝐃 a i → Ord A. Ord A.
826
827 notation "0" non associative with precedence 90 for @{ 'oO }.
828 notation "Λ term 90 f" non associative with precedence 50 for @{ 'oL $f }.
829 notation "x+1" non associative with precedence 50 for @{'oS $x }.
830
831 interpretation "ordinals Zero" 'oO = (oO ?).
832 interpretation "ordinals Lambda" 'oL f = (oL ? ? ? f).
833 interpretation "ordinals Succ" 'oS x = (oS ? x).
834
835 (*D
836
837 The dfinition of `U_x` is by recursion over the ordinal `x`. 
838 We thus define a recursive function. The `on x` directive tells
839 the system on which argument the function is (structurally) recursive.
840
841 In the `oS` case we use a local definition to name the recursive call
842 since it is used twice.
843
844 Note that Matita does not support notation in the left hand side
845 of a pattern match, and thus the names of the constructors have to 
846 be spelled out verbatim.
847
848 D*)
849
850 nlet rec famU (A : nAx) (U : Ω^A) (x : Ord A) on x : Ω^A ≝ 
851   match x with
852   [ oO ⇒ U
853   | oS y ⇒ let U_n ≝ famU A U y in U_n ∪ { x | ∃i.𝐈𝐦[𝐝 x i] ⊆ U_n} 
854   | oL a i f ⇒ { x | ∃j.x ∈ famU A U (f j) } ].
855   
856 notation < "term 90 U \sub (term 90 x)" non associative with precedence 50 for @{ 'famU $U $x }.
857 notation > "U ⎽ term 90 x" non associative with precedence 50 for @{ 'famU $U $x }.
858
859 interpretation "famU" 'famU U x = (famU ? U x).
860
861 (*D
862
863 We attach as the input notation for U_x the similar `U⎽x` where underscore,
864 that is a character valid for identifier names, has been replaced by `⎽` that is
865 not. The symbol `⎽` can act as a separator, and can be typed as an alternative
866 for `_` (i.e. pressing ALT-L after `_`). 
867
868 The notion ◃(U) has to be defined as the subset of of y 
869 belonging to U_x for some x. Moreover, we have to define the notion
870 of cover between sets again, since the one defined at the beginning
871 of the tutorial works only for the old axiom set definition.
872
873 D*)
874   
875 ndefinition ord_coverage : ∀A:nAx.∀U:Ω^A.Ω^A ≝ λA,U.{ y | ∃x:Ord A. y ∈ famU ? U x }.
876
877 ndefinition ord_cover_set ≝ λc:∀A:nAx.Ω^A → Ω^A.λA,C,U.
878   ∀y.y ∈ C → y ∈ c A U.
879
880 interpretation "coverage new cover" 'coverage U = (ord_coverage ? U).
881 interpretation "new covers set" 'covers a U = (ord_cover_set ord_coverage ? a U).
882 interpretation "new covers" 'covers a U = (mem ? (ord_coverage ? U) a).
883
884 (*D
885
886 Before proving that this cover relation validates the reflexivity and infinity
887 rules, we prove this little technical lemma that is used in the proof for the 
888 infinity rule.
889
890 D*)
891
892 nlemma ord_subset: ∀A:nAx.∀a:A.∀i,f,U.∀j:𝐃 a i. U⎽(f j) ⊆ U⎽(Λ f).
893 #A; #a; #i; #f; #U; #j; #b; #bUf; @ j; nassumption;
894 nqed.
895
896 (*D
897
898 The proof of infinity uses the following form of the Axiom of choice,
899 that cannot be prove inside Matita, since the existential quantifier
900 lives in the sort of predicative propositions while the sigma in the conclusion
901 lives in the sort of data types, and thus the former cannot be eliminated
902 to provide the second.
903
904 D*)
905
906 naxiom AC : ∀A,a,i,U.
907   (∀j:𝐃 a i.∃x:Ord A.𝐝 a i j ∈ U⎽x) → (Σf.∀j:𝐃 a i.𝐝 a i j ∈ U⎽(f j)).
908
909 (*D
910
911 In the proof of infinity, we have to rewrite under the ∈ predicate.
912 It is clearly possible to show that U⎽x is an extensional set:
913
914 > a = b → a ∈ U⎽x → b ∈ U⎽x
915
916 Anyway this proof in non trivial induction over x, that requires 𝐈 and 𝐃 to be
917 declared as morphisms. This poses to problem, but goes out of the scope of the 
918 tutorial and we thus assume it.
919
920 D*)
921
922 naxiom U_x_is_ext: ∀A:nAx.∀a,b:A.∀x.∀U. a = b → b ∈ U⎽x → a ∈ U⎽x.
923
924 (*D
925
926 The reflexivity proof is trivial, it is enough to provide the ordinal 0
927 as a witness, then ◃(U) reduces to U by definition, hence the conclusion.
928
929 D*)
930 ntheorem new_coverage_reflexive: ∀A:nAx.∀U:Ω^A.∀a. a ∈ U → a ◃ U.
931 #A; #U; #a; #H; @ (0); napply H;
932 nqed.
933
934 (*D
935
936 We now proceed with the proof of the infinity rule.
937
938 D*)
939
940 alias symbol "covers" = "new covers set".
941 alias symbol "covers" = "new covers".
942 alias symbol "covers" = "new covers set".
943 alias symbol "covers" = "new covers".
944 alias symbol "covers" = "new covers set".
945 alias symbol "covers" = "new covers".
946 alias symbol "covers" = "new covers set".
947 alias symbol "covers" = "new covers".
948 ntheorem new_coverage_infinity:
949   ∀A:nAx.∀U:Ω^A.∀a:A. (∃i:𝐈 a. 𝐈𝐦[𝐝 a i] ◃ U) → a ◃ U.
950 #A; #U; #a;                                   (** screenshot "n-cov-inf-1". *)  
951 *; #i; #H; nnormalize in H;                   (** screenshot "n-cov-inf-2". *)
952 ncut (∀y:𝐃 a i.∃x:Ord A.𝐝 a i y ∈ U⎽x); ##[    (** screenshot "n-cov-inf-3". *)
953   #z; napply H; @ z; napply #; ##] #H';       (** screenshot "n-cov-inf-4". *)
954 ncases (AC … H'); #f; #Hf;                    (** screenshot "n-cov-inf-5". *)
955 ncut (∀j.𝐝 a i j ∈ U⎽(Λ f));
956   ##[ #j; napply (ord_subset … f … (Hf j));##] #Hf';(** screenshot "n-cov-inf-6". *)
957 @ (Λ f+1);                                    (** screenshot "n-cov-inf-7". *)
958 @2;                                           (** screenshot "n-cov-inf-8". *) 
959 @i; #x; *; #d; #Hd;                           (** screenshot "n-cov-inf-9". *)  
960 napply (U_x_is_ext … Hd); napply Hf';
961 nqed.
962
963 (*D
964 D[n-cov-inf-1]
965 We eliminate the existential, obtaining an `i` and a proof that the 
966 image of d(a,i) is covered by U. The `nnormalize` tactic computes the normal
967 form of `H`, thus expands the definition of cover between sets.
968
969 D[n-cov-inf-2]
970 The paper proof considers `H` implicitly substitutes the equation assumed
971 by `H` in its conclusion. In Matita this step is not completely trivia.
972 We thus assert (`ncut`) the nicer form of `H`.
973
974 D[n-cov-inf-3]
975 After introducing `z`, `H` can be applied (choosing `𝐝 a i z` as `y`). 
976 What is the left to prove is that `∃j: 𝐃 a j. 𝐝 a i z = 𝐝 a i j`, that 
977 becomes trivial is `j` is chosen to be `z`. In the command `napply #`,
978 the `#` is a standard notation for the reflexivity property of the equality. 
979
980 D[n-cov-inf-4]
981 Under `H'` the axiom of choice `AC` can be eliminated, obtaining the `f` and 
982 its property. Note that the axiom `AC` was abstracted over `A,a,i,U` before
983 assuming `(∀j:𝐃 a i.∃x:Ord A.𝐝 a i j ∈ U⎽x)`. Thus the term that can be eliminated
984 is `AC ???? H'` where the system is able to infer every `?`. Matita provides
985 a facility to specify a number of `?` in a compact way, i.e. `…`. The system
986 expand `…` first to zero, then one, then two, three and finally four question 
987 marks, "guessing" how may of them are needed. 
988
989 D[n-cov-inf-5]
990 The paper proof does now a forward reasoning step, deriving (by the ord_subset 
991 lemma we proved above) `Hf'` i.e. 𝐝 a i j ∈ U⎽(Λf).
992
993 D[n-cov-inf-6]
994 To prove that `a◃U` we have to exhibit the ordinal x such that `a ∈ U⎽x`.
995
996 D[n-cov-inf-7]
997 The definition of `U⎽(…+1)` expands to the union of two sets, and proving
998 that `a ∈ X ∪ Y` is defined as proving that `a` is in `X` or `Y`. Applying
999 the second constructor `@2;` of the disjunction, we are left to prove that `a` 
1000 belongs to the right hand side.
1001
1002 D[n-cov-inf-8]
1003 We thus provide `i`, introduce the element being in the image and we are
1004 left to prove that it belongs to `U_(Λf)`. In the meanwhile, since belonging 
1005 to the image means that there exists an object in the domain… we eliminate the
1006 existential, obtaining `d` (of type `𝐃 a i`) and the equation defining `x`.  
1007
1008 D[n-cov-inf-9]
1009 We just need to use the equational definition of `x` to obtain a conclusion
1010 that can be proved with `Hf'`. We assumed that `U⎽x` is extensional for
1011 every `x`, thus we are allowed to use `Hd` and close the proof.
1012
1013 D*)
1014
1015 (*D
1016
1017 The next proof is that ◃(U) is mininal. The hardest part of the proof
1018 is to prepare the goal for the induction. The desiderata is to prove
1019 `U⎽o ⊆ V` by induction on `o`, but the conclusion of the lemma is,
1020 unfolding all definitions:
1021
1022 > ∀x. x ∈ { y | ∃o:Ord A.y ∈ U⎽o } → x ∈ V
1023
1024 D*)
1025
1026 nlemma new_coverage_min :  
1027   ∀A:nAx.∀U:Ω^A.∀V.U ⊆ V → (∀a:A.∀i.𝐈𝐦[𝐝 a i] ⊆ V → a ∈ V) → ◃U ⊆ V.
1028 #A; #U; #V; #HUV; #Im;#b;                       (** screenshot "n-cov-min-2". *)
1029 *; #o;                                          (** screenshot "n-cov-min-3". *)
1030 ngeneralize in match b; nchange with (U⎽o ⊆ V); (** screenshot "n-cov-min-4". *)
1031 nelim o;                                        (** screenshot "n-cov-min-5". *) 
1032 ##[ #b; #bU0; napply HUV; napply bU0;
1033 ##| #p; #IH; napply subseteq_union_l; ##[ nassumption; ##]
1034     #x; *; #i; #H; napply (Im ? i); napply (subseteq_trans … IH); napply H;
1035 ##| #a; #i; #f; #IH; #x; *; #d; napply IH; ##]
1036 nqed.
1037
1038 (*D
1039 D[n-cov-min-2]
1040 After all the introductions, event the element hidden in the ⊆ definition,
1041 we have to eliminate the existential quantifier, obtaining the ordinal `o`
1042
1043 D[n-cov-min-3]
1044 What is left is almost right, but the element `b` is already in the
1045 context. We thus generalize every occurrence of `b` in 
1046 the current goal, obtaining `∀c.c ∈ U⎽o → c ∈ V` that is `U⎽o ⊆ V`.
1047
1048 D[n-cov-min-4]
1049 We then proceed by induction on `o` obtaining the following goals
1050
1051 D[n-cov-min-5]
1052 All of them can be proved using simple set theoretic arguments,
1053 the induction hypothesis and the assumption `Im`.
1054
1055 D*)
1056
1057
1058 (*D
1059
1060 The notion `F⎽x` is again defined by recursion over the ordinal `x`.
1061
1062 D*)
1063
1064 nlet rec famF (A: nAx) (F : Ω^A) (x : Ord A) on x : Ω^A ≝ 
1065   match x with
1066   [ oO ⇒ F
1067   | oS o ⇒ let F_o ≝ famF A F o in F_o ∩ { x | ∀i:𝐈 x.∃j:𝐃 x i.𝐝 x i j ∈ F_o } 
1068   | oL a i f ⇒ { x | ∀j:𝐃 a i.x ∈ famF A F (f j) }
1069   ].
1070
1071 interpretation "famF" 'famU U x = (famF ? U x).
1072
1073 ndefinition ord_fished : ∀A:nAx.∀F:Ω^A.Ω^A ≝ λA,F.{ y | ∀x:Ord A. y ∈ F⎽x }.
1074
1075 interpretation "fished new fish" 'fished U = (ord_fished ? U).
1076 interpretation "new fish" 'fish a U = (mem ? (ord_fished ? U) a).
1077
1078 (*D
1079
1080 The proof of compatibility uses this little result, that we 
1081 proved outside the mail proof. 
1082
1083 D*)
1084 nlemma co_ord_subset: ∀A:nAx.∀F:Ω^A.∀a,i.∀f:𝐃 a i → Ord A.∀j. F⎽(Λ f) ⊆ F⎽(f j).
1085 #A; #F; #a; #i; #f; #j; #x; #H; napply H;
1086 nqed.
1087
1088 (*D
1089
1090 We assume the dual of the axiom of choice, as in the paper proof.
1091
1092 D*)
1093 naxiom AC_dual: ∀A:nAx.∀a:A.∀i,F. 
1094  (∀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.
1095
1096 (*D
1097
1098 Proving the anti-reflexivity property is simple, since the
1099 assumption `a ⋉ F` states that for every ordinal `x` (and thus also 0)
1100 `a ∈ F⎽x`. If `x` is choosen to be `0`, we obtain the thesis.
1101
1102 D*)
1103 ntheorem new_fish_antirefl: ∀A:nAx.∀F:Ω^A.∀a. a ⋉ F → a ∈ F.
1104 #A; #F; #a; #H; nlapply (H 0); #aFo; napply aFo;
1105 nqed.
1106
1107 (*D
1108
1109 We now prove the compatibility property for the new fish relation.
1110
1111 D*)
1112 ntheorem new_fish_compatible: 
1113  ∀A:nAx.∀F:Ω^A.∀a. a ⋉ F → ∀i:𝐈 a.∃j:𝐃 a i.𝐝 a i j ⋉ F.
1114 #A; #F; #a; #aF; #i; nnormalize;               (** screenshot "n-f-compat-1". *)
1115 napply AC_dual; #f;                            (** screenshot "n-f-compat-2". *)
1116 nlapply (aF (Λf+1)); #aLf;                     (** screenshot "n-f-compat-3". *)
1117 nchange in aLf with 
1118   (a ∈ F⎽(Λ f) ∧ ∀i:𝐈 a.∃j:𝐃 a i.𝐝 a i j ∈ F⎽(Λ f)); (** screenshot "n-f-compat-4". *)
1119 ncases aLf; #_; #H; nlapply (H i);                 (** screenshot "n-f-compat-5". *)
1120 *; #j; #Hj; @j;                                    (** screenshot "n-f-compat-6". *)
1121 napply (co_ord_subset … Hj);
1122 nqed.
1123
1124 (*D
1125 D[n-f-compat-1]
1126 After reducing to normal form the goal, we obseve it is exactly the conlusion of
1127 the dual axiom of choice we just assumed. We thus apply it ad introduce the 
1128 fcuntion `f`.
1129
1130 D[n-f-compat-2]
1131 The hypothesis `aF` states that `a⋉F⎽x` for every `x`, and we choose `Λf+1`.
1132
1133 D[n-f-compat-3]
1134 Since F_(Λf+1) is defined by recursion and we actually have a concrete input
1135 `Λf+1` for that recursive function, it can compute. Anyway, using the `nnormalize`
1136 tactic would reduce too much (both the `+1` and the `Λf` steps would be prformed);
1137 we thus explicitly give a convertible type for that hypothesis, corresponding 
1138 the computation of the `+1` step, plus the unfolding of `∩`.
1139
1140 D[n-f-compat-4]
1141 We are interested in the right hand side of `aLf`, an in particular to
1142 its intance where the generic index in `𝐈 a` is `i`.
1143
1144 D[n-f-compat-5]
1145 We then eliminate the existential, obtaining `j` and its property `Hj`. We provide
1146 the same witness 
1147
1148 D[n-f-compat-6]
1149 What is left to prove is exactly the `co_ord_subset` lemma we factored out
1150 of the main proof.
1151
1152 D*)
1153
1154 (*D
1155
1156 The proof that `⋉(F)` is maximal is exactly the dual one of the
1157 minimality of `◃(U)`. Thus the main problem is to obtain `G ⊆ F⎽o`
1158 before doing the induction over `o`.
1159
1160 Note that `G` is assumed to be of type `𝛀^A`, that means an extensional
1161 subset of `S`, while `Ω^A` means just a subset (note that the former is bold). 
1162
1163 D*)
1164 ntheorem max_new_fished: 
1165   ∀A:nAx.∀G:𝛀^A.∀F:Ω^A.G ⊆ F → (∀a.a ∈ G → ∀i.𝐈𝐦[𝐝 a i] ≬ G) → G ⊆ ⋉F.
1166 #A; #G; #F; #GF; #H; #b; #HbG; #o; 
1167 ngeneralize in match HbG; ngeneralize in match b;
1168 nchange with (G ⊆ F⎽o);
1169 nelim o;
1170 ##[ napply GF;
1171 ##| #p; #IH; napply (subseteq_intersection_r … IH);
1172     #x; #Hx; #i; ncases (H … Hx i); #c; *; *; #d; #Ed; #cG;
1173     @d; napply IH;                                (** screenshot "n-f-max-1". *)
1174     alias symbol "prop2" = "prop21".
1175     napply (. Ed^-1‡#); napply cG;    
1176 ##| #a; #i; #f; #Hf; nchange with (G ⊆ { y | ∀x. y ∈ F⎽(f x) }); 
1177     #b; #Hb; #d; napply (Hf d); napply Hb;
1178 ##]
1179 nqed.
1180
1181 (*D
1182 D[n-f-max-1]
1183 Here the situacion look really similar to the one of the dual proof where 
1184 we had to apply the assumption `U_x_is_ext`, but here the set is just `G`
1185 not `F_x`. Since we assumed `G` to be extensional we can employ the facilities
1186 Matita provides to perform rewriting in the general setting of setoids.
1187
1188 The lemma `.` simply triggers the mechanism, and the given argument has to
1189 mimick the context under which the rewriting has to happen. In that case
1190 we want to rewrite to the left of the binary morphism `∈`. The infix notation
1191 to represent the context of a binary morphism is `‡`. The right hand side 
1192 has to be left untouched, and the identity rewriting step is represented with 
1193 `#` (actually a reflexivity proof for the subterm identified by the context). 
1194
1195 We want to rewrite the left hand side using `Ed` right-to-left (the default
1196 is left-to-right). We thus write `Ed^-1`, that is a proof that `𝐝 x i d = c`. 
1197
1198 The complete command is `napply (. Ed^-1‡#)` that has to be read like:
1199
1200 > perform some rewritings under a binary morphism, 
1201 > on the right do nothing, 
1202 > on the left rewrite with Ed right-to-left.
1203
1204 After the rewriting step the goal is exactly the `cG` assumption.
1205
1206 D*)
1207
1208
1209 (*D
1210 <div id="appendix" class="anchor"></div>
1211 Appendix: tactics explanation
1212 -----------------------------
1213
1214 In this appendix we try to give a description of tactics
1215 in terms of sequent calculus rules annotated with proofs.
1216 The `:` separator has to be read as _is a proof of_, in the spirit
1217 of the Curry-Howard isomorphism.
1218
1219                   Γ ⊢  f  :  A1 → … → An → B    Γ ⊢ ?1 : A1 … ?n  :  An 
1220     napply f;    ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1221                            Γ ⊢ (f ?1 … ?n )  :  B
1222  
1223                    Γ ⊢  ?  :  F → B       Γ ⊢ f  :  F 
1224     nlapply f;    ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1225                              Γ ⊢ (? f)  :  B
1226
1227
1228                  Γ; x : T  ⊢ ?  :  P(x) 
1229     #x;      ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1230                 Γ ⊢ λx:T.?  :  ∀x:T.P(x)
1231
1232                        
1233                        Γ ⊢ ?_i  :  args_i → P(k_i args_i)          
1234     ncases x;   ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1235                 Γ ⊢ match x with [ k1 args1 ⇒ ?_1 | … | kn argsn ⇒ ?_n ]  :  P(x)                    
1236
1237
1238                       Γ ⊢ ?i  :  ∀t. P(t) → P(k_i … t …)          
1239     nelim x;   ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1240                    Γ ⊢ (T_rect_CProp0 ?_1 … ?_n)  :  P(x)                    
1241
1242 Where `T_rect_CProp0` is the induction principle for the 
1243 inductive type `T`.
1244
1245
1246                           Γ ⊢ ?  :  Q     Q ≡ P          
1247     nchange with Q;   ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1248                           Γ ⊢ ?  :  P                    
1249
1250 Where the equivalence relation between types `≡` keeps into account
1251 β-reduction, δ-reduction (definition unfolding), ζ-reduction (local
1252 definition unfolding), ι-reduction (pattern matching simplification),
1253 μ-reduction (recursive function computation) and ν-reduction (co-fixpoint
1254 computation).
1255
1256
1257                                Γ; H : Q; Δ ⊢ ?  :  G     Q ≡ P          
1258     nchange in H with Q; ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1259                                Γ; H : P; Δ ⊢ ?  :  G                    
1260
1261
1262                                Γ; H : Q; Δ ⊢ ?  :  G     P →* Q           
1263     nnormalize in H; ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1264                                Γ; H : P; Δ ⊢ ?  :  G                    
1265
1266 Where `Q` is the normal form of `P` considering βδζιμν-reduction steps.
1267
1268
1269                        Γ ⊢ ?  :  Q     P →* Q          
1270     nnormalize; ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1271                        Γ ⊢ ?  :  P                    
1272
1273
1274                     Γ ⊢ ?_2  :  T → G    Γ ⊢ ?_1  :  T
1275     ncut T;   ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1276                                Γ ⊢ (?_2 ?_1)  :  G                    
1277
1278
1279                                 Γ ⊢ ?  :  ∀x.P(x)
1280     ngeneralize in match t; ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
1281                                 Γ ⊢ (? t)  :  P(t)
1282                                 
1283 D*)
1284
1285
1286 (*D
1287
1288 <date>
1289 Last updated: $Date$
1290 </date>
1291
1292 [1]: http://upsilon.cc/~zack/research/publications/notation.pdf 
1293
1294 D*)