author | urbanc |
Mon, 31 Jan 2011 12:54:31 +0000 | |
changeset 54 | c19d2fc2cc69 |
parent 53 | da85feadb8e3 |
child 58 | 0d4d5bb321dc |
permissions | -rw-r--r-- |
24 | 1 |
(*<*) |
2 |
theory Paper |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
3 |
imports "../Myhill" "LaTeXsugar" |
24 | 4 |
begin |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
5 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
6 |
declare [[show_question_marks = false]] |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
7 |
|
54 | 8 |
consts |
9 |
REL :: "(string \<times> string) \<Rightarrow> bool" |
|
10 |
||
11 |
||
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
12 |
notation (latex output) |
50 | 13 |
str_eq_rel ("\<approx>\<^bsub>_\<^esub>") and |
14 |
Seq (infixr "\<cdot>" 100) and |
|
15 |
Star ("_\<^bsup>\<star>\<^esup>") and |
|
16 |
pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and |
|
54 | 17 |
Suc ("_+1>" [100] 100) and |
18 |
quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and |
|
19 |
REL ("\<approx>") |
|
52
4a517c6ac07d
tuning of the syntax; needs the stmaryrd latex package
urbanc
parents:
51
diff
changeset
|
20 |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
21 |
|
24 | 22 |
(*>*) |
23 |
||
24 |
section {* Introduction *} |
|
25 |
||
26 |
text {* |
|
54 | 27 |
|
28 |
Therefore instead of defining a regular language as being one where there exists an |
|
29 |
automata that regognises all of its strings, we define |
|
30 |
||
31 |
\begin{definition}[A Regular Language] |
|
32 |
A language @{text A} is regular, if there is a regular expression that matches all |
|
33 |
strings of @{text "A"}. |
|
34 |
\end{definition} |
|
35 |
||
36 |
\noindent |
|
37 |
{\bf Contributions:} A proof of the Myhil-Nerode Theorem based on regular expressions. The |
|
38 |
finiteness part of this theorem is proved using tagging-functions (which to our knowledge |
|
39 |
are novel in this context). |
|
24 | 40 |
|
41 |
*} |
|
42 |
||
50 | 43 |
section {* Preliminaries *} |
44 |
||
45 |
text {* |
|
54 | 46 |
Strings in Isabelle/HOL are lists of characters. Therefore the |
47 |
\emph{empty string} is represented by the empty list, written @{term "[]"}. \emph{Languages} are sets of |
|
48 |
strings. The language containing all strings is abbreviated as @{term "UNIV::string set"} |
|
49 |
and the notation for the quotient of a language @{text A} according to a relation @{term REL} is |
|
50 |
@{term "A // REL"}. |
|
51 |
||
52 |
Set operations |
|
53 |
||
54 |
\begin{center} |
|
55 |
@{thm Seq_def} |
|
56 |
\end{center} |
|
57 |
||
58 |
\noindent |
|
59 |
where @{text "@"} is the usual list-append operation. |
|
60 |
||
61 |
\noindent |
|
62 |
Regular expressions are defined as the following datatype |
|
63 |
||
64 |
\begin{center} |
|
65 |
@{text r} @{text "::="} |
|
66 |
@{term NULL}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
67 |
@{term EMPTY}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
68 |
@{term "CHAR c"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
69 |
@{term "SEQ r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
70 |
@{term "ALT r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
71 |
@{term "STAR r"} |
|
72 |
\end{center} |
|
73 |
||
51 | 74 |
Central to our proof will be the solution of equational systems |
50 | 75 |
involving regular expressions. For this we will use the following ``reverse'' |
76 |
version of Arden's lemma. |
|
77 |
||
78 |
\begin{lemma}[Reverse Arden's Lemma]\mbox{}\\ |
|
79 |
If @{thm (prem 1) ardens_revised} then |
|
80 |
@{thm (lhs) ardens_revised} has the unique solution |
|
81 |
@{thm (rhs) ardens_revised}. |
|
82 |
\end{lemma} |
|
83 |
||
84 |
\begin{proof} |
|
51 | 85 |
For the right-to-left direction we assume @{thm (rhs) ardens_revised} and show |
86 |
that @{thm (lhs) ardens_revised} holds. From Lemma ??? we have @{term "A\<star> = {[]} \<union> A ;; A\<star>"}, |
|
50 | 87 |
which is equal to @{term "A\<star> = {[]} \<union> A\<star> ;; A"}. Adding @{text B} to both |
88 |
sides gives @{term "B ;; A\<star> = B ;; ({[]} \<union> A\<star> ;; A)"}, whose right-hand side |
|
51 | 89 |
is equal to @{term "(B ;; A\<star>) ;; A \<union> B"}. This completes this direction. |
50 | 90 |
|
91 |
For the other direction we assume @{thm (lhs) ardens_revised}. By a simple induction |
|
51 | 92 |
on @{text n}, we can establish the property |
50 | 93 |
|
94 |
\begin{center} |
|
95 |
@{text "(*)"}\hspace{5mm} @{thm (concl) ardens_helper} |
|
96 |
\end{center} |
|
97 |
||
98 |
\noindent |
|
99 |
Using this property we can show that @{term "B ;; (A \<up> n) \<subseteq> X"} holds for |
|
100 |
all @{text n}. From this we can infer @{term "B ;; A\<star> \<subseteq> X"} using Lemma ???. |
|
51 | 101 |
For the inclusion in the other direction we assume a string @{text s} |
50 | 102 |
with length @{text k} is element in @{text X}. Since @{thm (prem 1) ardens_revised} |
51 | 103 |
we know that @{term "s \<notin> X ;; (A \<up> Suc k)"} since its length is only @{text k} |
104 |
(the strings in @{term "X ;; (A \<up> Suc k)"} are all longer). |
|
53 | 105 |
From @{text "(*)"} it follows then that |
50 | 106 |
@{term s} must be element in @{term "(\<Union>m\<in>{0..k}. B ;; (A \<up> m))"}. This in turn |
107 |
implies that @{term s} is in @{term "(\<Union>n. B ;; (A \<up> n))"}. Using Lemma ??? this |
|
108 |
is equal to @{term "B ;; A\<star>"}, as we needed to show.\qed |
|
109 |
\end{proof} |
|
110 |
*} |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
111 |
|
54 | 112 |
section {* Finite Partitions Imply Regularity of a Language *} |
113 |
||
114 |
text {* |
|
115 |
\begin{theorem} |
|
116 |
Given a language @{text A}. |
|
117 |
@{thm[mode=IfThen] hard_direction[where Lang="A"]} |
|
118 |
\end{theorem} |
|
119 |
*} |
|
120 |
||
121 |
section {* Regular Expressions Generate Finitely Many Partitions *} |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
122 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
123 |
text {* |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
124 |
|
54 | 125 |
\begin{theorem} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
126 |
Given @{text "r"} is a regular expressions, then @{thm rexp_imp_finite}. |
54 | 127 |
\end{theorem} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
128 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
129 |
\begin{proof} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
130 |
By induction on the structure of @{text r}. The cases for @{const NULL}, @{const EMPTY} |
50 | 131 |
and @{const CHAR} are straightforward, because we can easily establish |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
132 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
133 |
\begin{center} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
134 |
\begin{tabular}{l} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
135 |
@{thm quot_null_eq}\\ |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
136 |
@{thm quot_empty_subset}\\ |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
137 |
@{thm quot_char_subset} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
138 |
\end{tabular} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
139 |
\end{center} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
140 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
141 |
\end{proof} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
142 |
*} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
143 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
144 |
|
54 | 145 |
section {* Conclusion and Related Work *} |
146 |
||
24 | 147 |
(*<*) |
148 |
end |
|
149 |
(*>*) |