Journal/Paper.thy
changeset 181 97090fc7aa9f
parent 180 b755090d0f3d
child 182 560712a29a36
equal deleted inserted replaced
180:b755090d0f3d 181:97090fc7aa9f
    37 abbreviation "TIMESS \<equiv> Times_set"
    37 abbreviation "TIMESS \<equiv> Times_set"
    38 abbreviation "STAR \<equiv> Star"
    38 abbreviation "STAR \<equiv> Star"
    39 
    39 
    40 
    40 
    41 notation (latex output)
    41 notation (latex output)
    42   str_eq_rel ("\<approx>\<^bsub>_\<^esub>") and
    42   str_eq ("\<approx>\<^bsub>_\<^esub>") and
    43   str_eq ("_ \<approx>\<^bsub>_\<^esub> _") and
    43   str_eq_applied ("_ \<approx>\<^bsub>_\<^esub> _") and
    44   conc (infixr "\<cdot>" 100) and
    44   conc (infixr "\<cdot>" 100) and
    45   star ("_\<^bsup>\<star>\<^esup>") and
    45   star ("_\<^bsup>\<star>\<^esup>") and
    46   pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and
    46   pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and
    47   Suc ("_+1" [100] 100) and
    47   Suc ("_+1" [100] 100) and
    48   quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and
    48   quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and
    57   Setalt ("\<^raw:\ensuremath{\bigplus}>_" [1000] 999) and
    57   Setalt ("\<^raw:\ensuremath{\bigplus}>_" [1000] 999) and
    58   Append_rexp2 ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 100) and
    58   Append_rexp2 ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 100) and
    59   Append_rexp_rhs ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 50) and
    59   Append_rexp_rhs ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 50) and
    60   
    60   
    61   uminus ("\<^raw:\ensuremath{\overline{>_\<^raw:}}>" [100] 100) and
    61   uminus ("\<^raw:\ensuremath{\overline{>_\<^raw:}}>" [100] 100) and
    62   tag_str_Plus ("tag\<^bsub>PLUS\<^esub> _ _" [100, 100] 100) and
    62   tag_Plus ("tag\<^bsub>PLUS\<^esub> _ _" [100, 100] 100) and
    63   tag_str_Plus ("tag\<^bsub>PLUS\<^esub> _ _ _" [100, 100, 100] 100) and
    63   tag_Plus ("tag\<^bsub>PLUS\<^esub> _ _ _" [100, 100, 100] 100) and
    64   tag_str_Times ("tag\<^isub>S\<^isub>E\<^isub>Q _ _" [100, 100] 100) and
    64   tag_Times ("tag\<^isub>S\<^isub>E\<^isub>Q _ _" [100, 100] 100) and
    65   tag_str_Times ("tag\<^isub>S\<^isub>E\<^isub>Q _ _ _" [100, 100, 100] 100) and
    65   tag_Times ("tag\<^isub>S\<^isub>E\<^isub>Q _ _ _" [100, 100, 100] 100) and
    66   tag_str_Star ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _" [100] 100) and
    66   tag_Star ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _" [100] 100) and
    67   tag_str_Star ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _ _" [100, 100] 100) and
    67   tag_Star ("tag\<^isub>S\<^isub>T\<^isub>A\<^isub>R _ _" [100, 100] 100) and
    68   tag_eq_rel ("\<^raw:$\threesim$>\<^bsub>_\<^esub>") and
    68   tag_eq ("\<^raw:$\threesim$>\<^bsub>_\<^esub>") and
    69   Delta ("\<Delta>'(_')") and
    69   Delta ("\<Delta>'(_')") and
    70   nullable ("\<delta>'(_')") and
    70   nullable ("\<delta>'(_')") and
    71   Cons ("_ :: _" [100, 100] 100)
    71   Cons ("_ :: _" [100, 100] 100)
    72 
    72 
    73 lemma meta_eq_app:
    73 lemma meta_eq_app:
    74   shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x"
    74   shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x"
    75   by auto
    75   by auto
       
    76 
       
    77 lemma str_eq_def':
       
    78   shows "x \<approx>A y \<equiv> (\<forall>z. x @ z \<in> A \<longleftrightarrow> y @ z \<in> A)"
       
    79 unfolding str_eq_def by simp
    76 
    80 
    77 lemma conc_def':
    81 lemma conc_def':
    78   "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}"
    82   "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}"
    79 unfolding conc_def by simp
    83 unfolding conc_def by simp
    80 
    84 
   172   connecting the accepting states of $A_1$ to the initial state of $A_2$:
   176   connecting the accepting states of $A_1$ to the initial state of $A_2$:
   173   %  
   177   %  
   174 
   178 
   175   \begin{center}
   179   \begin{center}
   176   \begin{tabular}{ccc}
   180   \begin{tabular}{ccc}
   177   \begin{tikzpicture}[scale=0.9]
   181   \begin{tikzpicture}[scale=1]
   178   %\draw[step=2mm] (-1,-1) grid (1,1);
   182   %\draw[step=2mm] (-1,-1) grid (1,1);
   179   
   183   
   180   \draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3);
   184   \draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3);
   181   \draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3);
   185   \draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3);
   182 
   186 
   188 
   192 
   189   \node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
   193   \node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
   190   \node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
   194   \node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
   191   \node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
   195   \node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
   192 
   196 
   193   \draw (-0.6,0.0) node {\footnotesize$A_1$};
   197   \draw (-0.6,0.0) node {\small$A_1$};
   194   \draw ( 0.6,0.0) node {\footnotesize$A_2$};
   198   \draw ( 0.6,0.0) node {\small$A_2$};
   195   \end{tikzpicture}
   199   \end{tikzpicture}
   196 
   200 
   197   & 
   201   & 
   198 
   202 
   199   \raisebox{1.1mm}{\bf\Large$\;\;\;\Rightarrow\,\;\;$}
   203   \raisebox{1.1mm}{\bf\Large$\;\;\;\Rightarrow\,\;\;$}
   200 
   204 
   201   &
   205   &
   202 
   206 
   203   \begin{tikzpicture}[scale=0.9]
   207   \begin{tikzpicture}[scale=1]
   204   %\draw[step=2mm] (-1,-1) grid (1,1);
   208   %\draw[step=2mm] (-1,-1) grid (1,1);
   205   
   209   
   206   \draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3);
   210   \draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3);
   207   \draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3);
   211   \draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3);
   208 
   212 
   217   \node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
   221   \node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
   218   
   222   
   219   \draw (C) to [very thick, bend left=45] (B);
   223   \draw (C) to [very thick, bend left=45] (B);
   220   \draw (D) to [very thick, bend right=45] (B);
   224   \draw (D) to [very thick, bend right=45] (B);
   221 
   225 
   222   \draw (-0.6,0.0) node {\footnotesize$A_1$};
   226   \draw (-0.6,0.0) node {\small$A_1$};
   223   \draw ( 0.6,0.0) node {\footnotesize$A_2$};
   227   \draw ( 0.6,0.0) node {\small$A_2$};
   224   \end{tikzpicture}
   228   \end{tikzpicture}
   225 
   229 
   226   \end{tabular}
   230   \end{tabular}
   227   \end{center}
   231   \end{center}
   228 
   232 
   298 
   302 
   299   Also one might consider automata theory as a well-worn stock subject where
   303   Also one might consider automata theory as a well-worn stock subject where
   300   everything is crystal clear. However, paper proofs about automata often
   304   everything is crystal clear. However, paper proofs about automata often
   301   involve subtle side-conditions which are easily overlooked, but which make
   305   involve subtle side-conditions which are easily overlooked, but which make
   302   formal reasoning rather painful. For example Kozen's proof of the
   306   formal reasoning rather painful. For example Kozen's proof of the
   303   Myhill-Nerode theorem requires that the automata do not have inaccessible
   307   Myhill-Nerode theorem requires that automata do not have inaccessible
   304   states \cite{Kozen97}. Another subtle side-condition is completeness of
   308   states \cite{Kozen97}. Another subtle side-condition is completeness of
   305   automata, that is automata need to have total transition functions and at most one
   309   automata, that is automata need to have total transition functions and at most one
   306   `sink' state from which there is no connection to a final state (Brozowski
   310   `sink' state from which there is no connection to a final state (Brozowski
   307   mentions this side-condition in the context of state complexity
   311   mentions this side-condition in the context of state complexity
   308   of automata \cite{Brozowski10}). Such side-conditions mean that if we define a regular
   312   of automata \cite{Brozowski10}). Such side-conditions mean that if we define a regular
   344   \noindent 
   348   \noindent 
   345   {\bf Contributions:} There is an extensive literature on regular languages.
   349   {\bf Contributions:} There is an extensive literature on regular languages.
   346   To our best knowledge, our proof of the Myhill-Nerode theorem is the first
   350   To our best knowledge, our proof of the Myhill-Nerode theorem is the first
   347   that is based on regular expressions, only. The part of this theorem stating
   351   that is based on regular expressions, only. The part of this theorem stating
   348   that finitely many partitions imply regularity of the language is proved by
   352   that finitely many partitions imply regularity of the language is proved by
   349   an argument about solving equational sytems.  This argument appears to be
   353   an argument about solving equational systems.  This argument appears to be
   350   folklore. For the other part, we give two proofs: one direct proof using
   354   folklore. For the other part, we give two proofs: one direct proof using
   351   certain tagging-functions, and another indirect proof using Antimirov's
   355   certain tagging-functions, and another indirect proof using Antimirov's
   352   partial derivatives \cite{Antimirov95}. Again to our best knowledge, the
   356   partial derivatives \cite{Antimirov95}. Again to our best knowledge, the
   353   tagging-functions have not been used before to establish the Myhill-Nerode
   357   tagging-functions have not been used before to establish the Myhill-Nerode
   354   theorem. Derivatives of regular expressions have been recently used quite
   358   theorem. Derivatives of regular expressions have been recently used quite
   401   string; this property states that if \mbox{@{term "[] \<notin> A"}} then the lengths of
   405   string; this property states that if \mbox{@{term "[] \<notin> A"}} then the lengths of
   402   the strings in @{term "A \<up> (Suc n)"} must be longer than @{text n}.  We omit
   406   the strings in @{term "A \<up> (Suc n)"} must be longer than @{text n}.  We omit
   403   the proofs for these properties, but invite the reader to consult our
   407   the proofs for these properties, but invite the reader to consult our
   404   formalisation.\footnote{Available at \url{http://www4.in.tum.de/~urbanc/regexp.html}}
   408   formalisation.\footnote{Available at \url{http://www4.in.tum.de/~urbanc/regexp.html}}
   405 
   409 
   406   The notation in Isabelle/HOL for the quotient of a language @{text A} according to an 
   410   The notation in Isabelle/HOL for the quotient of a language @{text A}
   407   equivalence relation @{term REL} is @{term "A // REL"}. We will write 
   411   according to an equivalence relation @{term REL} is @{term "A // REL"}. We
   408   @{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined 
   412   will write @{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined as
   409   as \mbox{@{text "{y | y \<approx> x}"}}.
   413   \mbox{@{text "{y | y \<approx> x}"}}, and have @{text "x \<approx> y"} if and only if @{text
       
   414   "\<lbrakk>x\<rbrakk>\<^isub>\<approx> = \<lbrakk>y\<rbrakk>\<^isub>\<approx>"}.
   410 
   415 
   411 
   416 
   412   Central to our proof will be the solution of equational systems
   417   Central to our proof will be the solution of equational systems
   413   involving equivalence classes of languages. For this we will use Arden's Lemma 
   418   involving equivalence classes of languages. For this we will use Arden's Lemma 
   414   (see \cite[Page 100]{Sakarovitch09}),
   419   (see \cite[Page 100]{Sakarovitch09}),
   424   \end{lmm}
   429   \end{lmm}
   425 
   430 
   426   \begin{proof}
   431   \begin{proof}
   427   For the right-to-left direction we assume @{thm (rhs) arden} and show
   432   For the right-to-left direction we assume @{thm (rhs) arden} and show
   428   that @{thm (lhs) arden} holds. From Prop.~\ref{langprops}@{text "(i)"} 
   433   that @{thm (lhs) arden} holds. From Prop.~\ref{langprops}@{text "(i)"} 
   429   we have @{term "A\<star> = {[]} \<union> A \<cdot> A\<star>"},
   434   we have @{term "A\<star> = A \<cdot> A\<star> \<union> {[]}"},
   430   which is equal to @{term "A\<star> = {[]} \<union> A\<star> \<cdot> A"}. Adding @{text B} to both 
   435   which is equal to @{term "A\<star> = A\<star> \<cdot> A \<union> {[]}"}. Adding @{text B} to both 
   431   sides gives @{term "B \<cdot> A\<star> = B \<cdot> ({[]} \<union> A\<star> \<cdot> A)"}, whose right-hand side
   436   sides gives @{term "B \<cdot> A\<star> = B \<cdot> (A\<star> \<cdot> A \<union> {[]})"}, whose right-hand side
   432   is equal to @{term "(B \<cdot> A\<star>) \<cdot> A \<union> B"}. This completes this direction. 
   437   is equal to @{term "(B \<cdot> A\<star>) \<cdot> A \<union> B"}. This completes this direction. 
   433 
   438 
   434   For the other direction we assume @{thm (lhs) arden}. By a simple induction
   439   For the other direction we assume @{thm (lhs) arden}. By a simple induction
   435   on @{text n}, we can establish the property
   440   on @{text n}, we can establish the property
   436 
   441 
   513 
   518 
   514   \begin{dfntn}[Myhill-Nerode Relation]\label{myhillneroderel} 
   519   \begin{dfntn}[Myhill-Nerode Relation]\label{myhillneroderel} 
   515   Given a language @{text A}, two strings @{text x} and
   520   Given a language @{text A}, two strings @{text x} and
   516   @{text y} are Myhill-Nerode related provided
   521   @{text y} are Myhill-Nerode related provided
   517   \begin{center}
   522   \begin{center}
   518   @{thm str_eq_def[simplified str_eq_rel_def Pair_Collect]}
   523   @{thm str_eq_def'}
   519   \end{center}
   524   \end{center}
   520   \end{dfntn}
   525   \end{dfntn}
   521 
   526 
   522   \noindent
   527   \noindent
   523   It is easy to see that @{term "\<approx>A"} is an equivalence relation, which
   528   It is easy to see that @{term "\<approx>A"} is an equivalence relation, which
   639   \end{tabular}}
   644   \end{tabular}}
   640   \end{equation}
   645   \end{equation}
   641   
   646   
   642   \noindent
   647   \noindent
   643   where @{text "d\<^isub>1\<dots>d\<^isub>n"} is the sequence of all characters
   648   where @{text "d\<^isub>1\<dots>d\<^isub>n"} is the sequence of all characters
   644   except @{text c}, and @{text "c\<^isub>1\<dots>c\<^isub>m"} is the sequence of all
   649   but not containing @{text c}, and @{text "c\<^isub>1\<dots>c\<^isub>m"} is the sequence of all
   645   characters.  
   650   characters.  
   646 
   651 
   647   Overloading the function @{text \<calL>} for the two kinds of terms in the
   652   Overloading the function @{text \<calL>} for the two kinds of terms in the
   648   equational system, we have
   653   equational system, we have
   649   
   654   
  1065 
  1070 
  1066 section {* Myhill-Nerode, Second Part *}
  1071 section {* Myhill-Nerode, Second Part *}
  1067 
  1072 
  1068 text {*
  1073 text {*
  1069   \noindent
  1074   \noindent
  1070   In this section and the next we will give two proofs for establishing the second 
  1075   In this section we will give a proof for establishing the second 
  1071   part of the Myhill-Nerode theorem. It can be formulated in our setting as follows:
  1076   part of the Myhill-Nerode theorem. It can be formulated in our setting as follows:
  1072 
  1077 
  1073   \begin{thrm}
  1078   \begin{thrm}
  1074   Given @{text "r"} is a regular expression, then @{thm Myhill_Nerode2}.
  1079   Given @{text "r"} is a regular expression, then @{thm Myhill_Nerode2}.
  1075   \end{thrm}  
  1080   \end{thrm}  
  1076 
  1081 
  1077   \noindent
  1082   \noindent
  1078   The first proof will be by induction on the structure of @{text r}. It turns out
  1083   The proof will be by induction on the structure of @{text r}. It turns out
  1079   the base cases are straightforward.
  1084   the base cases are straightforward.
  1080 
  1085 
  1081 
  1086 
  1082   \begin{proof}[Base Cases]
  1087   \begin{proof}[Base Cases]
  1083   The cases for @{const ZERO}, @{const ONE} and @{const ATOM} are routine, because 
  1088   The cases for @{const ZERO}, @{const ONE} and @{const ATOM} are routine, because 
  1097 
  1102 
  1098   \noindent
  1103   \noindent
  1099   Much more interesting, however, are the inductive cases. They seem hard to solve 
  1104   Much more interesting, however, are the inductive cases. They seem hard to solve 
  1100   directly. The reader is invited to try. 
  1105   directly. The reader is invited to try. 
  1101 
  1106 
  1102   In order how to see how our first proof proceeds we use the following suggestive picture 
  1107   In order to see how our proof proceeds consider the following suggestive picture 
  1103   from Constable et al \cite{Constable00}:
  1108   taken from Constable et al \cite{Constable00}:
  1104 
  1109 
  1105   \begin{center}
  1110   \begin{equation}\label{pics}
  1106   \begin{tabular}{c@ {\hspace{10mm}}c@ {\hspace{10mm}}c}
  1111   \mbox{\begin{tabular}{c@ {\hspace{10mm}}c@ {\hspace{10mm}}c}
  1107   \begin{tikzpicture}[scale=1]
  1112   \begin{tikzpicture}[scale=1]
  1108   %Circle
  1113   %Circle
  1109   \draw[thick] (0,0) circle (1.1);    
  1114   \draw[thick] (0,0) circle (1.1);    
  1110   \end{tikzpicture}
  1115   \end{tikzpicture}
  1111   &
  1116   &
  1127      \draw[very thick] (0, 0) -- (\a:1.1);
  1132      \draw[very thick] (0, 0) -- (\a:1.1);
  1128   \foreach \a / \l in {22.5/1.1, 67.5/1.2, 112.5/2.1, 157.5/2.2, 202.4/3.1, 247.5/3.2, 292.5/4.1, 337.5/4.2}
  1133   \foreach \a / \l in {22.5/1.1, 67.5/1.2, 112.5/2.1, 157.5/2.2, 202.4/3.1, 247.5/3.2, 292.5/4.1, 337.5/4.2}
  1129       \draw (\a: 0.77) node {$a_{\l}$};
  1134       \draw (\a: 0.77) node {$a_{\l}$};
  1130   \end{tikzpicture}\\
  1135   \end{tikzpicture}\\
  1131   @{term UNIV} & @{term "UNIV // (\<approx>(lang r))"} & @{term "UNIV // R"}
  1136   @{term UNIV} & @{term "UNIV // (\<approx>(lang r))"} & @{term "UNIV // R"}
  1132   \end{tabular}
  1137   \end{tabular}}
  1133   \end{center}
  1138   \end{equation}
  1134 
  1139 
  1135   Our first proof will rely on some
  1140   \noindent
       
  1141   The relation @{term "\<approx>(lang r)"} partitions the set of all strings into some
       
  1142   equivalence classes. To show that there are only finitely many of
       
  1143   them, it suffices to show in each induction step the existence of another
       
  1144   relation, say @{text R}, for which we can show that there are finitely many
       
  1145   equivalence classes and which refines @{term "\<approx>(lang r)"}. A relation @{text
       
  1146   "R\<^isub>1"} is said to \emph{refine} @{text "R\<^isub>2"} provided @{text
       
  1147   "R\<^isub>1 \<subseteq> R\<^isub>2"}. For constructing @{text R} will rely on some
  1136   \emph{tagging-functions} defined over strings. Given the inductive hypothesis, it will 
  1148   \emph{tagging-functions} defined over strings. Given the inductive hypothesis, it will 
  1137   be easy to prove that the \emph{range} of these tagging-functions is finite. 
  1149   be easy to prove that the \emph{range} of these tagging-functions is finite. 
  1138   The range of a function @{text f} is defined as 
  1150   The range of a function @{text f} is defined as 
  1139   
  1151   
  1140   \begin{center}
  1152   \begin{center}
  1141   @{text "range f \<equiv> f ` UNIV"}
  1153   @{text "range f \<equiv> f ` UNIV"}
  1142   \end{center}
  1154   \end{center}
  1143 
  1155 
  1144   \noindent
  1156   \noindent
  1145   that means we take the image of @{text f} w.r.t.~all elements in the domain. 
  1157   that means we take the image of @{text f} w.r.t.~all elements in the
  1146   With this we will be able to infer that the tagging-functions, seen as relations,
  1158   domain. With this we will be able to infer that the tagging-functions, seen
  1147   give rise to finitely many equivalence classes of @{const UNIV}. Finally we 
  1159   as relations, give rise to finitely many equivalence classes of @{const
  1148   will show that the tagging-relations are more refined than @{term "\<approx>(lang r)"}, which
  1160   UNIV}. Finally we will show that the tagging-relations are more refined than
  1149   implies that @{term "UNIV // \<approx>(lang r)"} must also be finite---a relation @{text "R\<^isub>1"} 
  1161   @{term "\<approx>(lang r)"}, which implies that @{term "UNIV // \<approx>(lang r)"} must
  1150   is said to \emph{refine} @{text "R\<^isub>2"} provided @{text "R\<^isub>1 \<subseteq> R\<^isub>2"}.
  1162   also be finite.  We formally define the notion of a \emph{tagging-relation}
  1151   We formally define the notion of a \emph{tagging-relation} as follows.
  1163   as follows.
       
  1164 
  1152 
  1165 
  1153   \begin{dfntn}[Tagging-Relation] Given a tagging-function @{text tag}, then two strings @{text x}
  1166   \begin{dfntn}[Tagging-Relation] Given a tagging-function @{text tag}, then two strings @{text x}
  1154   and @{text y} are \emph{tag-related} provided
  1167   and @{text y} are \emph{tag-related} provided
  1155   \begin{center}
  1168   \begin{center}
  1156   @{text "x \<^raw:$\threesim$>\<^bsub>tag\<^esub> y \<equiv> tag x = tag y"}\;.
  1169   @{text "x \<^raw:$\threesim$>\<^bsub>tag\<^esub> y \<equiv> tag x = tag y"}\;.
  1210   they must also be @{text "R\<^isub>2"}-related, as we need to show.
  1223   they must also be @{text "R\<^isub>2"}-related, as we need to show.
  1211   \end{proof}
  1224   \end{proof}
  1212 
  1225 
  1213   \noindent
  1226   \noindent
  1214   Chaining Lem.~\ref{finone} and \ref{fintwo} together, means in order to show
  1227   Chaining Lem.~\ref{finone} and \ref{fintwo} together, means in order to show
  1215   that @{term "UNIV // \<approx>(lang r)"} is finite, we have to find a tagging-function whose
  1228   that @{term "UNIV // \<approx>(lang r)"} is finite, we have to construct a tagging-function whose
  1216   range can be shown to be finite and whose tagging-relation refines @{term "\<approx>(lang r)"}.
  1229   range can be shown to be finite and whose tagging-relation refines @{term "\<approx>(lang r)"}.
  1217   Let us attempt the @{const PLUS}-case first.
  1230   Let us attempt the @{const PLUS}-case first.
  1218 
  1231 
  1219   \begin{proof}[@{const "PLUS"}-Case] 
  1232   \begin{proof}[@{const "PLUS"}-Case] 
  1220   We take as tagging-function 
  1233   We take as tagging-function 
  1221   %
  1234   %
  1222   \begin{center}
  1235   \begin{center}
  1223   @{thm tag_str_Plus_def[where A="A" and B="B", THEN meta_eq_app]}
  1236   @{thm tag_Plus_def[where A="A" and B="B", THEN meta_eq_app]}
  1224   \end{center}
  1237   \end{center}
  1225 
  1238 
  1226   \noindent
  1239   \noindent
  1227   where @{text "A"} and @{text "B"} are some arbitrary languages.
  1240   where @{text "A"} and @{text "B"} are some arbitrary languages.
  1228   We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"}
  1241   We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"}
  1229   then @{term "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))"} holds. The range of
  1242   then @{term "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))"} holds. The range of
  1230   @{term "tag_str_Plus A B"} is a subset of this product set---so finite. It remains to be shown
  1243   @{term "tag_Plus A B"} is a subset of this product set---so finite. It remains to be shown
  1231   that @{text "=tag\<^isub>A\<^isub>L\<^isub>T A B="} refines @{term "\<approx>(A \<union> B)"}. This amounts to 
  1244   that @{text "=tag\<^isub>A\<^isub>L\<^isub>T A B="} refines @{term "\<approx>(A \<union> B)"}. This amounts to 
  1232   showing
  1245   showing
  1233   %
  1246   %
  1234   \begin{center}
  1247   \begin{center}
  1235   @{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"}
  1248   @{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"}
  1267   is to find out what the possible splits of @{text "x @ z"} are to be in @{term "A \<cdot> B"}
  1280   is to find out what the possible splits of @{text "x @ z"} are to be in @{term "A \<cdot> B"}
  1268   (this was easy in case of @{term "A \<union> B"}). To deal with this complication we define the
  1281   (this was easy in case of @{term "A \<union> B"}). To deal with this complication we define the
  1269   notions of \emph{string prefixes} 
  1282   notions of \emph{string prefixes} 
  1270   %
  1283   %
  1271   \begin{center}
  1284   \begin{center}
  1272   @{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\hspace{10mm}
  1285   \begin{tabular}{l}
       
  1286   @{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\\
  1273   @{text "x < y \<equiv> x \<le> y \<and> x \<noteq> y"}
  1287   @{text "x < y \<equiv> x \<le> y \<and> x \<noteq> y"}
       
  1288   \end{tabular}
  1274   \end{center}
  1289   \end{center}
  1275   %
  1290   %
  1276   \noindent
  1291   \noindent
  1277   and \emph{string subtraction}:
  1292   and \emph{string subtraction}:
  1278   %
  1293   %
  1279   \begin{center}
  1294   \begin{center}
  1280   @{text "[] - y \<equiv> []"}\hspace{10mm}
  1295   \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
  1281   @{text "x - [] \<equiv> x"}\hspace{10mm}
  1296   @{text "[] - y"}  & @{text "\<equiv>"} & @{text "[]"}\\
  1282   @{text "cx - dy \<equiv> if c = d then x - y else cx"}
  1297   @{text "x - []"}  & @{text "\<equiv>"} & @{text "x"}\\
       
  1298   @{text "cx - dy"} & @{text "\<equiv>"} & @{text "if c = d then x - y else cx"}
       
  1299   \end{tabular}
  1283   \end{center}
  1300   \end{center}
  1284   %
  1301   %
  1285   \noindent
  1302   \noindent
  1286   where @{text c} and @{text d} are characters, and @{text x} and @{text y} are strings. 
  1303   where @{text c} and @{text d} are characters, and @{text x} and @{text y} are strings. 
  1287   
  1304   
  1288   Now assuming  @{term "x @ z \<in> A \<cdot> B"} there are only two possible ways of how to `split' 
  1305   Now assuming  @{term "x @ z \<in> A \<cdot> B"} there are only two possible ways of how to `split' 
  1289   this string to be in @{term "A \<cdot> B"}:
  1306   this string to be in @{term "A \<cdot> B"}:
  1290   %
  1307   %
  1291   \begin{center}
  1308   \begin{center}
  1292   \begin{tabular}{@ {}c@ {\hspace{10mm}}c@ {}}
  1309   \begin{tabular}{c}
  1293   \scalebox{0.7}{
  1310   \scalebox{0.9}{
  1294   \begin{tikzpicture}
  1311   \begin{tikzpicture}
  1295     \node[draw,minimum height=3.8ex] (xa) { $\hspace{3em}@{text "x'"}\hspace{3em}$ };
  1312     \node[draw,minimum height=3.8ex] (xa) { $\hspace{3em}@{text "x'"}\hspace{3em}$ };
  1296     \node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.2em}@{text "x - x'"}\hspace{0.2em}$ };
  1313     \node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.2em}@{text "x - x'"}\hspace{0.2em}$ };
  1297     \node[draw,minimum height=3.8ex, right=-0.03em of xxa] (z) { $\hspace{5em}@{text z}\hspace{5em}$ };
  1314     \node[draw,minimum height=3.8ex, right=-0.03em of xxa] (z) { $\hspace{5em}@{text z}\hspace{5em}$ };
  1298 
  1315 
  1314 
  1331 
  1315     \draw[decoration={brace,transform={yscale=3}},decorate]
  1332     \draw[decoration={brace,transform={yscale=3}},decorate]
  1316            ($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$)
  1333            ($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$)
  1317                node[midway, below=0.5em]{@{term "x' \<in> A"}};
  1334                node[midway, below=0.5em]{@{term "x' \<in> A"}};
  1318   \end{tikzpicture}}
  1335   \end{tikzpicture}}
  1319   &
  1336   \\
  1320   \scalebox{0.7}{
  1337   \scalebox{0.9}{
  1321   \begin{tikzpicture}
  1338   \begin{tikzpicture}
  1322     \node[draw,minimum height=3.8ex] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ };
  1339     \node[draw,minimum height=3.8ex] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ };
  1323     \node[draw,minimum height=3.8ex, right=-0.03em of x] (za) { $\hspace{0.6em}@{text "z'"}\hspace{0.6em}$ };
  1340     \node[draw,minimum height=3.8ex, right=-0.03em of x] (za) { $\hspace{0.6em}@{text "z'"}\hspace{0.6em}$ };
  1324     \node[draw,minimum height=3.8ex, right=-0.03em of za] (zza) { $\hspace{2.6em}@{text "z - z'"}\hspace{2.6em}$  };
  1341     \node[draw,minimum height=3.8ex, right=-0.03em of za] (zza) { $\hspace{2.6em}@{text "z - z'"}\hspace{2.6em}$  };
  1325 
  1342 
  1351   or @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} (second picture).
  1368   or @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} (second picture).
  1352   In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. For this we use the 
  1369   In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. For this we use the 
  1353   following tagging-function
  1370   following tagging-function
  1354   %
  1371   %
  1355   \begin{center}
  1372   \begin{center}
  1356   @{thm tag_str_Times_def[where ?L1.0="A" and ?L2.0="B", THEN meta_eq_app]}
  1373   @{thm tag_Times_def[where ?A="A" and ?B="B", THEN meta_eq_app]}
  1357   \end{center}
  1374   \end{center}
  1358 
  1375 
  1359   \noindent
  1376   \noindent
  1360   with the idea that in the first split we have to make sure that @{text "(x - x') @ z"}
  1377   with the idea that in the first split we have to make sure that @{text "(x - x') @ z"}
  1361   is in the language @{text B}.
  1378   is in the language @{text B}.
  1362 
  1379 
  1363   \begin{proof}[@{const TIMES}-Case]
  1380   \begin{proof}[@{const TIMES}-Case]
  1364   If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"}
  1381   If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"}
  1365   then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of
  1382   then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of
  1366   @{term "tag_str_TIMES A B"} is a subset of this product set, and therefore finite.
  1383   @{term "tag_Times A B"} is a subset of this product set, and therefore finite.
  1367   We have to show injectivity of this tagging-function as
  1384   We have to show injectivity of this tagging-function as
  1368   %
  1385   %
  1369   \begin{center}
  1386   \begin{center}
  1370   @{term "\<forall>z. tag_str_TIMES A B x = tag_str_TIMES A B y \<and> x @ z \<in> A \<cdot> B \<longrightarrow> y @ z \<in> A \<cdot> B"}
  1387   @{term "\<forall>z. tag_Times A B x = tag_Times A B y \<and> x @ z \<in> A \<cdot> B \<longrightarrow> y @ z \<in> A \<cdot> B"}
  1371   \end{center}
  1388   \end{center}
  1372   %
  1389   %
  1373   \noindent
  1390   \noindent
  1374   There are two cases to be considered (see pictures above). First, there exists 
  1391   There are two cases to be considered (see pictures above). First, there exists 
  1375   a @{text "x'"} such that
  1392   a @{text "x'"} such that
  1378   \begin{center}
  1395   \begin{center}
  1379   @{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {x - x'} |x'. x' \<le> x \<and> x' \<in> A})"}
  1396   @{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {x - x'} |x'. x' \<le> x \<and> x' \<in> A})"}
  1380   \end{center}
  1397   \end{center}
  1381   %
  1398   %
  1382   \noindent
  1399   \noindent
  1383   and by the assumption about @{term "tag_str_TIMES A B"} also 
  1400   and by the assumption about @{term "tag_Times A B"} also 
  1384   %
  1401   %
  1385   \begin{center}
  1402   \begin{center}
  1386   @{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {y - y'} |y'. y' \<le> y \<and> y' \<in> A})"}
  1403   @{term "(\<approx>B `` {x - x'}) \<in> ({\<approx>B `` {y - y'} |y'. y' \<le> y \<and> y' \<in> A})"}
  1387   \end{center}
  1404   \end{center}
  1388   %
  1405   %
  1393   relation and together with the fact that @{text "(x - x') @ z \<in> B"}, we
  1410   relation and together with the fact that @{text "(x - x') @ z \<in> B"}, we
  1394   have @{text "(y - y') @ z \<in> B"}. We already know @{text "y' \<in> A"}, therefore
  1411   have @{text "(y - y') @ z \<in> B"}. We already know @{text "y' \<in> A"}, therefore
  1395   @{term "y @ z \<in> A \<cdot> B"}, as needed in this case.
  1412   @{term "y @ z \<in> A \<cdot> B"}, as needed in this case.
  1396 
  1413 
  1397   Second, there exists a @{text "z'"} such that @{term "x @ z' \<in> A"} and @{text "z - z' \<in> B"}.
  1414   Second, there exists a @{text "z'"} such that @{term "x @ z' \<in> A"} and @{text "z - z' \<in> B"}.
  1398   By the assumption about @{term "tag_str_TIMES A B"} we have
  1415   By the assumption about @{term "tag_Times A B"} we have
  1399   @{term "\<approx>A `` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Which means by the Myhill-Nerode
  1416   @{term "\<approx>A `` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Which means by the Myhill-Nerode
  1400   relation that @{term "y @ z' \<in> A"} holds. Using @{text "z - z' \<in> B"}, we can conclude also in this case
  1417   relation that @{term "y @ z' \<in> A"} holds. Using @{text "z - z' \<in> B"}, we can conclude also in this case
  1401   with @{term "y @ z \<in> A \<cdot> B"}. We again can complete the @{const TIMES}-case
  1418   with @{term "y @ z \<in> A \<cdot> B"}. We again can complete the @{const TIMES}-case
  1402   by setting @{text A} to @{term "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}. 
  1419   by setting @{text A} to @{term "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}. 
  1403   \end{proof}
  1420   \end{proof}
  1465 
  1482 
  1466   In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use
  1483   In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use
  1467   the following tagging-function:
  1484   the following tagging-function:
  1468   %
  1485   %
  1469   \begin{center}
  1486   \begin{center}
  1470   @{thm tag_str_Star_def[where ?L1.0="A", THEN meta_eq_app]}\smallskip
  1487   @{thm tag_Star_def[where ?A="A", THEN meta_eq_app]}\smallskip
  1471   \end{center}
  1488   \end{center}
  1472 
  1489 
  1473   \begin{proof}[@{const Star}-Case]
  1490   \begin{proof}[@{const Star}-Case]
  1474   If @{term "finite (UNIV // \<approx>A)"} 
  1491   If @{term "finite (UNIV // \<approx>A)"} 
  1475   then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of
  1492   then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of
  1476   @{term "tag_str_Star A"} is a subset of this set, and therefore finite.
  1493   @{term "tag_Star A"} is a subset of this set, and therefore finite.
  1477   Again we have to show injectivity of this tagging-function as  
  1494   Again we have to show injectivity of this tagging-function as  
  1478   %
  1495   %
  1479   \begin{center}
  1496   \begin{center}
  1480   @{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>"}
  1497   @{term "\<forall>z. tag_Star A x = tag_Star A y \<and> x @ z \<in> A\<star> \<longrightarrow> y @ z \<in> A\<star>"}
  1481   \end{center}  
  1498   \end{center}  
  1482   %
  1499   %
  1483   \noindent
  1500   \noindent
  1484   We first need to consider the case that @{text x} is the empty string.
  1501   We first need to consider the case that @{text x} is the empty string.
  1485   From the assumption we can infer @{text y} is the empty string and
  1502   From the assumption we can infer @{text y} is the empty string and