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