author | urbanc |
Tue, 09 Aug 2011 22:14:41 +0000 | |
changeset 189 | 48b452a2d4df |
parent 187 | 9f46a9571e37 |
child 190 | b73478aaf33e |
permissions | -rw-r--r-- |
24 | 1 |
(*<*) |
2 |
theory Paper |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
3 |
imports "../Closures" "../Attic/Prefix_subtract" |
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 |
|
92 | 15 |
abbreviation |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
16 |
"Append_rexp2 r_itm r \<equiv> Append_rexp r r_itm" |
92 | 17 |
|
18 |
||
172 | 19 |
abbreviation |
20 |
"pow" (infixl "\<up>" 100) |
|
21 |
where |
|
22 |
"A \<up> n \<equiv> A ^^ n" |
|
23 |
||
24 |
syntax (latex output) |
|
25 |
"_Collect" :: "pttrn => bool => 'a set" ("(1{_ | _})") |
|
26 |
"_CollectIn" :: "pttrn => 'a set => bool => 'a set" ("(1{_ \<in> _ | _})") |
|
27 |
translations |
|
28 |
"_Collect p P" <= "{p. P}" |
|
29 |
"_Collect p P" <= "{p|xs. P}" |
|
30 |
"_CollectIn p A P" <= "{p : A. P}" |
|
31 |
||
173 | 32 |
abbreviation "ZERO \<equiv> Zero" |
33 |
abbreviation "ONE \<equiv> One" |
|
34 |
abbreviation "ATOM \<equiv> Atom" |
|
35 |
abbreviation "PLUS \<equiv> Plus" |
|
36 |
abbreviation "TIMES \<equiv> Times" |
|
187 | 37 |
abbreviation "TIMESS \<equiv> Timess" |
172 | 38 |
abbreviation "STAR \<equiv> Star" |
39 |
||
40 |
||
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
41 |
notation (latex output) |
181 | 42 |
str_eq ("\<approx>\<^bsub>_\<^esub>") and |
43 |
str_eq_applied ("_ \<approx>\<^bsub>_\<^esub> _") and |
|
172 | 44 |
conc (infixr "\<cdot>" 100) and |
45 |
star ("_\<^bsup>\<star>\<^esup>") and |
|
50 | 46 |
pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and |
58 | 47 |
Suc ("_+1" [100] 100) and |
54 | 48 |
quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and |
66 | 49 |
REL ("\<approx>") and |
67 | 50 |
UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and |
186 | 51 |
lang ("\<^raw:\ensuremath{\cal{L}}>" 101) and |
172 | 52 |
lang ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and |
174 | 53 |
lang_trm ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and |
75 | 54 |
Lam ("\<lambda>'(_')" [100] 100) and |
89 | 55 |
Trn ("'(_, _')" [100, 100] 100) and |
71 | 56 |
EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and |
88 | 57 |
transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100) and |
92 | 58 |
Setalt ("\<^raw:\ensuremath{\bigplus}>_" [1000] 999) and |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
59 |
Append_rexp2 ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 100) and |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
60 |
Append_rexp_rhs ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 50) and |
172 | 61 |
|
119 | 62 |
uminus ("\<^raw:\ensuremath{\overline{>_\<^raw:}}>" [100] 100) and |
183 | 63 |
tag_Plus ("+tag _ _" [100, 100] 100) and |
64 |
tag_Plus ("+tag _ _ _" [100, 100, 100] 100) and |
|
184 | 65 |
tag_Times ("\<times>tag _ _" [100, 100] 100) and |
66 |
tag_Times ("\<times>tag _ _ _" [100, 100, 100] 100) and |
|
67 |
tag_Star ("\<star>tag _" [100] 100) and |
|
68 |
tag_Star ("\<star>tag _ _" [100, 100] 100) and |
|
181 | 69 |
tag_eq ("\<^raw:$\threesim$>\<^bsub>_\<^esub>") and |
174 | 70 |
Delta ("\<Delta>'(_')") and |
180 | 71 |
nullable ("\<delta>'(_')") and |
186 | 72 |
Cons ("_ :: _" [100, 100] 100) and |
73 |
Rev ("Rev _" [1000] 100) and |
|
74 |
Der ("Der _ _" [1000, 1000] 100) and |
|
75 |
ONE ("ONE" 999) and |
|
76 |
ZERO ("ZERO" 999) |
|
167 | 77 |
|
119 | 78 |
lemma meta_eq_app: |
79 |
shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x" |
|
80 |
by auto |
|
81 |
||
181 | 82 |
lemma str_eq_def': |
83 |
shows "x \<approx>A y \<equiv> (\<forall>z. x @ z \<in> A \<longleftrightarrow> y @ z \<in> A)" |
|
84 |
unfolding str_eq_def by simp |
|
85 |
||
172 | 86 |
lemma conc_def': |
87 |
"A \<cdot> B = {s\<^isub>1 @ s\<^isub>2 | s\<^isub>1 s\<^isub>2. s\<^isub>1 \<in> A \<and> s\<^isub>2 \<in> B}" |
|
88 |
unfolding conc_def by simp |
|
89 |
||
90 |
lemma conc_Union_left: |
|
91 |
shows "B \<cdot> (\<Union>n. A \<up> n) = (\<Union>n. B \<cdot> (A \<up> n))" |
|
92 |
unfolding conc_def by auto |
|
93 |
||
94 |
lemma test: |
|
95 |
assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)" |
|
96 |
shows "X = \<Union> (lang_trm ` rhs)" |
|
97 |
using assms l_eq_r_in_eqs by (simp) |
|
98 |
||
99 |
||
167 | 100 |
(* THEOREMS *) |
101 |
||
102 |
notation (Rule output) |
|
103 |
"==>" ("\<^raw:\mbox{}\inferrule{\mbox{>_\<^raw:}}>\<^raw:{\mbox{>_\<^raw:}}>") |
|
104 |
||
105 |
syntax (Rule output) |
|
106 |
"_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
107 |
("\<^raw:\mbox{}\inferrule{>_\<^raw:}>\<^raw:{\mbox{>_\<^raw:}}>") |
|
108 |
||
109 |
"_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" |
|
110 |
("\<^raw:\mbox{>_\<^raw:}\\>/ _") |
|
111 |
||
112 |
"_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>") |
|
113 |
||
114 |
notation (Axiom output) |
|
115 |
"Trueprop" ("\<^raw:\mbox{}\inferrule{\mbox{}}{\mbox{>_\<^raw:}}>") |
|
116 |
||
117 |
notation (IfThen output) |
|
118 |
"==>" ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
119 |
syntax (IfThen output) |
|
120 |
"_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
121 |
("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
122 |
"_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}> /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _") |
|
123 |
"_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>") |
|
124 |
||
125 |
notation (IfThenNoBox output) |
|
126 |
"==>" ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
127 |
syntax (IfThenNoBox output) |
|
128 |
"_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
129 |
("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
130 |
"_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("_ /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _") |
|
131 |
"_asm" :: "prop \<Rightarrow> asms" ("_") |
|
132 |
||
133 |
||
24 | 134 |
(*>*) |
135 |
||
70 | 136 |
|
24 | 137 |
section {* Introduction *} |
138 |
||
139 |
text {* |
|
167 | 140 |
\noindent |
58 | 141 |
Regular languages are an important and well-understood subject in Computer |
60 | 142 |
Science, with many beautiful theorems and many useful algorithms. There is a |
66 | 143 |
wide range of textbooks on this subject, many of which are aimed at students |
175 | 144 |
and contain very detailed `pencil-and-paper' proofs (e.g.~\cite{Kozen97, |
145 |
HopcroftUllman69}). It seems natural to exercise theorem provers by |
|
187 | 146 |
formalising the theorems and by verifying formally the algorithms. |
147 |
||
148 |
A popular choice for a theorem prover would be one based on Higher-Order |
|
149 |
Logic (HOL), for example HOL4, HOLlight or Isabelle/HOL. For the development |
|
175 | 150 |
presented in this paper we will use the latter. HOL is a predicate calculus |
151 |
that allows quantification over predicate variables. Its type system is |
|
187 | 152 |
based on Church's Simple Theory of Types \cite{Church40}. Although many |
153 |
mathematical concepts can be conveniently expressed in HOL, there are some |
|
175 | 154 |
limitations that hurt badly, if one attempts a simple-minded formalisation |
187 | 155 |
of regular languages in it. The typical approach to regular languages is to |
156 |
introduce finite automata and then define everything in terms of them |
|
157 |
\cite{Kozen97}. For example, a regular language is normally defined as: |
|
59 | 158 |
|
175 | 159 |
\begin{dfntn}\label{baddef} |
160 |
A language @{text A} is \emph{regular}, provided there is a |
|
161 |
finite deterministic automaton that recognises all strings of @{text "A"}. |
|
162 |
\end{dfntn} |
|
163 |
||
164 |
\noindent |
|
165 |
This approach has many benefits. Among them is the fact that it is easy to |
|
166 |
convince oneself that regular languages are closed under complementation: |
|
167 |
one just has to exchange the accepting and non-accepting states in the |
|
168 |
corresponding automaton to obtain an automaton for the complement language. |
|
169 |
The problem, however, lies with formalising such reasoning in a HOL-based |
|
170 |
theorem prover. Automata are built up from states and transitions that need |
|
171 |
to be represented as graphs, matrices or functions, none of which can be |
|
172 |
defined as an inductive datatype. |
|
66 | 173 |
|
82 | 174 |
In case of graphs and matrices, this means we have to build our own |
175 |
reasoning infrastructure for them, as neither Isabelle/HOL nor HOL4 nor |
|
176 |
HOLlight support them with libraries. Even worse, reasoning about graphs and |
|
172 | 177 |
matrices can be a real hassle in HOL-based theorem provers, because |
178 |
we have to be able to combine automata. Consider for |
|
82 | 179 |
example the operation of sequencing two automata, say $A_1$ and $A_2$, by |
167 | 180 |
connecting the accepting states of $A_1$ to the initial state of $A_2$: |
159 | 181 |
% |
172 | 182 |
|
60 | 183 |
\begin{center} |
66 | 184 |
\begin{tabular}{ccc} |
181 | 185 |
\begin{tikzpicture}[scale=1] |
66 | 186 |
%\draw[step=2mm] (-1,-1) grid (1,1); |
187 |
||
188 |
\draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3); |
|
189 |
\draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3); |
|
190 |
||
191 |
\node (A) at (-1.0,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
192 |
\node (B) at ( 0.2,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
193 |
||
194 |
\node (C) at (-0.2, 0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
195 |
\node (D) at (-0.2,-0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
196 |
||
197 |
\node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
198 |
\node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
199 |
\node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
200 |
||
181 | 201 |
\draw (-0.6,0.0) node {\small$A_1$}; |
202 |
\draw ( 0.6,0.0) node {\small$A_2$}; |
|
66 | 203 |
\end{tikzpicture} |
204 |
||
205 |
& |
|
206 |
||
207 |
\raisebox{1.1mm}{\bf\Large$\;\;\;\Rightarrow\,\;\;$} |
|
208 |
||
209 |
& |
|
210 |
||
181 | 211 |
\begin{tikzpicture}[scale=1] |
66 | 212 |
%\draw[step=2mm] (-1,-1) grid (1,1); |
213 |
||
214 |
\draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3); |
|
215 |
\draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3); |
|
216 |
||
217 |
\node (A) at (-1.0,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
218 |
\node (B) at ( 0.2,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
219 |
||
220 |
\node (C) at (-0.2, 0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
221 |
\node (D) at (-0.2,-0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
222 |
||
223 |
\node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
224 |
\node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
225 |
\node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
226 |
||
227 |
\draw (C) to [very thick, bend left=45] (B); |
|
228 |
\draw (D) to [very thick, bend right=45] (B); |
|
229 |
||
181 | 230 |
\draw (-0.6,0.0) node {\small$A_1$}; |
231 |
\draw ( 0.6,0.0) node {\small$A_2$}; |
|
66 | 232 |
\end{tikzpicture} |
233 |
||
234 |
\end{tabular} |
|
60 | 235 |
\end{center} |
236 |
||
237 |
\noindent |
|
178 | 238 |
On `paper' we can define the corresponding |
172 | 239 |
graph in terms of the disjoint |
88 | 240 |
union of the state nodes. Unfortunately in HOL, the standard definition for disjoint |
66 | 241 |
union, namely |
82 | 242 |
% |
243 |
\begin{equation}\label{disjointunion} |
|
172 | 244 |
@{text "A\<^isub>1 \<uplus> A\<^isub>2 \<equiv> {(1, x) | x \<in> A\<^isub>1} \<union> {(2, y) | y \<in> A\<^isub>2}"} |
82 | 245 |
\end{equation} |
60 | 246 |
|
61 | 247 |
\noindent |
173 | 248 |
changes the type---the disjoint union is not a set, but a set of |
249 |
pairs. Using this definition for disjoint union means we do not have a |
|
250 |
single type for automata. As a result we will not be able to define a regular |
|
251 |
language as one for which there exists an automaton that recognises all its |
|
175 | 252 |
strings. This is because we cannot make a definition in HOL that is polymorphic in |
178 | 253 |
the state type and there is no type quantification available in HOL (unlike |
187 | 254 |
in Coq, for example).\footnote{Slind already pointed out this problem in an email |
255 |
to the HOL4 mailing list on 21st April 2005.} |
|
172 | 256 |
|
257 |
An alternative, which provides us with a single type for automata, is to give every |
|
67 | 258 |
state node an identity, for example a natural |
70 | 259 |
number, and then be careful to rename these identities apart whenever |
67 | 260 |
connecting two automata. This results in clunky proofs |
66 | 261 |
establishing that properties are invariant under renaming. Similarly, |
67 | 262 |
connecting two automata represented as matrices results in very adhoc |
66 | 263 |
constructions, which are not pleasant to reason about. |
264 |
||
82 | 265 |
Functions are much better supported in Isabelle/HOL, but they still lead to similar |
88 | 266 |
problems as with graphs. Composing, for example, two non-deterministic automata in parallel |
93 | 267 |
requires also the formalisation of disjoint unions. Nipkow \cite{Nipkow98} |
101 | 268 |
dismisses for this the option of using identities, because it leads according to |
187 | 269 |
him to ``messy proofs''. Since he does not need to define what regular |
270 |
languages are, Nipkow opts for a variant of \eqref{disjointunion} using bit lists, but writes |
|
82 | 271 |
|
272 |
\begin{quote} |
|
93 | 273 |
\it% |
274 |
\begin{tabular}{@ {}l@ {}p{0.88\textwidth}@ {}} |
|
101 | 275 |
`` & All lemmas appear obvious given a picture of the composition of automata\ldots |
276 |
Yet their proofs require a painful amount of detail.'' |
|
277 |
\end{tabular} |
|
278 |
\end{quote} |
|
279 |
||
280 |
\noindent |
|
281 |
and |
|
282 |
||
283 |
\begin{quote} |
|
284 |
\it% |
|
285 |
\begin{tabular}{@ {}l@ {}p{0.88\textwidth}@ {}} |
|
93 | 286 |
`` & If the reader finds the above treatment in terms of bit lists revoltingly |
101 | 287 |
concrete, I cannot disagree. A more abstract approach is clearly desirable.'' |
93 | 288 |
\end{tabular} |
82 | 289 |
\end{quote} |
101 | 290 |
|
291 |
||
82 | 292 |
\noindent |
172 | 293 |
Moreover, it is not so clear how to conveniently impose a finiteness |
294 |
condition upon functions in order to represent \emph{finite} automata. The |
|
295 |
best is probably to resort to more advanced reasoning frameworks, such as |
|
296 |
\emph{locales} or \emph{type classes}, which are \emph{not} available in all |
|
297 |
HOL-based theorem provers. |
|
82 | 298 |
|
172 | 299 |
Because of these problems to do with representing automata, there seems to |
300 |
be no substantial formalisation of automata theory and regular languages |
|
301 |
carried out in HOL-based theorem provers. Nipkow \cite{Nipkow98} establishes |
|
302 |
the link between regular expressions and automata in the context of |
|
303 |
lexing. Berghofer and Reiter \cite{BerghoferReiter09} formalise automata |
|
304 |
working over bit strings in the context of Presburger arithmetic. The only |
|
305 |
larger formalisations of automata theory are carried out in Nuprl |
|
306 |
\cite{Constable00} and in Coq \cite{Filliatre97}. |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
307 |
|
177 | 308 |
Also one might consider automata theory as a well-worn stock subject where |
175 | 309 |
everything is crystal clear. However, paper proofs about automata often |
310 |
involve subtle side-conditions which are easily overlooked, but which make |
|
311 |
formal reasoning rather painful. For example Kozen's proof of the |
|
181 | 312 |
Myhill-Nerode theorem requires that automata do not have inaccessible |
175 | 313 |
states \cite{Kozen97}. Another subtle side-condition is completeness of |
177 | 314 |
automata, that is automata need to have total transition functions and at most one |
186 | 315 |
`sink' state from which there is no connection to a final state (Brzozowski |
177 | 316 |
mentions this side-condition in the context of state complexity |
186 | 317 |
of automata \cite{Brzozowski10}). Such side-conditions mean that if we define a regular |
175 | 318 |
language as one for which there exists \emph{a} finite automaton that |
177 | 319 |
recognises all its strings (see Def.~\ref{baddef}), then we need a lemma which |
187 | 320 |
ensures that another equivalent one can be found satisfying the |
175 | 321 |
side-condition. Unfortunately, such `little' and `obvious' lemmas make |
177 | 322 |
a formalisation of automata theory a hair-pulling experience. |
173 | 323 |
|
175 | 324 |
|
82 | 325 |
In this paper, we will not attempt to formalise automata theory in |
173 | 326 |
Isabelle/HOL nor will we attempt to formalise automata proofs from the |
172 | 327 |
literature, but take a different approach to regular languages than is |
328 |
usually taken. Instead of defining a regular language as one where there |
|
178 | 329 |
exists an automaton that recognises all its strings, we define a |
82 | 330 |
regular language as: |
54 | 331 |
|
186 | 332 |
\begin{dfntn}\label{regular} |
333 |
A language @{text A} is \emph{regular}, provided there is a regular expression |
|
334 |
that matches all strings of @{text "A"}. |
|
167 | 335 |
\end{dfntn} |
54 | 336 |
|
337 |
\noindent |
|
172 | 338 |
The reason is that regular expressions, unlike graphs, matrices and |
175 | 339 |
functions, can be easily defined as an inductive datatype. A reasoning |
340 |
infrastructure (like induction and recursion) comes then for free in |
|
341 |
HOL. Moreover, no side-conditions will be needed for regular expressions, |
|
178 | 342 |
like we need for automata. This convenience of regular expressions has |
175 | 343 |
recently been exploited in HOL4 with a formalisation of regular expression |
344 |
matching based on derivatives \cite{OwensSlind08} and with an equivalence |
|
345 |
checker for regular expressions in Isabelle/HOL \cite{KraussNipkow11}. The |
|
346 |
main purpose of this paper is to show that a central result about regular |
|
347 |
languages---the Myhill-Nerode theorem---can be recreated by only using |
|
348 |
regular expressions. This theorem gives necessary and sufficient conditions |
|
349 |
for when a language is regular. As a corollary of this theorem we can easily |
|
350 |
establish the usual closure properties, including complementation, for |
|
351 |
regular languages.\medskip |
|
61 | 352 |
|
174 | 353 |
\noindent |
175 | 354 |
{\bf Contributions:} There is an extensive literature on regular languages. |
355 |
To our best knowledge, our proof of the Myhill-Nerode theorem is the first |
|
356 |
that is based on regular expressions, only. The part of this theorem stating |
|
357 |
that finitely many partitions imply regularity of the language is proved by |
|
181 | 358 |
an argument about solving equational systems. This argument appears to be |
175 | 359 |
folklore. For the other part, we give two proofs: one direct proof using |
360 |
certain tagging-functions, and another indirect proof using Antimirov's |
|
361 |
partial derivatives \cite{Antimirov95}. Again to our best knowledge, the |
|
362 |
tagging-functions have not been used before to establish the Myhill-Nerode |
|
187 | 363 |
theorem. Derivatives of regular expressions have been used recently quite |
364 |
widely in the literature; partial derivatives, in contrast, attracted much |
|
365 |
less attention. However, partial derivatives are more suitable in the |
|
366 |
context of the Myhill-Nerode theorem, since it is easier to establish |
|
367 |
formally their finiteness result. We have not found any proof that uses |
|
368 |
either of them in order to prove the Myhill-Nerode theorem. |
|
24 | 369 |
*} |
370 |
||
50 | 371 |
section {* Preliminaries *} |
372 |
||
373 |
text {* |
|
172 | 374 |
\noindent |
67 | 375 |
Strings in Isabelle/HOL are lists of characters with the \emph{empty string} |
177 | 376 |
being represented by the empty list, written @{term "[]"}. We assume there |
377 |
are only finitely many different characters. \emph{Languages} are sets of |
|
378 |
strings. The language containing all strings is written in Isabelle/HOL as |
|
379 |
@{term "UNIV::string set"}. The concatenation of two languages is written |
|
380 |
@{term "A \<cdot> B"} and a language raised to the power @{text n} is written |
|
93 | 381 |
@{term "A \<up> n"}. They are defined as usual |
54 | 382 |
|
383 |
\begin{center} |
|
177 | 384 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
385 |
@{thm (lhs) conc_def'[THEN eq_reflection, where A1="A" and B1="B"]} |
|
386 |
& @{text "\<equiv>"} & @{thm (rhs) conc_def'[THEN eq_reflection, where A1="A" and B1="B"]}\\ |
|
387 |
||
388 |
@{thm (lhs) lang_pow.simps(1)[THEN eq_reflection, where A1="A"]} |
|
389 |
& @{text "\<equiv>"} & @{thm (rhs) lang_pow.simps(1)[THEN eq_reflection, where A1="A"]}\\ |
|
390 |
||
391 |
@{thm (lhs) lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]} |
|
392 |
& @{text "\<equiv>"} & @{thm (rhs) lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]} |
|
393 |
\end{tabular} |
|
54 | 394 |
\end{center} |
395 |
||
396 |
\noindent |
|
113 | 397 |
where @{text "@"} is the list-append operation. The Kleene-star of a language @{text A} |
172 | 398 |
is defined as the union over all powers, namely @{thm star_def}. In the paper |
88 | 399 |
we will make use of the following properties of these constructions. |
58 | 400 |
|
167 | 401 |
\begin{prpstn}\label{langprops}\mbox{}\\ |
187 | 402 |
\begin{tabular}{@ {}lp{10cm}} |
180 | 403 |
(i) & @{thm star_unfold_left} \\ |
92 | 404 |
(ii) & @{thm[mode=IfThen] pow_length}\\ |
172 | 405 |
(iii) & @{thm conc_Union_left} \\ |
187 | 406 |
(iv) & If @{thm (prem 1) star_decom} and @{thm (prem 2) star_decom} then |
407 |
there exists an @{text "x\<^isub>p"} and @{text "x\<^isub>s"} with @{text "x = x\<^isub>p @ x\<^isub>s"} |
|
408 |
and @{term "x\<^isub>p \<noteq> []"} such that @{term "x\<^isub>p \<in> A"} and @{term "x\<^isub>s \<in> A\<star>"}. |
|
71 | 409 |
\end{tabular} |
167 | 410 |
\end{prpstn} |
71 | 411 |
|
412 |
\noindent |
|
100 | 413 |
In @{text "(ii)"} we use the notation @{term "length s"} for the length of a |
156 | 414 |
string; this property states that if \mbox{@{term "[] \<notin> A"}} then the lengths of |
100 | 415 |
the strings in @{term "A \<up> (Suc n)"} must be longer than @{text n}. We omit |
416 |
the proofs for these properties, but invite the reader to consult our |
|
123 | 417 |
formalisation.\footnote{Available at \url{http://www4.in.tum.de/~urbanc/regexp.html}} |
71 | 418 |
|
181 | 419 |
The notation in Isabelle/HOL for the quotient of a language @{text A} |
420 |
according to an equivalence relation @{term REL} is @{term "A // REL"}. We |
|
421 |
will write @{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined as |
|
422 |
\mbox{@{text "{y | y \<approx> x}"}}, and have @{text "x \<approx> y"} if and only if @{text |
|
423 |
"\<lbrakk>x\<rbrakk>\<^isub>\<approx> = \<lbrakk>y\<rbrakk>\<^isub>\<approx>"}. |
|
71 | 424 |
|
425 |
||
51 | 426 |
Central to our proof will be the solution of equational systems |
176 | 427 |
involving equivalence classes of languages. For this we will use Arden's Lemma |
428 |
(see \cite[Page 100]{Sakarovitch09}), |
|
167 | 429 |
which solves equations of the form @{term "X = A \<cdot> X \<union> B"} provided |
115 | 430 |
@{term "[] \<notin> A"}. However we will need the following `reverse' |
167 | 431 |
version of Arden's Lemma (`reverse' in the sense of changing the order of @{term "A \<cdot> X"} to |
432 |
\mbox{@{term "X \<cdot> A"}}). |
|
50 | 433 |
|
167 | 434 |
\begin{lmm}[Reverse Arden's Lemma]\label{arden}\mbox{}\\ |
86 | 435 |
If @{thm (prem 1) arden} then |
115 | 436 |
@{thm (lhs) arden} if and only if |
86 | 437 |
@{thm (rhs) arden}. |
167 | 438 |
\end{lmm} |
50 | 439 |
|
440 |
\begin{proof} |
|
86 | 441 |
For the right-to-left direction we assume @{thm (rhs) arden} and show |
442 |
that @{thm (lhs) arden} holds. From Prop.~\ref{langprops}@{text "(i)"} |
|
181 | 443 |
we have @{term "A\<star> = A \<cdot> A\<star> \<union> {[]}"}, |
444 |
which is equal to @{term "A\<star> = A\<star> \<cdot> A \<union> {[]}"}. Adding @{text B} to both |
|
445 |
sides gives @{term "B \<cdot> A\<star> = B \<cdot> (A\<star> \<cdot> A \<union> {[]})"}, whose right-hand side |
|
167 | 446 |
is equal to @{term "(B \<cdot> A\<star>) \<cdot> A \<union> B"}. This completes this direction. |
50 | 447 |
|
86 | 448 |
For the other direction we assume @{thm (lhs) arden}. By a simple induction |
51 | 449 |
on @{text n}, we can establish the property |
50 | 450 |
|
451 |
\begin{center} |
|
86 | 452 |
@{text "(*)"}\hspace{5mm} @{thm (concl) arden_helper} |
50 | 453 |
\end{center} |
454 |
||
455 |
\noindent |
|
167 | 456 |
Using this property we can show that @{term "B \<cdot> (A \<up> n) \<subseteq> X"} holds for |
457 |
all @{text n}. From this we can infer @{term "B \<cdot> A\<star> \<subseteq> X"} using the definition |
|
71 | 458 |
of @{text "\<star>"}. |
51 | 459 |
For the inclusion in the other direction we assume a string @{text s} |
134 | 460 |
with length @{text k} is an element in @{text X}. Since @{thm (prem 1) arden} |
75 | 461 |
we know by Prop.~\ref{langprops}@{text "(ii)"} that |
167 | 462 |
@{term "s \<notin> X \<cdot> (A \<up> Suc k)"} since its length is only @{text k} |
463 |
(the strings in @{term "X \<cdot> (A \<up> Suc k)"} are all longer). |
|
53 | 464 |
From @{text "(*)"} it follows then that |
167 | 465 |
@{term s} must be an element in @{term "(\<Union>m\<in>{0..k}. B \<cdot> (A \<up> m))"}. This in turn |
466 |
implies that @{term s} is in @{term "(\<Union>n. B \<cdot> (A \<up> n))"}. Using Prop.~\ref{langprops}@{text "(iii)"} |
|
174 | 467 |
this is equal to @{term "B \<cdot> A\<star>"}, as we needed to show. |
50 | 468 |
\end{proof} |
67 | 469 |
|
470 |
\noindent |
|
88 | 471 |
Regular expressions are defined as the inductive datatype |
67 | 472 |
|
473 |
\begin{center} |
|
176 | 474 |
\begin{tabular}{rcl} |
475 |
@{text r} & @{text "::="} & @{term ZERO}\\ |
|
177 | 476 |
& @{text"|"} & @{term One}\\ |
477 |
& @{text"|"} & @{term "Atom c"}\\ |
|
478 |
& @{text"|"} & @{term "Times r r"}\\ |
|
479 |
& @{text"|"} & @{term "Plus r r"}\\ |
|
480 |
& @{text"|"} & @{term "Star r"} |
|
176 | 481 |
\end{tabular} |
67 | 482 |
\end{center} |
483 |
||
484 |
\noindent |
|
88 | 485 |
and the language matched by a regular expression is defined as |
67 | 486 |
|
487 |
\begin{center} |
|
176 | 488 |
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
172 | 489 |
@{thm (lhs) lang.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(1)}\\ |
490 |
@{thm (lhs) lang.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(2)}\\ |
|
491 |
@{thm (lhs) lang.simps(3)[where a="c"]} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(3)[where a="c"]}\\ |
|
492 |
@{thm (lhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} & |
|
493 |
@{thm (rhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\ |
|
494 |
@{thm (lhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} & |
|
495 |
@{thm (rhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\ |
|
496 |
@{thm (lhs) lang.simps(6)[where r="r"]} & @{text "\<equiv>"} & |
|
497 |
@{thm (rhs) lang.simps(6)[where r="r"]}\\ |
|
67 | 498 |
\end{tabular} |
499 |
\end{center} |
|
70 | 500 |
|
100 | 501 |
Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating |
132 | 502 |
a regular expression that matches the union of all languages of @{text rs}. We only need to know the |
503 |
existence |
|
92 | 504 |
of such a regular expression and therefore we use Isabelle/HOL's @{const "fold_graph"} and Hilbert's |
173 | 505 |
@{text "\<epsilon>"} to define @{term "\<Uplus>rs"}. This operation, roughly speaking, folds @{const PLUS} over the |
506 |
set @{text rs} with @{const ZERO} for the empty set. We can prove that for a finite set @{text rs} |
|
110 | 507 |
% |
508 |
\begin{equation}\label{uplus} |
|
509 |
\mbox{@{thm (lhs) folds_alt_simp} @{text "= \<Union> (\<calL> ` rs)"}} |
|
510 |
\end{equation} |
|
88 | 511 |
|
512 |
\noindent |
|
90 | 513 |
holds, whereby @{text "\<calL> ` rs"} stands for the |
514 |
image of the set @{text rs} under function @{text "\<calL>"}. |
|
50 | 515 |
*} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
516 |
|
132 | 517 |
|
133 | 518 |
section {* The Myhill-Nerode Theorem, First Part *} |
54 | 519 |
|
520 |
text {* |
|
177 | 521 |
\noindent |
174 | 522 |
\footnote{Folklore: Henzinger (arden-DFA-regexp.pdf); Hofmann} |
77 | 523 |
The key definition in the Myhill-Nerode theorem is the |
75 | 524 |
\emph{Myhill-Nerode relation}, which states that w.r.t.~a language two |
525 |
strings are related, provided there is no distinguishing extension in this |
|
154 | 526 |
language. This can be defined as a tertiary relation. |
75 | 527 |
|
174 | 528 |
\begin{dfntn}[Myhill-Nerode Relation]\label{myhillneroderel} |
529 |
Given a language @{text A}, two strings @{text x} and |
|
123 | 530 |
@{text y} are Myhill-Nerode related provided |
117 | 531 |
\begin{center} |
181 | 532 |
@{thm str_eq_def'} |
117 | 533 |
\end{center} |
167 | 534 |
\end{dfntn} |
70 | 535 |
|
71 | 536 |
\noindent |
75 | 537 |
It is easy to see that @{term "\<approx>A"} is an equivalence relation, which |
538 |
partitions the set of all strings, @{text "UNIV"}, into a set of disjoint |
|
108 | 539 |
equivalence classes. To illustrate this quotient construction, let us give a simple |
101 | 540 |
example: consider the regular language containing just |
92 | 541 |
the string @{text "[c]"}. The relation @{term "\<approx>({[c]})"} partitions @{text UNIV} |
101 | 542 |
into three equivalence classes @{text "X\<^isub>1"}, @{text "X\<^isub>2"} and @{text "X\<^isub>3"} |
90 | 543 |
as follows |
544 |
||
545 |
\begin{center} |
|
176 | 546 |
\begin{tabular}{l} |
547 |
@{text "X\<^isub>1 = {[]}"}\\ |
|
548 |
@{text "X\<^isub>2 = {[c]}"}\\ |
|
90 | 549 |
@{text "X\<^isub>3 = UNIV - {[], [c]}"} |
176 | 550 |
\end{tabular} |
90 | 551 |
\end{center} |
552 |
||
553 |
One direction of the Myhill-Nerode theorem establishes |
|
93 | 554 |
that if there are finitely many equivalence classes, like in the example above, then |
555 |
the language is regular. In our setting we therefore have to show: |
|
75 | 556 |
|
167 | 557 |
\begin{thrm}\label{myhillnerodeone} |
96 | 558 |
@{thm[mode=IfThen] Myhill_Nerode1} |
167 | 559 |
\end{thrm} |
71 | 560 |
|
75 | 561 |
\noindent |
90 | 562 |
To prove this theorem, we first define the set @{term "finals A"} as those equivalence |
100 | 563 |
classes from @{term "UNIV // \<approx>A"} that contain strings of @{text A}, namely |
75 | 564 |
% |
71 | 565 |
\begin{equation} |
70 | 566 |
@{thm finals_def} |
71 | 567 |
\end{equation} |
568 |
||
569 |
\noindent |
|
132 | 570 |
In our running example, @{text "X\<^isub>2"} is the only |
571 |
equivalence class in @{term "finals {[c]}"}. |
|
174 | 572 |
It is straightforward to show that in general |
573 |
||
177 | 574 |
\begin{equation}\label{finalprops} |
174 | 575 |
@{thm lang_is_union_of_finals}\hspace{15mm} |
576 |
@{thm finals_in_partitions} |
|
177 | 577 |
\end{equation} |
174 | 578 |
|
579 |
\noindent |
|
580 |
hold. |
|
75 | 581 |
Therefore if we know that there exists a regular expression for every |
100 | 582 |
equivalence class in \mbox{@{term "finals A"}} (which by assumption must be |
93 | 583 |
a finite set), then we can use @{text "\<bigplus>"} to obtain a regular expression |
98 | 584 |
that matches every string in @{text A}. |
70 | 585 |
|
75 | 586 |
|
90 | 587 |
Our proof of Thm.~\ref{myhillnerodeone} relies on a method that can calculate a |
79 | 588 |
regular expression for \emph{every} equivalence class, not just the ones |
77 | 589 |
in @{term "finals A"}. We |
93 | 590 |
first define the notion of \emph{one-character-transition} between |
591 |
two equivalence classes |
|
75 | 592 |
% |
71 | 593 |
\begin{equation} |
594 |
@{thm transition_def} |
|
595 |
\end{equation} |
|
70 | 596 |
|
71 | 597 |
\noindent |
92 | 598 |
which means that if we concatenate the character @{text c} to the end of all |
599 |
strings in the equivalence class @{text Y}, we obtain a subset of |
|
77 | 600 |
@{text X}. Note that we do not define an automaton here, we merely relate two sets |
110 | 601 |
(with the help of a character). In our concrete example we have |
178 | 602 |
@{term "X\<^isub>1 \<Turnstile>c\<Rightarrow> X\<^isub>2"}, @{term "X\<^isub>1 \<Turnstile>d\<^isub>i\<Rightarrow> X\<^isub>3"} with @{text "d\<^isub>i"} being any |
603 |
other character than @{text c}, and @{term "X\<^isub>3 \<Turnstile>c\<^isub>j\<Rightarrow> X\<^isub>3"} for any |
|
604 |
caracter @{text "c\<^isub>j"}. |
|
75 | 605 |
|
156 | 606 |
Next we construct an \emph{initial equational system} that |
607 |
contains an equation for each equivalence class. We first give |
|
608 |
an informal description of this construction. Suppose we have |
|
75 | 609 |
the equivalence classes @{text "X\<^isub>1,\<dots>,X\<^isub>n"}, there must be one and only one that |
610 |
contains the empty string @{text "[]"} (since equivalence classes are disjoint). |
|
77 | 611 |
Let us assume @{text "[] \<in> X\<^isub>1"}. We build the following equational system |
75 | 612 |
|
613 |
\begin{center} |
|
614 |
\begin{tabular}{rcl} |
|
173 | 615 |
@{text "X\<^isub>1"} & @{text "="} & @{text "(Y\<^isub>1\<^isub>1, ATOM c\<^isub>1\<^isub>1) + \<dots> + (Y\<^isub>1\<^isub>p, ATOM c\<^isub>1\<^isub>p) + \<lambda>(ONE)"} \\ |
616 |
@{text "X\<^isub>2"} & @{text "="} & @{text "(Y\<^isub>2\<^isub>1, ATOM c\<^isub>2\<^isub>1) + \<dots> + (Y\<^isub>2\<^isub>o, ATOM c\<^isub>2\<^isub>o)"} \\ |
|
75 | 617 |
& $\vdots$ \\ |
173 | 618 |
@{text "X\<^isub>n"} & @{text "="} & @{text "(Y\<^isub>n\<^isub>1, ATOM c\<^isub>n\<^isub>1) + \<dots> + (Y\<^isub>n\<^isub>q, ATOM c\<^isub>n\<^isub>q)"}\\ |
75 | 619 |
\end{tabular} |
620 |
\end{center} |
|
70 | 621 |
|
75 | 622 |
\noindent |
173 | 623 |
where the terms @{text "(Y\<^isub>i\<^isub>j, ATOM c\<^isub>i\<^isub>j)"} |
100 | 624 |
stand for all transitions @{term "Y\<^isub>i\<^isub>j \<Turnstile>c\<^isub>i\<^isub>j\<Rightarrow> |
159 | 625 |
X\<^isub>i"}. |
626 |
%The intuition behind the equational system is that every |
|
627 |
%equation @{text "X\<^isub>i = rhs\<^isub>i"} in this system |
|
628 |
%corresponds roughly to a state of an automaton whose name is @{text X\<^isub>i} and its predecessor states |
|
629 |
%are the @{text "Y\<^isub>i\<^isub>j"}; the @{text "c\<^isub>i\<^isub>j"} are the labels of the transitions from these |
|
630 |
%predecessor states to @{text X\<^isub>i}. |
|
631 |
There can only be |
|
173 | 632 |
finitely many terms of the form @{text "(Y\<^isub>i\<^isub>j, ATOM c\<^isub>i\<^isub>j)"} in a right-hand side |
156 | 633 |
since by assumption there are only finitely many |
159 | 634 |
equivalence classes and only finitely many characters. |
173 | 635 |
The term @{text "\<lambda>(ONE)"} in the first equation acts as a marker for the initial state, that |
159 | 636 |
is the equivalence class |
100 | 637 |
containing @{text "[]"}.\footnote{Note that we mark, roughly speaking, the |
115 | 638 |
single `initial' state in the equational system, which is different from |
100 | 639 |
the method by Brzozowski \cite{Brzozowski64}, where he marks the |
115 | 640 |
`terminal' states. We are forced to set up the equational system in our |
641 |
way, because the Myhill-Nerode relation determines the `direction' of the |
|
123 | 642 |
transitions---the successor `state' of an equivalence class @{text Y} can |
643 |
be reached by adding a character to the end of @{text Y}. This is also the |
|
156 | 644 |
reason why we have to use our reverse version of Arden's Lemma.} |
177 | 645 |
In our running example we have the initial equational system |
646 |
||
647 |
\begin{equation}\label{exmpcs} |
|
648 |
\mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
649 |
@{term "X\<^isub>1"} & @{text "="} & @{text "\<lambda>(ONE)"}\\ |
|
650 |
@{term "X\<^isub>2"} & @{text "="} & @{text "(X\<^isub>1, ATOM c)"}\\ |
|
651 |
@{term "X\<^isub>3"} & @{text "="} & @{text "(X\<^isub>1, ATOM d\<^isub>1) + \<dots> + (X\<^isub>1, ATOM d\<^isub>n)"}\\ |
|
184 | 652 |
& & \mbox{}\hspace{10mm}@{text "+ (X\<^isub>3, ATOM c\<^isub>1) + \<dots> + (X\<^isub>3, ATOM c\<^isub>m)"} |
177 | 653 |
\end{tabular}} |
654 |
\end{equation} |
|
655 |
||
656 |
\noindent |
|
657 |
where @{text "d\<^isub>1\<dots>d\<^isub>n"} is the sequence of all characters |
|
181 | 658 |
but not containing @{text c}, and @{text "c\<^isub>1\<dots>c\<^isub>m"} is the sequence of all |
178 | 659 |
characters. |
177 | 660 |
|
100 | 661 |
Overloading the function @{text \<calL>} for the two kinds of terms in the |
92 | 662 |
equational system, we have |
75 | 663 |
|
664 |
\begin{center} |
|
92 | 665 |
@{text "\<calL>(Y, r) \<equiv>"} % |
172 | 666 |
@{thm (rhs) lang_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} |
667 |
@{thm lang_trm.simps(1)[where r="r", THEN eq_reflection]} |
|
75 | 668 |
\end{center} |
669 |
||
670 |
\noindent |
|
100 | 671 |
and we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations |
75 | 672 |
% |
673 |
\begin{equation}\label{inv1} |
|
173 | 674 |
@{text "X\<^isub>i = \<calL>(Y\<^isub>i\<^isub>1, ATOM c\<^isub>i\<^isub>1) \<union> \<dots> \<union> \<calL>(Y\<^isub>i\<^isub>q, ATOM c\<^isub>i\<^isub>q)"}. |
75 | 675 |
\end{equation} |
676 |
||
677 |
\noindent |
|
678 |
hold. Similarly for @{text "X\<^isub>1"} we can show the following equation |
|
679 |
% |
|
680 |
\begin{equation}\label{inv2} |
|
173 | 681 |
@{text "X\<^isub>1 = \<calL>(Y\<^isub>1\<^isub>1, ATOM c\<^isub>1\<^isub>1) \<union> \<dots> \<union> \<calL>(Y\<^isub>1\<^isub>p, ATOM c\<^isub>1\<^isub>p) \<union> \<calL>(\<lambda>(ONE))"}. |
75 | 682 |
\end{equation} |
683 |
||
684 |
\noindent |
|
160 | 685 |
holds. The reason for adding the @{text \<lambda>}-marker to our initial equational system is |
103 | 686 |
to obtain this equation: it only holds with the marker, since none of |
108 | 687 |
the other terms contain the empty string. The point of the initial equational system is |
688 |
that solving it means we will be able to extract a regular expression for every equivalence class. |
|
100 | 689 |
|
101 | 690 |
Our representation for the equations in Isabelle/HOL are pairs, |
108 | 691 |
where the first component is an equivalence class (a set of strings) |
692 |
and the second component |
|
101 | 693 |
is a set of terms. Given a set of equivalence |
100 | 694 |
classes @{text CS}, our initial equational system @{term "Init CS"} is thus |
101 | 695 |
formally defined as |
104 | 696 |
% |
697 |
\begin{equation}\label{initcs} |
|
698 |
\mbox{\begin{tabular}{rcl} |
|
100 | 699 |
@{thm (lhs) Init_rhs_def} & @{text "\<equiv>"} & |
700 |
@{text "if"}~@{term "[] \<in> X"}\\ |
|
173 | 701 |
& & @{text "then"}~@{term "{Trn Y (ATOM c) | Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X} \<union> {Lam ONE}"}\\ |
702 |
& & @{text "else"}~@{term "{Trn Y (ATOM c)| Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}"}\\ |
|
100 | 703 |
@{thm (lhs) Init_def} & @{text "\<equiv>"} & @{thm (rhs) Init_def} |
104 | 704 |
\end{tabular}} |
705 |
\end{equation} |
|
100 | 706 |
|
707 |
||
708 |
||
709 |
\noindent |
|
710 |
Because we use sets of terms |
|
101 | 711 |
for representing the right-hand sides of equations, we can |
100 | 712 |
prove \eqref{inv1} and \eqref{inv2} more concisely as |
93 | 713 |
% |
167 | 714 |
\begin{lmm}\label{inv} |
100 | 715 |
If @{thm (prem 1) test} then @{text "X = \<Union> \<calL> ` rhs"}. |
167 | 716 |
\end{lmm} |
77 | 717 |
|
93 | 718 |
\noindent |
92 | 719 |
Our proof of Thm.~\ref{myhillnerodeone} will proceed by transforming the |
100 | 720 |
initial equational system into one in \emph{solved form} maintaining the invariant |
108 | 721 |
in Lem.~\ref{inv}. From the solved form we will be able to read |
89 | 722 |
off the regular expressions. |
723 |
||
100 | 724 |
In order to transform an equational system into solved form, we have two |
89 | 725 |
operations: one that takes an equation of the form @{text "X = rhs"} and removes |
110 | 726 |
any recursive occurrences of @{text X} in the @{text rhs} using our variant of Arden's |
92 | 727 |
Lemma. The other operation takes an equation @{text "X = rhs"} |
89 | 728 |
and substitutes @{text X} throughout the rest of the equational system |
110 | 729 |
adjusting the remaining regular expressions appropriately. To define this adjustment |
108 | 730 |
we define the \emph{append-operation} taking a term and a regular expression as argument |
89 | 731 |
|
732 |
\begin{center} |
|
177 | 733 |
\begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
734 |
@{thm (lhs) Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
|
735 |
& @{text "\<equiv>"} & |
|
736 |
@{thm (rhs) Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}\\ |
|
737 |
@{thm (lhs) Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
|
738 |
& @{text "\<equiv>"} & |
|
739 |
@{thm (rhs) Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
|
740 |
\end{tabular} |
|
89 | 741 |
\end{center} |
742 |
||
92 | 743 |
\noindent |
108 | 744 |
We lift this operation to entire right-hand sides of equations, written as |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
745 |
@{thm (lhs) Append_rexp_rhs_def[where rexp="r"]}. With this we can define |
101 | 746 |
the \emph{arden-operation} for an equation of the form @{text "X = rhs"} as: |
110 | 747 |
% |
748 |
\begin{equation}\label{arden_def} |
|
749 |
\mbox{\begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l} |
|
94 | 750 |
@{thm (lhs) Arden_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ |
751 |
& & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\ |
|
177 | 752 |
& & @{text "r' ="} & @{term "Star (\<Uplus> {r. Trn X r \<in> rhs})"}\\ |
753 |
& & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "Append_rexp_rhs rhs' r'"}}\\ |
|
110 | 754 |
\end{tabular}} |
755 |
\end{equation} |
|
93 | 756 |
|
757 |
\noindent |
|
101 | 758 |
In this definition, we first delete all terms of the form @{text "(X, r)"} from @{text rhs}; |
110 | 759 |
then we calculate the combined regular expressions for all @{text r} coming |
177 | 760 |
from the deleted @{text "(X, r)"}, and take the @{const Star} of it; |
178 | 761 |
finally we append this regular expression to @{text rhs'}. If we apply this |
762 |
operation to the right-hand side of @{text "X\<^isub>3"} in \eqref{exmpcs}, we obtain |
|
763 |
the equation: |
|
764 |
||
765 |
\begin{center} |
|
766 |
\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
767 |
@{term "X\<^isub>3"} & @{text "="} & |
|
184 | 768 |
@{text "(X\<^isub>1, TIMES (ATOM d\<^isub>1) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM c\<^isub>1,\<dots>, ATOM c\<^isub>m})) + \<dots> "}\\ |
178 | 769 |
& & \mbox{}\hspace{13mm} |
184 | 770 |
@{text "\<dots> + (X\<^isub>1, TIMES (ATOM d\<^isub>n) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM c\<^isub>1,\<dots>, ATOM c\<^isub>m}))"} |
178 | 771 |
\end{tabular} |
772 |
\end{center} |
|
773 |
||
774 |
||
775 |
\noindent |
|
776 |
That means we eliminated the dependency of @{text "X\<^isub>3"} on the |
|
777 |
right-hand side. Note we used the abbreviation |
|
184 | 778 |
@{text "\<^raw:\ensuremath{\bigplus}>{ATOM c\<^isub>1,\<dots>, ATOM c\<^isub>m}"} |
178 | 779 |
to stand for a regular expression that matches with every character. In |
183 | 780 |
our algorithm we are only interested in the existence of such a regular expression |
781 |
and do not specify it any further. |
|
178 | 782 |
|
783 |
It can be easily seen that the @{text "Arden"}-operation mimics Arden's |
|
784 |
Lemma on the level of equations. To ensure the non-emptiness condition of |
|
785 |
Arden's Lemma we say that a right-hand side is @{text ardenable} provided |
|
110 | 786 |
|
787 |
\begin{center} |
|
788 |
@{thm ardenable_def} |
|
789 |
\end{center} |
|
790 |
||
791 |
\noindent |
|
156 | 792 |
This allows us to prove a version of Arden's Lemma on the level of equations. |
110 | 793 |
|
167 | 794 |
\begin{lmm}\label{ardenable} |
113 | 795 |
Given an equation @{text "X = rhs"}. |
110 | 796 |
If @{text "X = \<Union>\<calL> ` rhs"}, |
179 | 797 |
@{thm (prem 2) Arden_preserves_soundness}, and |
798 |
@{thm (prem 3) Arden_preserves_soundness}, then |
|
135 | 799 |
@{text "X = \<Union>\<calL> ` (Arden X rhs)"}. |
167 | 800 |
\end{lmm} |
110 | 801 |
|
802 |
\noindent |
|
156 | 803 |
Our @{text ardenable} condition is slightly stronger than needed for applying Arden's Lemma, |
804 |
but we can still ensure that it holds troughout our algorithm of transforming equations |
|
805 |
into solved form. The \emph{substitution-operation} takes an equation |
|
95 | 806 |
of the form @{text "X = xrhs"} and substitutes it into the right-hand side @{text rhs}. |
94 | 807 |
|
808 |
\begin{center} |
|
95 | 809 |
\begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l} |
810 |
@{thm (lhs) Subst_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ |
|
811 |
& & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\ |
|
812 |
& & @{text "r' ="} & @{term "\<Uplus> {r. Trn X r \<in> rhs}"}\\ |
|
177 | 813 |
& & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "rhs' \<union> Append_rexp_rhs xrhs r'"}}\\ |
95 | 814 |
\end{tabular} |
94 | 815 |
\end{center} |
95 | 816 |
|
817 |
\noindent |
|
134 | 818 |
We again delete first all occurrences of @{text "(X, r)"} in @{text rhs}; we then calculate |
95 | 819 |
the regular expression corresponding to the deleted terms; finally we append this |
820 |
regular expression to @{text "xrhs"} and union it up with @{text rhs'}. When we use |
|
821 |
the substitution operation we will arrange it so that @{text "xrhs"} does not contain |
|
178 | 822 |
any occurrence of @{text X}. For example substituting the first equation in |
823 |
\eqref{exmpcs} into the right-hand side of the second, thus eliminating the equivalence |
|
824 |
class @{text "X\<^isub>1"}, gives us the equation |
|
825 |
||
826 |
\begin{equation}\label{exmpresult} |
|
827 |
\mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
828 |
@{term "X\<^isub>2"} & @{text "="} & @{text "\<lambda>(TIMES ONE (ATOM c))"}\\ |
|
829 |
\end{tabular}} |
|
830 |
\end{equation} |
|
96 | 831 |
|
134 | 832 |
With these two operations in place, we can define the operation that removes one equation |
100 | 833 |
from an equational systems @{text ES}. The operation @{const Subst_all} |
96 | 834 |
substitutes an equation @{text "X = xrhs"} throughout an equational system @{text ES}; |
100 | 835 |
@{const Remove} then completely removes such an equation from @{text ES} by substituting |
110 | 836 |
it to the rest of the equational system, but first eliminating all recursive occurrences |
96 | 837 |
of @{text X} by applying @{const Arden} to @{text "xrhs"}. |
838 |
||
839 |
\begin{center} |
|
840 |
\begin{tabular}{rcl} |
|
841 |
@{thm (lhs) Subst_all_def} & @{text "\<equiv>"} & @{thm (rhs) Subst_all_def}\\ |
|
842 |
@{thm (lhs) Remove_def} & @{text "\<equiv>"} & @{thm (rhs) Remove_def} |
|
843 |
\end{tabular} |
|
844 |
\end{center} |
|
100 | 845 |
|
846 |
\noindent |
|
110 | 847 |
Finally, we can define how an equational system should be solved. For this |
107 | 848 |
we will need to iterate the process of eliminating equations until only one equation |
154 | 849 |
will be left in the system. However, we do not just want to have any equation |
107 | 850 |
as being the last one, but the one involving the equivalence class for |
851 |
which we want to calculate the regular |
|
108 | 852 |
expression. Let us suppose this equivalence class is @{text X}. |
107 | 853 |
Since @{text X} is the one to be solved, in every iteration step we have to pick an |
108 | 854 |
equation to be eliminated that is different from @{text X}. In this way |
855 |
@{text X} is kept to the final step. The choice is implemented using Hilbert's choice |
|
107 | 856 |
operator, written @{text SOME} in the definition below. |
100 | 857 |
|
858 |
\begin{center} |
|
859 |
\begin{tabular}{rc@ {\hspace{4mm}}r@ {\hspace{1mm}}l} |
|
860 |
@{thm (lhs) Iter_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-4mm}}l}{@{text "let"}}\\ |
|
861 |
& & @{text "(Y, yrhs) ="} & @{term "SOME (Y, yrhs). (Y, yrhs) \<in> ES \<and> X \<noteq> Y"} \\ |
|
862 |
& & \multicolumn{2}{@ {\hspace{-4mm}}l}{@{text "in"}~~@{term "Remove ES Y yrhs"}}\\ |
|
863 |
\end{tabular} |
|
864 |
\end{center} |
|
865 |
||
866 |
\noindent |
|
110 | 867 |
The last definition we need applies @{term Iter} over and over until a condition |
159 | 868 |
@{text Cond} is \emph{not} satisfied anymore. This condition states that there |
110 | 869 |
are more than one equation left in the equational system @{text ES}. To solve |
870 |
an equational system we use Isabelle/HOL's @{text while}-operator as follows: |
|
101 | 871 |
|
100 | 872 |
\begin{center} |
873 |
@{thm Solve_def} |
|
874 |
\end{center} |
|
875 |
||
101 | 876 |
\noindent |
103 | 877 |
We are not concerned here with the definition of this operator |
115 | 878 |
(see Berghofer and Nipkow \cite{BerghoferNipkow00}), but note that we eliminate |
103 | 879 |
in each @{const Iter}-step a single equation, and therefore |
880 |
have a well-founded termination order by taking the cardinality |
|
881 |
of the equational system @{text ES}. This enables us to prove |
|
115 | 882 |
properties about our definition of @{const Solve} when we `call' it with |
104 | 883 |
the equivalence class @{text X} and the initial equational system |
884 |
@{term "Init (UNIV // \<approx>A)"} from |
|
108 | 885 |
\eqref{initcs} using the principle: |
110 | 886 |
% |
887 |
\begin{equation}\label{whileprinciple} |
|
888 |
\mbox{\begin{tabular}{l} |
|
103 | 889 |
@{term "invariant (Init (UNIV // \<approx>A))"} \\ |
890 |
@{term "\<forall>ES. invariant ES \<and> Cond ES \<longrightarrow> invariant (Iter X ES)"}\\ |
|
891 |
@{term "\<forall>ES. invariant ES \<and> Cond ES \<longrightarrow> card (Iter X ES) < card ES"}\\ |
|
892 |
@{term "\<forall>ES. invariant ES \<and> \<not> Cond ES \<longrightarrow> P ES"}\\ |
|
893 |
\hline |
|
894 |
\multicolumn{1}{c}{@{term "P (Solve X (Init (UNIV // \<approx>A)))"}} |
|
110 | 895 |
\end{tabular}} |
896 |
\end{equation} |
|
103 | 897 |
|
898 |
\noindent |
|
104 | 899 |
This principle states that given an invariant (which we will specify below) |
900 |
we can prove a property |
|
901 |
@{text "P"} involving @{const Solve}. For this we have to discharge the following |
|
902 |
proof obligations: first the |
|
113 | 903 |
initial equational system satisfies the invariant; second the iteration |
154 | 904 |
step @{text "Iter"} preserves the invariant as long as the condition @{term Cond} holds; |
113 | 905 |
third @{text "Iter"} decreases the termination order, and fourth that |
104 | 906 |
once the condition does not hold anymore then the property @{text P} must hold. |
103 | 907 |
|
104 | 908 |
The property @{term P} in our proof will state that @{term "Solve X (Init (UNIV // \<approx>A))"} |
108 | 909 |
returns with a single equation @{text "X = xrhs"} for some @{text "xrhs"}, and |
104 | 910 |
that this equational system still satisfies the invariant. In order to get |
911 |
the proof through, the invariant is composed of the following six properties: |
|
103 | 912 |
|
913 |
\begin{center} |
|
104 | 914 |
\begin{tabular}{@ {}rcl@ {\hspace{-13mm}}l @ {}} |
915 |
@{text "invariant ES"} & @{text "\<equiv>"} & |
|
103 | 916 |
@{term "finite ES"} & @{text "(finiteness)"}\\ |
917 |
& @{text "\<and>"} & @{thm (rhs) finite_rhs_def} & @{text "(finiteness rhs)"}\\ |
|
104 | 918 |
& @{text "\<and>"} & @{text "\<forall>(X, rhs)\<in>ES. X = \<Union>\<calL> ` rhs"} & @{text "(soundness)"}\\ |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
919 |
& @{text "\<and>"} & @{thm (rhs) distinctness_def}\\ |
104 | 920 |
& & & @{text "(distinctness)"}\\ |
110 | 921 |
& @{text "\<and>"} & @{thm (rhs) ardenable_all_def} & @{text "(ardenable)"}\\ |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
922 |
& @{text "\<and>"} & @{thm (rhs) validity_def} & @{text "(validity)"}\\ |
103 | 923 |
\end{tabular} |
924 |
\end{center} |
|
925 |
||
104 | 926 |
\noindent |
927 |
The first two ensure that the equational system is always finite (number of equations |
|
160 | 928 |
and number of terms in each equation); the third makes sure the `meaning' of the |
108 | 929 |
equations is preserved under our transformations. The other properties are a bit more |
930 |
technical, but are needed to get our proof through. Distinctness states that every |
|
154 | 931 |
equation in the system is distinct. @{text Ardenable} ensures that we can always |
156 | 932 |
apply the @{text Arden} operation. |
108 | 933 |
The last property states that every @{text rhs} can only contain equivalence classes |
934 |
for which there is an equation. Therefore @{text lhss} is just the set containing |
|
935 |
the first components of an equational system, |
|
936 |
while @{text "rhss"} collects all equivalence classes @{text X} in the terms of the |
|
123 | 937 |
form @{term "Trn X r"}. That means formally @{thm (lhs) lhss_def}~@{text "\<equiv> {X | (X, rhs) \<in> ES}"} |
110 | 938 |
and @{thm (lhs) rhss_def}~@{text "\<equiv> {X | (X, r) \<in> rhs}"}. |
108 | 939 |
|
104 | 940 |
|
110 | 941 |
It is straightforward to prove that the initial equational system satisfies the |
105 | 942 |
invariant. |
943 |
||
167 | 944 |
\begin{lmm}\label{invzero} |
104 | 945 |
@{thm[mode=IfThen] Init_ES_satisfies_invariant} |
167 | 946 |
\end{lmm} |
104 | 947 |
|
105 | 948 |
\begin{proof} |
949 |
Finiteness is given by the assumption and the way how we set up the |
|
950 |
initial equational system. Soundness is proved in Lem.~\ref{inv}. Distinctness |
|
154 | 951 |
follows from the fact that the equivalence classes are disjoint. The @{text ardenable} |
113 | 952 |
property also follows from the setup of the initial equational system, as does |
174 | 953 |
validity. |
105 | 954 |
\end{proof} |
955 |
||
113 | 956 |
\noindent |
957 |
Next we show that @{text Iter} preserves the invariant. |
|
958 |
||
167 | 959 |
\begin{lmm}\label{iterone} |
104 | 960 |
@{thm[mode=IfThen] iteration_step_invariant[where xrhs="rhs"]} |
167 | 961 |
\end{lmm} |
104 | 962 |
|
107 | 963 |
\begin{proof} |
156 | 964 |
The argument boils down to choosing an equation @{text "Y = yrhs"} to be eliminated |
110 | 965 |
and to show that @{term "Subst_all (ES - {(Y, yrhs)}) Y (Arden Y yrhs)"} |
966 |
preserves the invariant. |
|
967 |
We prove this as follows: |
|
968 |
||
969 |
\begin{center} |
|
177 | 970 |
\begin{tabular}{@ {}l@ {}} |
971 |
@{text "\<forall> ES."}\\ \mbox{}\hspace{5mm}@{thm (prem 1) Subst_all_satisfies_invariant} implies |
|
110 | 972 |
@{thm (concl) Subst_all_satisfies_invariant} |
177 | 973 |
\end{tabular} |
110 | 974 |
\end{center} |
975 |
||
976 |
\noindent |
|
156 | 977 |
Finiteness is straightforward, as the @{const Subst} and @{const Arden} operations |
116 | 978 |
keep the equational system finite. These operations also preserve soundness |
113 | 979 |
and distinctness (we proved soundness for @{const Arden} in Lem.~\ref{ardenable}). |
154 | 980 |
The property @{text ardenable} is clearly preserved because the append-operation |
110 | 981 |
cannot make a regular expression to match the empty string. Validity is |
982 |
given because @{const Arden} removes an equivalence class from @{text yrhs} |
|
983 |
and then @{const Subst_all} removes @{text Y} from the equational system. |
|
132 | 984 |
Having proved the implication above, we can instantiate @{text "ES"} with @{text "ES - {(Y, yrhs)}"} |
110 | 985 |
which matches with our proof-obligation of @{const "Subst_all"}. Since |
132 | 986 |
\mbox{@{term "ES = ES - {(Y, yrhs)} \<union> {(Y, yrhs)}"}}, we can use the assumption |
174 | 987 |
to complete the proof. |
107 | 988 |
\end{proof} |
989 |
||
113 | 990 |
\noindent |
991 |
We also need the fact that @{text Iter} decreases the termination measure. |
|
992 |
||
167 | 993 |
\begin{lmm}\label{itertwo} |
104 | 994 |
@{thm[mode=IfThen] iteration_step_measure[simplified (no_asm), where xrhs="rhs"]} |
167 | 995 |
\end{lmm} |
104 | 996 |
|
105 | 997 |
\begin{proof} |
998 |
By assumption we know that @{text "ES"} is finite and has more than one element. |
|
999 |
Therefore there must be an element @{term "(Y, yrhs) \<in> ES"} with |
|
110 | 1000 |
@{term "(Y, yrhs) \<noteq> (X, rhs)"}. Using the distinctness property we can infer |
105 | 1001 |
that @{term "Y \<noteq> X"}. We further know that @{text "Remove ES Y yrhs"} |
1002 |
removes the equation @{text "Y = yrhs"} from the system, and therefore |
|
174 | 1003 |
the cardinality of @{const Iter} strictly decreases. |
105 | 1004 |
\end{proof} |
1005 |
||
113 | 1006 |
\noindent |
134 | 1007 |
This brings us to our property we want to establish for @{text Solve}. |
113 | 1008 |
|
1009 |
||
167 | 1010 |
\begin{lmm} |
104 | 1011 |
If @{thm (prem 1) Solve} and @{thm (prem 2) Solve} then there exists |
1012 |
a @{text rhs} such that @{term "Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)}"} |
|
1013 |
and @{term "invariant {(X, rhs)}"}. |
|
167 | 1014 |
\end{lmm} |
104 | 1015 |
|
107 | 1016 |
\begin{proof} |
110 | 1017 |
In order to prove this lemma using \eqref{whileprinciple}, we have to use a slightly |
1018 |
stronger invariant since Lem.~\ref{iterone} and \ref{itertwo} have the precondition |
|
1019 |
that @{term "(X, rhs) \<in> ES"} for some @{text rhs}. This precondition is needed |
|
1020 |
in order to choose in the @{const Iter}-step an equation that is not \mbox{@{term "X = rhs"}}. |
|
113 | 1021 |
Therefore our invariant cannot be just @{term "invariant ES"}, but must be |
110 | 1022 |
@{term "invariant ES \<and> (\<exists>rhs. (X, rhs) \<in> ES)"}. By assumption |
1023 |
@{thm (prem 2) Solve} and Lem.~\ref{invzero}, the more general invariant holds for |
|
1024 |
the initial equational system. This is premise 1 of~\eqref{whileprinciple}. |
|
1025 |
Premise 2 is given by Lem.~\ref{iterone} and the fact that @{const Iter} might |
|
1026 |
modify the @{text rhs} in the equation @{term "X = rhs"}, but does not remove it. |
|
1027 |
Premise 3 of~\eqref{whileprinciple} is by Lem.~\ref{itertwo}. Now in premise 4 |
|
1028 |
we like to show that there exists a @{text rhs} such that @{term "ES = {(X, rhs)}"} |
|
1029 |
and that @{text "invariant {(X, rhs)}"} holds, provided the condition @{text "Cond"} |
|
113 | 1030 |
does not holds. By the stronger invariant we know there exists such a @{text "rhs"} |
110 | 1031 |
with @{term "(X, rhs) \<in> ES"}. Because @{text Cond} is not true, we know the cardinality |
123 | 1032 |
of @{text ES} is @{text 1}. This means @{text "ES"} must actually be the set @{text "{(X, rhs)}"}, |
110 | 1033 |
for which the invariant holds. This allows us to conclude that |
113 | 1034 |
@{term "Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)}"} and @{term "invariant {(X, rhs)}"} hold, |
174 | 1035 |
as needed. |
107 | 1036 |
\end{proof} |
1037 |
||
106 | 1038 |
\noindent |
1039 |
With this lemma in place we can show that for every equivalence class in @{term "UNIV // \<approx>A"} |
|
1040 |
there exists a regular expression. |
|
1041 |
||
167 | 1042 |
\begin{lmm}\label{every_eqcl_has_reg} |
105 | 1043 |
@{thm[mode=IfThen] every_eqcl_has_reg} |
167 | 1044 |
\end{lmm} |
105 | 1045 |
|
1046 |
\begin{proof} |
|
138 | 1047 |
By the preceding lemma, we know that there exists a @{text "rhs"} such |
105 | 1048 |
that @{term "Solve X (Init (UNIV // \<approx>A))"} returns the equation @{text "X = rhs"}, |
1049 |
and that the invariant holds for this equation. That means we |
|
1050 |
know @{text "X = \<Union>\<calL> ` rhs"}. We further know that |
|
109 | 1051 |
this is equal to \mbox{@{text "\<Union>\<calL> ` (Arden X rhs)"}} using the properties of the |
123 | 1052 |
invariant and Lem.~\ref{ardenable}. Using the validity property for the equation @{text "X = rhs"}, |
156 | 1053 |
we can infer that @{term "rhss rhs \<subseteq> {X}"} and because the @{text Arden} operation |
106 | 1054 |
removes that @{text X} from @{text rhs}, that @{term "rhss (Arden X rhs) = {}"}. |
113 | 1055 |
This means the right-hand side @{term "Arden X rhs"} can only consist of terms of the form @{term "Lam r"}. |
176 | 1056 |
So we can collect those (finitely many) regular expressions @{text rs} and have @{term "X = lang (\<Uplus>rs)"}. |
174 | 1057 |
With this we can conclude the proof. |
105 | 1058 |
\end{proof} |
1059 |
||
106 | 1060 |
\noindent |
1061 |
Lem.~\ref{every_eqcl_has_reg} allows us to finally give a proof for the first direction |
|
1062 |
of the Myhill-Nerode theorem. |
|
105 | 1063 |
|
106 | 1064 |
\begin{proof}[of Thm.~\ref{myhillnerodeone}] |
123 | 1065 |
By Lem.~\ref{every_eqcl_has_reg} we know that there exists a regular expression for |
105 | 1066 |
every equivalence class in @{term "UNIV // \<approx>A"}. Since @{text "finals A"} is |
110 | 1067 |
a subset of @{term "UNIV // \<approx>A"}, we also know that for every equivalence class |
123 | 1068 |
in @{term "finals A"} there exists a regular expression. Moreover by assumption |
106 | 1069 |
we know that @{term "finals A"} must be finite, and therefore there must be a finite |
105 | 1070 |
set of regular expressions @{text "rs"} such that |
176 | 1071 |
@{term "\<Union>(finals A) = lang (\<Uplus>rs)"}. |
105 | 1072 |
Since the left-hand side is equal to @{text A}, we can use @{term "\<Uplus>rs"} |
174 | 1073 |
as the regular expression that is needed in the theorem. |
105 | 1074 |
\end{proof} |
54 | 1075 |
*} |
1076 |
||
100 | 1077 |
|
1078 |
||
1079 |
||
1080 |
section {* Myhill-Nerode, Second Part *} |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1081 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1082 |
text {* |
173 | 1083 |
\noindent |
181 | 1084 |
In this section we will give a proof for establishing the second |
174 | 1085 |
part of the Myhill-Nerode theorem. It can be formulated in our setting as follows: |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1086 |
|
167 | 1087 |
\begin{thrm} |
135 | 1088 |
Given @{text "r"} is a regular expression, then @{thm Myhill_Nerode2}. |
167 | 1089 |
\end{thrm} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1090 |
|
116 | 1091 |
\noindent |
181 | 1092 |
The proof will be by induction on the structure of @{text r}. It turns out |
116 | 1093 |
the base cases are straightforward. |
1094 |
||
1095 |
||
1096 |
\begin{proof}[Base Cases] |
|
173 | 1097 |
The cases for @{const ZERO}, @{const ONE} and @{const ATOM} are routine, because |
149 | 1098 |
we can easily establish that |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1099 |
|
114 | 1100 |
\begin{center} |
1101 |
\begin{tabular}{l} |
|
172 | 1102 |
@{thm quot_zero_eq}\\ |
1103 |
@{thm quot_one_subset}\\ |
|
1104 |
@{thm quot_atom_subset} |
|
114 | 1105 |
\end{tabular} |
1106 |
\end{center} |
|
1107 |
||
116 | 1108 |
\noindent |
174 | 1109 |
hold, which shows that @{term "UNIV // \<approx>(lang r)"} must be finite. |
114 | 1110 |
\end{proof} |
109 | 1111 |
|
116 | 1112 |
\noindent |
183 | 1113 |
Much more interesting, however, are the inductive cases. They seem hard to be solved |
117 | 1114 |
directly. The reader is invited to try. |
1115 |
||
181 | 1116 |
In order to see how our proof proceeds consider the following suggestive picture |
1117 |
taken from Constable et al \cite{Constable00}: |
|
180 | 1118 |
|
181 | 1119 |
\begin{equation}\label{pics} |
1120 |
\mbox{\begin{tabular}{c@ {\hspace{10mm}}c@ {\hspace{10mm}}c} |
|
180 | 1121 |
\begin{tikzpicture}[scale=1] |
1122 |
%Circle |
|
1123 |
\draw[thick] (0,0) circle (1.1); |
|
1124 |
\end{tikzpicture} |
|
1125 |
& |
|
1126 |
\begin{tikzpicture}[scale=1] |
|
1127 |
%Circle |
|
1128 |
\draw[thick] (0,0) circle (1.1); |
|
1129 |
%Main rays |
|
1130 |
\foreach \a in {0, 90,...,359} |
|
1131 |
\draw[very thick] (0, 0) -- (\a:1.1); |
|
1132 |
\foreach \a / \l in {45/1, 135/2, 225/3, 315/4} |
|
1133 |
\draw (\a: 0.65) node {$a_\l$}; |
|
1134 |
\end{tikzpicture} |
|
1135 |
& |
|
1136 |
\begin{tikzpicture}[scale=1] |
|
1137 |
%Circle |
|
1138 |
\draw[thick] (0,0) circle (1.1); |
|
1139 |
%Main rays |
|
1140 |
\foreach \a in {0, 45,...,359} |
|
1141 |
\draw[very thick] (0, 0) -- (\a:1.1); |
|
1142 |
\foreach \a / \l in {22.5/1.1, 67.5/1.2, 112.5/2.1, 157.5/2.2, 202.4/3.1, 247.5/3.2, 292.5/4.1, 337.5/4.2} |
|
1143 |
\draw (\a: 0.77) node {$a_{\l}$}; |
|
1144 |
\end{tikzpicture}\\ |
|
1145 |
@{term UNIV} & @{term "UNIV // (\<approx>(lang r))"} & @{term "UNIV // R"} |
|
181 | 1146 |
\end{tabular}} |
1147 |
\end{equation} |
|
179 | 1148 |
|
181 | 1149 |
\noindent |
1150 |
The relation @{term "\<approx>(lang r)"} partitions the set of all strings into some |
|
183 | 1151 |
equivalence classes. To show that there are only finitely many of them, it |
1152 |
suffices to show in each induction step that another relation, say @{text |
|
184 | 1153 |
R}, has finitely many equivalence classes and refines @{term "\<approx>(lang r)"}. |
1154 |
||
1155 |
\begin{dfntn} |
|
1156 |
A relation @{text "R\<^isub>1"} is said to \emph{refine} @{text "R\<^isub>2"} |
|
1157 |
provided @{text "R\<^isub>1 \<subseteq> R\<^isub>2"}. |
|
1158 |
\end{dfntn} |
|
1159 |
||
1160 |
\noindent |
|
1161 |
For constructing @{text R} will |
|
183 | 1162 |
rely on some \emph{tagging-functions} defined over strings. Given the |
1163 |
inductive hypothesis, it will be easy to prove that the \emph{range} of |
|
1164 |
these tagging-functions is finite. The range of a function @{text f} is |
|
1165 |
defined as |
|
1166 |
||
174 | 1167 |
\begin{center} |
1168 |
@{text "range f \<equiv> f ` UNIV"} |
|
1169 |
\end{center} |
|
1170 |
||
1171 |
\noindent |
|
181 | 1172 |
that means we take the image of @{text f} w.r.t.~all elements in the |
1173 |
domain. With this we will be able to infer that the tagging-functions, seen |
|
187 | 1174 |
as relations, give rise to finitely many equivalence classes. |
1175 |
Finally we will show that the tagging-relations are more refined than |
|
181 | 1176 |
@{term "\<approx>(lang r)"}, which implies that @{term "UNIV // \<approx>(lang r)"} must |
1177 |
also be finite. We formally define the notion of a \emph{tagging-relation} |
|
1178 |
as follows. |
|
1179 |
||
117 | 1180 |
|
167 | 1181 |
\begin{dfntn}[Tagging-Relation] Given a tagging-function @{text tag}, then two strings @{text x} |
119 | 1182 |
and @{text y} are \emph{tag-related} provided |
117 | 1183 |
\begin{center} |
174 | 1184 |
@{text "x \<^raw:$\threesim$>\<^bsub>tag\<^esub> y \<equiv> tag x = tag y"}\;. |
117 | 1185 |
\end{center} |
167 | 1186 |
\end{dfntn} |
117 | 1187 |
|
145 | 1188 |
|
123 | 1189 |
In order to establish finiteness of a set @{text A}, we shall use the following powerful |
118 | 1190 |
principle from Isabelle/HOL's library. |
1191 |
% |
|
1192 |
\begin{equation}\label{finiteimageD} |
|
1193 |
@{thm[mode=IfThen] finite_imageD} |
|
1194 |
\end{equation} |
|
1195 |
||
1196 |
\noindent |
|
123 | 1197 |
It states that if an image of a set under an injective function @{text f} (injective over this set) |
131 | 1198 |
is finite, then the set @{text A} itself must be finite. We can use it to establish the following |
118 | 1199 |
two lemmas. |
1200 |
||
167 | 1201 |
\begin{lmm}\label{finone} |
117 | 1202 |
@{thm[mode=IfThen] finite_eq_tag_rel} |
167 | 1203 |
\end{lmm} |
117 | 1204 |
|
1205 |
\begin{proof} |
|
119 | 1206 |
We set in \eqref{finiteimageD}, @{text f} to be @{text "X \<mapsto> tag ` X"}. We have |
123 | 1207 |
@{text "range f"} to be a subset of @{term "Pow (range tag)"}, which we know must be |
119 | 1208 |
finite by assumption. Now @{term "f (UNIV // =tag=)"} is a subset of @{text "range f"}, |
1209 |
and so also finite. Injectivity amounts to showing that @{text "X = Y"} under the |
|
1210 |
assumptions that @{text "X, Y \<in> "}~@{term "UNIV // =tag="} and @{text "f X = f Y"}. |
|
149 | 1211 |
From the assumptions we can obtain @{text "x \<in> X"} and @{text "y \<in> Y"} with |
123 | 1212 |
@{text "tag x = tag y"}. Since @{text x} and @{text y} are tag-related, this in |
1213 |
turn means that the equivalence classes @{text X} |
|
174 | 1214 |
and @{text Y} must be equal. |
117 | 1215 |
\end{proof} |
1216 |
||
167 | 1217 |
\begin{lmm}\label{fintwo} |
123 | 1218 |
Given two equivalence relations @{text "R\<^isub>1"} and @{text "R\<^isub>2"}, whereby |
118 | 1219 |
@{text "R\<^isub>1"} refines @{text "R\<^isub>2"}. |
1220 |
If @{thm (prem 1) refined_partition_finite[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"]} |
|
1221 |
then @{thm (concl) refined_partition_finite[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"]}. |
|
167 | 1222 |
\end{lmm} |
117 | 1223 |
|
1224 |
\begin{proof} |
|
123 | 1225 |
We prove this lemma again using \eqref{finiteimageD}. This time we set @{text f} to |
118 | 1226 |
be @{text "X \<mapsto>"}~@{term "{R\<^isub>1 `` {x} | x. x \<in> X}"}. It is easy to see that |
135 | 1227 |
@{term "finite (f ` (UNIV // R\<^isub>2))"} because it is a subset of @{term "Pow (UNIV // R\<^isub>1)"}, |
174 | 1228 |
which must be finite by assumption. What remains to be shown is that @{text f} is injective |
118 | 1229 |
on @{term "UNIV // R\<^isub>2"}. This is equivalent to showing that two equivalence |
1230 |
classes, say @{text "X"} and @{text Y}, in @{term "UNIV // R\<^isub>2"} are equal, provided |
|
1231 |
@{text "f X = f Y"}. For @{text "X = Y"} to be equal, we have to find two elements |
|
1232 |
@{text "x \<in> X"} and @{text "y \<in> Y"} such that they are @{text R\<^isub>2} related. |
|
135 | 1233 |
We know there exists a @{text "x \<in> X"} with \mbox{@{term "X = R\<^isub>2 `` {x}"}}. |
1234 |
From the latter fact we can infer that @{term "R\<^isub>1 ``{x} \<in> f X"} |
|
123 | 1235 |
and further @{term "R\<^isub>1 ``{x} \<in> f Y"}. This means we can obtain a @{text y} |
1236 |
such that @{term "R\<^isub>1 `` {x} = R\<^isub>1 `` {y}"} holds. Consequently @{text x} and @{text y} |
|
118 | 1237 |
are @{text "R\<^isub>1"}-related. Since by assumption @{text "R\<^isub>1"} refines @{text "R\<^isub>2"}, |
174 | 1238 |
they must also be @{text "R\<^isub>2"}-related, as we need to show. |
117 | 1239 |
\end{proof} |
1240 |
||
1241 |
\noindent |
|
119 | 1242 |
Chaining Lem.~\ref{finone} and \ref{fintwo} together, means in order to show |
181 | 1243 |
that @{term "UNIV // \<approx>(lang r)"} is finite, we have to construct a tagging-function whose |
174 | 1244 |
range can be shown to be finite and whose tagging-relation refines @{term "\<approx>(lang r)"}. |
183 | 1245 |
Let us attempt the @{const PLUS}-case first. We take as tagging-function |
1246 |
||
119 | 1247 |
\begin{center} |
181 | 1248 |
@{thm tag_Plus_def[where A="A" and B="B", THEN meta_eq_app]} |
119 | 1249 |
\end{center} |
117 | 1250 |
|
119 | 1251 |
\noindent |
183 | 1252 |
where @{text "A"} and @{text "B"} are some arbitrary languages. The reason for this choice |
184 | 1253 |
is that we need to establish that @{term "=(tag_Plus A B)="} refines @{term "\<approx>(A \<union> B)"}. |
1254 |
This amounts to showing @{term "x \<approx>A y"} or @{term "x \<approx>B y"} under the assumption |
|
1255 |
@{term "x"}~@{term "=(tag_Plus A B)="}~@{term y}. As we shall see, this definition will |
|
187 | 1256 |
provide us with just the right assumptions in order to get the proof through. |
183 | 1257 |
|
1258 |
\begin{proof}[@{const "PLUS"}-Case] |
|
1259 |
We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite |
|
1260 |
(UNIV // \<approx>B)"} then @{term "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))"} |
|
1261 |
holds. The range of @{term "tag_Plus A B"} is a subset of this product |
|
1262 |
set---so finite. For the refinement proof-obligation, we know that @{term |
|
1263 |
"(\<approx>A `` {x}, \<approx>B `` {x}) = (\<approx>A `` {y}, \<approx>B `` {y})"} holds by assumption. Then |
|
184 | 1264 |
clearly either @{term "x \<approx>A y"} or @{term "x \<approx>B y"}, as we needed to |
183 | 1265 |
show. Finally we can discharge this case by setting @{text A} to @{term |
1266 |
"lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}. |
|
119 | 1267 |
\end{proof} |
1268 |
||
184 | 1269 |
\noindent |
1270 |
The @{const TIMES}-case is slightly more complicated. We first prove the |
|
187 | 1271 |
following lemma, which will aid the proof about refinement. |
184 | 1272 |
|
1273 |
\begin{lmm}\label{refinement} |
|
1274 |
The relation @{text "\<^raw:$\threesim$>\<^bsub>tag\<^esub>"} refines @{term "\<approx>A"}, provided for |
|
1275 |
all strings @{text x}, @{text y} and @{text z} we have \mbox{@{text "x \<^raw:$\threesim$>\<^bsub>tag\<^esub> y"}} |
|
1276 |
and @{term "x @ z \<in> A"} imply @{text "y @ z \<in> A"}. |
|
1277 |
\end{lmm} |
|
1278 |
||
109 | 1279 |
|
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1280 |
\noindent |
187 | 1281 |
We therefore can analyse how the strings @{text "x @ z"} are in the language |
1282 |
@{text A} and then construct an appropriate tagging-function to infer that |
|
1283 |
@{term "y @ z"} are also in @{text A}. For this we sill need the notion of |
|
1284 |
the set of all possible \emph{partitions} of a string |
|
182
560712a29a36
a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents:
181
diff
changeset
|
1285 |
|
184 | 1286 |
\begin{equation} |
1287 |
@{thm Partitions_def} |
|
1288 |
\end{equation} |
|
1289 |
||
187 | 1290 |
\noindent |
1291 |
If we know that @{text "(x\<^isub>p, x\<^isub>s) \<in> Partitions x"}, we will |
|
1292 |
refer to @{text "x\<^isub>p"} as the \emph{prefix} of the string @{text x}, |
|
1293 |
respectively to @{text "x\<^isub>s"} as the \emph{suffix}. |
|
1294 |
||
1295 |
||
167 | 1296 |
Now assuming @{term "x @ z \<in> A \<cdot> B"} there are only two possible ways of how to `split' |
1297 |
this string to be in @{term "A \<cdot> B"}: |
|
132 | 1298 |
% |
125 | 1299 |
\begin{center} |
181 | 1300 |
\begin{tabular}{c} |
184 | 1301 |
\scalebox{1}{ |
125 | 1302 |
\begin{tikzpicture} |
184 | 1303 |
\node[draw,minimum height=3.8ex] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ }; |
1304 |
\node[draw,minimum height=3.8ex, right=-0.03em of x] (za) { $\hspace{0.6em}@{text "z\<^isub>p"}\hspace{0.6em}$ }; |
|
1305 |
\node[draw,minimum height=3.8ex, right=-0.03em of za] (zza) { $\hspace{2.6em}@{text "z\<^isub>s"}\hspace{2.6em}$ }; |
|
1306 |
||
1307 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1308 |
(x.north west) -- ($(za.north west)+(0em,0em)$) |
|
1309 |
node[midway, above=0.5em]{@{text x}}; |
|
1310 |
||
1311 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1312 |
($(za.north west)+(0em,0ex)$) -- ($(zza.north east)+(0em,0ex)$) |
|
1313 |
node[midway, above=0.5em]{@{text z}}; |
|
1314 |
||
1315 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1316 |
($(x.north west)+(0em,3ex)$) -- ($(zza.north east)+(0em,3ex)$) |
|
1317 |
node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
|
1318 |
||
1319 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1320 |
($(za.south east)+(0em,0ex)$) -- ($(x.south west)+(0em,0ex)$) |
|
1321 |
node[midway, below=0.5em]{@{text "x @ z\<^isub>p \<in> A"}}; |
|
1322 |
||
1323 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1324 |
($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$) |
|
1325 |
node[midway, below=0.5em]{@{text "z\<^isub>s \<in> B"}}; |
|
1326 |
\end{tikzpicture}} |
|
1327 |
\\[2mm] |
|
1328 |
\scalebox{1}{ |
|
1329 |
\begin{tikzpicture} |
|
1330 |
\node[draw,minimum height=3.8ex] (xa) { $\hspace{3em}@{text "x\<^isub>p"}\hspace{3em}$ }; |
|
1331 |
\node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.2em}@{text "x\<^isub>s"}\hspace{0.2em}$ }; |
|
159 | 1332 |
\node[draw,minimum height=3.8ex, right=-0.03em of xxa] (z) { $\hspace{5em}@{text z}\hspace{5em}$ }; |
125 | 1333 |
|
1334 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1335 |
(xa.north west) -- ($(xxa.north east)+(0em,0em)$) |
|
128 | 1336 |
node[midway, above=0.5em]{@{text x}}; |
125 | 1337 |
|
1338 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1339 |
(z.north west) -- ($(z.north east)+(0em,0em)$) |
|
128 | 1340 |
node[midway, above=0.5em]{@{text z}}; |
125 | 1341 |
|
1342 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1343 |
($(xa.north west)+(0em,3ex)$) -- ($(z.north east)+(0em,3ex)$) |
|
167 | 1344 |
node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
125 | 1345 |
|
1346 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1347 |
($(z.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
|
184 | 1348 |
node[midway, below=0.5em]{@{term "x\<^isub>s @ z \<in> B"}}; |
125 | 1349 |
|
1350 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1351 |
($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$) |
|
184 | 1352 |
node[midway, below=0.5em]{@{term "x\<^isub>p \<in> A"}}; |
125 | 1353 |
\end{tikzpicture}} |
159 | 1354 |
\end{tabular} |
125 | 1355 |
\end{center} |
132 | 1356 |
% |
125 | 1357 |
\noindent |
184 | 1358 |
Either @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} |
1359 |
(first picture) or there is a prefix of @{text x} in @{text A} and the rest is in @{text B} |
|
1360 |
(second picture). In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. The first case |
|
1361 |
we will only go through if we know that @{term "x \<approx>A y"} holds @{text "(*)"}. Because then |
|
1362 |
we can infer from @{term "x @ z\<^isub>p \<in> A"} that @{term "y @ z\<^isub>p \<in> A"} holds for all @{text "z\<^isub>p"}. |
|
187 | 1363 |
In the second case we only know that @{text "x\<^isub>p"} and @{text "x\<^isub>s"} is one possible partition |
1364 |
of the string @{text x}. We have to know that both @{text "x\<^isub>p"} and the |
|
185 | 1365 |
corresponding partition @{text "y\<^isub>p"} are in @{text "A"}, and that @{text "x\<^isub>s"} is `@{text B}-related' |
184 | 1366 |
to @{text "y\<^isub>s"} @{text "(**)"}. From the latter fact we can infer that @{text "y\<^isub>s @ z \<in> B"}. |
187 | 1367 |
This will solve the second case. |
185 | 1368 |
Taking the two requirements, @{text "(*)"} and @{text "(**)"}, together we define the |
187 | 1369 |
tagging-function in the @{const Times}-case as: |
184 | 1370 |
|
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1371 |
\begin{center} |
184 | 1372 |
@{thm (lhs) tag_Times_def[where ?A="A" and ?B="B"]}~@{text "\<equiv>"}~ |
185 | 1373 |
@{text "(\<lbrakk>x\<rbrakk>\<^bsub>\<approx>A\<^esub>, {\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | x\<^isub>p \<in> A \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x})"} |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1374 |
\end{center} |
125 | 1375 |
|
1376 |
\noindent |
|
187 | 1377 |
We have to make the assumption for all suffixes @{text "x\<^isub>s"}, since we do |
1378 |
not know anything about how the string @{term x} is partitioned. |
|
1379 |
With this definition in place, let us prove the @{const "Times"}-case. |
|
184 | 1380 |
|
125 | 1381 |
|
173 | 1382 |
\begin{proof}[@{const TIMES}-Case] |
127 | 1383 |
If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
1384 |
then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of |
|
181 | 1385 |
@{term "tag_Times A B"} is a subset of this product set, and therefore finite. |
187 | 1386 |
For the refinement of @{term "\<approx>(A \<cdot> B)"} and @{text "\<^raw:$\threesim$>\<^bsub>\<times>tag A B\<^esub>"}, |
1387 |
we have by Lemma \ref{refinement} |
|
184 | 1388 |
|
127 | 1389 |
\begin{center} |
184 | 1390 |
@{term "tag_Times A B x = tag_Times A B y"} |
127 | 1391 |
\end{center} |
184 | 1392 |
|
127 | 1393 |
\noindent |
187 | 1394 |
and @{term "x @ z \<in> A \<cdot> B"}, and have to establish @{term "y @ z \<in> A \<cdot> |
1395 |
B"}. As shown in the pictures above, there are two cases to be |
|
1396 |
considered. First, there exists a @{text "z\<^isub>p"} and @{text |
|
1397 |
"z\<^isub>s"} such that @{term "x @ z\<^isub>p \<in> A"} and @{text "z\<^isub>s |
|
1398 |
\<in> B"}. By the assumption about @{term "tag_Times A B"} we have @{term "\<approx>A |
|
1399 |
`` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Hence by the Myhill-Nerode |
|
1400 |
relation @{term "y @ z\<^isub>p \<in> A"} holds. Using @{text "z\<^isub>s \<in> B"}, |
|
1401 |
we can conclude in this case with @{term "y @ z \<in> A \<cdot> B"} (recall @{text |
|
1402 |
"z\<^isub>p @ z\<^isub>s = z"}). |
|
184 | 1403 |
|
185 | 1404 |
Second there exists a partition @{text "x\<^isub>p"} and @{text "x\<^isub>s"} with |
184 | 1405 |
@{text "x\<^isub>p \<in> A"} and @{text "x\<^isub>s @ z \<in> B"}. We therefore have |
1406 |
||
127 | 1407 |
\begin{center} |
185 | 1408 |
@{text "\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> \<in> {\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | x\<^isub>p \<in> A \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x}"} |
127 | 1409 |
\end{center} |
184 | 1410 |
|
127 | 1411 |
\noindent |
181 | 1412 |
and by the assumption about @{term "tag_Times A B"} also |
184 | 1413 |
|
127 | 1414 |
\begin{center} |
185 | 1415 |
@{text "\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> \<in> {\<lbrakk>y\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | y\<^isub>p \<in> A \<and> (y\<^isub>p, y\<^isub>s) \<in> Partitions y}"} |
127 | 1416 |
\end{center} |
128 | 1417 |
|
1418 |
\noindent |
|
185 | 1419 |
This means there must be a partition @{text "y\<^isub>p"} and @{text "y\<^isub>s"} |
1420 |
such that @{term "y\<^isub>p \<in> A"} and @{term "\<approx>B `` {x\<^isub>s} = \<approx>B `` |
|
184 | 1421 |
{y\<^isub>s}"}. Unfolding the Myhill-Nerode relation and together with the |
187 | 1422 |
facts that @{text "x\<^isub>p \<in> A"} and \mbox{@{text "x\<^isub>s @ z \<in> B"}}, we |
185 | 1423 |
obtain @{term "y\<^isub>p \<in> A"} and @{text "y\<^isub>s @ z \<in> B"}, as needed in |
184 | 1424 |
this case. We again can complete the @{const TIMES}-case by setting @{text |
1425 |
A} to @{term "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}. |
|
1426 |
\end{proof} |
|
1427 |
||
1428 |
\noindent |
|
1429 |
The case for @{const Star} is similar to @{const TIMES}, but poses a few |
|
187 | 1430 |
extra challenges. To deal with them, we define first the notion of a \emph{string |
184 | 1431 |
prefix} and a \emph{strict string prefix}: |
1432 |
||
128 | 1433 |
\begin{center} |
184 | 1434 |
\begin{tabular}{l} |
1435 |
@{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\\ |
|
1436 |
@{text "x < y \<equiv> x \<le> y \<and> x \<noteq> y"} |
|
1437 |
\end{tabular} |
|
1438 |
\end{center} |
|
1439 |
||
187 | 1440 |
When analysing the case of @{text "x @ z"} being an element in @{term "A\<star>"} |
184 | 1441 |
and @{text x} is not the empty string, we have the following picture: |
1442 |
||
1443 |
\begin{center} |
|
1444 |
\scalebox{1}{ |
|
128 | 1445 |
\begin{tikzpicture} |
184 | 1446 |
\node[draw,minimum height=3.8ex] (xa) { $\hspace{4em}@{text "x\<^bsub>pmax\<^esub>"}\hspace{4em}$ }; |
1447 |
\node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.5em}@{text "x\<^bsub>s\<^esub>"}\hspace{0.5em}$ }; |
|
128 | 1448 |
\node[draw,minimum height=3.8ex, right=-0.03em of xxa] (za) { $\hspace{2em}@{text "z\<^isub>a"}\hspace{2em}$ }; |
1449 |
\node[draw,minimum height=3.8ex, right=-0.03em of za] (zb) { $\hspace{7em}@{text "z\<^isub>b"}\hspace{7em}$ }; |
|
1450 |
||
1451 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1452 |
(xa.north west) -- ($(xxa.north east)+(0em,0em)$) |
|
1453 |
node[midway, above=0.5em]{@{text x}}; |
|
1454 |
||
1455 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1456 |
(za.north west) -- ($(zb.north east)+(0em,0em)$) |
|
1457 |
node[midway, above=0.5em]{@{text z}}; |
|
1458 |
||
1459 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1460 |
($(xa.north west)+(0em,3ex)$) -- ($(zb.north east)+(0em,3ex)$) |
|
1461 |
node[midway, above=0.8em]{@{term "x @ z \<in> A\<star>"}}; |
|
1462 |
||
1463 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1464 |
($(za.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
|
185 | 1465 |
node[midway, below=0.5em]{@{term "x\<^isub>s @ z\<^isub>a \<in> A"}}; |
128 | 1466 |
|
1467 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1468 |
($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$) |
|
185 | 1469 |
node[midway, below=0.5em]{@{text "x\<^bsub>pmax\<^esub> \<in> A\<^isup>\<star>"}}; |
128 | 1470 |
|
1471 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1472 |
($(zb.south east)+(0em,0ex)$) -- ($(zb.south west)+(0em,0ex)$) |
|
136 | 1473 |
node[midway, below=0.5em]{@{term "z\<^isub>b \<in> A\<star>"}}; |
128 | 1474 |
|
1475 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1476 |
($(zb.south east)+(0em,-4ex)$) -- ($(xxa.south west)+(0em,-4ex)$) |
|
184 | 1477 |
node[midway, below=0.5em]{@{term "x\<^isub>s @ z \<in> A\<star>"}}; |
128 | 1478 |
\end{tikzpicture}} |
1479 |
\end{center} |
|
132 | 1480 |
% |
128 | 1481 |
\noindent |
184 | 1482 |
We can find a strict prefix @{text "x\<^isub>p"} of @{text x} such that @{term "x\<^isub>p \<in> A\<star>"}, |
1483 |
@{text "x\<^isub>p < x"} and the rest @{term "x\<^isub>s @ z \<in> A\<star>"}. For example the empty string |
|
187 | 1484 |
@{text "[]"} would do (recall @{term "x \<noteq> []"}). |
135 | 1485 |
There are potentially many such prefixes, but there can only be finitely many of them (the |
128 | 1486 |
string @{text x} is finite). Let us therefore choose the longest one and call it |
184 | 1487 |
@{text "x\<^bsub>pmax\<^esub>"}. Now for the rest of the string @{text "x\<^isub>s @ z"} we |
187 | 1488 |
know it is in @{term "A\<star>"} and cannot be the empty string. By Prop.~\ref{langprops}@{text "(iv)"}, |
185 | 1489 |
we can separate |
187 | 1490 |
this string into two parts, say @{text "a"} and @{text "b"}, such that @{text "a \<noteq> []"}, @{text "a \<in> A"} |
184 | 1491 |
and @{term "b \<in> A\<star>"}. Now @{text a} must be strictly longer than @{text "x\<^isub>s"}, |
1492 |
otherwise @{text "x\<^bsub>pmax\<^esub>"} is not the longest prefix. That means @{text a} |
|
128 | 1493 |
`overlaps' with @{text z}, splitting it into two components @{text "z\<^isub>a"} and |
184 | 1494 |
@{text "z\<^isub>b"}. For this we know that @{text "x\<^isub>s @ z\<^isub>a \<in> A"} and |
135 | 1495 |
@{term "z\<^isub>b \<in> A\<star>"}. To cut a story short, we have divided @{term "x @ z \<in> A\<star>"} |
128 | 1496 |
such that we have a string @{text a} with @{text "a \<in> A"} that lies just on the |
184 | 1497 |
`border' of @{text x} and @{text z}. This string is @{text "x\<^isub>s @ z\<^isub>a"}. |
1498 |
||
135 | 1499 |
In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use |
128 | 1500 |
the following tagging-function: |
132 | 1501 |
% |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1502 |
\begin{center} |
185 | 1503 |
@{thm (lhs) tag_Star_def[where ?A="A", THEN meta_eq_app]}~@{text "\<equiv>"}~ |
1504 |
@{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>s, x\<^isub>p) \<in> Partitions x}"} |
|
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1505 |
\end{center} |
128 | 1506 |
|
177 | 1507 |
\begin{proof}[@{const Star}-Case] |
130 | 1508 |
If @{term "finite (UNIV // \<approx>A)"} |
1509 |
then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
|
181 | 1510 |
@{term "tag_Star A"} is a subset of this set, and therefore finite. |
185 | 1511 |
Again we have to show under the assumption @{term "x"}~@{term "=(tag_Star A)="}~@{term y} |
1512 |
that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}. |
|
1513 |
||
130 | 1514 |
We first need to consider the case that @{text x} is the empty string. |
187 | 1515 |
From the assumption about strict prefixes in @{text "\<^raw:$\threesim$>\<^bsub>\<star>tag A\<^esub>"}, we |
1516 |
can infer @{text y} is the empty string and |
|
1517 |
then clearly have @{term "y @ z \<in> A\<star>"}. In case @{text x} is not the empty |
|
134 | 1518 |
string, we can divide the string @{text "x @ z"} as shown in the picture |
185 | 1519 |
above. By the tagging-function and the facts @{text "x\<^bsub>pmax\<^esub> \<in> A\<^isup>\<star>"} and @{text "x\<^bsub>pmax\<^esub> < x"}, |
1520 |
we have |
|
1521 |
||
130 | 1522 |
\begin{center} |
185 | 1523 |
@{text "\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> \<in> {\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^bsub>pmax\<^esub> < x \<and> x\<^bsub>pmax\<^esub> \<in> A\<^isup>\<star> \<and> (x\<^bsub>pmax\<^esub>, x\<^isub>s) \<in> Partitions x}"} |
130 | 1524 |
\end{center} |
185 | 1525 |
|
130 | 1526 |
\noindent |
1527 |
which by assumption is equal to |
|
185 | 1528 |
|
130 | 1529 |
\begin{center} |
185 | 1530 |
@{text "\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> \<in> {\<lbrakk>y\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | y\<^bsub>p\<^esub> < y \<and> y\<^bsub>p\<^esub> \<in> A\<^isup>\<star> \<and> (y\<^bsub>p\<^esub>, y\<^isub>s) \<in> Partitions y}"} |
130 | 1531 |
\end{center} |
185 | 1532 |
|
130 | 1533 |
\noindent |
187 | 1534 |
From this we know there exist partitions @{text "y\<^isub>p"} and @{text |
185 | 1535 |
"y\<^isub>s"} with @{term "y\<^isub>p \<in> A\<star>"} and also @{term "x\<^isub>s \<approx>A |
1536 |
y\<^isub>s"}. Unfolding the Myhill-Nerode relation we know @{term |
|
1537 |
"y\<^isub>s @ z\<^isub>a \<in> A"}. We also know that @{term "z\<^isub>b \<in> A\<star>"}. |
|
1538 |
Therefore @{term "y\<^isub>p @ (y\<^isub>s @ z\<^isub>a) @ z\<^isub>b \<in> |
|
1539 |
A\<star>"}, which means @{term "y @ z \<in> A\<star>"}. As the last step we have to set |
|
187 | 1540 |
@{text "A"} to @{term "lang r"} and thus complete the proof. |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1541 |
\end{proof} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1542 |
*} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1543 |
|
187 | 1544 |
section {* Second Part proved using Partial Derivatives *} |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1545 |
|
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1546 |
text {* |
173 | 1547 |
\noindent |
1548 |
As we have seen in the previous section, in order to establish |
|
1549 |
the second direction of the Myhill-Nerode theorem, we need to find |
|
174 | 1550 |
a more refined relation than @{term "\<approx>(lang r)"} for which we can |
1551 |
show that there are only finitely many equivalence classes. So far we |
|
1552 |
showed this by induction on @{text "r"}. However, there is also |
|
187 | 1553 |
an indirect method to come up with such a refined relation based on |
1554 |
derivatives of regular expressions \cite{Brzozowski64}. |
|
1555 |
||
1556 |
Assume the following two definitions for a \emph{left-quotient} of a language, |
|
1557 |
which we write as @{term "Der c A"} and @{term "Ders s A"} where @{text c} |
|
1558 |
is a character and @{text s} a string: |
|
174 | 1559 |
|
1560 |
\begin{center} |
|
1561 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{2mm}}l} |
|
1562 |
@{thm (lhs) Der_def} & @{text "\<equiv>"} & @{thm (rhs) Der_def}\\ |
|
1563 |
@{thm (lhs) Ders_def} & @{text "\<equiv>"} & @{thm (rhs) Ders_def}\\ |
|
1564 |
\end{tabular} |
|
1565 |
\end{center} |
|
1566 |
||
1567 |
\noindent |
|
187 | 1568 |
In order to aid readability, we shall also make use of the following abbreviation: |
1569 |
||
1570 |
\begin{center} |
|
1571 |
@{abbrev "Derss s A"} |
|
1572 |
\end{center} |
|
1573 |
||
1574 |
||
1575 |
\noindent |
|
186 | 1576 |
Clearly we have the following relation between the Myhill-Nerode relation |
1577 |
(Def.~\ref{myhillneroderel}) and left-quotients |
|
174 | 1578 |
|
1579 |
\begin{equation}\label{mhders} |
|
1580 |
@{term "x \<approx>A y"} \hspace{4mm}\text{if and only if}\hspace{4mm} @{term "Ders x A = Ders y A"} |
|
1581 |
\end{equation} |
|
1582 |
||
1583 |
\noindent |
|
187 | 1584 |
It is straightforward to establish the following properties for left-quotients: |
174 | 1585 |
|
186 | 1586 |
\begin{equation} |
1587 |
\mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{2mm}}l} |
|
187 | 1588 |
@{thm (lhs) Der_simps(1)} & $=$ & @{thm (rhs) Der_simps(1)}\\ |
1589 |
@{thm (lhs) Der_simps(2)} & $=$ & @{thm (rhs) Der_simps(2)}\\ |
|
1590 |
@{thm (lhs) Der_simps(3)} & $=$ & @{thm (rhs) Der_simps(3)}\\ |
|
1591 |
@{thm (lhs) Der_simps(4)} & $=$ & @{thm (rhs) Der_simps(4)}\\ |
|
174 | 1592 |
@{thm (lhs) Der_conc} & $=$ & @{thm (rhs) Der_conc}\\ |
1593 |
@{thm (lhs) Der_star} & $=$ & @{thm (rhs) Der_star}\\ |
|
187 | 1594 |
@{thm (lhs) Ders_simps(1)} & $=$ & @{thm (rhs) Ders_simps(1)}\\ |
1595 |
@{thm (lhs) Ders_simps(2)} & $=$ & @{thm (rhs) Ders_simps(2)}\\ |
|
1596 |
%@{thm (lhs) Ders_simps(3)[where ?s1.0="s\<^isub>1" and ?s2.0="s\<^isub>2"]} & $=$ |
|
1597 |
% & @{thm (rhs) Ders_simps(3)[where ?s1.0="s\<^isub>1" and ?s2.0="s\<^isub>2"]}\\ |
|
186 | 1598 |
\end{tabular}} |
1599 |
\end{equation} |
|
174 | 1600 |
|
1601 |
\noindent |
|
1602 |
where @{text "\<Delta>"} is a function that tests whether the empty string |
|
1603 |
is in the language and returns @{term "{[]}"} or @{term "{}"}, respectively. |
|
1604 |
The only interesting case above is the last one where we use Prop.~\ref{langprops} |
|
1605 |
in order to infer that @{term "Der c (A\<star>) = Der c (A \<cdot> A\<star>)"}. We can |
|
1606 |
then complete the proof by observing that @{term "Delta A \<cdot> Der c (A\<star>) \<subseteq> (Der c A) \<cdot> A\<star>"}. |
|
1607 |
||
1608 |
Brzozowski observed that the left-quotients for languages of regular |
|
1609 |
expressions can be calculated directly via the notion of \emph{derivatives |
|
186 | 1610 |
of a regular expression} \cite{Brzozowski64}, which we define in Isabelle/HOL as |
174 | 1611 |
follows: |
1612 |
||
1613 |
\begin{center} |
|
1614 |
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
|
1615 |
@{thm (lhs) der.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) der.simps(1)}\\ |
|
1616 |
@{thm (lhs) der.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) der.simps(2)}\\ |
|
1617 |
@{thm (lhs) der.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) der.simps(3)[where c'="d"]}\\ |
|
1618 |
@{thm (lhs) der.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
|
1619 |
& @{text "\<equiv>"} & @{thm (rhs) der.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
|
1620 |
@{thm (lhs) der.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
|
177 | 1621 |
& @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^isub>1"}~@{text "then"}~% |
1622 |
@{term "Plus (Times (der c r\<^isub>1) r\<^isub>2) (der c r\<^isub>2)"}\\ |
|
1623 |
& & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~% |
|
1624 |
@{term "Times (der c r\<^isub>1) r\<^isub>2"}\\ |
|
174 | 1625 |
@{thm (lhs) der.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) der.simps(6)}\smallskip\\ |
1626 |
@{thm (lhs) ders.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) ders.simps(1)}\\ |
|
1627 |
@{thm (lhs) ders.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) ders.simps(2)}\\ |
|
1628 |
\end{tabular} |
|
1629 |
\end{center} |
|
1630 |
||
1631 |
\noindent |
|
187 | 1632 |
The last two clauses extend derivatives for characters to strings (list of |
1633 |
characters). The list-cons operator is written \mbox{@{text "_ :: _"}}. The |
|
1634 |
function @{term "nullable r"} needed in the @{const Times}-case tests |
|
1635 |
whether a regular expression can recognise the empty string: |
|
174 | 1636 |
|
1637 |
\begin{center} |
|
177 | 1638 |
\begin{tabular}{c@ {\hspace{10mm}}c} |
174 | 1639 |
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1640 |
@{thm (lhs) nullable.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(1)}\\ |
|
1641 |
@{thm (lhs) nullable.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(2)}\\ |
|
1642 |
@{thm (lhs) nullable.simps(3)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(3)}\\ |
|
1643 |
\end{tabular} & |
|
1644 |
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
|
1645 |
@{thm (lhs) nullable.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
|
1646 |
& @{text "\<equiv>"} & @{thm (rhs) nullable.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
|
1647 |
@{thm (lhs) nullable.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
|
1648 |
& @{text "\<equiv>"} & @{thm (rhs) nullable.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
|
1649 |
@{thm (lhs) nullable.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(6)}\\ |
|
1650 |
\end{tabular} |
|
1651 |
\end{tabular} |
|
1652 |
\end{center} |
|
1653 |
||
1654 |
\noindent |
|
186 | 1655 |
By induction on the regular expression @{text r}, respectively the string @{text s}, |
1656 |
one can easily show that left-quotients and derivatives relate as follows |
|
1657 |
\cite{Sakarovitch09}: |
|
174 | 1658 |
|
1659 |
\begin{equation}\label{Dersders} |
|
186 | 1660 |
\mbox{\begin{tabular}{c} |
174 | 1661 |
@{thm Der_der}\\ |
1662 |
@{thm Ders_ders} |
|
1663 |
\end{tabular}} |
|
1664 |
\end{equation} |
|
1665 |
||
1666 |
\noindent |
|
186 | 1667 |
The importance in the context of the Myhill-Nerode theorem is that |
187 | 1668 |
we can use \eqref{mhders} and \eqref{Dersders} in order to |
1669 |
establish that @{term "x \<approx>(lang r) y"} is equivalent to |
|
186 | 1670 |
@{term "lang (ders x r) = lang (ders y r)"}. From this we obtain |
174 | 1671 |
|
186 | 1672 |
\begin{equation} |
1673 |
@{term "x \<approx>(lang r) y"}\hspace{4mm}\mbox{provided}\hspace{4mm}@{term "ders x r = ders y r"} |
|
1674 |
\end{equation} |
|
174 | 1675 |
|
1676 |
||
1677 |
\noindent |
|
187 | 1678 |
which means the right-hand side (seen as relation) refines the |
1679 |
Myhill-Nerode relation. Consequently, we can use |
|
1680 |
@{text "\<^raw:$\threesim$>\<^bsub>(\<lambda>x. ders x r)\<^esub>"} as a potential tagging-relation |
|
1681 |
for the regular expression @{text r}. However, in |
|
1682 |
order to be useful in the Myhill-Nerode theorem, we also have to show that |
|
1683 |
for the corresponding language there are only finitely many derivatives---ensuring |
|
1684 |
that there are only finitely many equivalence classes. Unfortunately, this |
|
1685 |
is not true in general. Sakarovitch gives an example where a regular |
|
1686 |
expression has infinitely many derivatives w.r.t.~a language |
|
1687 |
\cite[Page~141]{Sakarovitch09}. What Brzozowski \cite{Brzozowski64} proved |
|
1688 |
is that for every language there \emph{are} only finitely `dissimilar' |
|
1689 |
derivatives for a regular expression. Two regular expressions are said to be |
|
1690 |
\emph{similar} provided they can be identified using the using the @{text |
|
1691 |
"ACI"}-identities: |
|
174 | 1692 |
|
187 | 1693 |
\begin{equation}\label{ACI} |
1694 |
\mbox{\begin{tabular}{cl} |
|
186 | 1695 |
(@{text A}) & @{term "Plus (Plus r\<^isub>1 r\<^isub>2) r\<^isub>3"} $\equiv$ @{term "Plus r\<^isub>1 (Plus r\<^isub>2 r\<^isub>3)"}\\ |
1696 |
(@{text C}) & @{term "Plus r\<^isub>1 r\<^isub>2"} $\equiv$ @{term "Plus r\<^isub>2 r\<^isub>1"}\\ |
|
1697 |
(@{text I}) & @{term "Plus r r"} $\equiv$ @{term "r"}\\ |
|
187 | 1698 |
\end{tabular}} |
1699 |
\end{equation} |
|
174 | 1700 |
|
1701 |
\noindent |
|
187 | 1702 |
Carrying this idea through, we must not consider the set of all derivatives, |
1703 |
but the ones modulo @{text "ACI"}. In principle, this can be formally |
|
1704 |
defined, but it is very painful in a theorem prover (since there is no |
|
1705 |
direct characterisation of the set of dissimlar derivatives). |
|
1706 |
||
174 | 1707 |
|
186 | 1708 |
Fortunately, there is a much simpler approach using \emph{partial |
1709 |
derivatives}. They were introduced by Antimirov \cite{Antimirov95} and can be defined |
|
1710 |
in Isabelle/HOL as follows: |
|
173 | 1711 |
|
175 | 1712 |
\begin{center} |
1713 |
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
|
1714 |
@{thm (lhs) pder.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(1)}\\ |
|
1715 |
@{thm (lhs) pder.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(2)}\\ |
|
1716 |
@{thm (lhs) pder.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(3)[where c'="d"]}\\ |
|
1717 |
@{thm (lhs) pder.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
|
1718 |
& @{text "\<equiv>"} & @{thm (rhs) pder.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
|
1719 |
@{thm (lhs) pder.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
|
177 | 1720 |
& @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^isub>1"}~@{text "then"}~% |
187 | 1721 |
@{term "(Timess (pder c r\<^isub>1) r\<^isub>2) \<union> (pder c r\<^isub>2)"}\\ |
177 | 1722 |
& & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~% |
187 | 1723 |
@{term "Timess (pder c r\<^isub>1) r\<^isub>2"}\\ |
175 | 1724 |
@{thm (lhs) pder.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) pder.simps(6)}\smallskip\\ |
1725 |
@{thm (lhs) pders.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) pders.simps(1)}\\ |
|
187 | 1726 |
@{thm (lhs) pders.simps(2)} & @{text "\<equiv>"} & @{text "\<Union> (pders s) ` (pder c r)"}\\ |
175 | 1727 |
\end{tabular} |
1728 |
\end{center} |
|
173 | 1729 |
|
186 | 1730 |
\noindent |
187 | 1731 |
Again the last two clauses extend partial derivatives from characters to strings. |
1732 |
Unlike `simple' derivatives, the functions for partial derivatives return sets of regular |
|
1733 |
expressions. In the @{const Times} and @{const Star} cases we therefore use the |
|
1734 |
auxiliary definition |
|
186 | 1735 |
|
1736 |
\begin{center} |
|
1737 |
@{text "TIMESS rs r \<equiv> {TIMES r' r | r' \<in> rs}"} |
|
1738 |
\end{center} |
|
1739 |
||
1740 |
\noindent |
|
187 | 1741 |
in order to `sequence' a regular expression with a set of regular |
1742 |
expressions. Note that in the last clause we first build the set of partial |
|
1743 |
derivatives w.r.t~the character @{text c}, then build the image of this set under the |
|
1744 |
function @{term "pders s"} and finally `union up' all resulting sets. It will be |
|
1745 |
convenient to introduce the following abbreviation |
|
1746 |
||
1747 |
\begin{center} |
|
1748 |
@{abbrev "pderss s A"} |
|
1749 |
\end{center} |
|
1750 |
||
1751 |
\noindent |
|
1752 |
which simplifies the last clause of @{const "pders"} to |
|
1753 |
||
1754 |
\begin{center} |
|
1755 |
\begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
|
1756 |
@{thm (lhs) pders.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) pders.simps(2)}\\ |
|
1757 |
\end{tabular} |
|
1758 |
\end{center} |
|
1759 |
||
1760 |
Partial derivatives can be seen as having the @{text "ACI"}-identities already built in: |
|
1761 |
taking the partial derivatives of the |
|
1762 |
regular expressions in \eqref{ACI} gives us in each case |
|
1763 |
equal sets. Antimirov \cite{Antimirov95} showed a similar result to |
|
1764 |
\eqref{Dersders} for partial derivatives: |
|
186 | 1765 |
|
1766 |
\begin{equation} |
|
187 | 1767 |
\mbox{\begin{tabular}{lc} |
1768 |
@{text "(i)"} & @{thm Der_pder}\\ |
|
1769 |
@{text "(ii)"} & @{thm Ders_pders} |
|
186 | 1770 |
\end{tabular}} |
187 | 1771 |
\end{equation} |
1772 |
||
1773 |
\begin{proof} |
|
1774 |
The first fact is by a simple induction on @{text r}. For the second we slightly |
|
1775 |
modify Antimirov's proof by performing an induction on @{text s} where we |
|
1776 |
genaralise over all @{text r}. That means in the @{text "cons"}-case the |
|
1777 |
induction hypothesis is |
|
1778 |
||
1779 |
\begin{center} |
|
1780 |
@{text "(IH)"}\hspace{3mm}@{term "\<forall>r. Ders s (lang r) = \<Union> lang ` (pders s r)"} |
|
1781 |
\end{center} |
|
186 | 1782 |
|
1783 |
\noindent |
|
187 | 1784 |
With this we can establish |
1785 |
||
1786 |
\begin{center} |
|
1787 |
\begin{tabular}{r@ {\hspace{1.5mm}}c@ {\hspace{1.5mm}}ll} |
|
1788 |
@{term "Ders (c # s) (lang r)"} |
|
1789 |
& @{text "="} & @{term "Ders s (Der c (lang r))"} & by def.\\ |
|
1790 |
& @{text "="} & @{term "Ders s (\<Union> lang ` (pder c r))"} & by @{text "(i)"}\\ |
|
1791 |
& @{text "="} & @{term "\<Union> (Ders s) ` (lang ` (pder c r))"} & by def.~of @{text "Ders"}\\ |
|
1792 |
& @{text "="} & @{term "\<Union> lang ` (\<Union> pders s ` (pder c r))"} & by IH\\ |
|
1793 |
& @{text "="} & @{term "\<Union> lang ` (pders (c # s) r)"} & by def.\\ |
|
1794 |
\end{tabular} |
|
1795 |
\end{center} |
|
1796 |
||
1797 |
\noindent |
|
1798 |
In order to apply the induction hypothesis in the fourth step, we need the generalisation |
|
1799 |
over all regular expressions @{text r}. The case for the empty string is routine and omitted. |
|
1800 |
\end{proof} |
|
1801 |
||
1802 |
Antimirov also proved that for every language and regular expression there are only finitely |
|
186 | 1803 |
many partial derivatives. |
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1804 |
*} |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1805 |
|
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1806 |
section {* Closure Properties *} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1807 |
|
186 | 1808 |
text {* |
187 | 1809 |
\noindent |
1810 |
The real beauty of regular languages is that they are closed |
|
1811 |
under almost all set operations. Closure under union, concatenation and Kleene-star |
|
186 | 1812 |
are trivial to establish given our definition of regularity (Def.~\ref{regular}). |
1813 |
More interesting is the closure under complement, because |
|
1814 |
it seems difficult to construct a regular expression for the complement |
|
1815 |
language by direct means. However the existence of such a regular expression |
|
1816 |
can now be easily proved using the Myhill-Nerode theorem since |
|
1817 |
||
1818 |
\begin{center} |
|
1819 |
@{term "s\<^isub>1 \<approx>A s\<^isub>2"} if and only if @{term "s\<^isub>1 \<approx>(-A) s\<^isub>2"} |
|
1820 |
\end{center} |
|
1821 |
||
1822 |
\noindent |
|
1823 |
holds for any strings @{text "s\<^isub>1"} and @{text |
|
1824 |
"s\<^isub>2"}. Therefore @{text A} and the complement language @{term "-A"} |
|
1825 |
give rise to the same partitions. |
|
1826 |
||
1827 |
Once closure under complement is established, closure under intersection |
|
1828 |
and set difference is also easy, because |
|
1829 |
||
1830 |
\begin{center} |
|
1831 |
\begin{tabular}{c} |
|
1832 |
@{term "A \<inter> B = - (- A \<union> - B)"}\\ |
|
1833 |
@{term "A - B = - (- A \<union> B)"} |
|
1834 |
\end{tabular} |
|
1835 |
\end{center} |
|
1836 |
||
1837 |
\noindent |
|
1838 |
Closure of regular languages under reversal, which means |
|
1839 |
||
1840 |
\begin{center} |
|
1841 |
@{text "A\<^bsup>-1\<^esup> \<equiv> {s\<^bsup>-1\<^esup> | s \<in> A}"} |
|
1842 |
\end{center} |
|
1843 |
||
1844 |
\noindent |
|
1845 |
can be shown with the help of the following operation defined on regular |
|
1846 |
expressions |
|
1847 |
||
1848 |
\begin{center} |
|
1849 |
\begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
|
1850 |
@{thm (lhs) Rev.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) Rev.simps(1)}\\ |
|
1851 |
@{thm (lhs) Rev.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) Rev.simps(2)}\\ |
|
1852 |
@{thm (lhs) Rev.simps(3)} & @{text "\<equiv>"} & @{thm (rhs) Rev.simps(3)}\\ |
|
1853 |
@{thm (lhs) Rev.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} & |
|
1854 |
@{thm (rhs) Rev.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
|
1855 |
@{thm (lhs) Rev.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} & |
|
1856 |
@{thm (rhs) Rev.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
|
1857 |
@{thm (lhs) Rev.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) Rev.simps(6)}\\ |
|
1858 |
\end{tabular} |
|
1859 |
\end{center} |
|
1860 |
||
1861 |
||
1862 |
In connection with left-quotient, the perhaps surprising fact is that |
|
1863 |
regular languages are closed under any left-quotient. |
|
1864 |
||
1865 |
||
1866 |
*} |
|
1867 |
||
117 | 1868 |
|
54 | 1869 |
section {* Conclusion and Related Work *} |
1870 |
||
92 | 1871 |
text {* |
186 | 1872 |
\noindent |
112 | 1873 |
In this paper we took the view that a regular language is one where there |
115 | 1874 |
exists a regular expression that matches all of its strings. Regular |
145 | 1875 |
expressions can conveniently be defined as a datatype in HOL-based theorem |
1876 |
provers. For us it was therefore interesting to find out how far we can push |
|
154 | 1877 |
this point of view. We have established in Isabelle/HOL both directions |
1878 |
of the Myhill-Nerode theorem. |
|
132 | 1879 |
% |
167 | 1880 |
\begin{thrm}[The Myhill-Nerode Theorem]\mbox{}\\ |
132 | 1881 |
A language @{text A} is regular if and only if @{thm (rhs) Myhill_Nerode}. |
167 | 1882 |
\end{thrm} |
186 | 1883 |
|
132 | 1884 |
\noindent |
186 | 1885 |
Having formalised this theorem means we pushed our point of view quite |
1886 |
far. Using this theorem we can obviously prove when a language is \emph{not} |
|
1887 |
regular---by establishing that it has infinitely many equivalence classes |
|
1888 |
generated by the Myhill-Nerode relation (this is usually the purpose of the |
|
1889 |
pumping lemma \cite{Kozen97}). We can also use it to establish the standard |
|
1890 |
textbook results about closure properties of regular languages. Interesting |
|
1891 |
is the case of closure under complement, because it seems difficult to |
|
1892 |
construct a regular expression for the complement language by direct |
|
1893 |
means. However the existence of such a regular expression can be easily |
|
1894 |
proved using the Myhill-Nerode theorem. Proving the existence of such a |
|
1895 |
regular expression via automata using the standard method would be quite |
|
1896 |
involved. It includes the steps: regular expression @{text "\<Rightarrow>"} |
|
1897 |
non-deterministic automaton @{text "\<Rightarrow>"} deterministic automaton @{text "\<Rightarrow>"} |
|
1898 |
complement automaton @{text "\<Rightarrow>"} regular expression. |
|
1899 |
||
112 | 1900 |
|
116 | 1901 |
While regular expressions are convenient in formalisations, they have some |
122 | 1902 |
limitations. One is that there seems to be no method of calculating a |
123 | 1903 |
minimal regular expression (for example in terms of length) for a regular |
1904 |
language, like there is |
|
1905 |
for automata. On the other hand, efficient regular expression matching, |
|
1906 |
without using automata, poses no problem \cite{OwensReppyTuron09}. |
|
1907 |
For an implementation of a simple regular expression matcher, |
|
122 | 1908 |
whose correctness has been formally established, we refer the reader to |
1909 |
Owens and Slind \cite{OwensSlind08}. |
|
116 | 1910 |
|
1911 |
||
143
1cc87efb3b53
formalisation of first direction is now only 780 loc
urbanc
parents:
142
diff
changeset
|
1912 |
Our formalisation consists of 780 lines of Isabelle/Isar code for the first |
186 | 1913 |
direction and 460 for the second, plus around 300 lines of standard material |
1914 |
about regular languages. While this might be seen large, it should be seen |
|
1915 |
in the context of the work done by Constable at al \cite{Constable00} who |
|
1916 |
formalised the Myhill-Nerode theorem in Nuprl using automata. They write |
|
1917 |
that their four-member team needed something on the magnitude of 18 months |
|
1918 |
for their formalisation. The estimate for our formalisation is that we |
|
1919 |
needed approximately 3 months and this included the time to find our proof |
|
1920 |
arguments. Unlike Constable et al, who were able to follow the proofs from |
|
1921 |
\cite{HopcroftUllman69}, we had to find our own arguments. So for us the |
|
1922 |
formalisation was not the bottleneck. It is hard to gauge the size of a |
|
1923 |
formalisation in Nurpl, but from what is shown in the Nuprl Math Library |
|
1924 |
about their development it seems substantially larger than ours. The code of |
|
1925 |
ours can be found in the Mercurial Repository at |
|
132 | 1926 |
\mbox{\url{http://www4.in.tum.de/~urbanc/regexp.html}}. |
113 | 1927 |
|
112 | 1928 |
|
186 | 1929 |
|
112 | 1930 |
Our proof of the first direction is very much inspired by \emph{Brzozowski's |
134 | 1931 |
algebraic method} used to convert a finite automaton to a regular |
113 | 1932 |
expression \cite{Brzozowski64}. The close connection can be seen by considering the equivalence |
111 | 1933 |
classes as the states of the minimal automaton for the regular language. |
114 | 1934 |
However there are some subtle differences. Since we identify equivalence |
111 | 1935 |
classes with the states of the automaton, then the most natural choice is to |
1936 |
characterise each state with the set of strings starting from the initial |
|
113 | 1937 |
state leading up to that state. Usually, however, the states are characterised as the |
123 | 1938 |
strings starting from that state leading to the terminal states. The first |
1939 |
choice has consequences about how the initial equational system is set up. We have |
|
115 | 1940 |
the $\lambda$-term on our `initial state', while Brzozowski has it on the |
111 | 1941 |
terminal states. This means we also need to reverse the direction of Arden's |
156 | 1942 |
Lemma. |
92 | 1943 |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1944 |
This is also where our method shines, because we can completely |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1945 |
side-step the standard argument \cite{Kozen97} where automata need |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1946 |
to be composed, which as stated in the Introduction is not so easy |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1947 |
to formalise in a HOL-based theorem prover. However, it is also the |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1948 |
direction where we had to spend most of the `conceptual' time, as |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1949 |
our proof-argument based on tagging-functions is new for |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1950 |
establishing the Myhill-Nerode theorem. All standard proofs of this |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1951 |
direction proceed by arguments over automata.\medskip |
172 | 1952 |
|
173 | 1953 |
We expect that the development of Krauss \& Nipkow gets easier by |
1954 |
using partial derivatives.\medskip |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1955 |
|
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1956 |
\noindent |
173 | 1957 |
{\bf Acknowledgements:} |
1958 |
We are grateful for the comments we received from Larry |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
1959 |
Paulson. |
111 | 1960 |
|
92 | 1961 |
*} |
1962 |
||
1963 |
||
24 | 1964 |
(*<*) |
1965 |
end |
|
1966 |
(*>*) |