| author | wenzelm | 
| Fri, 05 Jul 2024 12:53:45 +0200 | |
| changeset 80509 | 2a9abd6a164e | 
| parent 79940 | 5e85ea359563 | 
| child 80932 | 261cd8722677 | 
| permissions | -rw-r--r-- | 
| 10213 | 1 | (* Title: HOL/Transitive_Closure.thy | 
| 2 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | |
| 3 | Copyright 1992 University of Cambridge | |
| 4 | *) | |
| 5 | ||
| 60758 | 6 | section \<open>Reflexive and Transitive closure of a relation\<close> | 
| 12691 | 7 | |
| 15131 | 8 | theory Transitive_Closure | 
| 77695 
93531ba2c784
reversed import dependency between Relation and Finite_Set; and move theorems around
 desharna parents: 
76751diff
changeset | 9 | imports Finite_Set | 
| 67723 | 10 | abbrevs "^*" = "\<^sup>*" "\<^sup>*\<^sup>*" | 
| 11 | and "^+" = "\<^sup>+" "\<^sup>+\<^sup>+" | |
| 12 | and "^=" = "\<^sup>=" "\<^sup>=\<^sup>=" | |
| 15131 | 13 | begin | 
| 12691 | 14 | |
| 69605 | 15 | ML_file \<open>~~/src/Provers/trancl.ML\<close> | 
| 48891 | 16 | |
| 60758 | 17 | text \<open> | 
| 61799 | 18 | \<open>rtrancl\<close> is reflexive/transitive closure, | 
| 19 | \<open>trancl\<close> is transitive closure, | |
| 20 | \<open>reflcl\<close> is reflexive closure. | |
| 12691 | 21 | |
| 63612 | 22 | These postfix operators have \<^emph>\<open>maximum priority\<close>, forcing their | 
| 12691 | 23 | operands to be atomic. | 
| 60758 | 24 | \<close> | 
| 10213 | 25 | |
| 63612 | 26 | context notes [[inductive_internals]] | 
| 61681 
ca53150406c9
option "inductive_defs" controls exposure of def and mono facts;
 wenzelm parents: 
61424diff
changeset | 27 | begin | 
| 
ca53150406c9
option "inductive_defs" controls exposure of def and mono facts;
 wenzelm parents: 
61424diff
changeset | 28 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 29 | inductive_set rtrancl :: "('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set"  ("(_\<^sup>*)" [1000] 999)
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 30 |   for r :: "('a \<times> 'a) set"
 | 
| 63612 | 31 | where | 
| 32 | rtrancl_refl [intro!, Pure.intro!, simp]: "(a, a) \<in> r\<^sup>*" | |
| 33 | | rtrancl_into_rtrancl [Pure.intro]: "(a, b) \<in> r\<^sup>* \<Longrightarrow> (b, c) \<in> r \<Longrightarrow> (a, c) \<in> r\<^sup>*" | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 34 | |
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 35 | inductive_set trancl :: "('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set"  ("(_\<^sup>+)" [1000] 999)
 | 
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 36 |   for r :: "('a \<times> 'a) set"
 | 
| 63612 | 37 | where | 
| 38 | r_into_trancl [intro, Pure.intro]: "(a, b) \<in> r \<Longrightarrow> (a, b) \<in> r\<^sup>+" | |
| 39 | | trancl_into_trancl [Pure.intro]: "(a, b) \<in> r\<^sup>+ \<Longrightarrow> (b, c) \<in> r \<Longrightarrow> (a, c) \<in> r\<^sup>+" | |
| 11327 
cd2c27a23df1
Transitive closure is now defined via "inductive".
 berghofe parents: 
11115diff
changeset | 40 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 41 | notation | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 42 |   rtranclp  ("(_\<^sup>*\<^sup>*)" [1000] 1000) and
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 43 |   tranclp  ("(_\<^sup>+\<^sup>+)" [1000] 1000)
 | 
| 13704 
854501b1e957
Transitive closure is now defined inductively as well.
 berghofe parents: 
12937diff
changeset | 44 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 45 | declare | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 46 | rtrancl_def [nitpick_unfold del] | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 47 | rtranclp_def [nitpick_unfold del] | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 48 | trancl_def [nitpick_unfold del] | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 49 | tranclp_def [nitpick_unfold del] | 
| 33878 
85102f57b4a8
removed "nitpick_def" attributes from (r)trancl(p), since "Nitpick.thy" overrides these
 blanchet parents: 
33656diff
changeset | 50 | |
| 61681 
ca53150406c9
option "inductive_defs" controls exposure of def and mono facts;
 wenzelm parents: 
61424diff
changeset | 51 | end | 
| 
ca53150406c9
option "inductive_defs" controls exposure of def and mono facts;
 wenzelm parents: 
61424diff
changeset | 52 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 53 | abbreviation reflcl :: "('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set"  ("(_\<^sup>=)" [1000] 999)
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 54 | where "r\<^sup>= \<equiv> r \<union> Id" | 
| 10213 | 55 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 56 | abbreviation reflclp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"  ("(_\<^sup>=\<^sup>=)" [1000] 1000)
 | 
| 67399 | 57 | where "r\<^sup>=\<^sup>= \<equiv> sup r (=)" | 
| 22262 | 58 | |
| 61955 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 59 | notation (ASCII) | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 60 |   rtrancl  ("(_^*)" [1000] 999) and
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 61 |   trancl  ("(_^+)" [1000] 999) and
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 62 |   reflcl  ("(_^=)" [1000] 999) and
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 63 |   rtranclp  ("(_^**)" [1000] 1000) and
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 64 |   tranclp  ("(_^++)" [1000] 1000) and
 | 
| 
e96292f32c3c
former "xsymbols" syntax is used by default, and ASCII replacement syntax with print mode "ASCII";
 wenzelm parents: 
61799diff
changeset | 65 |   reflclp  ("(_^==)" [1000] 1000)
 | 
| 12691 | 66 | |
| 67 | ||
| 60758 | 68 | subsection \<open>Reflexive closure\<close> | 
| 26271 | 69 | |
| 76638 | 70 | lemma reflcl_set_eq [pred_set_conv]: "(sup (\<lambda>x y. (x, y) \<in> r) (=)) = (\<lambda>x y. (x, y) \<in> r \<union> Id)" | 
| 71 | by (auto simp: fun_eq_iff) | |
| 72 | ||
| 63404 | 73 | lemma refl_reflcl[simp]: "refl (r\<^sup>=)" | 
| 74 | by (simp add: refl_on_def) | |
| 26271 | 75 | |
| 76496 | 76 | lemma reflp_on_reflclp[simp]: "reflp_on A R\<^sup>=\<^sup>=" | 
| 77 | by (simp add: reflp_on_def) | |
| 78 | ||
| 76638 | 79 | lemma antisym_on_reflcl[simp]: "antisym_on A (r\<^sup>=) \<longleftrightarrow> antisym_on A r" | 
| 80 | by (simp add: antisym_on_def) | |
| 81 | ||
| 79940 
5e85ea359563
renamed lemma antisymp_on_reflcp to antisymp_on_reflclp
 desharna parents: 
79939diff
changeset | 82 | lemma antisymp_on_reflclp[simp]: "antisymp_on A R\<^sup>=\<^sup>= \<longleftrightarrow> antisymp_on A R" | 
| 76638 | 83 | by (rule antisym_on_reflcl[to_pred]) | 
| 26271 | 84 | |
| 76751 | 85 | lemma trans_on_reflcl[simp]: "trans_on A r \<Longrightarrow> trans_on A (r\<^sup>=)" | 
| 86 | by (auto intro: trans_onI dest: trans_onD) | |
| 26271 | 87 | |
| 76750 | 88 | lemma transp_on_reflclp[simp]: "transp_on A R \<Longrightarrow> transp_on A R\<^sup>=\<^sup>=" | 
| 76751 | 89 | by (rule trans_on_reflcl[to_pred]) | 
| 76498 | 90 | |
| 79937 
d26c53bc6ce1
added lemmas antisym_on_reflcl_if_asym_on and antisymp_on_reflclp_if_asymp_on
 desharna parents: 
79806diff
changeset | 91 | lemma antisymp_on_reflclp_if_asymp_on: | 
| 
d26c53bc6ce1
added lemmas antisym_on_reflcl_if_asym_on and antisymp_on_reflclp_if_asymp_on
 desharna parents: 
79806diff
changeset | 92 | assumes "asymp_on A R" | 
| 
d26c53bc6ce1
added lemmas antisym_on_reflcl_if_asym_on and antisymp_on_reflclp_if_asymp_on
 desharna parents: 
79806diff
changeset | 93 | shows "antisymp_on A R\<^sup>=\<^sup>=" | 
| 79940 
5e85ea359563
renamed lemma antisymp_on_reflcp to antisymp_on_reflclp
 desharna parents: 
79939diff
changeset | 94 | unfolding antisymp_on_reflclp | 
| 79939 | 95 | using antisymp_on_if_asymp_on[OF \<open>asymp_on A R\<close>] . | 
| 79937 
d26c53bc6ce1
added lemmas antisym_on_reflcl_if_asym_on and antisymp_on_reflclp_if_asymp_on
 desharna parents: 
79806diff
changeset | 96 | |
| 
d26c53bc6ce1
added lemmas antisym_on_reflcl_if_asym_on and antisymp_on_reflclp_if_asymp_on
 desharna parents: 
79806diff
changeset | 97 | lemma antisym_on_reflcl_if_asym_on: "asym_on A R \<Longrightarrow> antisym_on A (R\<^sup>=)" | 
| 
d26c53bc6ce1
added lemmas antisym_on_reflcl_if_asym_on and antisymp_on_reflclp_if_asymp_on
 desharna parents: 
79806diff
changeset | 98 | using antisymp_on_reflclp_if_asymp_on[to_set] . | 
| 
d26c53bc6ce1
added lemmas antisym_on_reflcl_if_asym_on and antisymp_on_reflclp_if_asymp_on
 desharna parents: 
79806diff
changeset | 99 | |
| 63404 | 100 | lemma reflclp_idemp [simp]: "(P\<^sup>=\<^sup>=)\<^sup>=\<^sup>= = P\<^sup>=\<^sup>=" | 
| 101 | by blast | |
| 102 | ||
| 76497 | 103 | lemma reflclp_ident_if_reflp[simp]: "reflp R \<Longrightarrow> R\<^sup>=\<^sup>= = R" | 
| 104 | by (auto dest: reflpD) | |
| 105 | ||
| 79806 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 106 | text \<open>The following are special cases of @{thm [source] reflclp_ident_if_reflp},
 | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 107 | but they appear duplicated in multiple, independent theories, which causes name clashes.\<close> | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 108 | |
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 109 | lemma (in preorder) reflclp_less_eq[simp]: "(\<le>)\<^sup>=\<^sup>= = (\<le>)" | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 110 | using reflp_on_le by (simp only: reflclp_ident_if_reflp) | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 111 | |
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 112 | lemma (in preorder) reflclp_greater_eq[simp]: "(\<ge>)\<^sup>=\<^sup>= = (\<ge>)" | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 113 | using reflp_on_ge by (simp only: reflclp_ident_if_reflp) | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 114 | |
| 79938 | 115 | lemma order_reflclp_if_transp_and_asymp: | 
| 116 | assumes "transp R" and "asymp R" | |
| 117 | shows "class.order R\<^sup>=\<^sup>= R" | |
| 118 | proof unfold_locales | |
| 119 | show "\<And>x y. R x y = (R\<^sup>=\<^sup>= x y \<and> \<not> R\<^sup>=\<^sup>= y x)" | |
| 120 | using \<open>asymp R\<close> asympD by fastforce | |
| 121 | next | |
| 122 | show "\<And>x. R\<^sup>=\<^sup>= x x" | |
| 123 | by simp | |
| 124 | next | |
| 125 | show "\<And>x y z. R\<^sup>=\<^sup>= x y \<Longrightarrow> R\<^sup>=\<^sup>= y z \<Longrightarrow> R\<^sup>=\<^sup>= x z" | |
| 126 | using transp_on_reflclp[OF \<open>transp R\<close>, THEN transpD] . | |
| 127 | next | |
| 128 | show "\<And>x y. R\<^sup>=\<^sup>= x y \<Longrightarrow> R\<^sup>=\<^sup>= y x \<Longrightarrow> x = y" | |
| 129 | using antisymp_on_reflclp_if_asymp_on[OF \<open>asymp R\<close>, THEN antisympD] . | |
| 130 | qed | |
| 131 | ||
| 26271 | 132 | |
| 60758 | 133 | subsection \<open>Reflexive-transitive closure\<close> | 
| 12691 | 134 | |
| 63404 | 135 | lemma r_into_rtrancl [intro]: "\<And>p. p \<in> r \<Longrightarrow> p \<in> r\<^sup>*" | 
| 61799 | 136 | \<comment> \<open>\<open>rtrancl\<close> of \<open>r\<close> contains \<open>r\<close>\<close> | 
| 71627 | 137 | by (simp add: split_tupled_all rtrancl_refl [THEN rtrancl_into_rtrancl]) | 
| 12691 | 138 | |
| 63404 | 139 | lemma r_into_rtranclp [intro]: "r x y \<Longrightarrow> r\<^sup>*\<^sup>* x y" | 
| 61799 | 140 | \<comment> \<open>\<open>rtrancl\<close> of \<open>r\<close> contains \<open>r\<close>\<close> | 
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 141 | by (erule rtranclp.rtrancl_refl [THEN rtranclp.rtrancl_into_rtrancl]) | 
| 22262 | 142 | |
| 63404 | 143 | lemma rtranclp_mono: "r \<le> s \<Longrightarrow> r\<^sup>*\<^sup>* \<le> s\<^sup>*\<^sup>*" | 
| 61799 | 144 | \<comment> \<open>monotonicity of \<open>rtrancl\<close>\<close> | 
| 71627 | 145 | proof (rule predicate2I) | 
| 146 | show "s\<^sup>*\<^sup>* x y" if "r \<le> s" "r\<^sup>*\<^sup>* x y" for x y | |
| 147 | using \<open>r\<^sup>*\<^sup>* x y\<close> \<open>r \<le> s\<close> | |
| 148 | by (induction rule: rtranclp.induct) (blast intro: rtranclp.rtrancl_into_rtrancl)+ | |
| 149 | qed | |
| 12691 | 150 | |
| 63404 | 151 | lemma mono_rtranclp[mono]: "(\<And>a b. x a b \<longrightarrow> y a b) \<Longrightarrow> x\<^sup>*\<^sup>* a b \<longrightarrow> y\<^sup>*\<^sup>* a b" | 
| 60681 | 152 | using rtranclp_mono[of x y] by auto | 
| 153 | ||
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 154 | lemmas rtrancl_mono = rtranclp_mono [to_set] | 
| 22262 | 155 | |
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 156 | theorem rtranclp_induct [consumes 1, case_names base step, induct set: rtranclp]: | 
| 63404 | 157 | assumes a: "r\<^sup>*\<^sup>* a b" | 
| 158 | and cases: "P a" "\<And>y z. r\<^sup>*\<^sup>* a y \<Longrightarrow> r y z \<Longrightarrow> P y \<Longrightarrow> P z" | |
| 159 | shows "P b" | |
| 160 | using a by (induct x\<equiv>a b) (rule cases)+ | |
| 12691 | 161 | |
| 25425 
9191942c4ead
Removed some case_names and consumes attributes that are now no longer
 berghofe parents: 
