From 72f8ff3c58c5ac927f572267386f17be39d5a026 Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Sun, 26 Oct 2008 14:02:50 +0000 Subject: [PATCH] duality done --- .../matita/contribs/didactic/duality.ma | 90 +++++++++++++------ 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/helm/software/matita/contribs/didactic/duality.ma b/helm/software/matita/contribs/didactic/duality.ma index 4eaa9c7e3..7fe9082e1 100644 --- a/helm/software/matita/contribs/didactic/duality.ma +++ b/helm/software/matita/contribs/didactic/duality.ma @@ -98,7 +98,7 @@ inductive Formula : Type ≝ Suggerimento: non è necessario usare il costrutto if_then_else e tantomento il predicato di maggiore o uguale. *) -let rec sem (v: nat → nat) (F: Formula) on F ≝ +let rec sem (v: nat → nat) (F: Formula) on F : nat ≝ match F with [ FBot ⇒ 0 | FTop ⇒ 1 @@ -170,15 +170,15 @@ lemma max_min : ∀F,G,v. max (1 - [[F]]_v) (1 - [[G]]_v) = 1 - min [[F]]_v [[G Ad esempio la formula `(A ∨ (⊤ → B))` deve diventare `¬A ∨ (⊤ → ¬B)`. *) -let rec negate (F: Formula) on F ≝ +let rec negate (F: Formula) on F : Formula ≝ match F with - [ FBot ⇒ FBot + [ (*BEGIN*)FBot ⇒ FBot | FTop ⇒ FTop | FAtom n ⇒ FNot (FAtom n) | FAnd F1 F2 ⇒ FAnd (negate F1) (negate F2) | FOr F1 F2 ⇒ FOr (negate F1) (negate F2) | FImpl F1 F2 ⇒ FImpl (negate F1) (negate F2) - | FNot F ⇒ FNot (negate F) + | FNot F ⇒ FNot (negate F)(*END*) ]. (* Test 2 @@ -263,6 +263,12 @@ utilizzare il seguente comando: * `symmetry` Quando la conclusuine è `a = b` permette di cambiarla in `b = a`. + +* by H1, H2 we proved P (H) + + Il comando `by ... we proved` visto nella scorsa esercitazione + permette di utilizzare più ipotesi o lemmi alla volta + separandoli con una virgola. DOCEND*) @@ -279,18 +285,22 @@ lemma negate_invert: assume F:Formula. assume v:(ℕ→ℕ). we proceed by induction on F to prove ([[ negate F ]]_v=[[ F ]]_(invert v)). - case FBot . + case FBot. + (*BEGIN*) the thesis becomes ([[ negate FBot ]]_v=[[ FBot ]]_(invert v)). + (*END*) done. - case FTop . + case FTop. + (*BEGIN*) the thesis becomes ([[ negate FTop ]]_v=[[ FTop ]]_(invert v)). + (*END*) done. case FAtom. assume n : ℕ. the thesis becomes ([[ negate (FAtom n) ]]_v=[[ FAtom n ]]_(invert v)). the thesis becomes (1 - (min (v n) 1)= min (invert v n) 1). the thesis becomes (1 - (min (v n) 1)= min (if eqb (min (v n) 1) 0 then 1 else 0) 1). - by min_bool we proved (min (v n) 1 = 0 ∨ min (v n) 1 = 1) (H1); + by min_bool we proved ((*BEGIN*)min (v n) 1 = 0 ∨ min (v n) 1 = 1(*END*)) (H1); we proceed by cases on (H1) to prove (1 - (min (v n) 1)= min (if eqb (min (v n) 1) 0 then 1 else 0) 1). case Left. conclude @@ -305,6 +315,7 @@ we proceed by induction on F to prove ([[ negate F ]]_v=[[ F ]]_(invert v)). = 1. done. case Right. + (*BEGIN*) conclude (1 - (min (v n) 1)) = (1 - 1) by H. @@ -315,6 +326,7 @@ we proceed by induction on F to prove ([[ negate F ]]_v=[[ F ]]_(invert v)). = (min (if eqb 1 0 then 1 else O) 1) by H. = (min 0 1). = 0. + (*END*) done. case FAnd. assume f : Formula. @@ -330,9 +342,10 @@ we proceed by induction on F to prove ([[ negate F ]]_v=[[ F ]]_(invert v)). conclude (min [[ negate f ]]_v [[ negate f1]]_v) = (min [[ f ]]_(invert v) [[ negate f1]]_v) by H. - = (min [[ f ]]_(invert v) [[ f1]]_(invert v)) by H1. + = (min [[ f ]]_(invert v) [[ f1]]_(invert v)) by (*BEGIN*)H1(*END*). done. case FOr. + (*BEGIN*) assume f : Formula. by induction hypothesis we know ([[ negate f ]]_v=[[ f ]]_(invert v)) (H). @@ -347,8 +360,10 @@ we proceed by induction on F to prove ([[ negate F ]]_v=[[ F ]]_(invert v)). (max [[ negate f ]]_v [[ negate f1]]_v) = (max [[ f ]]_(invert v) [[ negate f1]]_v) by H. = (max [[ f ]]_(invert v) [[ f1]]_(invert v)) by H1. + (*END*) done. case FImpl. + (*BEGIN*) assume f : Formula. by induction hypothesis we know ([[ negate f ]]_v=[[ f ]]_(invert v)) (H). @@ -363,17 +378,20 @@ we proceed by induction on F to prove ([[ negate F ]]_v=[[ F ]]_(invert v)). (max (1 - [[ negate f ]]_v) [[ negate f1]]_v) = (max (1 - [[ f ]]_(invert v)) [[ negate f1]]_v) by H. = (max (1 - [[ f ]]_(invert v)) [[ f1]]_(invert v)) by H1. + (*END*) done. case FNot. + (*BEGIN*) assume f : Formula. by induction hypothesis we know ([[ negate f ]]_v=[[ f ]]_(invert v)) (H). - the thesis becomes - ([[ negate (FNot f) ]]_v=[[ FNot f ]]_(invert v)). - the thesis becomes - (1 - [[ negate f ]]_v=[[ FNot f ]]_(invert v)). - conclude (1 - [[ negate f ]]_v) = (1 - [[f]]_(invert v)) by H. - done. + the thesis becomes + ([[ negate (FNot f) ]]_v=[[ FNot f ]]_(invert v)). + the thesis becomes + (1 - [[ negate f ]]_v=[[ FNot f ]]_(invert v)). + conclude (1 - [[ negate f ]]_v) = (1 - [[f]]_(invert v)) by H. + (*END*) + done. qed. (* Esercizio 5 @@ -383,17 +401,19 @@ qed. *) lemma negate_fun: ∀F:Formula.∀G:Formula.F ≡ G→negate F ≡ negate G. + (*BEGIN*) assume F:Formula. assume G:Formula. suppose (F ≡ G) (H). the thesis becomes (negate F ≡ negate G). the thesis becomes (∀v:ℕ→ℕ.[[ negate F ]]_v=[[ negate G ]]_v). + (*END*) assume v:(ℕ→ℕ). conclude [[ negate F ]]_v = [[ F ]]_(invert v) by negate_invert. - = [[ G ]]_(invert v) by H. - = [[ negate G ]]_v by negate_invert. + = [[ G ]]_((*BEGIN*)invert v(*BEGIN*)) by (*BEGIN*)H(*BEGIN*). + = [[ negate G ]]_(*BEGIN*)v(*BEGIN*) by (*BEGIN*)negate_invert(*END*). done. qed. @@ -405,19 +425,27 @@ qed. *) lemma not_dualize_eq_negate: ∀F:Formula.negate F ≡ FNot (dualize F). + (*BEGIN*) assume F:Formula. the thesis becomes (∀v:ℕ→ℕ.[[negate F]]_v=[[FNot (dualize F)]]_v). + (*END*) assume v:(ℕ→ℕ). we proceed by induction on F to prove ([[negate F]]_v=[[FNot (dualize F)]]_v). - case FBot . + case FBot. + (*BEGIN*) the thesis becomes ([[ negate FBot ]]_v=[[ FNot (dualize FBot) ]]_v). + (*END*) done. - case FTop . + case FTop. + (*BEGIN*) the thesis becomes ([[ negate FTop ]]_v=[[ FNot (dualize FTop) ]]_v). + (*END*) done. case FAtom. + (*BEGIN*) assume n : ℕ. the thesis becomes ([[ negate (FAtom n) ]]_v=[[ FNot (dualize (FAtom n)) ]]_v). + (*END*) done. case FAnd. assume f : Formula. @@ -438,6 +466,7 @@ lemma not_dualize_eq_negate: = (1 - (max [[ dualize f ]]_v [[ dualize f1 ]]_v)) by min_max. done. case FOr. + (*BEGIN*) assume f : Formula. by induction hypothesis we know ([[ negate f ]]_v=[[ FNot (dualize f) ]]_v) (H). @@ -454,8 +483,10 @@ lemma not_dualize_eq_negate: = (max [[ FNot (dualize f) ]]_v [[ FNot (dualize f1) ]]_v) by H1. = (max (1 - [[ dualize f ]]_v) (1 - [[ dualize f1 ]]_v)). = (1 - (min [[ dualize f ]]_v [[ dualize f1 ]]_v)) by max_min. + (*END*) done. case FImpl. + (*BEGIN*) assume f : Formula. by induction hypothesis we know ([[ negate f ]]_v=[[ FNot (dualize f) ]]_v) (H). @@ -472,8 +503,10 @@ lemma not_dualize_eq_negate: = (max (1-[[ FNot (dualize f) ]]_v) [[ FNot (dualize f1) ]]_v) by H1. = (max (1 - [[ FNot (dualize f) ]]_v) (1 - [[ dualize f1 ]]_v)). = (1 - (min [[ FNot (dualize f) ]]_v [[ dualize f1 ]]_v)) by max_min. + (*END*) done. - case FNot. + case FNot. + (*BEGIN*) assume f : Formula. by induction hypothesis we know ([[ negate f ]]_v=[[ FNot (dualize f) ]]_v) (H). @@ -482,6 +515,7 @@ lemma not_dualize_eq_negate: the thesis becomes (1 - [[ negate f ]]_v=[[ FNot (dualize (FNot f)) ]]_v). conclude (1 - [[ negate f ]]_v) = (1 - [[ FNot (dualize f) ]]_v) by H. + (*END*) done. qed. @@ -492,15 +526,17 @@ qed. *) theorem not_inj: ∀F,G:Formula.FNot F ≡ FNot G→F ≡ G. + (*BEGIN*) assume F:Formula. assume G:Formula. suppose (FNot F ≡ FNot G) (H). the thesis becomes (F ≡ G). the thesis becomes (∀v:ℕ→ℕ.[[ F ]]_v=[[ G ]]_v). + (*END*) assume v:(ℕ→ℕ). by H we proved ([[ FNot F ]]_v=[[ FNot G ]]_v) (H1). - by sem_bool we proved ([[ F ]]_v=O∨[[ F ]]_v=1) (H2). - by sem_bool we proved ([[ G ]]_v=O∨[[ G ]]_v=1) (H3). + by sem_bool we proved ([[ F ]]_v=O ∨ [[ F ]]_v=1) (H2). + by (*BEGIN*)sem_bool(*END*) we proved ([[ G ]]_v=(*BEGIN*)O ∨ [[ G ]]_v=1(*END*)) (H3). we proceed by cases on H2 to prove ([[ F ]]_v=[[ G ]]_v). case Left. we proceed by cases on H3 to prove ([[ F ]]_v=[[ G ]]_v). @@ -519,6 +555,7 @@ theorem not_inj: = 1. done. case Right. + (*BEGIN*) we proceed by cases on H3 to prove ([[ F ]]_v=[[ G ]]_v). case Left. conclude @@ -533,7 +570,8 @@ theorem not_inj: = 0. done. case Right. - done. + (*END*) + done. qed. (*DOCBEGIN @@ -598,9 +636,9 @@ theorem duality: ∀F1,F2:Formula.F1 ≡ F2 → dualize F1 ≡ dualize F2. assume F2:Formula. suppose (F1 ≡ F2) (H). the thesis becomes (dualize F1 ≡ dualize F2). - by negate_fun we proved (negate F1 ≡ negate F2) (H1). - by not_dualize_eq_negate, equiv_rewrite we proved (FNot (dualize F1) ≡ negate F2) (H2). - by not_dualize_eq_negate, equiv_rewrite we proved (FNot (dualize F1) ≡ FNot (dualize F2)) (H3). - by not_inj we proved (dualize F1 ≡ dualize F2) (H4). + by (*BEGIN*)negate_fun(*END*) we proved (negate F1 ≡ negate F2) (H1). + by (*BEGIN*)not_dualize_eq_negate(*END*), (*BEGIN*)equiv_rewrite(*END*), H1 we proved (FNot (dualize F1) ≡ negate F2) (H2). + by (*BEGIN*)not_dualize_eq_negate(*END*), (*BEGIN*)equiv_rewrite(*END*), H2 we proved (FNot (dualize F1) ≡ FNot (dualize F2)) (H3). + by (*BEGIN*)not_inj(*END*), H3 we proved (dualize F1 ≡ dualize F2) (H4). done. qed. -- 2.39.2