| author | wenzelm | 
| Mon, 29 Jul 2019 11:09:37 +0200 | |
| changeset 70436 | 251f1fb44ccd | 
| parent 69605 | a96320074298 | 
| child 70491 | 8cac53925407 | 
| permissions | -rw-r--r-- | 
| 47325 | 1 | (* Title: HOL/Transfer.thy | 
| 2 | Author: Brian Huffman, TU Muenchen | |
| 51956 
a4d81cdebf8b
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
 kuncar parents: 
51955diff
changeset | 3 | Author: Ondrej Kuncar, TU Muenchen | 
| 47325 | 4 | *) | 
| 5 | ||
| 60758 | 6 | section \<open>Generic theorem transfer using relations\<close> | 
| 47325 | 7 | |
| 8 | theory Transfer | |
| 59275 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 9 | imports Basic_BNF_LFPs Hilbert_Choice Metis | 
| 47325 | 10 | begin | 
| 11 | ||
| 60758 | 12 | subsection \<open>Relator for function space\<close> | 
| 47325 | 13 | |
| 63343 | 14 | bundle lifting_syntax | 
| 53011 
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
 kuncar parents: 
52358diff
changeset | 15 | begin | 
| 63343 | 16 | notation rel_fun (infixr "===>" 55) | 
| 17 | notation map_fun (infixr "--->" 55) | |
| 53011 
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
 kuncar parents: 
52358diff
changeset | 18 | end | 
| 
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
 kuncar parents: 
52358diff
changeset | 19 | |
| 63343 | 20 | context includes lifting_syntax | 
| 53011 
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
 kuncar parents: 
52358diff
changeset | 21 | begin | 
| 
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
 kuncar parents: 
52358diff
changeset | 22 | |
| 55945 | 23 | lemma rel_funD2: | 
| 24 | assumes "rel_fun A B f g" and "A x x" | |
| 47937 
70375fa2679d
generate abs_eq, use it as a code equation for total quotients; no_abs_code renamed to no_code; added no_code for quotient_type command
 kuncar parents: 
47924diff
changeset | 25 | shows "B (f x) (g x)" | 
| 55945 | 26 | using assms by (rule rel_funD) | 
| 47937 
70375fa2679d
generate abs_eq, use it as a code equation for total quotients; no_abs_code renamed to no_code; added no_code for quotient_type command
 kuncar parents: 
47924diff
changeset | 27 | |
| 55945 | 28 | lemma rel_funE: | 
| 29 | assumes "rel_fun A B f g" and "A x y" | |
| 47325 | 30 | obtains "B (f x) (g y)" | 
| 55945 | 31 | using assms by (simp add: rel_fun_def) | 
| 47325 | 32 | |
| 55945 | 33 | lemmas rel_fun_eq = fun.rel_eq | 
| 47325 | 34 | |
| 55945 | 35 | lemma rel_fun_eq_rel: | 
| 67399 | 36 | shows "rel_fun (=) R = (\<lambda>f g. \<forall>x. R (f x) (g x))" | 
| 55945 | 37 | by (simp add: rel_fun_def) | 
| 47325 | 38 | |
| 39 | ||
| 60758 | 40 | subsection \<open>Transfer method\<close> | 
| 47325 | 41 | |
| 60758 | 42 | text \<open>Explicit tag for relation membership allows for | 
| 43 | backward proof methods.\<close> | |
| 47325 | 44 | |
| 45 | definition Rel :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'b \<Rightarrow> bool"
 | |
| 46 | where "Rel r \<equiv> r" | |
| 47 | ||
| 60758 | 48 | text \<open>Handling of equality relations\<close> | 
| 49975 
faf4afed009f
transfer package: more flexible handling of equality relations using is_equality predicate
 huffman parents: 
48891diff
changeset | 49 | |
| 
faf4afed009f
transfer package: more flexible handling of equality relations using is_equality predicate
 huffman parents: 
48891diff
changeset | 50 | definition is_equality :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 67399 | 51 | where "is_equality R \<longleftrightarrow> R = (=)" | 
| 49975 
faf4afed009f
transfer package: more flexible handling of equality relations using is_equality predicate
 huffman parents: 
48891diff
changeset | 52 | |
| 67399 | 53 | lemma is_equality_eq: "is_equality (=)" | 
| 51437 
8739f8abbecb
fixing transfer tactic - unfold fully identity relation by using relator_eq
 kuncar parents: 
51112diff
changeset | 54 | unfolding is_equality_def by simp | 
| 
8739f8abbecb
fixing transfer tactic - unfold fully identity relation by using relator_eq
 kuncar parents: 
51112diff
changeset | 55 | |
| 60758 | 56 | text \<open>Reverse implication for monotonicity rules\<close> | 
| 52354 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 57 | |
| 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 58 | definition rev_implies where | 
| 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 59 | "rev_implies x y \<longleftrightarrow> (y \<longrightarrow> x)" | 
| 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 60 | |
| 60758 | 61 | text \<open>Handling of meta-logic connectives\<close> | 
| 47325 | 62 | |
| 63 | definition transfer_forall where | |
| 64 | "transfer_forall \<equiv> All" | |
| 65 | ||
| 66 | definition transfer_implies where | |
| 67399 | 67 | "transfer_implies \<equiv> (\<longrightarrow>)" | 
| 47325 | 68 | |
| 47355 
3d9d98e0f1a4
add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
 huffman parents: 
47325diff
changeset | 69 | definition transfer_bforall :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 
3d9d98e0f1a4
add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
 huffman parents: 
47325diff
changeset | 70 | where "transfer_bforall \<equiv> (\<lambda>P Q. \<forall>x. P x \<longrightarrow> Q x)" | 
| 
3d9d98e0f1a4
add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
 huffman parents: 
47325diff
changeset | 71 | |
| 47325 | 72 | lemma transfer_forall_eq: "(\<And>x. P x) \<equiv> Trueprop (transfer_forall (\<lambda>x. P x))" | 
| 73 | unfolding atomize_all transfer_forall_def .. | |
| 74 | ||
| 75 | lemma transfer_implies_eq: "(A \<Longrightarrow> B) \<equiv> Trueprop (transfer_implies A B)" | |
| 76 | unfolding atomize_imp transfer_implies_def .. | |
| 77 | ||
| 47355 
3d9d98e0f1a4
add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
 huffman parents: 
47325diff
changeset | 78 | lemma transfer_bforall_unfold: | 
| 
3d9d98e0f1a4
add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
 huffman parents: 
