author | urbanc |
Tue, 08 Feb 2011 09:51:49 +0000 | |
changeset 77 | 63bc9f9d96ba |
parent 75 | d63baacbdb16 |
child 79 | bba9c80735f9 |
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" |
|
66 | 10 |
UPLUS :: "'a set \<Rightarrow> 'a set \<Rightarrow> (nat \<times> 'a) set" |
54 | 11 |
|
70 | 12 |
abbreviation |
13 |
"EClass x R \<equiv> R `` {x}" |
|
54 | 14 |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
15 |
notation (latex output) |
50 | 16 |
str_eq_rel ("\<approx>\<^bsub>_\<^esub>") and |
75 | 17 |
str_eq ("_ \<approx>\<^bsub>_\<^esub> _") and |
50 | 18 |
Seq (infixr "\<cdot>" 100) and |
19 |
Star ("_\<^bsup>\<star>\<^esup>") and |
|
20 |
pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and |
|
58 | 21 |
Suc ("_+1" [100] 100) and |
54 | 22 |
quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and |
66 | 23 |
REL ("\<approx>") and |
67 | 24 |
UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and |
75 | 25 |
L ("L'(_')" [0] 101) and |
26 |
Lam ("\<lambda>'(_')" [100] 100) and |
|
27 |
Trn ("_, _" [100, 100] 100) and |
|
71 | 28 |
EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and |
75 | 29 |
transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100) |
24 | 30 |
(*>*) |
31 |
||
70 | 32 |
|
24 | 33 |
section {* Introduction *} |
34 |
||
35 |
text {* |
|
58 | 36 |
Regular languages are an important and well-understood subject in Computer |
60 | 37 |
Science, with many beautiful theorems and many useful algorithms. There is a |
66 | 38 |
wide range of textbooks on this subject, many of which are aimed at students |
39 |
and contain very detailed ``pencil-and-paper'' proofs |
|
60 | 40 |
(e.g.~\cite{Kozen97}). It seems natural to exercise theorem provers by |
41 |
formalising these theorems and by verifying formally the algorithms. |
|
59 | 42 |
|
66 | 43 |
There is however a problem: the typical approach to regular languages is to |
44 |
introduce finite automata and then define everything in terms of them. For |
|
45 |
example, a regular language is normally defined as one whose strings are |
|
46 |
recognised by a finite deterministic automaton. This approach has many |
|
71 | 47 |
benefits. Among them is the fact that it is easy to convince oneself that |
66 | 48 |
regular languages are closed under complementation: one just has to exchange |
49 |
the accepting and non-accepting states in the corresponding automaton to |
|
50 |
obtain an automaton for the complement language. The problem, however, lies with |
|
67 | 51 |
formalising such reasoning in a HOL-based theorem prover, in our case |
70 | 52 |
Isabelle/HOL. Automata are build up from states and transitions that |
53 |
need to be represented as graphs or matrices, neither |
|
66 | 54 |
of which can be defined as inductive datatype.\footnote{In some works |
55 |
functions are used to represent state transitions, but also they are not |
|
56 |
inductive datatypes.} This means we have to build our own reasoning |
|
57 |
infrastructure for them, as neither Isabelle/HOL nor HOL4 nor HOLlight support |
|
58 |
them with libraries. |
|
59 |
||
60 |
Even worse, reasoning about graphs and matrices can be a real hassle in HOL-based |
|
61 |
theorem provers. Consider for example the operation of sequencing |
|
62 |
two automata, say $A_1$ and $A_2$, by connecting the |
|
67 | 63 |
accepting states of $A_1$ to the initial state of $A_2$: |
61 | 64 |
|
60 | 65 |
|
66 |
\begin{center} |
|
66 | 67 |
\begin{tabular}{ccc} |
68 |
\begin{tikzpicture}[scale=0.8] |
|
69 |
%\draw[step=2mm] (-1,-1) grid (1,1); |
|
70 |
||
71 |
\draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3); |
|
72 |
\draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3); |
|
73 |
||
74 |
\node (A) at (-1.0,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
75 |
\node (B) at ( 0.2,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
76 |
||
77 |
\node (C) at (-0.2, 0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
78 |
\node (D) at (-0.2,-0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
79 |
||
80 |
\node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
81 |
\node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
82 |
\node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
83 |
||
84 |
\draw (-0.6,0.0) node {\footnotesize$A_1$}; |
|
85 |
\draw ( 0.6,0.0) node {\footnotesize$A_2$}; |
|
86 |
\end{tikzpicture} |
|
87 |
||
88 |
& |
|
89 |
||
90 |
\raisebox{1.1mm}{\bf\Large$\;\;\;\Rightarrow\,\;\;$} |
|
91 |
||
92 |
& |
|
93 |
||
94 |
\begin{tikzpicture}[scale=0.8] |
|
95 |
%\draw[step=2mm] (-1,-1) grid (1,1); |
|
96 |
||
97 |
\draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3); |
|
98 |
\draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3); |
|
99 |
||
100 |
\node (A) at (-1.0,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
101 |
\node (B) at ( 0.2,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
102 |
||
103 |
\node (C) at (-0.2, 0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
104 |
\node (D) at (-0.2,-0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
105 |
||
106 |
\node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
107 |
\node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
108 |
\node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
109 |
||
110 |
\draw (C) to [very thick, bend left=45] (B); |
|
111 |
\draw (D) to [very thick, bend right=45] (B); |
|
112 |
||
113 |
\draw (-0.6,0.0) node {\footnotesize$A_1$}; |
|
114 |
\draw ( 0.6,0.0) node {\footnotesize$A_2$}; |
|
115 |
\end{tikzpicture} |
|
116 |
||
117 |
\end{tabular} |
|
60 | 118 |
\end{center} |
119 |
||
120 |
\noindent |
|
67 | 121 |
On ``paper'' we can define the corresponding graph in terms of the disjoint |
122 |
union of the state nodes. Unfortunately in HOL, the definition for disjoint |
|
66 | 123 |
union, namely |
60 | 124 |
|
61 | 125 |
\begin{center} |
66 | 126 |
@{term "UPLUS A\<^isub>1 A\<^isub>2 \<equiv> {(1, x) | x. x \<in> A\<^isub>1} \<union> {(2, y) | y. y \<in> A\<^isub>2}"} |
61 | 127 |
\end{center} |
60 | 128 |
|
61 | 129 |
\noindent |
66 | 130 |
changes the type---the disjoint union is not a set, but a set of pairs. |
131 |
Using this definition for disjoint unions means we do not have a single type for automata |
|
132 |
and hence will not be able to state properties about \emph{all} |
|
67 | 133 |
automata, since there is no type quantification available in HOL. An |
134 |
alternative, which provides us with a single type for automata, is to give every |
|
135 |
state node an identity, for example a natural |
|
70 | 136 |
number, and then be careful to rename these identities apart whenever |
67 | 137 |
connecting two automata. This results in clunky proofs |
66 | 138 |
establishing that properties are invariant under renaming. Similarly, |
67 | 139 |
connecting two automata represented as matrices results in very adhoc |
66 | 140 |
constructions, which are not pleasant to reason about. |
141 |
||
142 |
Because of these problems to do with representing automata, there seems |
|
143 |
to be no substantial formalisation of automata theory and regular languages |
|
144 |
carried out in a HOL-based theorem prover. We are only aware of the |
|
70 | 145 |
large formalisation of automata theory in Nuprl \cite{Constable00} and |
71 | 146 |
some smaller formalisations in Coq (for example \cite{Filliatre97}). |
58 | 147 |
|
66 | 148 |
In this paper, we will not attempt to formalise automata theory, but take a completely |
149 |
different approach to regular languages. Instead of defining a regular language as one |
|
150 |
where there exists an automaton that recognises all strings of the language, we define |
|
67 | 151 |
a regular language as: |
54 | 152 |
|
153 |
\begin{definition}[A Regular Language] |
|
77 | 154 |
A language @{text A} is \emph{regular}, provided there is a regular expression that matches all |
54 | 155 |
strings of @{text "A"}. |
156 |
\end{definition} |
|
157 |
||
158 |
\noindent |
|
66 | 159 |
The reason is that regular expressions, unlike graphs and matrices, can |
71 | 160 |
be easily defined as inductive datatype. Consequently a corresponding reasoning |
161 |
infrastructure comes for free. This has recently been exploited in HOL4 with a formalisation |
|
162 |
of regular expression matching based on derivatives \cite{OwensSlind08}. The purpose of this paper is to |
|
163 |
show that a central result about regular languages---the Myhill-Nerode theorem---can |
|
164 |
be recreated by only using regular expressions. This theorem gives necessary |
|
165 |
and sufficient conditions for when a language is regular. As a corollary of this |
|
67 | 166 |
theorem we can easily establish the usual closure properties, including |
167 |
complementation, for regular languages.\smallskip |
|
61 | 168 |
|
169 |
\noindent |
|
67 | 170 |
{\bf Contributions:} To our knowledge, our proof of the Myhill-Nerode theorem is the |
171 |
first that is based on regular expressions, only. We prove the part of this theorem |
|
172 |
stating that a regular expression has only finitely many partitions using certain |
|
173 |
tagging-functions. Again to our best knowledge, these tagging functions have |
|
174 |
not been used before to establish the Myhill-Nerode theorem. |
|
24 | 175 |
*} |
176 |
||
50 | 177 |
section {* Preliminaries *} |
178 |
||
179 |
text {* |
|
67 | 180 |
Strings in Isabelle/HOL are lists of characters with the \emph{empty string} |
181 |
being represented by the empty list, written @{term "[]"}. \emph{Languages} |
|
182 |
are sets of strings. The language containing all strings is written in |
|
71 | 183 |
Isabelle/HOL as @{term "UNIV::string set"}. The concatenation of two languages |
184 |
is written @{term "A ;; B"} and a language raised to the power $n$ is written |
|
185 |
@{term "A \<up> n"}. Their definitions are |
|
54 | 186 |
|
187 |
\begin{center} |
|
58 | 188 |
@{thm Seq_def[THEN eq_reflection, where A1="A" and B1="B"]} |
189 |
\hspace{7mm} |
|
190 |
@{thm pow.simps(1)[THEN eq_reflection, where A1="A"]} |
|
191 |
\hspace{7mm} |
|
192 |
@{thm pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]} |
|
54 | 193 |
\end{center} |
194 |
||
195 |
\noindent |
|
58 | 196 |
where @{text "@"} is the usual list-append operation. The Kleene-star of a language @{text A} |
71 | 197 |
is defined as the union over all powers, namely @{thm Star_def}. In the paper |
198 |
we will often make use of the following properties. |
|
58 | 199 |
|
71 | 200 |
\begin{proposition}\label{langprops}\mbox{}\\ |
201 |
\begin{tabular}{@ {}ll@ {\hspace{10mm}}ll} |
|
202 |
(i) & @{thm star_cases} & (ii) & @{thm[mode=IfThen] pow_length}\\ |
|
203 |
(iii) & @{thm seq_Union_left} & |
|
204 |
\end{tabular} |
|
205 |
\end{proposition} |
|
206 |
||
207 |
\noindent |
|
208 |
We omit the proofs of these properties, but invite the reader to consult |
|
209 |
our formalisation.\footnote{Available at ???} |
|
210 |
||
211 |
||
212 |
The notation for the quotient of a language @{text A} according to an |
|
213 |
equivalence relation @{term REL} is @{term "A // REL"}. We will write |
|
214 |
@{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined |
|
215 |
as @{text "{y | y \<approx> x}"}. |
|
216 |
||
217 |
||
51 | 218 |
Central to our proof will be the solution of equational systems |
77 | 219 |
involving sets of languages. For this we will use Arden's lemma \cite{Brzozowski64} |
71 | 220 |
which solves equations of the form @{term "X = A ;; X \<union> B"} provided |
221 |
@{term "[] \<notin> A"}. However we will need the following ``reverse'' |
|
50 | 222 |
version of Arden's lemma. |
223 |
||
75 | 224 |
\begin{lemma}[Reverse Arden's Lemma]\label{arden}\mbox{}\\ |
50 | 225 |
If @{thm (prem 1) ardens_revised} then |
226 |
@{thm (lhs) ardens_revised} has the unique solution |
|
227 |
@{thm (rhs) ardens_revised}. |
|
228 |
\end{lemma} |
|
229 |
||
230 |
\begin{proof} |
|
51 | 231 |
For the right-to-left direction we assume @{thm (rhs) ardens_revised} and show |
75 | 232 |
that @{thm (lhs) ardens_revised} holds. From Prop.~\ref{langprops}@{text "(i)"} |
71 | 233 |
we have @{term "A\<star> = {[]} \<union> A ;; A\<star>"}, |
50 | 234 |
which is equal to @{term "A\<star> = {[]} \<union> A\<star> ;; A"}. Adding @{text B} to both |
235 |
sides gives @{term "B ;; A\<star> = B ;; ({[]} \<union> A\<star> ;; A)"}, whose right-hand side |
|
51 | 236 |
is equal to @{term "(B ;; A\<star>) ;; A \<union> B"}. This completes this direction. |
50 | 237 |
|
238 |
For the other direction we assume @{thm (lhs) ardens_revised}. By a simple induction |
|
51 | 239 |
on @{text n}, we can establish the property |
50 | 240 |
|
241 |
\begin{center} |
|
242 |
@{text "(*)"}\hspace{5mm} @{thm (concl) ardens_helper} |
|
243 |
\end{center} |
|
244 |
||
245 |
\noindent |
|
246 |
Using this property we can show that @{term "B ;; (A \<up> n) \<subseteq> X"} holds for |
|
71 | 247 |
all @{text n}. From this we can infer @{term "B ;; A\<star> \<subseteq> X"} using the definition |
248 |
of @{text "\<star>"}. |
|
51 | 249 |
For the inclusion in the other direction we assume a string @{text s} |
50 | 250 |
with length @{text k} is element in @{text X}. Since @{thm (prem 1) ardens_revised} |
75 | 251 |
we know by Prop.~\ref{langprops}@{text "(ii)"} that |
71 | 252 |
@{term "s \<notin> X ;; (A \<up> Suc k)"} since its length is only @{text k} |
51 | 253 |
(the strings in @{term "X ;; (A \<up> Suc k)"} are all longer). |
53 | 254 |
From @{text "(*)"} it follows then that |
50 | 255 |
@{term s} must be element in @{term "(\<Union>m\<in>{0..k}. B ;; (A \<up> m))"}. This in turn |
75 | 256 |
implies that @{term s} is in @{term "(\<Union>n. B ;; (A \<up> n))"}. Using Prop.~\ref{langprops}@{text "(iii)"} |
71 | 257 |
this is equal to @{term "B ;; A\<star>"}, as we needed to show.\qed |
50 | 258 |
\end{proof} |
67 | 259 |
|
260 |
\noindent |
|
261 |
Regular expressions are defined as the following inductive datatype |
|
262 |
||
263 |
\begin{center} |
|
264 |
@{text r} @{text "::="} |
|
265 |
@{term NULL}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
266 |
@{term EMPTY}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
267 |
@{term "CHAR c"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
268 |
@{term "SEQ r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
269 |
@{term "ALT r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
270 |
@{term "STAR r"} |
|
271 |
\end{center} |
|
272 |
||
273 |
\noindent |
|
274 |
The language matched by a regular expression is defined as usual: |
|
275 |
||
276 |
\begin{center} |
|
277 |
\begin{tabular}{c@ {\hspace{10mm}}c} |
|
278 |
\begin{tabular}{rcl} |
|
279 |
@{thm (lhs) L_rexp.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(1)}\\ |
|
280 |
@{thm (lhs) L_rexp.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(2)}\\ |
|
281 |
@{thm (lhs) L_rexp.simps(3)[where c="c"]} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(3)[where c="c"]}\\ |
|
282 |
\end{tabular} |
|
283 |
& |
|
284 |
\begin{tabular}{rcl} |
|
285 |
@{thm (lhs) L_rexp.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} & |
|
286 |
@{thm (rhs) L_rexp.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
|
287 |
@{thm (lhs) L_rexp.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} & |
|
288 |
@{thm (rhs) L_rexp.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
|
289 |
@{thm (lhs) L_rexp.simps(6)[where r="r"]} & @{text "\<equiv>"} & |
|
290 |
@{thm (rhs) L_rexp.simps(6)[where r="r"]}\\ |
|
291 |
\end{tabular} |
|
292 |
\end{tabular} |
|
293 |
\end{center} |
|
70 | 294 |
|
50 | 295 |
*} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
296 |
|
54 | 297 |
section {* Finite Partitions Imply Regularity of a Language *} |
298 |
||
299 |
text {* |
|
77 | 300 |
The key definition in the Myhill-Nerode theorem is the |
75 | 301 |
\emph{Myhill-Nerode relation}, which states that w.r.t.~a language two |
302 |
strings are related, provided there is no distinguishing extension in this |
|
303 |
language. This can be defined as: |
|
304 |
||
70 | 305 |
\begin{definition}[Myhill-Nerode Relation]\mbox{}\\ |
75 | 306 |
@{thm str_eq_def[simplified str_eq_rel_def Pair_Collect]} |
70 | 307 |
\end{definition} |
308 |
||
71 | 309 |
\noindent |
75 | 310 |
It is easy to see that @{term "\<approx>A"} is an equivalence relation, which |
311 |
partitions the set of all strings, @{text "UNIV"}, into a set of disjoint |
|
312 |
equivalence classes. One direction of the Myhill-Nerode theorem establishes |
|
313 |
that if there are finitely many equivalence classes, then the language is |
|
77 | 314 |
regular. In our setting we therefore have to show: |
75 | 315 |
|
316 |
\begin{theorem}\label{myhillnerodeone} |
|
317 |
@{thm[mode=IfThen] hard_direction} |
|
318 |
\end{theorem} |
|
71 | 319 |
|
75 | 320 |
\noindent |
321 |
To prove this theorem, we define the set @{term "finals A"} as those equivalence |
|
322 |
classes that contain strings of @{text A}, namely |
|
323 |
% |
|
71 | 324 |
\begin{equation} |
70 | 325 |
@{thm finals_def} |
71 | 326 |
\end{equation} |
327 |
||
328 |
\noindent |
|
77 | 329 |
It is straightforward to show that @{thm lang_is_union_of_finals} and |
330 |
@{thm finals_included_in_UNIV} hold. |
|
75 | 331 |
Therefore if we know that there exists a regular expression for every |
332 |
equivalence class in @{term "finals A"} (which by assumption must be |
|
77 | 333 |
a finite set), then we can combine these regular expressions with @{const ALT} |
75 | 334 |
and obtain a regular expression that matches every string in @{text A}. |
70 | 335 |
|
75 | 336 |
|
77 | 337 |
We prove Thm.~\ref{myhillnerodeone} by giving a method that can calculate a |
338 |
regular expression for \emph{every} equivalence classe, not just the ones |
|
339 |
in @{term "finals A"}. We |
|
75 | 340 |
first define a notion of \emph{transition} between equivalence classes |
341 |
% |
|
71 | 342 |
\begin{equation} |
343 |
@{thm transition_def} |
|
344 |
\end{equation} |
|
70 | 345 |
|
71 | 346 |
\noindent |
75 | 347 |
which means that if we concatenate all strings matching the regular expression @{text r} |
348 |
to the end of all strings in the equivalence class @{text Y}, we obtain a subset of |
|
77 | 349 |
@{text X}. Note that we do not define an automaton here, we merely relate two sets |
350 |
(w.r.t.~a regular expression). |
|
75 | 351 |
|
352 |
Next we build an equational system that |
|
353 |
contains an equation for each equivalence class. Suppose we have |
|
354 |
the equivalence classes @{text "X\<^isub>1,\<dots>,X\<^isub>n"}, there must be one and only one that |
|
355 |
contains the empty string @{text "[]"} (since equivalence classes are disjoint). |
|
77 | 356 |
Let us assume @{text "[] \<in> X\<^isub>1"}. We build the following equational system |
75 | 357 |
|
358 |
\begin{center} |
|
359 |
\begin{tabular}{rcl} |
|
360 |
@{text "X\<^isub>1"} & @{text "="} & @{text "(Y\<^isub>1\<^isub>1, CHAR c\<^isub>1\<^isub>1) + \<dots> + (Y\<^isub>1\<^isub>p, CHAR c\<^isub>1\<^isub>p) + \<lambda>(EMPTY)"} \\ |
|
361 |
@{text "X\<^isub>2"} & @{text "="} & @{text "(Y\<^isub>2\<^isub>1, CHAR c\<^isub>2\<^isub>1) + \<dots> + (Y\<^isub>2\<^isub>o, CHAR c\<^isub>2\<^isub>o)"} \\ |
|
362 |
& $\vdots$ \\ |
|
363 |
@{text "X\<^isub>n"} & @{text "="} & @{text "(Y\<^isub>n\<^isub>1, CHAR c\<^isub>n\<^isub>1) + \<dots> + (Y\<^isub>n\<^isub>q, CHAR c\<^isub>n\<^isub>q)"}\\ |
|
364 |
\end{tabular} |
|
365 |
\end{center} |
|
70 | 366 |
|
75 | 367 |
\noindent |
368 |
where the pairs @{text "(Y\<^isub>i\<^isub>j, r\<^isub>i\<^isub>j)"} stand for all transitions |
|
369 |
@{term "Y\<^isub>i\<^isub>j \<Turnstile>r\<^isub>i\<^isub>j\<Rightarrow> X\<^isub>i"}. The term @{text "\<lambda>(EMPTY)"} acts as a marker for the equivalence |
|
370 |
class containing @{text "[]"}. (Note that we mark, roughly speaking, the |
|
371 |
single ``initial'' state in the equational system, which is different from |
|
77 | 372 |
the method by Brzozowski \cite{Brzozowski64}, since for his purposes he needs to mark |
373 |
the ``terminal'' states.) Overloading the function @{text L} for the two kinds of terms in the |
|
75 | 374 |
equational system as follows |
375 |
||
376 |
\begin{center} |
|
77 | 377 |
@{thm L_rhs_e.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} |
378 |
@{thm L_rhs_e.simps(1)[where r="r", THEN eq_reflection]} |
|
75 | 379 |
\end{center} |
380 |
||
381 |
\noindent |
|
382 |
we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations |
|
383 |
% |
|
384 |
\begin{equation}\label{inv1} |
|
385 |
@{text "X\<^isub>i = L(Y\<^isub>i\<^isub>1, CHAR c\<^isub>i\<^isub>1) \<union> \<dots> \<union> L(Y\<^isub>i\<^isub>q, CHAR c\<^isub>i\<^isub>q)"}. |
|
386 |
\end{equation} |
|
387 |
||
388 |
\noindent |
|
389 |
hold. Similarly for @{text "X\<^isub>1"} we can show the following equation |
|
390 |
% |
|
391 |
\begin{equation}\label{inv2} |
|
392 |
@{text "X\<^isub>1 = L(Y\<^isub>i\<^isub>1, CHAR c\<^isub>i\<^isub>1) \<union> \<dots> \<union> L(Y\<^isub>i\<^isub>p, CHAR c\<^isub>i\<^isub>p) \<union> L(\<lambda>(EMPTY))"}. |
|
393 |
\end{equation} |
|
394 |
||
395 |
\noindent |
|
77 | 396 |
The reason for adding the @{text \<lambda>}-marker to our equational system is |
397 |
to obtain this equation, which only holds in this form since none of |
|
398 |
the other terms contain the empty string. |
|
399 |
||
400 |
||
401 |
Our proof of Thm.~\ref{myhillnerodeone} |
|
75 | 402 |
will be by transforming the equational system into a \emph{solved form} |
403 |
maintaining the invariants \eqref{inv1} and \eqref{inv2}. From the solved |
|
404 |
form we will be able to read off the regular expressions using our |
|
405 |
variant of Arden's Lemma (Lem.~\ref{arden}). |
|
406 |
||
54 | 407 |
*} |
408 |
||
409 |
section {* Regular Expressions Generate Finitely Many Partitions *} |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
410 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
411 |
text {* |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
412 |
|
54 | 413 |
\begin{theorem} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
414 |
Given @{text "r"} is a regular expressions, then @{thm rexp_imp_finite}. |
54 | 415 |
\end{theorem} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
416 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
417 |
\begin{proof} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
418 |
By induction on the structure of @{text r}. The cases for @{const NULL}, @{const EMPTY} |
50 | 419 |
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
|
420 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
421 |
\begin{center} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
422 |
\begin{tabular}{l} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
423 |
@{thm quot_null_eq}\\ |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
424 |
@{thm quot_empty_subset}\\ |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
425 |
@{thm quot_char_subset} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
426 |
\end{tabular} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
427 |
\end{center} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
428 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
429 |
\end{proof} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
430 |
*} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
431 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
432 |
|
54 | 433 |
section {* Conclusion and Related Work *} |
434 |
||
24 | 435 |
(*<*) |
436 |
end |
|
437 |
(*>*) |