fact
stringlengths
1
2.11k
type
stringclasses
27 values
library
stringclasses
888 values
imports
listlengths
0
81
filename
stringlengths
9
106
symbolic_name
stringlengths
1
113
docstring
stringlengths
0
1.34k
NF_join_imp_reach: assumes "y \<in> NF A" and "(x, y) \<in> A\<^sup>\<down>" shows "(x, y) \<in> A\<^sup>*" using assms by (auto simp: join_def) (metis NF_not_suc rtrancl_converseD)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
NF_join_imp_reach
CR r
conversion_O_conversion[simp]: "A\<^sup>\<leftrightarrow>\<^sup>* O A\<^sup>\<leftrightarrow>\<^sup>* = A\<^sup>\<leftrightarrow>\<^sup>*" by (force simp: converse_def)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
conversion_O_conversion
null
trans_O_iff: "trans A \<longleftrightarrow> A O A \<subseteq> A" unfolding trans_def by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
trans_O_iff
null
refl_O_iff: "refl A \<longleftrightarrow> Id \<subseteq> A" unfolding refl_on_def by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
refl_O_iff
null
relpow_Suc: "r ^^ Suc n = r O r ^^ n" using relpow_add[of 1 n r] by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
relpow_Suc
null
converse_power: fixes r :: "'a rel" shows "(r\<inverse>)^^n = (r^^n)\<inverse>" proof (induct n) case (Suc n) show ?case unfolding relpow.simps(2)[of _ "r\<inverse>"] relpow_Suc[of _ r] by (simp add: Suc converse_relcomp) qed simp
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
converse_power
null
conversion_mono: "A \<subseteq> B \<Longrightarrow> A\<^sup>\<leftrightarrow>\<^sup>* \<subseteq> B\<^sup>\<leftrightarrow>\<^sup>*" by (auto simp: conversion_def intro!: rtrancl_mono)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
conversion_mono
null
conversion_conversion_idemp[simp]: "(A\<^sup>\<leftrightarrow>\<^sup>*)\<^sup>\<leftrightarrow>\<^sup>* = A\<^sup>\<leftrightarrow>\<^sup>*" by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
conversion_conversion_idemp
null
lower_set_imp_not_SN_on: assumes "s \<in> X" "\<forall>t \<in> X. \<exists>u \<in> X. (t,u) \<in> R" shows "\<not> SN_on R {s}" by (meson SN_on_imp_on_minimal assms)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
lower_set_imp_not_SN_on
null
SN_on_Image_rtrancl_iff[simp]: "SN_on R (R\<^sup>* `` X) \<longleftrightarrow> SN_on R X" (is "?l = ?r") proof(intro iffI) assume "?l" show "?r" by (rule SN_on_subset2[OF _ \<open>?l\<close>], auto) qed (fact SN_on_Image_rtrancl)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
SN_on_Image_rtrancl_iff
null
O_mono1: "R \<subseteq> R' \<Longrightarrow> S O R \<subseteq> S O R'" by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
O_mono1
?l
O_mono2: "R \<subseteq> R' \<Longrightarrow> R O T \<subseteq> R' O T" by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
O_mono2
?l
rtrancl_O_shift: "(S O R)\<^sup>* O S = S O (R O S)\<^sup>*" proof(intro equalityI subrelI) fix x y assume "(x,y) \<in> (S O R)\<^sup>* O S" then obtain n where "(x,y) \<in> (S O R)^^n O S" by blast then show "(x,y) \<in> S O (R O S)\<^sup>*" proof(induct n arbitrary: y) case IH: (Suc n) then obtain z where xz: "(x,z) \<in> (S O R)^^n O S" and zy: "(z,y) \<in> R O S" by auto from IH.hyps[OF xz] zy have "(x,y) \<in> S O (R O S)\<^sup>* O R O S" by auto then show ?case by(fold trancl_unfold_right, auto) qed auto next fix x y assume "(x,y) \<in> S O (R O S)\<^sup>*" then obtain n where "(x,y) \<in> S O (R O S)^^n" by blast then show "(x,y) \<in> (S O R)\<^sup>* O S" proof(induct n arbitrary: y) case IH: (Suc n) then obtain z where xz: "(x,z) \<in> S O (R O S)^^n" and zy: "(z,y) \<in> R O S" by auto from IH.hyps[OF xz] zy have "(x,y) \<in> ((S O R)\<^sup>* O S O R) O S" by auto from this[folded trancl_unfold_right] show ?case by (rule rev_subsetD[OF _ O_mono2], auto simp: O_assoc) qed auto qed
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
rtrancl_O_shift
null
O_rtrancl_O_O: "R O (S O R)\<^sup>* O S = (R O S)\<^sup>+" by (unfold rtrancl_O_shift trancl_unfold_left, auto)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
O_rtrancl_O_O
null
SN_on_subset_SN_terms: assumes SN: "SN_on R X" shows "X \<subseteq> {x. SN_on R {x}}" proof(intro subsetI, unfold mem_Collect_eq) fix x assume x: "x \<in> X" show "SN_on R {x}" by (rule SN_on_subset2[OF _ SN], insert x, auto) qed
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
SN_on_subset_SN_terms
null
SN_on_Un2: assumes "SN_on R X" and "SN_on R Y" shows "SN_on R (X \<union> Y)" using assms by fast
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
SN_on_Un2
null
SN_on_UN: assumes "\<And>x. SN_on R (X x)" shows "SN_on R (\<Union>x. X x)" using assms by fast
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
SN_on_UN
null
Image_subsetI: "R \<subseteq> R' \<Longrightarrow> R `` X \<subseteq> R' `` X" by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
Image_subsetI
null
SN_on_O_comm: assumes SN: "SN_on ((R :: ('a\<times>'b) set) O (S :: ('b\<times>'a) set)) (S `` X)" shows "SN_on (S O R) X" proof fix seq :: "nat \<Rightarrow> 'b" assume seq0: "seq 0 \<in> X" and chain: "chain (S O R) seq" from SN have SN: "SN_on (R O S) ((R O S)\<^sup>* `` S `` X)" by simp { fix i a assume ia: "(seq i,a) \<in> S" and aSi: "(a,seq (Suc i)) \<in> R" have "seq i \<in> (S O R)\<^sup>* `` X" proof (induct i) case 0 from seq0 show ?case by auto next case (Suc i) with chain have "seq (Suc i) \<in> ((S O R)\<^sup>* O S O R) `` X" by blast also have "... \<subseteq> (S O R)\<^sup>* `` X" by (fold trancl_unfold_right, auto) finally show ?case. qed with ia have "a \<in> ((S O R)\<^sup>* O S) `` X" by auto then have a: "a \<in> ((R O S)\<^sup>*) `` S `` X" by (auto simp: rtrancl_O_shift) with ia aSi have False proof(induct "a" arbitrary: i rule: SN_on_induct[OF SN]) case 1 show ?case by (fact a) next case IH: (2 a) from chain obtain b where *: "(seq (Suc i), b) \<in> S" "(b, seq (Suc (Suc i))) \<in> R" by auto with IH have ab: "(a,b) \<in> R O S" by auto with \<open>a \<in> (R O S)\<^sup>* `` S `` X\<close> have "b \<in> ((R O S)\<^sup>* O R O S) `` S `` X" by auto then have "b \<in> (R O S)\<^sup>* `` S `` X" by (rule rev_subsetD, intro Image_subsetI, fold trancl_unfold_right, auto) from IH.hyps[OF ab * this] IH.prems ab show False by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
SN_on_O_comm
null
SN_O_comm: "SN (R O S) \<longleftrightarrow> SN (S O R)" by (intro iffI; rule SN_on_O_comm[OF SN_on_subset2], auto)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
SN_O_comm
null
chain_mono: assumes "R' \<subseteq> R" "chain R' seq" shows "chain R seq" using assms by auto context fixes S R assumes push: "S O R \<subseteq> R O S\<^sup>*" begin
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
chain_mono
null
rtrancl_O_push: "S\<^sup>* O R \<subseteq> R O S\<^sup>*" proof- { fix n have "\<And>s t. (s,t) \<in> S ^^ n O R \<Longrightarrow> (s,t) \<in> R O S\<^sup>*" proof(induct n) case (Suc n) then obtain u where "(s,u) \<in> S" "(u,t) \<in> R O S\<^sup>*" unfolding relpow_Suc by blast then have "(s,t) \<in> S O R O S\<^sup>*" by auto also have "... \<subseteq> R O S\<^sup>* O S\<^sup>*" using push by blast also have "... \<subseteq> R O S\<^sup>*" by auto finally show ?case. qed auto } thus ?thesis by blast qed
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
rtrancl_O_push
null
rtrancl_U_push: "(S \<union> R)\<^sup>* = R\<^sup>* O S\<^sup>*" proof(intro equalityI subrelI) fix x y assume "(x,y) \<in> (S \<union> R)\<^sup>*" also have "... \<subseteq> (S\<^sup>* O R)\<^sup>* O S\<^sup>*" by regexp finally obtain z where xz: "(x,z) \<in> (S\<^sup>* O R)\<^sup>*" and zy: "(z,y) \<in> S\<^sup>*" by auto from xz have "(x,z) \<in> R\<^sup>* O S\<^sup>*" proof (induct rule: rtrancl_induct) case (step z w) then have "(x,w) \<in> R\<^sup>* O S\<^sup>* O S\<^sup>* O R" by auto also have "... \<subseteq> R\<^sup>* O S\<^sup>* O R" by regexp also have "... \<subseteq> R\<^sup>* O R O S\<^sup>*" using rtrancl_O_push by auto also have "... \<subseteq> R\<^sup>* O S\<^sup>*" by regexp finally show ?case. qed auto with zy show "(x,y) \<in> R\<^sup>* O S\<^sup>*" by auto qed regexp
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
rtrancl_U_push
null
SN_on_O_push: assumes SN: "SN_on R X" shows "SN_on (R O S\<^sup>*) X" proof fix seq have SN: "SN_on R (R\<^sup>* `` X)" using SN_on_Image_rtrancl[OF SN]. moreover assume "seq (0::nat) \<in> X" then have "seq 0 \<in> R\<^sup>* `` X" by auto ultimately show "chain (R O S\<^sup>*) seq \<Longrightarrow> False" proof(induct "seq 0" arbitrary: seq rule: SN_on_induct) case IH then have 01: "(seq 0, seq 1) \<in> R O S\<^sup>*" and 12: "(seq 1, seq 2) \<in> R O S\<^sup>*" and 23: "(seq 2, seq 3) \<in> R O S\<^sup>*" by (auto simp: eval_nat_numeral) then obtain s t where s: "(seq 0, s) \<in> R" and s1: "(s, seq 1) \<in> S\<^sup>*" and t: "(seq 1, t) \<in> R" and t2: "(t, seq 2) \<in> S\<^sup>*" by auto from s1 t have "(s,t) \<in> S\<^sup>* O R" by auto with rtrancl_O_push have st: "(s,t) \<in> R O S\<^sup>*" by auto from t2 23 have "(t, seq 3) \<in> S\<^sup>* O R O S\<^sup>*" by auto also from rtrancl_O_push have "... \<subseteq> R O S\<^sup>* O S\<^sup>*" by blast finally have t3: "(t, seq 3) \<in> R O S\<^sup>*" by regexp let ?seq = "\<lambda>i. case i of 0 \<Rightarrow> s | Suc 0 \<Rightarrow> t | i \<Rightarrow> seq (Suc i)" show ?case proof(rule IH) from s show "(seq 0, ?seq 0) \<in> R" by auto show "chain (R O S\<^sup>*) ?seq" proof (intro allI) fix i show "(?seq i, ?seq (Suc i)) \<in> R O S\<^sup>*" proof (cases i) case 0 with st show ?thesis by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
SN_on_O_push
null
SN_on_Image_push: assumes SN: "SN_on R X" shows "SN_on R (S\<^sup>* `` X)" proof- { fix n have "SN_on R ((S^^n) `` X)" proof(induct n) case 0 from SN show ?case by auto case (Suc n) from SN_on_O_push[OF this] have "SN_on (R O S\<^sup>*) ((S ^^ n) `` X)". from SN_on_Image[OF this] have "SN_on (R O S\<^sup>*) ((R O S\<^sup>*) `` (S ^^ n) `` X)". then have "SN_on R ((R O S\<^sup>*) `` (S ^^ n) `` X)" by (rule SN_on_mono, auto) from SN_on_subset2[OF Image_mono[OF push subset_refl] this] have "SN_on R (R `` (S ^^ Suc n) `` X)" by (auto simp: relcomp_Image) then show ?case by fast qed } then show ?thesis by fast qed
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
SN_on_Image_push
null
not_SN_onI[intro]: "f 0 \<in> X \<Longrightarrow> chain R f \<Longrightarrow> \<not> SN_on R X" by (unfold SN_on_def not_not, intro exI conjI)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
not_SN_onI
null
shift_comp[simp]: "shift (f \<circ> seq) n = f \<circ> (shift seq n)" by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
shift_comp
null
Id_on_union: "Id_on (A \<union> B) = Id_on A \<union> Id_on B" unfolding Id_on_def by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
Id_on_union
null
relpow_union_cases: "(a,d) \<in> (A \<union> B)^^n \<Longrightarrow> (a,d) \<in> B^^n \<or> (\<exists> b c k m. (a,b) \<in> B^^k \<and> (b,c) \<in> A \<and> (c,d) \<in> (A \<union> B)^^m \<and> n = Suc (k + m))" proof (induct n arbitrary: a d) case (Suc n a e) let ?AB = "A \<union> B" from Suc(2) obtain b where ab: "(a,b) \<in> ?AB" and be: "(b,e) \<in> ?AB^^n" by (rule relpow_Suc_E2) from ab show ?case proof assume "(a,b) \<in> A" show ?thesis proof (rule disjI2, intro exI conjI) show "Suc n = Suc (0 + n)" by simp show "(a,b) \<in> A" by fact qed (insert be, auto) next assume ab: "(a,b) \<in> B" from Suc(1)[OF be] show ?thesis proof assume "(b,e) \<in> B ^^ n" with ab show ?thesis by (intro disjI1 relpow_Suc_I2) next assume "\<exists> c d k m. (b, c) \<in> B ^^ k \<and> (c, d) \<in> A \<and> (d, e) \<in> ?AB ^^ m \<and> n = Suc (k + m)" then obtain c d k m where "(b, c) \<in> B ^^ k" and *: "(c, d) \<in> A" "(d, e) \<in> ?AB ^^ m" "n = Suc (k + m)" by blast with ab have ac: "(a,c) \<in> B ^^ (Suc k)" by (intro relpow_Suc_I2) show ?thesis by (intro disjI2 exI conjI, rule ac, (rule *)+, simp add: *) qed qed
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
relpow_union_cases
null
trans_refl_imp_rtrancl_id: assumes "trans r" "refl r" shows "r\<^sup>* = r" proof show "r\<^sup>* \<subseteq> r" proof fix x y assume "(x,y) \<in> r\<^sup>*" thus "(x,y) \<in> r" by (induct, insert assms, unfold refl_on_def trans_def, blast+) qed qed regexp
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
trans_refl_imp_rtrancl_id
by (intro disjI2 exI conjI, rule ac, (rule +, simp add:
trans_refl_imp_O_id: assumes "trans r" "refl r" shows "r O r = r" proof(intro equalityI) show "r O r \<subseteq> r" by(fact trans_O_subset[OF assms(1)]) have "r \<subseteq> r O Id" by auto moreover have "Id \<subseteq> r" by(fact assms(2)[unfolded refl_O_iff]) ultimately show "r \<subseteq> r O r" by auto qed
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
trans_refl_imp_O_id
null
relcomp3_I: assumes "(t, u) \<in> A" and "(s, t) \<in> B" and "(u, v) \<in> B" shows "(s, v) \<in> B O A O B" using assms by blast
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
relcomp3_I
null
relcomp3_transI: assumes "trans B" and "(t, u) \<in> B O A O B" and "(s, t) \<in> B" and "(u, v) \<in> B" shows "(s, v) \<in> B O A O B" using assms by (auto simp: trans_def intro: relcomp3_I) lemmas converse_inward = rtrancl_converse[symmetric] converse_Un converse_UNION converse_relcomp converse_converse converse_Id
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
relcomp3_transI
null
qc_SN_relto_iff: assumes "r O s \<subseteq> s O (s \<union> r)\<^sup>*" shows "SN (r\<^sup>* O s O r\<^sup>*) = SN s" proof - from converse_mono [THEN iffD2 , OF assms] have *: "s\<inverse> O r\<inverse> \<subseteq> (s\<inverse> \<union> r\<inverse>)\<^sup>* O s\<inverse>" unfolding converse_inward . have "(r\<^sup>* O s O r\<^sup>*)\<inverse> = (r\<inverse>)\<^sup>* O s\<inverse> O (r\<inverse>)\<^sup>*" by (simp only: converse_relcomp O_assoc rtrancl_converse) with qc_wf_relto_iff [OF *] show ?thesis by (simp add: SN_iff_wf) qed
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
qc_SN_relto_iff
null
conversion_empty[simp]: "conversion {} = Id" by (auto simp: conversion_def)
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
conversion_empty
null
symcl_idemp[simp]: "(r\<^sup>\<leftrightarrow>)\<^sup>\<leftrightarrow> = r\<^sup>\<leftrightarrow>" by auto
lemma
Abstract-Rewriting
[ "HOL-Library.Infinite_Set", "Regular-Sets.Regexp_Method", "Seq" ]
Abstract-Rewriting/Abstract_Rewriting.thy
symcl_idemp
null
SN_rel_on:: "'a rel \<Rightarrow> 'a rel \<Rightarrow> 'a set \<Rightarrow> bool" where "SN_rel_on R S \<equiv> SN_on (relto R S)"
definition
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on
null
SN_rel_on_alt:: "'a rel \<Rightarrow> 'a rel \<Rightarrow> 'a set \<Rightarrow> bool" where "SN_rel_on_alt R S T = (\<forall>f. chain (R \<union> S) f \<and> f 0 \<in> T \<longrightarrow> \<not> (INFM j. (f j, f (Suc j)) \<in> R))"
definition
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_alt
null
SN_rel:: "'a rel \<Rightarrow> 'a rel \<Rightarrow> bool" where "SN_rel R S \<equiv> SN_rel_on R S UNIV"
abbreviation
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel
null
SN_rel_alt:: "'a rel \<Rightarrow> 'a rel \<Rightarrow> bool" where "SN_rel_alt R S \<equiv> SN_rel_on_alt R S UNIV"
abbreviation
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_alt
null
relto_absorb[simp]: "relto R E O E\<^sup>* = relto R E" "E\<^sup>* O relto R E = relto R E" using O_assoc and rtrancl_idemp_self_comp by (metis)+
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_absorb
null
steps_preserve_SN_on_relto: assumes steps: "(a, b) \<in> (R \<union> S)^*" and SN: "SN_on (relto R S) {a}" shows "SN_on (relto R S) {b}" proof - let ?RS = "relto R S" have "(R \<union> S)^* \<subseteq> S^* \<union> ?RS^*" by regexp with steps have "(a,b) \<in> S^* \<or> (a,b) \<in> ?RS^*" by auto thus ?thesis proof assume "(a,b) \<in> ?RS^*" from steps_preserve_SN_on[OF this SN] show ?thesis . next assume Ssteps: "(a,b) \<in> S^*" show ?thesis proof fix f assume "f 0 \<in> {b}" and "chain ?RS f" hence f0: "f 0 = b" and steps: "\<And>i. (f i, f (Suc i)) \<in> ?RS" by auto let ?g = "\<lambda> i. if i = 0 then a else f i" have "\<not> SN_on ?RS {a}" unfolding SN_on_def not_not proof (rule exI[of _ ?g], intro conjI allI) fix i show "(?g i, ?g (Suc i)) \<in> ?RS" proof (cases i) case (Suc j) show ?thesis using steps[of i] unfolding Suc by simp next case 0 from steps[of 0, unfolded f0] Ssteps have steps: "(a,f (Suc 0)) \<in> S^* O ?RS" by blast
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
steps_preserve_SN_on_relto
null
step_preserves_SN_on_relto: assumes st: "(s,t) \<in> R \<union> E" and SN: "SN_on (relto R E) {s}" shows "SN_on (relto R E) {t}" by (rule steps_preserve_SN_on_relto[OF _ SN], insert st, auto)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
step_preserves_SN_on_relto
null
SN_rel_on_imp_SN_rel_on_alt: "SN_rel_on R S T \<Longrightarrow> SN_rel_on_alt R S T" proof (unfold SN_rel_on_def) assume SN: "SN_on (relto R S) T" show ?thesis proof (unfold SN_rel_on_alt_def, intro allI impI) fix f assume steps: "chain (R \<union> S) f \<and> f 0 \<in> T" with SN have SN: "SN_on (relto R S) {f 0}" and steps: "\<And> i. (f i, f (Suc i)) \<in> R \<union> S" unfolding SN_defs by auto obtain r where r: "\<And> j. r j \<equiv> (f j, f (Suc j)) \<in> R" by auto show "\<not> (INFM j. (f j, f (Suc j)) \<in> R)" proof (rule ccontr) assume "\<not> ?thesis" hence ih: "infinitely_many r" unfolding infinitely_many_def r by blast obtain r_index where "r_index = infinitely_many.index r" by simp with infinitely_many.index_p[OF ih] infinitely_many.index_ordered[OF ih] infinitely_many.index_not_p_between[OF ih] have r_index: "\<And> i. r (r_index i) \<and> r_index i < r_index (Suc i) \<and> (\<forall> j. r_index i < j \<and> j < r_index (Suc i) \<longrightarrow> \<not> r j)" by auto obtain g where g: "\<And> i. g i \<equiv> f (r_index i)" .. { fix i let ?ri = "r_index i" let ?rsi = "r_index (Suc i)" from r_index have isi: "?ri < ?rsi" by auto obtain ri rsi where ri: "ri = ?ri" and rsi: "rsi = ?rsi" by auto with r_index[of i] steps have inter: "\<And> j. ri < j \<and> j < rsi \<Longrightarrow> (f j, f (Suc j)) \<in> S" unfolding r by auto from ri isi rsi have risi: "ri < rsi" by simp { fix n assume "Suc n \<le> rsi - ri" hence "(f (Suc ri), f (Suc (n + ri))) \<in> S^*"
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_imp_SN_rel_on_alt
null
SN_rel_on_alt_imp_SN_rel_on: "SN_rel_on_alt R S T \<Longrightarrow> SN_rel_on R S T" proof (unfold SN_rel_on_def) assume SN: "SN_rel_on_alt R S T" show "SN_on (relto R S) T" proof fix f assume start: "f 0 \<in> T" and "chain (relto R S) f" hence steps: "\<And> i. (f i, f (Suc i)) \<in> S^* O R O S^*" by auto let ?prop = "\<lambda> i ai bi. (f i, bi) \<in> S^* \<and> (bi, ai) \<in> R \<and> (ai, f (Suc (i))) \<in> S^*" { fix i from steps obtain bi ai where "?prop i ai bi" by blast hence "\<exists> ai bi. ?prop i ai bi" by blast } hence "\<forall> i. \<exists> bi ai. ?prop i ai bi" by blast from choice[OF this] obtain b where "\<forall> i. \<exists> ai. ?prop i ai (b i)" by blast from choice[OF this] obtain a where steps: "\<And> i. ?prop i (a i) (b i)" by blast from steps[of 0] have fa0: "(f 0, a 0) \<in> S^* O R" by auto let ?prop = "\<lambda> i li. (b i, a i) \<in> R \<and> (\<forall> j < length li. ((a i # li) ! j, (a i # li) ! Suc j) \<in> S) \<and> last (a i # li) = b (Suc i)" { fix i from steps[of i] steps[of "Suc i"] have "(a i, f (Suc i)) \<in> S^*" and "(f (Suc i), b (Suc i)) \<in> S^*" by auto from rtrancl_trans[OF this] steps[of i] have R: "(b i, a i) \<in> R" and S: "(a i, b (Suc i)) \<in> S^*" by blast+ from S[unfolded rtrancl_list_conv] obtain li where "last (a i # li) = b (Suc i) \<and> (\<forall> j < length li. ((a i # li) ! j, (a i # li) ! Suc j) \<in> S)" .. with R have "?prop i li" by blast hence "\<exists> li. ?prop i li" .. } hence "\<forall> i. \<exists> li. ?prop i li" .. from choice[OF this] obtain l where steps: "\<And> i. ?prop i (l i)" by auto let ?p = "\<lambda> i. ?prop i (l i)"
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_alt_imp_SN_rel_on
null
SN_rel_on_conv: "SN_rel_on = SN_rel_on_alt" by (intro ext) (blast intro: SN_rel_on_imp_SN_rel_on_alt SN_rel_on_alt_imp_SN_rel_on) lemmas SN_rel_defs = SN_rel_on_def SN_rel_on_alt_def
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_conv
null
SN_rel_on_alt_r_empty: "SN_rel_on_alt {} S T" unfolding SN_rel_defs by auto
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_alt_r_empty
null
SN_rel_on_alt_s_empty: "SN_rel_on_alt R {} = SN_on R" by (intro ext, unfold SN_rel_defs SN_defs, auto)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_alt_s_empty
null
SN_rel_on_mono': assumes R: "R \<subseteq> R'" and S: "S \<subseteq> R' \<union> S'" and SN: "SN_rel_on R' S' T" shows "SN_rel_on R S T" proof - note conv = SN_rel_on_conv SN_rel_on_alt_def INFM_nat_le show ?thesis unfolding conv proof(intro allI impI) fix f assume "chain (R \<union> S) f \<and> f 0 \<in> T" with R S have "chain (R' \<union> S') f \<and> f 0 \<in> T" by auto from SN[unfolded conv, rule_format, OF this] show "\<not> (\<forall> m. \<exists> n \<ge> m. (f n, f (Suc n)) \<in> R)" using R by auto qed qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_mono'
null
relto_mono: assumes "R \<subseteq> R'" and "S \<subseteq> S'" shows "relto R S \<subseteq> relto R' S'" using assms rtrancl_mono by blast
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_mono
null
SN_rel_on_mono: assumes R: "R \<subseteq> R'" and S: "S \<subseteq> S'" and SN: "SN_rel_on R' S' T" shows "SN_rel_on R S T" using SN unfolding SN_rel_on_def using SN_on_mono[OF _ relto_mono[OF R S]] by blast lemmas SN_rel_on_alt_mono = SN_rel_on_mono[unfolded SN_rel_on_conv]
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_mono
null
SN_rel_on_imp_SN_on: assumes "SN_rel_on R S T" shows "SN_on R T" proof fix f assume "chain R f" and f0: "f 0 \<in> T" hence "\<And>i. (f i, f (Suc i)) \<in> relto R S" by blast thus False using assms f0 unfolding SN_rel_on_def SN_defs by blast qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_imp_SN_on
null
relto_Id: "relto R (S \<union> Id) = relto R S" by simp
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_Id
null
SN_rel_on_Id: shows "SN_rel_on R (S \<union> Id) T = SN_rel_on R S T" unfolding SN_rel_on_def by (simp only: relto_Id)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_Id
null
SN_rel_on_empty[simp]: "SN_rel_on R {} T = SN_on R T" unfolding SN_rel_on_def by auto
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_empty
null
SN_rel_on_ideriv: "SN_rel_on R S T = (\<not> (\<exists> as. ideriv R S as \<and> as 0 \<in> T))" (is "?L = ?R") proof assume ?L show ?R proof assume "\<exists> as. ideriv R S as \<and> as 0 \<in> T" then obtain as where id: "ideriv R S as" and T: "as 0 \<in> T" by auto note id = id[unfolded ideriv_def] from \<open>?L\<close>[unfolded SN_rel_on_conv SN_rel_on_alt_def, THEN spec[of _ as]] id T obtain i where i: "\<And> j. j \<ge> i \<Longrightarrow> (as j, as (Suc j)) \<notin> R" by auto with id[unfolded INFM_nat, THEN conjunct2, THEN spec[of _ "Suc i"]] show False by auto qed next assume ?R show ?L unfolding SN_rel_on_conv SN_rel_on_alt_def proof(intro allI impI) fix as assume "chain (R \<union> S) as \<and> as 0 \<in> T" with \<open>?R\<close>[unfolded ideriv_def] have "\<not> (INFM i. (as i, as (Suc i)) \<in> R)" by auto from this[unfolded INFM_nat] obtain i where i: "\<And>j. i < j \<Longrightarrow> (as j, as (Suc j)) \<notin> R" by auto show "\<not> (INFM j. (as j, as (Suc j)) \<in> R)" unfolding INFM_nat using i by blast qed qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_on_ideriv
null
SN_rel_to_SN_rel_alt: "SN_rel R S \<Longrightarrow> SN_rel_alt R S" proof (unfold SN_rel_on_def) assume SN: "SN (relto R S)" show ?thesis proof (unfold SN_rel_on_alt_def, intro allI impI) fix f presume steps: "chain (R \<union> S) f" obtain r where r: "\<And>j. r j \<equiv> (f j, f (Suc j)) \<in> R" by auto show "\<not> (INFM j. (f j, f (Suc j)) \<in> R)" proof (rule ccontr) assume "\<not> ?thesis" hence ih: "infinitely_many r" unfolding infinitely_many_def r by blast obtain r_index where "r_index = infinitely_many.index r" by simp with infinitely_many.index_p[OF ih] infinitely_many.index_ordered[OF ih] infinitely_many.index_not_p_between[OF ih] have r_index: "\<And> i. r (r_index i) \<and> r_index i < r_index (Suc i) \<and> (\<forall> j. r_index i < j \<and> j < r_index (Suc i) \<longrightarrow> \<not> r j)" by auto obtain g where g: "\<And> i. g i \<equiv> f (r_index i)" .. { fix i let ?ri = "r_index i" let ?rsi = "r_index (Suc i)" from r_index have isi: "?ri < ?rsi" by auto obtain ri rsi where ri: "ri = ?ri" and rsi: "rsi = ?rsi" by auto with r_index[of i] steps have inter: "\<And> j. ri < j \<and> j < rsi \<Longrightarrow> (f j, f (Suc j)) \<in> S" unfolding r by auto from ri isi rsi have risi: "ri < rsi" by simp { fix n assume "Suc n \<le> rsi - ri" hence "(f (Suc ri), f (Suc (n + ri))) \<in> S^*" proof (induct n, simp) case (Suc n)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_to_SN_rel_alt
null
SN_rel_alt_to_SN_rel: "SN_rel_alt R S \<Longrightarrow> SN_rel R S" proof (unfold SN_rel_on_def) assume SN: "SN_rel_alt R S" show "SN (relto R S)" proof fix f assume "chain (relto R S) f" hence steps: "\<And>i. (f i, f (Suc i)) \<in> S^* O R O S^*" by auto let ?prop = "\<lambda> i ai bi. (f i, bi) \<in> S^* \<and> (bi, ai) \<in> R \<and> (ai, f (Suc (i))) \<in> S^*" { fix i from steps obtain bi ai where "?prop i ai bi" by blast hence "\<exists> ai bi. ?prop i ai bi" by blast } hence "\<forall> i. \<exists> bi ai. ?prop i ai bi" by blast from choice[OF this] obtain b where "\<forall> i. \<exists> ai. ?prop i ai (b i)" by blast from choice[OF this] obtain a where steps: "\<And> i. ?prop i (a i) (b i)" by blast let ?prop = "\<lambda> i li. (b i, a i) \<in> R \<and> (\<forall> j < length li. ((a i # li) ! j, (a i # li) ! Suc j) \<in> S) \<and> last (a i # li) = b (Suc i)" { fix i from steps[of i] steps[of "Suc i"] have "(a i, f (Suc i)) \<in> S^*" and "(f (Suc i), b (Suc i)) \<in> S^*" by auto from rtrancl_trans[OF this] steps[of i] have R: "(b i, a i) \<in> R" and S: "(a i, b (Suc i)) \<in> S^*" by blast+ from S[unfolded rtrancl_list_conv] obtain li where "last (a i # li) = b (Suc i) \<and> (\<forall> j < length li. ((a i # li) ! j, (a i # li) ! Suc j) \<in> S)" .. with R have "?prop i li" by blast hence "\<exists> li. ?prop i li" .. } hence "\<forall> i. \<exists> li. ?prop i li" .. from choice[OF this] obtain l where steps: "\<And> i. ?prop i (l i)" by auto let ?p = "\<lambda> i. ?prop i (l i)" from steps have steps: "\<And> i. ?p i" by blast
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_alt_to_SN_rel
null
SN_rel_alt_r_empty: "SN_rel_alt {} S" unfolding SN_rel_defs by auto
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_alt_r_empty
null
SN_rel_alt_s_empty: "SN_rel_alt R {} = SN R" unfolding SN_rel_defs SN_defs by auto
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_alt_s_empty
null
SN_rel_mono': "R \<subseteq> R' \<Longrightarrow> S \<subseteq> R' \<union> S' \<Longrightarrow> SN_rel R' S' \<Longrightarrow> SN_rel R S" unfolding SN_rel_on_conv SN_rel_defs INFM_nat_le by (metis contra_subsetD sup.left_idem sup.mono)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_mono'
null
SN_rel_mono: assumes R: "R \<subseteq> R'" and S: "S \<subseteq> S'" and SN: "SN_rel R' S'" shows "SN_rel R S" using SN unfolding SN_rel_defs using SN_subset[OF _ relto_mono[OF R S]] by blast lemmas SN_rel_alt_mono = SN_rel_mono[unfolded SN_rel_on_conv]
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_mono
null
SN_rel_imp_SN: assumes "SN_rel R S" shows "SN R" proof fix f assume "\<forall> i. (f i, f (Suc i)) \<in> R" hence "\<And> i. (f i, f (Suc i)) \<in> relto R S" by blast thus False using assms unfolding SN_rel_defs SN_defs by fast qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_imp_SN
null
relto_trancl_conv: "(relto R S)^+ = ((R \<union> S))^* O R O ((R \<union> S))^*" by regexp
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_trancl_conv
null
SN_rel_Id: shows "SN_rel R (S \<union> Id) = SN_rel R S" unfolding SN_rel_defs by (simp only: relto_Id)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_Id
null
relto_rtrancl: "relto R (S^*) = relto R S" by regexp
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_rtrancl
null
SN_rel_empty[simp]: "SN_rel R {} = SN R" unfolding SN_rel_defs by auto
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_empty
null
SN_rel_ideriv: "SN_rel R S = (\<not> (\<exists> as. ideriv R S as))" (is "?L = ?R") proof assume ?L show ?R proof assume "\<exists> as. ideriv R S as" then obtain as where id: "ideriv R S as" by auto note id = id[unfolded ideriv_def] from \<open>?L\<close>[unfolded SN_rel_on_conv SN_rel_defs, THEN spec[of _ as]] id obtain i where i: "\<And> j. j \<ge> i \<Longrightarrow> (as j, as (Suc j)) \<notin> R" by auto with id[unfolded INFM_nat, THEN conjunct2, THEN spec[of _ "Suc i"]] show False by auto qed next assume ?R show ?L unfolding SN_rel_on_conv SN_rel_defs proof (intro allI impI) fix as presume "chain (R \<union> S) as" with \<open>?R\<close>[unfolded ideriv_def] have "\<not> (INFM i. (as i, as (Suc i)) \<in> R)" by auto from this[unfolded INFM_nat] obtain i where i: "\<And> j. i < j \<Longrightarrow> (as j, as (Suc j)) \<notin> R" by auto show "\<not> (INFM j. (as j, as (Suc j)) \<in> R)" unfolding INFM_nat using i by blast qed simp qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ideriv
null
SN_rel_map: fixes R Rw R' Rw' :: "'a rel" defines A: "A \<equiv> R' \<union> Rw'" assumes SN: "SN_rel R' Rw'" and R: "\<And>s t. (s,t) \<in> R \<Longrightarrow> (f s, f t) \<in> A^* O R' O A^*" and Rw: "\<And>s t. (s,t) \<in> Rw \<Longrightarrow> (f s, f t) \<in> A^*" shows "SN_rel R Rw" unfolding SN_rel_defs proof fix g assume steps: "chain (relto R Rw) g" let ?f = "\<lambda>i. (f (g i))" obtain h where h: "h = ?f" by auto { fix i let ?m = "\<lambda> (x,y). (f x, f y)" { fix s t assume "(s,t) \<in> Rw^*" hence "?m (s,t) \<in> A^*" proof (induct) case base show ?case by simp next case (step t u) from Rw[OF step(2)] step(3) show ?case by auto qed } note Rw = this from steps have "(g i, g (Suc i)) \<in> relto R Rw" .. from this
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_map
null
SN_rel_ext_type= top_s | top_ns | normal_s | normal_ns
datatype
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ext_type
null
SN_rel_ext_step:: "'a rel \<Rightarrow> 'a rel \<Rightarrow> 'a rel \<Rightarrow> 'a rel \<Rightarrow> SN_rel_ext_type \<Rightarrow> 'a rel" where "SN_rel_ext_step P Pw R Rw top_s = P" | "SN_rel_ext_step P Pw R Rw top_ns = Pw" | "SN_rel_ext_step P Pw R Rw normal_s = R" | "SN_rel_ext_step P Pw R Rw normal_ns = Rw"
fun
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ext_step
null
SN_rel_ext:: "'a rel \<Rightarrow> 'a rel \<Rightarrow> 'a rel \<Rightarrow> 'a rel \<Rightarrow> ('a \<Rightarrow> bool) \<Rightarrow> bool" where "SN_rel_ext P Pw R Rw M \<equiv> (\<not> (\<exists>f t. (\<forall> i. (f i, f (Suc i)) \<in> SN_rel_ext_step P Pw R Rw (t i)) \<and> (\<forall> i. M (f i)) \<and> (INFM i. t i \<in> {top_s,top_ns}) \<and> (INFM i. t i \<in> {top_s,normal_s})))"
definition
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ext
relative termination with four relations as required in DP-framework
SN_rel_ext_step_mono: assumes "P \<subseteq> P'" "Pw \<subseteq> Pw'" "R \<subseteq> R'" "Rw \<subseteq> Rw'" shows "SN_rel_ext_step P Pw R Rw t \<subseteq> SN_rel_ext_step P' Pw' R' Rw' t" using assms by (cases t, auto)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ext_step_mono
null
SN_rel_ext_mono: assumes subset: "P \<subseteq> P'" "Pw \<subseteq> Pw'" "R \<subseteq> R'" "Rw \<subseteq> Rw'" and SN: "SN_rel_ext P' Pw' R' Rw' M" shows "SN_rel_ext P Pw R Rw M" using SN_rel_ext_step_mono[OF subset] SN unfolding SN_rel_ext_def by blast
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ext_mono
null
SN_rel_ext_trans: fixes P Pw R Rw :: "'a rel" and M :: "'a \<Rightarrow> bool" defines M': "M' \<equiv> {(s,t). M t}" defines A: "A \<equiv> (P \<union> Pw \<union> R \<union> Rw) \<inter> M'" assumes "SN_rel_ext P Pw R Rw M" shows "SN_rel_ext (A^* O (P \<inter> M') O A^*) (A^* O ((P \<union> Pw) \<inter> M') O A^*) (A^* O ((P \<union> R) \<inter> M') O A^*) (A^*) M" (is "SN_rel_ext ?P ?Pw ?R ?Rw M") proof (rule ccontr) let ?relt = "SN_rel_ext_step ?P ?Pw ?R ?Rw" let ?rel = "SN_rel_ext_step P Pw R Rw" assume "\<not> ?thesis" from this[unfolded SN_rel_ext_def] obtain f ty where steps: "\<And> i. (f i, f (Suc i)) \<in> ?relt (ty i)" and min: "\<And> i. M (f i)" and inf1: "INFM i. ty i \<in> {top_s, top_ns}" and inf2: "INFM i. ty i \<in> {top_s, normal_s}" by auto let ?Un = "\<lambda> tt. \<Union> (?rel ` tt)" let ?UnM = "\<lambda> tt. (\<Union> (?rel ` tt)) \<inter> M'" let ?A = "?UnM {top_s,top_ns,normal_s,normal_ns}" let ?P' = "?UnM {top_s}" let ?Pw' = "?UnM {top_s,top_ns}" let ?R' = "?UnM {top_s,normal_s}" let ?Rw' = "?UnM {top_s,top_ns,normal_s,normal_ns}" have A: "A = ?A" unfolding A by auto have P: "(P \<inter> M') = ?P'" by auto have Pw: "(P \<union> Pw) \<inter> M' = ?Pw'" by auto have R: "(P \<union> R) \<inter> M' = ?R'" by auto have Rw: "A = ?Rw'" unfolding A .. {
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ext_trans
null
SN_rel_ext_map: fixes P Pw R Rw P' Pw' R' Rw' :: "'a rel" and M M' :: "'a \<Rightarrow> bool" defines Ms: "Ms \<equiv> {(s,t). M' t}" defines A: "A \<equiv> (P' \<union> Pw' \<union> R' \<union> Rw') \<inter> Ms" assumes SN: "SN_rel_ext P' Pw' R' Rw' M'" and P: "\<And> s t. M s \<Longrightarrow> M t \<Longrightarrow> (s,t) \<in> P \<Longrightarrow> (f s, f t) \<in> (A^* O (P' \<inter> Ms) O A^*) \<and> I t" and Pw: "\<And> s t. M s \<Longrightarrow> M t \<Longrightarrow> (s,t) \<in> Pw \<Longrightarrow> (f s, f t) \<in> (A^* O ((P' \<union> Pw') \<inter> Ms) O A^*) \<and> I t" and R: "\<And> s t. I s \<Longrightarrow> M s \<Longrightarrow> M t \<Longrightarrow> (s,t) \<in> R \<Longrightarrow> (f s, f t) \<in> (A^* O ((P' \<union> R') \<inter> Ms) O A^*) \<and> I t" and Rw: "\<And> s t. I s \<Longrightarrow> M s \<Longrightarrow> M t \<Longrightarrow> (s,t) \<in> Rw \<Longrightarrow> (f s, f t) \<in> A^* \<and> I t" shows "SN_rel_ext P Pw R Rw M" proof - note SN = SN_rel_ext_trans[OF SN] let ?P = "(A^* O (P' \<inter> Ms) O A^*)" let ?Pw = "(A^* O ((P' \<union> Pw') \<inter> Ms) O A^*)" let ?R = "(A^* O ((P' \<union> R') \<inter> Ms) O A^*)" let ?Rw = "A^*" let ?relt = "SN_rel_ext_step ?P ?Pw ?R ?Rw" let ?rel = "SN_rel_ext_step P Pw R Rw" show ?thesis proof (rule ccontr) assume "\<not> ?thesis" from this[unfolded SN_rel_ext_def] obtain g ty where steps: "\<And> i. (g i, g (Suc i)) \<in> ?rel (ty i)" and min: "\<And> i. M (g i)" and inf1: "INFM i. ty i \<in> {top_s, top_ns}" and inf2: "INFM i. ty i \<in> {top_s, normal_s}" by auto from inf1[unfolded INFM_nat] obtain k where k: "ty k \<in> {top_s, top_ns}" by auto let ?k = "Suc k" let ?i = "shift id ?k"
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ext_map
null
SN_rel_ext_map_min: fixes P Pw R Rw P' Pw' R' Rw' :: "'a rel" and M M' :: "'a \<Rightarrow> bool" defines Ms: "Ms \<equiv> {(s,t). M' t}" defines A: "A \<equiv> P' \<inter> Ms \<union> Pw' \<inter> Ms \<union> R' \<union> Rw'" assumes SN: "SN_rel_ext P' Pw' R' Rw' M'" and M: "\<And> t. M t \<Longrightarrow> M' (f t)" and M': "\<And> s t. M' s \<Longrightarrow> (s,t) \<in> R' \<union> Rw' \<Longrightarrow> M' t" and P: "\<And> s t. M s \<Longrightarrow> M t \<Longrightarrow> M' (f s) \<Longrightarrow> M' (f t) \<Longrightarrow> (s,t) \<in> P \<Longrightarrow> (f s, f t) \<in> (A^* O (P' \<inter> Ms) O A^*) \<and> I t" and Pw: "\<And> s t. M s \<Longrightarrow> M t \<Longrightarrow> M' (f s) \<Longrightarrow> M' (f t) \<Longrightarrow> (s,t) \<in> Pw \<Longrightarrow> (f s, f t) \<in> (A^* O (P' \<inter> Ms \<union> Pw' \<inter> Ms) O A^*) \<and> I t" and R: "\<And> s t. I s \<Longrightarrow> M s \<Longrightarrow> M t \<Longrightarrow> M' (f s) \<Longrightarrow> M' (f t) \<Longrightarrow> (s,t) \<in> R \<Longrightarrow> (f s, f t) \<in> (A^* O (P' \<inter> Ms \<union> R') O A^*) \<and> I t" and Rw: "\<And> s t. I s \<Longrightarrow> M s \<Longrightarrow> M t \<Longrightarrow> M' (f s) \<Longrightarrow> M' (f t) \<Longrightarrow> (s,t) \<in> Rw \<Longrightarrow> (f s, f t) \<in> A^* \<and> I t" shows "SN_rel_ext P Pw R Rw M" proof - let ?Ms = "{(s,t). M' t}" let ?A = "(P' \<union> Pw' \<union> R' \<union> Rw') \<inter> ?Ms" { fix s t assume s: "M' s" and "(s,t) \<in> A" with M'[OF s, of t] have "(s,t) \<in> ?A \<and> M' t" unfolding Ms A by auto } note Aone = this { fix s t assume s: "M' s" and steps: "(s,t) \<in> A^*" from steps have "(s,t) \<in> ?A^* \<and> M' t" proof (induct) case base from s show ?case by simp next case (step t u) note one = Aone[OF step(3)[THEN conjunct2] step(2)] from step(3) one have steps: "(s,u) \<in> ?A^* O ?A" by blast
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_ext_map_min
and a version where it is assumed that f always preserves M and that R' and Rw' preserve M'
SN_relto_imp_SN_rel: "SN (relto R S) \<Longrightarrow> SN_rel R S" proof - assume SN: "SN (relto R S)" show ?thesis proof (simp only: SN_rel_on_conv SN_rel_defs, intro allI impI) fix f presume steps: "chain (R \<union> S) f" obtain r where r: "\<And> j. r j \<equiv> (f j, f (Suc j)) \<in> R" by auto show "\<not> (INFM j. (f j, f (Suc j)) \<in> R)" proof (rule ccontr) assume "\<not> ?thesis" hence ih: "infinitely_many r" unfolding infinitely_many_def r INFM_nat_le by blast obtain r_index where "r_index = infinitely_many.index r" by simp with infinitely_many.index_p[OF ih] infinitely_many.index_ordered[OF ih] infinitely_many.index_not_p_between[OF ih] have r_index: "\<And> i. r (r_index i) \<and> r_index i < r_index (Suc i) \<and> (\<forall> j. r_index i < j \<and> j < r_index (Suc i) \<longrightarrow> \<not> r j)" by auto obtain g where g: "\<And> i. g i \<equiv> f (r_index i)" .. { fix i let ?ri = "r_index i" let ?rsi = "r_index (Suc i)" from r_index have isi: "?ri < ?rsi" by auto obtain ri rsi where ri: "ri = ?ri" and rsi: "rsi = ?rsi" by auto with r_index[of i] steps have inter: "\<And> j. ri < j \<and> j < rsi \<Longrightarrow> (f j, f (Suc j)) \<in> S" unfolding r by auto from ri isi rsi have risi: "ri < rsi" by simp { fix n assume "Suc n \<le> rsi - ri" hence "(f (Suc ri), f (Suc (n + ri))) \<in> S^*" proof (induct n, simp) case (Suc n)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_relto_imp_SN_rel
OLD PART
rtrancl_list_conv: "((s,t) \<in> R^*) = (\<exists>list. last (s # list) = t \<and> (\<forall>i. i < length list \<longrightarrow> ((s # list) ! i, (s # list) ! Suc i) \<in> R))" (is "?l = ?r") proof assume ?r then obtain list where "last (s # list) = t \<and> (\<forall> i. i < length list \<longrightarrow> ((s # list) ! i, (s # list) ! Suc i) \<in> R)" .. thus ?l proof (induct list arbitrary: s, simp) case (Cons u ll) hence "last (u # ll) = t \<and> (\<forall> i. i < length ll \<longrightarrow> ((u # ll) ! i, (u # ll) ! Suc i) \<in> R)" by auto from Cons(1)[OF this] have rec: "(u,t) \<in> R^*" . from Cons have "(s, u) \<in> R" by auto with rec show ?case by auto qed next assume ?l from rtrancl_imp_seq[OF this] obtain S n where s: "S 0 = s" and t: "S n = t" and steps: "\<forall> i<n. (S i, S (Suc i)) \<in> R" by auto let ?list = "map (\<lambda> i. S (Suc i)) [0 ..< n]" show ?r proof (rule exI[of _ ?list], intro conjI, cases n, simp add: s[symmetric] t[symmetric], simp add: t[symmetric]) show "\<forall> i < length ?list. ((s # ?list) ! i, (s # ?list) ! Suc i) \<in> R" proof (intro allI impI) fix i assume i: "i < length ?list" thus "((s # ?list) ! i, (s # ?list) ! Suc i) \<in> R" proof (cases i, simp add: s[symmetric] steps) case (Suc j) with i steps show ?thesis by simp
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
rtrancl_list_conv
FIXME: move
choice:: "(nat \<Rightarrow> 'a list) \<Rightarrow> nat \<Rightarrow> (nat \<times> nat)" where "choice f 0 = (0,0)" | "choice f (Suc n) = (let (i, j) = choice f n in if Suc j < length (f i) then (i, Suc j) else (Suc i, 0))"
fun
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
choice
null
SN_rel_imp_SN_relto: "SN_rel R S \<Longrightarrow> SN (relto R S)" proof - assume SN: "SN_rel R S" show "SN (relto R S)" proof fix f assume "\<forall> i. (f i, f (Suc i)) \<in> relto R S" hence steps: "\<And> i. (f i, f (Suc i)) \<in> S^* O R O S^*" by auto let ?prop = "\<lambda> i ai bi. (f i, bi) \<in> S^* \<and> (bi, ai) \<in> R \<and> (ai, f (Suc (i))) \<in> S^*" { fix i from steps obtain bi ai where "?prop i ai bi" by blast hence "\<exists> ai bi. ?prop i ai bi" by blast } hence "\<forall> i. \<exists> bi ai. ?prop i ai bi" by blast from choice[OF this] obtain b where "\<forall> i. \<exists> ai. ?prop i ai (b i)" by blast from choice[OF this] obtain a where steps: "\<And> i. ?prop i (a i) (b i)" by blast let ?prop = "\<lambda> i li. (b i, a i) \<in> R \<and> (\<forall> j < length li. ((a i # li) ! j, (a i # li) ! Suc j) \<in> S) \<and> last (a i # li) = b (Suc i)" { fix i from steps[of i] steps[of "Suc i"] have "(a i, f (Suc i)) \<in> S^*" and "(f (Suc i), b (Suc i)) \<in> S^*" by auto from rtrancl_trans[OF this] steps[of i] have R: "(b i, a i) \<in> R" and S: "(a i, b (Suc i)) \<in> S^*" by blast+ from S[unfolded rtrancl_list_conv] obtain li where "last (a i # li) = b (Suc i) \<and> (\<forall> j < length li. ((a i # li) ! j, (a i # li) ! Suc j) \<in> S)" .. with R have "?prop i li" by blast hence "\<exists> li. ?prop i li" .. } hence "\<forall> i. \<exists> li. ?prop i li" .. from choice[OF this] obtain l where steps: "\<And> i. ?prop i (l i)" by auto let ?p = "\<lambda> i. ?prop i (l i)" from steps have steps: "\<And> i. ?p i" by blast
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_imp_SN_relto
null
SN_relto_SN_rel_conv: "SN (relto R S) = SN_rel R S" by (blast intro: SN_relto_imp_SN_rel SN_rel_imp_SN_relto)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_relto_SN_rel_conv
null
SN_rel_empty1: "SN_rel {} S" unfolding SN_rel_defs by auto
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_empty1
null
SN_rel_empty2: "SN_rel R {} = SN R" unfolding SN_rel_defs SN_defs by auto
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_rel_empty2
null
SN_relto_mono: assumes R: "R \<subseteq> R'" and S: "S \<subseteq> S'" and SN: "SN (relto R' S')" shows "SN (relto R S)" using SN SN_subset[OF _ relto_mono[OF R S]] by blast
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_relto_mono
null
SN_relto_imp_SN: assumes "SN (relto R S)" shows "SN R" proof fix f assume "\<forall>i. (f i, f (Suc i)) \<in> R" hence "\<And>i. (f i, f (Suc i)) \<in> relto R S" by blast thus False using assms unfolding SN_defs by blast qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_relto_imp_SN
null
SN_relto_Id: "SN (relto R (S \<union> Id)) = SN (relto R S)" by (simp only: relto_Id)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_relto_Id
null
trans_subset_SN: assumes "trans R" and "R \<subseteq> (r \<union> s)" and "SN r" and "SN s" shows "SN R" proof fix f :: "nat \<Rightarrow> 'a" assume "f 0 \<in> UNIV" and chain: "chain R f" have *: "\<And>i j. i < j \<Longrightarrow> (f i, f j) \<in> r \<union> s" using assms and chain_imp_trancl [OF chain] by auto let ?M = "{i. \<forall>j>i. (f i, f j) \<notin> r}" show False proof (cases "finite ?M") let ?n = "Max ?M" assume "finite ?M" with Max_ge have "\<forall>i\<in>?M. i \<le> ?n" by simp then have "\<forall>k\<ge>Suc ?n. \<exists>k'>k. (f k, f k') \<in> r" by auto with steps_imp_chainp [of "Suc ?n" "\<lambda>x y. (x, y) \<in> r"] and assms show False by auto next assume "infinite ?M" then have "INFM j. j \<in> ?M" by (simp add: Inf_many_def) then interpret infinitely_many "\<lambda>i. i \<in> ?M" by (unfold_locales) assumption define g where [simp]: "g = index" have "\<forall>i. (f (g i), f (g (Suc i))) \<in> s" proof fix i have less: "g i < g (Suc i)" using index_ordered_less [of i "Suc i"] by simp have "g i \<in> ?M" using index_p by simp then have "(f (g i), f (g (Suc i))) \<notin> r" using less by simp moreover have "(f (g i), f (g (Suc i))) \<in> r \<union> s" using * [OF less] by simp
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
trans_subset_SN
Termination inheritance by transitivity (see, e.g., Geser's thesis).
SN_Un_conv: assumes "trans (r \<union> s)" shows "SN (r \<union> s) \<longleftrightarrow> SN r \<and> SN s" (is "SN ?r \<longleftrightarrow> ?rhs") proof assume "SN (r \<union> s)" thus "SN r \<and> SN s" using SN_subset[of ?r] by blast next assume "SN r \<and> SN s" with trans_subset_SN[OF assms subset_refl] show "SN ?r" by simp qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_Un_conv
SN s
SN_relto_Un: "SN (relto (R \<union> S) Q) \<longleftrightarrow> SN (relto R (S \<union> Q)) \<and> SN (relto S Q)" (is "SN ?a \<longleftrightarrow> SN ?b \<and> SN ?c") proof - have eq: "?a^+ = ?b^+ \<union> ?c^+" by regexp from SN_Un_conv[of "?b^+" "?c^+", unfolded eq[symmetric]] show ?thesis unfolding SN_trancl_SN_conv by simp qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_relto_Un
null
SN_relto_split: assumes "SN (relto r (s \<union> q2) \<union> relto q1 (s \<union> q2))" (is "SN ?a") and "SN (relto s q2)" (is "SN ?b") shows "SN (relto r (q1 \<union> q2) \<union> relto s (q1 \<union> q2))" (is "SN ?c") proof - have "?c^+ \<subseteq> ?a^+ \<union> ?b^+" by regexp from trans_subset_SN[OF _ this, unfolded SN_trancl_SN_conv, OF _ assms] show ?thesis by simp qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
SN_relto_split
null
relto_trancl_subset: assumes "a \<subseteq> c" and "b \<subseteq> c" shows "relto a b \<subseteq> c^+" proof - have "relto a b \<subseteq> (a \<union> b)^+" by regexp also have "\<dots> \<subseteq> c^+" by (rule trancl_mono_set, insert assms, auto) finally show ?thesis . qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_trancl_subset
null
relto_fun:: "'a rel \<Rightarrow> 'a rel \<Rightarrow> nat \<Rightarrow> (nat \<Rightarrow> 'a) \<Rightarrow> (nat \<Rightarrow> bool) \<Rightarrow> nat \<Rightarrow> 'a \<times> 'a \<Rightarrow> bool" where relto_fun: "as 0 = a \<Longrightarrow> as m = b \<Longrightarrow> (\<And> i. i < m \<Longrightarrow> (sel i \<longrightarrow> (as i, as (Suc i)) \<in> A) \<and> (\<not> sel i \<longrightarrow> (as i, as (Suc i)) \<in> B)) \<Longrightarrow> n = card { i . i < m \<and> sel i} \<Longrightarrow> (n = 0 \<longleftrightarrow> m = 0) \<Longrightarrow> relto_fun A B n as sel m (a,b)"
inductive
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_fun
An explicit version of @{const relto} which mentions all intermediate terms
relto_funD: assumes "relto_fun A B n as sel m (a,b)" shows "as 0 = a" "as m = b" "\<And> i. i < m \<Longrightarrow> sel i \<Longrightarrow> (as i, as (Suc i)) \<in> A" "\<And> i. i < m \<Longrightarrow> \<not> sel i \<Longrightarrow> (as i, as (Suc i)) \<in> B" "n = card { i . i < m \<and> sel i}" "n = 0 \<longleftrightarrow> m = 0" using assms[unfolded relto_fun.simps] by blast+
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_funD
null
relto_fun_refl: "\<exists> as sel. relto_fun A B 0 as sel 0 (a,a)" by (rule exI[of _ "\<lambda> _. a"], rule exI, rule relto_fun, auto)
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_fun_refl
null
relto_into_relto_fun: assumes "(a,b) \<in> relto A B" shows "\<exists> as sel m. relto_fun A B (Suc 0) as sel m (a,b)" proof - from assms obtain a' b' where aa: "(a,a') \<in> B^*" and ab: "(a',b') \<in> A" and bb: "(b',b) \<in> B^*" by auto from aa[unfolded rtrancl_fun_conv] obtain f1 n1 where f1: "f1 0 = a" "f1 n1 = a'" "\<And> i. i<n1 \<Longrightarrow> (f1 i, f1 (Suc i)) \<in> B" by auto from bb[unfolded rtrancl_fun_conv] obtain f2 n2 where f2: "f2 0 = b'" "f2 n2 = b" "\<And> i. i<n2 \<Longrightarrow> (f2 i, f2 (Suc i)) \<in> B" by auto let ?gen = "\<lambda> aa ab bb i. if i < n1 then aa i else if i = n1 then ab else bb (i - Suc n1)" let ?f = "?gen f1 a' f2" let ?sel = "?gen (\<lambda> _. False) True (\<lambda> _. False)" let ?m = "Suc (n1 + n2)" show ?thesis proof (rule exI[of _ ?f], rule exI[of _ ?sel], rule exI[of _ ?m], rule relto_fun) fix i assume i: "i < ?m" show "(?sel i \<longrightarrow> (?f i, ?f (Suc i)) \<in> A) \<and> (\<not> ?sel i \<longrightarrow> (?f i, ?f (Suc i)) \<in> B)" proof (cases "i < n1") case True with f1(3)[OF this] f1(2) show ?thesis by (cases "Suc i = n1", auto) next case False note nle = this show ?thesis proof (cases "i > n1") case False with nle have "i = n1" by auto thus ?thesis using f1 f2 ab by auto next case True
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_into_relto_fun
null
relto_fun_trans: assumes ab: "relto_fun A B n1 as1 sel1 m1 (a,b)" and bc: "relto_fun A B n2 as2 sel2 m2 (b,c)" shows "\<exists> as sel. relto_fun A B (n1 + n2) as sel (m1 + m2) (a,c)" proof - from relto_funD[OF ab] have 1: "as1 0 = a" "as1 m1 = b" "\<And> i. i < m1 \<Longrightarrow> (sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> A) \<and> (\<not> sel1 i \<longrightarrow> (as1 i, as1 (Suc i)) \<in> B)" "n1 = 0 \<longleftrightarrow> m1 = 0" and card1: "n1 = card {i. i < m1 \<and> sel1 i}" by blast+ from relto_funD[OF bc] have 2: "as2 0 = b" "as2 m2 = c" "\<And> i. i < m2 \<Longrightarrow> (sel2 i \<longrightarrow> (as2 i, as2 (Suc i)) \<in> A) \<and> (\<not> sel2 i \<longrightarrow> (as2 i, as2 (Suc i)) \<in> B)" "n2 = 0 \<longleftrightarrow> m2 = 0" and card2: "n2 = card {i. i < m2 \<and> sel2 i}" by blast+ let ?as = "\<lambda> i. if i < m1 then as1 i else as2 (i - m1)" let ?sel = "\<lambda> i. if i < m1 then sel1 i else sel2 (i - m1)" let ?m = "m1 + m2" let ?n = "n1 + n2" show ?thesis proof (rule exI[of _ ?as], rule exI[of _ ?sel], rule relto_fun) have id: "{ i . i < ?m \<and> ?sel i} = { i . i < m1 \<and> sel1 i} \<union> ((+) m1) ` { i. i < m2 \<and> sel2 i}" (is "_ = ?A \<union> ?f ` ?B") by force have "card (?A \<union> ?f ` ?B) = card ?A + card (?f ` ?B)" by (rule card_Un_disjoint, auto) also have "card (?f ` ?B) = card ?B" by (rule card_image, auto simp: inj_on_def) finally show "?n = card { i . i < ?m \<and> ?sel i}" unfolding card1 card2 id by simp next fix i assume i: "i < ?m" show "(?sel i \<longrightarrow> (?as i, ?as (Suc i)) \<in> A) \<and> (\<not> ?sel i \<longrightarrow> (?as i, ?as (Suc i)) \<in> B)"
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_fun_trans
null
reltos_into_relto_fun: assumes "(a,b) \<in> (relto A B)^^n" shows "\<exists> as sel m. relto_fun A B n as sel m (a,b)" using assms proof (induct n arbitrary: b) case (0 b) hence b: "b = a" by auto show ?case unfolding b using relto_fun_refl[of A B a] by blast next case (Suc n c) from relpow_Suc_E[OF Suc(2)] obtain b where ab: "(a,b) \<in> (relto A B)^^n" and bc: "(b,c) \<in> relto A B" by auto from Suc(1)[OF ab] obtain as sel m where IH: "relto_fun A B n as sel m (a, b)" by auto from relto_into_relto_fun[OF bc] obtain as sel m where "relto_fun A B (Suc 0) as sel m (b,c)" by blast from relto_fun_trans[OF IH this] show ?case by auto qed
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
reltos_into_relto_fun
null
relto_fun_into_reltos: assumes "relto_fun A B n as sel m (a,b)" shows "(a,b) \<in> (relto A B)^^n" proof - note * = relto_funD[OF assms] { fix m' let ?c = "\<lambda> m'. card {i. i < m' \<and> sel i}" assume "m' \<le> m" hence "(?c m' > 0 \<longrightarrow> (as 0, as m') \<in> (relto A B)^^ ?c m') \<and> (?c m' = 0 \<longrightarrow> (as 0, as m') \<in> B^*)" proof (induct m') case (Suc m') let ?x = "as 0" let ?y = "as m'" let ?z = "as (Suc m')" let ?C = "?c (Suc m')" have C: "?C = ?c m' + (if (sel m') then 1 else 0)" proof - have id: "{i. i < Suc m' \<and> sel i} = {i. i < m' \<and> sel i} \<union> (if sel m' then {m'} else {})" by (cases "sel m'", auto, case_tac "x = m'", auto) show ?thesis unfolding id by auto qed from Suc(2) have m': "m' \<le> m" and lt: "m' < m" by auto from Suc(1)[OF m'] have IH: "?c m' > 0 \<Longrightarrow> (?x, ?y) \<in> (relto A B) ^^ ?c m'" "?c m' = 0 \<Longrightarrow> (?x, ?y) \<in> B^*" by auto from *(3-4)[OF lt] have yz: "sel m' \<Longrightarrow> (?y, ?z) \<in> A" "\<not> sel m' \<Longrightarrow> (?y, ?z) \<in> B" by auto show ?case proof (cases "?c m' = 0") case True note c = this from IH(2)[OF this] have xy: "(?x, ?y) \<in> B^*" by auto show ?thesis
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_fun_into_reltos
null
relto_relto_fun_conv: "((a,b) \<in> (relto A B)^^n) = (\<exists> as sel m. relto_fun A B n as sel m (a,b))" using relto_fun_into_reltos[of A B n _ _ _ a b] reltos_into_relto_fun[of a b n B A] by blast
lemma
Abstract-Rewriting
[ "Abstract_Rewriting" ]
Abstract-Rewriting/Relative_Rewriting.thy
relto_relto_fun_conv
null