47325diff
changeset | 79 | "Trueprop (transfer_bforall P (\<lambda>x. Q x)) \<equiv> (\<And>x. P x \<Longrightarrow> Q x)" | 
| 
3d9d98e0f1a4
add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
 huffman parents: 
47325diff
changeset | 80 | unfolding transfer_bforall_def atomize_imp atomize_all .. | 
| 
3d9d98e0f1a4
add bounded quantifier constant transfer_bforall, whose definition is unfolded after transfer
 huffman parents: 
47325diff
changeset | 81 | |
| 67399 | 82 | lemma transfer_start: "\<lbrakk>P; Rel (=) P Q\<rbrakk> \<Longrightarrow> Q" | 
| 47325 | 83 | unfolding Rel_def by simp | 
| 84 | ||
| 67399 | 85 | lemma transfer_start': "\<lbrakk>P; Rel (\<longrightarrow>) P Q\<rbrakk> \<Longrightarrow> Q" | 
| 47325 | 86 | unfolding Rel_def by simp | 
| 87 | ||
| 47635 
ebb79474262c
rename 'correspondence' method to 'transfer_prover'
 huffman parents: 
47627diff
changeset | 88 | lemma transfer_prover_start: "\<lbrakk>x = x'; Rel R x' y\<rbrakk> \<Longrightarrow> Rel R x y" | 
| 47618 
1568dadd598a
make correspondence tactic more robust by replacing lhs with schematic variable before applying intro rules
 huffman parents: 
47612diff
changeset | 89 | by simp | 
| 
1568dadd598a
make correspondence tactic more robust by replacing lhs with schematic variable before applying intro rules
 huffman parents: 
47612diff
changeset | 90 | |
| 67399 | 91 | lemma untransfer_start: "\<lbrakk>Q; Rel (=) P Q\<rbrakk> \<Longrightarrow> P" | 
| 52358 
f4c4bcb0d564
implement 'untransferred' attribute, which is like 'transferred' but works in the opposite direction
 huffman parents: 
52354diff
changeset | 92 | unfolding Rel_def by simp | 
| 
f4c4bcb0d564
implement 'untransferred' attribute, which is like 'transferred' but works in the opposite direction
 huffman parents: 
52354diff
changeset | 93 | |
| 67399 | 94 | lemma Rel_eq_refl: "Rel (=) x x" | 
| 47325 | 95 | unfolding Rel_def .. | 
| 96 | ||
| 47789 
71a526ee569a
implement transfer tactic with more scalable forward proof methods
 huffman parents: 
47684diff
changeset | 97 | lemma Rel_app: | 
| 47523 
1bf0e92c1ca0
make transfer method more deterministic by using SOLVED' on some subgoals
 huffman parents: 
47503diff
changeset | 98 | assumes "Rel (A ===> B) f g" and "Rel A x y" | 
| 47789 
71a526ee569a
implement transfer tactic with more scalable forward proof methods
 huffman parents: 
47684diff
changeset | 99 | shows "Rel B (f x) (g y)" | 
| 55945 | 100 | using assms unfolding Rel_def rel_fun_def by fast | 
| 47523 
1bf0e92c1ca0
make transfer method more deterministic by using SOLVED' on some subgoals
 huffman parents: 
47503diff
changeset | 101 | |
| 47789 
71a526ee569a
implement transfer tactic with more scalable forward proof methods
 huffman parents: 
47684diff
changeset | 102 | lemma Rel_abs: | 
| 47523 
1bf0e92c1ca0
make transfer method more deterministic by using SOLVED' on some subgoals
 huffman parents: 
47503diff
changeset | 103 | assumes "\<And>x y. Rel A x y \<Longrightarrow> Rel B (f x) (g y)" | 
| 47789 
71a526ee569a
implement transfer tactic with more scalable forward proof methods
 huffman parents: 
47684diff
changeset | 104 | shows "Rel (A ===> B) (\<lambda>x. f x) (\<lambda>y. g y)" | 
| 55945 | 105 | using assms unfolding Rel_def rel_fun_def by fast | 
| 47523 
1bf0e92c1ca0
make transfer method more deterministic by using SOLVED' on some subgoals
 huffman parents: 
47503diff
changeset | 106 | |
| 60758 | 107 | subsection \<open>Predicates on relations, i.e. ``class constraints''\<close> | 
| 47325 | 108 | |
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 109 | definition left_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 110 | where "left_total R \<longleftrightarrow> (\<forall>x. \<exists>y. R x y)" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 111 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 112 | definition left_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 113 | where "left_unique R \<longleftrightarrow> (\<forall>x y z. R x z \<longrightarrow> R y z \<longrightarrow> x = y)" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 114 | |
| 47325 | 115 | definition right_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 116 | where "right_total R \<longleftrightarrow> (\<forall>y. \<exists>x. R x y)" | |
| 117 | ||
| 118 | definition right_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
 | |
| 119 | where "right_unique R \<longleftrightarrow> (\<forall>x y z. R x y \<longrightarrow> R x z \<longrightarrow> y = z)" | |
| 120 | ||
| 121 | definition bi_total :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
 | |
| 122 | where "bi_total R \<longleftrightarrow> (\<forall>x. \<exists>y. R x y) \<and> (\<forall>y. \<exists>x. R x y)" | |
| 123 | ||
| 124 | definition bi_unique :: "('a \<Rightarrow> 'b \<Rightarrow> bool) \<Rightarrow> bool"
 | |
