# HG changeset patch # User wenzelm # Date 1451766837 -3600 # Node ID 75a7db3cae7ed3211154cbdd3b96e51ad3599504 # Parent ae83bb2d014bb04495adb69ea699993825e2da0f more symbols; tuned; diff -r ae83bb2d014b -r 75a7db3cae7e src/HOL/Induct/Comb.thy --- a/src/HOL/Induct/Comb.thy Sat Jan 02 20:28:20 2016 +0100 +++ b/src/HOL/Induct/Comb.thy Sat Jan 02 21:33:57 2016 +0100 @@ -5,16 +5,16 @@ section \Combinatory Logic example: the Church-Rosser Theorem\ -theory Comb imports Main begin +theory Comb +imports Main +begin text \ Curiously, combinators do not include free variables. Example taken from @{cite camilleri92}. +\ -HOL system proofs may be found in the HOL distribution at - .../contrib/rule-induction/cl.ml -\ subsection \Definitions\ diff -r ae83bb2d014b -r 75a7db3cae7e src/ZF/Induct/Comb.thy --- a/src/ZF/Induct/Comb.thy Sat Jan 02 20:28:20 2016 +0100 +++ b/src/ZF/Induct/Comb.thy Sat Jan 02 21:33:57 2016 +0100 @@ -5,7 +5,9 @@ section \Combinatory Logic example: the Church-Rosser Theorem\ -theory Comb imports Main begin +theory Comb +imports Main +begin text \ Curiously, combinators do not include free variables. @@ -13,77 +15,69 @@ Example taken from @{cite camilleri92}. \ + subsection \Definitions\ text \Datatype definition of combinators \S\ and \K\.\ consts comb :: i datatype comb = - K - | S - | app ("p \ comb", "q \ comb") (infixl "\" 90) + K +| S +| app ("p \ comb", "q \ comb") (infixl "\" 90) text \ - Inductive definition of contractions, \-1->\ and - (multi-step) reductions, \-\\. + Inductive definition of contractions, \\\<^sup>1\ and + (multi-step) reductions, \\\. \ -consts - contract :: i +consts contract :: i +abbreviation contract_syntax :: "[i,i] \ o" (infixl "\\<^sup>1" 50) + where "p \\<^sup>1 q \ \ contract" -abbreviation - contract_syntax :: "[i,i] => o" (infixl "-1->" 50) - where "p -1-> q == \ contract" - -abbreviation - contract_multi :: "[i,i] => o" (infixl "-\" 50) - where "p -\ q == \ contract^*" +abbreviation contract_multi :: "[i,i] \ o" (infixl "\" 50) + where "p \ q \ \ contract^*" inductive domains "contract" \ "comb \ comb" intros - K: "[| p \ comb; q \ comb |] ==> K\p\q -1-> p" - S: "[| p \ comb; q \ comb; r \ comb |] ==> S\p\q\r -1-> (p\r)\(q\r)" - Ap1: "[| p-1->q; r \ comb |] ==> p\r -1-> q\r" - Ap2: "[| p-1->q; r \ comb |] ==> r\p -1-> r\q" + K: "[| p \ comb; q \ comb |] ==> K\p\q \\<^sup>1 p" + S: "[| p \ comb; q \ comb; r \ comb |] ==> S\p\q\r \\<^sup>1 (p\r)\(q\r)" + Ap1: "[| p\\<^sup>1q; r \ comb |] ==> p\r \\<^sup>1 q\r" + Ap2: "[| p\\<^sup>1q; r \ comb |] ==> r\p \\<^sup>1 r\q" type_intros comb.intros text \ - Inductive definition of parallel contractions, \=1=>\ and - (multi-step) parallel reductions, \===>\. + Inductive definition of parallel contractions, \\\<^sup>1\ and + (multi-step) parallel reductions, \\\. \ -consts - parcontract :: i +consts parcontract :: i -abbreviation - parcontract_syntax :: "[i,i] => o" (infixl "=1=>" 50) - where "p =1=> q == \ parcontract" +abbreviation parcontract_syntax :: "[i,i] => o" (infixl "\\<^sup>1" 50) + where "p \\<^sup>1 q == \ parcontract" -abbreviation - parcontract_multi :: "[i,i] => o" (infixl "===>" 50) - where "p ===> q == \ parcontract^+" +abbreviation parcontract_multi :: "[i,i] => o" (infixl "\" 50) + where "p \ q == \ parcontract^+" inductive domains "parcontract" \ "comb \ comb" intros - refl: "[| p \ comb |] ==> p =1=> p" - K: "[| p \ comb; q \ comb |] ==> K\p\q =1=> p" - S: "[| p \ comb; q \ comb; r \ comb |] ==> S\p\q\r =1=> (p\r)\(q\r)" - Ap: "[| p=1=>q; r=1=>s |] ==> p\r =1=> q\s" + refl: "[| p \ comb |] ==> p \\<^sup>1 p" + K: "[| p \ comb; q \ comb |] ==> K\p\q \\<^sup>1 p" + S: "[| p \ comb; q \ comb; r \ comb |] ==> S\p\q\r \\<^sup>1 (p\r)\(q\r)" + Ap: "[| p\\<^sup>1q; r\\<^sup>1s |] ==> p\r \\<^sup>1 q\s" type_intros comb.intros text \ Misc definitions. \ -definition - I :: i where - "I == S\K\K" +definition I :: i + where "I \ S\K\K" -definition - diamond :: "i => o" where - "diamond(r) == +definition diamond :: "i \ o" + where "diamond(r) \ \x y. \r \ (\y'. \r \ (\z. \r & \ r))" @@ -115,7 +109,7 @@ subsection \Results about Contraction\ text \ - For type checking: replaces @{term "a -1-> b"} by \a, b \ + For type checking: replaces @{term "a \\<^sup>1 b"} by \a, b \ comb\. \ @@ -140,30 +134,29 @@ contract.Ap1 [THEN rtrancl_into_rtrancl2] contract.Ap2 [THEN rtrancl_into_rtrancl2] -lemma "p \ comb ==> I\p -\ p" +lemma "p \ comb ==> I\p \ p" \ \Example only: not used\ - by (unfold I_def) (blast intro: reduction_rls) + unfolding I_def by (blast intro: reduction_rls) lemma comb_I: "I \ comb" - by (unfold I_def) blast + unfolding I_def by blast subsection \Non-contraction results\ text \Derive a case for each combinator constructor.\ -inductive_cases - K_contractE [elim!]: "K -1-> r" - and S_contractE [elim!]: "S -1-> r" - and Ap_contractE [elim!]: "p\q -1-> r" +inductive_cases K_contractE [elim!]: "K \\<^sup>1 r" + and S_contractE [elim!]: "S \\<^sup>1 r" + and Ap_contractE [elim!]: "p\q \\<^sup>1 r" -lemma I_contract_E: "I -1-> r ==> P" +lemma I_contract_E: "I \\<^sup>1 r ==> P" by (auto simp add: I_def) -lemma K1_contractD: "K\p -1-> r ==> (\q. r = K\q & p -1-> q)" +lemma K1_contractD: "K\p \\<^sup>1 r ==> (\q. r = K\q & p \\<^sup>1 q)" by auto -lemma Ap_reduce1: "[| p -\ q; r \ comb |] ==> p\r -\ q\r" +lemma Ap_reduce1: "[| p \ q; r \ comb |] ==> p\r \ q\r" apply (frule rtrancl_type [THEN subsetD, THEN SigmaD1]) apply (drule field_contract_eq [THEN equalityD1, THEN subsetD]) apply (erule rtrancl_induct) @@ -172,7 +165,7 @@ apply (blast intro: contract_combD2 reduction_rls) done -lemma Ap_reduce2: "[| p -\ q; r \ comb |] ==> r\p -\ r\q" +lemma Ap_reduce2: "[| p \ q; r \ comb |] ==> r\p \ r\q" apply (frule rtrancl_type [THEN subsetD, THEN SigmaD1]) apply (drule field_contract_eq [THEN equalityD1, THEN subsetD]) apply (erule rtrancl_induct) @@ -181,15 +174,15 @@ contract_combD2 reduction_rls) done -text \Counterexample to the diamond property for \-1->\.\ +text \Counterexample to the diamond property for \\\<^sup>1\.\ -lemma KIII_contract1: "K\I\(I\I) -1-> I" +lemma KIII_contract1: "K\I\(I\I) \\<^sup>1 I" by (blast intro: comb_I) -lemma KIII_contract2: "K\I\(I\I) -1-> K\I\((K\I)\(K\I))" +lemma KIII_contract2: "K\I\(I\I) \\<^sup>1 K\I\((K\I)\(K\I))" by (unfold I_def) (blast intro: contract.intros) -lemma KIII_contract3: "K\I\((K\I)\(K\I)) -1-> I" +lemma KIII_contract3: "K\I\((K\I)\(K\I)) \\<^sup>1 I" by (blast intro: comb_I) lemma not_diamond_contract: "\ diamond(contract)" @@ -201,7 +194,7 @@ subsection \Results about Parallel Contraction\ -text \For type checking: replaces \a =1=> b\ by \a, b +text \For type checking: replaces \a \\<^sup>1 b\ by \a, b \ comb\\ lemmas parcontract_combE2 = parcontract.dom_subset [THEN subsetD, THEN SigmaE2] and parcontract_combD1 = parcontract.dom_subset [THEN subsetD, THEN SigmaD1] @@ -212,9 +205,9 @@ text \Derive a case for each combinator constructor.\ inductive_cases - K_parcontractE [elim!]: "K =1=> r" - and S_parcontractE [elim!]: "S =1=> r" - and Ap_parcontractE [elim!]: "p\q =1=> r" + K_parcontractE [elim!]: "K \\<^sup>1 r" + and S_parcontractE [elim!]: "S \\<^sup>1 r" + and Ap_parcontractE [elim!]: "p\q \\<^sup>1 r" declare parcontract.intros [intro] @@ -222,15 +215,15 @@ subsection \Basic properties of parallel contraction\ lemma K1_parcontractD [dest!]: - "K\p =1=> r ==> (\p'. r = K\p' & p =1=> p')" + "K\p \\<^sup>1 r ==> (\p'. r = K\p' & p \\<^sup>1 p')" by auto lemma S1_parcontractD [dest!]: - "S\p =1=> r ==> (\p'. r = S\p' & p =1=> p')" + "S\p \\<^sup>1 r ==> (\p'. r = S\p' & p \\<^sup>1 p')" by auto lemma S2_parcontractD [dest!]: - "S\p\q =1=> r ==> (\p' q'. r = S\p'\q' & p =1=> p' & q =1=> q')" + "S\p\q \\<^sup>1 r ==> (\p' q'. r = S\p'\q' & p \\<^sup>1 p' & q \\<^sup>1 q')" by auto lemma diamond_parcontract: "diamond(parcontract)" @@ -242,13 +235,13 @@ done text \ - \medskip Equivalence of @{prop "p -\ q"} and @{prop "p ===> q"}. + \medskip Equivalence of @{prop "p \ q"} and @{prop "p \ q"}. \ -lemma contract_imp_parcontract: "p-1->q ==> p=1=>q" +lemma contract_imp_parcontract: "p\\<^sup>1q ==> p\\<^sup>1q" by (induct set: contract) auto -lemma reduce_imp_parreduce: "p-\q ==> p===>q" +lemma reduce_imp_parreduce: "p\q ==> p\q" apply (frule rtrancl_type [THEN subsetD, THEN SigmaD1]) apply (drule field_contract_eq [THEN equalityD1, THEN subsetD]) apply (erule rtrancl_induct) @@ -257,7 +250,7 @@ trans_trancl [THEN transD]) done -lemma parcontract_imp_reduce: "p=1=>q ==> p-\q" +lemma parcontract_imp_reduce: "p\\<^sup>1q ==> p\q" apply (induct set: parcontract) apply (blast intro: reduction_rls) apply (blast intro: reduction_rls) @@ -266,7 +259,7 @@ Ap_reduce1 Ap_reduce2 parcontract_combD1 parcontract_combD2) done -lemma parreduce_imp_reduce: "p===>q ==> p-\q" +lemma parreduce_imp_reduce: "p\q ==> p\q" apply (frule trancl_type [THEN subsetD, THEN SigmaD1]) apply (drule field_parcontract_eq [THEN equalityD1, THEN subsetD]) apply (erule trancl_induct, erule parcontract_imp_reduce) @@ -274,7 +267,7 @@ apply (erule parcontract_imp_reduce) done -lemma parreduce_iff_reduce: "p===>q \ p-\q" +lemma parreduce_iff_reduce: "p\q \ p\q" by (blast intro: parreduce_imp_reduce reduce_imp_parreduce) end