25295diff
changeset | 162 | lemmas rtrancl_induct [induct set: rtrancl] = rtranclp_induct [to_set] | 
| 22262 | 163 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 164 | lemmas rtranclp_induct2 = | 
| 63404 | 165 | rtranclp_induct[of _ "(ax,ay)" "(bx,by)", split_rule, consumes 1, case_names refl step] | 
| 22262 | 166 | |
| 14404 
4952c5a92e04
Transitive_Closure: added consumes and case_names attributes
 nipkow parents: 
14398diff
changeset | 167 | lemmas rtrancl_induct2 = | 
| 63404 | 168 | rtrancl_induct[of "(ax,ay)" "(bx,by)", split_format (complete), consumes 1, case_names refl step] | 
| 18372 | 169 | |
| 63404 | 170 | lemma refl_rtrancl: "refl (r\<^sup>*)" | 
| 171 | unfolding refl_on_def by fast | |
| 19228 | 172 | |
| 60758 | 173 | text \<open>Transitivity of transitive closure.\<close> | 
| 63404 | 174 | lemma trans_rtrancl: "trans (r\<^sup>*)" | 
| 12823 | 175 | proof (rule transI) | 
| 176 | fix x y z | |
| 177 | assume "(x, y) \<in> r\<^sup>*" | |
| 178 | assume "(y, z) \<in> r\<^sup>*" | |
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 179 | then show "(x, z) \<in> r\<^sup>*" | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 180 | proof induct | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 181 | case base | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 182 | show "(x, y) \<in> r\<^sup>*" by fact | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 183 | next | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 184 | case (step u v) | 
| 60758 | 185 | from \<open>(x, u) \<in> r\<^sup>*\<close> and \<open>(u, v) \<in> r\<close> | 
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 186 | show "(x, v) \<in> r\<^sup>*" .. | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 187 | qed | 
| 12823 | 188 | qed | 
| 12691 | 189 | |
| 45607 | 190 | lemmas rtrancl_trans = trans_rtrancl [THEN transD] | 
| 12691 | 191 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 192 | lemma rtranclp_trans: | 
| 63404 | 193 | assumes "r\<^sup>*\<^sup>* x y" | 
| 194 | and "r\<^sup>*\<^sup>* y z" | |
| 195 | shows "r\<^sup>*\<^sup>* x z" | |
| 196 | using assms(2,1) by induct iprover+ | |
| 22262 | 197 | |
| 26174 
9efd4c04eaa4
rtranclE, tranclE: tuned statement, added case_names;
 wenzelm parents: 
25425diff
changeset | 198 | lemma rtranclE [cases set: rtrancl]: | 
| 63404 | 199 | fixes a b :: 'a | 
| 200 | assumes major: "(a, b) \<in> r\<^sup>*" | |
| 26174 
9efd4c04eaa4
rtranclE, tranclE: tuned statement, added case_names;
 wenzelm parents: 
25425diff
changeset | 201 | obtains | 
| 
9efd4c04eaa4
rtranclE, tranclE: tuned statement, added case_names;
 wenzelm parents: 
25425diff
changeset | 202 | (base) "a = b" | 
| 63404 | 203 | | (step) y where "(a, y) \<in> r\<^sup>*" and "(y, b) \<in> r" | 
| 61799 | 204 | \<comment> \<open>elimination of \<open>rtrancl\<close> -- by induction on a special formula\<close> | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 205 | proof - | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 206 | have "a = b \<or> (\<exists>y. (a, y) \<in> r\<^sup>* \<and> (y, b) \<in> r)" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 207 | by (rule major [THEN rtrancl_induct]) blast+ | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 208 | then show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 209 | by (auto intro: base step) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 210 | qed | 
| 12691 | 211 | |
| 63404 | 212 | lemma rtrancl_Int_subset: "Id \<subseteq> s \<Longrightarrow> (r\<^sup>* \<inter> s) O r \<subseteq> s \<Longrightarrow> r\<^sup>* \<subseteq> s" | 
| 71627 | 213 | by (fastforce elim: rtrancl_induct) | 
| 22080 
7bf8868ab3e4
induction rules for trancl/rtrancl expressed using subsets
 paulson parents: 
21589diff
changeset | 214 | |
| 63404 | 215 | lemma converse_rtranclp_into_rtranclp: "r a b \<Longrightarrow> r\<^sup>*\<^sup>* b c \<Longrightarrow> r\<^sup>*\<^sup>* a c" | 
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 216 | by (rule rtranclp_trans) iprover+ | 
| 22262 | 217 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 218 | lemmas converse_rtrancl_into_rtrancl = converse_rtranclp_into_rtranclp [to_set] | 
| 12691 | 219 | |
| 69593 | 220 | text \<open>\<^medskip> More \<^term>\<open>r\<^sup>*\<close> equations and inclusions.\<close> | 
| 12691 | 221 | |
| 63404 | 222 | lemma rtranclp_idemp [simp]: "(r\<^sup>*\<^sup>*)\<^sup>*\<^sup>* = r\<^sup>*\<^sup>*" | 
| 71627 | 223 | proof - | 
| 224 | have "r\<^sup>*\<^sup>*\<^sup>*\<^sup>* x y \<Longrightarrow> r\<^sup>*\<^sup>* x y" for x y | |
| 225 | by (induction rule: rtranclp_induct) (blast intro: rtranclp_trans)+ | |
| 226 | then show ?thesis | |
| 227 | by (auto intro!: order_antisym) | |
| 228 | qed | |
| 12691 | 229 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 230 | lemmas rtrancl_idemp [simp] = rtranclp_idemp [to_set] | 
| 22262 | 231 | |
| 63404 | 232 | lemma rtrancl_idemp_self_comp [simp]: "R\<^sup>* O R\<^sup>* = R\<^sup>*" | 
| 71627 | 233 | by (force intro: rtrancl_trans) | 
| 12691 | 234 | |
| 63404 | 235 | lemma rtrancl_subset_rtrancl: "r \<subseteq> s\<^sup>* \<Longrightarrow> r\<^sup>* \<subseteq> s\<^sup>*" | 
| 71627 | 236 | by (drule rtrancl_mono, simp) | 
| 12691 | 237 | |
| 63404 | 238 | lemma rtranclp_subset: "R \<le> S \<Longrightarrow> S \<le> R\<^sup>*\<^sup>* \<Longrightarrow> S\<^sup>*\<^sup>* = R\<^sup>*\<^sup>*" | 
| 71627 | 239 | by (fastforce dest: rtranclp_mono) | 
| 12691 | 240 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 241 | lemmas rtrancl_subset = rtranclp_subset [to_set] | 
| 22262 | 242 | |
| 63404 | 243 | lemma rtranclp_sup_rtranclp: "(sup (R\<^sup>*\<^sup>*) (S\<^sup>*\<^sup>*))\<^sup>*\<^sup>* = (sup R S)\<^sup>*\<^sup>*" | 
| 244 | by (blast intro!: rtranclp_subset intro: rtranclp_mono [THEN predicate2D]) | |
| 12691 | 245 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 246 | lemmas rtrancl_Un_rtrancl = rtranclp_sup_rtranclp [to_set] | 
| 22262 | 247 | |
| 63404 | 248 | lemma rtranclp_reflclp [simp]: "(R\<^sup>=\<^sup>=)\<^sup>*\<^sup>* = R\<^sup>*\<^sup>*" | 
| 249 | by (blast intro!: rtranclp_subset) | |
| 22262 | 250 | |
| 50616 | 251 | lemmas rtrancl_reflcl [simp] = rtranclp_reflclp [to_set] | 
| 12691 | 252 | |
| 63404 | 253 | lemma rtrancl_r_diff_Id: "(r - Id)\<^sup>* = r\<^sup>*" | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 254 | by (rule rtrancl_subset [symmetric]) auto | 
| 12691 | 255 | |
| 67399 | 256 | lemma rtranclp_r_diff_Id: "(inf r (\<noteq>))\<^sup>*\<^sup>* = r\<^sup>*\<^sup>*" | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 257 | by (rule rtranclp_subset [symmetric]) auto | 
| 22262 | 258 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 259 | theorem rtranclp_converseD: | 
| 63404 | 260 | assumes "(r\<inverse>\<inverse>)\<^sup>*\<^sup>* x y" | 
| 261 | shows "r\<^sup>*\<^sup>* y x" | |
| 262 | using assms by induct (iprover intro: rtranclp_trans dest!: conversepD)+ | |
| 12691 | 263 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 264 | lemmas rtrancl_converseD = rtranclp_converseD [to_set] | 
| 22262 | 265 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 266 | theorem rtranclp_converseI: | 
| 63404 | 267 | assumes "r\<^sup>*\<^sup>* y x" | 
| 268 | shows "(r\<inverse>\<inverse>)\<^sup>*\<^sup>* x y" | |
| 269 | using assms by induct (iprover intro: rtranclp_trans conversepI)+ | |
| 12691 | 270 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 271 | lemmas rtrancl_converseI = rtranclp_converseI [to_set] | 
| 22262 | 272 | |
| 67613 | 273 | lemma rtrancl_converse: "(r\<inverse>)\<^sup>* = (r\<^sup>*)\<inverse>" | 
| 12691 | 274 | by (fast dest!: rtrancl_converseD intro!: rtrancl_converseI) | 
| 275 | ||
| 63404 | 276 | lemma sym_rtrancl: "sym r \<Longrightarrow> sym (r\<^sup>*)" | 
| 19228 | 277 | by (simp only: sym_conv_converse_eq rtrancl_converse [symmetric]) | 
| 278 | ||
| 34909 
a799687944af
Tuned some proofs; nicer case names for some of the induction / cases rules.
 berghofe parents: 
33878diff
changeset | 279 | theorem converse_rtranclp_induct [consumes 1, case_names base step]: | 
| 63404 | 280 | assumes major: "r\<^sup>*\<^sup>* a b" | 
| 281 | and cases: "P b" "\<And>y z. r y z \<Longrightarrow> r\<^sup>*\<^sup>* z b \<Longrightarrow> P z \<Longrightarrow> P y" | |
| 12937 
0c4fd7529467
clarified syntax of ``long'' statements: fixes/assumes/shows;
 wenzelm parents: 
12823diff
changeset | 282 | shows "P a" | 
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 283 | using rtranclp_converseI [OF major] | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 284 | by induct (iprover intro: cases dest!: conversepD rtranclp_converseD)+ | 
| 12691 | 285 | |
| 25425 
9191942c4ead
Removed some case_names and consumes attributes that are now no longer
 berghofe parents: 
25295diff
changeset | 286 | lemmas converse_rtrancl_induct = converse_rtranclp_induct [to_set] | 
| 22262 | 287 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 288 | lemmas converse_rtranclp_induct2 = | 
| 63612 | 289 | converse_rtranclp_induct [of _ "(ax, ay)" "(bx, by)", split_rule, consumes 1, case_names refl step] | 
| 22262 | 290 | |
| 14404 
4952c5a92e04
Transitive_Closure: added consumes and case_names attributes
 nipkow parents: 
14398diff
changeset | 291 | lemmas converse_rtrancl_induct2 = | 
| 63612 | 292 | converse_rtrancl_induct [of "(ax, ay)" "(bx, by)", split_format (complete), | 
| 63404 | 293 | consumes 1, case_names refl step] | 
| 12691 | 294 | |
| 34909 
a799687944af
Tuned some proofs; nicer case names for some of the induction / cases rules.
 berghofe parents: 
33878diff
changeset | 295 | lemma converse_rtranclpE [consumes 1, case_names base step]: | 
| 63404 | 296 | assumes major: "r\<^sup>*\<^sup>* x z" | 
| 297 | and cases: "x = z \<Longrightarrow> P" "\<And>y. r x y \<Longrightarrow> r\<^sup>*\<^sup>* y z \<Longrightarrow> P" | |
| 18372 | 298 | shows P | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 299 | proof - | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 300 | have "x = z \<or> (\<exists>y. r x y \<and> r\<^sup>*\<^sup>* y z)" | 
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
75652diff
changeset | 301 | by (rule major [THEN converse_rtranclp_induct]) iprover+ | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 302 | then show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 303 | by (auto intro: cases) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 304 | qed | 
| 12691 | 305 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 306 | lemmas converse_rtranclE = converse_rtranclpE [to_set] | 
| 22262 | 307 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 308 | lemmas converse_rtranclpE2 = converse_rtranclpE [of _ "(xa,xb)" "(za,zb)", split_rule] | 
| 22262 | 309 | |
| 310 | lemmas converse_rtranclE2 = converse_rtranclE [of "(xa,xb)" "(za,zb)", split_rule] | |
| 12691 | 311 | |
| 63404 | 312 | lemma r_comp_rtrancl_eq: "r O r\<^sup>* = r\<^sup>* O r" | 
| 12691 | 313 | by (blast elim: rtranclE converse_rtranclE | 
| 63612 | 314 | intro: rtrancl_into_rtrancl converse_rtrancl_into_rtrancl) | 
| 12691 | 315 | |
| 63404 | 316 | lemma rtrancl_unfold: "r\<^sup>* = Id \<union> r\<^sup>* O r" | 
| 15551 | 317 | by (auto intro: rtrancl_into_rtrancl elim: rtranclE) | 
| 318 | ||
| 31690 | 319 | lemma rtrancl_Un_separatorE: | 
| 63404 | 320 | "(a, b) \<in> (P \<union> Q)\<^sup>* \<Longrightarrow> \<forall>x y. (a, x) \<in> P\<^sup>* \<longrightarrow> (x, y) \<in> Q \<longrightarrow> x = y \<Longrightarrow> (a, b) \<in> P\<^sup>*" | 
| 63612 | 321 | proof (induct rule: rtrancl.induct) | 
| 322 | case rtrancl_refl | |
| 323 | then show ?case by blast | |
| 324 | next | |
| 325 | case rtrancl_into_rtrancl | |
| 326 | then show ?case by (blast intro: rtrancl_trans) | |
| 327 | qed | |
| 31690 | 328 | |
| 329 | lemma rtrancl_Un_separator_converseE: | |
| 63404 | 330 | "(a, b) \<in> (P \<union> Q)\<^sup>* \<Longrightarrow> \<forall>x y. (x, b) \<in> P\<^sup>* \<longrightarrow> (y, x) \<in> Q \<longrightarrow> y = x \<Longrightarrow> (a, b) \<in> P\<^sup>*" | 
| 63612 | 331 | proof (induct rule: converse_rtrancl_induct) | 
| 332 | case base | |
| 333 | then show ?case by blast | |
| 334 | next | |
| 335 | case step | |
| 336 | then show ?case by (blast intro: rtrancl_trans) | |
| 337 | qed | |
| 31690 | 338 | |
| 34970 | 339 | lemma Image_closed_trancl: | 
| 63404 | 340 | assumes "r `` X \<subseteq> X" | 
| 341 | shows "r\<^sup>* `` X = X" | |
| 34970 | 342 | proof - | 
| 63404 | 343 |   from assms have **: "{y. \<exists>x\<in>X. (x, y) \<in> r} \<subseteq> X"
 | 