| 125 | where "bi_unique R \<longleftrightarrow> | |
| 126 | (\<forall>x y z. R x y \<longrightarrow> R x z \<longrightarrow> y = z) \<and> | |
| 127 | (\<forall>x y z. R x z \<longrightarrow> R y z \<longrightarrow> x = y)" | |
| 128 | ||
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 129 | lemma left_uniqueI: "(\<And>x y z. \<lbrakk> A x z; A y z \<rbrakk> \<Longrightarrow> x = y) \<Longrightarrow> left_unique A" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 130 | unfolding left_unique_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 131 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 132 | lemma left_uniqueD: "\<lbrakk> left_unique A; A x z; A y z \<rbrakk> \<Longrightarrow> x = y" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 133 | unfolding left_unique_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 134 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 135 | lemma left_totalI: | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 136 | "(\<And>x. \<exists>y. R x y) \<Longrightarrow> left_total R" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 137 | unfolding left_total_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 138 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 139 | lemma left_totalE: | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 140 | assumes "left_total R" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 141 | obtains "(\<And>x. \<exists>y. R x y)" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 142 | using assms unfolding left_total_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 143 | |
| 53927 | 144 | lemma bi_uniqueDr: "\<lbrakk> bi_unique A; A x y; A x z \<rbrakk> \<Longrightarrow> y = z" | 
| 145 | by(simp add: bi_unique_def) | |
| 146 | ||
| 147 | lemma bi_uniqueDl: "\<lbrakk> bi_unique A; A x y; A z y \<rbrakk> \<Longrightarrow> x = z" | |
| 148 | by(simp add: bi_unique_def) | |
| 149 | ||
| 150 | lemma right_uniqueI: "(\<And>x y z. \<lbrakk> A x y; A x z \<rbrakk> \<Longrightarrow> y = z) \<Longrightarrow> right_unique A" | |
| 56085 | 151 | unfolding right_unique_def by fast | 
| 53927 | 152 | |
| 153 | lemma right_uniqueD: "\<lbrakk> right_unique A; A x y; A x z \<rbrakk> \<Longrightarrow> y = z" | |
| 56085 | 154 | unfolding right_unique_def by fast | 
| 53927 | 155 | |
| 59514 
509caf5edfa6
add intro and elim rules for right_total
 Andreas Lochbihler parents: 
59276diff
changeset | 156 | lemma right_totalI: "(\<And>y. \<exists>x. A x y) \<Longrightarrow> right_total A" | 
| 
509caf5edfa6
add intro and elim rules for right_total
 Andreas Lochbihler parents: 
59276diff
changeset | 157 | by(simp add: right_total_def) | 
| 
509caf5edfa6
add intro and elim rules for right_total
 Andreas Lochbihler parents: 
59276diff
changeset | 158 | |
| 
509caf5edfa6
add intro and elim rules for right_total
 Andreas Lochbihler parents: 
59276diff
changeset | 159 | lemma right_totalE: | 
| 
509caf5edfa6
add intro and elim rules for right_total
 Andreas Lochbihler parents: 
59276diff
changeset | 160 | assumes "right_total A" | 
| 
509caf5edfa6
add intro and elim rules for right_total
 Andreas Lochbihler parents: 
59276diff
changeset | 161 | obtains x where "A x y" | 
| 
509caf5edfa6
add intro and elim rules for right_total
 Andreas Lochbihler parents: 
59276diff
changeset | 162 | using assms by(auto simp add: right_total_def) | 
| 
509caf5edfa6
add intro and elim rules for right_total
 Andreas Lochbihler parents: 
59276diff
changeset | 163 | |
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 164 | lemma right_total_alt_def2: | 
| 67399 | 165 | "right_total R \<longleftrightarrow> ((R ===> (\<longrightarrow>)) ===> (\<longrightarrow>)) All All" | 
| 55945 | 166 | unfolding right_total_def rel_fun_def | 
| 47325 | 167 | apply (rule iffI, fast) | 
| 168 | apply (rule allI) | |
| 169 | apply (drule_tac x="\<lambda>x. True" in spec) | |
| 170 | apply (drule_tac x="\<lambda>y. \<exists>x. R x y" in spec) | |
| 171 | apply fast | |
| 172 | done | |
| 173 | ||
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 174 | lemma right_unique_alt_def2: | 
| 67399 | 175 | "right_unique R \<longleftrightarrow> (R ===> R ===> (\<longrightarrow>)) (=) (=)" | 
| 55945 | 176 | unfolding right_unique_def rel_fun_def by auto | 
| 47325 | 177 | |
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 178 | lemma bi_total_alt_def2: | 
| 67399 | 179 | "bi_total R \<longleftrightarrow> ((R ===> (=)) ===> (=)) All All" | 
| 55945 | 180 | unfolding bi_total_def rel_fun_def | 
| 47325 | 181 | apply (rule iffI, fast) | 
| 182 | apply safe | |
| 183 | apply (drule_tac x="\<lambda>x. \<exists>y. R x y" in spec) | |
| 184 | apply (drule_tac x="\<lambda>y. True" in spec) | |
| 185 | apply fast | |
| 186 | apply (drule_tac x="\<lambda>x. True" in spec) | |
| 187 | apply (drule_tac x="\<lambda>y. \<exists>x. R x y" in spec) | |
| 188 | apply fast | |
| 189 | done | |
| 190 | ||
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 191 | lemma bi_unique_alt_def2: | 
| 67399 | 192 | "bi_unique R \<longleftrightarrow> (R ===> R ===> (=)) (=) (=)" | 
| 55945 | 193 | unfolding bi_unique_def rel_fun_def by auto | 
| 47325 | 194 | |
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 195 | lemma [simp]: | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 196 | shows left_unique_conversep: "left_unique A\<inverse>\<inverse> \<longleftrightarrow> right_unique A" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 197 | and right_unique_conversep: "right_unique A\<inverse>\<inverse> \<longleftrightarrow> left_unique A" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 198 | by(auto simp add: left_unique_def right_unique_def) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 199 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 200 | lemma [simp]: | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 201 | shows left_total_conversep: "left_total A\<inverse>\<inverse> \<longleftrightarrow> right_total A" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 202 | and right_total_conversep: "right_total A\<inverse>\<inverse> \<longleftrightarrow> left_total A" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 203 | by(simp_all add: left_total_def right_total_def) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 204 | |
| 53944 | 205 | lemma bi_unique_conversep [simp]: "bi_unique R\<inverse>\<inverse> = bi_unique R" | 
| 206 | by(auto simp add: bi_unique_def) | |
| 207 | ||
| 208 | lemma bi_total_conversep [simp]: "bi_total R\<inverse>\<inverse> = bi_total R" | |
| 209 | by(auto simp add: bi_total_def) | |
| 210 | ||
| 67399 | 211 | lemma right_unique_alt_def: "right_unique R = (conversep R OO R \<le> (=))" unfolding right_unique_def by blast | 
| 212 | lemma left_unique_alt_def: "left_unique R = (R OO (conversep R) \<le> (=))" unfolding left_unique_def by blast | |
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 213 | |
| 67399 | 214 | lemma right_total_alt_def: "right_total R = (conversep R OO R \<ge> (=))" unfolding right_total_def by blast | 
| 215 | lemma left_total_alt_def: "left_total R = (R OO conversep R \<ge> (=))" unfolding left_total_def by blast | |
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 216 | |
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 217 | lemma bi_total_alt_def: "bi_total A = (left_total A \<and> right_total A)" | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 218 | unfolding left_total_def right_total_def bi_total_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 219 | |
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 220 | lemma bi_unique_alt_def: "bi_unique A = (left_unique A \<and> right_unique A)" | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 221 | unfolding left_unique_def right_unique_def bi_unique_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 222 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 223 | lemma bi_totalI: "left_total R \<Longrightarrow> right_total R \<Longrightarrow> bi_total R" | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 224 | unfolding bi_total_alt_def .. | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 225 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 226 | lemma bi_uniqueI: "left_unique R \<Longrightarrow> right_unique R \<Longrightarrow> bi_unique R" | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 227 | unfolding bi_unique_alt_def .. | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 228 | |
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 229 | end | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 230 | |
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 231 | |
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 232 | |
| 69605 | 233 | ML_file \<open>Tools/Transfer/transfer.ML\<close> | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 234 | declare refl [transfer_rule] | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 235 | |
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 236 | hide_const (open) Rel | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 237 | |
| 63343 | 238 | context includes lifting_syntax | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 239 | begin | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 240 | |
| 60758 | 241 | text \<open>Handling of domains\<close> | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 242 | |
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 243 | lemma Domainp_iff: "Domainp T x \<longleftrightarrow> (\<exists>y. T x y)" | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 244 | by auto | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 245 | |
| 58386 | 246 | lemma Domainp_refl[transfer_domain_rule]: | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 247 | "Domainp T = Domainp T" .. | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 248 | |
| 67399 | 249 | lemma Domain_eq_top[transfer_domain_rule]: "Domainp (=) = top" by auto | 
| 60229 
4cd6462c1fda
Workaround that allows us to execute lifted constants that have as a return type a datatype containing a subtype
 kuncar parents: 
