209 text {* |
209 text {* |
210 \noindent |
210 \noindent |
211 Regular languages are an important and well-understood subject in Computer |
211 Regular languages are an important and well-understood subject in Computer |
212 Science, with many beautiful theorems and many useful algorithms. There is a |
212 Science, with many beautiful theorems and many useful algorithms. There is a |
213 wide range of textbooks on this subject, many of which are aimed at students |
213 wide range of textbooks on this subject, many of which are aimed at students |
214 and contain very detailed `pencil-and-paper' proofs (e.g.~\cite{Kozen97, |
214 and contain very detailed `pencil-and-paper' proofs |
215 HopcroftUllman69}). It seems natural to exercise theorem provers by |
215 (e.g.~\cite{HopcroftUllman69,Kozen97}). It seems natural to exercise theorem provers by |
216 formalising the theorems and by verifying formally the algorithms. |
216 formalising the theorems and by verifying formally the algorithms. |
217 |
217 |
218 A popular choice for a theorem prover would be one based on Higher-Order |
218 A popular choice for a theorem prover would be one based on Higher-Order |
219 Logic (HOL), for example HOL4, HOLlight or Isabelle/HOL. For the development |
219 Logic (HOL), for example HOL4, HOLlight or Isabelle/HOL. For the development |
220 presented in this paper we will use the Isabelle/HOL. HOL is a predicate calculus |
220 presented in this paper we will use the Isabelle/HOL. HOL is a predicate calculus |
237 \noindent |
237 \noindent |
238 This approach has many benefits. Among them is the fact that it is easy to |
238 This approach has many benefits. Among them is the fact that it is easy to |
239 convince oneself that regular languages are closed under complementation: |
239 convince oneself that regular languages are closed under complementation: |
240 one just has to exchange the accepting and non-accepting states in the |
240 one just has to exchange the accepting and non-accepting states in the |
241 corresponding automaton to obtain an automaton for the complement language. |
241 corresponding automaton to obtain an automaton for the complement language. |
242 The problem, however, lies with formalising such reasoning in a HOL-based |
242 The problem, however, lies with formalising such reasoning in a |
243 theorem prover. Automata are built up from states and transitions that need |
243 theorem prover. Automata are built up from states and transitions that are |
244 to be represented as graphs, matrices or functions, none of which can be |
244 usually represented as graphs, matrices or functions, none of which can be |
245 defined as an inductive datatype. |
245 defined as an inductive datatype. |
246 |
246 |
247 In case of graphs and matrices, this means we have to build our own |
247 In case of graphs and matrices, this means we have to build our own |
248 reasoning infrastructure for them, as neither Isabelle/HOL nor HOL4 nor |
248 reasoning infrastructure for them, as neither Isabelle/HOL nor HOL4 nor |
249 HOLlight support them with libraries. Even worse, reasoning about graphs and |
249 HOLlight support them with libraries. Even worse, reasoning about graphs and |
250 matrices can be a real hassle in HOL-based theorem provers, because |
250 matrices can be a real hassle in theorem provers, because |
251 we have to be able to combine automata. Consider for |
251 we have to be able to combine automata. Consider for |
252 example the operation of sequencing two automata, say $A_1$ and $A_2$, by |
252 example the operation of sequencing two automata, say $A_1$ and $A_2$, by |
253 connecting the accepting states of $A_1$ to the initial state of $A_2$: |
253 connecting the accepting states of $A_1$ to the initial state of $A_2$: |
254 |
254 |
255 \begin{center} |
255 \begin{center} |
379 carried out in HOL-based theorem provers. Nipkow \cite{Nipkow98} establishes |
379 carried out in HOL-based theorem provers. Nipkow \cite{Nipkow98} establishes |
380 the link between regular expressions and automata in the context of |
380 the link between regular expressions and automata in the context of |
381 lexing. Berghofer and Reiter \cite{BerghoferReiter09} formalise automata |
381 lexing. Berghofer and Reiter \cite{BerghoferReiter09} formalise automata |
382 working over bit strings in the context of Presburger arithmetic. The only |
382 working over bit strings in the context of Presburger arithmetic. The only |
383 larger formalisations of automata theory are carried out in Nuprl |
383 larger formalisations of automata theory are carried out in Nuprl |
384 \cite{Constable00} and in Coq, e.g.~\cite{Filliatre97,Almeidaetal10}. |
384 \cite{Constable00} and in Coq, e.g.~\cite{Almeidaetal10,Filliatre97}. |
385 |
385 |
386 Also, one might consider automata as just convenient `vehicles' for |
386 Also, one might consider automata as just convenient `vehicles' for |
387 establishing properties about regular languages. However, paper proofs |
387 establishing properties about regular languages. However, paper proofs |
388 about automata often involve subtle side-conditions which are easily |
388 about automata often involve subtle side-conditions which are easily |
389 overlooked, but which make formal reasoning rather painful. For example |
389 overlooked, but which make formal reasoning rather painful. For example |
515 involving equivalence classes of languages. For this we will use Arden's Lemma |
515 involving equivalence classes of languages. For this we will use Arden's Lemma |
516 (see for example \cite[Page 100]{Sakarovitch09}), |
516 (see for example \cite[Page 100]{Sakarovitch09}), |
517 which solves equations of the form @{term "X = A \<cdot> X \<union> B"} provided |
517 which solves equations of the form @{term "X = A \<cdot> X \<union> B"} provided |
518 @{term "[] \<notin> A"}. However we will need the following `reversed' |
518 @{term "[] \<notin> A"}. However we will need the following `reversed' |
519 version of Arden's Lemma (`reversed' in the sense of changing the order of @{term "A \<cdot> X"} to |
519 version of Arden's Lemma (`reversed' in the sense of changing the order of @{term "A \<cdot> X"} to |
520 \mbox{@{term "X \<cdot> A"}}). |
520 \mbox{@{term "X \<cdot> A"}}).\footnote{The details of its proof are given in the Appendix.} |
521 |
521 |
522 \begin{lmm}[Reversed Arden's Lemma]\label{arden}\mbox{}\\ |
522 \begin{lmm}[(Reversed Arden's Lemma)]\label{arden}\mbox{}\\ |
523 If @{thm (prem 1) reversed_Arden} then |
523 If @{thm (prem 1) reversed_Arden} then |
524 @{thm (lhs) reversed_Arden} if and only if |
524 @{thm (lhs) reversed_Arden} if and only if |
525 @{thm (rhs) reversed_Arden}. |
525 @{thm (rhs) reversed_Arden}. |
526 \end{lmm} |
526 \end{lmm} |
527 |
|
528 \begin{proof} |
|
529 For the right-to-left direction we assume @{thm (rhs) reversed_Arden} and show |
|
530 that @{thm (lhs) reversed_Arden} holds. From Property~\ref{langprops}@{text "(i)"} |
|
531 we have @{term "A\<star> = A \<cdot> A\<star> \<union> {[]}"}, |
|
532 which is equal to @{term "A\<star> = A\<star> \<cdot> A \<union> {[]}"}. Adding @{text B} to both |
|
533 sides gives @{term "B \<cdot> A\<star> = B \<cdot> (A\<star> \<cdot> A \<union> {[]})"}, whose right-hand side |
|
534 is equal to @{term "(B \<cdot> A\<star>) \<cdot> A \<union> B"}. Applying the assumed equation |
|
535 completes this direction. |
|
536 |
|
537 For the other direction we assume @{thm (lhs) reversed_Arden}. By a simple induction |
|
538 on @{text n}, we can establish the property |
|
539 |
|
540 \begin{center} |
|
541 @{text "(*)"}\hspace{5mm} @{thm (concl) reversed_arden_helper} |
|
542 \end{center} |
|
543 |
|
544 \noindent |
|
545 Using this property we can show that @{term "B \<cdot> (A \<up> n) \<subseteq> X"} holds for |
|
546 all @{text n}. From this we can infer @{term "B \<cdot> A\<star> \<subseteq> X"} using the definition |
|
547 of @{text "\<star>"}. |
|
548 For the inclusion in the other direction we assume a string @{text s} |
|
549 with length @{text k} is an element in @{text X}. Since @{thm (prem 1) reversed_Arden} |
|
550 we know by Property~\ref{langprops}@{text "(ii)"} that |
|
551 @{term "s \<notin> X \<cdot> (A \<up> Suc k)"} since its length is only @{text k} |
|
552 (the strings in @{term "X \<cdot> (A \<up> Suc k)"} are all longer). |
|
553 From @{text "(*)"} it follows then that |
|
554 @{term s} must be an element in @{term "(\<Union>m\<le>k. B \<cdot> (A \<up> m))"}. This in turn |
|
555 implies that @{term s} is in @{term "(\<Union>n. B \<cdot> (A \<up> n))"}. Using Property~\ref{langprops}@{text "(iii)"} |
|
556 this is equal to @{term "B \<cdot> A\<star>"}, as we needed to show. |
|
557 \end{proof} |
|
558 |
527 |
559 \noindent |
528 \noindent |
560 Regular expressions are defined as the inductive datatype |
529 Regular expressions are defined as the inductive datatype |
561 |
530 |
562 \begin{center} |
531 \begin{center} |
586 @{thm (rhs) lang.simps(6)[where r="r"]}\\ |
555 @{thm (rhs) lang.simps(6)[where r="r"]}\\ |
587 \end{tabular} |
556 \end{tabular} |
588 \end{center} |
557 \end{center} |
589 |
558 |
590 Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating |
559 Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating |
591 a regular expression that matches the union of all languages of @{text rs}. We only need to know the |
560 a regular expression that matches the union of all languages of @{text rs}. |
|
561 This definion is not trivial in a theorem prover, but since |
|
562 we only need to know the |
592 existence |
563 existence |
593 of such a regular expression and therefore we use Isabelle/HOL's @{const "fold_graph"} and Hilbert's |
564 of such a regular expression, we can use Isabelle/HOL's @{const "fold_graph"} and Hilbert's |
594 @{text "\<epsilon>"} to define @{term "\<Uplus>rs"}. This operation, roughly speaking, folds @{const PLUS} over the |
565 @{text "\<epsilon>"} to define @{term "\<Uplus>rs"}. This operation, roughly speaking, folds @{const PLUS} over the |
595 set @{text rs} with @{const ZERO} for the empty set. We can prove that for a finite set @{text rs} |
566 set @{text rs} with @{const ZERO} for the empty set. We can prove that for a finite set @{text rs} |
596 % |
567 % |
597 \begin{equation}\label{uplus} |
568 \begin{equation}\label{uplus} |
598 \mbox{@{thm (lhs) folds_plus_simp} @{text "= \<Union> (\<calL> ` rs)"}} |
569 \mbox{@{thm (lhs) folds_plus_simp} @{text "= \<Union> (\<calL> ` rs)"}} |
618 The key definition in the Myhill-Nerode Theorem is the |
589 The key definition in the Myhill-Nerode Theorem is the |
619 \emph{Myhill-Nerode Relation}, which states that w.r.t.~a language two |
590 \emph{Myhill-Nerode Relation}, which states that w.r.t.~a language two |
620 strings are related, provided there is no distinguishing extension in this |
591 strings are related, provided there is no distinguishing extension in this |
621 language. This can be defined as a ternary relation. |
592 language. This can be defined as a ternary relation. |
622 |
593 |
623 \begin{dfntn}[Myhill-Nerode Relation]\label{myhillneroderel} |
594 \begin{dfntn}[(Myhill-Nerode Relation)]\label{myhillneroderel} |
624 Given a language @{text A}, two strings @{text x} and |
595 Given a language @{text A}, two strings @{text x} and |
625 @{text y} are Myhill-Nerode related provided |
596 @{text y} are Myhill-Nerode related provided |
626 \begin{center} |
597 \begin{center} |
627 @{thm str_eq_def'} |
598 @{thm str_eq_def'} |
628 \end{center} |
599 \end{center} |
1156 |
1127 |
1157 \noindent |
1128 \noindent |
1158 Lemma~\ref{every_eqcl_has_reg} allows us to finally give a proof for the first direction |
1129 Lemma~\ref{every_eqcl_has_reg} allows us to finally give a proof for the first direction |
1159 of the Myhill-Nerode Theorem. |
1130 of the Myhill-Nerode Theorem. |
1160 |
1131 |
1161 \begin{proof}[Proof of Theorem~\ref{myhillnerodeone}] |
1132 \begin{proof}[of Theorem~\ref{myhillnerodeone}] |
1162 By Lemma~\ref{every_eqcl_has_reg} we know that there exists a regular expression for |
1133 By Lemma~\ref{every_eqcl_has_reg} we know that there exists a regular expression for |
1163 every equivalence class in @{term "UNIV // \<approx>A"}. Since @{text "finals A"} is |
1134 every equivalence class in @{term "UNIV // \<approx>A"}. Since @{text "finals A"} is |
1164 a subset of @{term "UNIV // \<approx>A"}, we also know that for every equivalence class |
1135 a subset of @{term "UNIV // \<approx>A"}, we also know that for every equivalence class |
1165 in @{term "finals A"} there exists a regular expression. Moreover by assumption |
1136 in @{term "finals A"} there exists a regular expression. Moreover by assumption |
1166 we know that @{term "finals A"} must be finite, and therefore there must be a finite |
1137 we know that @{term "finals A"} must be finite, and therefore there must be a finite |
1196 \noindent |
1167 \noindent |
1197 The proof will be by induction on the structure of @{text r}. It turns out |
1168 The proof will be by induction on the structure of @{text r}. It turns out |
1198 the base cases are straightforward. |
1169 the base cases are straightforward. |
1199 |
1170 |
1200 |
1171 |
1201 \begin{proof}[Base Cases] |
1172 \begin{proof}[(Base Cases)] |
1202 The cases for @{const ZERO}, @{const ONE} and @{const ATOM} are routine, because |
1173 The cases for @{const ZERO}, @{const ONE} and @{const ATOM} are routine, because |
1203 we can easily establish that |
1174 we can easily establish that |
1204 |
1175 |
1205 \begin{center} |
1176 \begin{center} |
1206 \begin{tabular}{l} |
1177 \begin{tabular}{l} |
1280 @{term "\<approx>(lang r)"}, which implies that @{term "UNIV // \<approx>(lang r)"} must |
1251 @{term "\<approx>(lang r)"}, which implies that @{term "UNIV // \<approx>(lang r)"} must |
1281 also be finite. We formally define the notion of a \emph{tagging-relation} |
1252 also be finite. We formally define the notion of a \emph{tagging-relation} |
1282 as follows. |
1253 as follows. |
1283 |
1254 |
1284 |
1255 |
1285 \begin{dfntn}[Tagging-Relation] Given a tagging-function @{text tag}, then two strings @{text x} |
1256 \begin{dfntn}[(Tagging-Relation)] Given a tagging-function @{text tag}, then two strings @{text x} |
1286 and @{text y} are \emph{tag-related} provided |
1257 and @{text y} are \emph{tag-related} provided |
1287 \begin{center} |
1258 \begin{center} |
1288 @{text "x \<^raw:$\threesim$>\<^bsub>tag\<^esub> y \<equiv> tag x = tag y"}\;. |
1259 @{text "x \<^raw:$\threesim$>\<^bsub>tag\<^esub> y \<equiv> tag x = tag y"}\;. |
1289 \end{center} |
1260 \end{center} |
1290 \end{dfntn} |
1261 \end{dfntn} |
1358 is that we need to establish that @{term "=(tag_Plus A B)="} refines @{term "\<approx>(A \<union> B)"}. |
1329 is that we need to establish that @{term "=(tag_Plus A B)="} refines @{term "\<approx>(A \<union> B)"}. |
1359 This amounts to showing @{term "x \<approx>A y"} or @{term "x \<approx>B y"} under the assumption |
1330 This amounts to showing @{term "x \<approx>A y"} or @{term "x \<approx>B y"} under the assumption |
1360 @{term "x"}~@{term "=(tag_Plus A B)="}~@{term y}. As we shall see, this definition will |
1331 @{term "x"}~@{term "=(tag_Plus A B)="}~@{term y}. As we shall see, this definition will |
1361 provide us with just the right assumptions in order to get the proof through. |
1332 provide us with just the right assumptions in order to get the proof through. |
1362 |
1333 |
1363 \begin{proof}[@{const "PLUS"}-Case] |
1334 \begin{proof}[(@{const "PLUS"}-Case)] |
1364 We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite |
1335 We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite |
1365 (UNIV // \<approx>B)"} then @{term "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))"} |
1336 (UNIV // \<approx>B)"} then @{term "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))"} |
1366 holds. The range of @{term "tag_Plus A B"} is a subset of this product |
1337 holds. The range of @{term "tag_Plus A B"} is a subset of this product |
1367 set---so finite. For the refinement proof-obligation, we know that @{term |
1338 set---so finite. For the refinement proof-obligation, we know that @{term |
1368 "(\<approx>A `` {x}, \<approx>B `` {x}) = (\<approx>A `` {y}, \<approx>B `` {y})"} holds by assumption. Then |
1339 "(\<approx>A `` {x}, \<approx>B `` {x}) = (\<approx>A `` {y}, \<approx>B `` {y})"} holds by assumption. Then |
1402 this string to be in @{term "A \<cdot> B"}: |
1373 this string to be in @{term "A \<cdot> B"}: |
1403 % |
1374 % |
1404 \begin{center} |
1375 \begin{center} |
1405 \begin{tabular}{c} |
1376 \begin{tabular}{c} |
1406 \scalebox{1}{ |
1377 \scalebox{1}{ |
1407 \begin{tikzpicture}[fill=gray!20] |
1378 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1408 \node[draw,minimum height=3.8ex, fill] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ }; |
1379 \node[draw,minimum height=3.8ex, fill] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ }; |
1409 \node[draw,minimum height=3.8ex, right=-0.03em of x, fill] (za) { $\hspace{0.6em}@{text "z\<^isub>p"}\hspace{0.6em}$ }; |
1380 \node[draw,minimum height=3.8ex, right=-0.03em of x, fill] (za) { $\hspace{0.6em}@{text "z\<^isub>p"}\hspace{0.6em}$ }; |
1410 \node[draw,minimum height=3.8ex, right=-0.03em of za, fill] (zza) { $\hspace{2.6em}@{text "z\<^isub>s"}\hspace{2.6em}$ }; |
1381 \node[draw,minimum height=3.8ex, right=-0.03em of za, fill] (zza) { $\hspace{2.6em}@{text "z\<^isub>s"}\hspace{2.6em}$ }; |
1411 |
1382 |
1412 \draw[decoration={brace,transform={yscale=3}},decorate] |
1383 \draw[decoration={brace,transform={yscale=3}},decorate] |
1429 ($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$) |
1400 ($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$) |
1430 node[midway, below=0.5em]{@{text "z\<^isub>s \<in> B"}}; |
1401 node[midway, below=0.5em]{@{text "z\<^isub>s \<in> B"}}; |
1431 \end{tikzpicture}} |
1402 \end{tikzpicture}} |
1432 \\[2mm] |
1403 \\[2mm] |
1433 \scalebox{1}{ |
1404 \scalebox{1}{ |
1434 \begin{tikzpicture}[fill=gray!20] |
1405 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1435 \node[draw,minimum height=3.8ex, fill] (xa) { $\hspace{3em}@{text "x\<^isub>p"}\hspace{3em}$ }; |
1406 \node[draw,minimum height=3.8ex, fill] (xa) { $\hspace{3em}@{text "x\<^isub>p"}\hspace{3em}$ }; |
1436 \node[draw,minimum height=3.8ex, right=-0.03em of xa, fill] (xxa) { $\hspace{0.2em}@{text "x\<^isub>s"}\hspace{0.2em}$ }; |
1407 \node[draw,minimum height=3.8ex, right=-0.03em of xa, fill] (xxa) { $\hspace{0.2em}@{text "x\<^isub>s"}\hspace{0.2em}$ }; |
1437 \node[draw,minimum height=3.8ex, right=-0.03em of xxa, fill] (z) { $\hspace{5em}@{text z}\hspace{5em}$ }; |
1408 \node[draw,minimum height=3.8ex, right=-0.03em of xxa, fill] (z) { $\hspace{5em}@{text z}\hspace{5em}$ }; |
1438 |
1409 |
1439 \draw[decoration={brace,transform={yscale=3}},decorate] |
1410 \draw[decoration={brace,transform={yscale=3}},decorate] |
1482 Note that we have to make the assumption for all suffixes @{text "x\<^isub>s"}, since we do |
1453 Note that we have to make the assumption for all suffixes @{text "x\<^isub>s"}, since we do |
1483 not know anything about how the string @{term x} is partitioned. |
1454 not know anything about how the string @{term x} is partitioned. |
1484 With this definition in place, let us prove the @{const "Times"}-case. |
1455 With this definition in place, let us prove the @{const "Times"}-case. |
1485 |
1456 |
1486 |
1457 |
1487 \begin{proof}[@{const TIMES}-Case] |
1458 \begin{proof}[(@{const TIMES}-Case)] |
1488 If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
1459 If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
1489 then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of |
1460 then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of |
1490 @{term "tag_Times A B"} is a subset of this product set, and therefore finite. |
1461 @{term "tag_Times A B"} is a subset of this product set, and therefore finite. |
1491 For the refinement of @{term "\<approx>(A \<cdot> B)"} and @{text "\<^raw:$\threesim$>\<^bsub>\<times>tag A B\<^esub>"}, |
1462 For the refinement of @{term "\<approx>(A \<cdot> B)"} and @{text "\<^raw:$\threesim$>\<^bsub>\<times>tag A B\<^esub>"}, |
1492 we have by Lemma \ref{refinement} |
1463 we have by Lemma \ref{refinement} |
1545 When analysing the case of @{text "x @ z"} being an element in @{term "A\<star>"} |
1516 When analysing the case of @{text "x @ z"} being an element in @{term "A\<star>"} |
1546 and @{text x} is not the empty string, we have the following picture: |
1517 and @{text x} is not the empty string, we have the following picture: |
1547 |
1518 |
1548 \begin{center} |
1519 \begin{center} |
1549 \scalebox{1}{ |
1520 \scalebox{1}{ |
1550 \begin{tikzpicture}[fill=gray!20] |
1521 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1551 \node[draw,minimum height=3.8ex, fill] (xa) { $\hspace{4em}@{text "x\<^bsub>pmax\<^esub>"}\hspace{4em}$ }; |
1522 \node[draw,minimum height=3.8ex, fill] (xa) { $\hspace{4em}@{text "x\<^bsub>pmax\<^esub>"}\hspace{4em}$ }; |
1552 \node[draw,minimum height=3.8ex, right=-0.03em of xa, fill] (xxa) { $\hspace{0.5em}@{text "x\<^bsub>s\<^esub>"}\hspace{0.5em}$ }; |
1523 \node[draw,minimum height=3.8ex, right=-0.03em of xa, fill] (xxa) { $\hspace{0.5em}@{text "x\<^bsub>s\<^esub>"}\hspace{0.5em}$ }; |
1553 \node[draw,minimum height=3.8ex, right=-0.03em of xxa, fill] (za) { $\hspace{2em}@{text "z\<^isub>a"}\hspace{2em}$ }; |
1524 \node[draw,minimum height=3.8ex, right=-0.03em of xxa, fill] (za) { $\hspace{2em}@{text "z\<^isub>a"}\hspace{2em}$ }; |
1554 \node[draw,minimum height=3.8ex, right=-0.03em of za, fill] (zb) { $\hspace{7em}@{text "z\<^isub>b"}\hspace{7em}$ }; |
1525 \node[draw,minimum height=3.8ex, right=-0.03em of za, fill] (zb) { $\hspace{7em}@{text "z\<^isub>b"}\hspace{7em}$ }; |
1555 |
1526 |
1607 \begin{center} |
1578 \begin{center} |
1608 @{thm (lhs) tag_Star_def[where ?A="A", THEN meta_eq_app]}~@{text "\<equiv>"}~ |
1579 @{thm (lhs) tag_Star_def[where ?A="A", THEN meta_eq_app]}~@{text "\<equiv>"}~ |
1609 @{text "{\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^isub>p < x \<and> x\<^isub>p \<in> A\<^isup>\<star> \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x}"} |
1580 @{text "{\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^isub>p < x \<and> x\<^isub>p \<in> A\<^isup>\<star> \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x}"} |
1610 \end{center} |
1581 \end{center} |
1611 |
1582 |
1612 \begin{proof}[@{const Star}-Case] |
1583 \begin{proof}[(@{const Star}-Case)] |
1613 If @{term "finite (UNIV // \<approx>A)"} |
1584 If @{term "finite (UNIV // \<approx>A)"} |
1614 then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
1585 then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
1615 @{term "tag_Star A"} is a subset of this set, and therefore finite. |
1586 @{term "tag_Star A"} is a subset of this set, and therefore finite. |
1616 Again we have to show under the assumption @{term "x"}~@{term "=(tag_Star A)="}~@{term y} |
1587 Again we have to show under the assumption @{term "x"}~@{term "=(tag_Star A)="}~@{term y} |
1617 that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}. |
1588 that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}. |
1644 A\<star>"}, which means @{term "y @ z \<in> A\<star>"}. The last step is to set |
1615 A\<star>"}, which means @{term "y @ z \<in> A\<star>"}. The last step is to set |
1645 @{text "A"} to @{term "lang r"} and thus complete the proof. |
1616 @{text "A"} to @{term "lang r"} and thus complete the proof. |
1646 \end{proof} |
1617 \end{proof} |
1647 *} |
1618 *} |
1648 |
1619 |
1649 section {* Second Part proved using Partial Derivatives\label{derivatives} *} |
1620 section {* Second Part proved using Partial Derivatives *} |
1650 |
1621 |
1651 text {* |
1622 text {* |
|
1623 \label{derivatives} |
1652 \noindent |
1624 \noindent |
1653 As we have seen in the previous section, in order to establish |
1625 As we have seen in the previous section, in order to establish |
1654 the second direction of the Myhill-Nerode Theorem, it is sufficient to find |
1626 the second direction of the Myhill-Nerode Theorem, it is sufficient to find |
1655 a more refined relation than @{term "\<approx>(lang r)"} for which we can |
1627 a more refined relation than @{term "\<approx>(lang r)"} for which we can |
1656 show that there are only finitely many equivalence classes. So far we |
1628 show that there are only finitely many equivalence classes. So far we |
1715 regular expressions can be calculated directly using the notion of |
1687 regular expressions can be calculated directly using the notion of |
1716 \emph{derivatives of a regular expression} \cite{Brzozowski64}. We define |
1688 \emph{derivatives of a regular expression} \cite{Brzozowski64}. We define |
1717 this notion in Isabelle/HOL as follows: |
1689 this notion in Isabelle/HOL as follows: |
1718 |
1690 |
1719 \begin{center} |
1691 \begin{center} |
1720 \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1692 \begin{longtable}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1721 @{thm (lhs) deriv.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(1)}\\ |
1693 @{thm (lhs) deriv.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(1)}\\ |
1722 @{thm (lhs) deriv.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(2)}\\ |
1694 @{thm (lhs) deriv.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(2)}\\ |
1723 @{thm (lhs) deriv.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(3)[where c'="d"]}\\ |
1695 @{thm (lhs) deriv.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(3)[where c'="d"]}\\ |
1724 @{thm (lhs) deriv.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1696 @{thm (lhs) deriv.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1725 & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
1697 & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
1728 @{term "Plus (Times (deriv c r\<^isub>1) r\<^isub>2) (deriv c r\<^isub>2)"}\\ |
1700 @{term "Plus (Times (deriv c r\<^isub>1) r\<^isub>2) (deriv c r\<^isub>2)"}\\ |
1729 & & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~% |
1701 & & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~% |
1730 @{term "Times (deriv c r\<^isub>1) r\<^isub>2"}\\ |
1702 @{term "Times (deriv c r\<^isub>1) r\<^isub>2"}\\ |
1731 @{thm (lhs) deriv.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(6)}\smallskip\\ |
1703 @{thm (lhs) deriv.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(6)}\smallskip\\ |
1732 @{thm (lhs) derivs.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) derivs.simps(1)}\\ |
1704 @{thm (lhs) derivs.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) derivs.simps(1)}\\ |
1733 @{thm (lhs) derivs.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) derivs.simps(2)}\\ |
1705 @{thm (lhs) derivs.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) derivs.simps(2)} |
1734 \end{tabular} |
1706 \end{longtable} |
1735 \end{center} |
1707 \end{center} |
1736 |
1708 |
1737 \noindent |
1709 \noindent |
1738 The last two clauses extend derivatives from characters to strings. The |
1710 The last two clauses extend derivatives from characters to strings. The |
1739 boolean function @{term "nullable r"} needed in the @{const Times}-case tests |
1711 boolean function @{term "nullable r"} needed in the @{const Times}-case tests |
1984 Let us now return to our proof for the second direction in the Myhill-Nerode |
1956 Let us now return to our proof for the second direction in the Myhill-Nerode |
1985 Theorem. The point of the above calculations is to use |
1957 Theorem. The point of the above calculations is to use |
1986 @{text "\<^raw:$\threesim$>\<^bsub>(\<lambda>x. pders x r)\<^esub>"} as tagging-relation. |
1958 @{text "\<^raw:$\threesim$>\<^bsub>(\<lambda>x. pders x r)\<^esub>"} as tagging-relation. |
1987 |
1959 |
1988 |
1960 |
1989 \begin{proof}[Proof of Theorem~\ref{myhillnerodetwo} (second version)] |
1961 \begin{proof}[of Theorem~\ref{myhillnerodetwo} (second version)] |
1990 Using \eqref{mhders} |
1962 Using \eqref{mhders} |
1991 and \eqref{Derspders} we can easily infer that |
1963 and \eqref{Derspders} we can easily infer that |
1992 |
1964 |
1993 \begin{center} |
1965 \begin{center} |
1994 @{term "x \<approx>(lang r) y"}\hspace{4mm}\mbox{provided}\hspace{4mm}@{term "pderivs x r = pderivs y r"} |
1966 @{term "x \<approx>(lang r) y"}\hspace{4mm}\mbox{provided}\hspace{4mm}@{term "pderivs x r = pderivs y r"} |
2013 This relation refines @{term "\<approx>(lang r)"}, and therefore we can again conclude the |
1985 This relation refines @{term "\<approx>(lang r)"}, and therefore we can again conclude the |
2014 second part of the Myhill-Nerode Theorem. |
1986 second part of the Myhill-Nerode Theorem. |
2015 \end{proof} |
1987 \end{proof} |
2016 *} |
1988 *} |
2017 |
1989 |
2018 section {* Closure Properties of Regular Languages\label{closure} *} |
1990 section {* Closure Properties of Regular Languages *} |
2019 |
1991 |
2020 text {* |
1992 text {* |
|
1993 \label{closure} |
2021 \noindent |
1994 \noindent |
2022 The beauty of regular languages is that they are closed under many set |
1995 The beauty of regular languages is that they are closed under many set |
2023 operations. Closure under union, concatenation and Kleene-star are trivial |
1996 operations. Closure under union, concatenation and Kleene-star are trivial |
2024 to establish given our definition of regularity (recall Definition~\ref{regular}). |
1997 to establish given our definition of regularity (recall Definition~\ref{regular}). |
2025 More interesting in our setting is the closure under complement, because it seems difficult |
1998 More interesting in our setting is the closure under complement, because it seems difficult |
2040 Calculating such a regular expression via |
2013 Calculating such a regular expression via |
2041 automata using the standard method would be quite involved. It includes the |
2014 automata using the standard method would be quite involved. It includes the |
2042 steps: regular expression @{text "\<Rightarrow>"} non-deterministic automaton @{text |
2015 steps: regular expression @{text "\<Rightarrow>"} non-deterministic automaton @{text |
2043 "\<Rightarrow>"} deterministic automaton @{text "\<Rightarrow>"} complement automaton @{text "\<Rightarrow>"} |
2016 "\<Rightarrow>"} deterministic automaton @{text "\<Rightarrow>"} complement automaton @{text "\<Rightarrow>"} |
2044 regular expression. Clearly not something you want to formalise in a theorem |
2017 regular expression. Clearly not something you want to formalise in a theorem |
2045 prover in which it is cumbersome to reason about automata. |
2018 prover if it is cumbersome to reason about automata. |
2046 |
2019 |
2047 Once closure under complement is established, closure under intersection |
2020 Once closure under complement is established, closure under intersection |
2048 and set difference is also easy, because |
2021 and set difference is also easy, because |
2049 |
2022 |
2050 \begin{center} |
2023 \begin{center} |
2117 r))"}}. Thus the regular expression @{term "\<Uplus>(pderivs_lang B r)"} verifies that |
2090 r))"}}. Thus the regular expression @{term "\<Uplus>(pderivs_lang B r)"} verifies that |
2118 @{term "Deriv_lang B A"} is regular. |
2091 @{term "Deriv_lang B A"} is regular. |
2119 |
2092 |
2120 Even more surprising is the fact that for \emph{every} language @{text A}, the language |
2093 Even more surprising is the fact that for \emph{every} language @{text A}, the language |
2121 consisting of all (scattered) substrings of @{text A} is regular \cite{Haines69} (see also |
2094 consisting of all (scattered) substrings of @{text A} is regular \cite{Haines69} (see also |
2122 \cite{Shallit08, Gasarch09}). |
2095 \cite{Shallit08,Gasarch09}). |
2123 A \emph{(scattered) substring} can be obtained |
2096 A \emph{(scattered) substring} can be obtained |
2124 by striking out zero or more characters from a string. This can be defined |
2097 by striking out zero or more characters from a string. This can be defined |
2125 inductively in Isabelle/HOL by the following three rules: |
2098 inductively in Isabelle/HOL by the following three rules: |
2126 |
2099 |
2127 \begin{center} |
2100 \begin{center} |
2248 \end{proof} |
2221 \end{proof} |
2249 |
2222 |
2250 \noindent |
2223 \noindent |
2251 This lemma allows us to establish the second part of Theorem~\ref{subseqreg}. |
2224 This lemma allows us to establish the second part of Theorem~\ref{subseqreg}. |
2252 |
2225 |
2253 \begin{proof}[Proof of the Second Part of Theorem~\ref{subseqreg}] |
2226 \begin{proof}[of the Second Part of Theorem~\ref{subseqreg}] |
2254 Given any language @{text A}, by Lemma~\ref{mset} we know there exists |
2227 Given any language @{text A}, by Lemma~\ref{mset} we know there exists |
2255 a finite, and thus regular, language @{text M}. We further have @{term "SUPSEQ M = SUPSEQ A"}, |
2228 a finite, and thus regular, language @{text M}. We further have @{term "SUPSEQ M = SUPSEQ A"}, |
2256 which establishes the second part. |
2229 which establishes the second part. |
2257 \end{proof} |
2230 \end{proof} |
2258 |
2231 |
2265 \end{equation} |
2238 \end{equation} |
2266 |
2239 |
2267 \noindent |
2240 \noindent |
2268 holds. Now the first part of Theorem~\ref{subseqreg} is a simple consequence of the second part. |
2241 holds. Now the first part of Theorem~\ref{subseqreg} is a simple consequence of the second part. |
2269 |
2242 |
2270 \begin{proof}[Proof of the First Part of Theorem~\ref{subseqreg}] |
2243 \begin{proof}[of the First Part of Theorem~\ref{subseqreg}] |
2271 By the second part, we know the right-hand side of \eqref{compl} |
2244 By the second part, we know the right-hand side of \eqref{compl} |
2272 is regular, which means @{term "- SUBSEQ A"} is regular. But since |
2245 is regular, which means @{term "- SUBSEQ A"} is regular. But since |
2273 we established already that regularity is preserved under complement, also @{term "SUBSEQ A"} |
2246 we established already that regularity is preserved under complement, also @{term "SUBSEQ A"} |
2274 must be regular. |
2247 must be regular. |
2275 \end{proof} |
2248 \end{proof} |
2276 |
2249 |
2277 Finally we like to show that the Myhill-Nerode Theorem is also convenient for establishing |
2250 Finally we like to show that the Myhill-Nerode Theorem is also convenient for establishing |
2278 the non-regularity of languages. For this we use the following version of the Continuation |
2251 the non-regularity of languages. For this we use the following version of the Continuation |
2279 Lemma (see for example~\cite{Rosenberg06}). |
2252 Lemma (see for example~\cite{Rosenberg06}). |
2280 |
2253 |
2281 \begin{lmm}[Continuation Lemma] |
2254 \begin{lmm}[(Continuation Lemma)] |
2282 If a language @{text A} is regular and a set of strings @{text B} is infinite, |
2255 If a language @{text A} is regular and a set of strings @{text B} is infinite, |
2283 then there exist two distinct strings @{text x} and @{text y} in @{text B} |
2256 then there exist two distinct strings @{text x} and @{text y} in @{text B} |
2284 such that @{term "x \<approx>A y"}. |
2257 such that @{term "x \<approx>A y"}. |
2285 \end{lmm} |
2258 \end{lmm} |
2286 |
2259 |
2322 |
2295 |
2323 text {* |
2296 text {* |
2324 \noindent |
2297 \noindent |
2325 In this paper we took the view that a regular language is one where there |
2298 In this paper we took the view that a regular language is one where there |
2326 exists a regular expression that matches all of its strings. Regular |
2299 exists a regular expression that matches all of its strings. Regular |
2327 expressions can conveniently be defined as a datatype in HOL-based theorem |
2300 expressions can conveniently be defined as a datatype in theorem |
2328 provers. For us it was therefore interesting to find out how far we can push |
2301 provers. For us it was therefore interesting to find out how far we can push |
2329 this point of view. We have established in Isabelle/HOL both directions |
2302 this point of view. We have established in Isabelle/HOL both directions |
2330 of the Myhill-Nerode Theorem. |
2303 of the Myhill-Nerode Theorem. |
2331 % |
2304 % |
2332 \begin{thrm}[The Myhill-Nerode Theorem]\mbox{}\\ |
2305 \begin{thrm}[(The Myhill-Nerode Theorem)]\mbox{}\\ |
2333 A language @{text A} is regular if and only if @{thm (rhs) Myhill_Nerode}. |
2306 A language @{text A} is regular if and only if @{thm (rhs) Myhill_Nerode}. |
2334 \end{thrm} |
2307 \end{thrm} |
2335 |
2308 |
2336 \noindent |
2309 \noindent |
2337 Having formalised this theorem means we pushed our point of view quite |
2310 Having formalised this theorem means we pushed our point of view quite |
2344 construct a regular expression for the complement language by direct |
2317 construct a regular expression for the complement language by direct |
2345 means. However the existence of such a regular expression can be easily |
2318 means. However the existence of such a regular expression can be easily |
2346 proved using the Myhill-Nerode Theorem. |
2319 proved using the Myhill-Nerode Theorem. |
2347 |
2320 |
2348 Our insistence on regular expressions for proving the Myhill-Nerode Theorem |
2321 Our insistence on regular expressions for proving the Myhill-Nerode Theorem |
2349 arose from the limitations of HOL, which is the logic underlying the popular theorem provers HOL4, |
2322 arose from the problem of defining formally the regularity of a language. |
2350 HOLlight and Isabelle/HOL. In order to guarantee consistency, |
2323 In order to guarantee consistency, |
2351 formalisations in HOL can only extend the logic with definitions that introduce a new concept in |
2324 formalisations in HOL can only extend the logic with definitions that introduce a new concept in |
2352 terms of already existing notions. A convenient definition for automata |
2325 terms of already existing notions. A convenient definition for automata |
2353 (based on graphs) uses a polymorphic type for the state nodes. This allows |
2326 (based on graphs) uses a polymorphic type for the state nodes. This allows |
2354 us to use the standard operation for disjoint union whenever we need to compose two |
2327 us to use the standard operation for disjoint union whenever we need to compose two |
2355 automata. Unfortunately, we cannot use such a polymorphic definition |
2328 automata. Unfortunately, we cannot use such a polymorphic definition |
2365 @{text "M"} (indicated by dependency on the type-variable @{text "\<alpha>"}), but the definiendum |
2338 @{text "M"} (indicated by dependency on the type-variable @{text "\<alpha>"}), but the definiendum |
2366 @{text "is_regular"} is not. Such definitions are excluded from HOL, because |
2339 @{text "is_regular"} is not. Such definitions are excluded from HOL, because |
2367 they can lead easily to inconsistencies (see \cite{PittsHOL4} for a simple |
2340 they can lead easily to inconsistencies (see \cite{PittsHOL4} for a simple |
2368 example). Also HOL does not contain type-quantifiers which would allow us to |
2341 example). Also HOL does not contain type-quantifiers which would allow us to |
2369 get rid of the polymorphism by quantifying over the type-variable @{text |
2342 get rid of the polymorphism by quantifying over the type-variable @{text |
2370 "\<alpha>"}. Therefore when defining regularity in terms of automata, the only |
2343 "\<alpha>"}. Therefore when defining regularity in terms of automata, the |
2371 natural way out in HOL is to resort to state nodes with an identity, for |
2344 natural way out in HOL is to resort to state nodes with an identity, for |
2372 example a natural number. Unfortunatly, the consequence is that we have to |
2345 example a natural number. Unfortunatly, the consequence is that we have to |
2373 be careful when combining two automata so that there is no clash between two |
2346 be careful when combining two automata so that there is no clash between two |
2374 such states. This makes formalisations quite fiddly and rather |
2347 such states. This makes formalisations quite fiddly and rather |
2375 unpleasant. Regular expressions proved much more convenient for reasoning in |
2348 unpleasant. Regular expressions proved much more convenient for reasoning in |
2471 \cite{Filliatre97}. More recently, Almeida et al reported about another |
2444 \cite{Filliatre97}. More recently, Almeida et al reported about another |
2472 formalisation of regular languages in Coq \cite{Almeidaetal10}. Their |
2445 formalisation of regular languages in Coq \cite{Almeidaetal10}. Their |
2473 main result is the |
2446 main result is the |
2474 correctness of Mirkin's construction of an automaton from a regular |
2447 correctness of Mirkin's construction of an automaton from a regular |
2475 expression using partial derivatives. This took approximately 10600 lines |
2448 expression using partial derivatives. This took approximately 10600 lines |
2476 of code. In terms of time, the estimate for our formalisation is that we |
2449 of code. Also Braibant formalised a large part of regular language |
|
2450 theory and Kleene algebras in Coq \cite{Braibant12}. While he is mainly interested |
|
2451 in implementing decision procedures for Kleene algebras, his library |
|
2452 includes a proof of the Myhill-Nerode theorem. He reckons that our |
|
2453 ``development is more concise'' than his one based on matrices \cite[Page 67]{Braibant12}. |
|
2454 In terms of time, the estimate for our formalisation is that we |
2477 needed approximately 3 months and this included the time to find our proof |
2455 needed approximately 3 months and this included the time to find our proof |
2478 arguments. Unlike Constable et al, who were able to follow the Myhill-Nerode |
2456 arguments. Unlike Constable et al, who were able to follow the Myhill-Nerode |
2479 proof from \cite{HopcroftUllman69}, we had to find our own arguments. So for us the |
2457 proof from \cite{HopcroftUllman69}, we had to find our own arguments. So for us the |
2480 formalisation was not the bottleneck. The code of |
2458 formalisation was not the bottleneck. The code of |
2481 our formalisation can be found in the Archive of Formal Proofs at |
2459 our formalisation can be found in the Archive of Formal Proofs at |
2485 \noindent |
2463 \noindent |
2486 {\bf Acknowledgements:} |
2464 {\bf Acknowledgements:} |
2487 We are grateful for the comments we received from Larry Paulson. Tobias |
2465 We are grateful for the comments we received from Larry Paulson. Tobias |
2488 Nipkow made us aware of the properties in Theorem~\ref{subseqreg} and Tjark |
2466 Nipkow made us aware of the properties in Theorem~\ref{subseqreg} and Tjark |
2489 Weber helped us with proving them. |
2467 Weber helped us with proving them. |
|
2468 |
|
2469 \bibliographystyle{plain} |
|
2470 \bibliography{root} |
|
2471 |
|
2472 \newpage |
|
2473 \begin{appendix} |
|
2474 \section{Appendix$^\star$} |
|
2475 |
|
2476 \renewcommand{\thefootnote}{\mbox{$\star$}} |
|
2477 \footnotetext{If the reviewers deem more suitable, the authors are |
|
2478 prepared to drop material or move it to an electronic appendix.} |
|
2479 |
|
2480 \begin{proof}[of Lemma~\ref{arden}] |
|
2481 For the right-to-left direction we assume @{thm (rhs) reversed_Arden} and show |
|
2482 that @{thm (lhs) reversed_Arden} holds. From Property~\ref{langprops}@{text "(i)"} |
|
2483 we have @{term "A\<star> = A \<cdot> A\<star> \<union> {[]}"}, |
|
2484 which is equal to @{term "A\<star> = A\<star> \<cdot> A \<union> {[]}"}. Adding @{text B} to both |
|
2485 sides gives @{term "B \<cdot> A\<star> = B \<cdot> (A\<star> \<cdot> A \<union> {[]})"}, whose right-hand side |
|
2486 is equal to @{term "(B \<cdot> A\<star>) \<cdot> A \<union> B"}. Applying the assumed equation |
|
2487 completes this direction. |
|
2488 |
|
2489 For the other direction we assume @{thm (lhs) reversed_Arden}. By a simple induction |
|
2490 on @{text n}, we can establish the property |
|
2491 |
|
2492 \begin{center} |
|
2493 @{text "(*)"}\hspace{5mm} @{thm (concl) reversed_arden_helper} |
|
2494 \end{center} |
|
2495 |
|
2496 \noindent |
|
2497 Using this property we can show that @{term "B \<cdot> (A \<up> n) \<subseteq> X"} holds for |
|
2498 all @{text n}. From this we can infer @{term "B \<cdot> A\<star> \<subseteq> X"} using the definition |
|
2499 of @{text "\<star>"}. |
|
2500 For the inclusion in the other direction we assume a string @{text s} |
|
2501 with length @{text k} is an element in @{text X}. Since @{thm (prem 1) reversed_Arden} |
|
2502 we know by Property~\ref{langprops}@{text "(ii)"} that |
|
2503 @{term "s \<notin> X \<cdot> (A \<up> Suc k)"} since its length is only @{text k} |
|
2504 (the strings in @{term "X \<cdot> (A \<up> Suc k)"} are all longer). |
|
2505 From @{text "(*)"} it follows then that |
|
2506 @{term s} must be an element in @{term "(\<Union>m\<le>k. B \<cdot> (A \<up> m))"}. This in turn |
|
2507 implies that @{term s} is in @{term "(\<Union>n. B \<cdot> (A \<up> n))"}. Using Property~\ref{langprops}@{text "(iii)"} |
|
2508 this is equal to @{term "B \<cdot> A\<star>"}, as we needed to show. |
|
2509 \end{proof} |
|
2510 \end{appendix} |
2490 *} |
2511 *} |
2491 |
2512 |
2492 |
2513 |
2493 (*<*) |
2514 (*<*) |
2494 end |
2515 end |