482 regular expressions. This theorem gives necessary and sufficient conditions |
482 regular expressions. This theorem gives necessary and sufficient conditions |
483 for when a language is regular. As a corollary of this theorem we can easily |
483 for when a language is regular. As a corollary of this theorem we can easily |
484 establish the usual closure properties, including complementation, for |
484 establish the usual closure properties, including complementation, for |
485 regular languages. We use the Continuation Lemma, which is also a corollary |
485 regular languages. We use the Continuation Lemma, which is also a corollary |
486 of the Myhill-Nerode Theorem, for establishing |
486 of the Myhill-Nerode Theorem, for establishing |
487 the non-regularity of the language @{text "a\<^isup>nb\<^isup>n"}.\medskip |
487 the non-regularity of the language @{text "a\<^sup>nb\<^sup>n"}.\medskip |
488 |
488 |
489 \noindent |
489 \noindent |
490 {\bf Contributions:} There is an extensive literature on regular languages. |
490 {\bf Contributions:} There is an extensive literature on regular languages. |
491 To our best knowledge, our proof of the Myhill-Nerode Theorem is the first |
491 To our best knowledge, our proof of the Myhill-Nerode Theorem is the first |
492 that is based on regular expressions, only. The part of this theorem stating |
492 that is based on regular expressions, only. The part of this theorem stating |
557 formalisation.\footnote{Available under \citeN{myhillnerodeafp11} in the Archive of Formal Proofs at\\ |
557 formalisation.\footnote{Available under \citeN{myhillnerodeafp11} in the Archive of Formal Proofs at\\ |
558 \url{http://afp.sourceforge.net/entries/Myhill-Nerode.shtml}.} |
558 \url{http://afp.sourceforge.net/entries/Myhill-Nerode.shtml}.} |
559 |
559 |
560 The notation in Isabelle/HOL for the quotient of a language @{text A} |
560 The notation in Isabelle/HOL for the quotient of a language @{text A} |
561 according to an equivalence relation @{term REL} is @{term "A // REL"}. We |
561 according to an equivalence relation @{term REL} is @{term "A // REL"}. We |
562 will write @{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined as |
562 will write @{text "\<lbrakk>x\<rbrakk>\<^sub>\<approx>"} for the equivalence class defined as |
563 \mbox{@{text "{y | y \<approx> x}"}}, and have @{text "x \<approx> y"} if and only if @{text |
563 \mbox{@{text "{y | y \<approx> x}"}}, and have @{text "x \<approx> y"} if and only if @{text |
564 "\<lbrakk>x\<rbrakk>\<^isub>\<approx> = \<lbrakk>y\<rbrakk>\<^isub>\<approx>"}. |
564 "\<lbrakk>x\<rbrakk>\<^sub>\<approx> = \<lbrakk>y\<rbrakk>\<^sub>\<approx>"}. |
565 |
565 |
566 |
566 |
567 Central to our proof will be the solution of equational systems |
567 Central to our proof will be the solution of equational systems |
568 involving equivalence classes of languages. For this we will use Arden's Lemma |
568 involving equivalence classes of languages. For this we will use Arden's Lemma |
569 (see for example \citet[Page 100]{Sakarovitch09}), |
569 (see for example \citet[Page 100]{Sakarovitch09}), |
602 \begin{center} |
602 \begin{center} |
603 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
603 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
604 @{thm (lhs) lang.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(1)}\\ |
604 @{thm (lhs) lang.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(1)}\\ |
605 @{thm (lhs) lang.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(2)}\\ |
605 @{thm (lhs) lang.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(2)}\\ |
606 @{thm (lhs) lang.simps(3)[where a="c"]} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(3)[where a="c"]}\\ |
606 @{thm (lhs) lang.simps(3)[where a="c"]} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(3)[where a="c"]}\\ |
607 @{thm (lhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} & |
607 @{thm (lhs) lang.simps(4)[where ?r="r\<^sub>1" and ?s="r\<^sub>2"]} & @{text "\<equiv>"} & |
608 @{thm (rhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\ |
608 @{thm (rhs) lang.simps(4)[where ?r="r\<^sub>1" and ?s="r\<^sub>2"]}\\ |
609 @{thm (lhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} & |
609 @{thm (lhs) lang.simps(5)[where ?r="r\<^sub>1" and ?s="r\<^sub>2"]} & @{text "\<equiv>"} & |
610 @{thm (rhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\ |
610 @{thm (rhs) lang.simps(5)[where ?r="r\<^sub>1" and ?s="r\<^sub>2"]}\\ |
611 @{thm (lhs) lang.simps(6)[where r="r"]} & @{text "\<equiv>"} & |
611 @{thm (lhs) lang.simps(6)[where r="r"]} & @{text "\<equiv>"} & |
612 @{thm (rhs) lang.simps(6)[where r="r"]}\\ |
612 @{thm (rhs) lang.simps(6)[where r="r"]}\\ |
613 \end{tabular} |
613 \end{tabular} |
614 \end{center} |
614 \end{center} |
615 |
615 |
663 partitions the set of all strings, @{text "UNIV"}, into a set of disjoint |
663 partitions the set of all strings, @{text "UNIV"}, into a set of disjoint |
664 equivalence classes. To illustrate this quotient construction, let us give a simple |
664 equivalence classes. To illustrate this quotient construction, let us give a simple |
665 example: consider the regular language built up over the alphabet @{term "{a, b}"} and |
665 example: consider the regular language built up over the alphabet @{term "{a, b}"} and |
666 containing just the string two strings @{text "[a]"} and @{text "[a, b]"}. The |
666 containing just the string two strings @{text "[a]"} and @{text "[a, b]"}. The |
667 relation @{term "\<approx>({[a], [a, b]})"} partitions @{text UNIV} |
667 relation @{term "\<approx>({[a], [a, b]})"} partitions @{text UNIV} |
668 into four equivalence classes @{text "X\<^isub>1"}, @{text "X\<^isub>2"}, @{text "X\<^isub>3"} and @{text "X\<^isub>4"} |
668 into four equivalence classes @{text "X\<^sub>1"}, @{text "X\<^sub>2"}, @{text "X\<^sub>3"} and @{text "X\<^sub>4"} |
669 as follows |
669 as follows |
670 |
670 |
671 \begin{center} |
671 \begin{center} |
672 \begin{tabular}{l} |
672 \begin{tabular}{l} |
673 @{text "X\<^isub>1 = {[]}"}\\ |
673 @{text "X\<^sub>1 = {[]}"}\\ |
674 @{text "X\<^isub>2 = {[a]}"}\\ |
674 @{text "X\<^sub>2 = {[a]}"}\\ |
675 @{text "X\<^isub>3 = {[a, b]}"}\\ |
675 @{text "X\<^sub>3 = {[a, b]}"}\\ |
676 @{text "X\<^isub>4 = UNIV - {[], [a], [a, b]}"} |
676 @{text "X\<^sub>4 = UNIV - {[], [a], [a, b]}"} |
677 \end{tabular} |
677 \end{tabular} |
678 \end{center} |
678 \end{center} |
679 |
679 |
680 One direction of the Myhill-Nerode Theorem establishes |
680 One direction of the Myhill-Nerode Theorem establishes |
681 that if there are finitely many equivalence classes, like in the example above, then |
681 that if there are finitely many equivalence classes, like in the example above, then |
730 %(with the help of a character). |
730 %(with the help of a character). |
731 In our concrete example we have |
731 In our concrete example we have |
732 |
732 |
733 \begin{center} |
733 \begin{center} |
734 \begin{tabular}{l} |
734 \begin{tabular}{l} |
735 @{term "X\<^isub>1 \<Turnstile>a\<Rightarrow> X\<^isub>2"},\; @{term "X\<^isub>1 \<Turnstile>b\<Rightarrow> X\<^isub>4"};\\ |
735 @{term "X\<^sub>1 \<Turnstile>a\<Rightarrow> X\<^sub>2"},\; @{term "X\<^sub>1 \<Turnstile>b\<Rightarrow> X\<^sub>4"};\\ |
736 @{term "X\<^isub>2 \<Turnstile>b\<Rightarrow> X\<^isub>3"},\; @{term "X\<^isub>2 \<Turnstile>a\<Rightarrow> X\<^isub>4"};\\ |
736 @{term "X\<^sub>2 \<Turnstile>b\<Rightarrow> X\<^sub>3"},\; @{term "X\<^sub>2 \<Turnstile>a\<Rightarrow> X\<^sub>4"};\\ |
737 @{term "X\<^isub>3 \<Turnstile>a\<Rightarrow> X\<^isub>4"},\; @{term "X\<^isub>3 \<Turnstile>b\<Rightarrow> X\<^isub>4"} and\\ |
737 @{term "X\<^sub>3 \<Turnstile>a\<Rightarrow> X\<^sub>4"},\; @{term "X\<^sub>3 \<Turnstile>b\<Rightarrow> X\<^sub>4"} and\\ |
738 @{term "X\<^isub>4 \<Turnstile>a\<Rightarrow> X\<^isub>4"},\; @{term "X\<^isub>4 \<Turnstile>b\<Rightarrow> X\<^isub>4"}. |
738 @{term "X\<^sub>4 \<Turnstile>a\<Rightarrow> X\<^sub>4"},\; @{term "X\<^sub>4 \<Turnstile>b\<Rightarrow> X\<^sub>4"}. |
739 \end{tabular} |
739 \end{tabular} |
740 \end{center} |
740 \end{center} |
741 |
741 |
742 Next we construct an \emph{initial equational system} that |
742 Next we construct an \emph{initial equational system} that |
743 contains an equation for each equivalence class. We first give |
743 contains an equation for each equivalence class. We first give |
744 an informal description of this construction. Suppose we have |
744 an informal description of this construction. Suppose we have |
745 the equivalence classes @{text "X\<^isub>1,\<dots>,X\<^isub>n"}, there must be one and only one that |
745 the equivalence classes @{text "X\<^sub>1,\<dots>,X\<^sub>n"}, there must be one and only one that |
746 contains the empty string @{text "[]"} (since equivalence classes are disjoint). |
746 contains the empty string @{text "[]"} (since equivalence classes are disjoint). |
747 Let us assume @{text "[] \<in> X\<^isub>1"}. We build the following initial equational system |
747 Let us assume @{text "[] \<in> X\<^sub>1"}. We build the following initial equational system |
748 |
748 |
749 \begin{center} |
749 \begin{center} |
750 \begin{tabular}{rcl} |
750 \begin{tabular}{rcl} |
751 @{text "X\<^isub>1"} & @{text "="} & @{text "(Y\<^isub>1\<^isub>1, ATOM c\<^isub>1\<^isub>1) + \<dots> + (Y\<^isub>1\<^isub>p, ATOM c\<^isub>1\<^isub>p) + \<lambda>(ONE)"} \\ |
751 @{text "X\<^sub>1"} & @{text "="} & @{text "(Y\<^sub>1\<^sub>1, ATOM c\<^sub>1\<^sub>1) + \<dots> + (Y\<^sub>1\<^sub>p, ATOM c\<^sub>1\<^sub>p) + \<lambda>(ONE)"} \\ |
752 @{text "X\<^isub>2"} & @{text "="} & @{text "(Y\<^isub>2\<^isub>1, ATOM c\<^isub>2\<^isub>1) + \<dots> + (Y\<^isub>2\<^isub>o, ATOM c\<^isub>2\<^isub>o)"} \\ |
752 @{text "X\<^sub>2"} & @{text "="} & @{text "(Y\<^sub>2\<^sub>1, ATOM c\<^sub>2\<^sub>1) + \<dots> + (Y\<^sub>2\<^sub>o, ATOM c\<^sub>2\<^sub>o)"} \\ |
753 & $\vdots$ \\ |
753 & $\vdots$ \\ |
754 @{text "X\<^isub>n"} & @{text "="} & @{text "(Y\<^isub>n\<^isub>1, ATOM c\<^isub>n\<^isub>1) + \<dots> + (Y\<^isub>n\<^isub>q, ATOM c\<^isub>n\<^isub>q)"}\\ |
754 @{text "X\<^sub>n"} & @{text "="} & @{text "(Y\<^sub>n\<^sub>1, ATOM c\<^sub>n\<^sub>1) + \<dots> + (Y\<^sub>n\<^sub>q, ATOM c\<^sub>n\<^sub>q)"}\\ |
755 \end{tabular} |
755 \end{tabular} |
756 \end{center} |
756 \end{center} |
757 |
757 |
758 \noindent |
758 \noindent |
759 where the terms @{text "(Y\<^isub>i\<^isub>j, ATOM c\<^isub>i\<^isub>j)"} are pairs consisting of an equivalence class and |
759 where the terms @{text "(Y\<^sub>i\<^sub>j, ATOM c\<^sub>i\<^sub>j)"} are pairs consisting of an equivalence class and |
760 a regular expression. In the initial equational system, they |
760 a regular expression. In the initial equational system, they |
761 stand for all transitions @{term "Y\<^isub>i\<^isub>j \<Turnstile>c\<^isub>i\<^isub>j\<Rightarrow> |
761 stand for all transitions @{term "Y\<^sub>i\<^sub>j \<Turnstile>c\<^sub>i\<^sub>j\<Rightarrow> |
762 X\<^isub>i"}. |
762 X\<^sub>i"}. |
763 %The intuition behind the equational system is that every |
763 %The intuition behind the equational system is that every |
764 %equation @{text "X\<^isub>i = rhs\<^isub>i"} in this system |
764 %equation @{text "X\<^sub>i = rhs\<^sub>i"} in this system |
765 %corresponds roughly to a state of an automaton whose name is @{text X\<^isub>i} and its predecessor states |
765 %corresponds roughly to a state of an automaton whose name is @{text X\<^sub>i} and its predecessor states |
766 %are the @{text "Y\<^isub>i\<^isub>j"}; the @{text "c\<^isub>i\<^isub>j"} are the labels of the transitions from these |
766 %are the @{text "Y\<^sub>i\<^sub>j"}; the @{text "c\<^sub>i\<^sub>j"} are the labels of the transitions from these |
767 %predecessor states to @{text X\<^isub>i}. |
767 %predecessor states to @{text X\<^sub>i}. |
768 There can only be |
768 There can only be |
769 finitely many terms of the form @{text "(Y\<^isub>i\<^isub>j, ATOM c\<^isub>i\<^isub>j)"} in a right-hand side |
769 finitely many terms of the form @{text "(Y\<^sub>i\<^sub>j, ATOM c\<^sub>i\<^sub>j)"} in a right-hand side |
770 since by assumption there are only finitely many |
770 since by assumption there are only finitely many |
771 equivalence classes and only finitely many characters. |
771 equivalence classes and only finitely many characters. |
772 The term @{text "\<lambda>(ONE)"} in the first equation acts as a marker for the initial state, that |
772 The term @{text "\<lambda>(ONE)"} in the first equation acts as a marker for the initial state, that |
773 is the equivalence class |
773 is the equivalence class |
774 containing the empty string @{text "[]"}.\footnote{Note that we mark, roughly speaking, the |
774 containing the empty string @{text "[]"}.\footnote{Note that we mark, roughly speaking, the |
781 reason why we have to use our reversed version of Arden's Lemma.} |
781 reason why we have to use our reversed version of Arden's Lemma.} |
782 In our running example we have the initial equational system |
782 In our running example we have the initial equational system |
783 % |
783 % |
784 \begin{equation}\label{exmpcs} |
784 \begin{equation}\label{exmpcs} |
785 \mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
785 \mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
786 @{term "X\<^isub>1"} & @{text "="} & @{text "\<lambda>(ONE)"}\\ |
786 @{term "X\<^sub>1"} & @{text "="} & @{text "\<lambda>(ONE)"}\\ |
787 @{term "X\<^isub>2"} & @{text "="} & @{text "(X\<^isub>1, ATOM a)"}\\ |
787 @{term "X\<^sub>2"} & @{text "="} & @{text "(X\<^sub>1, ATOM a)"}\\ |
788 @{term "X\<^isub>3"} & @{text "="} & @{text "(X\<^isub>2, ATOM b)"}\\ |
788 @{term "X\<^sub>3"} & @{text "="} & @{text "(X\<^sub>2, ATOM b)"}\\ |
789 @{term "X\<^isub>4"} & @{text "="} & @{text "(X\<^isub>1, ATOM b) + (X\<^isub>2, ATOM a) + (X\<^isub>3, ATOM a)"}\\ |
789 @{term "X\<^sub>4"} & @{text "="} & @{text "(X\<^sub>1, ATOM b) + (X\<^sub>2, ATOM a) + (X\<^sub>3, ATOM a)"}\\ |
790 & & \mbox{}\hspace{0mm}@{text "+ (X\<^isub>3, ATOM b) + (X\<^isub>4, ATOM a) + (X\<^isub>4, ATOM b)"}\\ |
790 & & \mbox{}\hspace{0mm}@{text "+ (X\<^sub>3, ATOM b) + (X\<^sub>4, ATOM a) + (X\<^sub>4, ATOM b)"}\\ |
791 \end{tabular}} |
791 \end{tabular}} |
792 \end{equation} |
792 \end{equation} |
793 |
793 |
794 \noindent |
794 \noindent |
795 Overloading the function @{text \<calL>} for the two kinds of terms in the |
795 Overloading the function @{text \<calL>} for the two kinds of terms in the |
800 @{thm (rhs) lang_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} |
800 @{thm (rhs) lang_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm} |
801 @{thm lang_trm.simps(1)[where r="r", THEN eq_reflection]} |
801 @{thm lang_trm.simps(1)[where r="r", THEN eq_reflection]} |
802 \end{center} |
802 \end{center} |
803 |
803 |
804 \noindent |
804 \noindent |
805 and we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations |
805 and we can prove for @{text "X\<^sub>2\<^sub>.\<^sub>.\<^sub>n"} that the following equations |
806 % |
806 % |
807 \begin{equation}\label{inv1} |
807 \begin{equation}\label{inv1} |
808 @{text "X\<^isub>i = \<calL>(Y\<^isub>i\<^isub>1, ATOM c\<^isub>i\<^isub>1) \<union> \<dots> \<union> \<calL>(Y\<^isub>i\<^isub>q, ATOM c\<^isub>i\<^isub>q)"}. |
808 @{text "X\<^sub>i = \<calL>(Y\<^sub>i\<^sub>1, ATOM c\<^sub>i\<^sub>1) \<union> \<dots> \<union> \<calL>(Y\<^sub>i\<^sub>q, ATOM c\<^sub>i\<^sub>q)"}. |
809 \end{equation} |
809 \end{equation} |
810 |
810 |
811 \noindent |
811 \noindent |
812 hold. Similarly for @{text "X\<^isub>1"} we can show the following equation |
812 hold. Similarly for @{text "X\<^sub>1"} we can show the following equation |
813 % |
813 % |
814 \begin{equation}\label{inv2} |
814 \begin{equation}\label{inv2} |
815 @{text "X\<^isub>1 = \<calL>(Y\<^isub>1\<^isub>1, ATOM c\<^isub>1\<^isub>1) \<union> \<dots> \<union> \<calL>(Y\<^isub>1\<^isub>p, ATOM c\<^isub>1\<^isub>p) \<union> \<calL>(\<lambda>(ONE))"}. |
815 @{text "X\<^sub>1 = \<calL>(Y\<^sub>1\<^sub>1, ATOM c\<^sub>1\<^sub>1) \<union> \<dots> \<union> \<calL>(Y\<^sub>1\<^sub>p, ATOM c\<^sub>1\<^sub>p) \<union> \<calL>(\<lambda>(ONE))"}. |
816 \end{equation} |
816 \end{equation} |
817 |
817 |
818 \noindent |
818 \noindent |
819 holds. The reason for adding the @{text \<lambda>}-marker to our initial equational system is |
819 holds. The reason for adding the @{text \<lambda>}-marker to our initial equational system is |
820 to obtain this equation: it only holds with the marker, since none of |
820 to obtain this equation: it only holds with the marker, since none of |
861 adjusting the remaining regular expressions appropriately. To define this adjustment |
861 adjusting the remaining regular expressions appropriately. To define this adjustment |
862 we define the \emph{append-operation} taking a term and a regular expression as argument |
862 we define the \emph{append-operation} taking a term and a regular expression as argument |
863 |
863 |
864 \begin{center} |
864 \begin{center} |
865 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
865 \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l} |
866 @{thm (lhs) Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
866 @{thm (lhs) Append_rexp.simps(2)[where X="Y" and r="r\<^sub>1" and rexp="r\<^sub>2", THEN eq_reflection]} |
867 & @{text "\<equiv>"} & |
867 & @{text "\<equiv>"} & |
868 @{thm (rhs) Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}\\ |
868 @{thm (rhs) Append_rexp.simps(2)[where X="Y" and r="r\<^sub>1" and rexp="r\<^sub>2", THEN eq_reflection]}\\ |
869 @{thm (lhs) Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
869 @{thm (lhs) Append_rexp.simps(1)[where r="r\<^sub>1" and rexp="r\<^sub>2", THEN eq_reflection]} |
870 & @{text "\<equiv>"} & |
870 & @{text "\<equiv>"} & |
871 @{thm (rhs) Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]} |
871 @{thm (rhs) Append_rexp.simps(1)[where r="r\<^sub>1" and rexp="r\<^sub>2", THEN eq_reflection]} |
872 \end{tabular} |
872 \end{tabular} |
873 \end{center} |
873 \end{center} |
874 |
874 |
875 \noindent |
875 \noindent |
876 We lift this operation to entire right-hand sides of equations, written as |
876 We lift this operation to entire right-hand sides of equations, written as |
889 \noindent |
889 \noindent |
890 In this definition, we first delete all terms of the form @{text "(X, r)"} from @{text rhs}; |
890 In this definition, we first delete all terms of the form @{text "(X, r)"} from @{text rhs}; |
891 then we calculate the combined regular expressions for all @{text r} coming |
891 then we calculate the combined regular expressions for all @{text r} coming |
892 from the deleted @{text "(X, r)"}, and take the @{const Star} of it; |
892 from the deleted @{text "(X, r)"}, and take the @{const Star} of it; |
893 finally we append this regular expression to @{text rhs'}. If we apply this |
893 finally we append this regular expression to @{text rhs'}. If we apply this |
894 operation to the right-hand side of @{text "X\<^isub>4"} in \eqref{exmpcs}, we obtain |
894 operation to the right-hand side of @{text "X\<^sub>4"} in \eqref{exmpcs}, we obtain |
895 the equation: |
895 the equation: |
896 |
896 |
897 \begin{center} |
897 \begin{center} |
898 \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
898 \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
899 @{term "X\<^isub>4"} & @{text "="} & |
899 @{term "X\<^sub>4"} & @{text "="} & |
900 @{text "(X\<^isub>1, TIMES (ATOM b) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM a, ATOM b})) +"}\\ |
900 @{text "(X\<^sub>1, TIMES (ATOM b) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM a, ATOM b})) +"}\\ |
901 & & @{text "(X\<^isub>2, TIMES (ATOM a) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM a, ATOM b})) +"}\\ |
901 & & @{text "(X\<^sub>2, TIMES (ATOM a) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM a, ATOM b})) +"}\\ |
902 & & @{text "(X\<^isub>3, TIMES (ATOM a) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM a, ATOM b})) +"}\\ |
902 & & @{text "(X\<^sub>3, TIMES (ATOM a) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM a, ATOM b})) +"}\\ |
903 & & @{text "(X\<^isub>3, TIMES (ATOM b) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM a, ATOM b}))"} |
903 & & @{text "(X\<^sub>3, TIMES (ATOM b) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM a, ATOM b}))"} |
904 \end{tabular} |
904 \end{tabular} |
905 \end{center} |
905 \end{center} |
906 |
906 |
907 |
907 |
908 \noindent |
908 \noindent |
909 That means we eliminated the recursive occurrence of @{text "X\<^isub>4"} on the |
909 That means we eliminated the recursive occurrence of @{text "X\<^sub>4"} on the |
910 right-hand side. |
910 right-hand side. |
911 |
911 |
912 It can be easily seen that the @{text "Arden"}-operation mimics Arden's |
912 It can be easily seen that the @{text "Arden"}-operation mimics Arden's |
913 Lemma on the level of equations. To ensure the non-emptiness condition of |
913 Lemma on the level of equations. To ensure the non-emptiness condition of |
914 Arden's Lemma we say that a right-hand side is @{text ardenable} provided |
914 Arden's Lemma we say that a right-hand side is @{text ardenable} provided |
950 the regular expression corresponding to the deleted terms; finally we append this |
950 the regular expression corresponding to the deleted terms; finally we append this |
951 regular expression to @{text "xrhs"} and union it up with @{text rhs'}. When we use |
951 regular expression to @{text "xrhs"} and union it up with @{text rhs'}. When we use |
952 the substitution operation we will arrange it so that @{text "xrhs"} does not contain |
952 the substitution operation we will arrange it so that @{text "xrhs"} does not contain |
953 any occurrence of @{text X}. For example substituting the first equation in |
953 any occurrence of @{text X}. For example substituting the first equation in |
954 \eqref{exmpcs} into the right-hand side of the second, thus eliminating the equivalence |
954 \eqref{exmpcs} into the right-hand side of the second, thus eliminating the equivalence |
955 class @{text "X\<^isub>1"}, gives us the equation |
955 class @{text "X\<^sub>1"}, gives us the equation |
956 % |
956 % |
957 \begin{equation}\label{exmpresult} |
957 \begin{equation}\label{exmpresult} |
958 \mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
958 \mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
959 @{term "X\<^isub>2"} & @{text "="} & @{text "\<lambda>(TIMES ONE (ATOM a))"} |
959 @{term "X\<^sub>2"} & @{text "="} & @{text "\<lambda>(TIMES ONE (ATOM a))"} |
960 \end{tabular}} |
960 \end{tabular}} |
961 \end{equation} |
961 \end{equation} |
962 |
962 |
963 With these two operations in place, we can define the operation that removes one equation |
963 With these two operations in place, we can define the operation that removes one equation |
964 from an equational systems @{text ES}. The operation @{const Subst_all} |
964 from an equational systems @{text ES}. The operation @{const Subst_all} |
1221 Solving the equational system of our running example gives as solution for the |
1221 Solving the equational system of our running example gives as solution for the |
1222 two final equivalence classes: |
1222 two final equivalence classes: |
1223 |
1223 |
1224 \begin{center} |
1224 \begin{center} |
1225 \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
1225 \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
1226 @{text "X\<^isub>2"} & @{text "="} & @{text "TIMES ONE (ATOM a)"}\\ |
1226 @{text "X\<^sub>2"} & @{text "="} & @{text "TIMES ONE (ATOM a)"}\\ |
1227 @{text "X\<^isub>3"} & @{text "="} & @{text "TIMES (TIMES ONE (ATOM a)) (ATOM b)"} |
1227 @{text "X\<^sub>3"} & @{text "="} & @{text "TIMES (TIMES ONE (ATOM a)) (ATOM b)"} |
1228 \end{tabular} |
1228 \end{tabular} |
1229 \end{center} |
1229 \end{center} |
1230 |
1230 |
1231 \noindent |
1231 \noindent |
1232 Combining them with $\bigplus$ gives us a regular expression for the language @{text "{[a], [a, b]}"}. |
1232 Combining them with $\bigplus$ gives us a regular expression for the language @{text "{[a], [a, b]}"}. |
1233 |
1233 |
1234 Note that our algorithm for solving equational systems provides also a method for |
1234 Note that our algorithm for solving equational systems provides also a method for |
1235 calculating a regular expression for the complement of a regular language: |
1235 calculating a regular expression for the complement of a regular language: |
1236 if we combine all regular |
1236 if we combine all regular |
1237 expressions corresponding to equivalence classes not in @{term "finals A"} |
1237 expressions corresponding to equivalence classes not in @{term "finals A"} |
1238 (in the running example @{text "X\<^isub>1"} and @{text "X\<^isub>4"}), |
1238 (in the running example @{text "X\<^sub>1"} and @{text "X\<^sub>4"}), |
1239 then we obtain a regular expression for the complement language @{term "- A"}. |
1239 then we obtain a regular expression for the complement language @{term "- A"}. |
1240 This is similar to the usual construction of a `complement automaton'. |
1240 This is similar to the usual construction of a `complement automaton'. |
1241 |
1241 |
1242 *} |
1242 *} |
1243 |
1243 |
1371 \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
1371 \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l} |
1372 @{thm (lhs) tag_Plus_def[where A="A" and B="B", THEN meta_eq_app]} & |
1372 @{thm (lhs) tag_Plus_def[where A="A" and B="B", THEN meta_eq_app]} & |
1373 @{text "\<equiv>"} & |
1373 @{text "\<equiv>"} & |
1374 @{thm (rhs) tag_Plus_def[where A="A" and B="B", THEN meta_eq_app]} \\ |
1374 @{thm (rhs) tag_Plus_def[where A="A" and B="B", THEN meta_eq_app]} \\ |
1375 @{thm (lhs) tag_Times_def[where ?A="A" and ?B="B"]}\;@{text "x"} & @{text "\<equiv>"} & |
1375 @{thm (lhs) tag_Times_def[where ?A="A" and ?B="B"]}\;@{text "x"} & @{text "\<equiv>"} & |
1376 @{text "(\<lbrakk>x\<rbrakk>\<^bsub>\<approx>A\<^esub>, {\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | x\<^isub>p \<in> A \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x})"}\\ |
1376 @{text "(\<lbrakk>x\<rbrakk>\<^bsub>\<approx>A\<^esub>, {\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | x\<^sub>p \<in> A \<and> (x\<^sub>p, x\<^sub>s) \<in> Partitions x})"}\\ |
1377 @{thm (lhs) tag_Star_def[where ?A="A", THEN meta_eq_app]} & @{text "\<equiv>"} & |
1377 @{thm (lhs) tag_Star_def[where ?A="A", THEN meta_eq_app]} & @{text "\<equiv>"} & |
1378 @{text "{\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^isub>p < x \<and> x\<^isub>p \<in> A\<^isup>\<star> \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x}"} |
1378 @{text "{\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^sub>p < x \<and> x\<^sub>p \<in> A\<^sup>\<star> \<and> (x\<^sub>p, x\<^sub>s) \<in> Partitions x}"} |
1379 \end{tabular} |
1379 \end{tabular} |
1380 \caption{Three tagging functions used the cases for @{term "PLUS"}, @{term "TIMES"} and @{term "STAR"} |
1380 \caption{Three tagging functions used the cases for @{term "PLUS"}, @{term "TIMES"} and @{term "STAR"} |
1381 regular expressions. The sets @{text A} and @{text B} are arbitrary languages instantiated |
1381 regular expressions. The sets @{text A} and @{text B} are arbitrary languages instantiated |
1382 in the proof with the induction hypotheses. \emph{Partitions} is a function |
1382 in the proof with the induction hypotheses. \emph{Partitions} is a function |
1383 that generates all possible partitions of a string.\label{tagfig}} |
1383 that generates all possible partitions of a string.\label{tagfig}} |
1400 and @{text Y} must be equal. Therefore \eqref{finiteimageD} allows us to conclude |
1400 and @{text Y} must be equal. Therefore \eqref{finiteimageD} allows us to conclude |
1401 with @{thm (concl) finite_eq_tag_rel}.\qed |
1401 with @{thm (concl) finite_eq_tag_rel}.\qed |
1402 \end{proof} |
1402 \end{proof} |
1403 |
1403 |
1404 \begin{lemma}\label{fintwo} |
1404 \begin{lemma}\label{fintwo} |
1405 Given two equivalence relations @{text "R\<^isub>1"} and @{text "R\<^isub>2"}, whereby |
1405 Given two equivalence relations @{text "R\<^sub>1"} and @{text "R\<^sub>2"}, whereby |
1406 @{text "R\<^isub>1"} refines @{text "R\<^isub>2"}. |
1406 @{text "R\<^sub>1"} refines @{text "R\<^sub>2"}. |
1407 If @{thm (prem 1) refined_partition_finite[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"]} |
1407 If @{thm (prem 1) refined_partition_finite[where ?R1.0="R\<^sub>1" and ?R2.0="R\<^sub>2"]} |
1408 then @{thm (concl) refined_partition_finite[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"]}. |
1408 then @{thm (concl) refined_partition_finite[where ?R1.0="R\<^sub>1" and ?R2.0="R\<^sub>2"]}. |
1409 \end{lemma} |
1409 \end{lemma} |
1410 |
1410 |
1411 \begin{proof} |
1411 \begin{proof} |
1412 We prove this lemma again using \eqref{finiteimageD}. This time we set @{text f} to |
1412 We prove this lemma again using \eqref{finiteimageD}. This time we set @{text f} to |
1413 be @{text "X \<mapsto>"}~@{term "{R\<^isub>1 `` {x} | x. x \<in> X}"}. It is easy to see that |
1413 be @{text "X \<mapsto>"}~@{term "{R\<^sub>1 `` {x} | x. x \<in> X}"}. It is easy to see that |
1414 @{term "finite (f ` (UNIV // R\<^isub>2))"} because it is a subset of @{term "Pow (UNIV // R\<^isub>1)"}, |
1414 @{term "finite (f ` (UNIV // R\<^sub>2))"} because it is a subset of @{term "Pow (UNIV // R\<^sub>1)"}, |
1415 which must be finite by assumption. What remains to be shown is that @{text f} is injective |
1415 which must be finite by assumption. What remains to be shown is that @{text f} is injective |
1416 on @{term "UNIV // R\<^isub>2"}. This is equivalent to showing that two equivalence |
1416 on @{term "UNIV // R\<^sub>2"}. This is equivalent to showing that two equivalence |
1417 classes, say @{text "X"} and @{text Y}, in @{term "UNIV // R\<^isub>2"} are equal, provided |
1417 classes, say @{text "X"} and @{text Y}, in @{term "UNIV // R\<^sub>2"} are equal, provided |
1418 @{text "f X = f Y"}. For @{text "X = Y"} to be equal, we have to find two elements |
1418 @{text "f X = f Y"}. For @{text "X = Y"} to be equal, we have to find two elements |
1419 @{text "x \<in> X"} and @{text "y \<in> Y"} such that they are @{text R\<^isub>2} related. |
1419 @{text "x \<in> X"} and @{text "y \<in> Y"} such that they are @{text R\<^sub>2} related. |
1420 We know there exists a @{text "x \<in> X"} with \mbox{@{term "X = R\<^isub>2 `` {x}"}}. |
1420 We know there exists a @{text "x \<in> X"} with \mbox{@{term "X = R\<^sub>2 `` {x}"}}. |
1421 From the latter fact we can infer that @{term "R\<^isub>1 ``{x} \<in> f X"} |
1421 From the latter fact we can infer that @{term "R\<^sub>1 ``{x} \<in> f X"} |
1422 and further @{term "R\<^isub>1 ``{x} \<in> f Y"}. This means we can obtain a @{text y} |
1422 and further @{term "R\<^sub>1 ``{x} \<in> f Y"}. This means we can obtain a @{text y} |
1423 such that @{term "R\<^isub>1 `` {x} = R\<^isub>1 `` {y}"} holds. Consequently @{text x} and @{text y} |
1423 such that @{term "R\<^sub>1 `` {x} = R\<^sub>1 `` {y}"} holds. Consequently @{text x} and @{text y} |
1424 are @{text "R\<^isub>1"}-related. Since by assumption @{text "R\<^isub>1"} refines @{text "R\<^isub>2"}, |
1424 are @{text "R\<^sub>1"}-related. Since by assumption @{text "R\<^sub>1"} refines @{text "R\<^sub>2"}, |
1425 they must also be @{text "R\<^isub>2"}-related, as we need to show.\qed |
1425 they must also be @{text "R\<^sub>2"}-related, as we need to show.\qed |
1426 \end{proof} |
1426 \end{proof} |
1427 |
1427 |
1428 \noindent |
1428 \noindent |
1429 Chaining Lemma~\ref{finone} and \ref{fintwo} together, means in order to show |
1429 Chaining Lemma~\ref{finone} and \ref{fintwo} together, means in order to show |
1430 that @{term "UNIV // \<approx>(lang r)"} is finite, we have to construct a tagging-function whose |
1430 that @{term "UNIV // \<approx>(lang r)"} is finite, we have to construct a tagging-function whose |
1448 holds. The range of @{term "tag_Plus A B"} is a subset of this product |
1448 holds. The range of @{term "tag_Plus A B"} is a subset of this product |
1449 set---so finite. For the refinement proof-obligation, we know that @{term |
1449 set---so finite. For the refinement proof-obligation, we know that @{term |
1450 "(\<approx>A `` {x}, \<approx>B `` {x}) = (\<approx>A `` {y}, \<approx>B `` {y})"} holds by assumption. Then |
1450 "(\<approx>A `` {x}, \<approx>B `` {x}) = (\<approx>A `` {y}, \<approx>B `` {y})"} holds by assumption. Then |
1451 clearly either @{term "x \<approx>A y"} or @{term "x \<approx>B y"}, as we needed to |
1451 clearly either @{term "x \<approx>A y"} or @{term "x \<approx>B y"}, as we needed to |
1452 show. Finally we can discharge this case by setting @{text A} to @{term |
1452 show. Finally we can discharge this case by setting @{text A} to @{term |
1453 "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}.\qed |
1453 "lang r\<^sub>1"} and @{text B} to @{term "lang r\<^sub>2"}.\qed |
1454 \end{proof} |
1454 \end{proof} |
1455 |
1455 |
1456 \noindent |
1456 \noindent |
1457 The @{const TIMES}-case is slightly more complicated. We first prove the |
1457 The @{const TIMES}-case is slightly more complicated. We first prove the |
1458 following lemma, which will aid the proof about refinement. |
1458 following lemma, which will aid the proof about refinement. |
1488 \begin{center} |
1488 \begin{center} |
1489 \begin{tabular}{c} |
1489 \begin{tabular}{c} |
1490 \scalebox{1}{ |
1490 \scalebox{1}{ |
1491 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1491 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1492 \node[draw,minimum height=3.8ex, fill] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ }; |
1492 \node[draw,minimum height=3.8ex, fill] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ }; |
1493 \node[draw,minimum height=3.8ex, right=-0.03em of x, fill] (za) { $\hspace{0.6em}@{text "z\<^isub>p"}\hspace{0.6em}$ }; |
1493 \node[draw,minimum height=3.8ex, right=-0.03em of x, fill] (za) { $\hspace{0.6em}@{text "z\<^sub>p"}\hspace{0.6em}$ }; |
1494 \node[draw,minimum height=3.8ex, right=-0.03em of za, fill] (zza) { $\hspace{2.6em}@{text "z\<^isub>s"}\hspace{2.6em}$ }; |
1494 \node[draw,minimum height=3.8ex, right=-0.03em of za, fill] (zza) { $\hspace{2.6em}@{text "z\<^sub>s"}\hspace{2.6em}$ }; |
1495 |
1495 |
1496 \draw[decoration={brace,transform={yscale=3}},decorate] |
1496 \draw[decoration={brace,transform={yscale=3}},decorate] |
1497 (x.north west) -- ($(za.north west)+(0em,0em)$) |
1497 (x.north west) -- ($(za.north west)+(0em,0em)$) |
1498 node[midway, above=0.5em]{@{text x}}; |
1498 node[midway, above=0.5em]{@{text x}}; |
1499 |
1499 |
1505 ($(x.north west)+(0em,3ex)$) -- ($(zza.north east)+(0em,3ex)$) |
1505 ($(x.north west)+(0em,3ex)$) -- ($(zza.north east)+(0em,3ex)$) |
1506 node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
1506 node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
1507 |
1507 |
1508 \draw[decoration={brace,transform={yscale=3}},decorate] |
1508 \draw[decoration={brace,transform={yscale=3}},decorate] |
1509 ($(za.south east)+(0em,0ex)$) -- ($(x.south west)+(0em,0ex)$) |
1509 ($(za.south east)+(0em,0ex)$) -- ($(x.south west)+(0em,0ex)$) |
1510 node[midway, below=0.5em]{@{text "x @ z\<^isub>p \<in> A"}}; |
1510 node[midway, below=0.5em]{@{text "x @ z\<^sub>p \<in> A"}}; |
1511 |
1511 |
1512 \draw[decoration={brace,transform={yscale=3}},decorate] |
1512 \draw[decoration={brace,transform={yscale=3}},decorate] |
1513 ($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$) |
1513 ($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$) |
1514 node[midway, below=0.5em]{@{text "z\<^isub>s \<in> B"}}; |
1514 node[midway, below=0.5em]{@{text "z\<^sub>s \<in> B"}}; |
1515 \end{tikzpicture}} |
1515 \end{tikzpicture}} |
1516 \\[2mm] |
1516 \\[2mm] |
1517 \scalebox{1}{ |
1517 \scalebox{1}{ |
1518 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1518 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1519 \node[draw,minimum height=3.8ex, fill] (xa) { $\hspace{3em}@{text "x\<^isub>p"}\hspace{3em}$ }; |
1519 \node[draw,minimum height=3.8ex, fill] (xa) { $\hspace{3em}@{text "x\<^sub>p"}\hspace{3em}$ }; |
1520 \node[draw,minimum height=3.8ex, right=-0.03em of xa, fill] (xxa) { $\hspace{0.2em}@{text "x\<^isub>s"}\hspace{0.2em}$ }; |
1520 \node[draw,minimum height=3.8ex, right=-0.03em of xa, fill] (xxa) { $\hspace{0.2em}@{text "x\<^sub>s"}\hspace{0.2em}$ }; |
1521 \node[draw,minimum height=3.8ex, right=-0.03em of xxa, fill] (z) { $\hspace{5em}@{text z}\hspace{5em}$ }; |
1521 \node[draw,minimum height=3.8ex, right=-0.03em of xxa, fill] (z) { $\hspace{5em}@{text z}\hspace{5em}$ }; |
1522 |
1522 |
1523 \draw[decoration={brace,transform={yscale=3}},decorate] |
1523 \draw[decoration={brace,transform={yscale=3}},decorate] |
1524 (xa.north west) -- ($(xxa.north east)+(0em,0em)$) |
1524 (xa.north west) -- ($(xxa.north east)+(0em,0em)$) |
1525 node[midway, above=0.5em]{@{text x}}; |
1525 node[midway, above=0.5em]{@{text x}}; |
1532 ($(xa.north west)+(0em,3ex)$) -- ($(z.north east)+(0em,3ex)$) |
1532 ($(xa.north west)+(0em,3ex)$) -- ($(z.north east)+(0em,3ex)$) |
1533 node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
1533 node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}}; |
1534 |
1534 |
1535 \draw[decoration={brace,transform={yscale=3}},decorate] |
1535 \draw[decoration={brace,transform={yscale=3}},decorate] |
1536 ($(z.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
1536 ($(z.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
1537 node[midway, below=0.5em]{@{term "x\<^isub>s @ z \<in> B"}}; |
1537 node[midway, below=0.5em]{@{term "x\<^sub>s @ z \<in> B"}}; |
1538 |
1538 |
1539 \draw[decoration={brace,transform={yscale=3}},decorate] |
1539 \draw[decoration={brace,transform={yscale=3}},decorate] |
1540 ($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$) |
1540 ($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$) |
1541 node[midway, below=0.5em]{@{term "x\<^isub>p \<in> A"}}; |
1541 node[midway, below=0.5em]{@{term "x\<^sub>p \<in> A"}}; |
1542 \end{tikzpicture}} |
1542 \end{tikzpicture}} |
1543 \end{tabular} |
1543 \end{tabular} |
1544 \end{center} |
1544 \end{center} |
1545 % |
1545 % |
1546 |
1546 |
1548 Either @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} |
1548 Either @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} |
1549 (first picture) or there is a prefix of @{text x} in @{text A} and the rest is in @{text B} |
1549 (first picture) or there is a prefix of @{text x} in @{text A} and the rest is in @{text B} |
1550 (second picture). In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. The first case |
1550 (second picture). In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. The first case |
1551 we will only go through if we know that @{term "x \<approx>A y"} holds @{text "("}@{text "*"}@{text ")"}. |
1551 we will only go through if we know that @{term "x \<approx>A y"} holds @{text "("}@{text "*"}@{text ")"}. |
1552 Because then |
1552 Because then |
1553 we can infer from @{term "x @ z\<^isub>p \<in> A"} that @{term "y @ z\<^isub>p \<in> A"} holds for all @{text "z\<^isub>p"}. |
1553 we can infer from @{term "x @ z\<^sub>p \<in> A"} that @{term "y @ z\<^sub>p \<in> A"} holds for all @{text "z\<^sub>p"}. |
1554 In the second case we only know that @{text "x\<^isub>p"} and @{text "x\<^isub>s"} is one possible partition |
1554 In the second case we only know that @{text "x\<^sub>p"} and @{text "x\<^sub>s"} is one possible partition |
1555 of the string @{text x}. We have to know that both @{text "x\<^isub>p"} and the |
1555 of the string @{text x}. We have to know that both @{text "x\<^sub>p"} and the |
1556 corresponding partition @{text "y\<^isub>p"} are in @{text "A"}, and that @{text "x\<^isub>s"} is `@{text B}-related' |
1556 corresponding partition @{text "y\<^sub>p"} are in @{text "A"}, and that @{text "x\<^sub>s"} is `@{text B}-related' |
1557 to @{text "y\<^isub>s"} @{text "("}@{text "**"}@{text ")"}. From the latter fact we can infer that @{text "y\<^isub>s @ z \<in> B"}. |
1557 to @{text "y\<^sub>s"} @{text "("}@{text "**"}@{text ")"}. From the latter fact we can infer that @{text "y\<^sub>s @ z \<in> B"}. |
1558 This will solve the second case. |
1558 This will solve the second case. |
1559 Taking the two requirements, @{text "("}@{text "*"}@{text ")"} and @{text "(**)"}, together we define the |
1559 Taking the two requirements, @{text "("}@{text "*"}@{text ")"} and @{text "(**)"}, together we define the |
1560 tagging-function in the @{const Times}-case as (see Fig.~\ref{tagfig}): |
1560 tagging-function in the @{const Times}-case as (see Fig.~\ref{tagfig}): |
1561 |
1561 |
1562 \begin{center} |
1562 \begin{center} |
1563 @{thm (lhs) tag_Times_def[where ?A="A" and ?B="B"]}\;@{text "x"}~@{text "\<equiv>"}~ |
1563 @{thm (lhs) tag_Times_def[where ?A="A" and ?B="B"]}\;@{text "x"}~@{text "\<equiv>"}~ |
1564 @{text "(\<lbrakk>x\<rbrakk>\<^bsub>\<approx>A\<^esub>, {\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | x\<^isub>p \<in> A \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x})"} |
1564 @{text "(\<lbrakk>x\<rbrakk>\<^bsub>\<approx>A\<^esub>, {\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | x\<^sub>p \<in> A \<and> (x\<^sub>p, x\<^sub>s) \<in> Partitions x})"} |
1565 \end{center} |
1565 \end{center} |
1566 |
1566 |
1567 \noindent |
1567 \noindent |
1568 Note that we have to make the assumption for all suffixes @{text "x\<^isub>s"}, since we do |
1568 Note that we have to make the assumption for all suffixes @{text "x\<^sub>s"}, since we do |
1569 not know anything about how the string @{term x} is partitioned. |
1569 not know anything about how the string @{term x} is partitioned. |
1570 With this definition in place, let us prove the @{const "Times"}-case. |
1570 With this definition in place, let us prove the @{const "Times"}-case. |
1571 |
1571 |
1572 \begin{proof}[@{const TIMES}-Case] |
1572 \begin{proof}[@{const TIMES}-Case] |
1573 If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
1573 If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"} |
1581 \end{center} |
1581 \end{center} |
1582 |
1582 |
1583 \noindent |
1583 \noindent |
1584 and @{term "x @ z \<in> A \<cdot> B"}, and have to establish @{term "y @ z \<in> A \<cdot> |
1584 and @{term "x @ z \<in> A \<cdot> B"}, and have to establish @{term "y @ z \<in> A \<cdot> |
1585 B"}. As shown in the pictures above, there are two cases to be |
1585 B"}. As shown in the pictures above, there are two cases to be |
1586 considered. First, there exists a @{text "z\<^isub>p"} and @{text |
1586 considered. First, there exists a @{text "z\<^sub>p"} and @{text |
1587 "z\<^isub>s"} such that @{term "x @ z\<^isub>p \<in> A"} and @{text "z\<^isub>s |
1587 "z\<^sub>s"} such that @{term "x @ z\<^sub>p \<in> A"} and @{text "z\<^sub>s |
1588 \<in> B"}. By the assumption about @{term "tag_Times A B"} we have @{term "\<approx>A |
1588 \<in> B"}. By the assumption about @{term "tag_Times A B"} we have @{term "\<approx>A |
1589 `` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Hence by the Myhill-Nerode |
1589 `` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Hence by the Myhill-Nerode |
1590 Relation @{term "y @ z\<^isub>p \<in> A"} holds. Using @{text "z\<^isub>s \<in> B"}, |
1590 Relation @{term "y @ z\<^sub>p \<in> A"} holds. Using @{text "z\<^sub>s \<in> B"}, |
1591 we can conclude in this case with @{term "y @ z \<in> A \<cdot> B"} (recall @{text |
1591 we can conclude in this case with @{term "y @ z \<in> A \<cdot> B"} (recall @{text |
1592 "z\<^isub>p @ z\<^isub>s = z"}). |
1592 "z\<^sub>p @ z\<^sub>s = z"}). |
1593 |
1593 |
1594 Second there exists a partition @{text "x\<^isub>p"} and @{text "x\<^isub>s"} with |
1594 Second there exists a partition @{text "x\<^sub>p"} and @{text "x\<^sub>s"} with |
1595 @{text "x\<^isub>p \<in> A"} and @{text "x\<^isub>s @ z \<in> B"}. We therefore have |
1595 @{text "x\<^sub>p \<in> A"} and @{text "x\<^sub>s @ z \<in> B"}. We therefore have |
1596 |
1596 |
1597 \begin{center} |
1597 \begin{center} |
1598 @{text "\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> \<in> {\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | x\<^isub>p \<in> A \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x}"} |
1598 @{text "\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> \<in> {\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | x\<^sub>p \<in> A \<and> (x\<^sub>p, x\<^sub>s) \<in> Partitions x}"} |
1599 \end{center} |
1599 \end{center} |
1600 |
1600 |
1601 \noindent |
1601 \noindent |
1602 and by the assumption about @{term "tag_Times A B"} also |
1602 and by the assumption about @{term "tag_Times A B"} also |
1603 |
1603 |
1604 \begin{center} |
1604 \begin{center} |
1605 @{text "\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> \<in> {\<lbrakk>y\<^isub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | y\<^isub>p \<in> A \<and> (y\<^isub>p, y\<^isub>s) \<in> Partitions y}"} |
1605 @{text "\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> \<in> {\<lbrakk>y\<^sub>s\<rbrakk>\<^bsub>\<approx>B\<^esub> | y\<^sub>p \<in> A \<and> (y\<^sub>p, y\<^sub>s) \<in> Partitions y}"} |
1606 \end{center} |
1606 \end{center} |
1607 |
1607 |
1608 \noindent |
1608 \noindent |
1609 This means there must be a partition @{text "y\<^isub>p"} and @{text "y\<^isub>s"} |
1609 This means there must be a partition @{text "y\<^sub>p"} and @{text "y\<^sub>s"} |
1610 such that @{term "y\<^isub>p \<in> A"} and @{term "\<approx>B `` {x\<^isub>s} = \<approx>B `` |
1610 such that @{term "y\<^sub>p \<in> A"} and @{term "\<approx>B `` {x\<^sub>s} = \<approx>B `` |
1611 {y\<^isub>s}"}. Unfolding the Myhill-Nerode Relation and together with the |
1611 {y\<^sub>s}"}. Unfolding the Myhill-Nerode Relation and together with the |
1612 facts that @{text "x\<^isub>p \<in> A"} and \mbox{@{text "x\<^isub>s @ z \<in> B"}}, we |
1612 facts that @{text "x\<^sub>p \<in> A"} and \mbox{@{text "x\<^sub>s @ z \<in> B"}}, we |
1613 obtain @{term "y\<^isub>p \<in> A"} and @{text "y\<^isub>s @ z \<in> B"}, as needed in |
1613 obtain @{term "y\<^sub>p \<in> A"} and @{text "y\<^sub>s @ z \<in> B"}, as needed in |
1614 this case. We again can complete the @{const TIMES}-case by setting @{text |
1614 this case. We again can complete the @{const TIMES}-case by setting @{text |
1615 A} to @{term "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}.\qed |
1615 A} to @{term "lang r\<^sub>1"} and @{text B} to @{term "lang r\<^sub>2"}.\qed |
1616 \end{proof} |
1616 \end{proof} |
1617 |
1617 |
1618 \noindent |
1618 \noindent |
1619 The case for @{const Star} is similar to @{const TIMES}, but poses a few |
1619 The case for @{const Star} is similar to @{const TIMES}, but poses a few |
1620 extra challenges. To deal with them, we define first the notion of a \emph{string |
1620 extra challenges. To deal with them, we define first the notion of a \emph{string |
1633 \begin{center} |
1633 \begin{center} |
1634 \scalebox{1}{ |
1634 \scalebox{1}{ |
1635 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1635 \begin{tikzpicture}[scale=0.8,fill=gray!20] |
1636 \node[draw,minimum height=3.8ex, fill] (xa) { $\hspace{4em}@{text "x\<^bsub>pmax\<^esub>"}\hspace{4em}$ }; |
1636 \node[draw,minimum height=3.8ex, fill] (xa) { $\hspace{4em}@{text "x\<^bsub>pmax\<^esub>"}\hspace{4em}$ }; |
1637 \node[draw,minimum height=3.8ex, right=-0.03em of xa, fill] (xxa) { $\hspace{0.5em}@{text "x\<^bsub>s\<^esub>"}\hspace{0.5em}$ }; |
1637 \node[draw,minimum height=3.8ex, right=-0.03em of xa, fill] (xxa) { $\hspace{0.5em}@{text "x\<^bsub>s\<^esub>"}\hspace{0.5em}$ }; |
1638 \node[draw,minimum height=3.8ex, right=-0.03em of xxa, fill] (za) { $\hspace{2em}@{text "z\<^isub>a"}\hspace{2em}$ }; |
1638 \node[draw,minimum height=3.8ex, right=-0.03em of xxa, fill] (za) { $\hspace{2em}@{text "z\<^sub>a"}\hspace{2em}$ }; |
1639 \node[draw,minimum height=3.8ex, right=-0.03em of za, fill] (zb) { $\hspace{7em}@{text "z\<^isub>b"}\hspace{7em}$ }; |
1639 \node[draw,minimum height=3.8ex, right=-0.03em of za, fill] (zb) { $\hspace{7em}@{text "z\<^sub>b"}\hspace{7em}$ }; |
1640 |
1640 |
1641 \draw[decoration={brace,transform={yscale=3}},decorate] |
1641 \draw[decoration={brace,transform={yscale=3}},decorate] |
1642 (xa.north west) -- ($(xxa.north east)+(0em,0em)$) |
1642 (xa.north west) -- ($(xxa.north east)+(0em,0em)$) |
1643 node[midway, above=0.5em]{@{text x}}; |
1643 node[midway, above=0.5em]{@{text x}}; |
1644 |
1644 |
1650 ($(xa.north west)+(0em,3ex)$) -- ($(zb.north east)+(0em,3ex)$) |
1650 ($(xa.north west)+(0em,3ex)$) -- ($(zb.north east)+(0em,3ex)$) |
1651 node[midway, above=0.8em]{@{term "x @ z \<in> A\<star>"}}; |
1651 node[midway, above=0.8em]{@{term "x @ z \<in> A\<star>"}}; |
1652 |
1652 |
1653 \draw[decoration={brace,transform={yscale=3}},decorate] |
1653 \draw[decoration={brace,transform={yscale=3}},decorate] |
1654 ($(za.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
1654 ($(za.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$) |
1655 node[midway, below=0.5em]{@{term "x\<^isub>s @ z\<^isub>a \<in> A"}}; |
1655 node[midway, below=0.5em]{@{term "x\<^sub>s @ z\<^sub>a \<in> A"}}; |
1656 |
1656 |
1657 \draw[decoration={brace,transform={yscale=3}},decorate] |
1657 \draw[decoration={brace,transform={yscale=3}},decorate] |
1658 ($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$) |
1658 ($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$) |
1659 node[midway, below=0.5em]{@{text "x\<^bsub>pmax\<^esub> \<in> A\<^isup>\<star>"}}; |
1659 node[midway, below=0.5em]{@{text "x\<^bsub>pmax\<^esub> \<in> A\<^sup>\<star>"}}; |
1660 |
1660 |
1661 \draw[decoration={brace,transform={yscale=3}},decorate] |
1661 \draw[decoration={brace,transform={yscale=3}},decorate] |
1662 ($(zb.south east)+(0em,0ex)$) -- ($(zb.south west)+(0em,0ex)$) |
1662 ($(zb.south east)+(0em,0ex)$) -- ($(zb.south west)+(0em,0ex)$) |
1663 node[midway, below=0.5em]{@{term "z\<^isub>b \<in> A\<star>"}}; |
1663 node[midway, below=0.5em]{@{term "z\<^sub>b \<in> A\<star>"}}; |
1664 |
1664 |
1665 \draw[decoration={brace,transform={yscale=3}},decorate] |
1665 \draw[decoration={brace,transform={yscale=3}},decorate] |
1666 ($(zb.south east)+(0em,-4ex)$) -- ($(xxa.south west)+(0em,-4ex)$) |
1666 ($(zb.south east)+(0em,-4ex)$) -- ($(xxa.south west)+(0em,-4ex)$) |
1667 node[midway, below=0.5em]{@{term "x\<^isub>s @ z \<in> A\<star>"}}; |
1667 node[midway, below=0.5em]{@{term "x\<^sub>s @ z \<in> A\<star>"}}; |
1668 \end{tikzpicture}} |
1668 \end{tikzpicture}} |
1669 \end{center} |
1669 \end{center} |
1670 % |
1670 % |
1671 \noindent |
1671 \noindent |
1672 We can find a strict prefix @{text "x\<^isub>p"} of @{text x} such that @{term "x\<^isub>p \<in> A\<star>"}, |
1672 We can find a strict prefix @{text "x\<^sub>p"} of @{text x} such that @{term "x\<^sub>p \<in> A\<star>"}, |
1673 @{text "x\<^isub>p < x"} and the rest @{term "x\<^isub>s @ z \<in> A\<star>"}. For example the empty string |
1673 @{text "x\<^sub>p < x"} and the rest @{term "x\<^sub>s @ z \<in> A\<star>"}. For example the empty string |
1674 @{text "[]"} would do (recall @{term "x \<noteq> []"}). |
1674 @{text "[]"} would do (recall @{term "x \<noteq> []"}). |
1675 There are potentially many such prefixes, but there can only be finitely many of them (the |
1675 There are potentially many such prefixes, but there can only be finitely many of them (the |
1676 string @{text x} is finite). Let us therefore choose the longest one and call it |
1676 string @{text x} is finite). Let us therefore choose the longest one and call it |
1677 @{text "x\<^bsub>pmax\<^esub>"}. Now for the rest of the string @{text "x\<^isub>s @ z"} we |
1677 @{text "x\<^bsub>pmax\<^esub>"}. Now for the rest of the string @{text "x\<^sub>s @ z"} we |
1678 know it is in @{term "A\<star>"} and cannot be the empty string. By Property~\ref{langprops}@{text "(iv)"}, |
1678 know it is in @{term "A\<star>"} and cannot be the empty string. By Property~\ref{langprops}@{text "(iv)"}, |
1679 we can separate |
1679 we can separate |
1680 this string into two parts, say @{text "a"} and @{text "b"}, such that @{text "a \<noteq> []"}, @{text "a \<in> A"} |
1680 this string into two parts, say @{text "a"} and @{text "b"}, such that @{text "a \<noteq> []"}, @{text "a \<in> A"} |
1681 and @{term "b \<in> A\<star>"}. Now @{text a} must be strictly longer than @{text "x\<^isub>s"}, |
1681 and @{term "b \<in> A\<star>"}. Now @{text a} must be strictly longer than @{text "x\<^sub>s"}, |
1682 otherwise @{text "x\<^bsub>pmax\<^esub>"} is not the longest prefix. That means @{text a} |
1682 otherwise @{text "x\<^bsub>pmax\<^esub>"} is not the longest prefix. That means @{text a} |
1683 `overlaps' with @{text z}, splitting it into two components @{text "z\<^isub>a"} and |
1683 `overlaps' with @{text z}, splitting it into two components @{text "z\<^sub>a"} and |
1684 @{text "z\<^isub>b"}. For this we know that @{text "x\<^isub>s @ z\<^isub>a \<in> A"} and |
1684 @{text "z\<^sub>b"}. For this we know that @{text "x\<^sub>s @ z\<^sub>a \<in> A"} and |
1685 @{term "z\<^isub>b \<in> A\<star>"}. To cut a story short, we have divided @{term "x @ z \<in> A\<star>"} |
1685 @{term "z\<^sub>b \<in> A\<star>"}. To cut a story short, we have divided @{term "x @ z \<in> A\<star>"} |
1686 such that we have a string @{text a} with @{text "a \<in> A"} that lies just on the |
1686 such that we have a string @{text a} with @{text "a \<in> A"} that lies just on the |
1687 `border' of @{text x} and @{text z}. This string is @{text "x\<^isub>s @ z\<^isub>a"}. |
1687 `border' of @{text x} and @{text z}. This string is @{text "x\<^sub>s @ z\<^sub>a"}. |
1688 |
1688 |
1689 In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use |
1689 In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use |
1690 the following tagging-function: |
1690 the following tagging-function: |
1691 % |
1691 % |
1692 \begin{center} |
1692 \begin{center} |
1693 @{thm (lhs) tag_Star_def[where ?A="A", THEN meta_eq_app]}~@{text "\<equiv>"}~ |
1693 @{thm (lhs) tag_Star_def[where ?A="A", THEN meta_eq_app]}~@{text "\<equiv>"}~ |
1694 @{text "{\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^isub>p < x \<and> x\<^isub>p \<in> A\<^isup>\<star> \<and> (x\<^isub>p, x\<^isub>s) \<in> Partitions x}"} |
1694 @{text "{\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^sub>p < x \<and> x\<^sub>p \<in> A\<^sup>\<star> \<and> (x\<^sub>p, x\<^sub>s) \<in> Partitions x}"} |
1695 \end{center} |
1695 \end{center} |
1696 |
1696 |
1697 \begin{proof}[@{const Star}-Case] |
1697 \begin{proof}[@{const Star}-Case] |
1698 If @{term "finite (UNIV // \<approx>A)"} |
1698 If @{term "finite (UNIV // \<approx>A)"} |
1699 then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
1699 then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of |
1704 We first need to consider the case that @{text x} is the empty string. |
1704 We first need to consider the case that @{text x} is the empty string. |
1705 From the assumption about strict prefixes in @{text "\<^raw:$\threesim$>\<^bsub>\<star>tag A\<^esub>"}, we |
1705 From the assumption about strict prefixes in @{text "\<^raw:$\threesim$>\<^bsub>\<star>tag A\<^esub>"}, we |
1706 can infer @{text y} is the empty string and |
1706 can infer @{text y} is the empty string and |
1707 then clearly have @{term "y @ z \<in> A\<star>"}. In case @{text x} is not the empty |
1707 then clearly have @{term "y @ z \<in> A\<star>"}. In case @{text x} is not the empty |
1708 string, we can divide the string @{text "x @ z"} as shown in the picture |
1708 string, we can divide the string @{text "x @ z"} as shown in the picture |
1709 above. By the tagging-function and the facts @{text "x\<^bsub>pmax\<^esub> \<in> A\<^isup>\<star>"} and @{text "x\<^bsub>pmax\<^esub> < x"}, |
1709 above. By the tagging-function and the facts @{text "x\<^bsub>pmax\<^esub> \<in> A\<^sup>\<star>"} and @{text "x\<^bsub>pmax\<^esub> < x"}, |
1710 we have |
1710 we have |
1711 |
1711 |
1712 \begin{center} |
1712 \begin{center} |
1713 @{text "\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> \<in> {\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^bsub>pmax\<^esub> < x \<and> x\<^bsub>pmax\<^esub> \<in> A\<^isup>\<star> \<and> (x\<^bsub>pmax\<^esub>, x\<^isub>s) \<in> Partitions x}"} |
1713 @{text "\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> \<in> {\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | x\<^bsub>pmax\<^esub> < x \<and> x\<^bsub>pmax\<^esub> \<in> A\<^sup>\<star> \<and> (x\<^bsub>pmax\<^esub>, x\<^sub>s) \<in> Partitions x}"} |
1714 \end{center} |
1714 \end{center} |
1715 |
1715 |
1716 \noindent |
1716 \noindent |
1717 which by assumption is equal to |
1717 which by assumption is equal to |
1718 |
1718 |
1719 \begin{center} |
1719 \begin{center} |
1720 @{text "\<lbrakk>x\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> \<in> {\<lbrakk>y\<^isub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | y\<^bsub>p\<^esub> < y \<and> y\<^bsub>p\<^esub> \<in> A\<^isup>\<star> \<and> (y\<^bsub>p\<^esub>, y\<^isub>s) \<in> Partitions y}"} |
1720 @{text "\<lbrakk>x\<^sub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> \<in> {\<lbrakk>y\<^sub>s\<rbrakk>\<^bsub>\<approx>A\<^esub> | y\<^bsub>p\<^esub> < y \<and> y\<^bsub>p\<^esub> \<in> A\<^sup>\<star> \<and> (y\<^bsub>p\<^esub>, y\<^sub>s) \<in> Partitions y}"} |
1721 \end{center} |
1721 \end{center} |
1722 |
1722 |
1723 \noindent |
1723 \noindent |
1724 From this we know there exist a partition @{text "y\<^isub>p"} and @{text |
1724 From this we know there exist a partition @{text "y\<^sub>p"} and @{text |
1725 "y\<^isub>s"} with @{term "y\<^isub>p \<in> A\<star>"} and also @{term "x\<^isub>s \<approx>A |
1725 "y\<^sub>s"} with @{term "y\<^sub>p \<in> A\<star>"} and also @{term "x\<^sub>s \<approx>A |
1726 y\<^isub>s"}. Unfolding the Myhill-Nerode Relation we know @{term |
1726 y\<^sub>s"}. Unfolding the Myhill-Nerode Relation we know @{term |
1727 "y\<^isub>s @ z\<^isub>a \<in> A"}. We also know that @{term "z\<^isub>b \<in> A\<star>"}. |
1727 "y\<^sub>s @ z\<^sub>a \<in> A"}. We also know that @{term "z\<^sub>b \<in> A\<star>"}. |
1728 Therefore @{term "y\<^isub>p @ (y\<^isub>s @ z\<^isub>a) @ z\<^isub>b \<in> |
1728 Therefore @{term "y\<^sub>p @ (y\<^sub>s @ z\<^sub>a) @ z\<^sub>b \<in> |
1729 A\<star>"}, which means @{term "y @ z \<in> A\<star>"}. The last step is to set |
1729 A\<star>"}, which means @{term "y @ z \<in> A\<star>"}. The last step is to set |
1730 @{text "A"} to @{term "lang r"} and thus complete the proof.\qed |
1730 @{text "A"} to @{term "lang r"} and thus complete the proof.\qed |
1731 \end{proof} |
1731 \end{proof} |
1732 |
1732 |
1733 \begin{rmk} |
1733 \begin{rmk} |
1773 @{text "\<times>tag"} function (see second clause in Fig.~\ref{tagfig}). |
1773 @{text "\<times>tag"} function (see second clause in Fig.~\ref{tagfig}). |
1774 A state of this sequentially composed automaton is accepting, if the first |
1774 A state of this sequentially composed automaton is accepting, if the first |
1775 component is accepting and at least one state in the set is also accepting. |
1775 component is accepting and at least one state in the set is also accepting. |
1776 |
1776 |
1777 The idea behind the @{text "STAR"}-case is similar to the @{text "TIMES"}-case. |
1777 The idea behind the @{text "STAR"}-case is similar to the @{text "TIMES"}-case. |
1778 We assume some automaton has consumed some strictly smaller part of the input in @{text "A\<^isup>\<star>"}; |
1778 We assume some automaton has consumed some strictly smaller part of the input in @{text "A\<^sup>\<star>"}; |
1779 we need to check that from the state we ended up in a terminal state in the |
1779 we need to check that from the state we ended up in a terminal state in the |
1780 automaton @{text "\<lbrakk>_\<rbrakk>\<^bsub>\<approx>A\<^esub>"} can be reached. Since we do not know from which state this will |
1780 automaton @{text "\<lbrakk>_\<rbrakk>\<^bsub>\<approx>A\<^esub>"} can be reached. Since we do not know from which state this will |
1781 succeed, we need to run the automaton from all possible states we could have |
1781 succeed, we need to run the automaton from all possible states we could have |
1782 ended up in. Therefore the @{text "\<star>tag"} function generates again a set of states. |
1782 ended up in. Therefore the @{text "\<star>tag"} function generates again a set of states. |
1783 |
1783 |
1861 \begin{center} |
1861 \begin{center} |
1862 \begin{longtable}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1862 \begin{longtable}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1863 @{thm (lhs) deriv.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(1)}\\ |
1863 @{thm (lhs) deriv.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(1)}\\ |
1864 @{thm (lhs) deriv.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(2)}\\ |
1864 @{thm (lhs) deriv.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(2)}\\ |
1865 @{thm (lhs) deriv.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(3)[where c'="d"]}\\ |
1865 @{thm (lhs) deriv.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(3)[where c'="d"]}\\ |
1866 @{thm (lhs) deriv.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1866 @{thm (lhs) deriv.simps(4)[where ?r1.0="r\<^sub>1" and ?r2.0="r\<^sub>2"]} |
1867 & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
1867 & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(4)[where ?r1.0="r\<^sub>1" and ?r2.0="r\<^sub>2"]}\\ |
1868 @{thm (lhs) deriv.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1868 @{thm (lhs) deriv.simps(5)[where ?r1.0="r\<^sub>1" and ?r2.0="r\<^sub>2"]} |
1869 & @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^isub>1"}~@{text "then"}~% |
1869 & @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^sub>1"}~@{text "then"}~% |
1870 @{term "Plus (Times (deriv c r\<^isub>1) r\<^isub>2) (deriv c r\<^isub>2)"}\\ |
1870 @{term "Plus (Times (deriv c r\<^sub>1) r\<^sub>2) (deriv c r\<^sub>2)"}\\ |
1871 & & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~% |
1871 & & \phantom{@{text "if"}~@{term "nullable r\<^sub>1"}~}@{text "else"}~% |
1872 @{term "Times (deriv c r\<^isub>1) r\<^isub>2"}\\ |
1872 @{term "Times (deriv c r\<^sub>1) r\<^sub>2"}\\ |
1873 @{thm (lhs) deriv.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(6)}\smallskip\\ |
1873 @{thm (lhs) deriv.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) deriv.simps(6)}\smallskip\\ |
1874 @{thm (lhs) derivs.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) derivs.simps(1)}\\ |
1874 @{thm (lhs) derivs.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) derivs.simps(1)}\\ |
1875 @{thm (lhs) derivs.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) derivs.simps(2)} |
1875 @{thm (lhs) derivs.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) derivs.simps(2)} |
1876 \end{longtable} |
1876 \end{longtable} |
1877 \end{center} |
1877 \end{center} |
1933 Myhill-Nerode Theorem, we have to be able to establish that for the |
1933 Myhill-Nerode Theorem, we have to be able to establish that for the |
1934 corresponding language there are only finitely many derivatives---thus |
1934 corresponding language there are only finitely many derivatives---thus |
1935 ensuring that there are only finitely many equivalence |
1935 ensuring that there are only finitely many equivalence |
1936 classes. Unfortunately, this is not true in general. Sakarovitch gives an |
1936 classes. Unfortunately, this is not true in general. Sakarovitch gives an |
1937 example where a regular expression has infinitely many derivatives |
1937 example where a regular expression has infinitely many derivatives |
1938 w.r.t.~the language @{text "(ab)\<^isup>\<star> \<union> (ab)\<^isup>\<star>a"}, which is formally |
1938 w.r.t.~the language @{text "(ab)\<^sup>\<star> \<union> (ab)\<^sup>\<star>a"}, which is formally |
1939 written in our notation as \mbox{@{text "{[a,b]}\<^isup>\<star> \<union> ({[a,b]}\<^isup>\<star> \<cdot> {[a]})"}} |
1939 written in our notation as \mbox{@{text "{[a,b]}\<^sup>\<star> \<union> ({[a,b]}\<^sup>\<star> \<cdot> {[a]})"}} |
1940 (see \cite[Page~141]{Sakarovitch09}). |
1940 (see \cite[Page~141]{Sakarovitch09}). |
1941 |
1941 |
1942 |
1942 |
1943 What \citeN{Brzozowski64} established is that for every language there |
1943 What \citeN{Brzozowski64} established is that for every language there |
1944 \emph{are} only finitely `dissimilar' derivatives for a regular |
1944 \emph{are} only finitely `dissimilar' derivatives for a regular |
1945 expression. Two regular expressions are said to be \emph{similar} provided |
1945 expression. Two regular expressions are said to be \emph{similar} provided |
1946 they can be identified using the using the @{text "ACI"}-identities: |
1946 they can be identified using the using the @{text "ACI"}-identities: |
1947 % |
1947 % |
1948 \begin{equation}\label{ACI} |
1948 \begin{equation}\label{ACI} |
1949 \mbox{\begin{tabular}{cl} |
1949 \mbox{\begin{tabular}{cl} |
1950 (@{text A}) & @{term "Plus (Plus r\<^isub>1 r\<^isub>2) r\<^isub>3"} $\equiv$ @{term "Plus r\<^isub>1 (Plus r\<^isub>2 r\<^isub>3)"}\\ |
1950 (@{text A}) & @{term "Plus (Plus r\<^sub>1 r\<^sub>2) r\<^sub>3"} $\equiv$ @{term "Plus r\<^sub>1 (Plus r\<^sub>2 r\<^sub>3)"}\\ |
1951 (@{text C}) & @{term "Plus r\<^isub>1 r\<^isub>2"} $\equiv$ @{term "Plus r\<^isub>2 r\<^isub>1"}\\ |
1951 (@{text C}) & @{term "Plus r\<^sub>1 r\<^sub>2"} $\equiv$ @{term "Plus r\<^sub>2 r\<^sub>1"}\\ |
1952 (@{text I}) & @{term "Plus r r"} $\equiv$ @{term "r"}\\ |
1952 (@{text I}) & @{term "Plus r r"} $\equiv$ @{term "r"}\\ |
1953 \end{tabular}} |
1953 \end{tabular}} |
1954 \end{equation} |
1954 \end{equation} |
1955 |
1955 |
1956 \noindent |
1956 \noindent |
1967 \begin{center} |
1967 \begin{center} |
1968 \begin{longtable}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1968 \begin{longtable}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}} |
1969 @{thm (lhs) pderiv.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(1)}\\ |
1969 @{thm (lhs) pderiv.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(1)}\\ |
1970 @{thm (lhs) pderiv.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(2)}\\ |
1970 @{thm (lhs) pderiv.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(2)}\\ |
1971 @{thm (lhs) pderiv.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(3)[where c'="d"]}\\ |
1971 @{thm (lhs) pderiv.simps(3)[where c'="d"]} & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(3)[where c'="d"]}\\ |
1972 @{thm (lhs) pderiv.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1972 @{thm (lhs) pderiv.simps(4)[where ?r1.0="r\<^sub>1" and ?r2.0="r\<^sub>2"]} |
1973 & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\ |
1973 & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(4)[where ?r1.0="r\<^sub>1" and ?r2.0="r\<^sub>2"]}\\ |
1974 @{thm (lhs) pderiv.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} |
1974 @{thm (lhs) pderiv.simps(5)[where ?r1.0="r\<^sub>1" and ?r2.0="r\<^sub>2"]} |
1975 & @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^isub>1"}~@{text "then"}~% |
1975 & @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^sub>1"}~@{text "then"}~% |
1976 @{term "(Timess (pderiv c r\<^isub>1) r\<^isub>2) \<union> (pderiv c r\<^isub>2)"}\\ |
1976 @{term "(Timess (pderiv c r\<^sub>1) r\<^sub>2) \<union> (pderiv c r\<^sub>2)"}\\ |
1977 & & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~% |
1977 & & \phantom{@{text "if"}~@{term "nullable r\<^sub>1"}~}@{text "else"}~% |
1978 @{term "Timess (pderiv c r\<^isub>1) r\<^isub>2"}\\ |
1978 @{term "Timess (pderiv c r\<^sub>1) r\<^sub>2"}\\ |
1979 @{thm (lhs) pderiv.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(6)}\smallskip\\ |
1979 @{thm (lhs) pderiv.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) pderiv.simps(6)}\smallskip\\ |
1980 @{thm (lhs) pderivs.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) pderivs.simps(1)}\\ |
1980 @{thm (lhs) pderivs.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) pderivs.simps(1)}\\ |
1981 @{thm (lhs) pderivs.simps(2)} & @{text "\<equiv>"} & @{text "\<Union> (pders s) ` (pder c r)"} |
1981 @{thm (lhs) pderivs.simps(2)} & @{text "\<equiv>"} & @{text "\<Union> (pders s) ` (pder c r)"} |
1982 \end{longtable} |
1982 \end{longtable} |
1983 \end{center} |
1983 \end{center} |
2166 to construct a regular expression for the complement language by direct |
2166 to construct a regular expression for the complement language by direct |
2167 means. However the existence of such a regular expression can now be easily |
2167 means. However the existence of such a regular expression can now be easily |
2168 proved using both parts of the Myhill-Nerode Theorem, since |
2168 proved using both parts of the Myhill-Nerode Theorem, since |
2169 |
2169 |
2170 \begin{center} |
2170 \begin{center} |
2171 @{term "s\<^isub>1 \<approx>A s\<^isub>2"} if and only if @{term "s\<^isub>1 \<approx>(-A) s\<^isub>2"} |
2171 @{term "s\<^sub>1 \<approx>A s\<^sub>2"} if and only if @{term "s\<^sub>1 \<approx>(-A) s\<^sub>2"} |
2172 \end{center} |
2172 \end{center} |
2173 |
2173 |
2174 \noindent |
2174 \noindent |
2175 holds for any strings @{text "s\<^isub>1"} and @{text |
2175 holds for any strings @{text "s\<^sub>1"} and @{text |
2176 "s\<^isub>2"}. Therefore @{text A} and the complement language @{term "-A"} |
2176 "s\<^sub>2"}. Therefore @{text A} and the complement language @{term "-A"} |
2177 give rise to the same partitions. So if one is finite, the other is too, and |
2177 give rise to the same partitions. So if one is finite, the other is too, and |
2178 vice versa. As noted earlier, our algorithm for solving equational systems |
2178 vice versa. As noted earlier, our algorithm for solving equational systems |
2179 actually calculates a regular expression for the complement language. |
2179 actually calculates a regular expression for the complement language. |
2180 Calculating such a regular expression via |
2180 Calculating such a regular expression via |
2181 automata using the standard method would be quite involved. It includes the |
2181 automata using the standard method would be quite involved. It includes the |