59523diff
changeset | 250 | |
| 64425 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 251 | lemma Domainp_pred_fun_eq[relator_domain]: | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 252 | assumes "left_unique T" | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 253 | shows "Domainp (T ===> S) = pred_fun (Domainp T) (Domainp S)" | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 254 | using assms unfolding rel_fun_def Domainp_iff[abs_def] left_unique_def fun_eq_iff pred_fun_def | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 255 | apply safe | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 256 | apply blast | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 257 | apply (subst all_comm) | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 258 | apply (rule choice) | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 259 | apply blast | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 260 | done | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 261 | |
| 60758 | 262 | text \<open>Properties are preserved by relation composition.\<close> | 
| 47660 | 263 | |
| 264 | lemma OO_def: "R OO S = (\<lambda>x z. \<exists>y. R x y \<and> S y z)" | |
| 265 | by auto | |
| 266 | ||
| 267 | lemma bi_total_OO: "\<lbrakk>bi_total A; bi_total B\<rbrakk> \<Longrightarrow> bi_total (A OO B)" | |
| 56085 | 268 | unfolding bi_total_def OO_def by fast | 
| 47660 | 269 | |
| 270 | lemma bi_unique_OO: "\<lbrakk>bi_unique A; bi_unique B\<rbrakk> \<Longrightarrow> bi_unique (A OO B)" | |
| 56085 | 271 | unfolding bi_unique_def OO_def by blast | 
| 47660 | 272 | |
| 273 | lemma right_total_OO: | |
| 274 | "\<lbrakk>right_total A; right_total B\<rbrakk> \<Longrightarrow> right_total (A OO B)" | |
| 56085 | 275 | unfolding right_total_def OO_def by fast | 
| 47660 | 276 | |
| 277 | lemma right_unique_OO: | |
| 278 | "\<lbrakk>right_unique A; right_unique B\<rbrakk> \<Longrightarrow> right_unique (A OO B)" | |
| 56085 | 279 | unfolding right_unique_def OO_def by fast | 
| 47660 | 280 | |
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 281 | lemma left_total_OO: "left_total R \<Longrightarrow> left_total S \<Longrightarrow> left_total (R OO S)" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 282 | unfolding left_total_def OO_def by fast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 283 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 284 | lemma left_unique_OO: "left_unique R \<Longrightarrow> left_unique S \<Longrightarrow> left_unique (R OO S)" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 285 | unfolding left_unique_def OO_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 286 | |
| 47325 | 287 | |
| 60758 | 288 | subsection \<open>Properties of relators\<close> | 
| 47325 | 289 | |
| 67399 | 290 | lemma left_total_eq[transfer_rule]: "left_total (=)" | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 291 | unfolding left_total_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 292 | |
| 67399 | 293 | lemma left_unique_eq[transfer_rule]: "left_unique (=)" | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 294 | unfolding left_unique_def by blast | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 295 | |
| 67399 | 296 | lemma right_total_eq [transfer_rule]: "right_total (=)" | 
| 47325 | 297 | unfolding right_total_def by simp | 
| 298 | ||
| 67399 | 299 | lemma right_unique_eq [transfer_rule]: "right_unique (=)" | 
| 47325 | 300 | unfolding right_unique_def by simp | 
| 301 | ||
| 67399 | 302 | lemma bi_total_eq[transfer_rule]: "bi_total (=)" | 
| 47325 | 303 | unfolding bi_total_def by simp | 
| 304 | ||
| 67399 | 305 | lemma bi_unique_eq[transfer_rule]: "bi_unique (=)" | 
| 47325 | 306 | unfolding bi_unique_def by simp | 
| 307 | ||
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 308 | lemma left_total_fun[transfer_rule]: | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 309 | "\<lbrakk>left_unique A; left_total B\<rbrakk> \<Longrightarrow> left_total (A ===> B)" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 310 | unfolding left_total_def rel_fun_def | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 311 | apply (rule allI, rename_tac f) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 312 | apply (rule_tac x="\<lambda>y. SOME z. B (f (THE x. A x y)) z" in exI) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 313 | apply clarify | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 314 | apply (subgoal_tac "(THE x. A x y) = x", simp) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 315 | apply (rule someI_ex) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 316 | apply (simp) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 317 | apply (rule the_equality) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 318 | apply assumption | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 319 | apply (simp add: left_unique_def) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 320 | done | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 321 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 322 | lemma left_unique_fun[transfer_rule]: | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 323 | "\<lbrakk>left_total A; left_unique B\<rbrakk> \<Longrightarrow> left_unique (A ===> B)" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 324 | unfolding left_total_def left_unique_def rel_fun_def | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 325 | by (clarify, rule ext, fast) | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 326 | |
| 47325 | 327 | lemma right_total_fun [transfer_rule]: | 
| 328 | "\<lbrakk>right_unique A; right_total B\<rbrakk> \<Longrightarrow> right_total (A ===> B)" | |
| 55945 | 329 | unfolding right_total_def rel_fun_def | 
| 47325 | 330 | apply (rule allI, rename_tac g) | 
| 331 | apply (rule_tac x="\<lambda>x. SOME z. B z (g (THE y. A x y))" in exI) | |
| 332 | apply clarify | |
| 333 | apply (subgoal_tac "(THE y. A x y) = y", simp) | |
| 334 | apply (rule someI_ex) | |
| 335 | apply (simp) | |
| 336 | apply (rule the_equality) | |
| 337 | apply assumption | |
| 338 | apply (simp add: right_unique_def) | |
| 339 | done | |
| 340 | ||
| 341 | lemma right_unique_fun [transfer_rule]: | |
| 342 | "\<lbrakk>right_total A; right_unique B\<rbrakk> \<Longrightarrow> right_unique (A ===> B)" | |
| 55945 | 343 | unfolding right_total_def right_unique_def rel_fun_def | 
| 47325 | 344 | by (clarify, rule ext, fast) | 
| 345 | ||
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 346 | lemma bi_total_fun[transfer_rule]: | 
| 47325 | 347 | "\<lbrakk>bi_unique A; bi_total B\<rbrakk> \<Longrightarrow> bi_total (A ===> B)" | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 348 | unfolding bi_unique_alt_def bi_total_alt_def | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 349 | by (blast intro: right_total_fun left_total_fun) | 
| 47325 | 350 | |
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 351 | lemma bi_unique_fun[transfer_rule]: | 
| 47325 | 352 | "\<lbrakk>bi_total A; bi_unique B\<rbrakk> \<Longrightarrow> bi_unique (A ===> B)" | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 353 | unfolding bi_unique_alt_def bi_total_alt_def | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 354 | by (blast intro: right_unique_fun left_unique_fun) | 
| 47325 | 355 | |
| 56543 
9bd56f2e4c10
bi_unique and co. rules from the BNF hook must be introduced after bi_unique op= and co. rules are introduced
 kuncar parents: 
