Journal/Paper.thy
changeset 194 5347d7556487
parent 193 2a5ac68db24b
child 196 fa8d33d13cb6
equal deleted inserted replaced
193:2a5ac68db24b 194:5347d7556487
   615   strings in the equivalence class @{text Y}, we obtain a subset of 
   615   strings in the equivalence class @{text Y}, we obtain a subset of 
   616   @{text X}. Note that we do not define an automaton here, we merely relate two sets
   616   @{text X}. Note that we do not define an automaton here, we merely relate two sets
   617   (with the help of a character). In our concrete example we have 
   617   (with the help of a character). In our concrete example we have 
   618   @{term "X\<^isub>1 \<Turnstile>c\<Rightarrow> X\<^isub>2"}, @{term "X\<^isub>1 \<Turnstile>d\<^isub>i\<Rightarrow> X\<^isub>3"} with @{text "d\<^isub>i"} being any 
   618   @{term "X\<^isub>1 \<Turnstile>c\<Rightarrow> X\<^isub>2"}, @{term "X\<^isub>1 \<Turnstile>d\<^isub>i\<Rightarrow> X\<^isub>3"} with @{text "d\<^isub>i"} being any 
   619   other character than @{text c}, and @{term "X\<^isub>3 \<Turnstile>c\<^isub>j\<Rightarrow> X\<^isub>3"} for any 
   619   other character than @{text c}, and @{term "X\<^isub>3 \<Turnstile>c\<^isub>j\<Rightarrow> X\<^isub>3"} for any 
   620   caracter @{text "c\<^isub>j"}.
   620   character @{text "c\<^isub>j"}.
   621   
   621   
   622   Next we construct an \emph{initial equational system} that
   622   Next we construct an \emph{initial equational system} that
   623   contains an equation for each equivalence class. We first give
   623   contains an equation for each equivalence class. We first give
   624   an informal description of this construction. Suppose we have 
   624   an informal description of this construction. Suppose we have 
   625   the equivalence classes @{text "X\<^isub>1,\<dots>,X\<^isub>n"}, there must be one and only one that
   625   the equivalence classes @{text "X\<^isub>1,\<dots>,X\<^isub>n"}, there must be one and only one that
   815   @{text "X = \<Union>\<calL> ` (Arden X rhs)"}.
   815   @{text "X = \<Union>\<calL> ` (Arden X rhs)"}.
   816   \end{lmm}
   816   \end{lmm}
   817   
   817   
   818   \noindent
   818   \noindent
   819   Our @{text ardenable} condition is slightly stronger than needed for applying Arden's Lemma,
   819   Our @{text ardenable} condition is slightly stronger than needed for applying Arden's Lemma,
   820   but we can still ensure that it holds troughout our algorithm of transforming equations
   820   but we can still ensure that it holds throughout our algorithm of transforming equations
   821   into solved form. The \emph{substitution-operation} takes an equation
   821   into solved form. The \emph{substitution-operation} takes an equation
   822   of the form @{text "X = xrhs"} and substitutes it into the right-hand side @{text rhs}.
   822   of the form @{text "X = xrhs"} and substitutes it into the right-hand side @{text rhs}.
   823 
   823 
   824   \begin{center}
   824   \begin{center}
   825   \begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l}
   825   \begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l}
  1555   A\<star>"}, which means @{term "y @ z \<in> A\<star>"}. The last step is to set
  1555   A\<star>"}, which means @{term "y @ z \<in> A\<star>"}. The last step is to set
  1556   @{text "A"} to @{term "lang r"} and thus complete the proof.
  1556   @{text "A"} to @{term "lang r"} and thus complete the proof.
  1557   \end{proof}
  1557   \end{proof}
  1558 *}
  1558 *}
  1559 
  1559 
  1560 section {* Second Part proved using Partial Derivatives *}
  1560 section {* Second Part proved using Partial Derivatives\label{derivatives} *}
  1561 
  1561 
  1562 text {*
  1562 text {*
  1563   \noindent
  1563   \noindent
  1564   As we have seen in the previous section, in order to establish
  1564   As we have seen in the previous section, in order to establish
  1565   the second direction of the Myhill-Nerode theorem, we need to find 
  1565   the second direction of the Myhill-Nerode theorem, we need to find 
  1719 
  1719 
  1720   \noindent
  1720   \noindent
  1721   Carrying this idea through, we must not consider the set of all derivatives,
  1721   Carrying this idea through, we must not consider the set of all derivatives,
  1722   but the ones modulo @{text "ACI"}.  In principle, this can be done formally, 
  1722   but the ones modulo @{text "ACI"}.  In principle, this can be done formally, 
  1723   but it is very painful in a theorem prover (since there is no
  1723   but it is very painful in a theorem prover (since there is no
  1724   direct characterisation of the set of dissimlar derivatives).
  1724   direct characterisation of the set of dissimilar derivatives).
  1725 
  1725 
  1726 
  1726 
  1727   Fortunately, there is a much simpler approach using \emph{partial
  1727   Fortunately, there is a much simpler approach using \emph{partial
  1728   derivatives}. They were introduced by Antimirov \cite{Antimirov95} and can be defined
  1728   derivatives}. They were introduced by Antimirov \cite{Antimirov95} and can be defined
  1729   in Isabelle/HOL as follows:
  1729   in Isabelle/HOL as follows:
  1790   \end{equation} 
  1790   \end{equation} 
  1791 
  1791 
  1792   \begin{proof}
  1792   \begin{proof}
  1793   The first fact is by a simple induction on @{text r}. For the second we slightly
  1793   The first fact is by a simple induction on @{text r}. For the second we slightly
  1794   modify Antimirov's proof by performing an induction on @{text s} where we
  1794   modify Antimirov's proof by performing an induction on @{text s} where we
  1795   genaralise over all @{text r}. That means in the @{text "cons"}-case the 
  1795   generalise over all @{text r}. That means in the @{text "cons"}-case the 
  1796   induction hypothesis is
  1796   induction hypothesis is
  1797 
  1797 
  1798   \begin{center}
  1798   \begin{center}
  1799   @{text "(IH)"}\hspace{3mm}@{term "\<forall>r. Ders s (lang r) = \<Union> lang ` (pders s r)"}
  1799   @{text "(IH)"}\hspace{3mm}@{term "\<forall>r. Ders s (lang r) = \<Union> lang ` (pders s r)"}
  1800   \end{center}
  1800   \end{center}
  2051   Owens and Slind \cite{OwensSlind08}.
  2051   Owens and Slind \cite{OwensSlind08}.
  2052 
  2052 
  2053 
  2053 
  2054   Our formalisation consists of 780 lines of Isabelle/Isar code for the first
  2054   Our formalisation consists of 780 lines of Isabelle/Isar code for the first
  2055   direction and 460 for the second, plus around 300 lines of standard material
  2055   direction and 460 for the second, plus around 300 lines of standard material
  2056   about regular languages. While this might be seen large, it should be seen
  2056   about regular languages. The formalisation about derivatives and partial 
       
  2057   derivatives shown in Section~\ref{derivatives} consists of 390 lines of code.
       
  2058   While this might be seen large, it should be seen
  2057   in the context of the work done by Constable at al \cite{Constable00} who
  2059   in the context of the work done by Constable at al \cite{Constable00} who
  2058   formalised the Myhill-Nerode theorem in Nuprl using automata. They write
  2060   formalised the Myhill-Nerode theorem in Nuprl using automata. They write
  2059   that their four-member team needed something on the magnitude of 18 months
  2061   that their four-member team needed something on the magnitude of 18 months
  2060   for their formalisation. The estimate for our formalisation is that we
  2062   for their formalisation. The estimate for our formalisation is that we
  2061   needed approximately 3 months and this included the time to find our proof
  2063   needed approximately 3 months and this included the time to find our proof
  2064   formalisation was not the bottleneck. It is hard to gauge the size of a
  2066   formalisation was not the bottleneck. It is hard to gauge the size of a
  2065   formalisation in Nurpl, but from what is shown in the Nuprl Math Library
  2067   formalisation in Nurpl, but from what is shown in the Nuprl Math Library
  2066   about their development it seems substantially larger than ours. The code of
  2068   about their development it seems substantially larger than ours. The code of
  2067   ours can be found in the Mercurial Repository at
  2069   ours can be found in the Mercurial Repository at
  2068   \mbox{\url{http://www4.in.tum.de/~urbanc/regexp.html}}.
  2070   \mbox{\url{http://www4.in.tum.de/~urbanc/regexp.html}}.
  2069 
       
  2070 
  2071 
  2071 
  2072 
  2072   Our proof of the first direction is very much inspired by \emph{Brzozowski's
  2073   Our proof of the first direction is very much inspired by \emph{Brzozowski's
  2073   algebraic method} used to convert a finite automaton to a regular
  2074   algebraic method} used to convert a finite automaton to a regular
  2074   expression \cite{Brzozowski64}. The close connection can be seen by considering the equivalence
  2075   expression \cite{Brzozowski64}. The close connection can be seen by considering the equivalence