author | urbanc |
Mon, 22 Aug 2011 12:49:27 +0000 | |
changeset 203 | 5d724fe0e096 |
parent 195 | 5bbe63876f84 |
child 241 | 68d48522ea9a |
permissions | -rw-r--r-- |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
1 |
theory Derivatives |
203 | 2 |
imports Regular_Exp |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
3 |
begin |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
4 |
|
203 | 5 |
section {* Leftquotients, Derivatives and Partial Derivatives *} |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
6 |
|
203 | 7 |
text{* This theory is based on work by Brozowski \cite{Brzozowski64} and Antimirov \cite{Antimirov95}. *} |
8 |
||
9 |
subsection {* Left-Quotients of languages *} |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
10 |
|
203 | 11 |
definition Deriv :: "'a \<Rightarrow> 'a lang \<Rightarrow> 'a lang" |
12 |
where "Deriv x A = { xs. x#xs \<in> A }" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
13 |
|
203 | 14 |
definition Derivs :: "'a list \<Rightarrow> 'a lang \<Rightarrow> 'a lang" |
15 |
where "Derivs xs A = { ys. xs @ ys \<in> A }" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
16 |
|
187 | 17 |
abbreviation |
203 | 18 |
Derivss :: "'a list \<Rightarrow> 'a lang set \<Rightarrow> 'a lang" |
19 |
where |
|
20 |
"Derivss s As \<equiv> \<Union> (Derivs s) ` As" |
|
21 |
||
22 |
||
23 |
lemma Deriv_empty[simp]: "Deriv a {} = {}" |
|
24 |
and Deriv_epsilon[simp]: "Deriv a {[]} = {}" |
|
25 |
and Deriv_char[simp]: "Deriv a {[b]} = (if a = b then {[]} else {})" |
|
26 |
and Deriv_union[simp]: "Deriv a (A \<union> B) = Deriv a A \<union> Deriv a B" |
|
27 |
by (auto simp: Deriv_def) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
28 |
|
203 | 29 |
lemma Deriv_conc_subset: |
30 |
"Deriv a A @@ B \<subseteq> Deriv a (A @@ B)" (is "?L \<subseteq> ?R") |
|
31 |
proof |
|
32 |
fix w assume "w \<in> ?L" |
|
33 |
then obtain u v where "w = u @ v" "a # u \<in> A" "v \<in> B" |
|
34 |
by (auto simp: Deriv_def) |
|
35 |
then have "a # w \<in> A @@ B" |
|
36 |
by (auto intro: concI[of "a # u", simplified]) |
|
37 |
thus "w \<in> ?R" by (auto simp: Deriv_def) |
|
38 |
qed |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
39 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
40 |
lemma Der_conc [simp]: |
203 | 41 |
shows "Deriv c (A @@ B) = (Deriv c A) @@ B \<union> (if [] \<in> A then Deriv c B else {})" |
42 |
unfolding Deriv_def conc_def |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
43 |
by (auto simp add: Cons_eq_append_conv) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
44 |
|
203 | 45 |
lemma Deriv_star [simp]: |
46 |
shows "Deriv c (star A) = (Deriv c A) @@ star A" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
47 |
proof - |
203 | 48 |
have incl: "[] \<in> A \<Longrightarrow> Deriv c (star A) \<subseteq> (Deriv c A) @@ star A" |
49 |
unfolding Deriv_def conc_def |
|
50 |
apply(auto simp add: Cons_eq_append_conv) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
51 |
apply(drule star_decom) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
52 |
apply(auto simp add: Cons_eq_append_conv) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
53 |
done |
203 | 54 |
|
55 |
have "Deriv c (star A) = Deriv c (A @@ star A \<union> {[]})" |
|
180 | 56 |
by (simp only: star_unfold_left[symmetric]) |
203 | 57 |
also have "... = Deriv c (A @@ star A)" |
58 |
by (simp only: Deriv_union) (simp) |
|
59 |
also have "... = (Deriv c A) @@ (star A) \<union> (if [] \<in> A then Deriv c (star A) else {})" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
60 |
by simp |
203 | 61 |
also have "... = (Deriv c A) @@ star A" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
62 |
using incl by auto |
203 | 63 |
finally show "Deriv c (star A) = (Deriv c A) @@ star A" . |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
64 |
qed |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
65 |
|
203 | 66 |
lemma Derivs_simps [simp]: |
67 |
shows "Derivs [] A = A" |
|
68 |
and "Derivs (c # s) A = Derivs s (Deriv c A)" |
|
69 |
and "Derivs (s1 @ s2) A = Derivs s2 (Derivs s1 A)" |
|
70 |
unfolding Derivs_def Deriv_def by auto |
|
71 |
||
72 |
(* |
|
73 |
lemma Deriv_insert_eps[simp]: |
|
74 |
"Deriv a (insert [] A) = Deriv a A" |
|
75 |
by (auto simp: Deriv_def) |
|
76 |
*) |
|
77 |
||
78 |
||
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
79 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
80 |
subsection {* Brozowsky's derivatives of regular expressions *} |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
81 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
82 |
fun |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
83 |
nullable :: "'a rexp \<Rightarrow> bool" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
84 |
where |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
85 |
"nullable (Zero) = False" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
86 |
| "nullable (One) = True" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
87 |
| "nullable (Atom c) = False" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
88 |
| "nullable (Plus r1 r2) = (nullable r1 \<or> nullable r2)" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
89 |
| "nullable (Times r1 r2) = (nullable r1 \<and> nullable r2)" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
90 |
| "nullable (Star r) = True" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
91 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
92 |
fun |
203 | 93 |
deriv :: "'a \<Rightarrow> 'a rexp \<Rightarrow> 'a rexp" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
94 |
where |
203 | 95 |
"deriv c (Zero) = Zero" |
96 |
| "deriv c (One) = Zero" |
|
97 |
| "deriv c (Atom c') = (if c = c' then One else Zero)" |
|
98 |
| "deriv c (Plus r1 r2) = Plus (deriv c r1) (deriv c r2)" |
|
99 |
| "deriv c (Times r1 r2) = |
|
100 |
(if nullable r1 then Plus (Times (deriv c r1) r2) (deriv c r2) else Times (deriv c r1) r2)" |
|
101 |
| "deriv c (Star r) = Times (deriv c r) (Star r)" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
102 |
|
179 | 103 |
fun |
203 | 104 |
derivs :: "'a list \<Rightarrow> 'a rexp \<Rightarrow> 'a rexp" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
105 |
where |
203 | 106 |
"derivs [] r = r" |
107 |
| "derivs (c # s) r = derivs s (deriv c r)" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
108 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
109 |
|
203 | 110 |
lemma nullable_iff: |
111 |
shows "nullable r \<longleftrightarrow> [] \<in> lang r" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
112 |
by (induct r) (auto simp add: conc_def split: if_splits) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
113 |
|
203 | 114 |
lemma Deriv_deriv: |
115 |
shows "Deriv c (lang r) = lang (deriv c r)" |
|
116 |
by (induct r) (simp_all add: nullable_iff) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
117 |
|
203 | 118 |
lemma Derivs_derivs: |
119 |
shows "Derivs s (lang r) = lang (derivs s r)" |
|
120 |
by (induct s arbitrary: r) (simp_all add: Deriv_deriv) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
121 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
122 |
|
203 | 123 |
subsection {* Antimirov's partial derivivatives *} |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
124 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
125 |
abbreviation |
187 | 126 |
"Timess rs r \<equiv> {Times r' r | r'. r' \<in> rs}" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
127 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
128 |
fun |
203 | 129 |
pderiv :: "'a \<Rightarrow> 'a rexp \<Rightarrow> 'a rexp set" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
130 |
where |
203 | 131 |
"pderiv c Zero = {}" |
132 |
| "pderiv c One = {}" |
|
133 |
| "pderiv c (Atom c') = (if c = c' then {One} else {})" |
|
134 |
| "pderiv c (Plus r1 r2) = (pderiv c r1) \<union> (pderiv c r2)" |
|
135 |
| "pderiv c (Times r1 r2) = |
|
136 |
(if nullable r1 then Timess (pderiv c r1) r2 \<union> pderiv c r2 else Timess (pderiv c r1) r2)" |
|
137 |
| "pderiv c (Star r) = Timess (pderiv c r) (Star r)" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
138 |
|
179 | 139 |
fun |
203 | 140 |
pderivs :: "'a list \<Rightarrow> 'a rexp \<Rightarrow> ('a rexp) set" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
141 |
where |
203 | 142 |
"pderivs [] r = {r}" |
143 |
| "pderivs (c # s) r = \<Union> (pderivs s) ` (pderiv c r)" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
144 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
145 |
abbreviation |
203 | 146 |
pderiv_set :: "'a \<Rightarrow> 'a rexp set \<Rightarrow> 'a rexp set" |
147 |
where |
|
148 |
"pderiv_set c rs \<equiv> \<Union> pderiv c ` rs" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
149 |
|
203 | 150 |
abbreviation |
151 |
pderivs_set :: "'a list \<Rightarrow> 'a rexp set \<Rightarrow> 'a rexp set" |
|
152 |
where |
|
153 |
"pderivs_set s rs \<equiv> \<Union> (pderivs s) ` rs" |
|
154 |
||
155 |
lemma pderivs_append: |
|
156 |
"pderivs (s1 @ s2) r = \<Union> (pderivs s2) ` (pderivs s1 r)" |
|
179 | 157 |
by (induct s1 arbitrary: r) (simp_all) |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
158 |
|
203 | 159 |
lemma pderivs_snoc: |
160 |
shows "pderivs (s @ [c]) r = pderiv_set c (pderivs s r)" |
|
161 |
by (simp add: pderivs_append) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
162 |
|
203 | 163 |
lemma pderivs_simps [simp]: |
164 |
shows "pderivs s Zero = (if s = [] then {Zero} else {})" |
|
165 |
and "pderivs s One = (if s = [] then {One} else {})" |
|
166 |
and "pderivs s (Plus r1 r2) = (if s = [] then {Plus r1 r2} else (pderivs s r1) \<union> (pderivs s r2))" |
|
193
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
167 |
by (induct s) (simp_all) |
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
168 |
|
203 | 169 |
lemma pderivs_Atom: |
170 |
shows "pderivs s (Atom c) \<subseteq> {Atom c, One}" |
|
193
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
171 |
by (induct s) (simp_all) |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
172 |
|
203 | 173 |
subsection {* Relating left-quotients and partial derivivatives *} |
187 | 174 |
|
203 | 175 |
lemma Deriv_pderiv: |
176 |
shows "Deriv c (lang r) = \<Union> lang ` (pderiv c r)" |
|
177 |
by (induct r) (auto simp add: nullable_iff conc_UNION_distrib) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
178 |
|
203 | 179 |
lemma Derivs_pderivs: |
180 |
shows "Derivs s (lang r) = \<Union> lang ` (pderivs s r)" |
|
187 | 181 |
proof (induct s arbitrary: r) |
182 |
case (Cons c s) |
|
203 | 183 |
have ih: "\<And>r. Derivs s (lang r) = \<Union> lang ` (pderivs s r)" by fact |
184 |
have "Derivs (c # s) (lang r) = Derivs s (Deriv c (lang r))" by simp |
|
185 |
also have "\<dots> = Derivs s (\<Union> lang ` (pderiv c r))" by (simp add: Deriv_pderiv) |
|
186 |
also have "\<dots> = Derivss s (lang ` (pderiv c r))" |
|
187 |
by (auto simp add: Derivs_def) |
|
188 |
also have "\<dots> = \<Union> lang ` (pderivs_set s (pderiv c r))" |
|
187 | 189 |
using ih by auto |
203 | 190 |
also have "\<dots> = \<Union> lang ` (pderivs (c # s) r)" by simp |
191 |
finally show "Derivs (c # s) (lang r) = \<Union> lang ` pderivs (c # s) r" . |
|
192 |
qed (simp add: Derivs_def) |
|
187 | 193 |
|
203 | 194 |
subsection {* Relating derivivatives and partial derivivatives *} |
187 | 195 |
|
203 | 196 |
lemma deriv_pderiv: |
197 |
shows "(\<Union> lang ` (pderiv c r)) = lang (deriv c r)" |
|
198 |
unfolding Deriv_deriv[symmetric] Deriv_pderiv by simp |
|
187 | 199 |
|
203 | 200 |
lemma derivs_pderivs: |
201 |
shows "(\<Union> lang ` (pderivs s r)) = lang (derivs s r)" |
|
202 |
unfolding Derivs_derivs[symmetric] Derivs_pderivs by simp |
|
187 | 203 |
|
204 |
||
203 | 205 |
subsection {* Finiteness property of partial derivivatives *} |
187 | 206 |
|
191 | 207 |
definition |
203 | 208 |
pderivs_lang :: "'a lang \<Rightarrow> 'a rexp \<Rightarrow> 'a rexp set" |
209 |
where |
|
210 |
"pderivs_lang A r \<equiv> \<Union>x \<in> A. pderivs x r" |
|
191 | 211 |
|
203 | 212 |
lemma pderivs_lang_subsetI: |
213 |
assumes "\<And>s. s \<in> A \<Longrightarrow> pderivs s r \<subseteq> C" |
|
214 |
shows "pderivs_lang A r \<subseteq> C" |
|
215 |
using assms unfolding pderivs_lang_def by (rule UN_least) |
|
191 | 216 |
|
203 | 217 |
lemma pderivs_lang_union: |
218 |
shows "pderivs_lang (A \<union> B) r = (pderivs_lang A r \<union> pderivs_lang B r)" |
|
219 |
by (simp add: pderivs_lang_def) |
|
220 |
||
221 |
lemma pderivs_lang_subset: |
|
222 |
shows "A \<subseteq> B \<Longrightarrow> pderivs_lang A r \<subseteq> pderivs_lang B r" |
|
223 |
by (auto simp add: pderivs_lang_def) |
|
193
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
224 |
|
191 | 225 |
definition |
226 |
"UNIV1 \<equiv> UNIV - {[]}" |
|
227 |
||
203 | 228 |
lemma pderivs_lang_Zero [simp]: |
229 |
shows "pderivs_lang UNIV1 Zero = {}" |
|
230 |
unfolding UNIV1_def pderivs_lang_def by auto |
|
191 | 231 |
|
203 | 232 |
lemma pderivs_lang_One [simp]: |
233 |
shows "pderivs_lang UNIV1 One = {}" |
|
234 |
unfolding UNIV1_def pderivs_lang_def by (auto split: if_splits) |
|
191 | 235 |
|
203 | 236 |
lemma pderivs_lang_Atom [simp]: |
237 |
shows "pderivs_lang UNIV1 (Atom c) = {One}" |
|
238 |
unfolding UNIV1_def pderivs_lang_def |
|
193
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
239 |
apply(auto) |
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
240 |
apply(frule rev_subsetD) |
203 | 241 |
apply(rule pderivs_Atom) |
193
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
242 |
apply(simp) |
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
243 |
apply(case_tac xa) |
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
244 |
apply(auto split: if_splits) |
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
245 |
done |
191 | 246 |
|
203 | 247 |
lemma pderivs_lang_Plus [simp]: |
248 |
shows "pderivs_lang UNIV1 (Plus r1 r2) = pderivs_lang UNIV1 r1 \<union> pderivs_lang UNIV1 r2" |
|
249 |
unfolding UNIV1_def pderivs_lang_def by auto |
|
191 | 250 |
|
251 |
||
252 |
text {* Non-empty suffixes of a string (needed for teh cases of @{const Times} and @{const Star} *} |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
253 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
254 |
definition |
203 | 255 |
"PSuf s \<equiv> {v. v \<noteq> [] \<and> (\<exists>u. u @ v = s)}" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
256 |
|
203 | 257 |
lemma PSuf_snoc: |
258 |
shows "PSuf (s @ [c]) = (PSuf s) @@ {[c]} \<union> {[c]}" |
|
259 |
unfolding PSuf_def conc_def |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
260 |
by (auto simp add: append_eq_append_conv2 append_eq_Cons_conv) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
261 |
|
203 | 262 |
lemma PSuf_Union: |
263 |
shows "(\<Union>v \<in> PSuf s @@ {[c]}. f v) = (\<Union>v \<in> PSuf s. f (v @ [c]))" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
264 |
by (auto simp add: conc_def) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
265 |
|
203 | 266 |
lemma pderivs_lang_snoc: |
267 |
shows "pderivs_lang (PSuf s @@ {[c]}) r = (pderiv_set c (pderivs_lang (PSuf s) r))" |
|
268 |
unfolding pderivs_lang_def |
|
269 |
by (simp add: PSuf_Union pderivs_snoc) |
|
187 | 270 |
|
203 | 271 |
lemma pderivs_Times: |
272 |
shows "pderivs s (Times r1 r2) \<subseteq> Timess (pderivs s r1) r2 \<union> (pderivs_lang (PSuf s) r2)" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
273 |
proof (induct s rule: rev_induct) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
274 |
case (snoc c s) |
203 | 275 |
have ih: "pderivs s (Times r1 r2) \<subseteq> Timess (pderivs s r1) r2 \<union> (pderivs_lang (PSuf s) r2)" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
276 |
by fact |
203 | 277 |
have "pderivs (s @ [c]) (Times r1 r2) = pderiv_set c (pderivs s (Times r1 r2))" |
278 |
by (simp add: pderivs_snoc) |
|
279 |
also have "\<dots> \<subseteq> pderiv_set c (Timess (pderivs s r1) r2 \<union> (pderivs_lang (PSuf s) r2))" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
280 |
using ih by (auto) (blast) |
203 | 281 |
also have "\<dots> = pderiv_set c (Timess (pderivs s r1) r2) \<union> pderiv_set c (pderivs_lang (PSuf s) r2)" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
282 |
by (simp) |
203 | 283 |
also have "\<dots> = pderiv_set c (Timess (pderivs s r1) r2) \<union> pderivs_lang (PSuf s @@ {[c]}) r2" |
284 |
by (simp add: pderivs_lang_snoc) |
|
285 |
also |
|
286 |
have "\<dots> \<subseteq> pderiv_set c (Timess (pderivs s r1) r2) \<union> pderiv c r2 \<union> pderivs_lang (PSuf s @@ {[c]}) r2" |
|
187 | 287 |
by auto |
203 | 288 |
also |
289 |
have "\<dots> \<subseteq> Timess (pderiv_set c (pderivs s r1)) r2 \<union> pderiv c r2 \<union> pderivs_lang (PSuf s @@ {[c]}) r2" |
|
190 | 290 |
by (auto simp add: if_splits) (blast) |
203 | 291 |
also have "\<dots> = Timess (pderivs (s @ [c]) r1) r2 \<union> pderiv c r2 \<union> pderivs_lang (PSuf s @@ {[c]}) r2" |
292 |
by (simp add: pderivs_snoc) |
|
293 |
also have "\<dots> \<subseteq> Timess (pderivs (s @ [c]) r1) r2 \<union> pderivs_lang (PSuf (s @ [c])) r2" |
|
294 |
unfolding pderivs_lang_def by (auto simp add: PSuf_snoc) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
295 |
finally show ?case . |
187 | 296 |
qed (simp) |
297 |
||
203 | 298 |
lemma pderivs_lang_Times_aux1: |
191 | 299 |
assumes a: "s \<in> UNIV1" |
203 | 300 |
shows "pderivs_lang (PSuf s) r \<subseteq> pderivs_lang UNIV1 r" |
301 |
using a unfolding UNIV1_def PSuf_def pderivs_lang_def by auto |
|
191 | 302 |
|
203 | 303 |
lemma pderivs_lang_Times_aux2: |
191 | 304 |
assumes a: "s \<in> UNIV1" |
203 | 305 |
shows "Timess (pderivs s r1) r2 \<subseteq> Timess (pderivs_lang UNIV1 r1) r2" |
306 |
using a unfolding pderivs_lang_def by auto |
|
191 | 307 |
|
203 | 308 |
lemma pderivs_lang_Times: |
309 |
shows "pderivs_lang UNIV1 (Times r1 r2) \<subseteq> Timess (pderivs_lang UNIV1 r1) r2 \<union> pderivs_lang UNIV1 r2" |
|
310 |
apply(rule pderivs_lang_subsetI) |
|
191 | 311 |
apply(rule subset_trans) |
203 | 312 |
apply(rule pderivs_Times) |
313 |
using pderivs_lang_Times_aux1 pderivs_lang_Times_aux2 |
|
191 | 314 |
apply(blast) |
315 |
done |
|
316 |
||
203 | 317 |
lemma pderivs_Star: |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
318 |
assumes a: "s \<noteq> []" |
203 | 319 |
shows "pderivs s (Star r) \<subseteq> Timess (pderivs_lang (PSuf s) r) (Star r)" |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
320 |
using a |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
321 |
proof (induct s rule: rev_induct) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
322 |
case (snoc c s) |
203 | 323 |
have ih: "s \<noteq> [] \<Longrightarrow> pderivs s (Star r) \<subseteq> Timess (pderivs_lang (PSuf s) r) (Star r)" by fact |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
324 |
{ assume asm: "s \<noteq> []" |
203 | 325 |
have "pderivs (s @ [c]) (Star r) = pderiv_set c (pderivs s (Star r))" by (simp add: pderivs_snoc) |
326 |
also have "\<dots> \<subseteq> pderiv_set c (Timess (pderivs_lang (PSuf s) r) (Star r))" |
|
187 | 327 |
using ih[OF asm] by (auto) (blast) |
203 | 328 |
also have "\<dots> \<subseteq> Timess (pderiv_set c (pderivs_lang (PSuf s) r)) (Star r) \<union> pderiv c (Star r)" |
190 | 329 |
by (auto split: if_splits) (blast)+ |
203 | 330 |
also have "\<dots> \<subseteq> Timess (pderivs_lang (PSuf (s @ [c])) r) (Star r) \<union> (Timess (pderiv c r) (Star r))" |
331 |
by (simp only: PSuf_snoc pderivs_lang_snoc pderivs_lang_union) |
|
332 |
(auto simp add: pderivs_lang_def) |
|
333 |
also have "\<dots> = Timess (pderivs_lang (PSuf (s @ [c])) r) (Star r)" |
|
334 |
by (auto simp add: PSuf_snoc PSuf_Union pderivs_snoc pderivs_lang_def) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
335 |
finally have ?case . |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
336 |
} |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
337 |
moreover |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
338 |
{ assume asm: "s = []" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
339 |
then have ?case |
203 | 340 |
apply (auto simp add: pderivs_lang_def pderivs_snoc PSuf_def) |
190 | 341 |
apply(rule_tac x = "[c]" in exI) |
342 |
apply(auto) |
|
343 |
done |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
344 |
} |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
345 |
ultimately show ?case by blast |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
346 |
qed (simp) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
347 |
|
203 | 348 |
lemma pderivs_lang_Star: |
349 |
shows "pderivs_lang UNIV1 (Star r) \<subseteq> Timess (pderivs_lang UNIV1 r) (Star r)" |
|
350 |
apply(rule pderivs_lang_subsetI) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
351 |
apply(rule subset_trans) |
203 | 352 |
apply(rule pderivs_Star) |
191 | 353 |
apply(simp add: UNIV1_def) |
203 | 354 |
apply(simp add: UNIV1_def PSuf_def) |
355 |
apply(auto simp add: pderivs_lang_def) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
356 |
done |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
357 |
|
191 | 358 |
lemma finite_Timess [simp]: |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
359 |
assumes a: "finite A" |
187 | 360 |
shows "finite (Timess A r)" |
190 | 361 |
using a by auto |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
362 |
|
203 | 363 |
lemma finite_pderivs_lang_UNIV1: |
364 |
shows "finite (pderivs_lang UNIV1 r)" |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
365 |
apply(induct r) |
193
2a5ac68db24b
finished section about derivatives and closure properties
urbanc
parents:
191
diff
changeset
|
366 |
apply(simp_all add: |
203 | 367 |
finite_subset[OF pderivs_lang_Times] |
368 |
finite_subset[OF pderivs_lang_Star]) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
369 |
done |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
370 |
|
203 | 371 |
lemma pderivs_lang_UNIV: |
372 |
shows "pderivs_lang UNIV r = pderivs [] r \<union> pderivs_lang UNIV1 r" |
|
373 |
unfolding UNIV1_def pderivs_lang_def |
|
191 | 374 |
by blast |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
375 |
|
203 | 376 |
lemma finite_pderivs_lang_UNIV: |
377 |
shows "finite (pderivs_lang UNIV r)" |
|
378 |
unfolding pderivs_lang_UNIV |
|
379 |
by (simp add: finite_pderivs_lang_UNIV1) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
380 |
|
203 | 381 |
lemma finite_pderivs_lang: |
382 |
shows "finite (pderivs_lang A r)" |
|
383 |
by (metis finite_pderivs_lang_UNIV pderivs_lang_subset rev_finite_subset subset_UNIV) |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
384 |
|
179 | 385 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
diff
changeset
|
386 |
end |