56524diff
changeset | 356 | end | 
| 
9bd56f2e4c10
bi_unique and co. rules from the BNF hook must be introduced after bi_unique op= and co. rules are introduced
 kuncar parents: 
56524diff
changeset | 357 | |
| 59275 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 358 | lemma if_conn: | 
| 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 359 | "(if P \<and> Q then t else e) = (if P then if Q then t else e else e)" | 
| 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 360 | "(if P \<or> Q then t else e) = (if P then t else if Q then t else e)" | 
| 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 361 | "(if P \<longrightarrow> Q then t else e) = (if P then if Q then t else e else t)" | 
| 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 362 | "(if \<not> P then t else e) = (if P then e else t)" | 
| 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 363 | by auto | 
| 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 364 | |
| 69605 | 365 | ML_file \<open>Tools/Transfer/transfer_bnf.ML\<close> | 
| 366 | ML_file \<open>Tools/BNF/bnf_fp_rec_sugar_transfer.ML\<close> | |
| 59275 
77cd4992edcd
Add plugin to generate transfer theorem for primrec and primcorec
 desharna parents: 
59141diff
changeset | 367 | |
| 56543 
9bd56f2e4c10
bi_unique and co. rules from the BNF hook must be introduced after bi_unique op= and co. rules are introduced
 kuncar parents: 
56524diff
changeset | 368 | declare pred_fun_def [simp] | 
| 
9bd56f2e4c10
bi_unique and co. rules from the BNF hook must be introduced after bi_unique op= and co. rules are introduced
 kuncar parents: 
56524diff
changeset | 369 | declare rel_fun_eq [relator_eq] | 
| 
9bd56f2e4c10
bi_unique and co. rules from the BNF hook must be introduced after bi_unique op= and co. rules are introduced
 kuncar parents: 
56524diff
changeset | 370 | |
| 64425 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 371 | (* Delete the automated generated rule from the bnf command; | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 372 | we have a more general rule (Domainp_pred_fun_eq) that subsumes it. *) | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 373 | declare fun.Domainp_rel[relator_domain del] | 
| 
b17acc1834e3
a more general relator domain rule for the function type
 kuncar parents: 
64014diff
changeset | 374 | |
| 60758 | 375 | subsection \<open>Transfer rules\<close> | 
| 47325 | 376 | |
| 63343 | 377 | context includes lifting_syntax | 
| 56543 
9bd56f2e4c10
bi_unique and co. rules from the BNF hook must be introduced after bi_unique op= and co. rules are introduced
 kuncar parents: 
56524diff
changeset | 378 | begin | 
| 
9bd56f2e4c10
bi_unique and co. rules from the BNF hook must be introduced after bi_unique op= and co. rules are introduced
 kuncar parents: 
56524diff
changeset | 379 | |
| 53952 | 380 | lemma Domainp_forall_transfer [transfer_rule]: | 
| 381 | assumes "right_total A" | |
| 67399 | 382 | shows "((A ===> (=)) ===> (=)) | 
| 53952 | 383 | (transfer_bforall (Domainp A)) transfer_forall" | 
| 384 | using assms unfolding right_total_def | |
| 55945 | 385 | unfolding transfer_forall_def transfer_bforall_def rel_fun_def Domainp_iff | 
| 56085 | 386 | by fast | 
| 53952 | 387 | |
| 60758 | 388 | text \<open>Transfer rules using implication instead of equality on booleans.\<close> | 
| 47684 | 389 | |
| 52354 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 390 | lemma transfer_forall_transfer [transfer_rule]: | 
| 67399 | 391 | "bi_total A \<Longrightarrow> ((A ===> (=)) ===> (=)) transfer_forall transfer_forall" | 
| 392 | "right_total A \<Longrightarrow> ((A ===> (=)) ===> implies) transfer_forall transfer_forall" | |
| 52354 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 393 | "right_total A \<Longrightarrow> ((A ===> implies) ===> implies) transfer_forall transfer_forall" | 
| 67399 | 394 | "bi_total A \<Longrightarrow> ((A ===> (=)) ===> rev_implies) transfer_forall transfer_forall" | 
| 52354 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 395 | "bi_total A \<Longrightarrow> ((A ===> rev_implies) ===> rev_implies) transfer_forall transfer_forall" | 
| 55945 | 396 | unfolding transfer_forall_def rev_implies_def rel_fun_def right_total_def bi_total_def | 
| 56085 | 397 | by fast+ | 
| 52354 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 398 | |
| 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 399 | lemma transfer_implies_transfer [transfer_rule]: | 
| 67399 | 400 | "((=) ===> (=) ===> (=) ) transfer_implies transfer_implies" | 
| 52354 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 401 | "(rev_implies ===> implies ===> implies ) transfer_implies transfer_implies" | 
| 67399 | 402 | "(rev_implies ===> (=) ===> implies ) transfer_implies transfer_implies" | 
| 403 | "((=) ===> implies ===> implies ) transfer_implies transfer_implies" | |
| 404 | "((=) ===> (=) ===> implies ) transfer_implies transfer_implies" | |
| 52354 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 405 | "(implies ===> rev_implies ===> rev_implies) transfer_implies transfer_implies" | 
| 67399 | 406 | "(implies ===> (=) ===> rev_implies) transfer_implies transfer_implies" | 
| 407 | "((=) ===> rev_implies ===> rev_implies) transfer_implies transfer_implies" | |
| 408 | "((=) ===> (=) ===> rev_implies) transfer_implies transfer_implies" | |
| 55945 | 409 | unfolding transfer_implies_def rev_implies_def rel_fun_def by auto | 
| 52354 
acb4f932dd24
implement 'transferred' attribute for transfer package, with support for monotonicity of !!/==>
 huffman parents: 
