23 pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and |
23 pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and |
24 Suc ("_+1" [100] 100) and |
24 Suc ("_+1" [100] 100) and |
25 quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and |
25 quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and |
26 REL ("\<approx>") and |
26 REL ("\<approx>") and |
27 UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and |
27 UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and |
28 L ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and |
28 L_rexp ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and |
29 Lam ("\<lambda>'(_')" [100] 100) and |
29 Lam ("\<lambda>'(_')" [100] 100) and |
30 Trn ("'(_, _')" [100, 100] 100) and |
30 Trn ("'(_, _')" [100, 100] 100) and |
31 EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and |
31 EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and |
32 transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100) and |
32 transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100) and |
33 Setalt ("\<^raw:\ensuremath{\bigplus}>_" [1000] 999) and |
33 Setalt ("\<^raw:\ensuremath{\bigplus}>_" [1000] 999) and |
39 tag_str_ALT ("tag\<^isub>A\<^isub>L\<^isub>T _ _ _" [100, 100, 100] 100) and |
39 tag_str_ALT ("tag\<^isub>A\<^isub>L\<^isub>T _ _ _" [100, 100, 100] 100) and |
40 tag_str_SEQ ("tag\<^isub>S\<^isub>E\<^isub>Q _ _" [100, 100] 100) and |
40 tag_str_SEQ ("tag\<^isub>S\<^isub>E\<^isub>Q _ _" [100, 100] 100) and |
41 tag_str_SEQ ("tag\<^isub>S\<^isub>E\<^isub>Q _ _ _" [100, 100, 100] 100) and |
41 tag_str_SEQ ("tag\<^isub>S\<^isub>E\<^isub>Q _ _ _" [100, 100, 100] 100) and |
42 tag_str_STAR ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _" [100] 100) and |
42 tag_str_STAR ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _" [100] 100) and |
43 tag_str_STAR ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _ _" [100, 100] 100) |
43 tag_str_STAR ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _ _" [100, 100] 100) |
|
44 |
44 lemma meta_eq_app: |
45 lemma meta_eq_app: |
45 shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x" |
46 shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x" |
46 by auto |
47 by auto |
|
48 |
|
49 (* THEOREMS *) |
|
50 notation (Rule output) |
|
51 "==>" ("\<^raw:\mbox{}\inferrule{\mbox{>_\<^raw:}}>\<^raw:{\mbox{>_\<^raw:}}>") |
|
52 |
|
53 syntax (Rule output) |
|
54 "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
55 ("\<^raw:\mbox{}\inferrule{>_\<^raw:}>\<^raw:{\mbox{>_\<^raw:}}>") |
|
56 |
|
57 "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" |
|
58 ("\<^raw:\mbox{>_\<^raw:}\\>/ _") |
|
59 |
|
60 "_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>") |
|
61 |
|
62 notation (Axiom output) |
|
63 "Trueprop" ("\<^raw:\mbox{}\inferrule{\mbox{}}{\mbox{>_\<^raw:}}>") |
|
64 |
|
65 notation (IfThen output) |
|
66 "==>" ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
67 syntax (IfThen output) |
|
68 "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
69 ("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
70 "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}> /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _") |
|
71 "_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>") |
|
72 |
|
73 notation (IfThenNoBox output) |
|
74 "==>" ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
75 syntax (IfThenNoBox output) |
|
76 "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
77 ("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
78 "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("_ /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _") |
|
79 "_asm" :: "prop \<Rightarrow> asms" ("_") |
|
80 |
47 |
81 |
48 (*>*) |
82 (*>*) |
49 |
83 |
50 |
84 |
51 section {* Introduction *} |
85 section {* Introduction *} |
237 text {* |
271 text {* |
238 Strings in Isabelle/HOL are lists of characters with the \emph{empty string} |
272 Strings in Isabelle/HOL are lists of characters with the \emph{empty string} |
239 being represented by the empty list, written @{term "[]"}. \emph{Languages} |
273 being represented by the empty list, written @{term "[]"}. \emph{Languages} |
240 are sets of strings. The language containing all strings is written in |
274 are sets of strings. The language containing all strings is written in |
241 Isabelle/HOL as @{term "UNIV::string set"}. The concatenation of two languages |
275 Isabelle/HOL as @{term "UNIV::string set"}. The concatenation of two languages |
242 is written @{term "A ;; B"} and a language raised to the power @{text n} is written |
276 is written @{term "A \<cdot> B"} and a language raised to the power @{text n} is written |
243 @{term "A \<up> n"}. They are defined as usual |
277 @{term "A \<up> n"}. They are defined as usual |
244 |
278 |
245 \begin{center} |
279 \begin{center} |
246 @{thm Seq_def[THEN eq_reflection, where A1="A" and B1="B"]} |
280 @{thm Seq_def[THEN eq_reflection, where A1="A" and B1="B"]} |
247 \hspace{7mm} |
281 \hspace{7mm} |
276 as \mbox{@{text "{y | y \<approx> x}"}}. |
310 as \mbox{@{text "{y | y \<approx> x}"}}. |
277 |
311 |
278 |
312 |
279 Central to our proof will be the solution of equational systems |
313 Central to our proof will be the solution of equational systems |
280 involving equivalence classes of languages. For this we will use Arden's Lemma \cite{Brzozowski64}, |
314 involving equivalence classes of languages. For this we will use Arden's Lemma \cite{Brzozowski64}, |
281 which solves equations of the form @{term "X = A ;; X \<union> B"} provided |
315 which solves equations of the form @{term "X = A \<cdot> X \<union> B"} provided |
282 @{term "[] \<notin> A"}. However we will need the following `reverse' |
316 @{term "[] \<notin> A"}. However we will need the following `reverse' |
283 version of Arden's Lemma (`reverse' in the sense of changing the order of @{term "A ;; X"} to |
317 version of Arden's Lemma (`reverse' in the sense of changing the order of @{term "A \<cdot> X"} to |
284 \mbox{@{term "X ;; A"}}). |
318 \mbox{@{term "X \<cdot> A"}}). |
285 |
319 |
286 \begin{lemma}[Reverse Arden's Lemma]\label{arden}\mbox{}\\ |
320 \begin{lemma}[Reverse Arden's Lemma]\label{arden}\mbox{}\\ |
287 If @{thm (prem 1) arden} then |
321 If @{thm (prem 1) arden} then |
288 @{thm (lhs) arden} if and only if |
322 @{thm (lhs) arden} if and only if |
289 @{thm (rhs) arden}. |
323 @{thm (rhs) arden}. |
290 \end{lemma} |
324 \end{lemma} |
291 |
325 |
292 \begin{proof} |
326 \begin{proof} |
293 For the right-to-left direction we assume @{thm (rhs) arden} and show |
327 For the right-to-left direction we assume @{thm (rhs) arden} and show |
294 that @{thm (lhs) arden} holds. From Prop.~\ref{langprops}@{text "(i)"} |
328 that @{thm (lhs) arden} holds. From Prop.~\ref{langprops}@{text "(i)"} |
295 we have @{term "A\<star> = {[]} \<union> A ;; A\<star>"}, |
329 we have @{term "A\<star> = {[]} \<union> A \<cdot> A\<star>"}, |
296 which is equal to @{term "A\<star> = {[]} \<union> A\<star> ;; A"}. Adding @{text B} to both |
330 which is equal to @{term "A\<star> = {[]} \<union> A\<star> \<cdot> A"}. Adding @{text B} to both |
297 sides gives @{term "B ;; A\<star> = B ;; ({[]} \<union> A\<star> ;; A)"}, whose right-hand side |
331 sides gives @{term "B \<cdot> A\<star> = B \<cdot> ({[]} \<union> A\<star> \<cdot> A)"}, whose right-hand side |
298 is equal to @{term "(B ;; A\<star>) ;; A \<union> B"}. This completes this direction. |
332 is equal to @{term "(B \<cdot> A\<star>) \<cdot> A \<union> B"}. This completes this direction. |
299 |
333 |
300 For the other direction we assume @{thm (lhs) arden}. By a simple induction |
334 For the other direction we assume @{thm (lhs) arden}. By a simple induction |
301 on @{text n}, we can establish the property |
335 on @{text n}, we can establish the property |
302 |
336 |
303 \begin{center} |
337 \begin{center} |
304 @{text "(*)"}\hspace{5mm} @{thm (concl) arden_helper} |
338 @{text "(*)"}\hspace{5mm} @{thm (concl) arden_helper} |
305 \end{center} |
339 \end{center} |
306 |
340 |
307 \noindent |
341 \noindent |
308 Using this property we can show that @{term "B ;; (A \<up> n) \<subseteq> X"} holds for |
342 Using this property we can show that @{term "B \<cdot> (A \<up> n) \<subseteq> X"} holds for |
309 all @{text n}. From this we can infer @{term "B ;; A\<star> \<subseteq> X"} using the definition |
343 all @{text n}. From this we can infer @{term "B \<cdot> A\<star> \<subseteq> X"} using the definition |
310 of @{text "\<star>"}. |
344 of @{text "\<star>"}. |
311 For the inclusion in the other direction we assume a string @{text s} |
345 For the inclusion in the other direction we assume a string @{text s} |
312 with length @{text k} is an element in @{text X}. Since @{thm (prem 1) arden} |
346 with length @{text k} is an element in @{text X}. Since @{thm (prem 1) arden} |
313 we know by Prop.~\ref{langprops}@{text "(ii)"} that |
347 we know by Prop.~\ref{langprops}@{text "(ii)"} that |
314 @{term "s \<notin> X ;; (A \<up> Suc k)"} since its length is only @{text k} |
348 @{term "s \<notin> X \<cdot> (A \<up> Suc k)"} since its length is only @{text k} |
315 (the strings in @{term "X ;; (A \<up> Suc k)"} are all longer). |
349 (the strings in @{term "X \<cdot> (A \<up> Suc k)"} are all longer). |
316 From @{text "(*)"} it follows then that |
350 From @{text "(*)"} it follows then that |
317 @{term s} must be an element in @{term "(\<Union>m\<in>{0..k}. B ;; (A \<up> m))"}. This in turn |
351 @{term s} must be an element in @{term "(\<Union>m\<in>{0..k}. B \<cdot> (A \<up> m))"}. This in turn |
318 implies that @{term s} is in @{term "(\<Union>n. B ;; (A \<up> n))"}. Using Prop.~\ref{langprops}@{text "(iii)"} |
352 implies that @{term s} is in @{term "(\<Union>n. B \<cdot> (A \<up> n))"}. Using Prop.~\ref{langprops}@{text "(iii)"} |
319 this is equal to @{term "B ;; A\<star>"}, as we needed to show.\qed |
353 this is equal to @{term "B \<cdot> A\<star>"}, as we needed to show.\qed |
320 \end{proof} |
354 \end{proof} |
321 |
355 |
322 \noindent |
356 \noindent |
323 Regular expressions are defined as the inductive datatype |
357 Regular expressions are defined as the inductive datatype |
324 |
358 |
492 Overloading the function @{text \<calL>} for the two kinds of terms in the |
526 Overloading the function @{text \<calL>} for the two kinds of terms in the |
493 equational system, we have |
527 equational system, we have |
494 |
528 |
495 \begin{center} |
529 \begin{center} |
496 @{text "\<calL>(Y, r) \<equiv>"} % |
530 @{text "\<calL>(Y, r) \<equiv>"} % |
497 @{thm (rhs) L_rhs_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} |
531 @{thm (rhs) L_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} |
498 @{thm L_rhs_trm.simps(1)[where r="r", THEN eq_reflection]} |
532 @{thm L_trm.simps(1)[where r="r", THEN eq_reflection]} |
499 \end{center} |
533 \end{center} |
500 |
534 |
501 \noindent |
535 \noindent |
502 and we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations |
536 and we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations |
503 % |
537 % |
1024 The pattern in \eqref{pattern} is repeated for the other two cases. Unfortunately, |
1058 The pattern in \eqref{pattern} is repeated for the other two cases. Unfortunately, |
1025 they are slightly more complicated. In the @{const SEQ}-case we essentially have |
1059 they are slightly more complicated. In the @{const SEQ}-case we essentially have |
1026 to be able to infer that |
1060 to be able to infer that |
1027 % |
1061 % |
1028 \begin{center} |
1062 \begin{center} |
1029 @{text "\<dots>"}@{term "x @ z \<in> A ;; B \<longrightarrow> y @ z \<in> A ;; B"} |
1063 @{text "\<dots>"}@{term "x @ z \<in> A \<cdot> B \<longrightarrow> y @ z \<in> A \<cdot> B"} |
1030 \end{center} |
1064 \end{center} |
1031 % |
1065 % |
1032 \noindent |
1066 \noindent |
1033 using the information given by the appropriate tagging-function. The complication |
1067 using the information given by the appropriate tagging-function. The complication |
1034 is to find out what the possible splits of @{text "x @ z"} are to be in @{term "A ;; B"} |
1068 is to find out what the possible splits of @{text "x @ z"} are to be in @{term "A \<cdot> B"} |
1035 (this was easy in case of @{term "A \<union> B"}). To deal with this complication we define the |
1069 (this was easy in case of @{term "A \<union> B"}). To deal with this complication we define the |
1036 notions of \emph{string prefixes} |
1070 notions of \emph{string prefixes} |
1037 % |
1071 % |
1038 \begin{center} |
1072 \begin{center} |
1039 @{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\hspace{10mm} |
1073 @{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\hspace{10mm} |
1071 (z.north west) -- ($(z.north east)+(0em,0em)$) |
1105 (z.north west) -- ($(z.north east)+(0em,0em)$) |
1072 node[midway, above=0.5em]{@{text z}}; |
1106 node[midway, above=0.5em]{@{text z}}; |
1073 |
1107 |
1074 \draw[decoration={brace,transform={yscale=3}},decorate] |
1108 \draw[decoration={brace,transform={yscale=3}},decorate] |
1075 ($(xa.north west)+(0em,3ex)$) -- ($(z.north east)+(0em,3ex)$) |
1109 ($(xa.north west)+(0em,3ex)$) -- ($(z.north east)+(0em,3ex)$) |
1076 node[midway, above=0.8em]{@{term "x @ z \<in> A ;; B"}}; |
1110 node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
1077 |
1111 |
1078 \draw[decoration={brace,transform={yscale=3}},decorate] |
1112 \draw[decoration={brace,transform={yscale=3}},decorate] |
1079 ($(z.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
1113 ($(z.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
1080 node[midway, below=0.5em]{@{term "(x - x') @ z \<in> B"}}; |
1114 node[midway, below=0.5em]{@{term "(x - x') @ z \<in> B"}}; |
1081 |
1115 |
1098 ($(za.north west)+(0em,0ex)$) -- ($(zza.north east)+(0em,0ex)$) |
1132 ($(za.north west)+(0em,0ex)$) -- ($(zza.north east)+(0em,0ex)$) |
1099 node[midway, above=0.5em]{@{text z}}; |
1133 node[midway, above=0.5em]{@{text z}}; |
1100 |
1134 |
1101 \draw[decoration={brace,transform={yscale=3}},decorate] |
1135 \draw[decoration={brace,transform={yscale=3}},decorate] |
1102 ($(x.north west)+(0em,3ex)$) -- ($(zza.north east)+(0em,3ex)$) |
1136 ($(x.north west)+(0em,3ex)$) -- ($(zza.north east)+(0em,3ex)$) |
1103 node[midway, above=0.8em]{@{term "x @ z \<in> A ;; B"}}; |
1137 node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
1104 |
1138 |
1105 \draw[decoration={brace,transform={yscale=3}},decorate] |
1139 \draw[decoration={brace,transform={yscale=3}},decorate] |
1106 ($(za.south east)+(0em,0ex)$) -- ($(x.south west)+(0em,0ex)$) |
1140 ($(za.south east)+(0em,0ex)$) -- ($(x.south west)+(0em,0ex)$) |
1107 node[midway, below=0.5em]{@{text "x @ z' \<in> A"}}; |
1141 node[midway, below=0.5em]{@{text "x @ z' \<in> A"}}; |
1108 |
1142 |
1132 then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of |
1166 then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of |
1133 @{term "tag_str_SEQ A B"} is a subset of this product set, and therefore finite. |
1167 @{term "tag_str_SEQ A B"} is a subset of this product set, and therefore finite. |
1134 We have to show injectivity of this tagging-function as |
1168 We have to show injectivity of this tagging-function as |
1135 % |
1169 % |
1136 \begin{center} |
1170 \begin{center} |
1137 @{term "\<forall>z. tag_str_SEQ A B x = tag_str_SEQ A B y \<and> x @ z \<in> A ;; B \<longrightarrow> y @ z \<in> A ;; B"} |
1171 @{term "\<forall>z. tag_str_SEQ A B x = tag_str_SEQ A B y \<and> x @ z \<in> A \<cdot> B \<longrightarrow> y @ z \<in> A \<cdot> B"} |
1138 \end{center} |
1172 \end{center} |
1139 % |
1173 % |
1140 \noindent |
1174 \noindent |
1141 There are two cases to be considered (see pictures above). First, there exists |
1175 There are two cases to be considered (see pictures above). First, there exists |
1142 a @{text "x'"} such that |
1176 a @{text "x'"} such that |
1157 That means there must be a @{text "y'"} such that @{text "y' \<in> A"} and |
1191 That means there must be a @{text "y'"} such that @{text "y' \<in> A"} and |
1158 @{term "\<approx>B `` {x - x'} = \<approx>B `` {y - y'}"}. This equality means that |
1192 @{term "\<approx>B `` {x - x'} = \<approx>B `` {y - y'}"}. This equality means that |
1159 @{term "(x - x') \<approx>B (y - y')"} holds. Unfolding the Myhill-Nerode |
1193 @{term "(x - x') \<approx>B (y - y')"} holds. Unfolding the Myhill-Nerode |
1160 relation and together with the fact that @{text "(x - x') @ z \<in> B"}, we |
1194 relation and together with the fact that @{text "(x - x') @ z \<in> B"}, we |
1161 have @{text "(y - y') @ z \<in> B"}. We already know @{text "y' \<in> A"}, therefore |
1195 have @{text "(y - y') @ z \<in> B"}. We already know @{text "y' \<in> A"}, therefore |
1162 @{term "y @ z \<in> A ;; B"}, as needed in this case. |
1196 @{term "y @ z \<in> A \<cdot> B"}, as needed in this case. |
1163 |
1197 |
1164 Second, there exists a @{text "z'"} such that @{term "x @ z' \<in> A"} and @{text "z - z' \<in> B"}. |
1198 Second, there exists a @{text "z'"} such that @{term "x @ z' \<in> A"} and @{text "z - z' \<in> B"}. |
1165 By the assumption about @{term "tag_str_SEQ A B"} we have |
1199 By the assumption about @{term "tag_str_SEQ A B"} we have |
1166 @{term "\<approx>A `` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Which means by the Myhill-Nerode |
1200 @{term "\<approx>A `` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Which means by the Myhill-Nerode |
1167 relation that @{term "y @ z' \<in> A"} holds. Using @{text "z - z' \<in> B"}, we can conclude also in this case |
1201 relation that @{term "y @ z' \<in> A"} holds. Using @{text "z - z' \<in> B"}, we can conclude also in this case |
1168 with @{term "y @ z \<in> A ;; B"}. We again can complete the @{const SEQ}-case |
1202 with @{term "y @ z \<in> A \<cdot> B"}. We again can complete the @{const SEQ}-case |
1169 by setting @{text A} to @{term "L r\<^isub>1"} and @{text B} to @{term "L r\<^isub>2"}.\qed |
1203 by setting @{text A} to @{term "L r\<^isub>1"} and @{text B} to @{term "L r\<^isub>2"}.\qed |
1170 \end{proof} |
1204 \end{proof} |
1171 |
1205 |
1172 \noindent |
1206 \noindent |
1173 The case for @{const STAR} is similar to @{const SEQ}, but poses a few extra challenges. When |
1207 The case for @{const STAR} is similar to @{const SEQ}, but poses a few extra challenges. When |