author | urbanc |
Tue, 17 Apr 2012 15:45:05 +0000 | |
changeset 345 | 73a415af3bcd |
parent 334 | d47c2143ab8a |
child 385 | e5e32faa2446 |
permissions | -rw-r--r-- |
24 | 1 |
(*<*) |
2 |
theory Paper |
|
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
3 |
imports "../Closures2" "../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 |
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
9 |
REL :: "(string \<times> string) set" |
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 |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
15 |
abbreviation |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
16 |
"Append_rexp2 r_itm r == Append_rexp r r_itm" |
92 | 17 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
18 |
abbreviation |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
19 |
"pow" (infixl "\<up>" 100) |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
20 |
where |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
21 |
"A \<up> n \<equiv> A ^^ n" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
22 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
23 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
24 |
abbreviation "NULL \<equiv> Zero" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
25 |
abbreviation "EMPTY \<equiv> One" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
26 |
abbreviation "CHAR \<equiv> Atom" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
27 |
abbreviation "ALT \<equiv> Plus" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
28 |
abbreviation "SEQ \<equiv> Times" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
29 |
abbreviation "STAR \<equiv> Star" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
30 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
31 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
32 |
ML {* @{term "op ^^"} *} |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
33 |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
34 |
notation (latex output) |
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
35 |
str_eq ("\<approx>\<^bsub>_\<^esub>") and |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
36 |
str_eq_applied ("_ \<approx>\<^bsub>_\<^esub> _") and |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
37 |
conc (infixr "\<cdot>" 100) and |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
38 |
star ("_\<^bsup>\<star>\<^esup>") and |
50 | 39 |
pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and |
58 | 40 |
Suc ("_+1" [100] 100) and |
54 | 41 |
quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and |
66 | 42 |
REL ("\<approx>") and |
67 | 43 |
UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
44 |
lang ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and |
75 | 45 |
Lam ("\<lambda>'(_')" [100] 100) and |
89 | 46 |
Trn ("'(_, _')" [100, 100] 100) and |
71 | 47 |
EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and |
88 | 48 |
transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100) and |
92 | 49 |
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
|
50 |
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
|
51 |
Append_rexp_rhs ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 50) and |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
52 |
|
119 | 53 |
uminus ("\<^raw:\ensuremath{\overline{>_\<^raw:}}>" [100] 100) and |
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
54 |
tag_Plus ("tag\<^isub>A\<^isub>L\<^isub>T _ _" [100, 100] 100) and |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
55 |
tag_Plus ("tag\<^isub>A\<^isub>L\<^isub>T _ _ _" [100, 100, 100] 100) and |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
56 |
tag_Times ("tag\<^isub>S\<^isub>E\<^isub>Q _ _" [100, 100] 100) and |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
57 |
tag_Times ("tag\<^isub>S\<^isub>E\<^isub>Q _ _ _" [100, 100, 100] 100) and |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
58 |
tag_Star ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _" [100] 100) and |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
59 |
tag_Star ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _ _" [100, 100] 100) |
166 | 60 |
|
119 | 61 |
lemma meta_eq_app: |
62 |
shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x" |
|
63 |
by auto |
|
64 |
||
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
65 |
lemma conc_def': |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
66 |
"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}" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
67 |
unfolding conc_def by simp |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
68 |
|
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
69 |
lemma str_eq_def': |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
70 |
shows "x \<approx>A y \<equiv> (\<forall>z. x @ z \<in> A \<longleftrightarrow> y @ z \<in> A)" |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
71 |
unfolding str_eq_def by simp |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
72 |
|
166 | 73 |
(* THEOREMS *) |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
74 |
|
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
75 |
lemma conc_Union_left: |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
76 |
shows "B \<cdot> (\<Union>n. A \<up> n) = (\<Union>n. B \<cdot> (A \<up> n))" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
77 |
unfolding conc_def by auto |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
78 |
|
166 | 79 |
notation (Rule output) |
80 |
"==>" ("\<^raw:\mbox{}\inferrule{\mbox{>_\<^raw:}}>\<^raw:{\mbox{>_\<^raw:}}>") |
|
81 |
||
82 |
syntax (Rule output) |
|
83 |
"_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
84 |
("\<^raw:\mbox{}\inferrule{>_\<^raw:}>\<^raw:{\mbox{>_\<^raw:}}>") |
|
85 |
||
86 |
"_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" |
|
87 |
("\<^raw:\mbox{>_\<^raw:}\\>/ _") |
|
88 |
||
89 |
"_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>") |
|
90 |
||
91 |
notation (Axiom output) |
|
92 |
"Trueprop" ("\<^raw:\mbox{}\inferrule{\mbox{}}{\mbox{>_\<^raw:}}>") |
|
93 |
||
94 |
notation (IfThen output) |
|
95 |
"==>" ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
96 |
syntax (IfThen output) |
|
97 |
"_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
98 |
("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
99 |
"_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}> /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _") |
|
100 |
"_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>") |
|
101 |
||
102 |
notation (IfThenNoBox output) |
|
103 |
"==>" ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
104 |
syntax (IfThenNoBox output) |
|
105 |
"_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop" |
|
106 |
("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.") |
|
107 |
"_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("_ /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _") |
|
108 |
"_asm" :: "prop \<Rightarrow> asms" ("_") |
|
109 |
||
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
110 |
lemma pow_length: |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
111 |
assumes a: "[] \<notin> A" |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
112 |
and b: "s \<in> A \<up> Suc n" |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
113 |
shows "n < length s" |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
114 |
using b |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
115 |
proof (induct n arbitrary: s) |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
116 |
case 0 |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
117 |
have "s \<in> A \<up> Suc 0" by fact |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
118 |
with a have "s \<noteq> []" by auto |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
119 |
then show "0 < length s" by auto |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
120 |
next |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
121 |
case (Suc n) |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
122 |
have ih: "\<And>s. s \<in> A \<up> Suc n \<Longrightarrow> n < length s" by fact |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
123 |
have "s \<in> A \<up> Suc (Suc n)" by fact |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
124 |
then obtain s1 s2 where eq: "s = s1 @ s2" and *: "s1 \<in> A" and **: "s2 \<in> A \<up> Suc n" |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
125 |
by (auto simp add: Seq_def) |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
126 |
from ih ** have "n < length s2" by simp |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
127 |
moreover have "0 < length s1" using * a by auto |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
128 |
ultimately show "Suc n < length s" unfolding eq |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
129 |
by (simp only: length_append) |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
130 |
qed |
166 | 131 |
|
24 | 132 |
(*>*) |
133 |
||
70 | 134 |
|
24 | 135 |
section {* Introduction *} |
136 |
||
137 |
text {* |
|
58 | 138 |
Regular languages are an important and well-understood subject in Computer |
60 | 139 |
Science, with many beautiful theorems and many useful algorithms. There is a |
66 | 140 |
wide range of textbooks on this subject, many of which are aimed at students |
115 | 141 |
and contain very detailed `pencil-and-paper' proofs |
60 | 142 |
(e.g.~\cite{Kozen97}). It seems natural to exercise theorem provers by |
101 | 143 |
formalising the theorems and by verifying formally the algorithms. |
59 | 144 |
|
66 | 145 |
There is however a problem: the typical approach to regular languages is to |
146 |
introduce finite automata and then define everything in terms of them. For |
|
147 |
example, a regular language is normally defined as one whose strings are |
|
148 |
recognised by a finite deterministic automaton. This approach has many |
|
71 | 149 |
benefits. Among them is the fact that it is easy to convince oneself that |
66 | 150 |
regular languages are closed under complementation: one just has to exchange |
151 |
the accepting and non-accepting states in the corresponding automaton to |
|
152 |
obtain an automaton for the complement language. The problem, however, lies with |
|
67 | 153 |
formalising such reasoning in a HOL-based theorem prover, in our case |
115 | 154 |
Isabelle/HOL. Automata are built up from states and transitions that |
82 | 155 |
need to be represented as graphs, matrices or functions, none |
154 | 156 |
of which can be defined as an inductive datatype. |
66 | 157 |
|
82 | 158 |
In case of graphs and matrices, this means we have to build our own |
159 |
reasoning infrastructure for them, as neither Isabelle/HOL nor HOL4 nor |
|
160 |
HOLlight support them with libraries. Even worse, reasoning about graphs and |
|
161 |
matrices can be a real hassle in HOL-based theorem provers. Consider for |
|
162 |
example the operation of sequencing two automata, say $A_1$ and $A_2$, by |
|
159 | 163 |
connecting the accepting states of $A_1$ to the initial state of $A_2$:\\[-5.5mm] |
164 |
% |
|
60 | 165 |
\begin{center} |
66 | 166 |
\begin{tabular}{ccc} |
167 |
\begin{tikzpicture}[scale=0.8] |
|
168 |
%\draw[step=2mm] (-1,-1) grid (1,1); |
|
169 |
||
170 |
\draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3); |
|
171 |
\draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3); |
|
172 |
||
173 |
\node (A) at (-1.0,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
174 |
\node (B) at ( 0.2,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
175 |
||
176 |
\node (C) at (-0.2, 0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
177 |
\node (D) at (-0.2,-0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
178 |
||
179 |
\node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
180 |
\node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
181 |
\node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
182 |
||
183 |
\draw (-0.6,0.0) node {\footnotesize$A_1$}; |
|
184 |
\draw ( 0.6,0.0) node {\footnotesize$A_2$}; |
|
185 |
\end{tikzpicture} |
|
186 |
||
187 |
& |
|
188 |
||
189 |
\raisebox{1.1mm}{\bf\Large$\;\;\;\Rightarrow\,\;\;$} |
|
190 |
||
191 |
& |
|
192 |
||
193 |
\begin{tikzpicture}[scale=0.8] |
|
194 |
%\draw[step=2mm] (-1,-1) grid (1,1); |
|
195 |
||
196 |
\draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3); |
|
197 |
\draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3); |
|
198 |
||
199 |
\node (A) at (-1.0,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
200 |
\node (B) at ( 0.2,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
201 |
||
202 |
\node (C) at (-0.2, 0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
203 |
\node (D) at (-0.2,-0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
204 |
||
205 |
\node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
206 |
\node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
207 |
\node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {}; |
|
208 |
||
209 |
\draw (C) to [very thick, bend left=45] (B); |
|
210 |
\draw (D) to [very thick, bend right=45] (B); |
|
211 |
||
212 |
\draw (-0.6,0.0) node {\footnotesize$A_1$}; |
|
213 |
\draw ( 0.6,0.0) node {\footnotesize$A_2$}; |
|
214 |
\end{tikzpicture} |
|
215 |
||
216 |
\end{tabular} |
|
60 | 217 |
\end{center} |
218 |
||
219 |
\noindent |
|
115 | 220 |
On `paper' we can define the corresponding graph in terms of the disjoint |
88 | 221 |
union of the state nodes. Unfortunately in HOL, the standard definition for disjoint |
66 | 222 |
union, namely |
82 | 223 |
% |
224 |
\begin{equation}\label{disjointunion} |
|
66 | 225 |
@{term "UPLUS A\<^isub>1 A\<^isub>2 \<equiv> {(1, x) | x. x \<in> A\<^isub>1} \<union> {(2, y) | y. y \<in> A\<^isub>2}"} |
82 | 226 |
\end{equation} |
60 | 227 |
|
61 | 228 |
\noindent |
66 | 229 |
changes the type---the disjoint union is not a set, but a set of pairs. |
135 | 230 |
Using this definition for disjoint union means we do not have a single type for automata |
92 | 231 |
and hence will not be able to state certain properties about \emph{all} |
154 | 232 |
automata, since there is no type quantification available in HOL (unlike in Coq, for example). An |
67 | 233 |
alternative, which provides us with a single type for automata, is to give every |
234 |
state node an identity, for example a natural |
|
70 | 235 |
number, and then be careful to rename these identities apart whenever |
67 | 236 |
connecting two automata. This results in clunky proofs |
66 | 237 |
establishing that properties are invariant under renaming. Similarly, |
67 | 238 |
connecting two automata represented as matrices results in very adhoc |
66 | 239 |
constructions, which are not pleasant to reason about. |
240 |
||
82 | 241 |
Functions are much better supported in Isabelle/HOL, but they still lead to similar |
88 | 242 |
problems as with graphs. Composing, for example, two non-deterministic automata in parallel |
93 | 243 |
requires also the formalisation of disjoint unions. Nipkow \cite{Nipkow98} |
101 | 244 |
dismisses for this the option of using identities, because it leads according to |
245 |
him to ``messy proofs''. He |
|
103 | 246 |
opts for a variant of \eqref{disjointunion} using bit lists, but writes |
82 | 247 |
|
248 |
\begin{quote} |
|
93 | 249 |
\it% |
250 |
\begin{tabular}{@ {}l@ {}p{0.88\textwidth}@ {}} |
|
101 | 251 |
`` & All lemmas appear obvious given a picture of the composition of automata\ldots |
252 |
Yet their proofs require a painful amount of detail.'' |
|
253 |
\end{tabular} |
|
254 |
\end{quote} |
|
255 |
||
256 |
\noindent |
|
257 |
and |
|
258 |
||
259 |
\begin{quote} |
|
260 |
\it% |
|
261 |
\begin{tabular}{@ {}l@ {}p{0.88\textwidth}@ {}} |
|
93 | 262 |
`` & If the reader finds the above treatment in terms of bit lists revoltingly |
101 | 263 |
concrete, I cannot disagree. A more abstract approach is clearly desirable.'' |
93 | 264 |
\end{tabular} |
82 | 265 |
\end{quote} |
101 | 266 |
|
267 |
||
82 | 268 |
\noindent |
269 |
Moreover, it is not so clear how to conveniently impose a finiteness condition |
|
270 |
upon functions in order to represent \emph{finite} automata. The best is |
|
92 | 271 |
probably to resort to more advanced reasoning frameworks, such as \emph{locales} |
272 |
or \emph{type classes}, |
|
134 | 273 |
which are \emph{not} available in all HOL-based theorem provers. |
82 | 274 |
|
66 | 275 |
Because of these problems to do with representing automata, there seems |
276 |
to be no substantial formalisation of automata theory and regular languages |
|
115 | 277 |
carried out in HOL-based theorem provers. Nipkow \cite{Nipkow98} establishes |
278 |
the link between regular expressions and automata in |
|
279 |
the context of lexing. Berghofer and Reiter \cite{BerghoferReiter09} |
|
280 |
formalise automata working over |
|
281 |
bit strings in the context of Presburger arithmetic. |
|
114 | 282 |
The only larger formalisations of automata theory |
115 | 283 |
are carried out in Nuprl \cite{Constable00} and in Coq \cite{Filliatre97}. |
58 | 284 |
|
82 | 285 |
In this paper, we will not attempt to formalise automata theory in |
159 | 286 |
Isabelle/HOL, but take a different approach to regular |
82 | 287 |
languages. Instead of defining a regular language as one where there exists |
288 |
an automaton that recognises all strings of the language, we define a |
|
289 |
regular language as: |
|
54 | 290 |
|
82 | 291 |
\begin{definition} |
77 | 292 |
A language @{text A} is \emph{regular}, provided there is a regular expression that matches all |
54 | 293 |
strings of @{text "A"}. |
294 |
\end{definition} |
|
295 |
||
296 |
\noindent |
|
110 | 297 |
The reason is that regular expressions, unlike graphs, matrices and functions, can |
71 | 298 |
be easily defined as inductive datatype. Consequently a corresponding reasoning |
299 |
infrastructure comes for free. This has recently been exploited in HOL4 with a formalisation |
|
101 | 300 |
of regular expression matching based on derivatives \cite{OwensSlind08} and |
301 |
with an equivalence checker for regular expressions in Isabelle/HOL \cite{KraussNipkow11}. |
|
302 |
The purpose of this paper is to |
|
71 | 303 |
show that a central result about regular languages---the Myhill-Nerode theorem---can |
304 |
be recreated by only using regular expressions. This theorem gives necessary |
|
305 |
and sufficient conditions for when a language is regular. As a corollary of this |
|
67 | 306 |
theorem we can easily establish the usual closure properties, including |
307 |
complementation, for regular languages.\smallskip |
|
61 | 308 |
|
309 |
\noindent |
|
88 | 310 |
{\bf Contributions:} |
311 |
There is an extensive literature on regular languages. |
|
159 | 312 |
To our best knowledge, our proof of the Myhill-Nerode theorem is the |
67 | 313 |
first that is based on regular expressions, only. We prove the part of this theorem |
314 |
stating that a regular expression has only finitely many partitions using certain |
|
135 | 315 |
tagging-functions. Again to our best knowledge, these tagging-functions have |
67 | 316 |
not been used before to establish the Myhill-Nerode theorem. |
24 | 317 |
*} |
318 |
||
50 | 319 |
section {* Preliminaries *} |
320 |
||
321 |
text {* |
|
67 | 322 |
Strings in Isabelle/HOL are lists of characters with the \emph{empty string} |
92 | 323 |
being represented by the empty list, written @{term "[]"}. \emph{Languages} |
67 | 324 |
are sets of strings. The language containing all strings is written in |
71 | 325 |
Isabelle/HOL as @{term "UNIV::string set"}. The concatenation of two languages |
166 | 326 |
is written @{term "A \<cdot> B"} and a language raised to the power @{text n} is written |
93 | 327 |
@{term "A \<up> n"}. They are defined as usual |
54 | 328 |
|
329 |
\begin{center} |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
330 |
@{thm conc_def'[THEN eq_reflection, where A1="A" and B1="B"]} |
58 | 331 |
\hspace{7mm} |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
332 |
@{thm lang_pow.simps(1)[THEN eq_reflection, where A1="A"]} |
58 | 333 |
\hspace{7mm} |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
334 |
@{thm lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]} |
54 | 335 |
\end{center} |
336 |
||
337 |
\noindent |
|
113 | 338 |
where @{text "@"} is the list-append operation. The Kleene-star of a language @{text A} |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
339 |
is defined as the union over all powers, namely @{thm star_def}. In the paper |
88 | 340 |
we will make use of the following properties of these constructions. |
58 | 341 |
|
71 | 342 |
\begin{proposition}\label{langprops}\mbox{}\\ |
92 | 343 |
\begin{tabular}{@ {}ll} |
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
344 |
(i) & @{thm star_unfold_left} \\ |
92 | 345 |
(ii) & @{thm[mode=IfThen] pow_length}\\ |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
346 |
(iii) & @{thm conc_Union_left} \\ |
71 | 347 |
\end{tabular} |
348 |
\end{proposition} |
|
349 |
||
350 |
\noindent |
|
100 | 351 |
In @{text "(ii)"} we use the notation @{term "length s"} for the length of a |
156 | 352 |
string; this property states that if \mbox{@{term "[] \<notin> A"}} then the lengths of |
100 | 353 |
the strings in @{term "A \<up> (Suc n)"} must be longer than @{text n}. We omit |
354 |
the proofs for these properties, but invite the reader to consult our |
|
123 | 355 |
formalisation.\footnote{Available at \url{http://www4.in.tum.de/~urbanc/regexp.html}} |
71 | 356 |
|
90 | 357 |
The notation in Isabelle/HOL for the quotient of a language @{text A} according to an |
358 |
equivalence relation @{term REL} is @{term "A // REL"}. We will write |
|
71 | 359 |
@{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined |
156 | 360 |
as \mbox{@{text "{y | y \<approx> x}"}}. |
71 | 361 |
|
362 |
||
51 | 363 |
Central to our proof will be the solution of equational systems |
156 | 364 |
involving equivalence classes of languages. For this we will use Arden's Lemma \cite{Brzozowski64}, |
166 | 365 |
which solves equations of the form @{term "X = A \<cdot> X \<union> B"} provided |
115 | 366 |
@{term "[] \<notin> A"}. However we will need the following `reverse' |
166 | 367 |
version of Arden's Lemma (`reverse' in the sense of changing the order of @{term "A \<cdot> X"} to |
368 |
\mbox{@{term "X \<cdot> A"}}). |
|
50 | 369 |
|
75 | 370 |
\begin{lemma}[Reverse Arden's Lemma]\label{arden}\mbox{}\\ |
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
371 |
If @{thm (prem 1) reversed_Arden} then |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
372 |
@{thm (lhs) reversed_Arden} if and only if |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
373 |
@{thm (rhs) reversed_Arden}. |
50 | 374 |
\end{lemma} |
375 |
||
376 |
\begin{proof} |
|
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
377 |
For the right-to-left direction we assume @{thm (rhs) reversed_Arden} and show |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
378 |
that @{thm (lhs) reversed_Arden} holds. From Prop.~\ref{langprops}@{text "(i)"} |
166 | 379 |
we have @{term "A\<star> = {[]} \<union> A \<cdot> A\<star>"}, |
380 |
which is equal to @{term "A\<star> = {[]} \<union> A\<star> \<cdot> A"}. Adding @{text B} to both |
|
381 |
sides gives @{term "B \<cdot> A\<star> = B \<cdot> ({[]} \<union> A\<star> \<cdot> A)"}, whose right-hand side |
|
382 |
is equal to @{term "(B \<cdot> A\<star>) \<cdot> A \<union> B"}. This completes this direction. |
|
50 | 383 |
|
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
384 |
For the other direction we assume @{thm (lhs) reversed_Arden}. By a simple induction |
51 | 385 |
on @{text n}, we can establish the property |
50 | 386 |
|
387 |
\begin{center} |
|
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
388 |
@{text "(*)"}\hspace{5mm} @{thm (concl) reversed_arden_helper} |
50 | 389 |
\end{center} |
390 |
||
391 |
\noindent |
|
166 | 392 |
Using this property we can show that @{term "B \<cdot> (A \<up> n) \<subseteq> X"} holds for |
393 |
all @{text n}. From this we can infer @{term "B \<cdot> A\<star> \<subseteq> X"} using the definition |
|
71 | 394 |
of @{text "\<star>"}. |
51 | 395 |
For the inclusion in the other direction we assume a string @{text s} |
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
396 |
with length @{text k} is an element in @{text X}. Since @{thm (prem 1) reversed_Arden} |
75 | 397 |
we know by Prop.~\ref{langprops}@{text "(ii)"} that |
166 | 398 |
@{term "s \<notin> X \<cdot> (A \<up> Suc k)"} since its length is only @{text k} |
399 |
(the strings in @{term "X \<cdot> (A \<up> Suc k)"} are all longer). |
|
53 | 400 |
From @{text "(*)"} it follows then that |
166 | 401 |
@{term s} must be an element in @{term "(\<Union>m\<in>{0..k}. B \<cdot> (A \<up> m))"}. This in turn |
402 |
implies that @{term s} is in @{term "(\<Union>n. B \<cdot> (A \<up> n))"}. Using Prop.~\ref{langprops}@{text "(iii)"} |
|
403 |
this is equal to @{term "B \<cdot> A\<star>"}, as we needed to show.\qed |
|
50 | 404 |
\end{proof} |
67 | 405 |
|
406 |
\noindent |
|
88 | 407 |
Regular expressions are defined as the inductive datatype |
67 | 408 |
|
409 |
\begin{center} |
|
410 |
@{text r} @{text "::="} |
|
411 |
@{term NULL}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
412 |
@{term EMPTY}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
413 |
@{term "CHAR c"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
414 |
@{term "SEQ r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
415 |
@{term "ALT r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} |
|
416 |
@{term "STAR r"} |
|
417 |
\end{center} |
|
418 |
||
419 |
\noindent |
|
88 | 420 |
and the language matched by a regular expression is defined as |
67 | 421 |
|
422 |
\begin{center} |
|
423 |
\begin{tabular}{c@ {\hspace{10mm}}c} |
|
424 |
\begin{tabular}{rcl} |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
425 |
@{thm (lhs) lang.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(1)}\\ |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
426 |
@{thm (lhs) lang.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(2)}\\ |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
427 |
@{thm (lhs) lang.simps(3)[where a="c"]} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(3)[where a="c"]}\\ |
67 | 428 |
\end{tabular} |
429 |
& |
|
430 |
\begin{tabular}{rcl} |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
431 |
@{thm (lhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} & |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
432 |
@{thm (rhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\ |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
433 |
@{thm (lhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} & |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
434 |
@{thm (rhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\ |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
435 |
@{thm (lhs) lang.simps(6)[where r="r"]} & @{text "\<equiv>"} & |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
436 |
@{thm (rhs) lang.simps(6)[where r="r"]}\\ |
67 | 437 |
\end{tabular} |
438 |
\end{tabular} |
|
439 |
\end{center} |
|
70 | 440 |
|
100 | 441 |
Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating |
132 | 442 |
a regular expression that matches the union of all languages of @{text rs}. We only need to know the |
443 |
existence |
|
92 | 444 |
of such a regular expression and therefore we use Isabelle/HOL's @{const "fold_graph"} and Hilbert's |
93 | 445 |
@{text "\<epsilon>"} to define @{term "\<Uplus>rs"}. This operation, roughly speaking, folds @{const ALT} over the |
100 | 446 |
set @{text rs} with @{const NULL} for the empty set. We can prove that for a finite set @{text rs} |
110 | 447 |
% |
448 |
\begin{equation}\label{uplus} |
|
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
449 |
\mbox{@{thm (lhs) folds_plus_simp} @{text "= \<Union> (\<calL> ` rs)"}} |
110 | 450 |
\end{equation} |
88 | 451 |
|
452 |
\noindent |
|
90 | 453 |
holds, whereby @{text "\<calL> ` rs"} stands for the |
454 |
image of the set @{text rs} under function @{text "\<calL>"}. |
|
50 | 455 |
*} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
456 |
|
132 | 457 |
|
133 | 458 |
section {* The Myhill-Nerode Theorem, First Part *} |
54 | 459 |
|
460 |
text {* |
|
77 | 461 |
The key definition in the Myhill-Nerode theorem is the |
75 | 462 |
\emph{Myhill-Nerode relation}, which states that w.r.t.~a language two |
463 |
strings are related, provided there is no distinguishing extension in this |
|
154 | 464 |
language. This can be defined as a tertiary relation. |
75 | 465 |
|
117 | 466 |
\begin{definition}[Myhill-Nerode Relation] Given a language @{text A}, two strings @{text x} and |
123 | 467 |
@{text y} are Myhill-Nerode related provided |
117 | 468 |
\begin{center} |
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
469 |
@{thm str_eq_def'} |
117 | 470 |
\end{center} |
70 | 471 |
\end{definition} |
472 |
||
71 | 473 |
\noindent |
75 | 474 |
It is easy to see that @{term "\<approx>A"} is an equivalence relation, which |
475 |
partitions the set of all strings, @{text "UNIV"}, into a set of disjoint |
|
108 | 476 |
equivalence classes. To illustrate this quotient construction, let us give a simple |
101 | 477 |
example: consider the regular language containing just |
92 | 478 |
the string @{text "[c]"}. The relation @{term "\<approx>({[c]})"} partitions @{text UNIV} |
101 | 479 |
into three equivalence classes @{text "X\<^isub>1"}, @{text "X\<^isub>2"} and @{text "X\<^isub>3"} |
90 | 480 |
as follows |
481 |
||
482 |
\begin{center} |
|
483 |
@{text "X\<^isub>1 = {[]}"}\hspace{5mm} |
|
484 |
@{text "X\<^isub>2 = {[c]}"}\hspace{5mm} |
|
485 |
@{text "X\<^isub>3 = UNIV - {[], [c]}"} |
|
486 |
\end{center} |
|
487 |
||
488 |
One direction of the Myhill-Nerode theorem establishes |
|
93 | 489 |
that if there are finitely many equivalence classes, like in the example above, then |
490 |
the language is regular. In our setting we therefore have to show: |
|
75 | 491 |
|
492 |
\begin{theorem}\label{myhillnerodeone} |
|
96 | 493 |
@{thm[mode=IfThen] Myhill_Nerode1} |
75 | 494 |
\end{theorem} |
71 | 495 |
|
75 | 496 |
\noindent |
90 | 497 |
To prove this theorem, we first define the set @{term "finals A"} as those equivalence |
100 | 498 |
classes from @{term "UNIV // \<approx>A"} that contain strings of @{text A}, namely |
75 | 499 |
% |
71 | 500 |
\begin{equation} |
70 | 501 |
@{thm finals_def} |
71 | 502 |
\end{equation} |
503 |
||
504 |
\noindent |
|
132 | 505 |
In our running example, @{text "X\<^isub>2"} is the only |
506 |
equivalence class in @{term "finals {[c]}"}. |
|
90 | 507 |
It is straightforward to show that in general @{thm lang_is_union_of_finals} and |
79 | 508 |
@{thm finals_in_partitions} hold. |
75 | 509 |
Therefore if we know that there exists a regular expression for every |
100 | 510 |
equivalence class in \mbox{@{term "finals A"}} (which by assumption must be |
93 | 511 |
a finite set), then we can use @{text "\<bigplus>"} to obtain a regular expression |
98 | 512 |
that matches every string in @{text A}. |
70 | 513 |
|
75 | 514 |
|
90 | 515 |
Our proof of Thm.~\ref{myhillnerodeone} relies on a method that can calculate a |
79 | 516 |
regular expression for \emph{every} equivalence class, not just the ones |
77 | 517 |
in @{term "finals A"}. We |
93 | 518 |
first define the notion of \emph{one-character-transition} between |
519 |
two equivalence classes |
|
75 | 520 |
% |
71 | 521 |
\begin{equation} |
522 |
@{thm transition_def} |
|
523 |
\end{equation} |
|
70 | 524 |
|
71 | 525 |
\noindent |
92 | 526 |
which means that if we concatenate the character @{text c} to the end of all |
527 |
strings in the equivalence class @{text Y}, we obtain a subset of |
|
77 | 528 |
@{text X}. Note that we do not define an automaton here, we merely relate two sets |
110 | 529 |
(with the help of a character). In our concrete example we have |
92 | 530 |
@{term "X\<^isub>1 \<Turnstile>c\<Rightarrow> X\<^isub>2"}, @{term "X\<^isub>1 \<Turnstile>d\<Rightarrow> X\<^isub>3"} with @{text d} being any |
93 | 531 |
other character than @{text c}, and @{term "X\<^isub>3 \<Turnstile>d\<Rightarrow> X\<^isub>3"} for any @{text d}. |
75 | 532 |
|
156 | 533 |
Next we construct an \emph{initial equational system} that |
534 |
contains an equation for each equivalence class. We first give |
|
535 |
an informal description of this construction. Suppose we have |
|
75 | 536 |
the equivalence classes @{text "X\<^isub>1,\<dots>,X\<^isub>n"}, there must be one and only one that |
537 |
contains the empty string @{text "[]"} (since equivalence classes are disjoint). |
|
77 | 538 |
Let us assume @{text "[] \<in> X\<^isub>1"}. We build the following equational system |
75 | 539 |
|
540 |
\begin{center} |
|
541 |
\begin{tabular}{rcl} |
|
542 |
@{text "X\<^isub>1"} & @{text "="} & @{text "(Y\<^isub>1\<^isub>1, CHAR c\<^isub>1\<^isub>1) + \<dots> + (Y\<^isub>1\<^isub>p, CHAR c\<^isub>1\<^isub>p) + \<lambda>(EMPTY)"} \\ |
|
543 |
@{text "X\<^isub>2"} & @{text "="} & @{text "(Y\<^isub>2\<^isub>1, CHAR c\<^isub>2\<^isub>1) + \<dots> + (Y\<^isub>2\<^isub>o, CHAR c\<^isub>2\<^isub>o)"} \\ |
|
544 |
& $\vdots$ \\ |
|
545 |
@{text "X\<^isub>n"} & @{text "="} & @{text "(Y\<^isub>n\<^isub>1, CHAR c\<^isub>n\<^isub>1) + \<dots> + (Y\<^isub>n\<^isub>q, CHAR c\<^isub>n\<^isub>q)"}\\ |
|
546 |
\end{tabular} |
|
547 |
\end{center} |
|
70 | 548 |
|
75 | 549 |
\noindent |
100 | 550 |
where the terms @{text "(Y\<^isub>i\<^isub>j, CHAR c\<^isub>i\<^isub>j)"} |
551 |
stand for all transitions @{term "Y\<^isub>i\<^isub>j \<Turnstile>c\<^isub>i\<^isub>j\<Rightarrow> |
|
159 | 552 |
X\<^isub>i"}. |
553 |
%The intuition behind the equational system is that every |
|
554 |
%equation @{text "X\<^isub>i = rhs\<^isub>i"} in this system |
|
555 |
%corresponds roughly to a state of an automaton whose name is @{text X\<^isub>i} and its predecessor states |
|
556 |
%are the @{text "Y\<^isub>i\<^isub>j"}; the @{text "c\<^isub>i\<^isub>j"} are the labels of the transitions from these |
|
557 |
%predecessor states to @{text X\<^isub>i}. |
|
558 |
There can only be |
|
156 | 559 |
finitely many terms of the form @{text "(Y\<^isub>i\<^isub>j, CHAR c\<^isub>i\<^isub>j)"} in a right-hand side |
560 |
since by assumption there are only finitely many |
|
159 | 561 |
equivalence classes and only finitely many characters. |
562 |
The term @{text "\<lambda>(EMPTY)"} in the first equation acts as a marker for the initial state, that |
|
563 |
is the equivalence class |
|
100 | 564 |
containing @{text "[]"}.\footnote{Note that we mark, roughly speaking, the |
115 | 565 |
single `initial' state in the equational system, which is different from |
100 | 566 |
the method by Brzozowski \cite{Brzozowski64}, where he marks the |
115 | 567 |
`terminal' states. We are forced to set up the equational system in our |
568 |
way, because the Myhill-Nerode relation determines the `direction' of the |
|
123 | 569 |
transitions---the successor `state' of an equivalence class @{text Y} can |
570 |
be reached by adding a character to the end of @{text Y}. This is also the |
|
156 | 571 |
reason why we have to use our reverse version of Arden's Lemma.} |
159 | 572 |
%In our initial equation system there can only be |
573 |
%finitely many terms of the form @{text "(Y\<^isub>i\<^isub>j, CHAR c\<^isub>i\<^isub>j)"} in a right-hand side |
|
574 |
%since by assumption there are only finitely many |
|
575 |
%equivalence classes and only finitely many characters. |
|
100 | 576 |
Overloading the function @{text \<calL>} for the two kinds of terms in the |
92 | 577 |
equational system, we have |
75 | 578 |
|
579 |
\begin{center} |
|
92 | 580 |
@{text "\<calL>(Y, r) \<equiv>"} % |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
581 |
@{thm (rhs) lang_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
582 |
@{thm lang_trm.simps(1)[where r="r", THEN eq_reflection]} |
75 | 583 |
\end{center} |
584 |
||
585 |
\noindent |
|
100 | 586 |
and we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations |
75 | 587 |
% |
588 |
\begin{equation}\label{inv1} |
|
83 | 589 |
@{text "X\<^isub>i = \<calL>(Y\<^isub>i\<^isub>1, CHAR c\<^isub>i\<^isub>1) \<union> \<dots> \<union> \<calL>(Y\<^isub>i\<^isub>q, CHAR c\<^isub>i\<^isub>q)"}. |
75 | 590 |
\end{equation} |
591 |
||
592 |
\noindent |
|
593 |
hold. Similarly for @{text "X\<^isub>1"} we can show the following equation |
|
594 |
% |
|
595 |
\begin{equation}\label{inv2} |
|
159 | 596 |
@{text "X\<^isub>1 = \<calL>(Y\<^isub>1\<^isub>1, CHAR c\<^isub>1\<^isub>1) \<union> \<dots> \<union> \<calL>(Y\<^isub>1\<^isub>p, CHAR c\<^isub>1\<^isub>p) \<union> \<calL>(\<lambda>(EMPTY))"}. |
75 | 597 |
\end{equation} |
598 |
||
599 |
\noindent |
|
160 | 600 |
holds. The reason for adding the @{text \<lambda>}-marker to our initial equational system is |
103 | 601 |
to obtain this equation: it only holds with the marker, since none of |
108 | 602 |
the other terms contain the empty string. The point of the initial equational system is |
603 |
that solving it means we will be able to extract a regular expression for every equivalence class. |
|
100 | 604 |
|
101 | 605 |
Our representation for the equations in Isabelle/HOL are pairs, |
108 | 606 |
where the first component is an equivalence class (a set of strings) |
607 |
and the second component |
|
101 | 608 |
is a set of terms. Given a set of equivalence |
100 | 609 |
classes @{text CS}, our initial equational system @{term "Init CS"} is thus |
101 | 610 |
formally defined as |
104 | 611 |
% |
612 |
\begin{equation}\label{initcs} |
|
613 |
\mbox{\begin{tabular}{rcl} |
|
100 | 614 |
@{thm (lhs) Init_rhs_def} & @{text "\<equiv>"} & |
615 |
@{text "if"}~@{term "[] \<in> X"}\\ |
|
616 |
& & @{text "then"}~@{term "{Trn Y (CHAR c) | Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X} \<union> {Lam EMPTY}"}\\ |
|
617 |
& & @{text "else"}~@{term "{Trn Y (CHAR c)| Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}"}\\ |
|
618 |
@{thm (lhs) Init_def} & @{text "\<equiv>"} & @{thm (rhs) Init_def} |
|
104 | 619 |
\end{tabular}} |
620 |
\end{equation} |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
621 |
*}(*<*) |
100 | 622 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
623 |
lemma test: |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
624 |
assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
625 |
shows "X = \<Union> (lang_trm ` rhs)" |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
626 |
using assms l_eq_r_in_eqs by (simp) |
100 | 627 |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
628 |
(*>*)text {* |
100 | 629 |
\noindent |
630 |
Because we use sets of terms |
|
101 | 631 |
for representing the right-hand sides of equations, we can |
100 | 632 |
prove \eqref{inv1} and \eqref{inv2} more concisely as |
93 | 633 |
% |
100 | 634 |
\begin{lemma}\label{inv} |
635 |
If @{thm (prem 1) test} then @{text "X = \<Union> \<calL> ` rhs"}. |
|
636 |
\end{lemma} |
|
77 | 637 |
|
93 | 638 |
\noindent |
92 | 639 |
Our proof of Thm.~\ref{myhillnerodeone} will proceed by transforming the |
100 | 640 |
initial equational system into one in \emph{solved form} maintaining the invariant |
108 | 641 |
in Lem.~\ref{inv}. From the solved form we will be able to read |
89 | 642 |
off the regular expressions. |
643 |
||
100 | 644 |
In order to transform an equational system into solved form, we have two |
89 | 645 |
operations: one that takes an equation of the form @{text "X = rhs"} and removes |
110 | 646 |
any recursive occurrences of @{text X} in the @{text rhs} using our variant of Arden's |
92 | 647 |
Lemma. The other operation takes an equation @{text "X = rhs"} |
89 | 648 |
and substitutes @{text X} throughout the rest of the equational system |
110 | 649 |
adjusting the remaining regular expressions appropriately. To define this adjustment |
108 | 650 |
we define the \emph{append-operation} taking a term and a regular expression as argument |
89 | 651 |
|
652 |
\begin{center} |
|
162
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
653 |
@{thm Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}\hspace{10mm} |
e93760534354
added directory for journal version; took uptodate version of the theory files
urbanc
parents:
160
diff
changeset
|
654 |
@{thm Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
89 | 655 |
\end{center} |
656 |
||
92 | 657 |
\noindent |
108 | 658 |
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
|
659 |
@{thm (lhs) Append_rexp_rhs_def[where rexp="r"]}. With this we can define |
101 | 660 |
the \emph{arden-operation} for an equation of the form @{text "X = rhs"} as: |
110 | 661 |
% |
662 |
\begin{equation}\label{arden_def} |
|
663 |
\mbox{\begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l} |
|
94 | 664 |
@{thm (lhs) Arden_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ |
665 |
& & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\ |
|
666 |
& & @{text "r' ="} & @{term "STAR (\<Uplus> {r. Trn X r \<in> rhs})"}\\ |
|
667 |
& & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "append_rhs_rexp rhs' r'"}}\\ |
|
110 | 668 |
\end{tabular}} |
669 |
\end{equation} |
|
93 | 670 |
|
671 |
\noindent |
|
101 | 672 |
In this definition, we first delete all terms of the form @{text "(X, r)"} from @{text rhs}; |
110 | 673 |
then we calculate the combined regular expressions for all @{text r} coming |
94 | 674 |
from the deleted @{text "(X, r)"}, and take the @{const STAR} of it; |
675 |
finally we append this regular expression to @{text rhs'}. It can be easily seen |
|
156 | 676 |
that this operation mimics Arden's Lemma on the level of equations. To ensure |
677 |
the non-emptiness condition of Arden's Lemma we say that a right-hand side is |
|
154 | 678 |
@{text ardenable} provided |
110 | 679 |
|
680 |
\begin{center} |
|
681 |
@{thm ardenable_def} |
|
682 |
\end{center} |
|
683 |
||
684 |
\noindent |
|
156 | 685 |
This allows us to prove a version of Arden's Lemma on the level of equations. |
110 | 686 |
|
687 |
\begin{lemma}\label{ardenable} |
|
113 | 688 |
Given an equation @{text "X = rhs"}. |
110 | 689 |
If @{text "X = \<Union>\<calL> ` rhs"}, |
334
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
690 |
@{thm (prem 2) Arden_preserves_soundness}, and |
d47c2143ab8a
partially updated conference paper; slightly tuned journal paper
urbanc
parents:
170
diff
changeset
|
691 |
@{thm (prem 3) Arden_preserves_soundness}, then |
135 | 692 |
@{text "X = \<Union>\<calL> ` (Arden X rhs)"}. |
110 | 693 |
\end{lemma} |
694 |
||
695 |
\noindent |
|
156 | 696 |
Our @{text ardenable} condition is slightly stronger than needed for applying Arden's Lemma, |
697 |
but we can still ensure that it holds troughout our algorithm of transforming equations |
|
698 |
into solved form. The \emph{substitution-operation} takes an equation |
|
95 | 699 |
of the form @{text "X = xrhs"} and substitutes it into the right-hand side @{text rhs}. |
94 | 700 |
|
701 |
\begin{center} |
|
95 | 702 |
\begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l} |
703 |
@{thm (lhs) Subst_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ |
|
704 |
& & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\ |
|
705 |
& & @{text "r' ="} & @{term "\<Uplus> {r. Trn X r \<in> rhs}"}\\ |
|
706 |
& & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "rhs' \<union> append_rhs_rexp xrhs r'"}}\\ |
|
707 |
\end{tabular} |
|
94 | 708 |
\end{center} |
95 | 709 |
|
710 |
\noindent |
|
134 | 711 |
We again delete first all occurrences of @{text "(X, r)"} in @{text rhs}; we then calculate |
95 | 712 |
the regular expression corresponding to the deleted terms; finally we append this |
713 |
regular expression to @{text "xrhs"} and union it up with @{text rhs'}. When we use |
|
714 |
the substitution operation we will arrange it so that @{text "xrhs"} does not contain |
|
110 | 715 |
any occurrence of @{text X}. |
96 | 716 |
|
134 | 717 |
With these two operations in place, we can define the operation that removes one equation |
100 | 718 |
from an equational systems @{text ES}. The operation @{const Subst_all} |
96 | 719 |
substitutes an equation @{text "X = xrhs"} throughout an equational system @{text ES}; |
100 | 720 |
@{const Remove} then completely removes such an equation from @{text ES} by substituting |
110 | 721 |
it to the rest of the equational system, but first eliminating all recursive occurrences |
96 | 722 |
of @{text X} by applying @{const Arden} to @{text "xrhs"}. |
723 |
||
724 |
\begin{center} |
|
725 |
\begin{tabular}{rcl} |
|
726 |
@{thm (lhs) Subst_all_def} & @{text "\<equiv>"} & @{thm (rhs) Subst_all_def}\\ |
|
727 |
@{thm (lhs) Remove_def} & @{text "\<equiv>"} & @{thm (rhs) Remove_def} |
|
728 |
\end{tabular} |
|
729 |
\end{center} |
|
100 | 730 |
|
731 |
\noindent |
|
110 | 732 |
Finally, we can define how an equational system should be solved. For this |
107 | 733 |
we will need to iterate the process of eliminating equations until only one equation |
154 | 734 |
will be left in the system. However, we do not just want to have any equation |
107 | 735 |
as being the last one, but the one involving the equivalence class for |
736 |
which we want to calculate the regular |
|
108 | 737 |
expression. Let us suppose this equivalence class is @{text X}. |
107 | 738 |
Since @{text X} is the one to be solved, in every iteration step we have to pick an |
108 | 739 |
equation to be eliminated that is different from @{text X}. In this way |
740 |
@{text X} is kept to the final step. The choice is implemented using Hilbert's choice |
|
107 | 741 |
operator, written @{text SOME} in the definition below. |
100 | 742 |
|
743 |
\begin{center} |
|
744 |
\begin{tabular}{rc@ {\hspace{4mm}}r@ {\hspace{1mm}}l} |
|
745 |
@{thm (lhs) Iter_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-4mm}}l}{@{text "let"}}\\ |
|
746 |
& & @{text "(Y, yrhs) ="} & @{term "SOME (Y, yrhs). (Y, yrhs) \<in> ES \<and> X \<noteq> Y"} \\ |
|
747 |
& & \multicolumn{2}{@ {\hspace{-4mm}}l}{@{text "in"}~~@{term "Remove ES Y yrhs"}}\\ |
|
748 |
\end{tabular} |
|
749 |
\end{center} |
|
750 |
||
751 |
\noindent |
|
110 | 752 |
The last definition we need applies @{term Iter} over and over until a condition |
159 | 753 |
@{text Cond} is \emph{not} satisfied anymore. This condition states that there |
110 | 754 |
are more than one equation left in the equational system @{text ES}. To solve |
755 |
an equational system we use Isabelle/HOL's @{text while}-operator as follows: |
|
101 | 756 |
|
100 | 757 |
\begin{center} |
758 |
@{thm Solve_def} |
|
759 |
\end{center} |
|
760 |
||
101 | 761 |
\noindent |
103 | 762 |
We are not concerned here with the definition of this operator |
115 | 763 |
(see Berghofer and Nipkow \cite{BerghoferNipkow00}), but note that we eliminate |
103 | 764 |
in each @{const Iter}-step a single equation, and therefore |
765 |
have a well-founded termination order by taking the cardinality |
|
766 |
of the equational system @{text ES}. This enables us to prove |
|
115 | 767 |
properties about our definition of @{const Solve} when we `call' it with |
104 | 768 |
the equivalence class @{text X} and the initial equational system |
769 |
@{term "Init (UNIV // \<approx>A)"} from |
|
108 | 770 |
\eqref{initcs} using the principle: |
110 | 771 |
% |
772 |
\begin{equation}\label{whileprinciple} |
|
773 |
\mbox{\begin{tabular}{l} |
|
103 | 774 |
@{term "invariant (Init (UNIV // \<approx>A))"} \\ |
775 |
@{term "\<forall>ES. invariant ES \<and> Cond ES \<longrightarrow> invariant (Iter X ES)"}\\ |
|
776 |
@{term "\<forall>ES. invariant ES \<and> Cond ES \<longrightarrow> card (Iter X ES) < card ES"}\\ |
|
777 |
@{term "\<forall>ES. invariant ES \<and> \<not> Cond ES \<longrightarrow> P ES"}\\ |
|
778 |
\hline |
|
779 |
\multicolumn{1}{c}{@{term "P (Solve X (Init (UNIV // \<approx>A)))"}} |
|
110 | 780 |
\end{tabular}} |
781 |
\end{equation} |
|
103 | 782 |
|
783 |
\noindent |
|
104 | 784 |
This principle states that given an invariant (which we will specify below) |
785 |
we can prove a property |
|
786 |
@{text "P"} involving @{const Solve}. For this we have to discharge the following |
|
787 |
proof obligations: first the |
|
113 | 788 |
initial equational system satisfies the invariant; second the iteration |
154 | 789 |
step @{text "Iter"} preserves the invariant as long as the condition @{term Cond} holds; |
113 | 790 |
third @{text "Iter"} decreases the termination order, and fourth that |
104 | 791 |
once the condition does not hold anymore then the property @{text P} must hold. |
103 | 792 |
|
104 | 793 |
The property @{term P} in our proof will state that @{term "Solve X (Init (UNIV // \<approx>A))"} |
108 | 794 |
returns with a single equation @{text "X = xrhs"} for some @{text "xrhs"}, and |
104 | 795 |
that this equational system still satisfies the invariant. In order to get |
796 |
the proof through, the invariant is composed of the following six properties: |
|
103 | 797 |
|
798 |
\begin{center} |
|
104 | 799 |
\begin{tabular}{@ {}rcl@ {\hspace{-13mm}}l @ {}} |
800 |
@{text "invariant ES"} & @{text "\<equiv>"} & |
|
103 | 801 |
@{term "finite ES"} & @{text "(finiteness)"}\\ |
802 |
& @{text "\<and>"} & @{thm (rhs) finite_rhs_def} & @{text "(finiteness rhs)"}\\ |
|
104 | 803 |
& @{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
|
804 |
& @{text "\<and>"} & @{thm (rhs) distinctness_def}\\ |
104 | 805 |
& & & @{text "(distinctness)"}\\ |
110 | 806 |
& @{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
|
807 |
& @{text "\<and>"} & @{thm (rhs) validity_def} & @{text "(validity)"}\\ |
103 | 808 |
\end{tabular} |
809 |
\end{center} |
|
810 |
||
104 | 811 |
\noindent |
812 |
The first two ensure that the equational system is always finite (number of equations |
|
160 | 813 |
and number of terms in each equation); the third makes sure the `meaning' of the |
108 | 814 |
equations is preserved under our transformations. The other properties are a bit more |
815 |
technical, but are needed to get our proof through. Distinctness states that every |
|
154 | 816 |
equation in the system is distinct. @{text Ardenable} ensures that we can always |
156 | 817 |
apply the @{text Arden} operation. |
108 | 818 |
The last property states that every @{text rhs} can only contain equivalence classes |
819 |
for which there is an equation. Therefore @{text lhss} is just the set containing |
|
820 |
the first components of an equational system, |
|
821 |
while @{text "rhss"} collects all equivalence classes @{text X} in the terms of the |
|
123 | 822 |
form @{term "Trn X r"}. That means formally @{thm (lhs) lhss_def}~@{text "\<equiv> {X | (X, rhs) \<in> ES}"} |
110 | 823 |
and @{thm (lhs) rhss_def}~@{text "\<equiv> {X | (X, r) \<in> rhs}"}. |
108 | 824 |
|
104 | 825 |
|
110 | 826 |
It is straightforward to prove that the initial equational system satisfies the |
105 | 827 |
invariant. |
828 |
||
110 | 829 |
\begin{lemma}\label{invzero} |
104 | 830 |
@{thm[mode=IfThen] Init_ES_satisfies_invariant} |
831 |
\end{lemma} |
|
832 |
||
105 | 833 |
\begin{proof} |
834 |
Finiteness is given by the assumption and the way how we set up the |
|
835 |
initial equational system. Soundness is proved in Lem.~\ref{inv}. Distinctness |
|
154 | 836 |
follows from the fact that the equivalence classes are disjoint. The @{text ardenable} |
113 | 837 |
property also follows from the setup of the initial equational system, as does |
105 | 838 |
validity.\qed |
839 |
\end{proof} |
|
840 |
||
113 | 841 |
\noindent |
842 |
Next we show that @{text Iter} preserves the invariant. |
|
843 |
||
110 | 844 |
\begin{lemma}\label{iterone} |
104 | 845 |
@{thm[mode=IfThen] iteration_step_invariant[where xrhs="rhs"]} |
846 |
\end{lemma} |
|
847 |
||
107 | 848 |
\begin{proof} |
156 | 849 |
The argument boils down to choosing an equation @{text "Y = yrhs"} to be eliminated |
110 | 850 |
and to show that @{term "Subst_all (ES - {(Y, yrhs)}) Y (Arden Y yrhs)"} |
851 |
preserves the invariant. |
|
852 |
We prove this as follows: |
|
853 |
||
854 |
\begin{center} |
|
855 |
@{text "\<forall> ES."} @{thm (prem 1) Subst_all_satisfies_invariant} implies |
|
856 |
@{thm (concl) Subst_all_satisfies_invariant} |
|
857 |
\end{center} |
|
858 |
||
859 |
\noindent |
|
156 | 860 |
Finiteness is straightforward, as the @{const Subst} and @{const Arden} operations |
116 | 861 |
keep the equational system finite. These operations also preserve soundness |
113 | 862 |
and distinctness (we proved soundness for @{const Arden} in Lem.~\ref{ardenable}). |
154 | 863 |
The property @{text ardenable} is clearly preserved because the append-operation |
110 | 864 |
cannot make a regular expression to match the empty string. Validity is |
865 |
given because @{const Arden} removes an equivalence class from @{text yrhs} |
|
866 |
and then @{const Subst_all} removes @{text Y} from the equational system. |
|
132 | 867 |
Having proved the implication above, we can instantiate @{text "ES"} with @{text "ES - {(Y, yrhs)}"} |
110 | 868 |
which matches with our proof-obligation of @{const "Subst_all"}. Since |
132 | 869 |
\mbox{@{term "ES = ES - {(Y, yrhs)} \<union> {(Y, yrhs)}"}}, we can use the assumption |
110 | 870 |
to complete the proof.\qed |
107 | 871 |
\end{proof} |
872 |
||
113 | 873 |
\noindent |
874 |
We also need the fact that @{text Iter} decreases the termination measure. |
|
875 |
||
110 | 876 |
\begin{lemma}\label{itertwo} |
104 | 877 |
@{thm[mode=IfThen] iteration_step_measure[simplified (no_asm), where xrhs="rhs"]} |
878 |
\end{lemma} |
|
879 |
||
105 | 880 |
\begin{proof} |
881 |
By assumption we know that @{text "ES"} is finite and has more than one element. |
|
882 |
Therefore there must be an element @{term "(Y, yrhs) \<in> ES"} with |
|
110 | 883 |
@{term "(Y, yrhs) \<noteq> (X, rhs)"}. Using the distinctness property we can infer |
105 | 884 |
that @{term "Y \<noteq> X"}. We further know that @{text "Remove ES Y yrhs"} |
885 |
removes the equation @{text "Y = yrhs"} from the system, and therefore |
|
886 |
the cardinality of @{const Iter} strictly decreases.\qed |
|
887 |
\end{proof} |
|
888 |
||
113 | 889 |
\noindent |
134 | 890 |
This brings us to our property we want to establish for @{text Solve}. |
113 | 891 |
|
892 |
||
104 | 893 |
\begin{lemma} |
894 |
If @{thm (prem 1) Solve} and @{thm (prem 2) Solve} then there exists |
|
895 |
a @{text rhs} such that @{term "Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)}"} |
|
896 |
and @{term "invariant {(X, rhs)}"}. |
|
897 |
\end{lemma} |
|
898 |
||
107 | 899 |
\begin{proof} |
110 | 900 |
In order to prove this lemma using \eqref{whileprinciple}, we have to use a slightly |
901 |
stronger invariant since Lem.~\ref{iterone} and \ref{itertwo} have the precondition |
|
902 |
that @{term "(X, rhs) \<in> ES"} for some @{text rhs}. This precondition is needed |
|
903 |
in order to choose in the @{const Iter}-step an equation that is not \mbox{@{term "X = rhs"}}. |
|
113 | 904 |
Therefore our invariant cannot be just @{term "invariant ES"}, but must be |
110 | 905 |
@{term "invariant ES \<and> (\<exists>rhs. (X, rhs) \<in> ES)"}. By assumption |
906 |
@{thm (prem 2) Solve} and Lem.~\ref{invzero}, the more general invariant holds for |
|
907 |
the initial equational system. This is premise 1 of~\eqref{whileprinciple}. |
|
908 |
Premise 2 is given by Lem.~\ref{iterone} and the fact that @{const Iter} might |
|
909 |
modify the @{text rhs} in the equation @{term "X = rhs"}, but does not remove it. |
|
910 |
Premise 3 of~\eqref{whileprinciple} is by Lem.~\ref{itertwo}. Now in premise 4 |
|
911 |
we like to show that there exists a @{text rhs} such that @{term "ES = {(X, rhs)}"} |
|
912 |
and that @{text "invariant {(X, rhs)}"} holds, provided the condition @{text "Cond"} |
|
113 | 913 |
does not holds. By the stronger invariant we know there exists such a @{text "rhs"} |
110 | 914 |
with @{term "(X, rhs) \<in> ES"}. Because @{text Cond} is not true, we know the cardinality |
123 | 915 |
of @{text ES} is @{text 1}. This means @{text "ES"} must actually be the set @{text "{(X, rhs)}"}, |
110 | 916 |
for which the invariant holds. This allows us to conclude that |
113 | 917 |
@{term "Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)}"} and @{term "invariant {(X, rhs)}"} hold, |
918 |
as needed.\qed |
|
107 | 919 |
\end{proof} |
920 |
||
106 | 921 |
\noindent |
922 |
With this lemma in place we can show that for every equivalence class in @{term "UNIV // \<approx>A"} |
|
923 |
there exists a regular expression. |
|
924 |
||
105 | 925 |
\begin{lemma}\label{every_eqcl_has_reg} |
926 |
@{thm[mode=IfThen] every_eqcl_has_reg} |
|
927 |
\end{lemma} |
|
928 |
||
929 |
\begin{proof} |
|
138 | 930 |
By the preceding lemma, we know that there exists a @{text "rhs"} such |
105 | 931 |
that @{term "Solve X (Init (UNIV // \<approx>A))"} returns the equation @{text "X = rhs"}, |
932 |
and that the invariant holds for this equation. That means we |
|
933 |
know @{text "X = \<Union>\<calL> ` rhs"}. We further know that |
|
109 | 934 |
this is equal to \mbox{@{text "\<Union>\<calL> ` (Arden X rhs)"}} using the properties of the |
123 | 935 |
invariant and Lem.~\ref{ardenable}. Using the validity property for the equation @{text "X = rhs"}, |
156 | 936 |
we can infer that @{term "rhss rhs \<subseteq> {X}"} and because the @{text Arden} operation |
106 | 937 |
removes that @{text X} from @{text rhs}, that @{term "rhss (Arden X rhs) = {}"}. |
113 | 938 |
This means the right-hand side @{term "Arden X rhs"} can only consist of terms of the form @{term "Lam r"}. |
154 | 939 |
So we can collect those (finitely many) regular expressions @{text rs} and have @{term "X = L (\<Uplus>rs)"}. |
106 | 940 |
With this we can conclude the proof.\qed |
105 | 941 |
\end{proof} |
942 |
||
106 | 943 |
\noindent |
944 |
Lem.~\ref{every_eqcl_has_reg} allows us to finally give a proof for the first direction |
|
945 |
of the Myhill-Nerode theorem. |
|
105 | 946 |
|
106 | 947 |
\begin{proof}[of Thm.~\ref{myhillnerodeone}] |
123 | 948 |
By Lem.~\ref{every_eqcl_has_reg} we know that there exists a regular expression for |
105 | 949 |
every equivalence class in @{term "UNIV // \<approx>A"}. Since @{text "finals A"} is |
110 | 950 |
a subset of @{term "UNIV // \<approx>A"}, we also know that for every equivalence class |
123 | 951 |
in @{term "finals A"} there exists a regular expression. Moreover by assumption |
106 | 952 |
we know that @{term "finals A"} must be finite, and therefore there must be a finite |
105 | 953 |
set of regular expressions @{text "rs"} such that |
159 | 954 |
@{term "\<Union>(finals A) = L (\<Uplus>rs)"}. |
105 | 955 |
Since the left-hand side is equal to @{text A}, we can use @{term "\<Uplus>rs"} |
107 | 956 |
as the regular expression that is needed in the theorem.\qed |
105 | 957 |
\end{proof} |
54 | 958 |
*} |
959 |
||
100 | 960 |
|
961 |
||
962 |
||
963 |
section {* Myhill-Nerode, Second Part *} |
|
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
964 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
965 |
text {* |
116 | 966 |
We will prove in this section the second part of the Myhill-Nerode |
160 | 967 |
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
|
968 |
|
54 | 969 |
\begin{theorem} |
135 | 970 |
Given @{text "r"} is a regular expression, then @{thm Myhill_Nerode2}. |
54 | 971 |
\end{theorem} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
972 |
|
116 | 973 |
\noindent |
974 |
The proof will be by induction on the structure of @{text r}. It turns out |
|
975 |
the base cases are straightforward. |
|
976 |
||
977 |
||
978 |
\begin{proof}[Base Cases] |
|
979 |
The cases for @{const NULL}, @{const EMPTY} and @{const CHAR} are routine, because |
|
149 | 980 |
we can easily establish that |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
981 |
|
114 | 982 |
\begin{center} |
983 |
\begin{tabular}{l} |
|
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
984 |
@{thm quot_zero_eq}\\ |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
985 |
@{thm quot_one_subset}\\ |
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
986 |
@{thm quot_atom_subset} |
114 | 987 |
\end{tabular} |
988 |
\end{center} |
|
989 |
||
116 | 990 |
\noindent |
991 |
hold, which shows that @{term "UNIV // \<approx>(L r)"} must be finite.\qed |
|
114 | 992 |
\end{proof} |
109 | 993 |
|
116 | 994 |
\noindent |
154 | 995 |
Much more interesting, however, are the inductive cases. They seem hard to solve |
117 | 996 |
directly. The reader is invited to try. |
997 |
||
135 | 998 |
Our proof will rely on some |
138 | 999 |
\emph{tagging-functions} defined over strings. Given the inductive hypothesis, it will |
135 | 1000 |
be easy to prove that the \emph{range} of these tagging-functions is finite |
119 | 1001 |
(the range of a function @{text f} is defined as @{text "range f \<equiv> f ` UNIV"}). |
135 | 1002 |
With this we will be able to infer that the tagging-functions, seen as relations, |
117 | 1003 |
give rise to finitely many equivalence classes of @{const UNIV}. Finally we |
135 | 1004 |
will show that the tagging-relations are more refined than @{term "\<approx>(L r)"}, which |
123 | 1005 |
implies that @{term "UNIV // \<approx>(L r)"} must also be finite (a relation @{text "R\<^isub>1"} |
1006 |
is said to \emph{refine} @{text "R\<^isub>2"} provided @{text "R\<^isub>1 \<subseteq> R\<^isub>2"}). |
|
1007 |
We formally define the notion of a \emph{tagging-relation} as follows. |
|
117 | 1008 |
|
123 | 1009 |
\begin{definition}[Tagging-Relation] Given a tagging-function @{text tag}, then two strings @{text x} |
119 | 1010 |
and @{text y} are \emph{tag-related} provided |
117 | 1011 |
\begin{center} |
159 | 1012 |
@{text "x =tag= y \<equiv> tag x = tag y"}\;. |
117 | 1013 |
\end{center} |
1014 |
\end{definition} |
|
1015 |
||
145 | 1016 |
|
123 | 1017 |
In order to establish finiteness of a set @{text A}, we shall use the following powerful |
118 | 1018 |
principle from Isabelle/HOL's library. |
1019 |
% |
|
1020 |
\begin{equation}\label{finiteimageD} |
|
1021 |
@{thm[mode=IfThen] finite_imageD} |
|
1022 |
\end{equation} |
|
1023 |
||
1024 |
\noindent |
|
123 | 1025 |
It states that if an image of a set under an injective function @{text f} (injective over this set) |
131 | 1026 |
is finite, then the set @{text A} itself must be finite. We can use it to establish the following |
118 | 1027 |
two lemmas. |
1028 |
||
117 | 1029 |
\begin{lemma}\label{finone} |
1030 |
@{thm[mode=IfThen] finite_eq_tag_rel} |
|
1031 |
\end{lemma} |
|
1032 |
||
1033 |
\begin{proof} |
|
119 | 1034 |
We set in \eqref{finiteimageD}, @{text f} to be @{text "X \<mapsto> tag ` X"}. We have |
123 | 1035 |
@{text "range f"} to be a subset of @{term "Pow (range tag)"}, which we know must be |
119 | 1036 |
finite by assumption. Now @{term "f (UNIV // =tag=)"} is a subset of @{text "range f"}, |
1037 |
and so also finite. Injectivity amounts to showing that @{text "X = Y"} under the |
|
1038 |
assumptions that @{text "X, Y \<in> "}~@{term "UNIV // =tag="} and @{text "f X = f Y"}. |
|
149 | 1039 |
From the assumptions we can obtain @{text "x \<in> X"} and @{text "y \<in> Y"} with |
123 | 1040 |
@{text "tag x = tag y"}. Since @{text x} and @{text y} are tag-related, this in |
1041 |
turn means that the equivalence classes @{text X} |
|
119 | 1042 |
and @{text Y} must be equal.\qed |
117 | 1043 |
\end{proof} |
1044 |
||
1045 |
\begin{lemma}\label{fintwo} |
|
123 | 1046 |
Given two equivalence relations @{text "R\<^isub>1"} and @{text "R\<^isub>2"}, whereby |
118 | 1047 |
@{text "R\<^isub>1"} refines @{text "R\<^isub>2"}. |
1048 |
If @{thm (prem 1) refined_partition_finite[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"]} |
|
1049 |
then @{thm (concl) refined_partition_finite[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"]}. |
|
117 | 1050 |
\end{lemma} |
1051 |
||
1052 |
\begin{proof} |
|
123 | 1053 |
We prove this lemma again using \eqref{finiteimageD}. This time we set @{text f} to |
118 | 1054 |
be @{text "X \<mapsto>"}~@{term "{R\<^isub>1 `` {x} | x. x \<in> X}"}. It is easy to see that |
135 | 1055 |
@{term "finite (f ` (UNIV // R\<^isub>2))"} because it is a subset of @{term "Pow (UNIV // R\<^isub>1)"}, |
118 | 1056 |
which is finite by assumption. What remains to be shown is that @{text f} is injective |
1057 |
on @{term "UNIV // R\<^isub>2"}. This is equivalent to showing that two equivalence |
|
1058 |
classes, say @{text "X"} and @{text Y}, in @{term "UNIV // R\<^isub>2"} are equal, provided |
|
1059 |
@{text "f X = f Y"}. For @{text "X = Y"} to be equal, we have to find two elements |
|
1060 |
@{text "x \<in> X"} and @{text "y \<in> Y"} such that they are @{text R\<^isub>2} related. |
|
135 | 1061 |
We know there exists a @{text "x \<in> X"} with \mbox{@{term "X = R\<^isub>2 `` {x}"}}. |
1062 |
From the latter fact we can infer that @{term "R\<^isub>1 ``{x} \<in> f X"} |
|
123 | 1063 |
and further @{term "R\<^isub>1 ``{x} \<in> f Y"}. This means we can obtain a @{text y} |
1064 |
such that @{term "R\<^isub>1 `` {x} = R\<^isub>1 `` {y}"} holds. Consequently @{text x} and @{text y} |
|
118 | 1065 |
are @{text "R\<^isub>1"}-related. Since by assumption @{text "R\<^isub>1"} refines @{text "R\<^isub>2"}, |
1066 |
they must also be @{text "R\<^isub>2"}-related, as we need to show.\qed |
|
117 | 1067 |
\end{proof} |
1068 |
||
1069 |
\noindent |
|
119 | 1070 |
Chaining Lem.~\ref{finone} and \ref{fintwo} together, means in order to show |
135 | 1071 |
that @{term "UNIV // \<approx>(L r)"} is finite, we have to find a tagging-function whose |
119 | 1072 |
range can be shown to be finite and whose tagging-relation refines @{term "\<approx>(L r)"}. |
123 | 1073 |
Let us attempt the @{const ALT}-case first. |
119 | 1074 |
|
1075 |
\begin{proof}[@{const "ALT"}-Case] |
|
135 | 1076 |
We take as tagging-function |
132 | 1077 |
% |
119 | 1078 |
\begin{center} |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
1079 |
@{thm tag_str_Plus_def[where A="A" and B="B", THEN meta_eq_app]} |
119 | 1080 |
\end{center} |
117 | 1081 |
|
119 | 1082 |
\noindent |
1083 |
where @{text "A"} and @{text "B"} are some arbitrary languages. |
|
1084 |
We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
|
1085 |
then @{term "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))"} holds. The range of |
|
127 | 1086 |
@{term "tag_str_ALT A B"} is a subset of this product set---so finite. It remains to be shown |
120 | 1087 |
that @{text "=tag\<^isub>A\<^isub>L\<^isub>T A B="} refines @{term "\<approx>(A \<union> B)"}. This amounts to |
1088 |
showing |
|
1089 |
% |
|
1090 |
\begin{center} |
|
1091 |
@{term "tag\<^isub>A\<^isub>L\<^isub>T A B x = tag\<^isub>A\<^isub>L\<^isub>T A B y \<longrightarrow> x \<approx>(A \<union> B) y"} |
|
1092 |
\end{center} |
|
132 | 1093 |
% |
120 | 1094 |
\noindent |
1095 |
which by unfolding the Myhill-Nerode relation is identical to |
|
1096 |
% |
|
1097 |
\begin{equation}\label{pattern} |
|
1098 |
@{text "\<forall>z. tag\<^isub>A\<^isub>L\<^isub>T A B x = tag\<^isub>A\<^isub>L\<^isub>T A B y \<and> x @ z \<in> A \<union> B \<longrightarrow> y @ z \<in> A \<union> B"} |
|
1099 |
\end{equation} |
|
132 | 1100 |
% |
120 | 1101 |
\noindent |
1102 |
since both @{text "=tag\<^isub>A\<^isub>L\<^isub>T A B="} and @{term "\<approx>(A \<union> B)"} are symmetric. To solve |
|
142
f1fea2c2713f
changed one occurence of tagging function into tagging relation
urbanc
parents:
138
diff
changeset
|
1103 |
\eqref{pattern} we just have to unfold the definition of the tagging-function and analyse |
123 | 1104 |
in which set, @{text A} or @{text B}, the string @{term "x @ z"} is. |
1105 |
The definition of the tagging-function will give us in each case the |
|
1106 |
information to infer that @{text "y @ z \<in> A \<union> B"}. |
|
1107 |
Finally we |
|
120 | 1108 |
can discharge this case by setting @{text A} to @{term "L r\<^isub>1"} and @{text B} to @{term "L r\<^isub>2"}.\qed |
119 | 1109 |
\end{proof} |
1110 |
||
109 | 1111 |
|
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1112 |
\noindent |
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1113 |
The pattern in \eqref{pattern} is repeated for the other two cases. Unfortunately, |
123 | 1114 |
they are slightly more complicated. In the @{const SEQ}-case we essentially have |
1115 |
to be able to infer that |
|
132 | 1116 |
% |
123 | 1117 |
\begin{center} |
166 | 1118 |
@{text "\<dots>"}@{term "x @ z \<in> A \<cdot> B \<longrightarrow> y @ z \<in> A \<cdot> B"} |
123 | 1119 |
\end{center} |
132 | 1120 |
% |
123 | 1121 |
\noindent |
135 | 1122 |
using the information given by the appropriate tagging-function. The complication |
166 | 1123 |
is to find out what the possible splits of @{text "x @ z"} are to be in @{term "A \<cdot> B"} |
135 | 1124 |
(this was easy in case of @{term "A \<union> B"}). To deal with this complication we define the |
124
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1125 |
notions of \emph{string prefixes} |
132 | 1126 |
% |
124
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1127 |
\begin{center} |
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1128 |
@{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\hspace{10mm} |
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1129 |
@{text "x < y \<equiv> x \<le> y \<and> x \<noteq> y"} |
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1130 |
\end{center} |
132 | 1131 |
% |
124
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1132 |
\noindent |
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1133 |
and \emph{string subtraction}: |
132 | 1134 |
% |
124
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1135 |
\begin{center} |
159 | 1136 |
@{text "[] - y \<equiv> []"}\hspace{10mm} |
1137 |
@{text "x - [] \<equiv> x"}\hspace{10mm} |
|
1138 |
@{text "cx - dy \<equiv> if c = d then x - y else cx"} |
|
124
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1139 |
\end{center} |
132 | 1140 |
% |
124
8233510cab6c
added definition of string prefix and string subtraction
urbanc
parents:
123
diff
changeset
|
1141 |
\noindent |
142
f1fea2c2713f
changed one occurence of tagging function into tagging relation
urbanc
parents:
138
diff
changeset
|
1142 |
where @{text c} and @{text d} are characters, and @{text x} and @{text y} are strings. |
132 | 1143 |
|
166 | 1144 |
Now assuming @{term "x @ z \<in> A \<cdot> B"} there are only two possible ways of how to `split' |
1145 |
this string to be in @{term "A \<cdot> B"}: |
|
132 | 1146 |
% |
125 | 1147 |
\begin{center} |
159 | 1148 |
\begin{tabular}{@ {}c@ {\hspace{10mm}}c@ {}} |
125 | 1149 |
\scalebox{0.7}{ |
1150 |
\begin{tikzpicture} |
|
159 | 1151 |
\node[draw,minimum height=3.8ex] (xa) { $\hspace{3em}@{text "x'"}\hspace{3em}$ }; |
1152 |
\node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.2em}@{text "x - x'"}\hspace{0.2em}$ }; |
|
1153 |
\node[draw,minimum height=3.8ex, right=-0.03em of xxa] (z) { $\hspace{5em}@{text z}\hspace{5em}$ }; |
|
125 | 1154 |
|
1155 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1156 |
(xa.north west) -- ($(xxa.north east)+(0em,0em)$) |
|
128 | 1157 |
node[midway, above=0.5em]{@{text x}}; |
125 | 1158 |
|
1159 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1160 |
(z.north west) -- ($(z.north east)+(0em,0em)$) |
|
128 | 1161 |
node[midway, above=0.5em]{@{text z}}; |
125 | 1162 |
|
1163 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1164 |
($(xa.north west)+(0em,3ex)$) -- ($(z.north east)+(0em,3ex)$) |
|
166 | 1165 |
node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
125 | 1166 |
|
1167 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1168 |
($(z.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
|
1169 |
node[midway, below=0.5em]{@{term "(x - x') @ z \<in> B"}}; |
|
1170 |
||
1171 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1172 |
($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$) |
|
1173 |
node[midway, below=0.5em]{@{term "x' \<in> A"}}; |
|
1174 |
\end{tikzpicture}} |
|
159 | 1175 |
& |
125 | 1176 |
\scalebox{0.7}{ |
1177 |
\begin{tikzpicture} |
|
159 | 1178 |
\node[draw,minimum height=3.8ex] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ }; |
1179 |
\node[draw,minimum height=3.8ex, right=-0.03em of x] (za) { $\hspace{0.6em}@{text "z'"}\hspace{0.6em}$ }; |
|
1180 |
\node[draw,minimum height=3.8ex, right=-0.03em of za] (zza) { $\hspace{2.6em}@{text "z - z'"}\hspace{2.6em}$ }; |
|
125 | 1181 |
|
1182 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1183 |
(x.north west) -- ($(za.north west)+(0em,0em)$) |
|
128 | 1184 |
node[midway, above=0.5em]{@{text x}}; |
125 | 1185 |
|
1186 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1187 |
($(za.north west)+(0em,0ex)$) -- ($(zza.north east)+(0em,0ex)$) |
|
128 | 1188 |
node[midway, above=0.5em]{@{text z}}; |
125 | 1189 |
|
1190 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1191 |
($(x.north west)+(0em,3ex)$) -- ($(zza.north east)+(0em,3ex)$) |
|
166 | 1192 |
node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
125 | 1193 |
|
1194 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1195 |
($(za.south east)+(0em,0ex)$) -- ($(x.south west)+(0em,0ex)$) |
|
1196 |
node[midway, below=0.5em]{@{text "x @ z' \<in> A"}}; |
|
1197 |
||
1198 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1199 |
($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$) |
|
1200 |
node[midway, below=0.5em]{@{text "(z - z') \<in> B"}}; |
|
1201 |
\end{tikzpicture}} |
|
159 | 1202 |
\end{tabular} |
125 | 1203 |
\end{center} |
132 | 1204 |
% |
125 | 1205 |
\noindent |
156 | 1206 |
Either there is a prefix of @{text x} in @{text A} and the rest is in @{text B} (first picture), |
1207 |
or @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} (second picture). |
|
166 | 1208 |
In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. For this we use the |
125 | 1209 |
following tagging-function |
132 | 1210 |
% |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1211 |
\begin{center} |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
1212 |
@{thm tag_str_Times_def[where ?L1.0="A" and ?L2.0="B", THEN meta_eq_app]} |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1213 |
\end{center} |
125 | 1214 |
|
1215 |
\noindent |
|
132 | 1216 |
with the idea that in the first split we have to make sure that @{text "(x - x') @ z"} |
127 | 1217 |
is in the language @{text B}. |
125 | 1218 |
|
1219 |
\begin{proof}[@{const SEQ}-Case] |
|
127 | 1220 |
If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
1221 |
then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of |
|
1222 |
@{term "tag_str_SEQ A B"} is a subset of this product set, and therefore finite. |
|
130 | 1223 |
We have to show injectivity of this tagging-function as |
132 | 1224 |
% |
127 | 1225 |
\begin{center} |
166 | 1226 |
@{term "\<forall>z. tag_str_SEQ A B x = tag_str_SEQ A B y \<and> x @ z \<in> A \<cdot> B \<longrightarrow> y @ z \<in> A \<cdot> B"} |
127 | 1227 |
\end{center} |
132 | 1228 |
% |
127 | 1229 |
\noindent |
128 | 1230 |
There are two cases to be considered (see pictures above). First, there exists |
1231 |
a @{text "x'"} such that |
|
127 | 1232 |
@{text "x' \<in> A"}, @{text "x' \<le> x"} and @{text "(x - x') @ z \<in> B"} hold. We therefore have |
132 | 1233 |
% |
127 | 1234 |
\begin{center} |
1235 |
@{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {x - x'} |x'. x' \<le> x \<and> x' \<in> A})"} |
|
1236 |
\end{center} |
|
132 | 1237 |
% |
127 | 1238 |
\noindent |
1239 |
and by the assumption about @{term "tag_str_SEQ A B"} also |
|
132 | 1240 |
% |
127 | 1241 |
\begin{center} |
1242 |
@{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {y - y'} |y'. y' \<le> y \<and> y' \<in> A})"} |
|
1243 |
\end{center} |
|
132 | 1244 |
% |
127 | 1245 |
\noindent |
1246 |
That means there must be a @{text "y'"} such that @{text "y' \<in> A"} and |
|
1247 |
@{term "\<approx>B `` {x - x'} = \<approx>B `` {y - y'}"}. This equality means that |
|
1248 |
@{term "(x - x') \<approx>B (y - y')"} holds. Unfolding the Myhill-Nerode |
|
1249 |
relation and together with the fact that @{text "(x - x') @ z \<in> B"}, we |
|
1250 |
have @{text "(y - y') @ z \<in> B"}. We already know @{text "y' \<in> A"}, therefore |
|
166 | 1251 |
@{term "y @ z \<in> A \<cdot> B"}, as needed in this case. |
127 | 1252 |
|
1253 |
Second, there exists a @{text "z'"} such that @{term "x @ z' \<in> A"} and @{text "z - z' \<in> B"}. |
|
1254 |
By the assumption about @{term "tag_str_SEQ A B"} we have |
|
1255 |
@{term "\<approx>A `` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Which means by the Myhill-Nerode |
|
134 | 1256 |
relation that @{term "y @ z' \<in> A"} holds. Using @{text "z - z' \<in> B"}, we can conclude also in this case |
166 | 1257 |
with @{term "y @ z \<in> A \<cdot> B"}. We again can complete the @{const SEQ}-case |
129 | 1258 |
by setting @{text A} to @{term "L r\<^isub>1"} and @{text B} to @{term "L r\<^isub>2"}.\qed |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1259 |
\end{proof} |
128 | 1260 |
|
1261 |
\noindent |
|
135 | 1262 |
The case for @{const STAR} is similar to @{const SEQ}, but poses a few extra challenges. When |
137 | 1263 |
we analyse the case that @{text "x @ z"} is an element in @{term "A\<star>"} and @{text x} is not the |
130 | 1264 |
empty string, we |
128 | 1265 |
have the following picture: |
132 | 1266 |
% |
128 | 1267 |
\begin{center} |
1268 |
\scalebox{0.7}{ |
|
1269 |
\begin{tikzpicture} |
|
1270 |
\node[draw,minimum height=3.8ex] (xa) { $\hspace{4em}@{text "x'\<^isub>m\<^isub>a\<^isub>x"}\hspace{4em}$ }; |
|
1271 |
\node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.5em}@{text "x - x'\<^isub>m\<^isub>a\<^isub>x"}\hspace{0.5em}$ }; |
|
1272 |
\node[draw,minimum height=3.8ex, right=-0.03em of xxa] (za) { $\hspace{2em}@{text "z\<^isub>a"}\hspace{2em}$ }; |
|
1273 |
\node[draw,minimum height=3.8ex, right=-0.03em of za] (zb) { $\hspace{7em}@{text "z\<^isub>b"}\hspace{7em}$ }; |
|
1274 |
||
1275 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1276 |
(xa.north west) -- ($(xxa.north east)+(0em,0em)$) |
|
1277 |
node[midway, above=0.5em]{@{text x}}; |
|
1278 |
||
1279 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1280 |
(za.north west) -- ($(zb.north east)+(0em,0em)$) |
|
1281 |
node[midway, above=0.5em]{@{text z}}; |
|
1282 |
||
1283 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1284 |
($(xa.north west)+(0em,3ex)$) -- ($(zb.north east)+(0em,3ex)$) |
|
1285 |
node[midway, above=0.8em]{@{term "x @ z \<in> A\<star>"}}; |
|
1286 |
||
1287 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1288 |
($(za.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
|
1289 |
node[midway, below=0.5em]{@{text "(x - x'\<^isub>m\<^isub>a\<^isub>x) @ z\<^isub>a \<in> A"}}; |
|
1290 |
||
1291 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1292 |
($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$) |
|
136 | 1293 |
node[midway, below=0.5em]{@{term "x'\<^isub>m\<^isub>a\<^isub>x \<in> A\<star>"}}; |
128 | 1294 |
|
1295 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1296 |
($(zb.south east)+(0em,0ex)$) -- ($(zb.south west)+(0em,0ex)$) |
|
136 | 1297 |
node[midway, below=0.5em]{@{term "z\<^isub>b \<in> A\<star>"}}; |
128 | 1298 |
|
1299 |
\draw[decoration={brace,transform={yscale=3}},decorate] |
|
1300 |
($(zb.south east)+(0em,-4ex)$) -- ($(xxa.south west)+(0em,-4ex)$) |
|
136 | 1301 |
node[midway, below=0.5em]{@{term "(x - x'\<^isub>m\<^isub>a\<^isub>x) @ z \<in> A\<star>"}}; |
128 | 1302 |
\end{tikzpicture}} |
1303 |
\end{center} |
|
132 | 1304 |
% |
128 | 1305 |
\noindent |
135 | 1306 |
We can find a strict prefix @{text "x'"} of @{text x} such that @{term "x' \<in> A\<star>"}, |
1307 |
@{text "x' < x"} and the rest @{term "(x - x') @ z \<in> A\<star>"}. For example the empty string |
|
128 | 1308 |
@{text "[]"} would do. |
135 | 1309 |
There are potentially many such prefixes, but there can only be finitely many of them (the |
128 | 1310 |
string @{text x} is finite). Let us therefore choose the longest one and call it |
1311 |
@{text "x'\<^isub>m\<^isub>a\<^isub>x"}. Now for the rest of the string @{text "(x - x'\<^isub>m\<^isub>a\<^isub>x) @ z"} we |
|
135 | 1312 |
know it is in @{term "A\<star>"}. By definition of @{term "A\<star>"}, we can separate |
1313 |
this string into two parts, say @{text "a"} and @{text "b"}, such that @{text "a \<in> A"} |
|
1314 |
and @{term "b \<in> A\<star>"}. Now @{text a} must be strictly longer than @{text "x - x'\<^isub>m\<^isub>a\<^isub>x"}, |
|
128 | 1315 |
otherwise @{text "x'\<^isub>m\<^isub>a\<^isub>x"} is not the longest prefix. That means @{text a} |
1316 |
`overlaps' with @{text z}, splitting it into two components @{text "z\<^isub>a"} and |
|
1317 |
@{text "z\<^isub>b"}. For this we know that @{text "(x - x'\<^isub>m\<^isub>a\<^isub>x) @ z\<^isub>a \<in> A"} and |
|
135 | 1318 |
@{term "z\<^isub>b \<in> A\<star>"}. To cut a story short, we have divided @{term "x @ z \<in> A\<star>"} |
128 | 1319 |
such that we have a string @{text a} with @{text "a \<in> A"} that lies just on the |
145 | 1320 |
`border' of @{text x} and @{text z}. This string is @{text "(x - x'\<^isub>m\<^isub>a\<^isub>x) @ z\<^isub>a"}. |
128 | 1321 |
|
135 | 1322 |
In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use |
128 | 1323 |
the following tagging-function: |
132 | 1324 |
% |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1325 |
\begin{center} |
170
b1258b7d2789
made the theories compatible with the existing developments in the AFP; old theories are in the directory Attic
urbanc
parents:
166
diff
changeset
|
1326 |
@{thm tag_str_Star_def[where ?L1.0="A", THEN meta_eq_app]}\smallskip |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1327 |
\end{center} |
128 | 1328 |
|
1329 |
\begin{proof}[@{const STAR}-Case] |
|
130 | 1330 |
If @{term "finite (UNIV // \<approx>A)"} |
1331 |
then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
|
1332 |
@{term "tag_str_STAR A"} is a subset of this set, and therefore finite. |
|
1333 |
Again we have to show injectivity of this tagging-function as |
|
132 | 1334 |
% |
130 | 1335 |
\begin{center} |
1336 |
@{term "\<forall>z. tag_str_STAR A x = tag_str_STAR A y \<and> x @ z \<in> A\<star> \<longrightarrow> y @ z \<in> A\<star>"} |
|
1337 |
\end{center} |
|
132 | 1338 |
% |
130 | 1339 |
\noindent |
1340 |
We first need to consider the case that @{text x} is the empty string. |
|
1341 |
From the assumption we can infer @{text y} is the empty string and |
|
135 | 1342 |
clearly have @{term "y @ z \<in> A\<star>"}. In case @{text x} is not the empty |
134 | 1343 |
string, we can divide the string @{text "x @ z"} as shown in the picture |
135 | 1344 |
above. By the tagging-function we have |
132 | 1345 |
% |
130 | 1346 |
\begin{center} |
1347 |
@{term "\<approx>A `` {(x - x'\<^isub>m\<^isub>a\<^isub>x)} \<in> ({\<approx>A `` {x - x'} |x'. x' < x \<and> x' \<in> A\<star>})"} |
|
1348 |
\end{center} |
|
132 | 1349 |
% |
130 | 1350 |
\noindent |
1351 |
which by assumption is equal to |
|
132 | 1352 |
% |
130 | 1353 |
\begin{center} |
1354 |
@{term "\<approx>A `` {(x - x'\<^isub>m\<^isub>a\<^isub>x)} \<in> ({\<approx>A `` {y - y'} |y'. y' < y \<and> y' \<in> A\<star>})"} |
|
1355 |
\end{center} |
|
132 | 1356 |
% |
130 | 1357 |
\noindent |
135 | 1358 |
and we know that we have a @{term "y' \<in> A\<star>"} and @{text "y' < y"} |
132 | 1359 |
and also know @{term "(x - x'\<^isub>m\<^isub>a\<^isub>x) \<approx>A (y - y')"}. Unfolding the Myhill-Nerode |
135 | 1360 |
relation we know @{term "(y - y') @ z\<^isub>a \<in> A"}. We also know that @{term "z\<^isub>b \<in> A\<star>"}. |
1361 |
Therefore @{term "y' @ ((y - y') @ z\<^isub>a) @ z\<^isub>b \<in> A\<star>"}, which means |
|
1362 |
@{term "y @ z \<in> A\<star>"}. As the last step we have to set @{text "A"} to @{term "L r"} and |
|
132 | 1363 |
complete the proof.\qed |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1364 |
\end{proof} |
39
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1365 |
*} |
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1366 |
|
a59473f0229d
tuned a little bit the section about finite partitions
urbanc
parents:
37
diff
changeset
|
1367 |
|
117 | 1368 |
|
54 | 1369 |
section {* Conclusion and Related Work *} |
1370 |
||
92 | 1371 |
text {* |
112 | 1372 |
In this paper we took the view that a regular language is one where there |
115 | 1373 |
exists a regular expression that matches all of its strings. Regular |
145 | 1374 |
expressions can conveniently be defined as a datatype in HOL-based theorem |
1375 |
provers. For us it was therefore interesting to find out how far we can push |
|
154 | 1376 |
this point of view. We have established in Isabelle/HOL both directions |
1377 |
of the Myhill-Nerode theorem. |
|
132 | 1378 |
% |
1379 |
\begin{theorem}[The Myhill-Nerode Theorem]\mbox{}\\ |
|
1380 |
A language @{text A} is regular if and only if @{thm (rhs) Myhill_Nerode}. |
|
1381 |
\end{theorem} |
|
1382 |
% |
|
1383 |
\noindent |
|
1384 |
Having formalised this theorem means we |
|
1385 |
pushed our point of view quite far. Using this theorem we can obviously prove when a language |
|
112 | 1386 |
is \emph{not} regular---by establishing that it has infinitely many |
1387 |
equivalence classes generated by the Myhill-Nerode relation (this is usually |
|
1388 |
the purpose of the pumping lemma \cite{Kozen97}). We can also use it to |
|
1389 |
establish the standard textbook results about closure properties of regular |
|
1390 |
languages. Interesting is the case of closure under complement, because |
|
1391 |
it seems difficult to construct a regular expression for the complement |
|
113 | 1392 |
language by direct means. However the existence of such a regular expression |
1393 |
can be easily proved using the Myhill-Nerode theorem since |
|
132 | 1394 |
% |
112 | 1395 |
\begin{center} |
1396 |
@{term "s\<^isub>1 \<approx>A s\<^isub>2"} if and only if @{term "s\<^isub>1 \<approx>(-A) s\<^isub>2"} |
|
1397 |
\end{center} |
|
132 | 1398 |
% |
112 | 1399 |
\noindent |
1400 |
holds for any strings @{text "s\<^isub>1"} and @{text |
|
114 | 1401 |
"s\<^isub>2"}. Therefore @{text A} and the complement language @{term "-A"} give rise to the same |
159 | 1402 |
partitions. Proving the existence of such a regular expression via automata |
1403 |
using the standard method would |
|
114 | 1404 |
be quite involved. It includes the |
112 | 1405 |
steps: regular expression @{text "\<Rightarrow>"} non-deterministic automaton @{text |
1406 |
"\<Rightarrow>"} deterministic automaton @{text "\<Rightarrow>"} complement automaton @{text "\<Rightarrow>"} |
|
1407 |
regular expression. |
|
1408 |
||
116 | 1409 |
While regular expressions are convenient in formalisations, they have some |
122 | 1410 |
limitations. One is that there seems to be no method of calculating a |
123 | 1411 |
minimal regular expression (for example in terms of length) for a regular |
1412 |
language, like there is |
|
1413 |
for automata. On the other hand, efficient regular expression matching, |
|
1414 |
without using automata, poses no problem \cite{OwensReppyTuron09}. |
|
1415 |
For an implementation of a simple regular expression matcher, |
|
122 | 1416 |
whose correctness has been formally established, we refer the reader to |
1417 |
Owens and Slind \cite{OwensSlind08}. |
|
116 | 1418 |
|
1419 |
||
143
1cc87efb3b53
formalisation of first direction is now only 780 loc
urbanc
parents:
142
diff
changeset
|
1420 |
Our formalisation consists of 780 lines of Isabelle/Isar code for the first |
149 | 1421 |
direction and 460 for the second, plus around 300 lines of standard material about |
122 | 1422 |
regular languages. While this might be seen as too large to count as a |
1423 |
concise proof pearl, this should be seen in the context of the work done by |
|
1424 |
Constable at al \cite{Constable00} who formalised the Myhill-Nerode theorem |
|
1425 |
in Nuprl using automata. They write that their four-member team needed |
|
134 | 1426 |
something on the magnitude of 18 months for their formalisation. The |
122 | 1427 |
estimate for our formalisation is that we needed approximately 3 months and |
1428 |
this included the time to find our proof arguments. Unlike Constable et al, |
|
1429 |
who were able to follow the proofs from \cite{HopcroftUllman69}, we had to |
|
1430 |
find our own arguments. So for us the formalisation was not the |
|
1431 |
bottleneck. It is hard to gauge the size of a formalisation in Nurpl, but |
|
1432 |
from what is shown in the Nuprl Math Library about their development it |
|
1433 |
seems substantially larger than ours. The code of ours can be found in the |
|
1434 |
Mercurial Repository at |
|
132 | 1435 |
\mbox{\url{http://www4.in.tum.de/~urbanc/regexp.html}}. |
113 | 1436 |
|
112 | 1437 |
|
1438 |
Our proof of the first direction is very much inspired by \emph{Brzozowski's |
|
134 | 1439 |
algebraic method} used to convert a finite automaton to a regular |
113 | 1440 |
expression \cite{Brzozowski64}. The close connection can be seen by considering the equivalence |
111 | 1441 |
classes as the states of the minimal automaton for the regular language. |
114 | 1442 |
However there are some subtle differences. Since we identify equivalence |
111 | 1443 |
classes with the states of the automaton, then the most natural choice is to |
1444 |
characterise each state with the set of strings starting from the initial |
|
113 | 1445 |
state leading up to that state. Usually, however, the states are characterised as the |
123 | 1446 |
strings starting from that state leading to the terminal states. The first |
1447 |
choice has consequences about how the initial equational system is set up. We have |
|
115 | 1448 |
the $\lambda$-term on our `initial state', while Brzozowski has it on the |
111 | 1449 |
terminal states. This means we also need to reverse the direction of Arden's |
156 | 1450 |
Lemma. |
92 | 1451 |
|
112 | 1452 |
We briefly considered using the method Brzozowski presented in the Appendix |
113 | 1453 |
of~\cite{Brzozowski64} in order to prove the second direction of the |
112 | 1454 |
Myhill-Nerode theorem. There he calculates the derivatives for regular |
159 | 1455 |
expressions and shows that for every language there can be only |
1456 |
finitely many of them %derivations |
|
1457 |
(if regarded equal modulo ACI). We could |
|
1458 |
have used as tagging-function the set of derivatives of a regular expression |
|
1459 |
with respect to a language. Using the fact that two strings are |
|
123 | 1460 |
Myhill-Nerode related whenever their derivative is the same, together with |
156 | 1461 |
the fact that there are only finitely such derivatives |
1462 |
would give us a similar argument as ours. However it seems not so easy to |
|
159 | 1463 |
calculate the set of derivatives modulo ACI. Therefore we preferred our |
123 | 1464 |
direct method of using tagging-functions. This |
112 | 1465 |
is also where our method shines, because we can completely side-step the |
1466 |
standard argument \cite{Kozen97} where automata need to be composed, which |
|
159 | 1467 |
as stated in the Introduction is not so easy to formalise in a |
121
1cf12a107b03
added directory with the small files and numbers of lines
urbanc
parents:
120
diff
changeset
|
1468 |
HOL-based theorem prover. However, it is also the direction where we had to |
123 | 1469 |
spend most of the `conceptual' time, as our proof-argument based on tagging-functions |
1470 |
is new for establishing the Myhill-Nerode theorem. All standard proofs |
|
159 | 1471 |
of this direction use %proceed by |
1472 |
arguments over automata.\\[-6mm]%\medskip |
|
1473 |
% |
|
1474 |
%\noindent |
|
1475 |
%{\bf Acknowledgements:} We are grateful for the comments we received from Larry |
|
1476 |
%Paulson and the referees of the paper. |
|
111 | 1477 |
|
92 | 1478 |
*} |
1479 |
||
1480 |
||
24 | 1481 |
(*<*) |
1482 |
end |
|
1483 |
(*>*) |