| 344 | by auto | |
| 345 | have "x \<in> X" if 1: "(y, x) \<in> r\<^sup>*" and 2: "y \<in> X" for x y | |
| 34970 | 346 | proof - | 
| 63404 | 347 | from 1 show "x \<in> X" | 
| 34970 | 348 | proof induct | 
| 63404 | 349 | case base | 
| 350 | show ?case by (fact 2) | |
| 34970 | 351 | next | 
| 63404 | 352 | case step | 
| 353 | with ** show ?case by auto | |
| 34970 | 354 | qed | 
| 355 | qed | |
| 356 | then show ?thesis by auto | |
| 357 | qed | |
| 358 | ||
| 79773 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 359 | lemma rtranclp_ident_if_reflp_and_transp: | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 360 | assumes "reflp R" and "transp R" | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 361 | shows "R\<^sup>*\<^sup>* = R" | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 362 | proof (intro ext iffI) | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 363 | fix x y | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 364 | show "R\<^sup>*\<^sup>* x y \<Longrightarrow> R x y" | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 365 | proof (induction y rule: rtranclp_induct) | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 366 | case base | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 367 | show ?case | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 368 | using \<open>reflp R\<close>[THEN reflpD] . | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 369 | next | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 370 | case (step y z) | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 371 | thus ?case | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 372 | using \<open>transp R\<close>[THEN transpD, of x y z] by simp | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 373 | qed | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 374 | next | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 375 | fix x y | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 376 | show "R x y \<Longrightarrow> R\<^sup>*\<^sup>* x y" | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 377 | using r_into_rtranclp . | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 378 | qed | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 379 | |
| 79806 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 380 | text \<open>The following are special cases of @{thm [source] rtranclp_ident_if_reflp_and_transp},
 | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 381 | but they appear duplicated in multiple, independent theories, which causes name clashes.\<close> | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 382 | |
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 383 | lemma (in preorder) rtranclp_less_eq[simp]: "(\<le>)\<^sup>*\<^sup>* = (\<le>)" | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 384 | using reflp_on_le transp_on_le by (simp only: rtranclp_ident_if_reflp_and_transp) | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 385 | |
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 386 | lemma (in preorder) rtranclp_greater_eq[simp]: "(\<ge>)\<^sup>*\<^sup>* = (\<ge>)" | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 387 | using reflp_on_ge transp_on_ge by (simp only: rtranclp_ident_if_reflp_and_transp) | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 388 | |
| 12691 | 389 | |
| 60758 | 390 | subsection \<open>Transitive closure\<close> | 
| 10331 | 391 | |
| 75652 
c4a1088d0081
added lemmas total_on_trancl and totalp_on_tranclp
 desharna parents: 
74375diff
changeset | 392 | lemma totalp_on_tranclp: "totalp_on A R \<Longrightarrow> totalp_on A (tranclp R)" | 
| 
c4a1088d0081
added lemmas total_on_trancl and totalp_on_tranclp
 desharna parents: 
74375diff
changeset | 393 | by (auto intro: totalp_onI dest: totalp_onD) | 
| 
c4a1088d0081
added lemmas total_on_trancl and totalp_on_tranclp
 desharna parents: 
74375diff
changeset | 394 | |
| 
c4a1088d0081
added lemmas total_on_trancl and totalp_on_tranclp
 desharna parents: 
74375diff
changeset | 395 | lemma total_on_trancl: "total_on A r \<Longrightarrow> total_on A (trancl r)" | 
| 
c4a1088d0081
added lemmas total_on_trancl and totalp_on_tranclp
 desharna parents: 
74375diff
changeset | 396 | by (rule totalp_on_tranclp[to_set]) | 
| 
c4a1088d0081
added lemmas total_on_trancl and totalp_on_tranclp
 desharna parents: 
74375diff
changeset | 397 | |
| 71627 | 398 | lemma trancl_mono: | 
| 399 | assumes "p \<in> r\<^sup>+" "r \<subseteq> s" | |
| 400 | shows "p \<in> s\<^sup>+" | |
| 401 | proof - | |
| 402 | have "\<lbrakk>(a, b) \<in> r\<^sup>+; r \<subseteq> s\<rbrakk> \<Longrightarrow> (a, b) \<in> s\<^sup>+" for a b | |
| 403 | by (induction rule: trancl.induct) (iprover dest: subsetD)+ | |
| 404 | with assms show ?thesis | |
| 405 | by (cases p) force | |
| 406 | qed | |
| 12691 | 407 | |
| 63404 | 408 | lemma r_into_trancl': "\<And>p. p \<in> r \<Longrightarrow> p \<in> r\<^sup>+" | 
| 13704 
854501b1e957
Transitive closure is now defined inductively as well.
 berghofe parents: 
12937diff
changeset | 409 | by (simp only: split_tupled_all) (erule r_into_trancl) | 
| 
854501b1e957
Transitive closure is now defined inductively as well.
 berghofe parents: 
12937diff
changeset | 410 | |
| 63404 | 411 | text \<open>\<^medskip> Conversions between \<open>trancl\<close> and \<open>rtrancl\<close>.\<close> | 
| 12691 | 412 | |
| 63404 | 413 | lemma tranclp_into_rtranclp: "r\<^sup>+\<^sup>+ a b \<Longrightarrow> r\<^sup>*\<^sup>* a b" | 
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 414 | by (erule tranclp.induct) iprover+ | 
| 12691 | 415 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 416 | lemmas trancl_into_rtrancl = tranclp_into_rtranclp [to_set] | 
| 22262 | 417 | |
| 63404 | 418 | lemma rtranclp_into_tranclp1: | 
| 419 | assumes "r\<^sup>*\<^sup>* a b" | |
| 420 | shows "r b c \<Longrightarrow> r\<^sup>+\<^sup>+ a c" | |
| 421 | using assms by (induct arbitrary: c) iprover+ | |
| 12691 | 422 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 423 | lemmas rtrancl_into_trancl1 = rtranclp_into_tranclp1 [to_set] | 
| 22262 | 424 | |
| 71627 | 425 | lemma rtranclp_into_tranclp2: | 
| 426 | assumes "r a b" "r\<^sup>*\<^sup>* b c" shows "r\<^sup>+\<^sup>+ a c" | |
| 61799 | 427 | \<comment> \<open>intro rule from \<open>r\<close> and \<open>rtrancl\<close>\<close> | 
| 71627 | 428 | using \<open>r\<^sup>*\<^sup>* b c\<close> | 
| 429 | proof (cases rule: rtranclp.cases) | |
| 430 | case rtrancl_refl | |
| 431 | with assms show ?thesis | |
| 432 | by iprover | |
| 433 | next | |
| 434 | case rtrancl_into_rtrancl | |
| 435 | with assms show ?thesis | |
| 436 | by (auto intro: rtranclp_trans [THEN rtranclp_into_tranclp1]) | |
| 437 | qed | |
| 12691 | 438 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 439 | lemmas rtrancl_into_trancl2 = rtranclp_into_tranclp2 [to_set] | 
| 22262 | 440 | |
| 61799 | 441 | text \<open>Nice induction rule for \<open>trancl\<close>\<close> | 
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 442 | lemma tranclp_induct [consumes 1, case_names base step, induct pred: tranclp]: | 
| 63404 | 443 | assumes a: "r\<^sup>+\<^sup>+ a b" | 
| 444 | and cases: "\<And>y. r a y \<Longrightarrow> P y" "\<And>y z. r\<^sup>+\<^sup>+ a y \<Longrightarrow> r y z \<Longrightarrow> P y \<Longrightarrow> P z" | |
| 445 | shows "P b" | |
| 446 | using a by (induct x\<equiv>a b) (iprover intro: cases)+ | |
| 12691 | 447 | |
| 25425 
9191942c4ead
Removed some case_names and consumes attributes that are now no longer
 berghofe parents: 
25295diff
changeset | 448 | lemmas trancl_induct [induct set: trancl] = tranclp_induct [to_set] | 
| 22262 | 449 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 450 | lemmas tranclp_induct2 = | 
| 63612 | 451 | tranclp_induct [of _ "(ax, ay)" "(bx, by)", split_rule, consumes 1, case_names base step] | 
| 22262 | 452 | |
| 22172 | 453 | lemmas trancl_induct2 = | 
| 63612 | 454 | trancl_induct [of "(ax, ay)" "(bx, by)", split_format (complete), | 
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 455 | consumes 1, case_names base step] | 
| 22172 | 456 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 457 | lemma tranclp_trans_induct: | 
| 63404 | 458 | assumes major: "r\<^sup>+\<^sup>+ x y" | 
| 459 | and cases: "\<And>x y. r x y \<Longrightarrow> P x y" "\<And>x y z. r\<^sup>+\<^sup>+ x y \<Longrightarrow> P x y \<Longrightarrow> r\<^sup>+\<^sup>+ y z \<Longrightarrow> P y z \<Longrightarrow> P x z" | |
| 18372 | 460 | shows "P x y" | 
| 61799 | 461 | \<comment> \<open>Another induction rule for trancl, incorporating transitivity\<close> | 
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 462 | by (iprover intro: major [THEN tranclp_induct] cases) | 
| 12691 | 463 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 464 | lemmas trancl_trans_induct = tranclp_trans_induct [to_set] | 
| 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 465 | |
| 26174 
9efd4c04eaa4
rtranclE, tranclE: tuned statement, added case_names;
 wenzelm parents: 
25425diff
changeset | 466 | lemma tranclE [cases set: trancl]: | 
| 63404 | 467 | assumes "(a, b) \<in> r\<^sup>+" | 
| 26174 
9efd4c04eaa4
rtranclE, tranclE: tuned statement, added case_names;
 wenzelm parents: 
25425diff
changeset | 468 | obtains | 
| 63404 | 469 | (base) "(a, b) \<in> r" | 
| 470 | | (step) c where "(a, c) \<in> r\<^sup>+" and "(c, b) \<in> r" | |
| 26174 
9efd4c04eaa4
rtranclE, tranclE: tuned statement, added case_names;
 wenzelm parents: 
25425diff
changeset | 471 | using assms by cases simp_all | 
| 10980 | 472 | |
| 63404 | 473 | lemma trancl_Int_subset: "r \<subseteq> s \<Longrightarrow> (r\<^sup>+ \<inter> s) O r \<subseteq> s \<Longrightarrow> r\<^sup>+ \<subseteq> s" | 
| 71627 | 474 | by (fastforce simp add: elim: trancl_induct) | 
| 22080 
7bf8868ab3e4
induction rules for trancl/rtrancl expressed using subsets
 paulson parents: 
21589diff
changeset | 475 | |
| 63404 | 476 | lemma trancl_unfold: "r\<^sup>+ = r \<union> r\<^sup>+ O r" | 
| 15551 | 477 | by (auto intro: trancl_into_trancl elim: tranclE) | 
| 478 | ||
| 69593 | 479 | text \<open>Transitivity of \<^term>\<open>r\<^sup>+\<close>\<close> | 
| 63404 | 480 | lemma trans_trancl [simp]: "trans (r\<^sup>+)" | 
| 13704 
854501b1e957
Transitive closure is now defined inductively as well.
 berghofe parents: 
12937diff
changeset | 481 | proof (rule transI) | 
| 
854501b1e957
Transitive closure is now defined inductively as well.
 berghofe parents: 
12937diff
changeset | 482 | fix x y z | 
| 63404 | 483 | assume "(x, y) \<in> r\<^sup>+" | 
| 484 | assume "(y, z) \<in> r\<^sup>+" | |
| 485 | then show "(x, z) \<in> r\<^sup>+" | |
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 486 | proof induct | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 487 | case (base u) | 
| 63404 | 488 | from \<open>(x, y) \<in> r\<^sup>+\<close> and \<open>(y, u) \<in> r\<close> | 
| 489 | show "(x, u) \<in> r\<^sup>+" .. | |
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 490 | next | 
| 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 491 | case (step u v) | 
| 63404 | 492 | from \<open>(x, u) \<in> r\<^sup>+\<close> and \<open>(u, v) \<in> r\<close> | 
| 493 | show "(x, v) \<in> r\<^sup>+" .. | |
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 494 | qed | 
| 13704 
854501b1e957
Transitive closure is now defined inductively as well.
 berghofe parents: 
12937diff
changeset | 495 | qed | 
| 12691 | 496 | |
| 45607 | 497 | lemmas trancl_trans = trans_trancl [THEN transD] | 
| 12691 | 498 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 499 | lemma tranclp_trans: | 
| 63404 | 500 | assumes "r\<^sup>+\<^sup>+ x y" | 
| 501 | and "r\<^sup>+\<^sup>+ y z" | |
| 502 | shows "r\<^sup>+\<^sup>+ x z" | |
| 503 | using assms(2,1) by induct iprover+ | |
| 22262 | 504 | |
| 63404 | 505 | lemma trancl_id [simp]: "trans r \<Longrightarrow> r\<^sup>+ = r" | 
| 71627 | 506 | unfolding trans_def by (fastforce simp add: elim: trancl_induct) | 
| 19623 | 507 | |
| 26179 
bc5d582d6cfe
rtranclp_induct, tranclp_induct: added case_names;
 wenzelm parents: 
26174diff
changeset | 508 | lemma rtranclp_tranclp_tranclp: | 
| 63404 | 509 | assumes "r\<^sup>*\<^sup>* x y" | 
| 510 | shows "\<And>z. r\<^sup>+\<^sup>+ y z \<Longrightarrow> r\<^sup>+\<^sup>+ x z" | |
| 511 | using assms by induct (iprover intro: tranclp_trans)+ | |
| 12691 | 512 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 513 | lemmas rtrancl_trancl_trancl = rtranclp_tranclp_tranclp [to_set] | 
| 22262 | 514 | |
| 63404 | 515 | lemma tranclp_into_tranclp2: "r a b \<Longrightarrow> r\<^sup>+\<^sup>+ b c \<Longrightarrow> r\<^sup>+\<^sup>+ a c" | 
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 516 | by (erule tranclp_trans [OF tranclp.r_into_trancl]) | 
| 22262 | 517 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 518 | lemmas trancl_into_trancl2 = tranclp_into_tranclp2 [to_set] | 
| 12691 | 519 | |
| 71627 | 520 | lemma tranclp_converseI: | 
| 521 | assumes "(r\<^sup>+\<^sup>+)\<inverse>\<inverse> x y" shows "(r\<inverse>\<inverse>)\<^sup>+\<^sup>+ x y" | |
| 522 | using conversepD [OF assms] | |
| 523 | proof (induction rule: tranclp_induct) | |
| 524 | case (base y) | |
| 525 | then show ?case | |
| 526 | by (iprover intro: conversepI) | |
| 527 | next | |
| 528 | case (step y z) | |
| 529 | then show ?case | |
| 530 | by (iprover intro: conversepI tranclp_trans) | |
| 531 | qed | |
| 12691 | 532 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 533 | lemmas trancl_converseI = tranclp_converseI [to_set] | 
| 22262 | 534 | |
| 71627 | 535 | lemma tranclp_converseD: | 
| 536 | assumes "(r\<inverse>\<inverse>)\<^sup>+\<^sup>+ x y" shows "(r\<^sup>+\<^sup>+)\<inverse>\<inverse> x y" | |
| 537 | proof - | |
| 538 | have "r\<^sup>+\<^sup>+ y x" | |
| 539 | using assms | |
| 540 | by (induction rule: tranclp_induct) (iprover dest: conversepD intro: tranclp_trans)+ | |
| 541 | then show ?thesis | |
| 542 | by (rule conversepI) | |
| 543 | qed | |
| 12691 | 544 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 545 | lemmas trancl_converseD = tranclp_converseD [to_set] | 
| 22262 | 546 | |
| 63404 | 547 | lemma tranclp_converse: "(r\<inverse>\<inverse>)\<^sup>+\<^sup>+ = (r\<^sup>+\<^sup>+)\<inverse>\<inverse>" | 
| 548 | by (fastforce simp add: fun_eq_iff intro!: tranclp_converseI dest!: tranclp_converseD) | |
| 22262 | 549 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 550 | lemmas trancl_converse = tranclp_converse [to_set] | 
| 12691 | 551 | |
| 63404 | 552 | lemma sym_trancl: "sym r \<Longrightarrow> sym (r\<^sup>+)" | 
| 19228 | 553 | by (simp only: sym_conv_converse_eq trancl_converse [symmetric]) | 
| 554 | ||
| 34909 
a799687944af
Tuned some proofs; nicer case names for some of the induction / cases rules.
 berghofe parents: 