51956diff
changeset | 410 | |
| 47684 | 411 | lemma eq_imp_transfer [transfer_rule]: | 
| 67399 | 412 | "right_unique A \<Longrightarrow> (A ===> A ===> (\<longrightarrow>)) (=) (=)" | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 413 | unfolding right_unique_alt_def2 . | 
| 47684 | 414 | |
| 60758 | 415 | text \<open>Transfer rules using equality.\<close> | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 416 | |
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 417 | lemma left_unique_transfer [transfer_rule]: | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 418 | assumes "right_total A" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 419 | assumes "right_total B" | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 420 | assumes "bi_unique A" | 
| 67399 | 421 | shows "((A ===> B ===> (=)) ===> implies) left_unique left_unique" | 
| 56518 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 422 | using assms unfolding left_unique_def[abs_def] right_total_def bi_unique_def rel_fun_def | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 423 | by metis | 
| 
beb3b6851665
left_total and left_unique rules are now transfer rules (cleaner solution, reflexvity_rule attribute not needed anymore)
 kuncar parents: 
56085diff
changeset | 424 | |
| 47636 | 425 | lemma eq_transfer [transfer_rule]: | 
| 47325 | 426 | assumes "bi_unique A" | 
| 67399 | 427 | shows "(A ===> A ===> (=)) (=) (=)" | 
| 55945 | 428 | using assms unfolding bi_unique_def rel_fun_def by auto | 
| 47325 | 429 | |
| 51956 
a4d81cdebf8b
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
 kuncar parents: 
51955diff
changeset | 430 | lemma right_total_Ex_transfer[transfer_rule]: | 
| 
a4d81cdebf8b
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
 kuncar parents: 
51955diff
changeset | 431 | assumes "right_total A" | 
| 67399 | 432 | shows "((A ===> (=)) ===> (=)) (Bex (Collect (Domainp A))) Ex" | 
| 55945 | 433 | using assms unfolding right_total_def Bex_def rel_fun_def Domainp_iff[abs_def] | 
| 56085 | 434 | by fast | 
| 51956 
a4d81cdebf8b
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
 kuncar parents: 
51955diff
changeset | 435 | |
| 
a4d81cdebf8b
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
 kuncar parents: 
51955diff
changeset | 436 | lemma right_total_All_transfer[transfer_rule]: | 
| 
a4d81cdebf8b
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
 kuncar parents: 
51955diff
changeset | 437 | assumes "right_total A" | 
| 67399 | 438 | shows "((A ===> (=)) ===> (=)) (Ball (Collect (Domainp A))) All" | 
| 55945 | 439 | using assms unfolding right_total_def Ball_def rel_fun_def Domainp_iff[abs_def] | 
| 56085 | 440 | by fast | 
| 51956 
a4d81cdebf8b
better support for domains in Lifting/Transfer = replace Domainp T by the actual invariant in a transferred goal
 kuncar parents: 
51955diff
changeset | 441 | |
| 68521 | 442 | lemma right_total_fun_eq_transfer: | 
| 443 | includes lifting_syntax | |
| 444 | assumes [transfer_rule]: "right_total A" "bi_unique B" | |
| 445 | shows "((A ===> B) ===> (A ===> B) ===> (=)) (\<lambda>f g. \<forall>x\<in>Collect(Domainp A). f x = g x) (=)" | |
| 446 | unfolding fun_eq_iff | |
| 447 | by transfer_prover | |
| 448 | ||
| 47636 | 449 | lemma All_transfer [transfer_rule]: | 
| 47325 | 450 | assumes "bi_total A" | 
| 67399 | 451 | shows "((A ===> (=)) ===> (=)) All All" | 
| 55945 | 452 | using assms unfolding bi_total_def rel_fun_def by fast | 
| 47325 | 453 | |
| 47636 | 454 | lemma Ex_transfer [transfer_rule]: | 
| 47325 | 455 | assumes "bi_total A" | 
| 67399 | 456 | shows "((A ===> (=)) ===> (=)) Ex Ex" | 
| 55945 | 457 | using assms unfolding bi_total_def rel_fun_def by fast | 
| 47325 | 458 | |
| 59515 | 459 | lemma Ex1_parametric [transfer_rule]: | 
| 460 | assumes [transfer_rule]: "bi_unique A" "bi_total A" | |
| 67399 | 461 | shows "((A ===> (=)) ===> (=)) Ex1 Ex1" | 
| 59515 | 462 | unfolding Ex1_def[abs_def] by transfer_prover | 
| 463 | ||
| 58448 | 464 | declare If_transfer [transfer_rule] | 
| 47325 | 465 | |
| 47636 | 466 | lemma Let_transfer [transfer_rule]: "(A ===> (A ===> B) ===> B) Let Let" | 
| 55945 | 467 | unfolding rel_fun_def by simp | 
| 47612 | 468 | |
| 58916 | 469 | declare id_transfer [transfer_rule] | 
| 47625 | 470 | |
| 58444 | 471 | declare comp_transfer [transfer_rule] | 
| 47325 | 472 | |
| 58916 | 473 | lemma curry_transfer [transfer_rule]: | 
| 474 | "((rel_prod A B ===> C) ===> A ===> B ===> C) curry curry" | |
| 475 | unfolding curry_def by transfer_prover | |
| 476 | ||
| 47636 | 477 | lemma fun_upd_transfer [transfer_rule]: | 
| 47325 | 478 | assumes [transfer_rule]: "bi_unique A" | 
| 479 | shows "((A ===> B) ===> A ===> B ===> A ===> B) fun_upd fun_upd" | |
| 47635 
ebb79474262c
rename 'correspondence' method to 'transfer_prover'
 huffman parents: 
