353 \end{tabular} |
353 \end{tabular} |
354 \end{tabular} |
354 \end{tabular} |
355 \end{center} |
355 \end{center} |
356 |
356 |
357 Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating |
357 Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating |
358 a regular expression that matches all languages of @{text rs}. We only need to know the existence |
358 a regular expression that matches the union of all languages of @{text rs}. We only need to know the |
|
359 existence |
359 of such a regular expression and therefore we use Isabelle/HOL's @{const "fold_graph"} and Hilbert's |
360 of such a regular expression and therefore we use Isabelle/HOL's @{const "fold_graph"} and Hilbert's |
360 @{text "\<epsilon>"} to define @{term "\<Uplus>rs"}. This operation, roughly speaking, folds @{const ALT} over the |
361 @{text "\<epsilon>"} to define @{term "\<Uplus>rs"}. This operation, roughly speaking, folds @{const ALT} over the |
361 set @{text rs} with @{const NULL} for the empty set. We can prove that for a finite set @{text rs} |
362 set @{text rs} with @{const NULL} for the empty set. We can prove that for a finite set @{text rs} |
362 % |
363 % |
363 \begin{equation}\label{uplus} |
364 \begin{equation}\label{uplus} |
367 \noindent |
368 \noindent |
368 holds, whereby @{text "\<calL> ` rs"} stands for the |
369 holds, whereby @{text "\<calL> ` rs"} stands for the |
369 image of the set @{text rs} under function @{text "\<calL>"}. |
370 image of the set @{text rs} under function @{text "\<calL>"}. |
370 *} |
371 *} |
371 |
372 |
372 section {* The Myhill-Nerode Theorem, First Part *} |
373 |
|
374 section {* The Myhill-Nerode Theorem *} |
373 |
375 |
374 text {* |
376 text {* |
375 The key definition in the Myhill-Nerode theorem is the |
377 The key definition in the Myhill-Nerode theorem is the |
376 \emph{Myhill-Nerode relation}, which states that w.r.t.~a language two |
378 \emph{Myhill-Nerode relation}, which states that w.r.t.~a language two |
377 strings are related, provided there is no distinguishing extension in this |
379 strings are related, provided there is no distinguishing extension in this |
414 \begin{equation} |
416 \begin{equation} |
415 @{thm finals_def} |
417 @{thm finals_def} |
416 \end{equation} |
418 \end{equation} |
417 |
419 |
418 \noindent |
420 \noindent |
419 In our running example, @{text "X\<^isub>2"} is the only equivalence class in @{term "finals {[c]}"}. |
421 In our running example, @{text "X\<^isub>2"} is the only |
|
422 equivalence class in @{term "finals {[c]}"}. |
420 It is straightforward to show that in general @{thm lang_is_union_of_finals} and |
423 It is straightforward to show that in general @{thm lang_is_union_of_finals} and |
421 @{thm finals_in_partitions} hold. |
424 @{thm finals_in_partitions} hold. |
422 Therefore if we know that there exists a regular expression for every |
425 Therefore if we know that there exists a regular expression for every |
423 equivalence class in \mbox{@{term "finals A"}} (which by assumption must be |
426 equivalence class in \mbox{@{term "finals A"}} (which by assumption must be |
424 a finite set), then we can use @{text "\<bigplus>"} to obtain a regular expression |
427 a finite set), then we can use @{text "\<bigplus>"} to obtain a regular expression |
755 and distinctness (we proved soundness for @{const Arden} in Lem.~\ref{ardenable}). |
758 and distinctness (we proved soundness for @{const Arden} in Lem.~\ref{ardenable}). |
756 The property ardenable is clearly preserved because the append-operation |
759 The property ardenable is clearly preserved because the append-operation |
757 cannot make a regular expression to match the empty string. Validity is |
760 cannot make a regular expression to match the empty string. Validity is |
758 given because @{const Arden} removes an equivalence class from @{text yrhs} |
761 given because @{const Arden} removes an equivalence class from @{text yrhs} |
759 and then @{const Subst_all} removes @{text Y} from the equational system. |
762 and then @{const Subst_all} removes @{text Y} from the equational system. |
760 Having proved the implication above, we can replace @{text "ES"} with @{text "ES - {(Y, yrhs)}"} |
763 Having proved the implication above, we can instantiate @{text "ES"} with @{text "ES - {(Y, yrhs)}"} |
761 which matches with our proof-obligation of @{const "Subst_all"}. Since |
764 which matches with our proof-obligation of @{const "Subst_all"}. Since |
762 \mbox{@{term "ES = ES - {(Y, yrhs)} \<union> {(Y, yrhs)}"}}, we can use our assumption |
765 \mbox{@{term "ES = ES - {(Y, yrhs)} \<union> {(Y, yrhs)}"}}, we can use the assumption |
763 to complete the proof.\qed |
766 to complete the proof.\qed |
764 \end{proof} |
767 \end{proof} |
765 |
768 |
766 \noindent |
769 \noindent |
767 We also need the fact that @{text Iter} decreases the termination measure. |
770 We also need the fact that @{text Iter} decreases the termination measure. |
986 showing |
989 showing |
987 % |
990 % |
988 \begin{center} |
991 \begin{center} |
989 @{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"} |
992 @{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"} |
990 \end{center} |
993 \end{center} |
991 |
994 % |
992 \noindent |
995 \noindent |
993 which by unfolding the Myhill-Nerode relation is identical to |
996 which by unfolding the Myhill-Nerode relation is identical to |
994 % |
997 % |
995 \begin{equation}\label{pattern} |
998 \begin{equation}\label{pattern} |
996 @{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"} |
999 @{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"} |
997 \end{equation} |
1000 \end{equation} |
998 |
1001 % |
999 \noindent |
1002 \noindent |
1000 since both @{text "=tag\<^isub>A\<^isub>L\<^isub>T A B="} and @{term "\<approx>(A \<union> B)"} are symmetric. To solve |
1003 since both @{text "=tag\<^isub>A\<^isub>L\<^isub>T A B="} and @{term "\<approx>(A \<union> B)"} are symmetric. To solve |
1001 \eqref{pattern} we just have to unfold the definition of the tagging-relation and analyse |
1004 \eqref{pattern} we just have to unfold the definition of the tagging-relation and analyse |
1002 in which set, @{text A} or @{text B}, the string @{term "x @ z"} is. |
1005 in which set, @{text A} or @{text B}, the string @{term "x @ z"} is. |
1003 The definition of the tagging-function will give us in each case the |
1006 The definition of the tagging-function will give us in each case the |
1009 |
1012 |
1010 \noindent |
1013 \noindent |
1011 The pattern in \eqref{pattern} is repeated for the other two cases. Unfortunately, |
1014 The pattern in \eqref{pattern} is repeated for the other two cases. Unfortunately, |
1012 they are slightly more complicated. In the @{const SEQ}-case we essentially have |
1015 they are slightly more complicated. In the @{const SEQ}-case we essentially have |
1013 to be able to infer that |
1016 to be able to infer that |
1014 |
1017 % |
1015 \begin{center} |
1018 \begin{center} |
1016 @{term "x @ z \<in> A ;; B \<longrightarrow> y @ z \<in> A ;; B"} |
1019 @{term "x @ z \<in> A ;; B \<longrightarrow> y @ z \<in> A ;; B"} |
1017 \end{center} |
1020 \end{center} |
1018 |
1021 % |
1019 \noindent |
1022 \noindent |
1020 using the information given by the appropriate tagging function. The complication |
1023 using the information given by the appropriate tagging function. The complication |
1021 is to find out what the possible splits of @{text "x @ z"} are to be in @{term "A ;; B"} |
1024 is to find out what the possible splits of @{text "x @ z"} are to be in @{term "A ;; B"} |
1022 (this was easy in case of @{term "A \<union> B"}). For this we define the |
1025 (this was easy in case of @{term "A \<union> B"}). For this we define the |
1023 notions of \emph{string prefixes} |
1026 notions of \emph{string prefixes} |
1024 |
1027 % |
1025 \begin{center} |
1028 \begin{center} |
1026 @{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\hspace{10mm} |
1029 @{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\hspace{10mm} |
1027 @{text "x < y \<equiv> x \<le> y \<and> x \<noteq> y"} |
1030 @{text "x < y \<equiv> x \<le> y \<and> x \<noteq> y"} |
1028 \end{center} |
1031 \end{center} |
1029 |
1032 % |
1030 \noindent |
1033 \noindent |
1031 and \emph{string subtraction}: |
1034 and \emph{string subtraction}: |
1032 |
1035 % |
1033 \begin{center} |
1036 \begin{center} |
1034 \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
1037 \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
1035 @{text "[] - y"} & @{text "\<equiv>"} & @{text "[]"}\\ |
1038 @{text "[] - y"} & @{text "\<equiv>"} & @{text "[]"}\\ |
1036 @{text "x - []"} & @{text "\<equiv>"} & @{text x}\\ |
1039 @{text "x - []"} & @{text "\<equiv>"} & @{text x}\\ |
1037 @{text "cx - dy"} & @{text "\<equiv>"} & @{text "if c = d then x - y else cx"}\\ |
1040 @{text "cx - dy"} & @{text "\<equiv>"} & @{text "if c = d then x - y else cx"}\\ |
1038 \end{tabular} |
1041 \end{tabular} |
1039 \end{center} |
1042 \end{center} |
1040 |
1043 % |
1041 \noindent |
1044 \noindent |
1042 where @{text c} and @{text d} are characters, and @{text x} and @{text y} are strings. |
1045 where @{text c} and @{text d} are characters, and @{text x} and @{text y} are strings. |
|
1046 |
1043 Now assuming @{term "x @ z \<in> A ;; B"} there are only two possible ways of how to `split' |
1047 Now assuming @{term "x @ z \<in> A ;; B"} there are only two possible ways of how to `split' |
1044 this string to be in @{term "A ;; B"}: |
1048 this string to be in @{term "A ;; B"}: |
1045 |
1049 % |
1046 \begin{center} |
1050 \begin{center} |
1047 \scalebox{0.7}{ |
1051 \scalebox{0.7}{ |
1048 \begin{tikzpicture} |
1052 \begin{tikzpicture} |
1049 \node[draw,minimum height=3.8ex] (xa) { $\hspace{4em}@{text "x'"}\hspace{4em}$ }; |
1053 \node[draw,minimum height=3.8ex] (xa) { $\hspace{4em}@{text "x'"}\hspace{4em}$ }; |
1050 \node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.5em}@{text "x - x'"}\hspace{0.5em}$ }; |
1054 \node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.5em}@{text "x - x'"}\hspace{0.5em}$ }; |
1096 \draw[decoration={brace,transform={yscale=3}},decorate] |
1100 \draw[decoration={brace,transform={yscale=3}},decorate] |
1097 ($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$) |
1101 ($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$) |
1098 node[midway, below=0.5em]{@{text "(z - z') \<in> B"}}; |
1102 node[midway, below=0.5em]{@{text "(z - z') \<in> B"}}; |
1099 \end{tikzpicture}} |
1103 \end{tikzpicture}} |
1100 \end{center} |
1104 \end{center} |
1101 |
1105 % |
1102 \noindent |
1106 \noindent |
1103 Either there is a prefix of @{text x} in @{text A} and the rest in @{text B}, |
1107 Either there is a prefix of @{text x} in @{text A} and the rest in @{text B}, |
1104 or @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B}. |
1108 or @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B}. |
1105 In both cases we have to show that @{term "y @ z \<in> A ;; B"}. For this we use the |
1109 In both cases we have to show that @{term "y @ z \<in> A ;; B"}. For this we use the |
1106 following tagging-function |
1110 following tagging-function |
1107 |
1111 % |
1108 \begin{center} |
1112 \begin{center} |
1109 @{thm tag_str_SEQ_def[where ?L1.0="A" and ?L2.0="B", THEN meta_eq_app]} |
1113 @{thm tag_str_SEQ_def[where ?L1.0="A" and ?L2.0="B", THEN meta_eq_app]} |
1110 \end{center} |
1114 \end{center} |
1111 |
1115 |
1112 \noindent |
1116 \noindent |
1113 with the idea that in the first split we have to make sure that @{text "x - x'"} |
1117 with the idea that in the first split we have to make sure that @{text "(x - x') @ z"} |
1114 is in the language @{text B}. |
1118 is in the language @{text B}. |
1115 |
1119 |
1116 \begin{proof}[@{const SEQ}-Case] |
1120 \begin{proof}[@{const SEQ}-Case] |
1117 If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
1121 If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
1118 then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of |
1122 then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of |
1119 @{term "tag_str_SEQ A B"} is a subset of this product set, and therefore finite. |
1123 @{term "tag_str_SEQ A B"} is a subset of this product set, and therefore finite. |
1120 We have to show injectivity of this tagging-function as |
1124 We have to show injectivity of this tagging-function as |
1121 |
1125 % |
1122 \begin{center} |
1126 \begin{center} |
1123 @{term "\<forall>z. tag_str_SEQ A B x = tag_str_SEQ A B y \<and> x @ z \<in> A ;; B \<longrightarrow> y @ z \<in> A ;; B"} |
1127 @{term "\<forall>z. tag_str_SEQ A B x = tag_str_SEQ A B y \<and> x @ z \<in> A ;; B \<longrightarrow> y @ z \<in> A ;; B"} |
1124 \end{center} |
1128 \end{center} |
1125 |
1129 % |
1126 \noindent |
1130 \noindent |
1127 There are two cases to be considered (see pictures above). First, there exists |
1131 There are two cases to be considered (see pictures above). First, there exists |
1128 a @{text "x'"} such that |
1132 a @{text "x'"} such that |
1129 @{text "x' \<in> A"}, @{text "x' \<le> x"} and @{text "(x - x') @ z \<in> B"} hold. We therefore have |
1133 @{text "x' \<in> A"}, @{text "x' \<le> x"} and @{text "(x - x') @ z \<in> B"} hold. We therefore have |
1130 |
1134 % |
1131 \begin{center} |
1135 \begin{center} |
1132 @{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {x - x'} |x'. x' \<le> x \<and> x' \<in> A})"} |
1136 @{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {x - x'} |x'. x' \<le> x \<and> x' \<in> A})"} |
1133 \end{center} |
1137 \end{center} |
1134 |
1138 % |
1135 \noindent |
1139 \noindent |
1136 and by the assumption about @{term "tag_str_SEQ A B"} also |
1140 and by the assumption about @{term "tag_str_SEQ A B"} also |
1137 |
1141 % |
1138 \begin{center} |
1142 \begin{center} |
1139 @{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {y - y'} |y'. y' \<le> y \<and> y' \<in> A})"} |
1143 @{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {y - y'} |y'. y' \<le> y \<and> y' \<in> A})"} |
1140 \end{center} |
1144 \end{center} |
1141 |
1145 % |
1142 \noindent |
1146 \noindent |
1143 That means there must be a @{text "y'"} such that @{text "y' \<in> A"} and |
1147 That means there must be a @{text "y'"} such that @{text "y' \<in> A"} and |
1144 @{term "\<approx>B `` {x - x'} = \<approx>B `` {y - y'}"}. This equality means that |
1148 @{term "\<approx>B `` {x - x'} = \<approx>B `` {y - y'}"}. This equality means that |
1145 @{term "(x - x') \<approx>B (y - y')"} holds. Unfolding the Myhill-Nerode |
1149 @{term "(x - x') \<approx>B (y - y')"} holds. Unfolding the Myhill-Nerode |
1146 relation and together with the fact that @{text "(x - x') @ z \<in> B"}, we |
1150 relation and together with the fact that @{text "(x - x') @ z \<in> B"}, we |
1158 \noindent |
1162 \noindent |
1159 The case for @{const STAR} is similar as @{const SEQ}, but poses a few extra challenges. When |
1163 The case for @{const STAR} is similar as @{const SEQ}, but poses a few extra challenges. When |
1160 we analyse the case that @{text "x @ z"} is an element in @{text "A\<star>"} and @{text x} is not the |
1164 we analyse the case that @{text "x @ z"} is an element in @{text "A\<star>"} and @{text x} is not the |
1161 empty string, we |
1165 empty string, we |
1162 have the following picture: |
1166 have the following picture: |
1163 |
1167 % |
1164 \begin{center} |
1168 \begin{center} |
1165 \scalebox{0.7}{ |
1169 \scalebox{0.7}{ |
1166 \begin{tikzpicture} |
1170 \begin{tikzpicture} |
1167 \node[draw,minimum height=3.8ex] (xa) { $\hspace{4em}@{text "x'\<^isub>m\<^isub>a\<^isub>x"}\hspace{4em}$ }; |
1171 \node[draw,minimum height=3.8ex] (xa) { $\hspace{4em}@{text "x'\<^isub>m\<^isub>a\<^isub>x"}\hspace{4em}$ }; |
1168 \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}$ }; |
1172 \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}$ }; |
1196 \draw[decoration={brace,transform={yscale=3}},decorate] |
1200 \draw[decoration={brace,transform={yscale=3}},decorate] |
1197 ($(zb.south east)+(0em,-4ex)$) -- ($(xxa.south west)+(0em,-4ex)$) |
1201 ($(zb.south east)+(0em,-4ex)$) -- ($(xxa.south west)+(0em,-4ex)$) |
1198 node[midway, below=0.5em]{@{text "(x - x'\<^isub>m\<^isub>a\<^isub>x) @ z \<in> A\<star>"}}; |
1202 node[midway, below=0.5em]{@{text "(x - x'\<^isub>m\<^isub>a\<^isub>x) @ z \<in> A\<star>"}}; |
1199 \end{tikzpicture}} |
1203 \end{tikzpicture}} |
1200 \end{center} |
1204 \end{center} |
1201 |
1205 % |
1202 \noindent |
1206 \noindent |
1203 We can find a strict prefix @{text "x'"} of @{text x} such that @{text "x' \<in> A\<star>"}, |
1207 We can find a strict prefix @{text "x'"} of @{text x} such that @{text "x' \<in> A\<star>"}, |
1204 @{text "x' < x"} and the rest @{text "(x - x') @ z \<in> A\<star>"}. For example the empty string |
1208 @{text "x' < x"} and the rest @{text "(x - x') @ z \<in> A\<star>"}. For example the empty string |
1205 @{text "[]"} would do. |
1209 @{text "[]"} would do. |
1206 There are many such prefixes, but there can only be finitely many of them (the |
1210 There are many such prefixes, but there can only be finitely many of them (the |
1216 such that we have a string @{text a} with @{text "a \<in> A"} that lies just on the |
1220 such that we have a string @{text a} with @{text "a \<in> A"} that lies just on the |
1217 `border' of @{text x} and @{text z}. This string is @{text "(x - x') @ z\<^isub>a"}. |
1221 `border' of @{text x} and @{text z}. This string is @{text "(x - x') @ z\<^isub>a"}. |
1218 |
1222 |
1219 In order to show that @{text "x @ z \<in> A\<star>"} implies @{text "y @ z \<in> A\<star>"}, we use |
1223 In order to show that @{text "x @ z \<in> A\<star>"} implies @{text "y @ z \<in> A\<star>"}, we use |
1220 the following tagging-function: |
1224 the following tagging-function: |
1221 |
1225 % |
1222 \begin{center} |
1226 \begin{center} |
1223 @{thm tag_str_STAR_def[where ?L1.0="A", THEN meta_eq_app]} |
1227 @{thm tag_str_STAR_def[where ?L1.0="A", THEN meta_eq_app]}\smallskip |
1224 \end{center} |
1228 \end{center} |
1225 |
1229 |
1226 \begin{proof}[@{const STAR}-Case] |
1230 \begin{proof}[@{const STAR}-Case] |
1227 If @{term "finite (UNIV // \<approx>A)"} |
1231 If @{term "finite (UNIV // \<approx>A)"} |
1228 then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
1232 then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
1229 @{term "tag_str_STAR A"} is a subset of this set, and therefore finite. |
1233 @{term "tag_str_STAR A"} is a subset of this set, and therefore finite. |
1230 Again we have to show injectivity of this tagging-function as |
1234 Again we have to show injectivity of this tagging-function as |
1231 |
1235 % |
1232 \begin{center} |
1236 \begin{center} |
1233 @{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>"} |
1237 @{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>"} |
1234 \end{center} |
1238 \end{center} |
1235 |
1239 % |
1236 \noindent |
1240 \noindent |
1237 We first need to consider the case that @{text x} is the empty string. |
1241 We first need to consider the case that @{text x} is the empty string. |
1238 From the assumption we can infer @{text y} is the empty string and |
1242 From the assumption we can infer @{text y} is the empty string and |
1239 clearly have @{text "y @ z \<in> A\<star>"}. In case @{text x} is not the empty |
1243 clearly have @{text "y @ z \<in> A\<star>"}. In case @{text x} is not the empty |
1240 string, we can devide the string @{text "x @ z"} as shown in the picture |
1244 string, we can devide the string @{text "x @ z"} as shown in the picture |
1241 above. By the tagging function we have |
1245 above. By the tagging function we have |
1242 |
1246 % |
1243 \begin{center} |
1247 \begin{center} |
1244 @{term "\<approx>A `` {(x - x'\<^isub>m\<^isub>a\<^isub>x)} \<in> ({\<approx>A `` {x - x'} |x'. x' < x \<and> x' \<in> A\<star>})"} |
1248 @{term "\<approx>A `` {(x - x'\<^isub>m\<^isub>a\<^isub>x)} \<in> ({\<approx>A `` {x - x'} |x'. x' < x \<and> x' \<in> A\<star>})"} |
1245 \end{center} |
1249 \end{center} |
1246 |
1250 % |
1247 \noindent |
1251 \noindent |
1248 which by assumption is equal to |
1252 which by assumption is equal to |
1249 |
1253 % |
1250 \begin{center} |
1254 \begin{center} |
1251 @{term "\<approx>A `` {(x - x'\<^isub>m\<^isub>a\<^isub>x)} \<in> ({\<approx>A `` {y - y'} |y'. y' < y \<and> y' \<in> A\<star>})"} |
1255 @{term "\<approx>A `` {(x - x'\<^isub>m\<^isub>a\<^isub>x)} \<in> ({\<approx>A `` {y - y'} |y'. y' < y \<and> y' \<in> A\<star>})"} |
1252 \end{center} |
1256 \end{center} |
1253 |
1257 % |
1254 \noindent |
1258 \noindent |
1255 and we know that we have a @{text "y'\<^isub>m\<^isub>a\<^isub>x \<in> A\<star>"} and @{text "y'\<^isub>m\<^isub>a\<^isub>x < y"} |
1259 and we know that we have a @{text "y' \<in> A\<star>"} and @{text "y' < y"} |
1256 and also know @{term "(x - x'\<^isub>m\<^isub>a\<^isub>x) \<approx>A (y - y'\<^isub>m\<^isub>a\<^isub>x)"}. Unfolding the Myhill-Nerode |
1260 and also know @{term "(x - x'\<^isub>m\<^isub>a\<^isub>x) \<approx>A (y - y')"}. Unfolding the Myhill-Nerode |
1257 relation we know @{term "(y - y'\<^isub>m\<^isub>a\<^isub>x) @ z\<^isub>a \<in> A"}. We also know that @{text "z\<^isub>b \<in> A\<star>"}. |
1261 relation we know @{term "(y - y') @ z\<^isub>a \<in> A"}. We also know that @{text "z\<^isub>b \<in> A\<star>"}. |
1258 Therefore, finally, @{text "y'\<^isub>m\<^isub>a\<^isub>x @ ((y - y'\<^isub>m\<^isub>a\<^isub>x) @ z\<^isub>a) @ z\<^isub>b \<in> A\<star>"}, which means |
1262 Therefore, finally, @{text "y' @ ((y - y') @ z\<^isub>a) @ z\<^isub>b \<in> A\<star>"}, which means |
1259 @{term "y @ z \<in> A\<star>"}. As a last step we have to set @{text "A"} to @{text "L r"} and |
1263 @{term "y @ z \<in> A\<star>"}. As the last step we have to set @{text "A"} to @{text "L r"} and |
1260 complete the proof. |
1264 complete the proof.\qed |
1261 \end{proof} |
1265 \end{proof} |
1262 *} |
1266 *} |
1263 |
1267 |
1264 |
1268 |
1265 |
1269 |
1268 text {* |
1272 text {* |
1269 In this paper we took the view that a regular language is one where there |
1273 In this paper we took the view that a regular language is one where there |
1270 exists a regular expression that matches all of its strings. Regular |
1274 exists a regular expression that matches all of its strings. Regular |
1271 expressions can conveniently be defined as a datatype in a HOL-based theorem |
1275 expressions can conveniently be defined as a datatype in a HOL-based theorem |
1272 prover. For us it was therefore interesting to find out how far we can push |
1276 prover. For us it was therefore interesting to find out how far we can push |
1273 this point of view. |
1277 this point of view. We have establised both directions of the Myhill-Nerode |
1274 |
1278 theorem. |
1275 Having formalised the Myhill-Nerode theorem means we |
1279 % |
1276 pushed quite far. Using this theorem we can obviously prove when a language |
1280 \begin{theorem}[The Myhill-Nerode Theorem]\mbox{}\\ |
|
1281 A language @{text A} is regular if and only if @{thm (rhs) Myhill_Nerode}. |
|
1282 \end{theorem} |
|
1283 % |
|
1284 \noindent |
|
1285 Having formalised this theorem means we |
|
1286 pushed our point of view quite far. Using this theorem we can obviously prove when a language |
1277 is \emph{not} regular---by establishing that it has infinitely many |
1287 is \emph{not} regular---by establishing that it has infinitely many |
1278 equivalence classes generated by the Myhill-Nerode relation (this is usually |
1288 equivalence classes generated by the Myhill-Nerode relation (this is usually |
1279 the purpose of the pumping lemma \cite{Kozen97}). We can also use it to |
1289 the purpose of the pumping lemma \cite{Kozen97}). We can also use it to |
1280 establish the standard textbook results about closure properties of regular |
1290 establish the standard textbook results about closure properties of regular |
1281 languages. Interesting is the case of closure under complement, because |
1291 languages. Interesting is the case of closure under complement, because |
1282 it seems difficult to construct a regular expression for the complement |
1292 it seems difficult to construct a regular expression for the complement |
1283 language by direct means. However the existence of such a regular expression |
1293 language by direct means. However the existence of such a regular expression |
1284 can be easily proved using the Myhill-Nerode theorem since |
1294 can be easily proved using the Myhill-Nerode theorem since |
1285 |
1295 % |
1286 \begin{center} |
1296 \begin{center} |
1287 @{term "s\<^isub>1 \<approx>A s\<^isub>2"} if and only if @{term "s\<^isub>1 \<approx>(-A) s\<^isub>2"} |
1297 @{term "s\<^isub>1 \<approx>A s\<^isub>2"} if and only if @{term "s\<^isub>1 \<approx>(-A) s\<^isub>2"} |
1288 \end{center} |
1298 \end{center} |
1289 |
1299 % |
1290 \noindent |
1300 \noindent |
1291 holds for any strings @{text "s\<^isub>1"} and @{text |
1301 holds for any strings @{text "s\<^isub>1"} and @{text |
1292 "s\<^isub>2"}. Therefore @{text A} and the complement language @{term "-A"} give rise to the same |
1302 "s\<^isub>2"}. Therefore @{text A} and the complement language @{term "-A"} give rise to the same |
1293 partitions. Proving the existence of such a regular expression via automata would |
1303 partitions. Proving the existence of such a regular expression via automata would |
1294 be quite involved. It includes the |
1304 be quite involved. It includes the |
1320 find our own arguments. So for us the formalisation was not the |
1330 find our own arguments. So for us the formalisation was not the |
1321 bottleneck. It is hard to gauge the size of a formalisation in Nurpl, but |
1331 bottleneck. It is hard to gauge the size of a formalisation in Nurpl, but |
1322 from what is shown in the Nuprl Math Library about their development it |
1332 from what is shown in the Nuprl Math Library about their development it |
1323 seems substantially larger than ours. The code of ours can be found in the |
1333 seems substantially larger than ours. The code of ours can be found in the |
1324 Mercurial Repository at |
1334 Mercurial Repository at |
1325 |
1335 \mbox{\url{http://www4.in.tum.de/~urbanc/regexp.html}}. |
1326 \begin{center} |
|
1327 \url{http://www4.in.tum.de/~urbanc/regexp.html} |
|
1328 \end{center} |
|
1329 |
1336 |
1330 |
1337 |
1331 Our proof of the first direction is very much inspired by \emph{Brzozowski's |
1338 Our proof of the first direction is very much inspired by \emph{Brzozowski's |
1332 algebraic mehod} used to convert a finite automaton to a regular |
1339 algebraic mehod} used to convert a finite automaton to a regular |
1333 expression \cite{Brzozowski64}. The close connection can be seen by considering the equivalence |
1340 expression \cite{Brzozowski64}. The close connection can be seen by considering the equivalence |