33878diff
changeset | 555 | lemma converse_tranclp_induct [consumes 1, case_names base step]: | 
| 63404 | 556 | assumes major: "r\<^sup>+\<^sup>+ a b" | 
| 557 | and cases: "\<And>y. r y b \<Longrightarrow> P y" "\<And>y z. r y z \<Longrightarrow> r\<^sup>+\<^sup>+ z b \<Longrightarrow> P z \<Longrightarrow> P y" | |
| 18372 | 558 | shows "P a" | 
| 71627 | 559 | proof - | 
| 560 | have "r\<inverse>\<inverse>\<^sup>+\<^sup>+ b a" | |
| 561 | by (intro tranclp_converseI conversepI major) | |
| 562 | then show ?thesis | |
| 563 | by (induction rule: tranclp_induct) (blast intro: cases dest: tranclp_converseD)+ | |
| 564 | qed | |
| 12691 | 565 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 566 | lemmas converse_trancl_induct = converse_tranclp_induct [to_set] | 
| 22262 | 567 | |
| 63404 | 568 | lemma tranclpD: "R\<^sup>+\<^sup>+ x y \<Longrightarrow> \<exists>z. R x z \<and> R\<^sup>*\<^sup>* z y" | 
| 71627 | 569 | proof (induction rule: converse_tranclp_induct) | 
| 570 | case (step u v) | |
| 571 | then show ?case | |
| 572 | by (blast intro: rtranclp_trans) | |
| 573 | qed auto | |
| 12691 | 574 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 575 | lemmas tranclD = tranclpD [to_set] | 
| 22262 | 576 | |
| 31577 | 577 | lemma converse_tranclpE: | 
| 578 | assumes major: "tranclp r x z" | |
| 63404 | 579 | and base: "r x z \<Longrightarrow> P" | 
| 63612 | 580 | and step: "\<And>y. r x y \<Longrightarrow> tranclp r y z \<Longrightarrow> P" | 
| 31577 | 581 | shows P | 
| 582 | proof - | |
| 63404 | 583 | from tranclpD [OF major] obtain y where "r x y" and "rtranclp r y z" | 
| 584 | by iprover | |
| 31577 | 585 | from this(2) show P | 
| 586 | proof (cases rule: rtranclp.cases) | |
| 587 | case rtrancl_refl | |
| 63404 | 588 | with \<open>r x y\<close> base show P | 
| 589 | by iprover | |
| 31577 | 590 | next | 
| 591 | case rtrancl_into_rtrancl | |
| 71627 | 592 | then have "tranclp r y z" | 
| 31577 | 593 | by (iprover intro: rtranclp_into_tranclp1) | 
| 63404 | 594 | with \<open>r x y\<close> step show P | 
| 595 | by iprover | |
| 31577 | 596 | qed | 
| 597 | qed | |
| 598 | ||
| 599 | lemmas converse_tranclE = converse_tranclpE [to_set] | |
| 600 | ||
| 63404 | 601 | lemma tranclD2: "(x, y) \<in> R\<^sup>+ \<Longrightarrow> \<exists>z. (x, z) \<in> R\<^sup>* \<and> (z, y) \<in> R" | 
| 25295 
12985023be5e
tranclD2 (tranclD at the other end) + trancl_power
 kleing parents: 
23743diff
changeset | 602 | by (blast elim: tranclE intro: trancl_into_rtrancl) | 
| 
12985023be5e
tranclD2 (tranclD at the other end) + trancl_power
 kleing parents: 
23743diff
changeset | 603 | |
| 63404 | 604 | lemma irrefl_tranclI: "r\<inverse> \<inter> r\<^sup>* = {} \<Longrightarrow> (x, x) \<notin> r\<^sup>+"
 | 
| 18372 | 605 | by (blast elim: tranclE dest: trancl_into_rtrancl) | 
| 12691 | 606 | |
| 63404 | 607 | lemma irrefl_trancl_rD: "\<forall>x. (x, x) \<notin> r\<^sup>+ \<Longrightarrow> (x, y) \<in> r \<Longrightarrow> x \<noteq> y" | 
| 12691 | 608 | by (blast dest: r_into_trancl) | 
| 609 | ||
| 63404 | 610 | lemma trancl_subset_Sigma_aux: "(a, b) \<in> r\<^sup>* \<Longrightarrow> r \<subseteq> A \<times> A \<Longrightarrow> a = b \<or> a \<in> A" | 
| 18372 | 611 | by (induct rule: rtrancl_induct) auto | 
| 12691 | 612 | |
| 71627 | 613 | lemma trancl_subset_Sigma: | 
| 614 | assumes "r \<subseteq> A \<times> A" shows "r\<^sup>+ \<subseteq> A \<times> A" | |
| 615 | proof (rule trancl_Int_subset [OF assms]) | |
| 616 | show "(r\<^sup>+ \<inter> A \<times> A) O r \<subseteq> A \<times> A" | |
| 617 | using assms by auto | |
| 618 | qed | |
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 619 | |
| 63404 | 620 | lemma reflclp_tranclp [simp]: "(r\<^sup>+\<^sup>+)\<^sup>=\<^sup>= = r\<^sup>*\<^sup>*" | 
| 71627 | 621 | by (fast elim: rtranclp.cases tranclp_into_rtranclp dest: rtranclp_into_tranclp1) | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 622 | |
| 50616 | 623 | lemmas reflcl_trancl [simp] = reflclp_tranclp [to_set] | 
| 22262 | 624 | |
| 63404 | 625 | lemma trancl_reflcl [simp]: "(r\<^sup>=)\<^sup>+ = r\<^sup>*" | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 626 | proof - | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 627 | have "(a, b) \<in> (r\<^sup>=)\<^sup>+ \<Longrightarrow> (a, b) \<in> r\<^sup>*" for a b | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 628 | by (force dest: trancl_into_rtrancl) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 629 | moreover have "(a, b) \<in> (r\<^sup>=)\<^sup>+" if "(a, b) \<in> r\<^sup>*" for a b | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 630 | using that | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 631 | proof (cases a b rule: rtranclE) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 632 | case step | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 633 | show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 634 | by (rule rtrancl_into_trancl1) (use step in auto) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 635 | qed auto | 
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 636 | ultimately show ?thesis | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 637 | by auto | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 638 | qed | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 639 | |
| 63404 | 640 | lemma rtrancl_trancl_reflcl [code]: "r\<^sup>* = (r\<^sup>+)\<^sup>=" | 
| 45140 | 641 | by simp | 
| 642 | ||
| 63404 | 643 | lemma trancl_empty [simp]: "{}\<^sup>+ = {}"
 | 
| 11084 | 644 | by (auto elim: trancl_induct) | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 645 | |
| 63404 | 646 | lemma rtrancl_empty [simp]: "{}\<^sup>* = Id"
 | 
| 11084 | 647 | by (rule subst [OF reflcl_trancl]) simp | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 648 | |
| 63404 | 649 | lemma rtranclpD: "R\<^sup>*\<^sup>* a b \<Longrightarrow> a = b \<or> a \<noteq> b \<and> R\<^sup>+\<^sup>+ a b" | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 650 | by (force simp: reflclp_tranclp [symmetric] simp del: reflclp_tranclp) | 
| 22262 | 651 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 652 | lemmas rtranclD = rtranclpD [to_set] | 
| 11084 | 653 | |
| 63404 | 654 | lemma rtrancl_eq_or_trancl: "(x,y) \<in> R\<^sup>* \<longleftrightarrow> x = y \<or> x \<noteq> y \<and> (x, y) \<in> R\<^sup>+" | 
| 16514 | 655 | by (fast elim: trancl_into_rtrancl dest: rtranclD) | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 656 | |
| 63404 | 657 | lemma trancl_unfold_right: "r\<^sup>+ = r\<^sup>* O r" | 
| 658 | by (auto dest: tranclD2 intro: rtrancl_into_trancl1) | |
| 33656 
fc1af6753233
a few lemmas for point-free reasoning about transitive closure
 krauss parents: 
32901diff
changeset | 659 | |
| 63404 | 660 | lemma trancl_unfold_left: "r\<^sup>+ = r O r\<^sup>*" | 
| 661 | by (auto dest: tranclD intro: rtrancl_into_trancl2) | |
| 33656 
fc1af6753233
a few lemmas for point-free reasoning about transitive closure
 krauss parents: 
32901diff
changeset | 662 | |
| 63404 | 663 | lemma trancl_insert: "(insert (y, x) r)\<^sup>+ = r\<^sup>+ \<union> {(a, b). (a, y) \<in> r\<^sup>* \<and> (x, b) \<in> r\<^sup>*}"
 | 
| 61799 | 664 | \<comment> \<open>primitive recursion for \<open>trancl\<close> over finite relations\<close> | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 665 | proof - | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 666 | have "\<And>a b. (a, b) \<in> (insert (y, x) r)\<^sup>+ \<Longrightarrow> | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 667 |            (a, b) \<in> r\<^sup>+ \<union> {(a, b). (a, y) \<in> r\<^sup>* \<and> (x, b) \<in> r\<^sup>*}"
 | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 668 | by (erule trancl_induct) (blast intro: rtrancl_into_trancl1 trancl_into_rtrancl trancl_trans)+ | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 669 |   moreover have "r\<^sup>+ \<union> {(a, b). (a, y) \<in> r\<^sup>* \<and> (x, b) \<in> r\<^sup>*}  \<subseteq> (insert (y, x) r)\<^sup>+"
 | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 670 | by (blast intro: trancl_mono rtrancl_mono [THEN [2] rev_subsetD] | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 671 | rtrancl_trancl_trancl rtrancl_into_trancl2) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 672 | ultimately show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 673 | by auto | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 674 | qed | 
| 57178 | 675 | |
| 676 | lemma trancl_insert2: | |
| 63404 | 677 |   "(insert (a, b) r)\<^sup>+ = r\<^sup>+ \<union> {(x, y). ((x, a) \<in> r\<^sup>+ \<or> x = a) \<and> ((b, y) \<in> r\<^sup>+ \<or> y = b)}"
 | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 678 | by (auto simp: trancl_insert rtrancl_eq_or_trancl) | 
| 57178 | 679 | |
| 63404 | 680 | lemma rtrancl_insert: "(insert (a,b) r)\<^sup>* = r\<^sup>* \<union> {(x, y). (x, a) \<in> r\<^sup>* \<and> (b, y) \<in> r\<^sup>*}"
 | 
| 681 | using trancl_insert[of a b r] | |
| 682 | by (simp add: rtrancl_trancl_reflcl del: reflcl_trancl) blast | |
| 57178 | 683 | |
| 33656 
fc1af6753233
a few lemmas for point-free reasoning about transitive closure
 krauss parents: 
32901diff
changeset | 684 | |
| 60758 | 685 | text \<open>Simplifying nested closures\<close> | 
| 33656 
fc1af6753233
a few lemmas for point-free reasoning about transitive closure
 krauss parents: 
32901diff
changeset | 686 | |
| 63404 | 687 | lemma rtrancl_trancl_absorb[simp]: "(R\<^sup>*)\<^sup>+ = R\<^sup>*" | 
| 688 | by (simp add: trans_rtrancl) | |
| 33656 
fc1af6753233
a few lemmas for point-free reasoning about transitive closure
 krauss parents: 
32901diff
changeset | 689 | |
| 63404 | 690 | lemma trancl_rtrancl_absorb[simp]: "(R\<^sup>+)\<^sup>* = R\<^sup>*" | 
| 691 | by (subst reflcl_trancl[symmetric]) simp | |
| 33656 
fc1af6753233
a few lemmas for point-free reasoning about transitive closure
 krauss parents: 
32901diff
changeset | 692 | |
| 63404 | 693 | lemma rtrancl_reflcl_absorb[simp]: "(R\<^sup>*)\<^sup>= = R\<^sup>*" | 
| 694 | by auto | |
| 33656 
fc1af6753233
a few lemmas for point-free reasoning about transitive closure
 krauss parents: 
32901diff
changeset | 695 | |
| 
fc1af6753233
a few lemmas for point-free reasoning about transitive closure
 krauss parents: 
32901diff
changeset | 696 | |
| 61799 | 697 | text \<open>\<open>Domain\<close> and \<open>Range\<close>\<close> | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 698 | |
| 63404 | 699 | lemma Domain_rtrancl [simp]: "Domain (R\<^sup>*) = UNIV" | 
| 11084 | 700 | by blast | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 701 | |
| 63404 | 702 | lemma Range_rtrancl [simp]: "Range (R\<^sup>*) = UNIV" | 
| 11084 | 703 | by blast | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 704 | |
| 63404 | 705 | lemma rtrancl_Un_subset: "(R\<^sup>* \<union> S\<^sup>*) \<subseteq> (R \<union> S)\<^sup>*" | 
| 11084 | 706 | by (rule rtrancl_Un_rtrancl [THEN subst]) fast | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 707 | |
| 63404 | 708 | lemma in_rtrancl_UnI: "x \<in> R\<^sup>* \<or> x \<in> S\<^sup>* \<Longrightarrow> x \<in> (R \<union> S)\<^sup>*" | 
| 11084 | 709 | by (blast intro: subsetD [OF rtrancl_Un_subset]) | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 710 | |
| 63404 | 711 | lemma trancl_domain [simp]: "Domain (r\<^sup>+) = Domain r" | 
| 46752 
e9e7209eb375
more fundamental pred-to-set conversions, particularly by means of inductive_set; associated consolidation of some theorem names (c.f. NEWS)
 haftmann parents: 
46664diff
changeset | 712 | by (unfold Domain_unfold) (blast dest: tranclD) | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 713 | |
| 63404 | 714 | lemma trancl_range [simp]: "Range (r\<^sup>+) = Range r" | 
| 46752 
e9e7209eb375
more fundamental pred-to-set conversions, particularly by means of inductive_set; associated consolidation of some theorem names (c.f. NEWS)
 haftmann parents: 
46664diff
changeset | 715 | unfolding Domain_converse [symmetric] by (simp add: trancl_converse [symmetric]) | 
| 10996 
74e970389def
Moved some thms from Transitive_ClosureTr.ML to Transitive_Closure.thy
 nipkow parents: 
10980diff
changeset | 716 | |
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 717 | lemma Not_Domain_rtrancl: | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 718 | assumes "x \<notin> Domain R" shows "(x, y) \<in> R\<^sup>* \<longleftrightarrow> x = y" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 719 | proof - | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 720 | have "(x, y) \<in> R\<^sup>* \<Longrightarrow> x = y" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 721 | by (erule rtrancl_induct) (use assms in auto) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 722 | then show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 723 | by auto | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 724 | qed | 
| 11327 
cd2c27a23df1
Transitive closure is now defined via "inductive".
 berghofe parents: 