47627diff
changeset | 480 | unfolding fun_upd_def [abs_def] by transfer_prover | 
| 47325 | 481 | |
| 55415 | 482 | lemma case_nat_transfer [transfer_rule]: | 
| 67399 | 483 | "(A ===> ((=) ===> A) ===> (=) ===> A) case_nat case_nat" | 
| 55945 | 484 | unfolding rel_fun_def by (simp split: nat.split) | 
| 47627 
2b1d3eda59eb
add secondary transfer rule for universal quantifiers on non-bi-total relations
 huffman parents: 
47625diff
changeset | 485 | |
| 55415 | 486 | lemma rec_nat_transfer [transfer_rule]: | 
| 67399 | 487 | "(A ===> ((=) ===> A ===> A) ===> (=) ===> A) rec_nat rec_nat" | 
| 55945 | 488 | unfolding rel_fun_def by (clarsimp, rename_tac n, induct_tac n, simp_all) | 
| 47924 | 489 | |
| 490 | lemma funpow_transfer [transfer_rule]: | |
| 67399 | 491 | "((=) ===> (A ===> A) ===> (A ===> A)) compow compow" | 
| 47924 | 492 | unfolding funpow_def by transfer_prover | 
| 493 | ||
| 53952 | 494 | lemma mono_transfer[transfer_rule]: | 
| 495 | assumes [transfer_rule]: "bi_total A" | |
| 67399 | 496 | assumes [transfer_rule]: "(A ===> A ===> (=)) (\<le>) (\<le>)" | 
| 497 | assumes [transfer_rule]: "(B ===> B ===> (=)) (\<le>) (\<le>)" | |
| 498 | shows "((A ===> B) ===> (=)) mono mono" | |
| 53952 | 499 | unfolding mono_def[abs_def] by transfer_prover | 
| 500 | ||
| 58182 | 501 | lemma right_total_relcompp_transfer[transfer_rule]: | 
| 53952 | 502 | assumes [transfer_rule]: "right_total B" | 
| 67399 | 503 | shows "((A ===> B ===> (=)) ===> (B ===> C ===> (=)) ===> A ===> C ===> (=)) | 
| 504 | (\<lambda>R S x z. \<exists>y\<in>Collect (Domainp B). R x y \<and> S y z) (OO)" | |
| 53952 | 505 | unfolding OO_def[abs_def] by transfer_prover | 
| 506 | ||
| 58182 | 507 | lemma relcompp_transfer[transfer_rule]: | 
| 53952 | 508 | assumes [transfer_rule]: "bi_total B" | 
| 67399 | 509 | shows "((A ===> B ===> (=)) ===> (B ===> C ===> (=)) ===> A ===> C ===> (=)) (OO) (OO)" | 
| 53952 | 510 | unfolding OO_def[abs_def] by transfer_prover | 
| 47627 
2b1d3eda59eb
add secondary transfer rule for universal quantifiers on non-bi-total relations
 huffman parents: 
47625diff
changeset | 511 | |
| 53952 | 512 | lemma right_total_Domainp_transfer[transfer_rule]: | 
| 513 | assumes [transfer_rule]: "right_total B" | |
| 67399 | 514 | shows "((A ===> B ===> (=)) ===> A ===> (=)) (\<lambda>T x. \<exists>y\<in>Collect(Domainp B). T x y) Domainp" | 
| 53952 | 515 | apply(subst(2) Domainp_iff[abs_def]) by transfer_prover | 
| 516 | ||
| 517 | lemma Domainp_transfer[transfer_rule]: | |
| 518 | assumes [transfer_rule]: "bi_total B" | |
| 67399 | 519 | shows "((A ===> B ===> (=)) ===> A ===> (=)) Domainp Domainp" | 
| 53952 | 520 | unfolding Domainp_iff[abs_def] by transfer_prover | 
| 521 | ||
| 58182 | 522 | lemma reflp_transfer[transfer_rule]: | 
| 67399 | 523 | "bi_total A \<Longrightarrow> ((A ===> A ===> (=)) ===> (=)) reflp reflp" | 
| 53952 | 524 | "right_total A \<Longrightarrow> ((A ===> A ===> implies) ===> implies) reflp reflp" | 
| 67399 | 525 | "right_total A \<Longrightarrow> ((A ===> A ===> (=)) ===> implies) reflp reflp" | 
| 53952 | 526 | "bi_total A \<Longrightarrow> ((A ===> A ===> rev_implies) ===> rev_implies) reflp reflp" | 
| 67399 | 527 | "bi_total A \<Longrightarrow> ((A ===> A ===> (=)) ===> rev_implies) reflp reflp" | 
| 63092 | 528 | unfolding reflp_def[abs_def] rev_implies_def bi_total_def right_total_def rel_fun_def | 
| 53952 | 529 | by fast+ | 
| 530 | ||
| 531 | lemma right_unique_transfer [transfer_rule]: | |
| 59523 | 532 | "\<lbrakk> right_total A; right_total B; bi_unique B \<rbrakk> | 
| 67399 | 533 | \<Longrightarrow> ((A ===> B ===> (=)) ===> implies) right_unique right_unique" | 
| 59523 | 534 | unfolding right_unique_def[abs_def] right_total_def bi_unique_def rel_fun_def | 
| 53952 | 535 | by metis | 
| 47325 | 536 | |
| 59523 | 537 | lemma left_total_parametric [transfer_rule]: | 
| 538 | assumes [transfer_rule]: "bi_total A" "bi_total B" | |
| 67399 | 539 | shows "((A ===> B ===> (=)) ===> (=)) left_total left_total" | 
| 59523 | 540 | unfolding left_total_def[abs_def] by transfer_prover | 
| 541 | ||
| 542 | lemma right_total_parametric [transfer_rule]: | |
| 543 | assumes [transfer_rule]: "bi_total A" "bi_total B" | |
| 67399 | 544 | shows "((A ===> B ===> (=)) ===> (=)) right_total right_total" | 
| 59523 | 545 | unfolding right_total_def[abs_def] by transfer_prover | 
| 546 | ||
| 547 | lemma left_unique_parametric [transfer_rule]: | |
| 548 | assumes [transfer_rule]: "bi_unique A" "bi_total A" "bi_total B" | |
| 67399 | 549 | shows "((A ===> B ===> (=)) ===> (=)) left_unique left_unique" | 
| 59523 | 550 | unfolding left_unique_def[abs_def] by transfer_prover | 
| 551 | ||
| 552 | lemma prod_pred_parametric [transfer_rule]: | |
| 67399 | 553 | "((A ===> (=)) ===> (B ===> (=)) ===> rel_prod A B ===> (=)) pred_prod pred_prod" | 
| 62324 | 554 | unfolding prod.pred_set[abs_def] Basic_BNFs.fsts_def Basic_BNFs.snds_def fstsp.simps sndsp.simps | 
| 59523 | 555 | by simp transfer_prover | 
| 556 | ||
| 557 | lemma apfst_parametric [transfer_rule]: | |
| 558 | "((A ===> B) ===> rel_prod A C ===> rel_prod B C) apfst apfst" | |
| 559 | unfolding apfst_def[abs_def] by transfer_prover | |
| 560 | ||
| 67399 | 561 | lemma rel_fun_eq_eq_onp: "((=) ===> eq_onp P) = eq_onp (\<lambda>f. \<forall>x. P(f x))" | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 562 | unfolding eq_onp_def rel_fun_def by auto | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 563 | |
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 564 | lemma rel_fun_eq_onp_rel: | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 565 | shows "((eq_onp R) ===> S) = (\<lambda>f g. \<forall>x. R x \<longrightarrow> S (f x) (g x))" | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 566 | by (auto simp add: eq_onp_def rel_fun_def) | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 567 | |
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 568 | lemma eq_onp_transfer [transfer_rule]: | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 569 | assumes [transfer_rule]: "bi_unique A" | 
| 67399 | 570 | shows "((A ===> (=)) ===> A ===> A ===> (=)) eq_onp eq_onp" | 
| 56524 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 571 | unfolding eq_onp_def[abs_def] by transfer_prover | 
| 
f4ba736040fa
setup for Transfer and Lifting from BNF; tuned thm names
 kuncar parents: 
