4 Compilare i seguenti campi:
21 Non modificare quanto segue
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.
34 Il linguaggio delle formule, dove gli atomi sono
35 rapperesentati da un numero naturale
37 inductive Formula : Type ≝
40 | FAtom: nat → Formula
41 | FAnd: Formula → Formula → Formula
42 | FOr: Formula → Formula → Formula
43 | FImpl: Formula → Formula → Formula
44 | FNot: Formula → Formula
47 let rec sem (v: nat → nat) (F: Formula) on F : nat ≝
51 | FAtom n ⇒ min (v n) 1
52 | FAnd F1 F2 ⇒ min (sem v F1) (sem v F2)
53 | FOr F1 F2 ⇒ max (sem v F1) (sem v F2)
54 | FImpl F1 F2 ⇒ max (1 - sem v F1) (sem v F2)
55 | FNot F1 ⇒ 1 - (sem v F1)
62 Non modificare quanto segue.
64 notation < "[[ \nbsp term 19 a \nbsp ]] \nbsp \sub term 90 v" non associative with precedence 90 for @{ 'semantics $v $a }.
65 notation > "[[ term 19 a ]] \sub term 90 v" non associative with precedence 90 for @{ 'semantics $v $a }.
66 notation > "[[ term 19 a ]]_ term 90 v" non associative with precedence 90 for @{ sem $v $a }.
67 interpretation "Semantic of Formula" 'semantics v a = (sem v a).
74 Gli strumenti per la dimostrazione assistita sono corredati da
75 librerie di teoremi già dimostrati. Per portare a termine l'esercitazione
76 sono necessari i seguenti lemmi:
78 * lemma `sem_le_1` : `∀F,v. [[ F ]]_v ≤ 1`
79 * lemma `min_1_1` : `∀x. x ≤ 1 → 1 - (1 - x) = x`
80 * lemma `min_bool` : `∀n. min n 1 = 0 ∨ min n 1 = 1`
81 * lemma `min_max` : `∀F,G,v.min (1 - [[F]]_v) (1 - [[G]]_v) = 1 - max [[F]]_v [[G]]_v`
82 * lemma `max_min` : `∀F,G,v.max (1 - [[F]]_v) (1 - [[G]]_v) = 1 - min [[F]]_v [[G]]_v`
83 * lemma `decidable_eq_nat` : `∀x,y.x = y ∨ x ≠ y`
91 Non modificare quanto segue.
93 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.
94 lemma min_bool : ∀n. min n 1 = 0 ∨ min n 1 = 1. intros; cases n; [left;reflexivity] cases n1; right; reflexivity; qed.
95 lemma min_max : ∀F,G,v. min (1 - [[F]]_v) (1 - [[G]]_v) = 1 - max [[F]]_v [[G]]_v. intros; cases (sem_bool F v);cases (sem_bool G v); rewrite > H; rewrite >H1; simplify; reflexivity; qed.
96 lemma max_min : ∀F,G,v. max (1 - [[F]]_v) (1 - [[G]]_v) = 1 - min [[F]]_v [[G]]_v. intros; cases (sem_bool F v);cases (sem_bool G v); rewrite > H; rewrite >H1; simplify; reflexivity; qed.
97 lemma min_1_1 : ∀x.x ≤ 1 → 1 - (1 - x) = x. intros; inversion H; intros; destruct; [reflexivity;] rewrite < (le_n_O_to_eq ? H1); reflexivity;qed.
98 lemma sem_le_1 : ∀F,v.[[F]]_v ≤ 1. intros; cases (sem_bool F v); rewrite > H; [apply le_O_n|apply le_n]qed.
99 let rec subst (x:nat) (G: Formula) (F: Formula) on F ≝
103 | FAtom n ⇒ if eqb n x then G else (FAtom n)
104 | FAnd F1 F2 ⇒ FAnd (subst x G F1) (subst x G F2)
105 | FOr F1 F2 ⇒ FOr (subst x G F1) (subst x G F2)
106 | FImpl F1 F2 ⇒ FImpl (subst x G F1) (subst x G F2)
107 | FNot F ⇒ FNot (subst x G F)
110 notation < "t [ \nbsp term 19 a / term 19 b \nbsp ]" non associative with precedence 19 for @{ 'substitution $b $a $t }.
111 notation > "t [ term 90 a / term 90 b]" non associative with precedence 19 for @{ 'substitution $b $a $t }.
112 interpretation "Substitution for Formula" 'substitution b a t = (subst b a t).
113 definition equiv ≝ λF1,F2. ∀v.[[ F1 ]]_v = [[ F2 ]]_v.
114 notation "hvbox(a \nbsp break mstyle color #0000ff (≡) \nbsp b)" non associative with precedence 45 for @{ 'equivF $a $b }.
115 notation > "a ≡ b" non associative with precedence 50 for @{ equiv $a $b }.
116 interpretation "equivalence for Formulas" 'equivF a b = (equiv a b).
119 ∀F,x,v. [[ if eqb [[FAtom x]]_v 0 then F[FBot/x] else (F[FTop/x]) ]]_v = [[F]]_v.
123 we proceed by induction on F to prove ([[ if eqb [[FAtom x]]_v 0 then F[FBot/x] else (F[FTop/x]) ]]_v = [[F]]_v).
125 the thesis becomes ([[ if eqb [[FAtom x]]_v 0 then FBot[FBot/x] else (FBot[FTop/x]) ]]_v = [[FBot]]_v).
126 we proceed by cases on (eqb [[ FAtom x ]]_v 0)
127 to prove ([[ if eqb [[FAtom x]]_v 0 then FBot[FBot/x] else (FBot[FTop/x]) ]]_v = [[FBot]]_v).
129 the thesis becomes ([[ if true then FBot[FBot/x] else (FBot[FTop/x]) ]]_v = [[FBot]]_v).
130 the thesis becomes ([[ FBot[FBot/x]]]_v = [[FBot]]_v).
131 the thesis becomes ([[ FBot ]]_v = [[FBot]]_v).
132 the thesis becomes (0 = 0).
137 we proceed by cases on (eqb [[ FAtom x ]]_v 0)
138 to prove ([[ if eqb [[FAtom x]]_v 0 then FTop[FBot/x] else (FTop[FTop/x]) ]]_v = [[FTop]]_v).
145 the thesis becomes ([[ if eqb [[ FAtom x ]]_v O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v = [[ FAtom n ]]_ v).
146 by decidable_eq_nat we proved (n = x ∨ n ≠ x) (H).
147 by sem_bool we proved ([[ FAtom x ]]_v = 0 ∨ [[ FAtom x ]]_v = 1) (H1).
148 we proceed by cases on H to prove
149 ([[ if eqb [[ FAtom x ]]_v O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v = [[ FAtom n ]]_ v).
150 case Left. (* H2 : n = x *)
151 we proceed by cases on H1 to prove
152 ([[ if eqb [[ FAtom x ]]_v O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v = [[ FAtom n ]]_ v).
153 case Left. (* H3 : [[ FAtom x ]]_v = 0 *)
155 ([[ if eqb [[ FAtom x ]]_v O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v)
156 = ([[ if eqb 0 0 then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v) by H3.
157 = ([[ if true then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v).
158 = ([[ (FAtom n)[ FBot/x ] ]]_v).
159 = ([[ if eqb n x then FBot else (FAtom n) ]]_v).
160 = ([[ if eqb n n then FBot else (FAtom n) ]]_v) by H2.
161 = ([[ if true then FBot else (FAtom n) ]]_v) by eqb_n_n.
164 = [[ FAtom x ]]_v by H3.
165 = [[ FAtom n ]]_v by H2.
169 ([[ if eqb [[ FAtom x ]]_v O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v)
170 = ([[ if eqb 1 0 then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v) by H3.
171 = ([[ if false then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v).
172 = ([[ (FAtom n)[ FTop/x ] ]]_v).
173 = ([[ if eqb n x then FTop else (FAtom n) ]]_v).
174 = ([[ if eqb n n then FTop else (FAtom n) ]]_v) by H2.
175 = ([[ if true then FTop else (FAtom n) ]]_v) by eqb_n_n.
178 = [[ FAtom x ]]_v by H3.
179 = [[ FAtom n ]]_v by H2.
182 we proceed by cases on H1 to prove
183 ([[ if eqb [[ FAtom x ]]_v O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v = [[ FAtom n ]]_ v).
186 ([[ if eqb [[ FAtom x ]]_v O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v)
187 = ([[ if eqb 0 O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v) by H3.
188 = [[ (FAtom n)[ FBot/x ] ]]_v.
189 = [[ if eqb n x then FBot else (FAtom n) ]]_v.
190 = [[ if false then FBot else (FAtom n) ]]_v by (not_eq_to_eqb_false ?? H2).
195 ([[ if eqb [[ FAtom x ]]_v O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v)
196 = ([[ if eqb 1 O then (FAtom n)[ FBot/x ] else (FAtom n[ FTop/x ]) ]]_v) by H3.
197 = [[ FAtom n[ FTop/x ] ]]_v.
198 = [[ if eqb n x then FTop else (FAtom n) ]]_v.
199 = [[ if false then FTop else (FAtom n) ]]_v by (not_eq_to_eqb_false ?? H2).
204 by induction hypothesis we know ([[ if eqb [[ FAtom x ]]_v O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H).
206 by induction hypothesis we know ([[ if eqb [[ FAtom x ]]_v O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H1).
208 ([[ if eqb [[ FAtom x ]]_v O then ((FAnd f f1)[ FBot/x ]) else ((FAnd f f1)[ FTop/x ]) ]]_v = [[ FAnd f f1 ]]_v).
209 by sem_bool we proved ([[ FAtom x ]]_v = 0 ∨ [[ FAtom x ]]_v = 1) (H2).
210 we proceed by cases on H2 to prove
211 ([[ if eqb [[ FAtom x ]]_v O then ((FAnd f f1)[ FBot/x ]) else ((FAnd f f1)[ FTop/x ]) ]]_v = [[ FAnd f f1 ]]_v).
214 ([[ if eqb 0 O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H4).
215 by H4 we proved ([[ f[FBot/x ] ]]_v = [[ f ]]_v) (H5).
217 ([[ if eqb 0 O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H6).
218 by H6 we proved ([[ f1[FBot/x ] ]]_v = [[ f1 ]]_v) (H7).
220 ([[ if eqb [[ FAtom x ]]_v O then ((FAnd f f1)[ FBot/x ]) else ((FAnd f f1)[ FTop/x ]) ]]_v)
221 = ([[ if eqb 0 O then ((FAnd f f1)[ FBot/x ]) else ((FAnd f f1)[ FTop/x ]) ]]_v) by H3.
222 = ([[ if true then ((FAnd f f1)[ FBot/x ]) else ((FAnd f f1)[ FTop/x ]) ]]_v).
223 = ([[ (FAnd f f1)[ FBot/x ] ]]_v).
224 = ([[ FAnd (f[ FBot/x ]) (f1[ FBot/x ]) ]]_v).
225 = (min [[ f[ FBot/x ] ]]_v [[ f1[ FBot/x ] ]]_v).
226 = (min [[ f ]]_v [[ f1[ FBot/x ] ]]_v) by H5.
227 = (min [[ f ]]_v [[ f1 ]]_v) by H6.
228 = ([[ FAnd f f1 ]]_v).
232 ([[ if eqb 1 O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H4).
233 by H4 we proved ([[ f[FTop/x ] ]]_v = [[ f ]]_v) (H5).
235 ([[ if eqb 1 O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H6).
236 by H6 we proved ([[ f1[FTop/x ] ]]_v = [[ f1 ]]_v) (H7).
238 ([[ if eqb [[ FAtom x ]]_v O then ((FAnd f f1)[ FBot/x ]) else ((FAnd f f1)[ FTop/x ]) ]]_v)
239 = ([[ if eqb 1 O then ((FAnd f f1)[ FBot/x ]) else ((FAnd f f1)[ FTop/x ]) ]]_v) by H3.
240 = ([[ if false then ((FAnd f f1)[ FBot/x ]) else ((FAnd f f1)[ FTop/x ]) ]]_v).
241 = ([[ (FAnd f f1)[ FTop/x ] ]]_v).
242 = ([[ FAnd (f[ FTop/x ]) (f1[ FTop/x ]) ]]_v).
243 = (min [[ f[ FTop/x ] ]]_v [[ f1[ FTop/x ] ]]_v).
244 = (min [[ f ]]_v [[ f1[ FTop/x ] ]]_v) by H5.
245 = (min [[ f ]]_v [[ f1 ]]_v) by H6.
246 = ([[ FAnd f f1 ]]_v).
250 by induction hypothesis we know ([[ if eqb [[ FAtom x ]]_v O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H).
252 by induction hypothesis we know ([[ if eqb [[ FAtom x ]]_v O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H1).
254 ([[ if eqb [[ FAtom x ]]_v O then ((FOr f f1)[ FBot/x ]) else ((FOr f f1)[ FTop/x ]) ]]_v = [[ FOr f f1 ]]_v).
255 by sem_bool we proved ([[ FAtom x ]]_v = 0 ∨ [[ FAtom x ]]_v = 1) (H2).
256 we proceed by cases on H2 to prove
257 ([[ if eqb [[ FAtom x ]]_v O then ((FOr f f1)[ FBot/x ]) else ((FOr f f1)[ FTop/x ]) ]]_v = [[ FOr f f1 ]]_v).
260 ([[ if eqb 0 O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H4).
261 by H4 we proved ([[ f[FBot/x ] ]]_v = [[ f ]]_v) (H5).
263 ([[ if eqb 0 O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H6).
264 by H6 we proved ([[ f1[FBot/x ] ]]_v = [[ f1 ]]_v) (H7).
266 ([[ if eqb [[ FAtom x ]]_v O then ((FOr f f1)[ FBot/x ]) else ((FOr f f1)[ FTop/x ]) ]]_v)
267 = ([[ if eqb 0 O then ((FOr f f1)[ FBot/x ]) else ((FOr f f1)[ FTop/x ]) ]]_v) by H3.
268 = ([[ if true then ((FOr f f1)[ FBot/x ]) else ((FOr f f1)[ FTop/x ]) ]]_v).
269 = ([[ (FOr f f1)[ FBot/x ] ]]_v).
270 = ([[ FOr (f[ FBot/x ]) (f1[ FBot/x ]) ]]_v).
271 = (max [[ f[ FBot/x ] ]]_v [[ f1[ FBot/x ] ]]_v).
272 = (max [[ f ]]_v [[ f1[ FBot/x ] ]]_v) by H5.
273 = (max [[ f ]]_v [[ f1 ]]_v) by H6.
274 = ([[ FOr f f1 ]]_v).
278 ([[ if eqb 1 O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H4).
279 by H4 we proved ([[ f[FTop/x ] ]]_v = [[ f ]]_v) (H5).
281 ([[ if eqb 1 O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H6).
282 by H6 we proved ([[ f1[FTop/x ] ]]_v = [[ f1 ]]_v) (H7).
284 ([[ if eqb [[ FAtom x ]]_v O then ((FOr f f1)[ FBot/x ]) else ((FOr f f1)[ FTop/x ]) ]]_v)
285 = ([[ if eqb 1 O then ((FOr f f1)[ FBot/x ]) else ((FOr f f1)[ FTop/x ]) ]]_v) by H3.
286 = ([[ if false then ((FOr f f1)[ FBot/x ]) else ((FOr f f1)[ FTop/x ]) ]]_v).
287 = ([[ (FOr f f1)[ FTop/x ] ]]_v).
288 = ([[ FOr (f[ FTop/x ]) (f1[ FTop/x ]) ]]_v).
289 = (max [[ f[ FTop/x ] ]]_v [[ f1[ FTop/x ] ]]_v).
290 = (max [[ f ]]_v [[ f1[ FTop/x ] ]]_v) by H5.
291 = (max [[ f ]]_v [[ f1 ]]_v) by H6.
292 = ([[ FOr f f1 ]]_v).
296 by induction hypothesis we know ([[ if eqb [[ FAtom x ]]_v O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H).
298 by induction hypothesis we know ([[ if eqb [[ FAtom x ]]_v O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H1).
300 ([[ if eqb [[ FAtom x ]]_v O then ((FImpl f f1)[ FBot/x ]) else ((FImpl f f1)[ FTop/x ]) ]]_v = [[ FImpl f f1 ]]_v).
301 by sem_bool we proved ([[ FAtom x ]]_v = 0 ∨ [[ FAtom x ]]_v = 1) (H2).
302 we proceed by cases on H2 to prove
303 ([[ if eqb [[ FAtom x ]]_v O then ((FImpl f f1)[ FBot/x ]) else ((FImpl f f1)[ FTop/x ]) ]]_v = [[ FImpl f f1 ]]_v).
306 ([[ if eqb 0 O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H4).
307 by H4 we proved ([[ f[FBot/x ] ]]_v = [[ f ]]_v) (H5).
309 ([[ if eqb 0 O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H6).
310 by H6 we proved ([[ f1[FBot/x ] ]]_v = [[ f1 ]]_v) (H7).
312 ([[ if eqb [[ FAtom x ]]_v O then ((FImpl f f1)[ FBot/x ]) else ((FImpl f f1)[ FTop/x ]) ]]_v)
313 = ([[ if eqb 0 O then ((FImpl f f1)[ FBot/x ]) else ((FImpl f f1)[ FTop/x ]) ]]_v) by H3.
314 = ([[ if true then ((FImpl f f1)[ FBot/x ]) else ((FImpl f f1)[ FTop/x ]) ]]_v).
315 = ([[ (FImpl f f1)[ FBot/x ] ]]_v).
316 = ([[ FImpl (f[ FBot/x ]) (f1[ FBot/x ]) ]]_v).
317 = (max (1 - [[ f[ FBot/x ] ]]_v) [[ f1[ FBot/x ] ]]_v).
318 = (max (1 - [[ f ]]_v) [[ f1[ FBot/x ] ]]_v) by H5.
319 = (max (1 - [[ f ]]_v) [[ f1 ]]_v) by H6.
320 = ([[ FImpl f f1 ]]_v).
324 ([[ if eqb 1 O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H4).
325 by H4 we proved ([[ f[FTop/x ] ]]_v = [[ f ]]_v) (H5).
327 ([[ if eqb 1 O then f1[ FBot/x ] else (f1[ FTop/x ]) ]]_v = [[ f1 ]]_v) (H6).
328 by H6 we proved ([[ f1[FTop/x ] ]]_v = [[ f1 ]]_v) (H7).
330 ([[ if eqb [[ FAtom x ]]_v O then ((FImpl f f1)[ FBot/x ]) else ((FImpl f f1)[ FTop/x ]) ]]_v)
331 = ([[ if eqb 1 O then ((FImpl f f1)[ FBot/x ]) else ((FImpl f f1)[ FTop/x ]) ]]_v) by H3.
332 = ([[ if false then ((FImpl f f1)[ FBot/x ]) else ((FImpl f f1)[ FTop/x ]) ]]_v).
333 = ([[ (FImpl f f1)[ FTop/x ] ]]_v).
334 = ([[ FImpl (f[ FTop/x ]) (f1[ FTop/x ]) ]]_v).
335 = (max (1 - [[ f[ FTop/x ] ]]_v) [[ f1[ FTop/x ] ]]_v).
336 = (max (1 - [[ f ]]_v) [[ f1[ FTop/x ] ]]_v) by H5.
337 = (max (1 - [[ f ]]_v) [[ f1 ]]_v) by H6.
338 = ([[ FImpl f f1 ]]_v).
342 by induction hypothesis we know ([[ if eqb [[ FAtom x ]]_v O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H).
344 ([[ if eqb [[ FAtom x ]]_v O then ((FNot f)[ FBot/x ]) else ((FNot f)[ FTop/x ]) ]]_v = [[ FNot f ]]_v).
345 by sem_bool we proved ([[ FAtom x ]]_v = 0 ∨ [[ FAtom x ]]_v = 1) (H2).
346 we proceed by cases on H2 to prove
347 ([[ if eqb [[ FAtom x ]]_v O then ((FNot f)[ FBot/x ]) else ((FNot f)[ FTop/x ]) ]]_v = [[ FNot f ]]_v).
350 ([[ if eqb 0 O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H4).
351 by H4 we proved ([[ f[FBot/x ] ]]_v = [[ f ]]_v) (H5).
353 ([[ if eqb [[ FAtom x ]]_v O then ((FNot f)[ FBot/x ]) else ((FNot f)[ FTop/x ]) ]]_v)
354 = ([[ if eqb 0 O then ((FNot f)[ FBot/x ]) else ((FNot f)[ FTop/x ]) ]]_v) by H1.
355 = ([[ if true then ((FNot f)[ FBot/x ]) else ((FNot f)[ FTop/x ]) ]]_v).
356 = ([[ (FNot f)[ FBot/x ] ]]_v).
357 = ([[ FNot (f[ FBot/x ]) ]]_v).
358 change with (1 - [[ f[ FBot/x ] ]]_v = [[ FNot f ]]_v).
359 = (1 - [[ f ]]_v) by H5.
360 change with ([[ FNot f ]]_v = [[ FNot f ]]_v).
364 ([[ if eqb 1 O then f[ FBot/x ] else (f[ FTop/x ]) ]]_v = [[ f ]]_v) (H4).
365 by H4 we proved ([[ f[FTop/x ] ]]_v = [[ f ]]_v) (H5).
367 ([[ if eqb [[ FAtom x ]]_v O then ((FNot f)[ FBot/x ]) else ((FNot f)[ FTop/x ]) ]]_v)
368 = ([[ if eqb 1 O then ((FNot f)[ FBot/x ]) else ((FNot f)[ FTop/x ]) ]]_v) by H1.
369 = ([[ if false then ((FNot f)[ FBot/x ]) else ((FNot f)[ FTop/x ]) ]]_v).
370 = ([[ (FNot f)[ FTop/x ] ]]_v).
371 = ([[ FNot (f[ FTop/x ]) ]]_v).
372 change with (1 - [[ f[ FTop/x ] ]]_v = [[ FNot f ]]_v) .
373 = (1 - [[ f ]]_v) by H5.
374 change with ([[ FNot f ]]_v = [[ FNot f ]]_v).
378 let rec maxatom (F : Formula) on F : ℕ ≝
383 | FAnd F1 F2 ⇒ max (maxatom F1) (maxatom F2)
384 | FOr F1 F2 ⇒ max (maxatom F1) (maxatom F2)
385 | FImpl F1 F2 ⇒ max (maxatom F1) (maxatom F2)
386 | FNot F1 ⇒ maxatom F1
390 let rec expandall (F : Formula) (v : ℕ → ℕ) (n : nat) on n: Formula ≝
394 if eqb [[ FAtom n ]]_v 0
395 then (expandall F v m)[FBot/n]
396 else ((expandall F v m)[FTop/n])
400 lemma BDD : ∀F,n,v. [[ expandall F v n ]]_v = [[ F ]]_v.
401 intros; elim n; simplify; [reflexivity]
402 cases (sem_bool (FAtom (S n1)) v); simplify in H1; rewrite > H1; simplify;
403 [ lapply (shannon (expandall F v n1) (S n1) v);
404 simplify in Hletin; rewrite > H1 in Hletin; simplify in Hletin;
405 rewrite > Hletin; assumption;
406 | lapply (shannon (expandall F v n1) (S n1) v);
407 simplify in Hletin; rewrite > H1 in Hletin; simplify in Hletin;
408 rewrite > Hletin; assumption;]