Journal/Paper.thy
changeset 239 13de6a49294e
parent 238 a6513d0b16fc
child 240 17aa8c8fbe7d
equal deleted inserted replaced
238:a6513d0b16fc 239:13de6a49294e
    34 abbreviation "ATOM \<equiv> Atom"
    34 abbreviation "ATOM \<equiv> Atom"
    35 abbreviation "PLUS \<equiv> Plus"
    35 abbreviation "PLUS \<equiv> Plus"
    36 abbreviation "TIMES \<equiv> Times"
    36 abbreviation "TIMES \<equiv> Times"
    37 abbreviation "TIMESS \<equiv> Timess"
    37 abbreviation "TIMESS \<equiv> Timess"
    38 abbreviation "STAR \<equiv> Star"
    38 abbreviation "STAR \<equiv> Star"
    39 abbreviation "ALLREG \<equiv> Allreg"
    39 abbreviation "ALLS \<equiv> Star Allreg"
    40 
    40 
    41 definition
    41 definition
    42   Delta :: "'a lang \<Rightarrow> 'a lang"
    42   Delta :: "'a lang \<Rightarrow> 'a lang"
    43 where
    43 where
    44   "Delta A = (if [] \<in> A then {[]} else {})"
    44   "Delta A = (if [] \<in> A then {[]} else {})"
    89   pderiv ("pder") and
    89   pderiv ("pder") and
    90   pderivs ("pders") and
    90   pderivs ("pders") and
    91   pderivs_set ("pderss") and
    91   pderivs_set ("pderss") and
    92   SUBSEQ ("Subseq") and
    92   SUBSEQ ("Subseq") and
    93   SUPSEQ ("Supseq") and
    93   SUPSEQ ("Supseq") and
    94   UP ("'(_')\<up>")
    94   UP ("'(_')\<up>") and
       
    95   ALLS ("ALL")
    95   
    96   
    96   
    97   
    97 lemmas Deriv_simps = Deriv_empty Deriv_epsilon Deriv_char Deriv_union
    98 lemmas Deriv_simps = Deriv_empty Deriv_epsilon Deriv_char Deriv_union
    98 
    99 
    99 definition
   100 definition
   492   Property @{text "(iv)"} states that a non-empty string in @{term "A\<star>"} can
   493   Property @{text "(iv)"} states that a non-empty string in @{term "A\<star>"} can
   493   always be split up into a non-empty prefix belonging to @{text "A"} and the
   494   always be split up into a non-empty prefix belonging to @{text "A"} and the
   494   rest being in @{term "A\<star>"}. We omit
   495   rest being in @{term "A\<star>"}. We omit
   495   the proofs for these properties, but invite the reader to consult our
   496   the proofs for these properties, but invite the reader to consult our
   496   formalisation.\footnote{Available in the Archive of Formal Proofs at 
   497   formalisation.\footnote{Available in the Archive of Formal Proofs at 
   497   \url{http://afp.sf.net/entries/Myhill-Nerode.shtml} 
   498   \url{http://afp.sourceforge.net/devel-entries/Myhill-Nerode.shtml} 
   498   \cite{myhillnerodeafp11}.}
   499   \cite{myhillnerodeafp11}.}
   499 
   500 
   500   The notation in Isabelle/HOL for the quotient of a language @{text A}
   501   The notation in Isabelle/HOL for the quotient of a language @{text A}
   501   according to an equivalence relation @{term REL} is @{term "A // REL"}. We
   502   according to an equivalence relation @{term REL} is @{term "A // REL"}. We
   502   will write @{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined as
   503   will write @{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined as
  2141   are regular.
  2142   are regular.
  2142   \end{lmm}
  2143   \end{lmm}
  2143 
  2144 
  2144   \noindent
  2145   \noindent
  2145   Our proof follows the one given in \cite[92--95]{Shallit08}, except that we use
  2146   Our proof follows the one given in \cite[92--95]{Shallit08}, except that we use
  2146   Higman's lemma, which is already proved in the Isabelle/HOL library. Higman's
  2147   Higman's Lemma, which is already proved in the Isabelle/HOL library. Higman's
  2147   lemma allows us to infer that every set @{text A} of antichains, namely
  2148   Lemma allows us to infer that every set @{text A} of antichains, namely
  2148 
  2149 
  2149   \begin{equation}\label{higman}
  2150   \begin{equation}\label{higman}
  2150   @{text "\<forall>x, y \<in> A."}~@{term "x \<noteq> y \<longrightarrow> \<not>(x \<preceq> y) \<and> \<not>(y \<preceq> x)"}
  2151   @{text "\<forall>x, y \<in> A."}~@{term "x \<noteq> y \<longrightarrow> \<not>(x \<preceq> y) \<and> \<not>(y \<preceq> x)"}
  2151   \end{equation} 
  2152   \end{equation} 
  2152 
  2153 
  2173   \begin{lmm}
  2174   \begin{lmm}
  2174   If @{text A} is regular, then also @{term "SUPSEQ A"}.
  2175   If @{text A} is regular, then also @{term "SUPSEQ A"}.
  2175   \end{lmm}
  2176   \end{lmm}
  2176 
  2177 
  2177   \begin{proof}
  2178   \begin{proof}
  2178   Since our alphabet is finite, we can find a regular expression, written @{const Allreg}, that
  2179   Since our alphabet is finite, we have a regular expression, written @{text ALL}, that
  2179   matches every single-character string. With this regular expression we can inductively define
  2180   matches every string. With this regular expression we can inductively define
  2180   the operation @{text "r\<up>"} over regular expressions
  2181   the operation @{text "r\<up>"} 
  2181 
  2182 
  2182   \begin{center}
  2183   \begin{center}
  2183   \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
  2184   \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
  2184   @{thm (lhs) UP.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) UP.simps(1)}\\  
  2185   @{thm (lhs) UP.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) UP.simps(1)}\\  
  2185   @{thm (lhs) UP.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) UP.simps(2)}\\ 
  2186   @{thm (lhs) UP.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) UP.simps(2)}\\ 
  2186   @{thm (lhs) UP.simps(3)} & @{text "\<equiv>"} &\\ 
  2187   @{thm (lhs) UP.simps(3)} & @{text "\<equiv>"} & @{thm (rhs) UP.simps(3)}\\ 
  2187    \multicolumn{3}{r}{@{thm (rhs) UP.simps(3)}}\\ 
       
  2188   @{thm (lhs) UP.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & 
  2188   @{thm (lhs) UP.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & 
  2189      @{text "\<equiv>"} & @{thm (rhs) UP.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
  2189      @{text "\<equiv>"} & @{thm (rhs) UP.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
  2190   @{thm (lhs) UP.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & 
  2190   @{thm (lhs) UP.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & 
  2191      @{text "\<equiv>"} & @{thm (rhs) UP.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
  2191      @{text "\<equiv>"} & @{thm (rhs) UP.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
  2192   @{thm (lhs) UP.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) UP.simps(6)}
  2192   @{thm (lhs) UP.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) UP.simps(6)}
  2193   \end{tabular}
  2193   \end{tabular}
  2194   \end{center}
  2194   \end{center}
  2195 
  2195 
  2196   \noindent
  2196   \noindent
  2197   and use \eqref{supseqprops} establish that @{thm lang_UP} holds. This shows
  2197   and use \eqref{supseqprops} to establish that @{thm lang_UP} holds. This shows
  2198   that @{term "SUBSEQ A"} is regular provided @{text A} is.
  2198   that @{term "SUBSEQ A"} is regular, provided @{text A} is.
  2199   \end{proof}
  2199   \end{proof}
  2200 
  2200 
  2201   \noindent
  2201   \noindent
  2202   Now we can prove our main lemma, namely
  2202   Now we can prove our main lemma w.r.t.~@{const "SUPSEQ"}, namely
  2203 
  2203 
  2204   \begin{lmm}\label{mset}
  2204   \begin{lmm}\label{mset}
  2205   For every language @{text A}, there exists a finite language @{text M} such that
  2205   For every language @{text A}, there exists a finite language @{text M} such that
  2206   \begin{center}
  2206   \begin{center}
  2207   \mbox{@{term "SUPSEQ M = SUPSEQ A"}}\;.
  2207   \mbox{@{term "SUPSEQ M = SUPSEQ A"}}\;.
  2215   \begin{center}
  2215   \begin{center}
  2216   @{thm minimal_def}
  2216   @{thm minimal_def}
  2217   \end{center}
  2217   \end{center}
  2218 
  2218 
  2219   \noindent
  2219   \noindent
  2220   By Higman's lemma \eqref{higman} we know
  2220   By Higman's Lemma \eqref{higman} we know
  2221   that @{term "M \<equiv> {x \<in> A. minimal x A}"} is finite, since every minimal element is incomparable, 
  2221   that @{term "M \<equiv> {x \<in> A. minimal x A}"} is finite, since every minimal element is incomparable, 
  2222   except with itself.
  2222   except with itself.
  2223   It is also straightforward to show that @{term "SUPSEQ M \<subseteq> SUPSEQ A"}. For
  2223   It is also straightforward to show that @{term "SUPSEQ M \<subseteq> SUPSEQ A"}. For
  2224   the other direction we have  @{term "x \<in> SUPSEQ A"}. From this we can obtain 
  2224   the other direction we have  @{term "x \<in> SUPSEQ A"}. From this we can obtain 
  2225   a @{text y} such that @{term "y \<in> A"} and @{term "y \<preceq> x"}. Since we know that
  2225   a @{text y} such that @{term "y \<in> A"} and @{term "y \<preceq> x"}. Since we know that
  2234   \end{proof}
  2234   \end{proof}
  2235 
  2235 
  2236   \noindent
  2236   \noindent
  2237   This lemma allows us to establish the second part of Lemma~\ref{subseqreg}.
  2237   This lemma allows us to establish the second part of Lemma~\ref{subseqreg}.
  2238 
  2238 
  2239   \begin{proof}[The Second Part of Lemma~\ref{subseqreg}]
  2239   \begin{proof}[Proof of the Second Part of Lemma~\ref{subseqreg}]
  2240   Given any language @{text A}, by Lemma~\ref{mset} we know there exists
  2240   Given any language @{text A}, by Lemma~\ref{mset} we know there exists
  2241   a finite, and thus regular, language @{text M}. We further have @{term "SUPSEQ M = SUPSEQ A"},
  2241   a finite, and thus regular, language @{text M}. We further have @{term "SUPSEQ M = SUPSEQ A"},
  2242   which establishes the second part.    
  2242   which establishes the second part.    
  2243   \end{proof}
  2243   \end{proof}
  2244 
  2244 
  2249   \begin{equation}\label{compl}
  2249   \begin{equation}\label{compl}
  2250   @{thm SUBSEQ_complement}
  2250   @{thm SUBSEQ_complement}
  2251   \end{equation}
  2251   \end{equation}
  2252 
  2252 
  2253   \noindent
  2253   \noindent
  2254   holds. Now the first part is a simple consequence of the second part.
  2254   holds. Now the first part of~\ref{subseqreg} is a simple consequence of the second part.
  2255 
  2255 
  2256   \begin{proof}[The First Part of Lemma~\ref{subseqreg}]
  2256   \begin{proof}[Proof of the First Part of Lemma~\ref{subseqreg}]
  2257   By the second part of Lemma~\ref{subseqreg}, we know the right-hand side of \eqref{compl}
  2257   By the second part of Lemma~\ref{subseqreg}, we know the right-hand side of \eqref{compl}
  2258   is regular, which means @{term "- SUBSEQ A"} is regular. But since
  2258   is regular, which means @{term "- SUBSEQ A"} is regular. But since
  2259   we established already that regularity is preserved under complement, also @{term "SUBSEQ A"}
  2259   we established already that regularity is preserved under complement, also @{term "SUBSEQ A"}
  2260   must be regular. 
  2260   must be regular. 
  2261   \end{proof}
  2261   \end{proof}
  2417   formalisation in Nurpl, but from what is shown in the Nuprl Math Library
  2417   formalisation in Nurpl, but from what is shown in the Nuprl Math Library
  2418   about their development it seems substantially larger than ours. We attribute
  2418   about their development it seems substantially larger than ours. We attribute
  2419   this to our use of regular expressions, which meant we did not need to `fight' 
  2419   this to our use of regular expressions, which meant we did not need to `fight' 
  2420   the theorem prover. The code of
  2420   the theorem prover. The code of
  2421   our formalisation can be found in the Archive of Formal Proofs at
  2421   our formalisation can be found in the Archive of Formal Proofs at
  2422   \mbox{\url{http://afp.sf.net/entries/Myhill-Nerode.shtml}} \cite{myhillnerodeafp11}.\medskip
  2422   \mbox{\url{http://afp.sourceforge.net/devel-entries/Myhill-Nerode.shtml}} \cite{myhillnerodeafp11}.\medskip
  2423   
  2423   
  2424   \noindent
  2424   \noindent
  2425   {\bf Acknowledgements:}
  2425   {\bf Acknowledgements:}
  2426   We are grateful for the comments we received from Larry
  2426   We are grateful for the comments we received from Larry
  2427   Paulson.
  2427   Paulson, Tobias Nipkow made us aware of the properties in Lemma~\ref{subseqreg}
       
  2428   and Tjark Weber helped us with their proofs.
  2428 
  2429 
  2429 *}
  2430 *}
  2430 
  2431 
  2431 
  2432 
  2432 (*<*)
  2433 (*<*)