56520diff
changeset | 572 | |
| 57599 | 573 | lemma rtranclp_parametric [transfer_rule]: | 
| 574 | assumes "bi_unique A" "bi_total A" | |
| 67399 | 575 | shows "((A ===> A ===> (=)) ===> A ===> A ===> (=)) rtranclp rtranclp" | 
| 57599 | 576 | proof(rule rel_funI iffI)+ | 
| 577 | fix R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" and R' x y x' y' | |
| 67399 | 578 | assume R: "(A ===> A ===> (=)) R R'" and "A x x'" | 
| 57599 | 579 |   {
 | 
| 580 | assume "R\<^sup>*\<^sup>* x y" "A y y'" | |
| 581 | thus "R'\<^sup>*\<^sup>* x' y'" | |
| 582 | proof(induction arbitrary: y') | |
| 583 | case base | |
| 60758 | 584 | with \<open>bi_unique A\<close> \<open>A x x'\<close> have "x' = y'" by(rule bi_uniqueDr) | 
| 57599 | 585 | thus ?case by simp | 
| 586 | next | |
| 587 | case (step y z z') | |
| 60758 | 588 | from \<open>bi_total A\<close> obtain y' where "A y y'" unfolding bi_total_def by blast | 
| 57599 | 589 | hence "R'\<^sup>*\<^sup>* x' y'" by(rule step.IH) | 
| 60758 | 590 | moreover from R \<open>A y y'\<close> \<open>A z z'\<close> \<open>R y z\<close> | 
| 57599 | 591 | have "R' y' z'" by(auto dest: rel_funD) | 
| 592 | ultimately show ?case .. | |
| 593 | qed | |
| 594 | next | |
| 595 | assume "R'\<^sup>*\<^sup>* x' y'" "A y y'" | |
| 596 | thus "R\<^sup>*\<^sup>* x y" | |
| 597 | proof(induction arbitrary: y) | |
| 598 | case base | |
| 60758 | 599 | with \<open>bi_unique A\<close> \<open>A x x'\<close> have "x = y" by(rule bi_uniqueDl) | 
| 57599 | 600 | thus ?case by simp | 
| 601 | next | |
| 602 | case (step y' z' z) | |
| 60758 | 603 | from \<open>bi_total A\<close> obtain y where "A y y'" unfolding bi_total_def by blast | 
| 57599 | 604 | hence "R\<^sup>*\<^sup>* x y" by(rule step.IH) | 
| 60758 | 605 | moreover from R \<open>A y y'\<close> \<open>A z z'\<close> \<open>R' y' z'\<close> | 
| 57599 | 606 | have "R y z" by(auto dest: rel_funD) | 
| 607 | ultimately show ?case .. | |
| 608 | qed | |
| 609 | } | |
| 610 | qed | |
| 611 | ||
| 59523 | 612 | lemma right_unique_parametric [transfer_rule]: | 
| 613 | assumes [transfer_rule]: "bi_total A" "bi_unique B" "bi_total B" | |
| 67399 | 614 | shows "((A ===> B ===> (=)) ===> (=)) right_unique right_unique" | 
| 59523 | 615 | unfolding right_unique_def[abs_def] by transfer_prover | 
| 616 | ||
| 61630 | 617 | lemma map_fun_parametric [transfer_rule]: | 
| 618 | "((A ===> B) ===> (C ===> D) ===> (B ===> C) ===> A ===> D) map_fun map_fun" | |
| 619 | unfolding map_fun_def[abs_def] by transfer_prover | |
| 620 | ||
| 47325 | 621 | end | 
| 53011 
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
 kuncar parents: 
52358diff
changeset | 622 | |
| 64014 | 623 | |
| 69593 | 624 | subsection \<open>\<^const>\<open>of_nat\<close>\<close> | 
| 64014 | 625 | |
| 626 | lemma transfer_rule_of_nat: | |
| 627 | fixes R :: "'a::semiring_1 \<Rightarrow> 'b::semiring_1 \<Rightarrow> bool" | |
| 628 | assumes [transfer_rule]: "R 0 0" "R 1 1" | |
| 629 | "rel_fun R (rel_fun R R) plus plus" | |
| 630 | shows "rel_fun HOL.eq R of_nat of_nat" | |
| 631 | by (unfold of_nat_def [abs_def]) transfer_prover | |
| 632 | ||
| 53011 
aeee0a4be6cf
introduce locale with syntax for fun_rel and map_fun and make thus ===> and ---> local
 kuncar parents: 
52358diff
changeset | 633 | end |