11115diff
changeset | 725 | |
| 63404 | 726 | lemma trancl_subset_Field2: "r\<^sup>+ \<subseteq> Field r \<times> Field r" | 
| 71627 | 727 | by (rule trancl_Int_subset) (auto simp: Field_def) | 
| 29609 | 728 | |
| 63404 | 729 | lemma finite_trancl[simp]: "finite (r\<^sup>+) = finite r" | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 730 | proof | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 731 | show "finite (r\<^sup>+) \<Longrightarrow> finite r" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 732 | by (blast intro: r_into_trancl' finite_subset) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 733 | show "finite r \<Longrightarrow> finite (r\<^sup>+)" | 
| 71627 | 734 | by (auto simp: finite_Field trancl_subset_Field2 [THEN finite_subset]) | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 735 | qed | 
| 29609 | 736 | |
| 68456 | 737 | lemma finite_rtrancl_Image[simp]: assumes "finite R" "finite A" shows "finite (R\<^sup>* `` A)" | 
| 68455 | 738 | proof (rule ccontr) | 
| 739 | assume "infinite (R\<^sup>* `` A)" | |
| 740 | with assms show False | |
| 741 | by(simp add: rtrancl_trancl_reflcl Un_Image del: reflcl_trancl) | |
| 742 | qed | |
| 743 | ||
| 61799 | 744 | text \<open>More about converse \<open>rtrancl\<close> and \<open>trancl\<close>, should | 
| 60758 | 745 | be merged with main body.\<close> | 
| 12428 
f3033eed309a
setup [trans] rules for calculational Isar reasoning
 kleing parents: 
11327diff
changeset | 746 | |
| 14337 
e13731554e50
undid split_comp_eq[simp] because it leads to nontermination together with split_def!
 nipkow parents: 
14208diff
changeset | 747 | lemma single_valued_confluent: | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 748 | assumes "single_valued r" and xy: "(x, y) \<in> r\<^sup>*" and xz: "(x, z) \<in> r\<^sup>*" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 749 | shows "(y, z) \<in> r\<^sup>* \<or> (z, y) \<in> r\<^sup>*" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 750 | using xy | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 751 | proof (induction rule: rtrancl_induct) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 752 | case base | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 753 | show ?case | 
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 754 | by (simp add: assms) | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 755 | next | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 756 | case (step y z) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 757 | with xz \<open>single_valued r\<close> show ?case | 
| 71627 | 758 | by (auto elim: converse_rtranclE dest: single_valuedD intro: rtrancl_trans) | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 759 | qed | 
| 14337 
e13731554e50
undid split_comp_eq[simp] because it leads to nontermination together with split_def!
 nipkow parents: 
14208diff
changeset | 760 | |
| 63404 | 761 | lemma r_r_into_trancl: "(a, b) \<in> R \<Longrightarrow> (b, c) \<in> R \<Longrightarrow> (a, c) \<in> R\<^sup>+" | 
| 12428 
f3033eed309a
setup [trans] rules for calculational Isar reasoning
 kleing parents: 
11327diff
changeset | 762 | by (fast intro: trancl_trans) | 
| 
f3033eed309a
setup [trans] rules for calculational Isar reasoning
 kleing parents: 
11327diff
changeset | 763 | |
| 63404 | 764 | lemma trancl_into_trancl: "(a, b) \<in> r\<^sup>+ \<Longrightarrow> (b, c) \<in> r \<Longrightarrow> (a, c) \<in> r\<^sup>+" | 
| 63612 | 765 | by (induct rule: trancl_induct) (fast intro: r_r_into_trancl trancl_trans)+ | 
| 12428 
f3033eed309a
setup [trans] rules for calculational Isar reasoning
 kleing parents: 
11327diff
changeset | 766 | |
| 71627 | 767 | lemma tranclp_rtranclp_tranclp: | 
| 768 | assumes "r\<^sup>+\<^sup>+ a b" "r\<^sup>*\<^sup>* b c" shows "r\<^sup>+\<^sup>+ a c" | |
| 769 | proof - | |
| 770 | obtain z where "r a z" "r\<^sup>*\<^sup>* z c" | |
| 771 | using assms by (iprover dest: tranclpD rtranclp_trans) | |
| 772 | then show ?thesis | |
| 773 | by (blast dest: rtranclp_into_tranclp2) | |
| 774 | qed | |
| 12428 
f3033eed309a
setup [trans] rules for calculational Isar reasoning
 kleing parents: 
11327diff
changeset | 775 | |
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 776 | lemma rtranclp_conversep: "r\<inverse>\<inverse>\<^sup>*\<^sup>* = r\<^sup>*\<^sup>*\<inverse>\<inverse>" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 777 | by(auto simp add: fun_eq_iff intro: rtranclp_converseI rtranclp_converseD) | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 778 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 779 | lemmas symp_rtranclp = sym_rtrancl[to_pred] | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 780 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 781 | lemmas symp_conv_conversep_eq = sym_conv_converse_eq[to_pred] | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 782 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 783 | lemmas rtranclp_tranclp_absorb [simp] = rtrancl_trancl_absorb[to_pred] | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 784 | lemmas tranclp_rtranclp_absorb [simp] = trancl_rtrancl_absorb[to_pred] | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 785 | lemmas rtranclp_reflclp_absorb [simp] = rtrancl_reflcl_absorb[to_pred] | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 786 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 787 | lemmas trancl_rtrancl_trancl = tranclp_rtranclp_tranclp [to_set] | 
| 22262 | 788 | |
| 12691 | 789 | lemmas transitive_closure_trans [trans] = | 
| 790 | r_r_into_trancl trancl_trans rtrancl_trans | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 791 | trancl.trancl_into_trancl trancl_into_trancl2 | 
| 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 792 | rtrancl.rtrancl_into_rtrancl converse_rtrancl_into_rtrancl | 
| 12691 | 793 | rtrancl_trancl_trancl trancl_rtrancl_trancl | 
| 12428 
f3033eed309a
setup [trans] rules for calculational Isar reasoning
 kleing parents: 
11327diff
changeset | 794 | |
| 23743 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 795 | lemmas transitive_closurep_trans' [trans] = | 
| 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 796 | tranclp_trans rtranclp_trans | 
| 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 797 | tranclp.trancl_into_trancl tranclp_into_tranclp2 | 
| 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 798 | rtranclp.rtrancl_into_rtrancl converse_rtranclp_into_rtranclp | 
| 
52fbc991039f
rtrancl and trancl are now defined using inductive_set.
 berghofe parents: 
22422diff
changeset | 799 | rtranclp_tranclp_tranclp tranclp_rtranclp_tranclp | 
| 22262 | 800 | |
| 12428 
f3033eed309a
setup [trans] rules for calculational Isar reasoning
 kleing parents: 
11327diff
changeset | 801 | declare trancl_into_rtrancl [elim] | 
| 11327 
cd2c27a23df1
Transitive closure is now defined via "inductive".
 berghofe parents: 
11115diff
changeset | 802 | |
| 79773 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 803 | lemma tranclp_ident_if_transp: | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 804 | assumes "transp R" | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 805 | shows "R\<^sup>+\<^sup>+ = R" | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 806 | proof (intro ext iffI) | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 807 | fix x y | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 808 | show "R\<^sup>+\<^sup>+ x y \<Longrightarrow> R x y" | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 809 | proof (induction y rule: tranclp_induct) | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 810 | case (base y) | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 811 | thus ?case | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 812 | by simp | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 813 | next | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 814 | case (step y z) | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 815 | thus ?case | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 816 | using \<open>transp R\<close>[THEN transpD, of x y z] by simp | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 817 | qed | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 818 | next | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 819 | fix x y | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 820 | show "R x y \<Longrightarrow> R\<^sup>+\<^sup>+ x y" | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 821 | using tranclp.r_into_trancl . | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 822 | qed | 
| 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 823 | |
| 79806 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 824 | text \<open>The following are special cases of @{thm [source] tranclp_ident_if_transp},
 | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 825 | but they appear duplicated in multiple, independent theories, which causes name clashes.\<close> | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 826 | |
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 827 | lemma (in preorder) tranclp_less[simp]: "(<)\<^sup>+\<^sup>+ = (<)" | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 828 | using transp_on_less by (simp only: tranclp_ident_if_transp) | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 829 | |
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 830 | lemma (in preorder) tranclp_less_eq[simp]: "(\<le>)\<^sup>+\<^sup>+ = (\<le>)" | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 831 | using transp_on_le by (simp only: tranclp_ident_if_transp) | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 832 | |
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 833 | lemma (in preorder) tranclp_greater[simp]: "(>)\<^sup>+\<^sup>+ = (>)" | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 834 | using transp_on_greater by (simp only: tranclp_ident_if_transp) | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 835 | |
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 836 | lemma (in preorder) tranclp_greater_eq[simp]: "(\<ge>)\<^sup>+\<^sup>+ = (\<ge>)" | 
| 
ba8fb71587ae
added lemmas reflclp_(less|greater)_eq[simp], rtranclp_(less|greater)_eq[simp], and tranclp_(less|greater|less_eq|greater_eq)[simp]
 desharna parents: 
79773diff
changeset | 837 | using transp_on_ge by (simp only: tranclp_ident_if_transp) | 
| 79773 
0e8620af9c91
added lemmas rtranclp_ident_if_reflp_and_transp and tranclp_ident_if_transp
 desharna parents: 
79668diff
changeset | 838 | |
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 839 | subsection \<open>Symmetric closure\<close> | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 840 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 841 | definition symclp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a \<Rightarrow> 'a \<Rightarrow> bool"
 | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 842 | where "symclp r x y \<longleftrightarrow> r x y \<or> r y x" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 843 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 844 | lemma symclpI [simp, intro?]: | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 845 | shows symclpI1: "r x y \<Longrightarrow> symclp r x y" | 
| 71627 | 846 | and symclpI2: "r y x \<Longrightarrow> symclp r x y" | 
| 847 | by(simp_all add: symclp_def) | |
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 848 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 849 | lemma symclpE [consumes 1, cases pred]: | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 850 | assumes "symclp r x y" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 851 | obtains (base) "r x y" | (sym) "r y x" | 
| 71627 | 852 | using assms by(auto simp add: symclp_def) | 
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 853 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 854 | lemma symclp_pointfree: "symclp r = sup r r\<inverse>\<inverse>" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 855 | by(auto simp add: symclp_def fun_eq_iff) | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 856 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 857 | lemma symclp_greater: "r \<le> symclp r" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 858 | by(simp add: symclp_pointfree) | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 859 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 860 | lemma symclp_conversep [simp]: "symclp r\<inverse>\<inverse> = symclp r" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 861 | by(simp add: symclp_pointfree sup.commute) | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 862 | |
| 76675 | 863 | lemma symp_on_symclp [simp]: "symp_on A (symclp R)" | 
| 864 | by(auto simp add: symp_on_def elim: symclpE intro: symclpI) | |
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 865 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 866 | lemma symp_symclp_eq: "symp r \<Longrightarrow> symclp r = r" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 867 | by(simp add: symclp_pointfree symp_conv_conversep_eq) | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 868 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 869 | lemma symp_rtranclp_symclp [simp]: "symp (symclp r)\<^sup>*\<^sup>*" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 870 | by(simp add: symp_rtranclp) | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 871 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 872 | lemma rtranclp_symclp_sym [sym]: "(symclp r)\<^sup>*\<^sup>* x y \<Longrightarrow> (symclp r)\<^sup>*\<^sup>* y x" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 873 | by(rule sympD[OF symp_rtranclp_symclp]) | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 874 | |
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 875 | lemma symclp_idem [simp]: "symclp (symclp r) = symclp r" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 876 | by(simp add: symclp_pointfree sup_commute converse_join) | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 877 | |
| 76495 
a718547c3493
strengthened lemma reflp_rtranclp and renamed to reflp_on_rtranclp
 desharna parents: 
75669diff
changeset | 878 | lemma reflp_on_rtranclp [simp]: "reflp_on A R\<^sup>*\<^sup>*" | 
| 
a718547c3493
strengthened lemma reflp_rtranclp and renamed to reflp_on_rtranclp
 desharna parents: 
75669diff
changeset | 879 | by (simp add: reflp_on_def) | 
| 
a718547c3493
strengthened lemma reflp_rtranclp and renamed to reflp_on_rtranclp
 desharna parents: 
75669diff
changeset | 880 | |
| 63404 | 881 | |
| 60758 | 882 | subsection \<open>The power operation on relations\<close> | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 883 | |
| 63404 | 884 | text \<open>\<open>R ^^ n = R O \<dots> O R\<close>, the n-fold composition of \<open>R\<close>\<close> | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 885 | |
| 30971 | 886 | overloading | 
| 63404 | 887 |   relpow \<equiv> "compow :: nat \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set"
 | 
| 888 |   relpowp \<equiv> "compow :: nat \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool)"
 | |
| 30971 | 889 | begin | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 890 | |
| 63404 | 891 | primrec relpow :: "nat \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set"
 | 
| 63612 | 892 | where | 
| 893 | "relpow 0 R = Id" | |
| 894 | | "relpow (Suc n) R = (R ^^ n) O R" | |
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 895 | |
| 63404 | 896 | primrec relpowp :: "nat \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool)"
 | 
| 63612 | 897 | where | 
| 898 | "relpowp 0 R = HOL.eq" | |
| 899 | | "relpowp (Suc n) R = (R ^^ n) OO R" | |
| 47202 | 900 | |
| 30971 | 901 | end | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 902 | |
| 47202 | 903 | lemma relpowp_relpow_eq [pred_set_conv]: | 
| 63404 | 904 | "(\<lambda>x y. (x, y) \<in> R) ^^ n = (\<lambda>x y. (x, y) \<in> R ^^ n)" for R :: "'a rel" | 
| 47433 
07f4bf913230
renamed "rel_comp" to "relcomp" (to be consistent with, e.g., "relpow")
 griff parents: 
47202diff
changeset | 905 | by (induct n) (simp_all add: relcompp_relcomp_eq) | 
| 47202 | 906 | |
| 63404 | 907 | text \<open>For code generation:\<close> | 
| 46360 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 908 | |
| 63404 | 909 | definition relpow :: "nat \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set"
 | 
| 910 | where relpow_code_def [code_abbrev]: "relpow = compow" | |
| 46360 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 911 | |
| 63404 | 912 | definition relpowp :: "nat \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool)"
 | 
| 913 | where relpowp_code_def [code_abbrev]: "relpowp = compow" | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 914 | |
| 46360 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 915 | lemma [code]: | 
| 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 916 | "relpow (Suc n) R = (relpow n R) O R" | 
| 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 917 | "relpow 0 R = Id" | 
| 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 918 | by (simp_all add: relpow_code_def) | 
| 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 919 | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 920 | lemma [code]: | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 921 | "relpowp (Suc n) R = (R ^^ n) OO R" | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 922 | "relpowp 0 R = HOL.eq" | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 923 | by (simp_all add: relpowp_code_def) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 924 | |
| 46360 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 925 | hide_const (open) relpow | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 926 | hide_const (open) relpowp | 
| 46360 
5cb81e3fa799
adding code generation for relpow by copying the ideas for code generation of funpow
 bulwahn parents: 
46347diff
changeset | 927 | |
| 63612 | 928 | lemma relpow_1 [simp]: "R ^^ 1 = R" | 
| 929 |   for R :: "('a \<times> 'a) set"
 | |
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 930 | by simp | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 931 | |
| 63612 | 932 | lemma relpowp_1 [simp]: "P ^^ 1 = P" | 
| 933 | for P :: "'a \<Rightarrow> 'a \<Rightarrow> bool" | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 934 | by (fact relpow_1 [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 935 | |
| 63404 | 936 | lemma relpow_0_I: "(x, x) \<in> R ^^ 0" | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 937 | by simp | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 938 | |
| 63404 | 939 | lemma relpowp_0_I: "(P ^^ 0) x x" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 940 | by (fact relpow_0_I [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 941 | |
| 63404 | 942 | lemma relpow_Suc_I: "(x, y) \<in> R ^^ n \<Longrightarrow> (y, z) \<in> R \<Longrightarrow> (x, z) \<in> R ^^ Suc n" | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 943 | by auto | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 944 | |
| 63404 | 945 | lemma relpowp_Suc_I: "(P ^^ n) x y \<Longrightarrow> P y z \<Longrightarrow> (P ^^ Suc n) x z" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 946 | by (fact relpow_Suc_I [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 947 | |
| 63404 | 948 | lemma relpow_Suc_I2: "(x, y) \<in> R \<Longrightarrow> (y, z) \<in> R ^^ n \<Longrightarrow> (x, z) \<in> R ^^ Suc n" | 
| 44890 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 nipkow parents: 
43596diff
changeset | 949 | by (induct n arbitrary: z) (simp, fastforce) | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 950 | |
| 63404 | 951 | lemma relpowp_Suc_I2: "P x y \<Longrightarrow> (P ^^ n) y z \<Longrightarrow> (P ^^ Suc n) x z" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 952 | by (fact relpow_Suc_I2 [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 953 | |
| 63404 | 954 | lemma relpow_0_E: "(x, y) \<in> R ^^ 0 \<Longrightarrow> (x = y \<Longrightarrow> P) \<Longrightarrow> P" | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 955 | by simp | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 956 | |
| 63404 | 957 | lemma relpowp_0_E: "(P ^^ 0) x y \<Longrightarrow> (x = y \<Longrightarrow> Q) \<Longrightarrow> Q" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 958 | by (fact relpow_0_E [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 959 | |
| 63404 | 960 | lemma relpow_Suc_E: "(x, z) \<in> R ^^ Suc n \<Longrightarrow> (\<And>y. (x, y) \<in> R ^^ n \<Longrightarrow> (y, z) \<in> R \<Longrightarrow> P) \<Longrightarrow> P" | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 961 | by auto | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 962 | |
| 63404 | 963 | lemma relpowp_Suc_E: "(P ^^ Suc n) x z \<Longrightarrow> (\<And>y. (P ^^ n) x y \<Longrightarrow> P y z \<Longrightarrow> Q) \<Longrightarrow> Q" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 964 | by (fact relpow_Suc_E [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 965 | |
| 46362 | 966 | lemma relpow_E: | 
| 63612 | 967 | "(x, z) \<in> R ^^ n \<Longrightarrow> | 
| 968 | (n = 0 \<Longrightarrow> x = z \<Longrightarrow> P) \<Longrightarrow> | |
| 969 | (\<And>y m. n = Suc m \<Longrightarrow> (x, y) \<in> R ^^ m \<Longrightarrow> (y, z) \<in> R \<Longrightarrow> P) \<Longrightarrow> P" | |
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 970 | by (cases n) auto | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 971 | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 972 | lemma relpowp_E: | 
| 63612 | 973 | "(P ^^ n) x z \<Longrightarrow> | 
| 974 | (n = 0 \<Longrightarrow> x = z \<Longrightarrow> Q) \<Longrightarrow> | |
| 975 | (\<And>y m. n = Suc m \<Longrightarrow> (P ^^ m) x y \<Longrightarrow> P y z \<Longrightarrow> Q) \<Longrightarrow> Q" | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 976 | by (fact relpow_E [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 977 | |
| 63404 | 978 | lemma relpow_Suc_D2: "(x, z) \<in> R ^^ Suc n \<Longrightarrow> (\<exists>y. (x, y) \<in> R \<and> (y, z) \<in> R ^^ n)" | 
| 63612 | 979 | by (induct n arbitrary: x z) | 
| 980 | (blast intro: relpow_0_I relpow_Suc_I elim: relpow_0_E relpow_Suc_E)+ | |
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 981 | |
| 63404 | 982 | lemma relpowp_Suc_D2: "(P ^^ Suc n) x z \<Longrightarrow> \<exists>y. P x y \<and> (P ^^ n) y z" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 983 | by (fact relpow_Suc_D2 [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 984 | |
| 63404 | 985 | lemma relpow_Suc_E2: "(x, z) \<in> R ^^ Suc n \<Longrightarrow> (\<And>y. (x, y) \<in> R \<Longrightarrow> (y, z) \<in> R ^^ n \<Longrightarrow> P) \<Longrightarrow> P" | 
| 46362 | 986 | by (blast dest: relpow_Suc_D2) | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 987 | |
| 63404 | 988 | lemma relpowp_Suc_E2: "(P ^^ Suc n) x z \<Longrightarrow> (\<And>y. P x y \<Longrightarrow> (P ^^ n) y z \<Longrightarrow> Q) \<Longrightarrow> Q" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 989 | by (fact relpow_Suc_E2 [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 990 | |
| 63404 | 991 | lemma relpow_Suc_D2': "\<forall>x y z. (x, y) \<in> R ^^ n \<and> (y, z) \<in> R \<longrightarrow> (\<exists>w. (x, w) \<in> R \<and> (w, z) \<in> R ^^ n)" | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 992 | by (induct n) (simp_all, blast) | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 993 | |
| 63404 | 994 | lemma relpowp_Suc_D2': "\<forall>x y z. (P ^^ n) x y \<and> P y z \<longrightarrow> (\<exists>w. P x w \<and> (P ^^ n) w z)" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 995 | by (fact relpow_Suc_D2' [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 996 | |
| 46362 | 997 | lemma relpow_E2: | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 998 | assumes "(x, z) \<in> R ^^ n" "n = 0 \<Longrightarrow> x = z \<Longrightarrow> P" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 999 | "\<And>y m. n = Suc m \<Longrightarrow> (x, y) \<in> R \<Longrightarrow> (y, z) \<in> R ^^ m \<Longrightarrow> P" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1000 | shows "P" | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1001 | proof (cases n) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1002 | case 0 | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1003 | with assms show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1004 | by simp | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1005 | next | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1006 | case (Suc m) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1007 | with assms relpow_Suc_D2' [of m R] show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1008 | by force | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1009 | qed | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1010 | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1011 | lemma relpowp_E2: | 
| 63612 | 1012 | "(P ^^ n) x z \<Longrightarrow> | 
| 1013 | (n = 0 \<Longrightarrow> x = z \<Longrightarrow> Q) \<Longrightarrow> | |
| 1014 | (\<And>y m. n = Suc m \<Longrightarrow> P x y \<Longrightarrow> (P ^^ m) y z \<Longrightarrow> Q) \<Longrightarrow> Q" | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1015 | by (fact relpow_E2 [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1016 | |
| 79611 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1017 | lemma relpowp_trans[trans]: "(R ^^ i) x y \<Longrightarrow> (R ^^ j) y z \<Longrightarrow> (R ^^ (i + j)) x z" | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1018 | proof (induction i arbitrary: x) | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1019 | case 0 | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1020 | thus ?case by simp | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1021 | next | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1022 | case (Suc i) | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1023 | obtain x' where "R x x'" and "(R ^^ i) x' y" | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1024 | using \<open>(R ^^ Suc i) x y\<close>[THEN relpowp_Suc_D2] by auto | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1025 | |
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1026 | show "(R ^^ (Suc i + j)) x z" | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1027 | unfolding add_Suc | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1028 | proof (rule relpowp_Suc_I2) | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1029 | show "R x x'" | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1030 | using \<open>R x x'\<close> . | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1031 | next | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1032 | show "(R ^^ (i + j)) x' z" | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1033 | using Suc.IH[OF \<open>(R ^^ i) x' y\<close> \<open>(R ^^ j) y z\<close>] . | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1034 | qed | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1035 | qed | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1036 | |
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1037 | lemma relpow_trans[trans]: "(x, y) \<in> R ^^ i \<Longrightarrow> (y, z) \<in> R ^^ j \<Longrightarrow> (x, z) \<in> R ^^ (i + j)" | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1038 | using relpowp_trans[to_set] . | 
| 
97612262718a
added lemmas relpow_trans[trans] and relpowp_trans[trans]
 desharna parents: 
77695diff
changeset | 1039 | |
| 79668 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1040 | lemma relpowp_left_unique: | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1041 | fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" and n :: nat and x y z :: 'a | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1042 | assumes lunique: "\<And>x y z. R x z \<Longrightarrow> R y z \<Longrightarrow> x = y" | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1043 | shows "(R ^^ n) x z \<Longrightarrow> (R ^^ n) y z \<Longrightarrow> x = y" | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1044 | proof (induction n arbitrary: x y z) | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1045 | case 0 | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1046 | thus ?case | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1047 | by simp | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1048 | next | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1049 | case (Suc n') | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1050 | then obtain x' y' :: 'a where | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1051 | "(R ^^ n') x x'" and "R x' z" and | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1052 | "(R ^^ n') y y'" and "R y' z" | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1053 | by auto | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1054 | |
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1055 | have "x' = y'" | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1056 | using lunique[OF \<open>R x' z\<close> \<open>R y' z\<close>] . | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1057 | |
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1058 | show "x = y" | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1059 | proof (rule Suc.IH) | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1060 | show "(R ^^ n') x x'" | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1061 | using \<open>(R ^^ n') x x'\<close> . | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1062 | next | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1063 | show "(R ^^ n') y x'" | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1064 | using \<open>(R ^^ n') y y'\<close> | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1065 | unfolding \<open>x' = y'\<close> . | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1066 | qed | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1067 | qed | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1068 | |
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1069 | lemma relpow_left_unique: | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1070 |   fixes R :: "('a \<times> 'a) set" and n :: nat and x y z :: 'a
 | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1071 | shows "(\<And>x y z. (x, z) \<in> R \<Longrightarrow> (y, z) \<in> R \<Longrightarrow> x = y) \<Longrightarrow> | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1072 | (x, z) \<in> R ^^ n \<Longrightarrow> (y, z) \<in> R ^^ n \<Longrightarrow> x = y" | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1073 | using relpowp_left_unique[to_set] . | 
| 
9f36a31fe7ae
added lemmas relpowp_left_unique and relpow_left_unique
 desharna parents: 
79667diff
changeset | 1074 | |
| 79667 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1075 | lemma relpowp_right_unique: | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1076 | fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" and n :: nat and x y z :: 'a | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1077 | assumes runique: "\<And>x y z. R x y \<Longrightarrow> R x z \<Longrightarrow> y = z" | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1078 | shows "(R ^^ n) x y \<Longrightarrow> (R ^^ n) x z \<Longrightarrow> y = z" | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1079 | proof (induction n arbitrary: x y z) | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1080 | case 0 | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1081 | thus ?case | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1082 | by simp | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1083 | next | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1084 | case (Suc n') | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1085 | then obtain x' :: 'a where | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1086 | "(R ^^ n') x x'" and "R x' y" and "R x' z" | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1087 | by auto | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1088 | thus "y = z" | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1089 | using runique by simp | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1090 | qed | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1091 | |
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1092 | lemma relpow_right_unique: | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1093 |   fixes R :: "('a \<times> 'a) set" and n :: nat and x y z :: 'a
 | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1094 | shows "(\<And>x y z. (x, y) \<in> R \<Longrightarrow> (x, z) \<in> R \<Longrightarrow> y = z) \<Longrightarrow> | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1095 | (x, y) \<in> (R ^^ n) \<Longrightarrow> (x, z) \<in> (R ^^ n) \<Longrightarrow> y = z" | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1096 | using relpowp_right_unique[to_set] . | 
| 
d4c077078497
added lemmas relpowp_right_unique and relpow_right_unique
 desharna parents: 
79611diff
changeset | 1097 | |
| 63404 | 1098 | lemma relpow_add: "R ^^ (m + n) = R^^m O R^^n" | 
| 45976 | 1099 | by (induct n) auto | 
| 31351 | 1100 | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1101 | lemma relpowp_add: "P ^^ (m + n) = P ^^ m OO P ^^ n" | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1102 | by (fact relpow_add [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1103 | |
| 46362 | 1104 | lemma relpow_commute: "R O R ^^ n = R ^^ n O R" | 
| 63404 | 1105 | by (induct n) (simp_all add: O_assoc [symmetric]) | 
| 31970 
ccaadfcf6941
move rel_pow_commute: "R O R ^^ n = R ^^ n O R" to Transitive_Closure
 krauss parents: 
31690diff
changeset | 1106 | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1107 | lemma relpowp_commute: "P OO P ^^ n = P ^^ n OO P" | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1108 | by (fact relpow_commute [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1109 | |
| 63404 | 1110 | lemma relpow_empty: "0 < n \<Longrightarrow> ({} :: ('a \<times> 'a) set) ^^ n = {}"
 | 
| 45153 | 1111 | by (cases n) auto | 
| 45116 
f947eeef6b6f
adding lemma about rel_pow in Transitive_Closure for executable equation of the (refl) transitive closure
 bulwahn parents: 
44921diff
changeset | 1112 | |
| 63404 | 1113 | lemma relpowp_bot: "0 < n \<Longrightarrow> (\<bottom> :: 'a \<Rightarrow> 'a \<Rightarrow> bool) ^^ n = \<bottom>" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1114 | by (fact relpow_empty [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1115 | |
| 46362 | 1116 | lemma rtrancl_imp_UN_relpow: | 
| 63404 | 1117 | assumes "p \<in> R\<^sup>*" | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1118 | shows "p \<in> (\<Union>n. R ^^ n)" | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1119 | proof (cases p) | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1120 | case (Pair x y) | 
| 63404 | 1121 | with assms have "(x, y) \<in> R\<^sup>*" by simp | 
| 63612 | 1122 | then have "(x, y) \<in> (\<Union>n. R ^^ n)" | 
| 1123 | proof induct | |
| 63404 | 1124 | case base | 
| 1125 | show ?case by (blast intro: relpow_0_I) | |
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1126 | next | 
| 63404 | 1127 | case step | 
| 1128 | then show ?case by (blast intro: relpow_Suc_I) | |
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1129 | qed | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1130 | with Pair show ?thesis by simp | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1131 | qed | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1132 | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1133 | lemma rtranclp_imp_Sup_relpowp: | 
| 63404 | 1134 | assumes "(P\<^sup>*\<^sup>*) x y" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1135 | shows "(\<Squnion>n. P ^^ n) x y" | 
| 61424 
c3658c18b7bc
prod_case as canonical name for product type eliminator
 haftmann parents: 
61378diff
changeset | 1136 | using assms and rtrancl_imp_UN_relpow [of "(x, y)", to_pred] by simp | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1137 | |
| 46362 | 1138 | lemma relpow_imp_rtrancl: | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1139 | assumes "p \<in> R ^^ n" | 
| 63404 | 1140 | shows "p \<in> R\<^sup>*" | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1141 | proof (cases p) | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1142 | case (Pair x y) | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1143 | with assms have "(x, y) \<in> R ^^ n" by simp | 
| 63612 | 1144 | then have "(x, y) \<in> R\<^sup>*" | 
| 1145 | proof (induct n arbitrary: x y) | |
| 63404 | 1146 | case 0 | 
| 1147 | then show ?case by simp | |
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1148 | next | 
| 63404 | 1149 | case Suc | 
| 1150 | then show ?case | |
| 46362 | 1151 | by (blast elim: relpow_Suc_E intro: rtrancl_into_rtrancl) | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1152 | qed | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1153 | with Pair show ?thesis by simp | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1154 | qed | 
| 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1155 | |
| 63404 | 1156 | lemma relpowp_imp_rtranclp: "(P ^^ n) x y \<Longrightarrow> (P\<^sup>*\<^sup>*) x y" | 
| 1157 | using relpow_imp_rtrancl [of "(x, y)", to_pred] by simp | |
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1158 | |
| 63404 | 1159 | lemma rtrancl_is_UN_relpow: "R\<^sup>* = (\<Union>n. R ^^ n)" | 
| 46362 | 1160 | by (blast intro: rtrancl_imp_UN_relpow relpow_imp_rtrancl) | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1161 | |
| 63404 | 1162 | lemma rtranclp_is_Sup_relpowp: "P\<^sup>*\<^sup>* = (\<Squnion>n. P ^^ n)" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1163 | using rtrancl_is_UN_relpow [to_pred, of P] by auto | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1164 | |
| 63404 | 1165 | lemma rtrancl_power: "p \<in> R\<^sup>* \<longleftrightarrow> (\<exists>n. p \<in> R ^^ n)" | 
| 46362 | 1166 | by (simp add: rtrancl_is_UN_relpow) | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1167 | |
| 63404 | 1168 | lemma rtranclp_power: "(P\<^sup>*\<^sup>*) x y \<longleftrightarrow> (\<exists>n. (P ^^ n) x y)" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1169 | by (simp add: rtranclp_is_Sup_relpowp) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1170 | |
| 63404 | 1171 | lemma trancl_power: "p \<in> R\<^sup>+ \<longleftrightarrow> (\<exists>n > 0. p \<in> R ^^ n)" | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1172 | proof - | 
| 71627 | 1173 | have "(a, b) \<in> R\<^sup>+ \<longleftrightarrow> (\<exists>n>0. (a, b) \<in> R ^^ n)" for a b | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1174 | proof safe | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1175 | show "(a, b) \<in> R\<^sup>+ \<Longrightarrow> \<exists>n>0. (a, b) \<in> R ^^ n" | 
| 71627 | 1176 | by (fastforce simp: rtrancl_is_UN_relpow relcomp_unfold dest: tranclD2) | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1177 | show "(a, b) \<in> R\<^sup>+" if "n > 0" "(a, b) \<in> R ^^ n" for n | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1178 | proof (cases n) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1179 | case (Suc m) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1180 | with that show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1181 | by (auto simp: dest: relpow_imp_rtrancl rtrancl_into_trancl1) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1182 | qed (use that in auto) | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1183 | qed | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1184 | then show ?thesis | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1185 | by (cases p) auto | 
| 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1186 | qed | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1187 | |
| 63404 | 1188 | lemma tranclp_power: "(P\<^sup>+\<^sup>+) x y \<longleftrightarrow> (\<exists>n > 0. (P ^^ n) x y)" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1189 | using trancl_power [to_pred, of P "(x, y)"] by simp | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1190 | |
| 63404 | 1191 | lemma rtrancl_imp_relpow: "p \<in> R\<^sup>* \<Longrightarrow> \<exists>n. p \<in> R ^^ n" | 
| 46362 | 1192 | by (auto dest: rtrancl_imp_UN_relpow) | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1193 | |
| 63404 | 1194 | lemma rtranclp_imp_relpowp: "(P\<^sup>*\<^sup>*) x y \<Longrightarrow> \<exists>n. (P ^^ n) x y" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1195 | by (auto dest: rtranclp_imp_Sup_relpowp) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1196 | |
| 63404 | 1197 | text \<open>By Sternagel/Thiemann:\<close> | 
| 1198 | lemma relpow_fun_conv: "(a, b) \<in> R ^^ n \<longleftrightarrow> (\<exists>f. f 0 = a \<and> f n = b \<and> (\<forall>i<n. (f i, f (Suc i)) \<in> R))" | |
| 41987 | 1199 | proof (induct n arbitrary: b) | 
| 63404 | 1200 | case 0 | 
| 1201 | show ?case by auto | |
| 41987 | 1202 | next | 
| 1203 | case (Suc n) | |
| 1204 | show ?case | |
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
75652diff
changeset | 1205 | proof - | 
| 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
75652diff
changeset | 1206 | have "(\<exists>y. (\<exists>f. f 0 = a \<and> f n = y \<and> (\<forall>i<n. (f i,f(Suc i)) \<in> R)) \<and> (y,b) \<in> R) \<longleftrightarrow> | 
| 63404 | 1207 | (\<exists>f. f 0 = a \<and> f(Suc n) = b \<and> (\<forall>i<Suc n. (f i, f (Suc i)) \<in> R))" | 
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
75652diff
changeset | 1208 | (is "?l \<longleftrightarrow> ?r") | 
| 41987 | 1209 | proof | 
| 1210 | assume ?l | |
| 63404 | 1211 | then obtain c f | 
| 1212 | where 1: "f 0 = a" "f n = c" "\<And>i. i < n \<Longrightarrow> (f i, f (Suc i)) \<in> R" "(c,b) \<in> R" | |
| 1213 | by auto | |
| 41987 | 1214 | let ?g = "\<lambda> m. if m = Suc n then b else f m" | 
| 63404 | 1215 | show ?r by (rule exI[of _ ?g]) (simp add: 1) | 
| 41987 | 1216 | next | 
| 1217 | assume ?r | |
| 63404 | 1218 | then obtain f where 1: "f 0 = a" "b = f (Suc n)" "\<And>i. i < Suc n \<Longrightarrow> (f i, f (Suc i)) \<in> R" | 
| 1219 | by auto | |
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
75652diff
changeset | 1220 | show ?l by (rule exI[of _ "f n"], rule conjI, rule exI[of _ f], auto simp add: 1) | 
| 41987 | 1221 | qed | 
| 75669 
43f5dfb7fa35
tuned (some HOL lints, by Yecine Megdiche);
 Fabian Huch <huch@in.tum.de> parents: 
75652diff
changeset | 1222 | then show ?thesis by (simp add: relcomp_unfold Suc) | 
| 41987 | 1223 | qed | 
| 1224 | qed | |
| 1225 | ||
| 63404 | 1226 | lemma relpowp_fun_conv: "(P ^^ n) x y \<longleftrightarrow> (\<exists>f. f 0 = x \<and> f n = y \<and> (\<forall>i<n. P (f i) (f (Suc i))))" | 
| 47492 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1227 | by (fact relpow_fun_conv [to_pred]) | 
| 
2631a12fb2d1
duplicate "relpow" facts for "relpowp" (to emphasize that both worlds exist and obtain better search results with "find_theorems")
 Christian Sternagel parents: 
47433diff
changeset | 1228 | |
| 46362 | 1229 | lemma relpow_finite_bounded1: | 
| 63404 | 1230 |   fixes R :: "('a \<times> 'a) set"
 | 
| 1231 | assumes "finite R" and "k > 0" | |
| 63612 | 1232 |   shows "R^^k \<subseteq> (\<Union>n\<in>{n. 0 < n \<and> n \<le> card R}. R^^n)"
 | 
| 1233 | (is "_ \<subseteq> ?r") | |
| 63404 | 1234 | proof - | 
| 1235 | have "(a, b) \<in> R^^(Suc k) \<Longrightarrow> \<exists>n. 0 < n \<and> n \<le> card R \<and> (a, b) \<in> R^^n" for a b k | |
| 1236 | proof (induct k arbitrary: b) | |
| 1237 | case 0 | |
| 1238 |     then have "R \<noteq> {}" by auto
 | |
| 1239 | with card_0_eq[OF \<open>finite R\<close>] have "card R \<ge> Suc 0" by auto | |
| 1240 | then show ?case using 0 by force | |
| 1241 | next | |
| 1242 | case (Suc k) | |
| 1243 | then obtain a' where "(a, a') \<in> R^^(Suc k)" and "(a', b) \<in> R" | |
| 1244 | by auto | |
| 1245 | from Suc(1)[OF \<open>(a, a') \<in> R^^(Suc k)\<close>] obtain n where "n \<le> card R" and "(a, a') \<in> R ^^ n" | |
| 1246 | by auto | |
| 1247 | have "(a, b) \<in> R^^(Suc n)" | |
| 1248 | using \<open>(a, a') \<in> R^^n\<close> and \<open>(a', b)\<in> R\<close> by auto | |
| 1249 | from \<open>n \<le> card R\<close> consider "n < card R" | "n = card R" by force | |
| 1250 | then show ?case | |
| 1251 | proof cases | |
| 1252 | case 1 | |
| 1253 | then show ?thesis | |
| 1254 | using \<open>(a, b) \<in> R^^(Suc n)\<close> Suc_leI[OF \<open>n < card R\<close>] by blast | |
| 41987 | 1255 | next | 
| 63404 | 1256 | case 2 | 
| 1257 | from \<open>(a, b) \<in> R ^^ (Suc n)\<close> [unfolded relpow_fun_conv] | |
| 1258 | obtain f where "f 0 = a" and "f (Suc n) = b" | |
| 1259 | and steps: "\<And>i. i \<le> n \<Longrightarrow> (f i, f (Suc i)) \<in> R" by auto | |
| 1260 | let ?p = "\<lambda>i. (f i, f(Suc i))" | |
| 1261 |       let ?N = "{i. i \<le> n}"
 | |
| 1262 | have "?p ` ?N \<subseteq> R" | |
| 1263 | using steps by auto | |
| 1264 | from card_mono[OF assms(1) this] have "card (?p ` ?N) \<le> card R" . | |
| 1265 | also have "\<dots> < card ?N" | |
| 1266 | using \<open>n = card R\<close> by simp | |
| 1267 | finally have "\<not> inj_on ?p ?N" | |
| 1268 | by (rule pigeonhole) | |
| 1269 | then obtain i j where i: "i \<le> n" and j: "j \<le> n" and ij: "i \<noteq> j" and pij: "?p i = ?p j" | |
| 1270 | by (auto simp: inj_on_def) | |
| 1271 | let ?i = "min i j" | |
| 1272 | let ?j = "max i j" | |
| 1273 | have i: "?i \<le> n" and j: "?j \<le> n" and pij: "?p ?i = ?p ?j" and ij: "?i < ?j" | |
| 1274 | using i j ij pij unfolding min_def max_def by auto | |
| 1275 | from i j pij ij obtain i j where i: "i \<le> n" and j: "j \<le> n" and ij: "i < j" | |
| 1276 | and pij: "?p i = ?p j" | |
| 1277 | by blast | |
| 1278 | let ?g = "\<lambda>l. if l \<le> i then f l else f (l + (j - i))" | |
| 1279 | let ?n = "Suc (n - (j - i))" | |
| 1280 | have abl: "(a, b) \<in> R ^^ ?n" | |
| 1281 | unfolding relpow_fun_conv | |
| 1282 | proof (rule exI[of _ ?g], intro conjI impI allI) | |
| 1283 | show "?g ?n = b" | |
| 1284 | using \<open>f(Suc n) = b\<close> j ij by auto | |
| 1285 | next | |
| 1286 | fix k | |
| 1287 | assume "k < ?n" | |
| 1288 | show "(?g k, ?g (Suc k)) \<in> R" | |
| 1289 | proof (cases "k < i") | |
| 1290 | case True | |
| 1291 | with i have "k \<le> n" | |
| 1292 | by auto | |
| 1293 | from steps[OF this] show ?thesis | |
| 1294 | using True by simp | |
| 41987 | 1295 | next | 
| 63404 | 1296 | case False | 
| 1297 | then have "i \<le> k" by auto | |
| 1298 | show ?thesis | |
| 1299 | proof (cases "k = i") | |
| 41987 | 1300 | case True | 
| 63404 | 1301 | then show ?thesis | 
| 1302 | using ij pij steps[OF i] by simp | |
| 41987 | 1303 | next | 
| 1304 | case False | |
| 63404 | 1305 | with \<open>i \<le> k\<close> have "i < k" by auto | 
| 1306 | then have small: "k + (j - i) \<le> n" | |
| 1307 | using \<open>k<?n\<close> by arith | |
| 41987 | 1308 | show ?thesis | 
| 63404 | 1309 | using steps[OF small] \<open>i<k\<close> by auto | 
| 41987 | 1310 | qed | 
| 63404 | 1311 | qed | 
| 1312 | qed (simp add: \<open>f 0 = a\<close>) | |
| 1313 | moreover have "?n \<le> n" | |
| 1314 | using i j ij by arith | |
| 1315 | ultimately show ?thesis | |
| 1316 | using \<open>n = card R\<close> by blast | |
| 41987 | 1317 | qed | 
| 63404 | 1318 | qed | 
| 1319 | then show ?thesis | |
| 1320 | using gr0_implies_Suc[OF \<open>k > 0\<close>] by auto | |
| 41987 | 1321 | qed | 
| 1322 | ||
| 46362 | 1323 | lemma relpow_finite_bounded: | 
| 63404 | 1324 |   fixes R :: "('a \<times> 'a) set"
 | 
| 1325 | assumes "finite R" | |
| 69276 | 1326 |   shows "R^^k \<subseteq> (\<Union>n\<in>{n. n \<le> card R}. R^^n)"
 | 
| 71627 | 1327 | proof (cases k) | 
| 1328 | case (Suc k') | |
| 1329 | then show ?thesis | |
| 1330 | using relpow_finite_bounded1[OF assms, of k] by auto | |
| 1331 | qed force | |
| 41987 | 1332 | |
| 63404 | 1333 | lemma rtrancl_finite_eq_relpow: "finite R \<Longrightarrow> R\<^sup>* = (\<Union>n\<in>{n. n \<le> card R}. R^^n)"
 | 
| 1334 | by (fastforce simp: rtrancl_power dest: relpow_finite_bounded) | |
| 41987 | 1335 | |
| 71627 | 1336 | lemma trancl_finite_eq_relpow: | 
| 1337 |   assumes "finite R" shows "R\<^sup>+ = (\<Union>n\<in>{n. 0 < n \<and> n \<le> card R}. R^^n)"
 | |
| 1338 | proof - | |
| 1339 | have "\<And>a b n. \<lbrakk>0 < n; (a, b) \<in> R ^^ n\<rbrakk> \<Longrightarrow> \<exists>x>0. x \<le> card R \<and> (a, b) \<in> R ^^ x" | |
| 1340 | using assms by (auto dest: relpow_finite_bounded1) | |
| 1341 | then show ?thesis | |
| 1342 | by (auto simp: trancl_power) | |
| 1343 | qed | |
| 41987 | 1344 | |
| 47433 
07f4bf913230
renamed "rel_comp" to "relcomp" (to be consistent with, e.g., "relpow")
 griff parents: 
47202diff
changeset | 1345 | lemma finite_relcomp[simp,intro]: | 
| 63404 | 1346 | assumes "finite R" and "finite S" | 
| 1347 | shows "finite (R O S)" | |
| 41987 | 1348 | proof- | 
| 62343 
24106dc44def
prefer abbreviations for compound operators INFIMUM and SUPREMUM
 haftmann parents: 
62093diff
changeset | 1349 |   have "R O S = (\<Union>(x, y)\<in>R. \<Union>(u, v)\<in>S. if u = y then {(x, v)} else {})"
 | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1350 | by (force simp: split_def image_constant_conv split: if_splits) | 
| 63404 | 1351 | then show ?thesis | 
| 1352 | using assms by clarsimp | |
| 41987 | 1353 | qed | 
| 1354 | ||
| 63404 | 1355 | lemma finite_relpow [simp, intro]: | 
| 1356 |   fixes R :: "('a \<times> 'a) set"
 | |
| 1357 | assumes "finite R" | |
| 1358 | shows "n > 0 \<Longrightarrow> finite (R^^n)" | |
| 63612 | 1359 | proof (induct n) | 
| 1360 | case 0 | |
| 1361 | then show ?case by simp | |
| 1362 | next | |
| 1363 | case (Suc n) | |
| 1364 | then show ?case by (cases n) (use assms in simp_all) | |
| 1365 | qed | |
| 41987 | 1366 | |
| 46362 | 1367 | lemma single_valued_relpow: | 
| 63404 | 1368 |   fixes R :: "('a \<times> 'a) set"
 | 
| 30954 
cf50e67bc1d1
power operation on functions in theory Nat; power operation on relations in theory Transitive_Closure
 haftmann parents: 
30549diff
changeset | 1369 | shows "single_valued R \<Longrightarrow> single_valued (R ^^ n)" | 
| 63612 | 1370 | proof (induct n arbitrary: R) | 
| 1371 | case 0 | |
| 1372 | then show ?case by simp | |
| 1373 | next | |
| 1374 | case (Suc n) | |
| 1375 | show ?case | |
| 1376 | by (rule single_valuedI) | |
| 1377 | (use Suc in \<open>fast dest: single_valuedD elim: relpow_Suc_E\<close>) | |
| 1378 | qed | |
| 15551 | 1379 | |
| 45140 | 1380 | |
| 60758 | 1381 | subsection \<open>Bounded transitive closure\<close> | 
| 45140 | 1382 | |
| 1383 | definition ntrancl :: "nat \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> ('a \<times> 'a) set"
 | |
| 63404 | 1384 |   where "ntrancl n R = (\<Union>i\<in>{i. 0 < i \<and> i \<le> Suc n}. R ^^ i)"
 | 
| 45140 | 1385 | |
| 63404 | 1386 | lemma ntrancl_Zero [simp, code]: "ntrancl 0 R = R" | 
| 45140 | 1387 | proof | 
| 1388 | show "R \<subseteq> ntrancl 0 R" | |
| 1389 | unfolding ntrancl_def by fastforce | |
| 63404 | 1390 | have "0 < i \<and> i \<le> Suc 0 \<longleftrightarrow> i = 1" for i | 
| 1391 | by auto | |
| 1392 | then show "ntrancl 0 R \<le> R" | |
| 45140 | 1393 | unfolding ntrancl_def by auto | 
| 1394 | qed | |
| 1395 | ||
| 63404 | 1396 | lemma ntrancl_Suc [simp]: "ntrancl (Suc n) R = ntrancl n R O (Id \<union> R)" | 
| 45140 | 1397 | proof | 
| 63612 | 1398 | have "(a, b) \<in> ntrancl n R O (Id \<union> R)" if "(a, b) \<in> ntrancl (Suc n) R" for a b | 
| 1399 | proof - | |
| 1400 | from that obtain i where "0 < i" "i \<le> Suc (Suc n)" "(a, b) \<in> R ^^ i" | |
| 45140 | 1401 | unfolding ntrancl_def by auto | 
| 63612 | 1402 | show ?thesis | 
| 45140 | 1403 | proof (cases "i = 1") | 
| 1404 | case True | |
| 71627 | 1405 | with \<open>(a, b) \<in> R ^^ i\<close> show ?thesis | 
| 63612 | 1406 | by (auto simp: ntrancl_def) | 
| 45140 | 1407 | next | 
| 1408 | case False | |
| 63612 | 1409 | with \<open>0 < i\<close> obtain j where j: "i = Suc j" "0 < j" | 
| 45140 | 1410 | by (cases i) auto | 
| 63612 | 1411 | with \<open>(a, b) \<in> R ^^ i\<close> obtain c where c1: "(a, c) \<in> R ^^ j" and c2: "(c, b) \<in> R" | 
| 45140 | 1412 | by auto | 
| 60758 | 1413 | from c1 j \<open>i \<le> Suc (Suc n)\<close> have "(a, c) \<in> ntrancl n R" | 
| 63612 | 1414 | by (fastforce simp: ntrancl_def) | 
| 1415 | with c2 show ?thesis by fastforce | |
| 45140 | 1416 | qed | 
| 63612 | 1417 | qed | 
| 63404 | 1418 | then show "ntrancl (Suc n) R \<subseteq> ntrancl n R O (Id \<union> R)" | 
| 45140 | 1419 | by auto | 
| 1420 | show "ntrancl n R O (Id \<union> R) \<subseteq> ntrancl (Suc n) R" | |
| 63612 | 1421 | by (fastforce simp: ntrancl_def) | 
| 45140 | 1422 | qed | 
| 1423 | ||
| 63404 | 1424 | lemma [code]: "ntrancl (Suc n) r = (let r' = ntrancl n r in r' \<union> r' O r)" | 
| 1425 | by (auto simp: Let_def) | |
| 46347 
54870ad19af4
new code equation for ntrancl that allows computation of the transitive closure of sets on infinite types as well
 bulwahn parents: 
46127diff
changeset | 1426 | |
| 63404 | 1427 | lemma finite_trancl_ntranl: "finite R \<Longrightarrow> trancl R = ntrancl (card R - 1) R" | 
| 68618 
3db8520941a4
de-applying (mostly Set_Interval)
 paulson <lp15@cam.ac.uk> parents: 
68456diff
changeset | 1428 | by (cases "card R") (auto simp: trancl_finite_eq_relpow relpow_empty ntrancl_def) | 
| 45140 | 1429 | |
| 1430 | ||
| 60758 | 1431 | subsection \<open>Acyclic relations\<close> | 
| 45139 | 1432 | |
| 63404 | 1433 | definition acyclic :: "('a \<times> 'a) set \<Rightarrow> bool"
 | 
| 1434 | where "acyclic r \<longleftrightarrow> (\<forall>x. (x,x) \<notin> r\<^sup>+)" | |
| 45139 | 1435 | |
| 63404 | 1436 | abbreviation acyclicP :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
 | 
| 1437 |   where "acyclicP r \<equiv> acyclic {(x, y). r x y}"
 | |
| 45139 | 1438 | |
| 63404 | 1439 | lemma acyclic_irrefl [code]: "acyclic r \<longleftrightarrow> irrefl (r\<^sup>+)" | 
| 45139 | 1440 | by (simp add: acyclic_def irrefl_def) | 
| 1441 | ||
| 63404 | 1442 | lemma acyclicI: "\<forall>x. (x, x) \<notin> r\<^sup>+ \<Longrightarrow> acyclic r" | 
| 45139 | 1443 | by (simp add: acyclic_def) | 
| 1444 | ||
| 70749 
5d06b7bb9d22
More type class generalisations. Note that linorder_antisym_conv1 and linorder_antisym_conv2 no longer exist.
 paulson <lp15@cam.ac.uk> parents: 
69605diff
changeset | 1445 | lemma (in preorder) acyclicI_order: | 
| 54412 | 1446 | assumes *: "\<And>a b. (a, b) \<in> r \<Longrightarrow> f b < f a" | 
| 1447 | shows "acyclic r" | |
| 1448 | proof - | |
| 63404 | 1449 | have "f b < f a" if "(a, b) \<in> r\<^sup>+" for a b | 
| 1450 | using that by induct (auto intro: * less_trans) | |
| 54412 | 1451 | then show ?thesis | 
| 1452 | by (auto intro!: acyclicI) | |
| 1453 | qed | |
| 1454 | ||
| 63404 | 1455 | lemma acyclic_insert [iff]: "acyclic (insert (y, x) r) \<longleftrightarrow> acyclic r \<and> (x, y) \<notin> r\<^sup>*" | 
| 63612 | 1456 | by (simp add: acyclic_def trancl_insert) (blast intro: rtrancl_trans) | 
| 45139 | 1457 | |
| 63404 | 1458 | lemma acyclic_converse [iff]: "acyclic (r\<inverse>) \<longleftrightarrow> acyclic r" | 
| 1459 | by (simp add: acyclic_def trancl_converse) | |
| 45139 | 1460 | |
| 1461 | lemmas acyclicP_converse [iff] = acyclic_converse [to_pred] | |
| 1462 | ||
| 63404 | 1463 | lemma acyclic_impl_antisym_rtrancl: "acyclic r \<Longrightarrow> antisym (r\<^sup>*)" | 
| 63612 | 1464 | by (simp add: acyclic_def antisym_def) | 
| 1465 | (blast elim: rtranclE intro: rtrancl_into_trancl1 rtrancl_trancl_trancl) | |
| 45139 | 1466 | |
| 1467 | (* Other direction: | |
| 1468 | acyclic = no loops | |
| 1469 | antisym = only self loops | |
| 63404 | 1470 | Goalw [acyclic_def,antisym_def] "antisym( r\<^sup>* ) \<Longrightarrow> acyclic(r - Id) | 
| 1471 | \<Longrightarrow> antisym( r\<^sup>* ) = acyclic(r - Id)"; | |
| 45139 | 1472 | *) | 
| 1473 | ||
| 63404 | 1474 | lemma acyclic_subset: "acyclic s \<Longrightarrow> r \<subseteq> s \<Longrightarrow> acyclic r" | 
| 1475 | unfolding acyclic_def by (blast intro: trancl_mono) | |
| 45139 | 1476 | |
| 1477 | ||
| 60758 | 1478 | subsection \<open>Setup of transitivity reasoner\<close> | 
| 15076 
4b3d280ef06a
New prover for transitive and reflexive-transitive closure of relations.
 ballarin parents: 
14565diff
changeset | 1479 | |
| 60758 | 1480 | ML \<open> | 
| 32215 | 1481 | structure Trancl_Tac = Trancl_Tac | 
| 1482 | ( | |
| 1483 |   val r_into_trancl = @{thm trancl.r_into_trancl};
 | |
| 1484 |   val trancl_trans  = @{thm trancl_trans};
 | |
| 1485 |   val rtrancl_refl = @{thm rtrancl.rtrancl_refl};
 | |
| 1486 |   val r_into_rtrancl = @{thm r_into_rtrancl};
 | |
| 1487 |   val trancl_into_rtrancl = @{thm trancl_into_rtrancl};
 | |
| 1488 |   val rtrancl_trancl_trancl = @{thm rtrancl_trancl_trancl};
 | |
| 1489 |   val trancl_rtrancl_trancl = @{thm trancl_rtrancl_trancl};
 | |
| 1490 |   val rtrancl_trans = @{thm rtrancl_trans};
 | |
| 15096 | 1491 | |
| 74345 | 1492 | fun decomp \<^Const_>\<open>Trueprop for t\<close> = | 
| 63404 | 1493 | let | 
| 74375 | 1494 | fun dec \<^Const_>\<open>Set.member _ for \<^Const_>\<open>Pair _ _ for a b\<close> rel\<close> = | 
| 63404 | 1495 | let | 
| 74345 | 1496 | fun decr \<^Const_>\<open>rtrancl _ for r\<close> = (r,"r*") | 
| 1497 | | decr \<^Const_>\<open>trancl _ for r\<close> = (r,"r+") | |
| 63404 | 1498 | | decr r = (r,"r"); | 
| 1499 | val (rel,r) = decr (Envir.beta_eta_contract rel); | |
| 1500 | in SOME (a,b,rel,r) end | |
| 1501 | | dec _ = NONE | |
| 1502 | in dec t end | |
| 30107 
f3b3b0e3d184
Fixed nonexhaustive match problem in decomp, to make it fail more gracefully
 berghofe parents: 
29609diff
changeset | 1503 | | decomp _ = NONE; | 
| 32215 | 1504 | ); | 
| 15076 
4b3d280ef06a
New prover for transitive and reflexive-transitive closure of relations.
 ballarin parents: 
14565diff
changeset | 1505 | |
| 32215 | 1506 | structure Tranclp_Tac = Trancl_Tac | 
| 1507 | ( | |
| 1508 |   val r_into_trancl = @{thm tranclp.r_into_trancl};
 | |
| 1509 |   val trancl_trans  = @{thm tranclp_trans};
 | |
| 1510 |   val rtrancl_refl = @{thm rtranclp.rtrancl_refl};
 | |
| 1511 |   val r_into_rtrancl = @{thm r_into_rtranclp};
 | |
| 1512 |   val trancl_into_rtrancl = @{thm tranclp_into_rtranclp};
 | |
| 1513 |   val rtrancl_trancl_trancl = @{thm rtranclp_tranclp_tranclp};
 | |
| 1514 |   val trancl_rtrancl_trancl = @{thm tranclp_rtranclp_tranclp};
 | |
| 1515 |   val rtrancl_trans = @{thm rtranclp_trans};
 | |
| 22262 | 1516 | |
| 74345 | 1517 | fun decomp \<^Const_>\<open>Trueprop for t\<close> = | 
| 63404 | 1518 | let | 
| 1519 | fun dec (rel $ a $ b) = | |
| 1520 | let | |
| 74345 | 1521 | fun decr \<^Const_>\<open>rtranclp _ for r\<close> = (r,"r*") | 
| 1522 | | decr \<^Const_>\<open>tranclp _ for r\<close> = (r,"r+") | |
| 63404 | 1523 | | decr r = (r,"r"); | 
| 1524 | val (rel,r) = decr rel; | |
| 1525 | in SOME (a, b, rel, r) end | |
| 1526 | | dec _ = NONE | |
| 1527 | in dec t end | |
| 30107 
f3b3b0e3d184
Fixed nonexhaustive match problem in decomp, to make it fail more gracefully
 berghofe parents: 
29609diff
changeset | 1528 | | decomp _ = NONE; | 
| 32215 | 1529 | ); | 
| 60758 | 1530 | \<close> | 
| 22262 | 1531 | |
| 60758 | 1532 | setup \<open> | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
50616diff
changeset | 1533 | map_theory_simpset (fn ctxt => ctxt | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
50616diff
changeset | 1534 | addSolver (mk_solver "Trancl" Trancl_Tac.trancl_tac) | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
50616diff
changeset | 1535 | addSolver (mk_solver "Rtrancl" Trancl_Tac.rtrancl_tac) | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
50616diff
changeset | 1536 | addSolver (mk_solver "Tranclp" Tranclp_Tac.trancl_tac) | 
| 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
50616diff
changeset | 1537 | addSolver (mk_solver "Rtranclp" Tranclp_Tac.rtrancl_tac)) | 
| 60758 | 1538 | \<close> | 
| 15076 
4b3d280ef06a
New prover for transitive and reflexive-transitive closure of relations.
 ballarin parents: 
14565diff
changeset | 1539 | |
| 71393 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 1540 | lemma transp_rtranclp [simp]: "transp R\<^sup>*\<^sup>*" | 
| 
fce780f9c9c6
new examples of BNF lifting across quotients using a new theory of confluence,
 traytel parents: 
70749diff
changeset | 1541 | by(auto simp add: transp_def) | 
| 32215 | 1542 | |
| 60758 | 1543 | text \<open>Optional methods.\<close> | 
| 15076 
4b3d280ef06a
New prover for transitive and reflexive-transitive closure of relations.
 ballarin parents: 
14565diff
changeset | 1544 | |
| 
4b3d280ef06a
New prover for transitive and reflexive-transitive closure of relations.
 ballarin parents: 
14565diff
changeset | 1545 | method_setup trancl = | 
| 60758 | 1546 | \<open>Scan.succeed (SIMPLE_METHOD' o Trancl_Tac.trancl_tac)\<close> | 
| 1547 | \<open>simple transitivity reasoner\<close> | |
| 15076 
4b3d280ef06a
New prover for transitive and reflexive-transitive closure of relations.
 ballarin parents: 
14565diff
changeset | 1548 | method_setup rtrancl = | 
| 60758 | 1549 | \<open>Scan.succeed (SIMPLE_METHOD' o Trancl_Tac.rtrancl_tac)\<close> | 
| 1550 | \<open>simple transitivity reasoner\<close> | |
| 22262 | 1551 | method_setup tranclp = | 
| 60758 | 1552 | \<open>Scan.succeed (SIMPLE_METHOD' o Tranclp_Tac.trancl_tac)\<close> | 
| 1553 | \<open>simple transitivity reasoner (predicate version)\<close> | |
| 22262 | 1554 | method_setup rtranclp = | 
| 60758 | 1555 | \<open>Scan.succeed (SIMPLE_METHOD' o Tranclp_Tac.rtrancl_tac)\<close> | 
| 1556 | \<open>simple transitivity reasoner (predicate version)\<close> | |
| 15076 
4b3d280ef06a
New prover for transitive and reflexive-transitive closure of relations.
 ballarin parents: 
14565diff
changeset | 1557 | |
| 10213 | 1558 | end |