]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/library/didactic/exercises/shannon.ma
f0a191729a95d8be7972a3a069a4b42f92b99760
[helm.git] / helm / software / matita / library / didactic / exercises / shannon.ma
1 (* Esercizio 0
2    ===========
3
4    Compilare i seguenti campi:
5
6    Nome1: ...
7    Cognome1: ...
8    Matricola1: ...
9    Account1: ...
10
11    Nome2: ...
12    Cognome2: ...
13    Matricola2: ...
14    Account2: ...
15
16 *)
17
18 (* ATTENZIONE
19    ==========
20    
21    Non modificare quanto segue 
22 *)
23 include "nat/minus.ma".
24 definition if_then_else ≝ λT:Type.λe,t,f.match e return λ_.T with [ true ⇒ t | false ⇒ f].
25 notation > "'if' term 19 e 'then' term 19 t 'else' term 90 f" non associative with precedence 19 for @{ 'if_then_else $e $t $f }.
26 notation < "'if' \nbsp term 19 e \nbsp 'then' \nbsp term 19 t \nbsp 'else' \nbsp term 90 f \nbsp" non associative with precedence 19 for @{ 'if_then_else $e $t $f }.
27 interpretation "Formula if_then_else" 'if_then_else e t f = (if_then_else _ e t f).
28 definition max ≝ λn,m. if eqb (n - m) 0 then m else n. 
29 definition min ≝ λn,m. if eqb (n - m) 0 then n else m. 
30
31 (* Ripasso 1
32    =========
33    
34    Il linguaggio delle formule, dove gli atomi sono
35    rapperesentati da un numero naturale
36 *)
37 inductive Formula : Type ≝
38 | FBot: Formula
39 | FTop: Formula
40 | FAtom: nat → Formula
41 | FAnd: Formula → Formula → Formula
42 | FOr: Formula → Formula → Formula
43 | FImpl: Formula → Formula → Formula
44 | FNot: Formula → Formula
45 .
46
47 (* Ripasso 2
48    =========
49    
50    La semantica di una formula `F` in un mondo `v`: `[[ F ]]_v` 
51 *)
52 let rec sem (v: nat → nat) (F: Formula) on F : nat ≝
53  match F with
54   [ FBot ⇒ 0
55   | FTop ⇒ 1
56   | FAtom n ⇒ min (v n) 1
57   | FAnd F1 F2 ⇒ min (sem v F1) (sem v F2)
58   | FOr F1 F2 ⇒ max (sem v F1) (sem v F2)
59   | FImpl F1 F2 ⇒ max (1 - sem v F1) (sem v F2)
60   | FNot F1 ⇒ 1 - (sem v F1)
61   ]
62 .
63
64 (* ATTENZIONE
65    ==========
66    
67    Non modificare quanto segue.
68 *)
69 notation < "[[ \nbsp term 19 a \nbsp ]] \nbsp \sub term 90 v" non associative with precedence 90 for @{ 'semantics $v $a }.
70 notation > "[[ term 19 a ]] \sub term 90 v" non associative with precedence 90 for @{ 'semantics $v $a }.
71 notation > "[[ term 19 a ]]_ term 90 v" non associative with precedence 90 for @{ sem $v $a }.
72 interpretation "Semantic of Formula" 'semantics v a = (sem v a).
73 lemma sem_bool : ∀F,v. [[ F ]]_v = 0 ∨ [[ F ]]_v = 1.  intros; elim F; simplify; [left;reflexivity; |right;reflexivity; |cases (v n);[left;|cases n1;right;]reflexivity; |4,5,6: cases H; cases H1; rewrite > H2; rewrite > H3; simplify; first [ left;reflexivity | right; reflexivity ].  |cases H; rewrite > H1; simplify;[right|left]reflexivity;] qed.
74
75 (* Ripasso 3
76    =========
77    
78    L'operazione di sostituzione di una formula `G` al posto dell'atomo
79    `x` in una formula `F`: `F[G/x]` 
80 *)
81
82 let rec subst (x:nat) (G: Formula) (F: Formula) on F ≝
83  match F with
84   [ FBot ⇒ FBot
85   | FTop ⇒ FTop
86   | FAtom n ⇒ if eqb n x then G else (FAtom n)
87   | FAnd F1 F2 ⇒ FAnd (subst x G F1) (subst x G F2)
88   | FOr F1 F2 ⇒ FOr (subst x G F1) (subst x G F2)
89   | FImpl F1 F2 ⇒ FImpl (subst x G F1) (subst x G F2)
90   | FNot F ⇒ FNot (subst x G F)
91   ].
92
93 (* ATTENZIONE
94    ==========
95    
96    Non modificare quanto segue.
97 *)  
98 notation < "t [ \nbsp term 19 a / term 19 b \nbsp ]" non associative with precedence 19 for @{ 'substitution $b $a $t }.
99 notation > "t [ term 90 a / term 90 b]" non associative with precedence 19 for @{ 'substitution $b $a $t }.
100 interpretation "Substitution for Formula" 'substitution b a t = (subst b a t).
101 definition equiv ≝ λF1,F2. ∀v.[[ F1 ]]_v = [[ F2 ]]_v.
102 notation "hvbox(a \nbsp break mstyle color #0000ff (≡) \nbsp b)"  non associative with precedence 45 for @{ 'equivF $a $b }.
103 notation > "a ≡ b" non associative with precedence 50 for @{ equiv $a $b }.
104 interpretation "equivalence for Formulas" 'equivF a b = (equiv a b).
105 lemma min_1_sem: ∀F,v.min 1 [[ F ]]_v = [[ F ]]_v. intros; cases (sem_bool F v); rewrite > H; reflexivity; qed.
106 lemma max_0_sem: ∀F,v.max [[ F ]]_v 0 = [[ F ]]_v. intros; cases (sem_bool F v); rewrite > H; reflexivity; qed.
107 definition IFTE := λA,B,C:Formula. FOr (FAnd A B) (FAnd (FNot A) C).
108
109 (*DOCBEGIN
110
111 La libreria di Matita
112 =====================
113
114 Per portare a termine l'esercitazione sono necessari i seguenti lemmi:
115
116 * lemma `decidable_eq_nat` : `∀x,y.x = y ∨ x ≠ y`
117 * lemma `sem_bool` : `∀F,v. [[ F ]]_v = 0 ∨ [[ F ]]_v = 1`
118 * lemma `not_eq_to_eqb_false` : `∀x,y.x ≠ y → eqb x y = false`
119 * lemma `eq_to_eqb_true` : `∀x,y.x = y → eqb x y = true`
120 * lemma `min_1_sem` : `∀F,v.min 1 [[ F ]]_v = [[ F ]]_v`
121 * lemma `max_0_sem` : `∀F,v.max [[ F ]]_v 0 = [[ F ]]_v`
122
123 Nota su `x = y` e `eqb x y`
124 ---------------------------
125
126 Se vi siete mai chiesti la differenza tra `x = y` ed `eqb x y`
127 quanto segue prova a chiarirla.
128
129 Presi due numeri `x` e `y` in ℕ, dire che `x = y` significa i due numeri 
130 sono lo stesso numero, ovvero che se `x` è il numero `3`,
131 anche `y` è il numero `3`.
132
133 `eqb` è un funzione, un programma, che confronta due numeri naturali
134 e restituisce `true` se sono uguali, `false` se sono diversi. L'utilizzo
135 di tale programma è necessario per usare il costrutto (che è a sua volta 
136 un programma) `if E then A else B`, che lancia il programma `E`, 
137 e se il suo
138 risultato è `true` si comporta come `A` altrimenti come `B`. Come
139 ben sapete i programmi possono contenere errori. In particolare anche
140 `eqb` potrebbe essere sbagliato, e per esempio restituire sempre `true`. 
141 I teoremi `eq_to_eqb_true` e 
142 `not_eq_to_eqb_false` sono la dimostrazione che il programma `eqb` è 
143 corretto, ovvero che che se `x = y` allora `eqb x y` restituisce `true`,
144 se `x ≠ y` allora `eqb x y` restituisce `false`.  
145
146 Il teorema di espansione di Shannon
147 ===================================
148
149 Si definisce un connettivo logico `IFTE A B C` come
150  
151         FOr (FAnd A B) (FAnd (FNot A) C)
152
153 Il teorema dice che data una formula `F`, e preso un atomo `x`, la seguente 
154 formula è equivalente a `F`:
155
156         IFTE (FAtom x) (F[FTop/x]) (F[FBot/x])
157         
158 Ovvero, fissato un mondo `v`, sostituisco l'atomo `x` con `FBot` se tale 
159 atomo è falso, lo sostituisco con `FTop` se è vero.
160
161 La dimostrazione è composta da due lemmi, `shannon_false` e `shannon_true`.
162
163 Vediamo solo la dimostrazione del primo, essendo il secondo del tutto analogo.
164 Il lemma asserisce quanto segue:
165
166         ∀F,x,v. [[ FAtom x ]]_v = 0 → [[ F[FBot/x] ]]_v = [[ F ]]_v
167         
168 Una volta assunte la formula `F`, l'atomo `x`, il mondo `v` e aver 
169 supposto che `[[ FAtom x ]]_v = 0` si procede per induzione su `F`.
170 I casi `FTop` e `FBot` sono banali. Nei casi `FAnd/FOr/FImpl/FNot`,
171 una volta assunte le sottoformule e le relative ipotesi induttive, 
172 si conclude con una catena di uguaglianze.
173
174 Il caso `FAtom` richiede maggiore cura. Assunto l'indice dell'atomo `n`,
175 occorre utilizzare il lemma `decidable_eq_nat` per ottenere l'ipotesi
176 aggiuntiva `n = x ∨ n ≠ x` (dove `x` è l'atomo su cui predica il teorema).
177 Si procede per casi sull'ipotesi appena ottenuta.
178 In entrambi i casi, usando i lemmi `eq_to_eqb_true` oppure `not_eq_to_eqb_false`
179 si ottengolo le ipotesi aggiuntive `(eqb n x = true)` oppure `(eqb n x = false)`.
180 Entrambi i casi si concludono con una catena di uguaglianze.
181
182 Il teorema principale si dimostra utilizzando il lemma `sem_bool` per 
183 ottenre l'ipotesi `[[ FAtom x ]]_v = 0 ∨ [[ FAtom x ]]_v = 1` su cui
184 si procede poi per casi. Entrambi i casi si concludono con
185 una catena di uguaglianze che utilizza i lemmi dimostrati in precedenza 
186 e i lemmi `min_1_sem` oppure `max_0_sem`.
187
188 DOCEND*)
189
190 lemma shannon_false: 
191   ∀F,x,v. [[ FAtom x ]]_v = 0 → [[ F[FBot/x] ]]_v = [[ F ]]_v.
192 (*BEGIN*)
193 assume F : Formula.
194 assume x : ℕ.
195 assume v : (ℕ → ℕ).
196 suppose ([[ FAtom x ]]_v = 0) (H).
197 we proceed by induction on F to prove ([[ F[FBot/x] ]]_v = [[ F ]]_v).
198 case FBot.
199   the thesis becomes ([[ FBot[FBot/x] ]]_v = [[ FBot ]]_v).
200   the thesis becomes ([[ FBot ]]_v = [[ FBot ]]_v).
201   done. 
202 case FTop.
203   the thesis becomes ([[ FTop[FBot/x] ]]_v = [[ FTop ]]_v).
204   the thesis becomes ([[ FTop ]]_v = [[ FTop ]]_v).
205   done.
206 case FAtom.
207   assume n : ℕ.
208   the thesis becomes ([[ (FAtom n)[FBot/x] ]]_v = [[ FAtom n ]]_v).
209   the thesis becomes ([[ if eqb n x then FBot else (FAtom n) ]]_v = [[ FAtom n ]]_v).
210   by decidable_eq_nat we proved (n = x ∨ n ≠ x) (H1).
211   we proceed by cases on H1 to prove ([[ if eqb n x then FBot else (FAtom n) ]]_v = [[ FAtom n ]]_v).
212     case Left.
213       by H2, eq_to_eqb_true we proved (eqb n x = true) (H3).
214       conclude
215           ([[ if eqb n x then FBot else (FAtom n) ]]_v)
216         = ([[ if true then FBot else (FAtom n) ]]_v) by H3.
217         = ([[ FBot ]]_v). 
218         = 0.
219         = ([[ FAtom x ]]_v) by H.
220         = ([[ FAtom n ]]_v) by H2.
221     done.
222     case Right.
223       by H2, not_eq_to_eqb_false we proved (eqb n x = false) (H3).
224       conclude
225           ([[ if eqb n x then FBot else (FAtom n) ]]_v)
226         = ([[ if false then FBot else (FAtom n) ]]_v) by H3.
227         = ([[ FAtom n ]]_v). 
228     done.
229 case FAnd.
230   assume f1 : Formula.
231   by induction hypothesis we know ([[ f1[FBot/x] ]]_v = [[ f1 ]]_v) (H1).
232   assume f2 : Formula. 
233   by induction hypothesis we know ([[ f2[FBot/x] ]]_v = [[ f2 ]]_v) (H2).
234   the thesis becomes ([[ (FAnd f1 f2)[FBot/x] ]]_v = [[ FAnd f1 f2 ]]_v).
235   conclude 
236       ([[ (FAnd f1 f2)[FBot/x] ]]_v)
237     = ([[ FAnd (f1[FBot/x]) (f2[FBot/x]) ]]_v).
238     = (min [[ f1[FBot/x] ]]_v [[ f2[FBot/x] ]]_v).
239     = (min [[ f1 ]]_v [[ f2[FBot/x] ]]_v) by H1.
240     = (min [[ f1 ]]_v [[ f2 ]]_v) by H2.
241     = ([[ FAnd f1 f2 ]]_v).
242   done. 
243 case FOr.
244   assume f1 : Formula.
245   by induction hypothesis we know ([[ f1[FBot/x] ]]_v = [[ f1 ]]_v) (H1).
246   assume f2 : Formula. 
247   by induction hypothesis we know ([[ f2[FBot/x] ]]_v = [[ f2 ]]_v) (H2).
248   the thesis becomes ([[ (FOr f1 f2)[FBot/x] ]]_v = [[ FOr f1 f2 ]]_v).
249   conclude 
250       ([[ (FOr f1 f2)[FBot/x] ]]_v)
251     = ([[ FOr (f1[FBot/x]) (f2[FBot/x]) ]]_v).
252     = (max [[ f1[FBot/x] ]]_v  [[ f2[FBot/x] ]]_v).
253     = (max [[ f1 ]]_v  [[ f2[FBot/x] ]]_v) by H1.
254     = (max [[ f1 ]]_v  [[ f2 ]]_v) by H2.
255     = ([[ FOr f1 f2 ]]_v).
256   done.
257 case FImpl.
258   assume f1 : Formula.
259   by induction hypothesis we know ([[ f1[FBot/x] ]]_v = [[ f1 ]]_v) (H1).
260   assume f2 : Formula. 
261   by induction hypothesis we know ([[ f2[FBot/x] ]]_v = [[ f2 ]]_v) (H2).
262   the thesis becomes ([[ (FImpl f1 f2)[FBot/x] ]]_v = [[ FImpl f1 f2 ]]_v).
263   conclude
264       ([[ (FImpl f1 f2)[FBot/x] ]]_v)
265     = ([[ FImpl (f1[FBot/x]) (f2[FBot/x]) ]]_v).
266     = (max (1 - [[ f1[FBot/x] ]]_v) [[ f2[FBot/x] ]]_v).
267     = (max (1 - [[ f1 ]]_v) [[ f2[FBot/x] ]]_v) by H1.
268     = (max (1 - [[ f1 ]]_v) [[ f2 ]]_v) by H2.
269     = ([[ FImpl f1 f2 ]]_v).
270   done.
271 case FNot.
272   assume f : Formula.
273   by induction hypothesis we know ([[ f[FBot/x] ]]_v = [[ f ]]_v) (H1).
274   the thesis becomes ([[ (FNot f)[FBot/x] ]]_v = [[ FNot f ]]_v).
275   conclude 
276       ([[ (FNot f)[FBot/x] ]]_v)
277     = ([[ FNot (f[FBot/x]) ]]_v).
278     = (1 - [[ f[FBot/x] ]]_v).
279     = (1 - [[ f ]]_v) by H1.
280     = ([[ FNot f ]]_v).
281   done.
282 (*END*)
283 qed. 
284
285 lemma shannon_true: 
286   ∀F,x,v. [[ FAtom x ]]_v = 1 → [[ F[FTop/x] ]]_v = [[ F ]]_v.
287 (*BEGIN*)
288 assume F : Formula.
289 assume x : ℕ.
290 assume v : (ℕ → ℕ).
291 suppose ([[ FAtom x ]]_v = 1) (H).
292 we proceed by induction on F to prove ([[ F[FTop/x] ]]_v = [[ F ]]_v).
293 case FBot.
294   the thesis becomes ([[ FBot[FTop/x] ]]_v = [[ FBot ]]_v).
295   the thesis becomes ([[ FBot ]]_v = [[ FBot ]]_v).
296   done. 
297 case FTop.
298   the thesis becomes ([[ FTop[FTop/x] ]]_v = [[ FTop ]]_v).
299   the thesis becomes ([[ FTop ]]_v = [[ FTop ]]_v).
300   done.
301 case FAtom.
302   assume n : ℕ.
303   the thesis becomes ([[ (FAtom n)[FTop/x] ]]_v = [[ FAtom n ]]_v).
304   the thesis becomes ([[ if eqb n x then FTop else (FAtom n) ]]_v = [[ FAtom n ]]_v).
305   by decidable_eq_nat we proved (n = x ∨ n ≠ x) (H1).
306   we proceed by cases on H1 to prove ([[ if eqb n x then FTop else (FAtom n) ]]_v = [[ FAtom n ]]_v).
307     case Left.
308       by H2, eq_to_eqb_true we proved (eqb n x = true) (H3).
309       conclude
310           ([[ if eqb n x then FTop else (FAtom n) ]]_v)
311         = ([[ if true then FTop else (FAtom n) ]]_v) by H3.
312         = ([[ FTop ]]_v). 
313         = 1.
314         = ([[ FAtom x ]]_v) by H.
315         = ([[ FAtom n ]]_v) by H2.
316     done.
317     case Right.
318       by H2, not_eq_to_eqb_false we proved (eqb n x = false) (H3).
319       conclude
320           ([[ if eqb n x then FTop else (FAtom n) ]]_v)
321         = ([[ if false then FTop else (FAtom n) ]]_v) by H3.
322         = ([[ FAtom n ]]_v). 
323     done.
324 case FAnd.
325   assume f1 : Formula.
326   by induction hypothesis we know ([[ f1[FTop/x] ]]_v = [[ f1 ]]_v) (H1).
327   assume f2 : Formula. 
328   by induction hypothesis we know ([[ f2[FTop/x] ]]_v = [[ f2 ]]_v) (H2).
329   the thesis becomes ([[ (FAnd f1 f2)[FTop/x] ]]_v = [[ FAnd f1 f2 ]]_v).
330   conclude 
331       ([[ (FAnd f1 f2)[FTop/x] ]]_v)
332     = ([[ FAnd (f1[FTop/x]) (f2[FTop/x]) ]]_v).
333     = (min [[ f1[FTop/x] ]]_v [[ f2[FTop/x] ]]_v).
334     = (min [[ f1 ]]_v [[ f2[FTop/x] ]]_v) by H1.
335     = (min [[ f1 ]]_v [[ f2 ]]_v) by H2.
336     = ([[ FAnd f1 f2 ]]_v).
337   done. 
338 case FOr.
339   assume f1 : Formula.
340   by induction hypothesis we know ([[ f1[FTop/x] ]]_v = [[ f1 ]]_v) (H1).
341   assume f2 : Formula. 
342   by induction hypothesis we know ([[ f2[FTop/x] ]]_v = [[ f2 ]]_v) (H2).
343   the thesis becomes ([[ (FOr f1 f2)[FTop/x] ]]_v = [[ FOr f1 f2 ]]_v).
344   conclude 
345       ([[ (FOr f1 f2)[FTop/x] ]]_v)
346     = ([[ FOr (f1[FTop/x]) (f2[FTop/x]) ]]_v).
347     = (max [[ f1[FTop/x] ]]_v  [[ f2[FTop/x] ]]_v).
348     = (max [[ f1 ]]_v  [[ f2[FTop/x] ]]_v) by H1.
349     = (max [[ f1 ]]_v  [[ f2 ]]_v) by H2.
350     = ([[ FOr f1 f2 ]]_v).
351   done.
352 case FImpl.
353   assume f1 : Formula.
354   by induction hypothesis we know ([[ f1[FTop/x] ]]_v = [[ f1 ]]_v) (H1).
355   assume f2 : Formula. 
356   by induction hypothesis we know ([[ f2[FTop/x] ]]_v = [[ f2 ]]_v) (H2).
357   the thesis becomes ([[ (FImpl f1 f2)[FTop/x] ]]_v = [[ FImpl f1 f2 ]]_v).
358   conclude
359       ([[ (FImpl f1 f2)[FTop/x] ]]_v)
360     = ([[ FImpl (f1[FTop/x]) (f2[FTop/x]) ]]_v).
361     = (max (1 - [[ f1[FTop/x] ]]_v) [[ f2[FTop/x] ]]_v).
362     = (max (1 - [[ f1 ]]_v) [[ f2[FTop/x] ]]_v) by H1.
363     = (max (1 - [[ f1 ]]_v) [[ f2 ]]_v) by H2.
364     = ([[ FImpl f1 f2 ]]_v).
365   done.
366 case FNot.
367   assume f : Formula.
368   by induction hypothesis we know ([[ f[FTop/x] ]]_v = [[ f ]]_v) (H1).
369   the thesis becomes ([[ (FNot f)[FTop/x] ]]_v = [[ FNot f ]]_v).
370   conclude 
371       ([[ (FNot f)[FTop/x] ]]_v)
372     = ([[ FNot (f[FTop/x]) ]]_v).
373     = (1 - [[ f[FTop/x] ]]_v).
374     = (1 - [[ f ]]_v) by H1.
375     = ([[ FNot f ]]_v).
376   done.
377 (*END*)
378 qed. 
379
380 theorem shannon : 
381   ∀F,x. IFTE (FAtom x) (F[FTop/x]) (F[FBot/x]) ≡ F.
382 (*BEGIN*)
383 assume F : Formula.
384 assume x : ℕ.
385 assume v : (ℕ → ℕ).
386 the thesis becomes ([[ IFTE (FAtom x) (F[FTop/x]) (F[FBot/x])]]_v = [[ F ]]_v).
387 by sem_bool we proved ([[ FAtom x]]_v = 0 ∨ [[ FAtom x]]_v = 1) (H).
388 we proceed by cases on H to prove ([[ IFTE (FAtom x) (F[FTop/x]) (F[FBot/x])]]_v = [[ F ]]_v).
389 case Left.
390   conclude 
391       ([[ IFTE (FAtom x) (F[FTop/x]) (F[FBot/x])]]_v)
392     = ([[ FOr (FAnd (FAtom x) (F[FTop/x])) (FAnd (FNot (FAtom x)) (F[FBot/x]))]]_v).
393     = (max [[ (FAnd (FAtom x) (F[FTop/x])) ]]_v [[ (FAnd (FNot (FAtom x)) (F[FBot/x]))]]_v).
394     = (max (min  [[ FAtom x ]]_v [[ F[FTop/x] ]]_v) (min (1 - [[ FAtom x ]]_v) [[ F[FBot/x] ]]_v)).
395     = (max (min  0 [[ F[FTop/x] ]]_v) (min (1 - 0) [[ F[FBot/x] ]]_v)) by H.    
396     = (max 0 (min 1 [[ F[FBot/x] ]]_v)).
397     = (max 0 [[ F[FBot/x] ]]_v) by min_1_sem.
398     = ([[ F[FBot/x] ]]_v).
399     = ([[ F ]]_v) by H1, shannon_false.
400   done.
401 case Right.
402   conclude 
403       ([[ IFTE (FAtom x) (F[FTop/x]) (F[FBot/x])]]_v)
404     = ([[ FOr (FAnd (FAtom x) (F[FTop/x])) (FAnd (FNot (FAtom x)) (F[FBot/x]))]]_v).
405     = (max [[ (FAnd (FAtom x) (F[FTop/x])) ]]_v [[ (FAnd (FNot (FAtom x)) (F[FBot/x]))]]_v).
406     = (max (min  [[ FAtom x ]]_v [[ F[FTop/x] ]]_v) (min (1 - [[ FAtom x ]]_v) [[ F[FBot/x] ]]_v)).
407     = (max (min  1 [[ F[FTop/x] ]]_v) (min (1 - 1) [[ F[FBot/x] ]]_v)) by H.    
408     = (max (min  1 [[ F[FTop/x] ]]_v) (min 0 [[ F[FBot/x] ]]_v)).
409     = (max [[ F[FTop/x] ]]_v (min 0 [[ F[FBot/x] ]]_v)) by min_1_sem.
410     = (max [[ F[FTop/x] ]]_v 0).
411     = ([[ F[FTop/x] ]]_v) by max_0_sem.
412     = ([[ F ]]_v) by H1, shannon_true.
413   done.
414 (*END*)
415 qed.
416
417 (*DOCBEGIN
418
419 Note generali
420 =============
421
422 Si ricorda che:
423
424 1. Ogni volta che nella finestra di destra compare un simbolo `∀` oppure un 
425    simbolo `→` è opportuno usare il comando `assume` oppure `suppose` 
426    oppure (se si è in un caso di una dimostrazione per induzione) il comando
427    `by induction hypothesis we know` (che vengono nuovamente spiegati in seguito).
428    
429 2. Ogni caso (o sotto caso) della dimostrazione:
430
431    1. Inizia con una sequenza di comandi `assume` o `suppose` oppure 
432       `by induction hypothesis we know`. Tale sequenza di comandi può anche 
433       essere vuota.
434        
435    2. Continua poi con almeno un comando `the thesis becomes`.
436    
437    3. Eventualmente seguono vari comandi `by ... we proved` per 
438       utilizzare i teoremi già disponibili per generare nuove
439       ipotesi.
440       
441    4. Eventualmente uno o più comandi `we proceed by cases on (...) to prove (...)`.
442       
443    5. Se necessario un comando `conclude` seguito da un numero anche
444       molto lungo di passi `= (...) by ... .` per rendere la parte 
445       sinistra della vostra tesi uguale alla parte destra.
446       
447    6. Ogni caso termina con `done`.
448
449 3. Ogni caso corrispondente a un nodo con sottoformule (FAnd/For/FNot)
450    avrà tante ipotesi induttive quante sono le sue sottoformule e tali
451    ipotesi sono necessarie per portare a termine la dimostrazione.
452
453 I comandi da utilizzare
454 =======================
455
456 * `the thesis becomes (...).`
457
458   Afferma quale sia la tesi da dimostrare. Se ripetuto
459   permette di espandere le definizioni.
460         
461 * `we proceed by cases on (...) to prove (...).`
462
463   Permette di andare per casi su una ipotesi (quando essa è della forma
464   `A ∨ B`).
465    
466   Esempio: `we proceed by cases on H to prove Q.`
467         
468 * `case ... .`
469
470   Nelle dimostrazioni per casi o per induzioni si utulizza tale comando
471   per inizia la sotto prova relativa a un caso. Esempio: `case Fbot.`
472   
473 * `done.`
474
475   Ogni caso di una dimostrazione deve essere terminato con il comando
476   `done.`  
477
478 * `assume ... : (...) .`
479         
480   Assume una formula o un numero, ad esempio `assume n : (ℕ).` assume
481   un numero naturale `n`.
482         
483 * `by ..., ..., ..., we proved (...) (...).`
484
485   Permette di comporre lemmi e ipotesi per ottenere nuove ipotesi.
486   Ad esempio `by H, H1 we prove (F ≡ G) (H2).` ottiene una nuova ipotesi
487   `H2` che dice che `F ≡ G` componendo insieme `H` e `H1`.
488         
489 * `conclude (...) = (...) by ... .`
490
491   Il comando conclude lavora SOLO sulla parte sinistra della tesi. È il comando
492   con cui si inizia una catena di uguaglianze. La prima formula che si
493   scrive deve essere esattamente uguale alla parte sinistra della conclusione
494   originale. Esempio `conclude ([[ FAtom x ]]_v) = ([[ FAtom n ]]_v) by H.`
495   Se la giustificazione non è un lemma o una ipotesi ma la semplice espansione
496   di una definizione, la parte `by ...` deve essere omessa.
497           
498 * `= (...) by ... .`
499
500   Continua un comando `conclude`, lavorando sempre sulla parte sinistra della
501   tesi.
502
503 DOCEND*)