X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2Flibrary%2Fdemo%2Fnatural_deduction.ma;h=234b99af759e159aa110f32b6d89e46229ba0884;hb=85857e1832b921fdba61be9e7fbfc81da50f38f6;hp=4f9d70ffc69d348161fe84ea01d75bd960562c04;hpb=0b9d417be5c46dacd7107f2e50539b6114ce9341;p=helm.git diff --git a/helm/software/matita/library/demo/natural_deduction.ma b/helm/software/matita/library/demo/natural_deduction.ma index 4f9d70ffc..234b99af7 100644 --- a/helm/software/matita/library/demo/natural_deduction.ma +++ b/helm/software/matita/library/demo/natural_deduction.ma @@ -12,15 +12,26 @@ (* *) (**************************************************************************) -definition cast ≝ λA:CProp.λa:A.a. +(*definition cast ≝ λA,B:CProp.λa:A.a.*) +axiom cast: ∀A,B:CProp.B → A. + +(*notation < "\infrule (t\atop ⋮) (b \ALPOSTODI a) (? \ERROR)" with precedence 19 +for @{ 'caste $a $b $t }. +interpretation "cast" 'caste a b t = (cast a b t).*) +notation < "\infrule (t\atop ⋮) mstyle color #ff0000 (b) (? \ERROR)" with precedence 19 +for @{ 'caste $a $b $t }. +interpretation "cast" 'caste a b t = (cast a b t). notation < "\infrule (t\atop ⋮) a ?" with precedence 19 for @{ 'cast $a $t }. -interpretation "cast" 'cast a t = (cast a t). +interpretation "cast" 'cast a t = (cast a a t). definition assumpt ≝ λA:CProp.λa:A.a. +notation < "[ a ] \sup mstyle color #ff0000 (H)" with precedence 19 for @{ 'asse $a $H }. +interpretation "assumption" 'asse a H = (cast _ _ (assumpt a (cast _ _ H))). + notation < "[ a ] \sup H" with precedence 19 for @{ 'ass $a $H }. -interpretation "assumption" 'ass a H = (cast _ (assumpt a H)). +interpretation "assumption" 'ass a H = (cast a a (assumpt a (cast a a H))). inductive Imply (A,B:CProp) : CProp ≝ Imply_intro: (A → B) → Imply A B. @@ -28,13 +39,18 @@ inductive Imply (A,B:CProp) : CProp ≝ notation "hbox(a break ⇒ b)" right associative with precedence 20 for @{ 'Imply $a $b }. interpretation "Imply" 'Imply a b = (Imply a b). -notation < "\infrule hbox(\emsp b \emsp) ab (⇒\sub\i \emsp ident H) " with precedence 19 for @{ 'Imply_intro $ab (λ${ident H}:$p.$b) }. -interpretation "Imply_intro" 'Imply_intro ab \eta.b = (cast ab (Imply_intro _ _ b)). +notation < "\infrule hbox(\emsp b \emsp) mstyle color #ff0000(ab) (⇒\sub\i \emsp ident H \ERROR) " with precedence 19 +for @{ 'Imply_introe $xxx $ab (λ${ident H}:$p.$b) }. +interpretation "Imply_intro" 'Imply_introe xxx ab \eta.b = (cast xxx ab (Imply_intro _ _ b)). + +notation < "\infrule hbox(\emsp b \emsp) ab (⇒\sub\i \emsp ident H) " with precedence 19 +for @{ 'Imply_intro $ab (λ${ident H}:$p.$b) }. +interpretation "Imply_intro" 'Imply_intro ab \eta.b = (cast ab ab (Imply_intro _ _ b)). definition Imply_elim ≝ λA,B.λf:Imply A B.λa:A.match f with [ Imply_intro g ⇒ g a]. notation < "\infrule hbox(\emsp ab \emsp\emsp\emsp a\emsp) b (⇒\sub\e) " with precedence 19 for @{ 'Imply_elim $ab $a $b }. -interpretation "Imply_elim" 'Imply_elim ab a b = (cast b (Imply_elim _ _ ab a)). +interpretation "Imply_elim" 'Imply_elim ab a b = (cast _ b (Imply_elim _ _ ab a)). inductive And (A,B:CProp) : CProp ≝ And_intro: A → B → And A B. @@ -42,19 +58,19 @@ inductive And (A,B:CProp) : CProp ≝ interpretation "constructive and" 'and x y = (And x y). notation < "\infrule hbox(\emsp a \emsp\emsp\emsp b \emsp) ab (∧\sub\i)" with precedence 19 for @{ 'And_intro $a $b $ab }. -interpretation "And_intro" 'And_intro a b ab = (cast ab (And_intro _ _ a b)). +interpretation "And_intro" 'And_intro a b ab = (cast _ ab (And_intro _ _ a b)). definition And_elim_l ≝ λA,B.λc:A∧B.match c with [ And_intro a b ⇒ a ]. notation < "\infrule hbox(\emsp ab \emsp) a (∧\sub\e\sup\l)" with precedence 19 for @{ 'And_elim_l $ab $a }. -interpretation "And_elim_l" 'And_elim_l ab a = (cast a (And_elim_l _ _ ab)). +interpretation "And_elim_l" 'And_elim_l ab a = (cast _ a (And_elim_l _ _ ab)). definition And_elim_r ≝ λA,B.λc:A∧B.match c with [ And_intro a b ⇒ b ]. notation < "\infrule hbox(\emsp ab \emsp) b (∧\sub\e\sup\r)" with precedence 19 for @{ 'And_elim_r $ab $b }. -interpretation "And_elim_r" 'And_elim_r ab b = (cast b (And_elim_r _ _ ab)). +interpretation "And_elim_r" 'And_elim_r ab b = (cast _ b (And_elim_r _ _ ab)). inductive Or (A,B:CProp) : CProp ≝ | Or_intro_l: A → Or A B @@ -63,10 +79,10 @@ inductive Or (A,B:CProp) : CProp ≝ interpretation "constructive or" 'or x y = (Or x y). notation < "\infrule hbox(\emsp a \emsp) ab (∨\sub\i\sup\l)" with precedence 19 for @{ 'Or_intro_l $a $ab }. -interpretation "Or_intro_l" 'Or_intro_l a ab = (cast ab (Or_intro_l _ _ a)). +interpretation "Or_intro_l" 'Or_intro_l a ab = (cast _ ab (Or_intro_l _ _ a)). notation < "\infrule hbox(\emsp b \emsp) ab (∨\sub\i\sup\l)" with precedence 19 for @{ 'Or_intro_r $b $ab }. -interpretation "Or_intro_l" 'Or_intro_r b ab = (cast ab (Or_intro_r _ _ b)). +interpretation "Or_intro_l" 'Or_intro_r b ab = (cast _ ab (Or_intro_r _ _ b)). definition Or_elim ≝ λA,B,C:CProp.λc:A∨B.λfa: A → C.λfb: B → C. @@ -74,7 +90,7 @@ definition Or_elim ≝ notation < "\infrule hbox(\emsp ab \emsp\emsp\emsp ac \emsp\emsp\emsp bc \emsp) c (∨\sub\e \emsp ident Ha \emsp ident Hb)" with precedence 19 for @{ 'Or_elim $ab (λ${ident Ha}:$ta.$ac) (λ${ident Hb}:$tb.$bc) $c }. -interpretation "Or_elim" 'Or_elim ab \eta.ac \eta.bc c = (cast c (Or_elim _ _ _ ab ac bc)). +interpretation "Or_elim" 'Or_elim ab \eta.ac \eta.bc c = (cast _ c (Or_elim _ _ _ ab ac bc)). inductive Exists (A:Type) (P:A→CProp) : CProp ≝ Exists_intro: ∀w:A. P w → Exists A P. @@ -83,7 +99,7 @@ interpretation "constructive ex" 'exists \eta.x = (Exists _ x). notation < "\infrule hbox(\emsp Pn \emsp) Px (∃\sub\i)" with precedence 19 for @{ 'Exists_intro $Pn $Px }. -interpretation "Exists_intro" 'Exists_intro Pn Px = (cast Px (Exists_intro _ _ _ Pn)). +interpretation "Exists_intro" 'Exists_intro Pn Px = (cast _ Px (Exists_intro _ _ _ Pn)). definition Exists_elim ≝ λA:Type.λP:A→CProp.λC:CProp.λc:∃x:A.P x.λH:(∀x.P x → C). @@ -91,7 +107,7 @@ definition Exists_elim ≝ notation < "\infrule hbox(\emsp ExPx \emsp\emsp\emsp Pc \emsp) c (∃\sub\e \emsp ident n \emsp ident HPn)" with precedence 19 for @{ 'Exists_elim $ExPx (λ${ident n}:$tn.λ${ident HPn}:$Pn.$Pc) $c }. -interpretation "Exists_elim" 'Exists_elim ExPx Pc c = (cast c (Exists_elim _ _ _ ExPx Pc)). +interpretation "Exists_elim" 'Exists_elim ExPx Pc c = (cast _ c (Exists_elim _ _ _ ExPx Pc)). inductive Forall (A:Type) (P:A→CProp) : CProp ≝ Forall_intro: (∀n:A. P n) → Forall A P. @@ -102,13 +118,13 @@ interpretation "Forall" 'Forall \eta.Px = (Forall _ Px). notation < "\infrule hbox(\emsp Px \emsp) Pn (∀\sub\i \emsp ident x)" with precedence 19 for @{ 'Forall_intro (λ${ident x}:$tx.$Px) $Pn }. -interpretation "Forall_intro" 'Forall_intro Px Pn = (cast Pn (Forall_intro _ _ Px)). +interpretation "Forall_intro" 'Forall_intro Px Pn = (cast _ Pn (Forall_intro _ _ Px)). definition Forall_elim ≝ λA:Type.λP:A→CProp.λn:A.λf:∀x:A.P x.match f with [ Forall_intro g ⇒ g n ]. notation < "\infrule hbox(\emsp Px \emsp) Pn (∀\sub\i)" with precedence 19 for @{ 'Forall_elim $Px $Pn }. -interpretation "Forall_elim" 'Forall_elim Px Pn = (cast Pn (Forall_elim _ _ _ Px)). +interpretation "Forall_elim" 'Forall_elim Px Pn = (cast _ Pn (Forall_elim _ _ _ Px)). axiom A: CProp. axiom B: CProp. @@ -118,36 +134,45 @@ axiom E: CProp. notation > "[H]" with precedence 90 -for @{ assumpt ? $H}. +for @{ assumpt ? (cast ? ? $H)}. notation > "⇒\sub\i [ident H] term 90 b" with precedence 19 -for @{ Imply_intro ?? (λ${ident H}.cast $b ?) }. +for @{ Imply_intro ?? (λ${ident H}.cast ? $b ?) }. notation > "⇒\sub\e term 90 ab term 90 a" with precedence 19 -for @{ Imply_elim ?? (cast $ab ?) (cast $a ?) }. +for @{ Imply_elim ?? (cast ? $ab ?) (cast $a $a ?) }. notation > "∧\sub\i term 90 a term 90 b" with precedence 19 -for @{ And_intro ?? (cast $a ?) (cast $b ?) }. +for @{ And_intro ?? (cast ? $a ?) (cast ? $b ?) }. +(*notation > "∧\sub\e\sup\l term 90 ab" with precedence 19 +for @{ And_elim_l ?? (cast (? ∧ False) $ab ?) }. +notation > "∧\sub\e\sup\l term 90 a ∧ term 90 b" with precedence 19 +for @{ And_elim_l ?? (cast (? ∧ $b) ($a ∧ $b) ?) }. *) notation > "∧\sub\e\sup\l term 90 ab" with precedence 19 -for @{ And_elim_l ?? (cast $ab ?) }. +for @{ And_elim_l ?? (cast $ab $ab ?) }. (* CSC: WRONG *) notation > "∧\sub\e\sup\r term 90 ab" with precedence 19 -for @{ And_elim_r ?? (cast $ab ?) }. +for @{ And_elim_r ?? (cast $ab $ab ?) }. (* CSC: WRONG *) notation > "∨\sub\i\sup\l term 90 a" with precedence 19 -for @{ Or_intro_l ?? (cast $a ?) }. +for @{ Or_intro_l ?? (cast ? $a ?) }. notation > "∨\sub\i\sup\r term 90 a" with precedence 19 -for @{ Or_intro_r ?? (cast $a ?) }. +for @{ Or_intro_r ?? (cast ? $a ?) }. notation > "∨\sub\e term 90 ab [ident Ha] term 90 c1 [ident Hb] term 90 c2" with precedence 19 -for @{ Or_elim ??? (cast $ab ?) (λ${ident Ha}.cast $c1 ?) (λ${ident Hb}.cast $c2 ?) }. +for @{ Or_elim ??? (cast $ab $ab ?) (λ${ident Ha}.cast ? $c1 ?) (λ${ident Hb}.cast ? $c2 ?) }. notation > "∀\sub\i [ident z] term 90 a" with precedence 19 -for @{ Forall_intro ?? (λ${ident z}.cast $a ?) }. +for @{ Forall_intro ?? (λ${ident z}.cast ? $a ?) }. notation > "∀\sub\e term 90 ab" with precedence 19 -for @{ Forall_elim ?? ? (cast $ab ?) }. +for @{ Forall_elim ?? ? (cast $ab $ab ?) }. (* CSC: WRONG *) notation > "∃\sub\e term 90 enpn [ident z] [ident pz] term 90 c" with precedence 19 -for @{ Exists_elim ??? (cast $enpn ?) (λ${ident z}.λ${ident pz}.cast $c ?) }. +for @{ Exists_elim ??? (cast $enpn $enpn ?) (λ${ident z}.λ${ident pz}.cast ? $c ?) }. notation > "∃\sub\i term 90 n term 90 pn" with precedence 19 -for @{ Exists_intro ? (λ_.?) $n (cast $pn ?) }. +for @{ Exists_intro ? (λ_.?) $n (cast ? $pn ?) }. lemma ex1 : (A ⇒ E) ∨ B ⇒ A ∧ C ⇒ (E ∧ C) ∨ B. - apply cast; + apply (cast ? ((A⇒E)∨B⇒A∧C⇒E∧C∨B)); + (*NICE: TRY THIS ERROR! + apply (⇒\sub\i [H] (A∧C⇒E∧E∧C∨B)); + apply (⇒\sub\i [K] (E∧E∧C∨B)); + OR DO THE RIGHT THING *) apply (⇒\sub\i [H] (A∧C⇒E∧C∨B)); apply (⇒\sub\i [K] (E∧C∨B)); + apply (∨\sub\e ((A⇒E)∨B) [C1] (E∧C∨B) [C2] (E∧C∨B)); [ apply [H]; | apply (∨\sub\i\sup\l (E∧C)); @@ -169,7 +194,7 @@ axiom N: Type. axiom R: N → N → CProp. lemma ex2: (∀a:N.∀b:N.R a b ⇒ R b a) ⇒ ∀z:N.(∃x.R x z) ⇒ ∃y. R z y. - apply cast; + apply (cast ? ((∀a:N.∀b:N.R a b ⇒ R b a) ⇒ ∀z:N.(∃x.R x z) ⇒ ∃y. R z y)); apply (⇒\sub\i [H] (∀z:N.(∃x:N.R x z)⇒∃y:N.R z y)); apply (∀\sub\i [z] ((∃x:N.R x z)⇒∃y:N.R z y)); apply (⇒\sub\i [H2] (∃y:N.R z y)); @@ -183,4 +208,4 @@ lemma ex2: (∀a:N.∀b:N.R a b ⇒ R b a) ⇒ ∀z:N.(∃x.R x z) ⇒ ∃y. R z | apply [H3] ] ] -qed. \ No newline at end of file +qed.