Journal/Paper.thy
author urbanc
Tue, 09 Aug 2011 22:14:41 +0000
changeset 189 48b452a2d4df
parent 187 9f46a9571e37
child 190 b73478aaf33e
permissions -rw-r--r--
more on paper and literature
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
     1
(*<*)
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
     2
theory Paper
182
560712a29a36 a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents: 181
diff changeset
     3
imports "../Closures" "../Attic/Prefix_subtract" 
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
     4
begin
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
     5
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
     6
declare [[show_question_marks = false]]
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
     7
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
     8
consts
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
     9
 REL :: "(string \<times> string) \<Rightarrow> bool"
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    10
 UPLUS :: "'a set \<Rightarrow> 'a set \<Rightarrow> (nat \<times> 'a) set"
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
    11
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
    12
abbreviation
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
    13
  "EClass x R \<equiv> R `` {x}"
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
    14
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
    15
abbreviation 
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    16
  "Append_rexp2 r_itm r \<equiv> Append_rexp r r_itm"
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
    17
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
    18
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    19
abbreviation
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    20
  "pow" (infixl "\<up>" 100)
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    21
where
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    22
  "A \<up> n \<equiv> A ^^ n"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    23
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    24
syntax (latex output)
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    25
  "_Collect" :: "pttrn => bool => 'a set"              ("(1{_ | _})")
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    26
  "_CollectIn" :: "pttrn => 'a set => bool => 'a set"   ("(1{_ \<in> _ | _})")
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    27
translations
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    28
  "_Collect p P"      <= "{p. P}"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    29
  "_Collect p P"      <= "{p|xs. P}"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    30
  "_CollectIn p A P"  <= "{p : A. P}"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    31
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
    32
abbreviation "ZERO \<equiv> Zero"
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
    33
abbreviation "ONE \<equiv> One"
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
    34
abbreviation "ATOM \<equiv> Atom"
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
    35
abbreviation "PLUS \<equiv> Plus"
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
    36
abbreviation "TIMES \<equiv> Times"
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
    37
abbreviation "TIMESS \<equiv> Timess"
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    38
abbreviation "STAR \<equiv> Star"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    39
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    40
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
    41
notation (latex output)
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    42
  str_eq ("\<approx>\<^bsub>_\<^esub>") and
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    43
  str_eq_applied ("_ \<approx>\<^bsub>_\<^esub> _") and
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    44
  conc (infixr "\<cdot>" 100) and
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    45
  star ("_\<^bsup>\<star>\<^esup>") and
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    46
  pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
    47
  Suc ("_+1" [100] 100) and
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
    48
  quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    49
  REL ("\<approx>") and
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
    50
  UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
    51
  lang ("\<^raw:\ensuremath{\cal{L}}>" 101) and
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    52
  lang ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
    53
  lang_trm ("\<^raw:\ensuremath{\cal{L}}>'(_')" [0] 101) and
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
    54
  Lam ("\<lambda>'(_')" [100] 100) and 
89
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
    55
  Trn ("'(_, _')" [100, 100] 100) and 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
    56
  EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 86
diff changeset
    57
  transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100) and
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
    58
  Setalt ("\<^raw:\ensuremath{\bigplus}>_" [1000] 999) and
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    59
  Append_rexp2 ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 100) and
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
    60
  Append_rexp_rhs ("_ \<^raw:\ensuremath{\triangleleft}> _" [100, 100] 50) and
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    61
  
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    62
  uminus ("\<^raw:\ensuremath{\overline{>_\<^raw:}}>" [100] 100) and
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
    63
  tag_Plus ("+tag _ _" [100, 100] 100) and
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
    64
  tag_Plus ("+tag _ _ _" [100, 100, 100] 100) and
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
    65
  tag_Times ("\<times>tag _ _" [100, 100] 100) and
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
    66
  tag_Times ("\<times>tag _ _ _" [100, 100, 100] 100) and
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
    67
  tag_Star ("\<star>tag _" [100] 100) and
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
    68
  tag_Star ("\<star>tag _ _" [100, 100] 100) and
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    69
  tag_eq ("\<^raw:$\threesim$>\<^bsub>_\<^esub>") and
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
    70
  Delta ("\<Delta>'(_')") and
180
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
    71
  nullable ("\<delta>'(_')") and
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
    72
  Cons ("_ :: _" [100, 100] 100) and
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
    73
  Rev ("Rev _" [1000] 100) and
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
    74
  Der ("Der _ _" [1000, 1000] 100) and
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
    75
  ONE ("ONE" 999) and
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
    76
  ZERO ("ZERO" 999)
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
    77
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    78
lemma meta_eq_app:
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    79
  shows "f \<equiv> \<lambda>x. g x \<Longrightarrow> f x \<equiv> g x"
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    80
  by auto
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
    81
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    82
lemma str_eq_def':
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    83
  shows "x \<approx>A y \<equiv> (\<forall>z. x @ z \<in> A \<longleftrightarrow> y @ z \<in> A)"
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    84
unfolding str_eq_def by simp
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
    85
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    86
lemma conc_def':
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    87
  "A \<cdot> B = {s\<^isub>1 @ s\<^isub>2 | s\<^isub>1 s\<^isub>2. s\<^isub>1 \<in> A \<and> s\<^isub>2 \<in> B}"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    88
unfolding conc_def by simp
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    89
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    90
lemma conc_Union_left: 
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    91
  shows "B \<cdot> (\<Union>n. A \<up> n) = (\<Union>n. B \<cdot> (A \<up> n))"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    92
unfolding conc_def by auto
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    93
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    94
lemma test:
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    95
  assumes X_in_eqs: "(X, rhs) \<in> Init (UNIV // \<approx>A)"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    96
  shows "X = \<Union> (lang_trm `  rhs)"
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    97
using assms l_eq_r_in_eqs by (simp)
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    98
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
    99
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   100
(* THEOREMS *)
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   101
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   102
notation (Rule output)
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   103
  "==>"  ("\<^raw:\mbox{}\inferrule{\mbox{>_\<^raw:}}>\<^raw:{\mbox{>_\<^raw:}}>")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   104
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   105
syntax (Rule output)
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   106
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   107
  ("\<^raw:\mbox{}\inferrule{>_\<^raw:}>\<^raw:{\mbox{>_\<^raw:}}>")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   108
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   109
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" 
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   110
  ("\<^raw:\mbox{>_\<^raw:}\\>/ _")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   111
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   112
  "_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   113
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   114
notation (Axiom output)
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   115
  "Trueprop"  ("\<^raw:\mbox{}\inferrule{\mbox{}}{\mbox{>_\<^raw:}}>")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   116
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   117
notation (IfThen output)
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   118
  "==>"  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   119
syntax (IfThen output)
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   120
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   121
  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   122
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}> /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   123
  "_asm" :: "prop \<Rightarrow> asms" ("\<^raw:\mbox{>_\<^raw:}>")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   124
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   125
notation (IfThenNoBox output)
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   126
  "==>"  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _/ \<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   127
syntax (IfThenNoBox output)
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   128
  "_bigimpl" :: "asms \<Rightarrow> prop \<Rightarrow> prop"
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   129
  ("\<^raw:{\normalsize{}>If\<^raw:\,}> _ /\<^raw:{\normalsize \,>then\<^raw:\,}>/ _.")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   130
  "_asms" :: "prop \<Rightarrow> asms \<Rightarrow> asms" ("_ /\<^raw:{\normalsize \,>and\<^raw:\,}>/ _")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   131
  "_asm" :: "prop \<Rightarrow> asms" ("_")
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   132
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   133
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   134
(*>*)
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   135
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   136
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   137
section {* Introduction *}
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   138
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   139
text {*
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   140
  \noindent
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   141
  Regular languages are an important and well-understood subject in Computer
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   142
  Science, with many beautiful theorems and many useful algorithms. There is a
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   143
  wide range of textbooks on this subject, many of which are aimed at students
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   144
  and contain very detailed `pencil-and-paper' proofs (e.g.~\cite{Kozen97,
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   145
  HopcroftUllman69}). It seems natural to exercise theorem provers by
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   146
  formalising the theorems and by verifying formally the algorithms.  
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   147
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   148
  A popular choice for a theorem prover would be one based on Higher-Order
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   149
  Logic (HOL), for example HOL4, HOLlight or Isabelle/HOL. For the development
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   150
  presented in this paper we will use the latter. HOL is a predicate calculus
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   151
  that allows quantification over predicate variables. Its type system is
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   152
  based on Church's Simple Theory of Types \cite{Church40}.  Although many
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   153
  mathematical concepts can be conveniently expressed in HOL, there are some
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   154
  limitations that hurt badly, if one attempts a simple-minded formalisation
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   155
  of regular languages in it.  The typical approach to regular languages is to
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   156
  introduce finite automata and then define everything in terms of them
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   157
  \cite{Kozen97}.  For example, a regular language is normally defined as:
59
fc35eb54fdc9 more on the intro
urbanc
parents: 58
diff changeset
   158
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   159
  \begin{dfntn}\label{baddef}
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   160
  A language @{text A} is \emph{regular}, provided there is a 
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   161
  finite deterministic automaton that recognises all strings of @{text "A"}.
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   162
  \end{dfntn}
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   163
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   164
  \noindent  
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   165
  This approach has many benefits. Among them is the fact that it is easy to
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   166
  convince oneself that regular languages are closed under complementation:
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   167
  one just has to exchange the accepting and non-accepting states in the
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   168
  corresponding automaton to obtain an automaton for the complement language.
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   169
  The problem, however, lies with formalising such reasoning in a HOL-based
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   170
  theorem prover. Automata are built up from states and transitions that need
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   171
  to be represented as graphs, matrices or functions, none of which can be
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   172
  defined as an inductive datatype.
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   173
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   174
  In case of graphs and matrices, this means we have to build our own
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   175
  reasoning infrastructure for them, as neither Isabelle/HOL nor HOL4 nor
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   176
  HOLlight support them with libraries. Even worse, reasoning about graphs and
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   177
  matrices can be a real hassle in HOL-based theorem provers, because
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   178
  we have to be able to combine automata.  Consider for
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   179
  example the operation of sequencing two automata, say $A_1$ and $A_2$, by
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   180
  connecting the accepting states of $A_1$ to the initial state of $A_2$:
159
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   181
  %  
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   182
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   183
  \begin{center}
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   184
  \begin{tabular}{ccc}
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   185
  \begin{tikzpicture}[scale=1]
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   186
  %\draw[step=2mm] (-1,-1) grid (1,1);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   187
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   188
  \draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   189
  \draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   190
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   191
  \node (A) at (-1.0,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   192
  \node (B) at ( 0.2,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   193
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   194
  \node (C) at (-0.2, 0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   195
  \node (D) at (-0.2,-0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   196
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   197
  \node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   198
  \node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   199
  \node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   200
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   201
  \draw (-0.6,0.0) node {\small$A_1$};
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   202
  \draw ( 0.6,0.0) node {\small$A_2$};
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   203
  \end{tikzpicture}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   204
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   205
  & 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   206
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   207
  \raisebox{1.1mm}{\bf\Large$\;\;\;\Rightarrow\,\;\;$}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   208
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   209
  &
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   210
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   211
  \begin{tikzpicture}[scale=1]
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   212
  %\draw[step=2mm] (-1,-1) grid (1,1);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   213
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   214
  \draw[rounded corners=1mm, very thick] (-1.0,-0.3) rectangle (-0.2,0.3);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   215
  \draw[rounded corners=1mm, very thick] ( 0.2,-0.3) rectangle ( 1.0,0.3);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   216
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   217
  \node (A) at (-1.0,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   218
  \node (B) at ( 0.2,0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   219
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   220
  \node (C) at (-0.2, 0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   221
  \node (D) at (-0.2,-0.13) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   222
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   223
  \node (E) at (1.0, 0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   224
  \node (F) at (1.0,-0.0) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   225
  \node (G) at (1.0,-0.2) [circle, very thick, draw, fill=white, inner sep=0.4mm] {};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   226
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   227
  \draw (C) to [very thick, bend left=45] (B);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   228
  \draw (D) to [very thick, bend right=45] (B);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   229
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   230
  \draw (-0.6,0.0) node {\small$A_1$};
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   231
  \draw ( 0.6,0.0) node {\small$A_2$};
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   232
  \end{tikzpicture}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   233
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   234
  \end{tabular}
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   235
  \end{center}
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   236
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   237
  \noindent
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   238
  On `paper' we can define the corresponding 
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   239
  graph in terms of the disjoint 
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 86
diff changeset
   240
  union of the state nodes. Unfortunately in HOL, the standard definition for disjoint 
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   241
  union, namely 
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   242
  %
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   243
  \begin{equation}\label{disjointunion}
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   244
  @{text "A\<^isub>1 \<uplus> A\<^isub>2 \<equiv> {(1, x) | x \<in> A\<^isub>1} \<union> {(2, y) | y \<in> A\<^isub>2}"}
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   245
  \end{equation}
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   246
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   247
  \noindent
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   248
  changes the type---the disjoint union is not a set, but a set of
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   249
  pairs. Using this definition for disjoint union means we do not have a
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   250
  single type for automata. As a result we will not be able to define a regular
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   251
  language as one for which there exists an automaton that recognises all its
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   252
  strings. This is because we cannot make a definition in HOL that is polymorphic in 
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   253
  the state type and there is no type quantification available in HOL (unlike 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   254
  in Coq, for example).\footnote{Slind already pointed out this problem in an email 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   255
  to the HOL4 mailing list on 21st April 2005.}
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   256
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   257
  An alternative, which provides us with a single type for automata, is to give every 
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   258
  state node an identity, for example a natural
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   259
  number, and then be careful to rename these identities apart whenever
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   260
  connecting two automata. This results in clunky proofs
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   261
  establishing that properties are invariant under renaming. Similarly,
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   262
  connecting two automata represented as matrices results in very adhoc
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   263
  constructions, which are not pleasant to reason about.
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   264
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   265
  Functions are much better supported in Isabelle/HOL, but they still lead to similar
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 86
diff changeset
   266
  problems as with graphs.  Composing, for example, two non-deterministic automata in parallel
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   267
  requires also the formalisation of disjoint unions. Nipkow \cite{Nipkow98} 
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   268
  dismisses for this the option of using identities, because it leads according to 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   269
  him to ``messy proofs''. Since he does not need to define what regular
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   270
  languages are, Nipkow opts for a variant of \eqref{disjointunion} using bit lists, but writes 
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   271
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   272
  \begin{quote}
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   273
  \it%
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   274
  \begin{tabular}{@ {}l@ {}p{0.88\textwidth}@ {}}
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   275
  `` & All lemmas appear obvious given a picture of the composition of automata\ldots
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   276
       Yet their proofs require a painful amount of detail.''
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   277
  \end{tabular}
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   278
  \end{quote}
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   279
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   280
  \noindent
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   281
  and
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   282
  
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   283
  \begin{quote}
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   284
  \it%
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   285
  \begin{tabular}{@ {}l@ {}p{0.88\textwidth}@ {}}
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   286
  `` & If the reader finds the above treatment in terms of bit lists revoltingly
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   287
       concrete, I cannot disagree. A more abstract approach is clearly desirable.''
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   288
  \end{tabular}
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   289
  \end{quote}
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   290
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   291
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   292
  \noindent
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   293
  Moreover, it is not so clear how to conveniently impose a finiteness
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   294
  condition upon functions in order to represent \emph{finite} automata. The
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   295
  best is probably to resort to more advanced reasoning frameworks, such as
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   296
  \emph{locales} or \emph{type classes}, which are \emph{not} available in all
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   297
  HOL-based theorem provers.
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   298
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   299
  Because of these problems to do with representing automata, there seems to
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   300
  be no substantial formalisation of automata theory and regular languages
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   301
  carried out in HOL-based theorem provers. Nipkow \cite{Nipkow98} establishes
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   302
  the link between regular expressions and automata in the context of
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   303
  lexing. Berghofer and Reiter \cite{BerghoferReiter09} formalise automata
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   304
  working over bit strings in the context of Presburger arithmetic.  The only
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   305
  larger formalisations of automata theory are carried out in Nuprl
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   306
  \cite{Constable00} and in Coq \cite{Filliatre97}.
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   307
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   308
  Also one might consider automata theory as a well-worn stock subject where
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   309
  everything is crystal clear. However, paper proofs about automata often
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   310
  involve subtle side-conditions which are easily overlooked, but which make
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   311
  formal reasoning rather painful. For example Kozen's proof of the
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   312
  Myhill-Nerode theorem requires that automata do not have inaccessible
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   313
  states \cite{Kozen97}. Another subtle side-condition is completeness of
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   314
  automata, that is automata need to have total transition functions and at most one
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
   315
  `sink' state from which there is no connection to a final state (Brzozowski
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   316
  mentions this side-condition in the context of state complexity
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
   317
  of automata \cite{Brzozowski10}). Such side-conditions mean that if we define a regular
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   318
  language as one for which there exists \emph{a} finite automaton that
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   319
  recognises all its strings (see Def.~\ref{baddef}), then we need a lemma which
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   320
  ensures that another equivalent one can be found satisfying the
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   321
  side-condition. Unfortunately, such `little' and `obvious' lemmas make
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   322
  a formalisation of automata theory a hair-pulling experience.
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   323
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   324
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   325
  In this paper, we will not attempt to formalise automata theory in
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   326
  Isabelle/HOL nor will we attempt to formalise automata proofs from the
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   327
  literature, but take a different approach to regular languages than is
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   328
  usually taken. Instead of defining a regular language as one where there
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   329
  exists an automaton that recognises all its strings, we define a
82
14b12b5de6d3 added coments about functions
urbanc
parents: 79
diff changeset
   330
  regular language as:
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   331
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
   332
  \begin{dfntn}\label{regular}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
   333
  A language @{text A} is \emph{regular}, provided there is a regular expression 
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
   334
  that matches all strings of @{text "A"}.
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   335
  \end{dfntn}
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   336
  
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   337
  \noindent
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   338
  The reason is that regular expressions, unlike graphs, matrices and
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   339
  functions, can be easily defined as an inductive datatype. A reasoning
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   340
  infrastructure (like induction and recursion) comes then for free in
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   341
  HOL. Moreover, no side-conditions will be needed for regular expressions,
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   342
  like we need for automata. This convenience of regular expressions has
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   343
  recently been exploited in HOL4 with a formalisation of regular expression
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   344
  matching based on derivatives \cite{OwensSlind08} and with an equivalence
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   345
  checker for regular expressions in Isabelle/HOL \cite{KraussNipkow11}.  The
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   346
  main purpose of this paper is to show that a central result about regular
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   347
  languages---the Myhill-Nerode theorem---can be recreated by only using
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   348
  regular expressions. This theorem gives necessary and sufficient conditions
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   349
  for when a language is regular. As a corollary of this theorem we can easily
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   350
  establish the usual closure properties, including complementation, for
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   351
  regular languages.\medskip
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   352
  
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   353
  \noindent 
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   354
  {\bf Contributions:} There is an extensive literature on regular languages.
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   355
  To our best knowledge, our proof of the Myhill-Nerode theorem is the first
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   356
  that is based on regular expressions, only. The part of this theorem stating
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   357
  that finitely many partitions imply regularity of the language is proved by
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   358
  an argument about solving equational systems.  This argument appears to be
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   359
  folklore. For the other part, we give two proofs: one direct proof using
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   360
  certain tagging-functions, and another indirect proof using Antimirov's
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   361
  partial derivatives \cite{Antimirov95}. Again to our best knowledge, the
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
   362
  tagging-functions have not been used before to establish the Myhill-Nerode
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   363
  theorem. Derivatives of regular expressions have been used recently quite
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   364
  widely in the literature; partial derivatives, in contrast, attracted much
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   365
  less attention. However, partial derivatives are more suitable in the
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   366
  context of the Myhill-Nerode theorem, since it is easier to establish
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   367
  formally their finiteness result. We have not found any proof that uses
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   368
  either of them in order to prove the Myhill-Nerode theorem.
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   369
*}
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   370
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   371
section {* Preliminaries *}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   372
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   373
text {*
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   374
  \noindent
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   375
  Strings in Isabelle/HOL are lists of characters with the \emph{empty string}
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   376
  being represented by the empty list, written @{term "[]"}.  We assume there
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   377
  are only finitely many different characters.  \emph{Languages} are sets of
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   378
  strings. The language containing all strings is written in Isabelle/HOL as
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   379
  @{term "UNIV::string set"}. The concatenation of two languages is written
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   380
  @{term "A \<cdot> B"} and a language raised to the power @{text n} is written
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   381
  @{term "A \<up> n"}. They are defined as usual
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   382
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   383
  \begin{center}
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   384
  \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   385
  @{thm (lhs) conc_def'[THEN eq_reflection, where A1="A" and B1="B"]}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   386
  & @{text "\<equiv>"} & @{thm (rhs) conc_def'[THEN eq_reflection, where A1="A" and B1="B"]}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   387
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   388
  @{thm (lhs) lang_pow.simps(1)[THEN eq_reflection, where A1="A"]}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   389
  & @{text "\<equiv>"} & @{thm (rhs) lang_pow.simps(1)[THEN eq_reflection, where A1="A"]}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   390
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   391
  @{thm (lhs) lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   392
  & @{text "\<equiv>"} & @{thm (rhs) lang_pow.simps(2)[THEN eq_reflection, where A1="A" and n1="n"]}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   393
  \end{tabular}
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   394
  \end{center}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   395
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   396
  \noindent
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   397
  where @{text "@"} is the list-append operation. The Kleene-star of a language @{text A}
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   398
  is defined as the union over all powers, namely @{thm star_def}. In the paper
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 86
diff changeset
   399
  we will make use of the following properties of these constructions.
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   400
  
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   401
  \begin{prpstn}\label{langprops}\mbox{}\\
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   402
  \begin{tabular}{@ {}lp{10cm}}
180
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
   403
  (i)   & @{thm star_unfold_left}     \\ 
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   404
  (ii)  & @{thm[mode=IfThen] pow_length}\\
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   405
  (iii) & @{thm conc_Union_left} \\ 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   406
  (iv)  & If @{thm (prem 1) star_decom} and @{thm (prem 2) star_decom} then
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   407
          there exists an @{text "x\<^isub>p"} and @{text "x\<^isub>s"} with @{text "x = x\<^isub>p @ x\<^isub>s"} 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
   408
          and @{term "x\<^isub>p \<noteq> []"} such that @{term "x\<^isub>p \<in> A"} and @{term "x\<^isub>s \<in> A\<star>"}.
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   409
  \end{tabular}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   410
  \end{prpstn}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   411
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   412
  \noindent
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   413
  In @{text "(ii)"} we use the notation @{term "length s"} for the length of a
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   414
  string; this property states that if \mbox{@{term "[] \<notin> A"}} then the lengths of
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   415
  the strings in @{term "A \<up> (Suc n)"} must be longer than @{text n}.  We omit
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   416
  the proofs for these properties, but invite the reader to consult our
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
   417
  formalisation.\footnote{Available at \url{http://www4.in.tum.de/~urbanc/regexp.html}}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   418
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   419
  The notation in Isabelle/HOL for the quotient of a language @{text A}
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   420
  according to an equivalence relation @{term REL} is @{term "A // REL"}. We
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   421
  will write @{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined as
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   422
  \mbox{@{text "{y | y \<approx> x}"}}, and have @{text "x \<approx> y"} if and only if @{text
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   423
  "\<lbrakk>x\<rbrakk>\<^isub>\<approx> = \<lbrakk>y\<rbrakk>\<^isub>\<approx>"}.
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   424
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   425
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   426
  Central to our proof will be the solution of equational systems
176
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   427
  involving equivalence classes of languages. For this we will use Arden's Lemma 
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   428
  (see \cite[Page 100]{Sakarovitch09}),
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   429
  which solves equations of the form @{term "X = A \<cdot> X \<union> B"} provided
115
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
   430
  @{term "[] \<notin> A"}. However we will need the following `reverse' 
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   431
  version of Arden's Lemma (`reverse' in the sense of changing the order of @{term "A \<cdot> X"} to
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   432
  \mbox{@{term "X \<cdot> A"}}).
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   433
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   434
  \begin{lmm}[Reverse Arden's Lemma]\label{arden}\mbox{}\\
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 83
diff changeset
   435
  If @{thm (prem 1) arden} then
115
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
   436
  @{thm (lhs) arden} if and only if
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 83
diff changeset
   437
  @{thm (rhs) arden}.
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   438
  \end{lmm}
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   439
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   440
  \begin{proof}
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 83
diff changeset
   441
  For the right-to-left direction we assume @{thm (rhs) arden} and show
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 83
diff changeset
   442
  that @{thm (lhs) arden} holds. From Prop.~\ref{langprops}@{text "(i)"} 
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   443
  we have @{term "A\<star> = A \<cdot> A\<star> \<union> {[]}"},
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   444
  which is equal to @{term "A\<star> = A\<star> \<cdot> A \<union> {[]}"}. Adding @{text B} to both 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   445
  sides gives @{term "B \<cdot> A\<star> = B \<cdot> (A\<star> \<cdot> A \<union> {[]})"}, whose right-hand side
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   446
  is equal to @{term "(B \<cdot> A\<star>) \<cdot> A \<union> B"}. This completes this direction. 
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   447
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 83
diff changeset
   448
  For the other direction we assume @{thm (lhs) arden}. By a simple induction
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   449
  on @{text n}, we can establish the property
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   450
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   451
  \begin{center}
86
6457e668dee5 tuned comments and names in Myhill_1
urbanc
parents: 83
diff changeset
   452
  @{text "(*)"}\hspace{5mm} @{thm (concl) arden_helper}
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   453
  \end{center}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   454
  
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   455
  \noindent
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   456
  Using this property we can show that @{term "B \<cdot> (A \<up> n) \<subseteq> X"} holds for
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   457
  all @{text n}. From this we can infer @{term "B \<cdot> A\<star> \<subseteq> X"} using the definition
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   458
  of @{text "\<star>"}.
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   459
  For the inclusion in the other direction we assume a string @{text s}
134
08afbed1c8c7 chunhan's comments
urbanc
parents: 133
diff changeset
   460
  with length @{text k} is an element in @{text X}. Since @{thm (prem 1) arden}
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   461
  we know by Prop.~\ref{langprops}@{text "(ii)"} that 
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   462
  @{term "s \<notin> X \<cdot> (A \<up> Suc k)"} since its length is only @{text k}
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   463
  (the strings in @{term "X \<cdot> (A \<up> Suc k)"} are all longer). 
53
da85feadb8e3 small typo
urbanc
parents: 52
diff changeset
   464
  From @{text "(*)"} it follows then that
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   465
  @{term s} must be an element in @{term "(\<Union>m\<in>{0..k}. B \<cdot> (A \<up> m))"}. This in turn
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   466
  implies that @{term s} is in @{term "(\<Union>n. B \<cdot> (A \<up> n))"}. Using Prop.~\ref{langprops}@{text "(iii)"} 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   467
  this is equal to @{term "B \<cdot> A\<star>"}, as we needed to show.
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   468
  \end{proof}
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   469
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   470
  \noindent
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 86
diff changeset
   471
  Regular expressions are defined as the inductive datatype
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   472
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   473
  \begin{center}
176
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   474
  \begin{tabular}{rcl}
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   475
  @{text r} & @{text "::="} & @{term ZERO}\\
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   476
   & @{text"|"} & @{term One}\\ 
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   477
   & @{text"|"} & @{term "Atom c"}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   478
   & @{text"|"} & @{term "Times r r"}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   479
   & @{text"|"} & @{term "Plus r r"}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   480
   & @{text"|"} & @{term "Star r"}
176
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   481
  \end{tabular}
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   482
  \end{center}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   483
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   484
  \noindent
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 86
diff changeset
   485
  and the language matched by a regular expression is defined as
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   486
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   487
  \begin{center}
176
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   488
  \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   489
  @{thm (lhs) lang.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(1)}\\
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   490
  @{thm (lhs) lang.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(2)}\\
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   491
  @{thm (lhs) lang.simps(3)[where a="c"]} & @{text "\<equiv>"} & @{thm (rhs) lang.simps(3)[where a="c"]}\\
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   492
  @{thm (lhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} &
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   493
       @{thm (rhs) lang.simps(4)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   494
  @{thm (lhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]} & @{text "\<equiv>"} &
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   495
       @{thm (rhs) lang.simps(5)[where ?r="r\<^isub>1" and ?s="r\<^isub>2"]}\\
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   496
  @{thm (lhs) lang.simps(6)[where r="r"]} & @{text "\<equiv>"} &
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   497
      @{thm (rhs) lang.simps(6)[where r="r"]}\\
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   498
  \end{tabular}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   499
  \end{center}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   500
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   501
  Given a finite set of regular expressions @{text rs}, we will make use of the operation of generating 
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
   502
  a regular expression that matches the union of all languages of @{text rs}. We only need to know the 
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
   503
  existence
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   504
  of such a regular expression and therefore we use Isabelle/HOL's @{const "fold_graph"} and Hilbert's
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   505
  @{text "\<epsilon>"} to define @{term "\<Uplus>rs"}. This operation, roughly speaking, folds @{const PLUS} over the 
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   506
  set @{text rs} with @{const ZERO} for the empty set. We can prove that for a finite set @{text rs}
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   507
  %
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   508
  \begin{equation}\label{uplus}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   509
  \mbox{@{thm (lhs) folds_alt_simp} @{text "= \<Union> (\<calL> ` rs)"}}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   510
  \end{equation}
88
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 86
diff changeset
   511
1436fc451bb9 added something about Setalt and folds
urbanc
parents: 86
diff changeset
   512
  \noindent
90
97b783438316 added an example
urbanc
parents: 89
diff changeset
   513
  holds, whereby @{text "\<calL> ` rs"} stands for the 
97b783438316 added an example
urbanc
parents: 89
diff changeset
   514
  image of the set @{text rs} under function @{text "\<calL>"}.
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   515
*}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   516
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
   517
133
3ab755a96cef minor change
urbanc
parents: 132
diff changeset
   518
section {* The Myhill-Nerode Theorem, First Part *}
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   519
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   520
text {*
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   521
  \noindent
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   522
  \footnote{Folklore: Henzinger (arden-DFA-regexp.pdf); Hofmann}
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   523
  The key definition in the Myhill-Nerode theorem is the
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   524
  \emph{Myhill-Nerode relation}, which states that w.r.t.~a language two 
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   525
  strings are related, provided there is no distinguishing extension in this
154
7c68b9ad4486 implemented most suggestions from the reviewers
urbanc
parents: 149
diff changeset
   526
  language. This can be defined as a tertiary relation.
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   527
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   528
  \begin{dfntn}[Myhill-Nerode Relation]\label{myhillneroderel} 
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   529
  Given a language @{text A}, two strings @{text x} and
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
   530
  @{text y} are Myhill-Nerode related provided
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
   531
  \begin{center}
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   532
  @{thm str_eq_def'}
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
   533
  \end{center}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   534
  \end{dfntn}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   535
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   536
  \noindent
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   537
  It is easy to see that @{term "\<approx>A"} is an equivalence relation, which
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   538
  partitions the set of all strings, @{text "UNIV"}, into a set of disjoint
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   539
  equivalence classes. To illustrate this quotient construction, let us give a simple 
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   540
  example: consider the regular language containing just
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   541
  the string @{text "[c]"}. The relation @{term "\<approx>({[c]})"} partitions @{text UNIV}
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   542
  into three equivalence classes @{text "X\<^isub>1"}, @{text "X\<^isub>2"} and  @{text "X\<^isub>3"}
90
97b783438316 added an example
urbanc
parents: 89
diff changeset
   543
  as follows
97b783438316 added an example
urbanc
parents: 89
diff changeset
   544
  
97b783438316 added an example
urbanc
parents: 89
diff changeset
   545
  \begin{center}
176
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   546
  \begin{tabular}{l}
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   547
  @{text "X\<^isub>1 = {[]}"}\\
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   548
  @{text "X\<^isub>2 = {[c]}"}\\
90
97b783438316 added an example
urbanc
parents: 89
diff changeset
   549
  @{text "X\<^isub>3 = UNIV - {[], [c]}"}
176
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
   550
  \end{tabular}
90
97b783438316 added an example
urbanc
parents: 89
diff changeset
   551
  \end{center}
97b783438316 added an example
urbanc
parents: 89
diff changeset
   552
97b783438316 added an example
urbanc
parents: 89
diff changeset
   553
  One direction of the Myhill-Nerode theorem establishes 
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   554
  that if there are finitely many equivalence classes, like in the example above, then 
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   555
  the language is regular. In our setting we therefore have to show:
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   556
  
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   557
  \begin{thrm}\label{myhillnerodeone}
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   558
  @{thm[mode=IfThen] Myhill_Nerode1}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   559
  \end{thrm}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   560
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   561
  \noindent
90
97b783438316 added an example
urbanc
parents: 89
diff changeset
   562
  To prove this theorem, we first define the set @{term "finals A"} as those equivalence
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   563
  classes from @{term "UNIV // \<approx>A"} that contain strings of @{text A}, namely
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   564
  %
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   565
  \begin{equation} 
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   566
  @{thm finals_def}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   567
  \end{equation}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   568
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   569
  \noindent
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
   570
  In our running example, @{text "X\<^isub>2"} is the only 
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
   571
  equivalence class in @{term "finals {[c]}"}.
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   572
  It is straightforward to show that in general 
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   573
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   574
  \begin{equation}\label{finalprops}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   575
  @{thm lang_is_union_of_finals}\hspace{15mm} 
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   576
  @{thm finals_in_partitions} 
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   577
  \end{equation}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   578
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   579
  \noindent
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   580
  hold. 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   581
  Therefore if we know that there exists a regular expression for every
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   582
  equivalence class in \mbox{@{term "finals A"}} (which by assumption must be
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   583
  a finite set), then we can use @{text "\<bigplus>"} to obtain a regular expression 
98
36f9d19be0e6 included comments by Xingyuan
urbanc
parents: 96
diff changeset
   584
  that matches every string in @{text A}.
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   585
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   586
90
97b783438316 added an example
urbanc
parents: 89
diff changeset
   587
  Our proof of Thm.~\ref{myhillnerodeone} relies on a method that can calculate a
79
bba9c80735f9 started to define things more directly
urbanc
parents: 77
diff changeset
   588
  regular expression for \emph{every} equivalence class, not just the ones 
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   589
  in @{term "finals A"}. We
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   590
  first define the notion of \emph{one-character-transition} between 
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   591
  two equivalence classes
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   592
  %
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   593
  \begin{equation} 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   594
  @{thm transition_def}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   595
  \end{equation}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   596
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   597
  \noindent
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   598
  which means that if we concatenate the character @{text c} to the end of all 
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   599
  strings in the equivalence class @{text Y}, we obtain a subset of 
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   600
  @{text X}. Note that we do not define an automaton here, we merely relate two sets
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   601
  (with the help of a character). In our concrete example we have 
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   602
  @{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 
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   603
  other character than @{text c}, and @{term "X\<^isub>3 \<Turnstile>c\<^isub>j\<Rightarrow> X\<^isub>3"} for any 
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   604
  caracter @{text "c\<^isub>j"}.
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   605
  
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   606
  Next we construct an \emph{initial equational system} that
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   607
  contains an equation for each equivalence class. We first give
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   608
  an informal description of this construction. Suppose we have 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   609
  the equivalence classes @{text "X\<^isub>1,\<dots>,X\<^isub>n"}, there must be one and only one that
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   610
  contains the empty string @{text "[]"} (since equivalence classes are disjoint).
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   611
  Let us assume @{text "[] \<in> X\<^isub>1"}. We build the following equational system
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   612
  
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   613
  \begin{center}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   614
  \begin{tabular}{rcl}
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   615
  @{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)"} \\
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   616
  @{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)"} \\
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   617
  & $\vdots$ \\
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   618
  @{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)"}\\
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   619
  \end{tabular}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   620
  \end{center}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   621
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   622
  \noindent
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   623
  where the terms @{text "(Y\<^isub>i\<^isub>j, ATOM c\<^isub>i\<^isub>j)"}
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   624
  stand for all transitions @{term "Y\<^isub>i\<^isub>j \<Turnstile>c\<^isub>i\<^isub>j\<Rightarrow>
159
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   625
  X\<^isub>i"}. 
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   626
  %The intuition behind the equational system is that every 
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   627
  %equation @{text "X\<^isub>i = rhs\<^isub>i"} in this system
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   628
  %corresponds roughly to a state of an automaton whose name is @{text X\<^isub>i} and its predecessor states 
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   629
  %are the @{text "Y\<^isub>i\<^isub>j"}; the @{text "c\<^isub>i\<^isub>j"} are the labels of the transitions from these 
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   630
  %predecessor states to @{text X\<^isub>i}. 
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   631
  There can only be
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   632
  finitely many terms of the form @{text "(Y\<^isub>i\<^isub>j, ATOM c\<^isub>i\<^isub>j)"} in a right-hand side 
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   633
  since by assumption there are only finitely many
159
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   634
  equivalence classes and only finitely many characters.
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   635
  The term @{text "\<lambda>(ONE)"} in the first equation acts as a marker for the initial state, that
159
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   636
  is the equivalence class
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   637
  containing @{text "[]"}.\footnote{Note that we mark, roughly speaking, the
115
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
   638
  single `initial' state in the equational system, which is different from
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   639
  the method by Brzozowski \cite{Brzozowski64}, where he marks the
115
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
   640
  `terminal' states. We are forced to set up the equational system in our
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
   641
  way, because the Myhill-Nerode relation determines the `direction' of the
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
   642
  transitions---the successor `state' of an equivalence class @{text Y} can
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
   643
  be reached by adding a character to the end of @{text Y}. This is also the
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   644
  reason why we have to use our reverse version of Arden's Lemma.}
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   645
  In our running example we have the initial equational system
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   646
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   647
  \begin{equation}\label{exmpcs}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   648
  \mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   649
  @{term "X\<^isub>1"} & @{text "="} & @{text "\<lambda>(ONE)"}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   650
  @{term "X\<^isub>2"} & @{text "="} & @{text "(X\<^isub>1, ATOM c)"}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   651
  @{term "X\<^isub>3"} & @{text "="} & @{text "(X\<^isub>1, ATOM d\<^isub>1) + \<dots> + (X\<^isub>1, ATOM d\<^isub>n)"}\\
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
   652
               & & \mbox{}\hspace{10mm}@{text "+ (X\<^isub>3, ATOM c\<^isub>1) + \<dots> + (X\<^isub>3, ATOM c\<^isub>m)"}
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   653
  \end{tabular}}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   654
  \end{equation}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   655
  
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   656
  \noindent
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   657
  where @{text "d\<^isub>1\<dots>d\<^isub>n"} is the sequence of all characters
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
   658
  but not containing @{text c}, and @{text "c\<^isub>1\<dots>c\<^isub>m"} is the sequence of all
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   659
  characters.  
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   660
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   661
  Overloading the function @{text \<calL>} for the two kinds of terms in the
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   662
  equational system, we have
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   663
  
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   664
  \begin{center}
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   665
  @{text "\<calL>(Y, r) \<equiv>"} %
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   666
  @{thm (rhs) lang_trm.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm}
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
   667
  @{thm lang_trm.simps(1)[where r="r", THEN eq_reflection]}
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   668
  \end{center}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   669
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   670
  \noindent
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   671
  and we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   672
  %
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   673
  \begin{equation}\label{inv1}
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   674
  @{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)"}.
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   675
  \end{equation}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   676
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   677
  \noindent
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   678
  hold. Similarly for @{text "X\<^isub>1"} we can show the following equation
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   679
  %
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   680
  \begin{equation}\label{inv2}
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   681
  @{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))"}.
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   682
  \end{equation}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   683
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   684
  \noindent
160
ea2e5acbfe4a added comments from Chunhan
urbanc
parents: 159
diff changeset
   685
  holds. The reason for adding the @{text \<lambda>}-marker to our initial equational system is 
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   686
  to obtain this equation: it only holds with the marker, since none of 
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   687
  the other terms contain the empty string. The point of the initial equational system is
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   688
  that solving it means we will be able to extract a regular expression for every equivalence class. 
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   689
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   690
  Our representation for the equations in Isabelle/HOL are pairs,
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   691
  where the first component is an equivalence class (a set of strings)
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   692
  and the second component
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   693
  is a set of terms. Given a set of equivalence
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   694
  classes @{text CS}, our initial equational system @{term "Init CS"} is thus 
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   695
  formally defined as
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   696
  %
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   697
  \begin{equation}\label{initcs}
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   698
  \mbox{\begin{tabular}{rcl}     
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   699
  @{thm (lhs) Init_rhs_def} & @{text "\<equiv>"} & 
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   700
  @{text "if"}~@{term "[] \<in> X"}\\
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   701
  & & @{text "then"}~@{term "{Trn Y (ATOM c) | Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X} \<union> {Lam ONE}"}\\
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
   702
  & & @{text "else"}~@{term "{Trn Y (ATOM c)| Y c. Y \<in> CS \<and> Y \<Turnstile>c\<Rightarrow> X}"}\\
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   703
  @{thm (lhs) Init_def}     & @{text "\<equiv>"} & @{thm (rhs) Init_def}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   704
  \end{tabular}}
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   705
  \end{equation}
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   706
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   707
  
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   708
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   709
  \noindent
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   710
  Because we use sets of terms 
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   711
  for representing the right-hand sides of equations, we can 
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   712
  prove \eqref{inv1} and \eqref{inv2} more concisely as
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   713
  %
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   714
  \begin{lmm}\label{inv}
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   715
  If @{thm (prem 1) test} then @{text "X = \<Union> \<calL> ` rhs"}.
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   716
  \end{lmm}
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   717
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   718
  \noindent
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   719
  Our proof of Thm.~\ref{myhillnerodeone} will proceed by transforming the
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   720
  initial equational system into one in \emph{solved form} maintaining the invariant
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   721
  in Lem.~\ref{inv}. From the solved form we will be able to read
89
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
   722
  off the regular expressions. 
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
   723
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   724
  In order to transform an equational system into solved form, we have two 
89
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
   725
  operations: one that takes an equation of the form @{text "X = rhs"} and removes
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   726
  any recursive occurrences of @{text X} in the @{text rhs} using our variant of Arden's 
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   727
  Lemma. The other operation takes an equation @{text "X = rhs"}
89
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
   728
  and substitutes @{text X} throughout the rest of the equational system
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   729
  adjusting the remaining regular expressions appropriately. To define this adjustment 
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   730
  we define the \emph{append-operation} taking a term and a regular expression as argument
89
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
   731
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
   732
  \begin{center}
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   733
  \begin{tabular}{r@ {\hspace{2mm}}c@ {\hspace{2mm}}l}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   734
  @{thm (lhs) Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   735
  & @{text "\<equiv>"} & 
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   736
  @{thm (rhs) Append_rexp.simps(2)[where X="Y" and r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   737
  @{thm (lhs) Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   738
  & @{text "\<equiv>"} & 
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   739
  @{thm (rhs) Append_rexp.simps(1)[where r="r\<^isub>1" and rexp="r\<^isub>2", THEN eq_reflection]}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   740
  \end{tabular}
89
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
   741
  \end{center}
42af13d194c9 a bit more on the paper
urbanc
parents: 88
diff changeset
   742
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
   743
  \noindent
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   744
  We lift this operation to entire right-hand sides of equations, written as
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   745
  @{thm (lhs) Append_rexp_rhs_def[where rexp="r"]}. With this we can define
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   746
  the \emph{arden-operation} for an equation of the form @{text "X = rhs"} as:
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   747
  %
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   748
  \begin{equation}\label{arden_def}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   749
  \mbox{\begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l}
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 93
diff changeset
   750
  @{thm (lhs) Arden_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ 
5b12cd0a3b3c latest on the paper
urbanc
parents: 93
diff changeset
   751
   & & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   752
   & & @{text "r' ="}   & @{term "Star (\<Uplus> {r. Trn X r \<in> rhs})"}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   753
   & &  \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "Append_rexp_rhs rhs' r'"}}\\ 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   754
  \end{tabular}}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   755
  \end{equation}
93
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   756
2aa3756dcc9f more on the paper
urbanc
parents: 92
diff changeset
   757
  \noindent
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   758
  In this definition, we first delete all terms of the form @{text "(X, r)"} from @{text rhs};
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   759
  then we calculate the combined regular expressions for all @{text r} coming 
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   760
  from the deleted @{text "(X, r)"}, and take the @{const Star} of it;
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   761
  finally we append this regular expression to @{text rhs'}. If we apply this
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   762
  operation to the right-hand side of @{text "X\<^isub>3"} in \eqref{exmpcs}, we obtain
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   763
  the equation:
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   764
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   765
  \begin{center}
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   766
  \begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   767
  @{term "X\<^isub>3"} & @{text "="} & 
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
   768
    @{text "(X\<^isub>1, TIMES (ATOM d\<^isub>1) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM c\<^isub>1,\<dots>, ATOM c\<^isub>m})) + \<dots> "}\\
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   769
  & & \mbox{}\hspace{13mm}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
   770
     @{text "\<dots> + (X\<^isub>1, TIMES (ATOM d\<^isub>n) (STAR \<^raw:\ensuremath{\bigplus}>{ATOM c\<^isub>1,\<dots>, ATOM c\<^isub>m}))"}
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   771
  \end{tabular}
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   772
  \end{center}
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   773
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   774
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   775
  \noindent
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   776
  That means we eliminated the dependency of @{text "X\<^isub>3"} on the
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   777
  right-hand side.  Note we used the abbreviation 
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
   778
  @{text "\<^raw:\ensuremath{\bigplus}>{ATOM c\<^isub>1,\<dots>, ATOM c\<^isub>m}"} 
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   779
  to stand for a regular expression that matches with every character. In 
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
   780
  our algorithm we are only interested in the existence of such a regular expression
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
   781
  and do not specify it any further. 
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   782
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   783
  It can be easily seen that the @{text "Arden"}-operation mimics Arden's
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   784
  Lemma on the level of equations. To ensure the non-emptiness condition of
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   785
  Arden's Lemma we say that a right-hand side is @{text ardenable} provided
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   786
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   787
  \begin{center}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   788
  @{thm ardenable_def}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   789
  \end{center}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   790
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   791
  \noindent
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   792
  This allows us to prove a version of Arden's Lemma on the level of equations.
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   793
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   794
  \begin{lmm}\label{ardenable}
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   795
  Given an equation @{text "X = rhs"}.
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   796
  If @{text "X = \<Union>\<calL> ` rhs"},
179
edacc141060f small improvements
urbanc
parents: 178
diff changeset
   797
  @{thm (prem 2) Arden_preserves_soundness}, and
edacc141060f small improvements
urbanc
parents: 178
diff changeset
   798
  @{thm (prem 3) Arden_preserves_soundness}, then
135
604518f0127f final polished
urbanc
parents: 134
diff changeset
   799
  @{text "X = \<Union>\<calL> ` (Arden X rhs)"}.
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   800
  \end{lmm}
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   801
  
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   802
  \noindent
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   803
  Our @{text ardenable} condition is slightly stronger than needed for applying Arden's Lemma,
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   804
  but we can still ensure that it holds troughout our algorithm of transforming equations
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   805
  into solved form. The \emph{substitution-operation} takes an equation
95
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   806
  of the form @{text "X = xrhs"} and substitutes it into the right-hand side @{text rhs}.
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 93
diff changeset
   807
5b12cd0a3b3c latest on the paper
urbanc
parents: 93
diff changeset
   808
  \begin{center}
95
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   809
  \begin{tabular}{rc@ {\hspace{2mm}}r@ {\hspace{1mm}}l}
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   810
  @{thm (lhs) Subst_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "let"}}\\ 
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   811
   & & @{text "rhs' ="} & @{term "rhs - {Trn X r | r. Trn X r \<in> rhs}"} \\
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   812
   & & @{text "r' ="}   & @{term "\<Uplus> {r. Trn X r \<in> rhs}"}\\
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   813
   & &  \multicolumn{2}{@ {\hspace{-2mm}}l}{@{text "in"}~~@{term "rhs' \<union> Append_rexp_rhs xrhs r'"}}\\ 
95
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   814
  \end{tabular}
94
5b12cd0a3b3c latest on the paper
urbanc
parents: 93
diff changeset
   815
  \end{center}
95
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   816
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   817
  \noindent
134
08afbed1c8c7 chunhan's comments
urbanc
parents: 133
diff changeset
   818
  We again delete first all occurrences of @{text "(X, r)"} in @{text rhs}; we then calculate
95
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   819
  the regular expression corresponding to the deleted terms; finally we append this
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   820
  regular expression to @{text "xrhs"} and union it up with @{text rhs'}. When we use
9540c2f2ea77 more things
urbanc
parents: 94
diff changeset
   821
  the substitution operation we will arrange it so that @{text "xrhs"} does not contain
178
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   822
  any occurrence of @{text X}. For example substituting the first equation in
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   823
  \eqref{exmpcs} into the right-hand side of the second, thus eliminating the equivalence 
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   824
  class @{text "X\<^isub>1"}, gives us the equation
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   825
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   826
  \begin{equation}\label{exmpresult}
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   827
  \mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   828
  @{term "X\<^isub>2"} & @{text "="} & @{text "\<lambda>(TIMES ONE (ATOM c))"}\\
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   829
  \end{tabular}}
c6ebfe052109 added more examles
urbanc
parents: 177
diff changeset
   830
  \end{equation}
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   831
134
08afbed1c8c7 chunhan's comments
urbanc
parents: 133
diff changeset
   832
  With these two operations in place, we can define the operation that removes one equation
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   833
  from an equational systems @{text ES}. The operation @{const Subst_all}
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   834
  substitutes an equation @{text "X = xrhs"} throughout an equational system @{text ES}; 
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   835
  @{const Remove} then completely removes such an equation from @{text ES} by substituting 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   836
  it to the rest of the equational system, but first eliminating all recursive occurrences
96
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   837
  of @{text X} by applying @{const Arden} to @{text "xrhs"}.
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   838
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   839
  \begin{center}
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   840
  \begin{tabular}{rcl}
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   841
  @{thm (lhs) Subst_all_def} & @{text "\<equiv>"} & @{thm (rhs) Subst_all_def}\\
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   842
  @{thm (lhs) Remove_def}    & @{text "\<equiv>"} & @{thm (rhs) Remove_def}
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   843
  \end{tabular}
3b9deda4f459 simplified a bit the proof
urbanc
parents: 95
diff changeset
   844
  \end{center}
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   845
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   846
  \noindent
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   847
  Finally, we can define how an equational system should be solved. For this 
107
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
   848
  we will need to iterate the process of eliminating equations until only one equation
154
7c68b9ad4486 implemented most suggestions from the reviewers
urbanc
parents: 149
diff changeset
   849
  will be left in the system. However, we do not just want to have any equation
107
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
   850
  as being the last one, but the one involving the equivalence class for 
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
   851
  which we want to calculate the regular 
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   852
  expression. Let us suppose this equivalence class is @{text X}. 
107
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
   853
  Since @{text X} is the one to be solved, in every iteration step we have to pick an
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   854
  equation to be eliminated that is different from @{text X}. In this way 
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   855
  @{text X} is kept to the final step. The choice is implemented using Hilbert's choice 
107
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
   856
  operator, written @{text SOME} in the definition below.
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   857
  
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   858
  \begin{center}
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   859
  \begin{tabular}{rc@ {\hspace{4mm}}r@ {\hspace{1mm}}l}
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   860
  @{thm (lhs) Iter_def} & @{text "\<equiv>"}~~\mbox{} & \multicolumn{2}{@ {\hspace{-4mm}}l}{@{text "let"}}\\ 
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   861
   & & @{text "(Y, yrhs) ="} & @{term "SOME (Y, yrhs). (Y, yrhs) \<in> ES \<and> X \<noteq> Y"} \\
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   862
   & &  \multicolumn{2}{@ {\hspace{-4mm}}l}{@{text "in"}~~@{term "Remove ES Y yrhs"}}\\ 
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   863
  \end{tabular}
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   864
  \end{center}
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   865
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   866
  \noindent
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   867
  The last definition we need applies @{term Iter} over and over until a condition 
159
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
   868
  @{text Cond} is \emph{not} satisfied anymore. This condition states that there
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   869
  are more than one equation left in the equational system @{text ES}. To solve
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   870
  an equational system we use Isabelle/HOL's @{text while}-operator as follows:
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   871
  
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   872
  \begin{center}
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   873
  @{thm Solve_def}
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   874
  \end{center}
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
   875
101
d3fe0597080a updated paper
urbanc
parents: 100
diff changeset
   876
  \noindent
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   877
  We are not concerned here with the definition of this operator
115
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
   878
  (see Berghofer and Nipkow \cite{BerghoferNipkow00}), but note that we eliminate
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   879
  in each @{const Iter}-step a single equation, and therefore 
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   880
  have a well-founded termination order by taking the cardinality 
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   881
  of the equational system @{text ES}. This enables us to prove
115
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
   882
  properties about our definition of @{const Solve} when we `call' it with
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   883
  the equivalence class @{text X} and the initial equational system 
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   884
  @{term "Init (UNIV // \<approx>A)"} from
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   885
  \eqref{initcs} using the principle:
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   886
  %
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   887
  \begin{equation}\label{whileprinciple}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   888
  \mbox{\begin{tabular}{l}
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   889
  @{term "invariant (Init (UNIV // \<approx>A))"} \\
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   890
  @{term "\<forall>ES. invariant ES \<and> Cond ES \<longrightarrow> invariant (Iter X ES)"}\\
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   891
  @{term "\<forall>ES. invariant ES \<and> Cond ES \<longrightarrow> card (Iter X ES) < card ES"}\\
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   892
  @{term "\<forall>ES. invariant ES \<and> \<not> Cond ES \<longrightarrow> P ES"}\\
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   893
  \hline
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   894
  \multicolumn{1}{c}{@{term "P (Solve X (Init (UNIV // \<approx>A)))"}}
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   895
  \end{tabular}}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   896
  \end{equation}
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   897
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   898
  \noindent
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   899
  This principle states that given an invariant (which we will specify below) 
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   900
  we can prove a property
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   901
  @{text "P"} involving @{const Solve}. For this we have to discharge the following
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   902
  proof obligations: first the
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   903
  initial equational system satisfies the invariant; second the iteration
154
7c68b9ad4486 implemented most suggestions from the reviewers
urbanc
parents: 149
diff changeset
   904
  step @{text "Iter"} preserves the invariant as long as the condition @{term Cond} holds;
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   905
  third @{text "Iter"} decreases the termination order, and fourth that
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   906
  once the condition does not hold anymore then the property @{text P} must hold.
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   907
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   908
  The property @{term P} in our proof will state that @{term "Solve X (Init (UNIV // \<approx>A))"}
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   909
  returns with a single equation @{text "X = xrhs"} for some @{text "xrhs"}, and
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   910
  that this equational system still satisfies the invariant. In order to get
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   911
  the proof through, the invariant is composed of the following six properties:
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   912
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   913
  \begin{center}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   914
  \begin{tabular}{@ {}rcl@ {\hspace{-13mm}}l @ {}}
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   915
  @{text "invariant ES"} & @{text "\<equiv>"} &
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   916
      @{term "finite ES"} & @{text "(finiteness)"}\\
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   917
  & @{text "\<and>"} & @{thm (rhs) finite_rhs_def} & @{text "(finiteness rhs)"}\\
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   918
  & @{text "\<and>"} & @{text "\<forall>(X, rhs)\<in>ES. X = \<Union>\<calL> ` rhs"} & @{text "(soundness)"}\\
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   919
  & @{text "\<and>"} & @{thm (rhs) distinctness_def}\\
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   920
  &             &  & @{text "(distinctness)"}\\
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   921
  & @{text "\<and>"} & @{thm (rhs) ardenable_all_def} & @{text "(ardenable)"}\\   
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
   922
  & @{text "\<and>"} & @{thm (rhs) validity_def} & @{text "(validity)"}\\
103
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   923
  \end{tabular}
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   924
  \end{center}
f460d5f75cb5 updated
urbanc
parents: 101
diff changeset
   925
 
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   926
  \noindent
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   927
  The first two ensure that the equational system is always finite (number of equations
160
ea2e5acbfe4a added comments from Chunhan
urbanc
parents: 159
diff changeset
   928
  and number of terms in each equation); the third makes sure the `meaning' of the 
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   929
  equations is preserved under our transformations. The other properties are a bit more
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   930
  technical, but are needed to get our proof through. Distinctness states that every
154
7c68b9ad4486 implemented most suggestions from the reviewers
urbanc
parents: 149
diff changeset
   931
  equation in the system is distinct. @{text Ardenable} ensures that we can always
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   932
  apply the @{text Arden} operation. 
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   933
  The last property states that every @{text rhs} can only contain equivalence classes
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   934
  for which there is an equation. Therefore @{text lhss} is just the set containing 
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   935
  the first components of an equational system,
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   936
  while @{text "rhss"} collects all equivalence classes @{text X} in the terms of the 
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
   937
  form @{term "Trn X r"}. That means formally @{thm (lhs) lhss_def}~@{text "\<equiv> {X | (X, rhs) \<in> ES}"} 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   938
  and @{thm (lhs) rhss_def}~@{text "\<equiv> {X | (X, r) \<in> rhs}"}.
108
212bfa431fa5 filled details in one place
urbanc
parents: 107
diff changeset
   939
  
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   940
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   941
  It is straightforward to prove that the initial equational system satisfies the
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   942
  invariant.
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   943
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   944
  \begin{lmm}\label{invzero}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   945
  @{thm[mode=IfThen] Init_ES_satisfies_invariant}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   946
  \end{lmm}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   947
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   948
  \begin{proof}
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   949
  Finiteness is given by the assumption and the way how we set up the 
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   950
  initial equational system. Soundness is proved in Lem.~\ref{inv}. Distinctness
154
7c68b9ad4486 implemented most suggestions from the reviewers
urbanc
parents: 149
diff changeset
   951
  follows from the fact that the equivalence classes are disjoint. The @{text ardenable}
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   952
  property also follows from the setup of the initial equational system, as does 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   953
  validity.
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   954
  \end{proof}
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   955
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   956
  \noindent
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   957
  Next we show that @{text Iter} preserves the invariant.
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   958
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   959
  \begin{lmm}\label{iterone}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   960
  @{thm[mode=IfThen] iteration_step_invariant[where xrhs="rhs"]}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   961
  \end{lmm}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   962
107
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
   963
  \begin{proof} 
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   964
  The argument boils down to choosing an equation @{text "Y = yrhs"} to be eliminated
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   965
  and to show that @{term "Subst_all (ES - {(Y, yrhs)}) Y (Arden Y yrhs)"} 
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   966
  preserves the invariant.
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   967
  We prove this as follows:
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   968
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   969
  \begin{center}
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   970
  \begin{tabular}{@ {}l@ {}}
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   971
  @{text "\<forall> ES."}\\ \mbox{}\hspace{5mm}@{thm (prem 1) Subst_all_satisfies_invariant} implies
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   972
  @{thm (concl) Subst_all_satisfies_invariant}
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
   973
  \end{tabular}
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   974
  \end{center}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   975
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   976
  \noindent
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
   977
  Finiteness is straightforward, as the @{const Subst} and @{const Arden} operations 
116
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
   978
  keep the equational system finite. These operations also preserve soundness 
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   979
  and distinctness (we proved soundness for @{const Arden} in Lem.~\ref{ardenable}).
154
7c68b9ad4486 implemented most suggestions from the reviewers
urbanc
parents: 149
diff changeset
   980
  The property @{text ardenable} is clearly preserved because the append-operation
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   981
  cannot make a regular expression to match the empty string. Validity is
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   982
  given because @{const Arden} removes an equivalence class from @{text yrhs}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   983
  and then @{const Subst_all} removes @{text Y} from the equational system.
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
   984
  Having proved the implication above, we can instantiate @{text "ES"} with @{text "ES - {(Y, yrhs)}"}
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
   985
  which matches with our proof-obligation of @{const "Subst_all"}. Since
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
   986
  \mbox{@{term "ES = ES - {(Y, yrhs)} \<union> {(Y, yrhs)}"}}, we can use the assumption 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
   987
  to complete the proof.
107
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
   988
  \end{proof}
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
   989
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   990
  \noindent
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   991
  We also need the fact that @{text Iter} decreases the termination measure.
ec774952190c polished everything
urbanc
parents: 112
diff changeset
   992
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   993
  \begin{lmm}\label{itertwo}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   994
  @{thm[mode=IfThen] iteration_step_measure[simplified (no_asm), where xrhs="rhs"]}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
   995
  \end{lmm}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
   996
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   997
  \begin{proof}
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   998
  By assumption we know that @{text "ES"} is finite and has more than one element.
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
   999
  Therefore there must be an element @{term "(Y, yrhs) \<in> ES"} with 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1000
  @{term "(Y, yrhs) \<noteq> (X, rhs)"}. Using the distinctness property we can infer
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1001
  that @{term "Y \<noteq> X"}. We further know that @{text "Remove ES Y yrhs"}
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1002
  removes the equation @{text "Y = yrhs"} from the system, and therefore 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1003
  the cardinality of @{const Iter} strictly decreases.
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1004
  \end{proof}
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1005
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1006
  \noindent
134
08afbed1c8c7 chunhan's comments
urbanc
parents: 133
diff changeset
  1007
  This brings us to our property we want to establish for @{text Solve}.
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1008
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1009
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1010
  \begin{lmm}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
  1011
  If @{thm (prem 1) Solve} and @{thm (prem 2) Solve} then there exists
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
  1012
  a @{text rhs} such that  @{term "Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)}"}
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
  1013
  and @{term "invariant {(X, rhs)}"}.
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1014
  \end{lmm}
104
5bd73aa805a7 updated paper
urbanc
parents: 103
diff changeset
  1015
107
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
  1016
  \begin{proof} 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1017
  In order to prove this lemma using \eqref{whileprinciple}, we have to use a slightly
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1018
  stronger invariant since Lem.~\ref{iterone} and \ref{itertwo} have the precondition 
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1019
  that @{term "(X, rhs) \<in> ES"} for some @{text rhs}. This precondition is needed
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1020
  in order to choose in the @{const Iter}-step an equation that is not \mbox{@{term "X = rhs"}}.
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1021
  Therefore our invariant cannot be just @{term "invariant ES"}, but must be 
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1022
  @{term "invariant ES \<and> (\<exists>rhs. (X, rhs) \<in> ES)"}. By assumption 
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1023
  @{thm (prem 2) Solve} and Lem.~\ref{invzero}, the more general invariant holds for
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1024
  the initial equational system. This is premise 1 of~\eqref{whileprinciple}.
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1025
  Premise 2 is given by Lem.~\ref{iterone} and the fact that @{const Iter} might
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1026
  modify the @{text rhs} in the equation @{term "X = rhs"}, but does not remove it.
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1027
  Premise 3 of~\eqref{whileprinciple} is by Lem.~\ref{itertwo}. Now in premise 4
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1028
  we like to show that there exists a @{text rhs} such that @{term "ES = {(X, rhs)}"}
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1029
  and that @{text "invariant {(X, rhs)}"} holds, provided the condition @{text "Cond"}
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1030
  does not holds. By the stronger invariant we know there exists such a @{text "rhs"}
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1031
  with @{term "(X, rhs) \<in> ES"}. Because @{text Cond} is not true, we know the cardinality
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1032
  of @{text ES} is @{text 1}. This means @{text "ES"} must actually be the set @{text "{(X, rhs)}"},
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1033
  for which the invariant holds. This allows us to conclude that 
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1034
  @{term "Solve X (Init (UNIV // \<approx>A)) = {(X, rhs)}"} and @{term "invariant {(X, rhs)}"} hold,
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1035
  as needed.
107
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
  1036
  \end{proof}
6f4f9b7b9891 updated paper
urbanc
parents: 106
diff changeset
  1037
106
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1038
  \noindent
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1039
  With this lemma in place we can show that for every equivalence class in @{term "UNIV // \<approx>A"}
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1040
  there exists a regular expression.
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1041
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1042
  \begin{lmm}\label{every_eqcl_has_reg}
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1043
  @{thm[mode=IfThen] every_eqcl_has_reg}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1044
  \end{lmm}
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1045
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1046
  \begin{proof}
138
2dfe13bc1443 three typos
urbanc
parents: 137
diff changeset
  1047
  By the preceding lemma, we know that there exists a @{text "rhs"} such
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1048
  that @{term "Solve X (Init (UNIV // \<approx>A))"} returns the equation @{text "X = rhs"},
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1049
  and that the invariant holds for this equation. That means we 
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1050
  know @{text "X = \<Union>\<calL> ` rhs"}. We further know that
109
79b37ef9505f minor updated
urbanc
parents: 108
diff changeset
  1051
  this is equal to \mbox{@{text "\<Union>\<calL> ` (Arden X rhs)"}} using the properties of the 
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1052
  invariant and Lem.~\ref{ardenable}. Using the validity property for the equation @{text "X = rhs"},
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
  1053
  we can infer that @{term "rhss rhs \<subseteq> {X}"} and because the @{text Arden} operation
106
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1054
  removes that @{text X} from @{text rhs}, that @{term "rhss (Arden X rhs) = {}"}.
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1055
  This means the right-hand side @{term "Arden X rhs"} can only consist of terms of the form @{term "Lam r"}.
176
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
  1056
  So we can collect those (finitely many) regular expressions @{text rs} and have @{term "X = lang (\<Uplus>rs)"}.
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1057
  With this we can conclude the proof.
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1058
  \end{proof}
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1059
106
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1060
  \noindent
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1061
  Lem.~\ref{every_eqcl_has_reg} allows us to finally give a proof for the first direction
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1062
  of the Myhill-Nerode theorem.
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1063
106
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1064
  \begin{proof}[of Thm.~\ref{myhillnerodeone}]
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1065
  By Lem.~\ref{every_eqcl_has_reg} we know that there exists a regular expression for
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1066
  every equivalence class in @{term "UNIV // \<approx>A"}. Since @{text "finals A"} is
110
e500cab16be4 completed first direction
urbanc
parents: 109
diff changeset
  1067
  a subset of  @{term "UNIV // \<approx>A"}, we also know that for every equivalence class
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1068
  in @{term "finals A"} there exists a regular expression. Moreover by assumption 
106
91dc591de63f updated paper
urbanc
parents: 105
diff changeset
  1069
  we know that @{term "finals A"} must be finite, and therefore there must be a finite
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1070
  set of regular expressions @{text "rs"} such that
176
6969de1eb96b latest version of the journal paper
urbanc
parents: 175
diff changeset
  1071
  @{term "\<Union>(finals A) = lang (\<Uplus>rs)"}.
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1072
  Since the left-hand side is equal to @{text A}, we can use @{term "\<Uplus>rs"} 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1073
  as the regular expression that is needed in the theorem.
105
ae6ad1363eb9 updated paper
urbanc
parents: 104
diff changeset
  1074
  \end{proof}
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
  1075
*}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
  1076
100
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
  1077
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
  1078
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
  1079
2409827d8eb8 updated
urbanc
parents: 98
diff changeset
  1080
section {* Myhill-Nerode, Second Part *}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
  1081
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
  1082
text {*
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1083
  \noindent
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1084
  In this section we will give a proof for establishing the second 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1085
  part of the Myhill-Nerode theorem. It can be formulated in our setting as follows:
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
  1086
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1087
  \begin{thrm}
135
604518f0127f final polished
urbanc
parents: 134
diff changeset
  1088
  Given @{text "r"} is a regular expression, then @{thm Myhill_Nerode2}.
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1089
  \end{thrm}  
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
  1090
116
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1091
  \noindent
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1092
  The proof will be by induction on the structure of @{text r}. It turns out
116
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1093
  the base cases are straightforward.
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1094
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1095
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1096
  \begin{proof}[Base Cases]
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1097
  The cases for @{const ZERO}, @{const ONE} and @{const ATOM} are routine, because 
149
e122cb146ecc added the most current versions of the theories.
urbanc
parents: 145
diff changeset
  1098
  we can easily establish that
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
  1099
114
c5eb5f3065ae updated bib
urbanc
parents: 113
diff changeset
  1100
  \begin{center}
c5eb5f3065ae updated bib
urbanc
parents: 113
diff changeset
  1101
  \begin{tabular}{l}
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
  1102
  @{thm quot_zero_eq}\\
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
  1103
  @{thm quot_one_subset}\\
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
  1104
  @{thm quot_atom_subset}
114
c5eb5f3065ae updated bib
urbanc
parents: 113
diff changeset
  1105
  \end{tabular}
c5eb5f3065ae updated bib
urbanc
parents: 113
diff changeset
  1106
  \end{center}
c5eb5f3065ae updated bib
urbanc
parents: 113
diff changeset
  1107
116
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1108
  \noindent
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1109
  hold, which shows that @{term "UNIV // \<approx>(lang r)"} must be finite.
114
c5eb5f3065ae updated bib
urbanc
parents: 113
diff changeset
  1110
  \end{proof}
109
79b37ef9505f minor updated
urbanc
parents: 108
diff changeset
  1111
116
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1112
  \noindent
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1113
  Much more interesting, however, are the inductive cases. They seem hard to be solved 
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1114
  directly. The reader is invited to try. 
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1115
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1116
  In order to see how our proof proceeds consider the following suggestive picture 
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1117
  taken from Constable et al \cite{Constable00}:
180
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1118
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1119
  \begin{equation}\label{pics}
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1120
  \mbox{\begin{tabular}{c@ {\hspace{10mm}}c@ {\hspace{10mm}}c}
180
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1121
  \begin{tikzpicture}[scale=1]
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1122
  %Circle
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1123
  \draw[thick] (0,0) circle (1.1);    
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1124
  \end{tikzpicture}
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1125
  &
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1126
  \begin{tikzpicture}[scale=1]
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1127
  %Circle
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1128
  \draw[thick] (0,0) circle (1.1);    
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1129
  %Main rays
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1130
  \foreach \a in {0, 90,...,359}
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1131
    \draw[very thick] (0, 0) -- (\a:1.1);
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1132
  \foreach \a / \l in {45/1, 135/2, 225/3, 315/4}
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1133
      \draw (\a: 0.65) node {$a_\l$};
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1134
  \end{tikzpicture}
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1135
  &
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1136
  \begin{tikzpicture}[scale=1]
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1137
  %Circle
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1138
  \draw[thick] (0,0) circle (1.1);    
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1139
  %Main rays
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1140
  \foreach \a in {0, 45,...,359}
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1141
     \draw[very thick] (0, 0) -- (\a:1.1);
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1142
  \foreach \a / \l in {22.5/1.1, 67.5/1.2, 112.5/2.1, 157.5/2.2, 202.4/3.1, 247.5/3.2, 292.5/4.1, 337.5/4.2}
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1143
      \draw (\a: 0.77) node {$a_{\l}$};
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1144
  \end{tikzpicture}\\
b755090d0f3d added a picture
urbanc
parents: 179
diff changeset
  1145
  @{term UNIV} & @{term "UNIV // (\<approx>(lang r))"} & @{term "UNIV // R"}
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1146
  \end{tabular}}
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1147
  \end{equation}
179
edacc141060f small improvements
urbanc
parents: 178
diff changeset
  1148
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1149
  \noindent
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1150
  The relation @{term "\<approx>(lang r)"} partitions the set of all strings into some
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1151
  equivalence classes. To show that there are only finitely many of them, it
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1152
  suffices to show in each induction step that another relation, say @{text
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1153
  R}, has finitely many equivalence classes and refines @{term "\<approx>(lang r)"}. 
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1154
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1155
  \begin{dfntn}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1156
  A relation @{text "R\<^isub>1"} is said to \emph{refine} @{text "R\<^isub>2"}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1157
  provided @{text "R\<^isub>1 \<subseteq> R\<^isub>2"}. 
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1158
  \end{dfntn}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1159
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1160
  \noindent
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1161
  For constructing @{text R} will
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1162
  rely on some \emph{tagging-functions} defined over strings. Given the
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1163
  inductive hypothesis, it will be easy to prove that the \emph{range} of
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1164
  these tagging-functions is finite. The range of a function @{text f} is
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1165
  defined as
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1166
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1167
  \begin{center}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1168
  @{text "range f \<equiv> f ` UNIV"}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1169
  \end{center}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1170
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1171
  \noindent
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1172
  that means we take the image of @{text f} w.r.t.~all elements in the
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1173
  domain. With this we will be able to infer that the tagging-functions, seen
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1174
  as relations, give rise to finitely many equivalence classes. 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1175
  Finally we will show that the tagging-relations are more refined than
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1176
  @{term "\<approx>(lang r)"}, which implies that @{term "UNIV // \<approx>(lang r)"} must
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1177
  also be finite.  We formally define the notion of a \emph{tagging-relation}
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1178
  as follows.
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1179
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1180
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1181
  \begin{dfntn}[Tagging-Relation] Given a tagging-function @{text tag}, then two strings @{text x}
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1182
  and @{text y} are \emph{tag-related} provided
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1183
  \begin{center}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1184
  @{text "x \<^raw:$\threesim$>\<^bsub>tag\<^esub> y \<equiv> tag x = tag y"}\;.
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1185
  \end{center}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1186
  \end{dfntn}
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1187
145
099e20f25b25 corrected small typo
urbanc
parents: 143
diff changeset
  1188
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1189
  In order to establish finiteness of a set @{text A}, we shall use the following powerful
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1190
  principle from Isabelle/HOL's library.
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1191
  %
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1192
  \begin{equation}\label{finiteimageD}
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1193
  @{thm[mode=IfThen] finite_imageD}
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1194
  \end{equation}
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1195
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1196
  \noindent
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1197
  It states that if an image of a set under an injective function @{text f} (injective over this set) 
131
6b4c20714b4f chunhan's comments
urbanc
parents: 130
diff changeset
  1198
  is finite, then the set @{text A} itself must be finite. We can use it to establish the following 
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1199
  two lemmas.
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1200
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1201
  \begin{lmm}\label{finone}
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1202
  @{thm[mode=IfThen] finite_eq_tag_rel}
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1203
  \end{lmm}
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1204
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1205
  \begin{proof}
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1206
  We set in \eqref{finiteimageD}, @{text f} to be @{text "X \<mapsto> tag ` X"}. We have
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1207
  @{text "range f"} to be a subset of @{term "Pow (range tag)"}, which we know must be
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1208
  finite by assumption. Now @{term "f (UNIV // =tag=)"} is a subset of @{text "range f"},
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1209
  and so also finite. Injectivity amounts to showing that @{text "X = Y"} under the
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1210
  assumptions that @{text "X, Y \<in> "}~@{term "UNIV // =tag="} and @{text "f X = f Y"}.
149
e122cb146ecc added the most current versions of the theories.
urbanc
parents: 145
diff changeset
  1211
  From the assumptions we can obtain @{text "x \<in> X"} and @{text "y \<in> Y"} with 
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1212
  @{text "tag x = tag y"}. Since @{text x} and @{text y} are tag-related, this in 
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1213
  turn means that the equivalence classes @{text X}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1214
  and @{text Y} must be equal.
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1215
  \end{proof}
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1216
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1217
  \begin{lmm}\label{fintwo} 
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1218
  Given two equivalence relations @{text "R\<^isub>1"} and @{text "R\<^isub>2"}, whereby
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1219
  @{text "R\<^isub>1"} refines @{text "R\<^isub>2"}.
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1220
  If @{thm (prem 1) refined_partition_finite[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"]}
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1221
  then @{thm (concl) refined_partition_finite[where ?R1.0="R\<^isub>1" and ?R2.0="R\<^isub>2"]}.
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1222
  \end{lmm}
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1223
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1224
  \begin{proof}
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1225
  We prove this lemma again using \eqref{finiteimageD}. This time we set @{text f} to
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1226
  be @{text "X \<mapsto>"}~@{term "{R\<^isub>1 `` {x} | x. x \<in> X}"}. It is easy to see that 
135
604518f0127f final polished
urbanc
parents: 134
diff changeset
  1227
  @{term "finite (f ` (UNIV // R\<^isub>2))"} because it is a subset of @{term "Pow (UNIV // R\<^isub>1)"},
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1228
  which must be finite by assumption. What remains to be shown is that @{text f} is injective
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1229
  on @{term "UNIV // R\<^isub>2"}. This is equivalent to showing that two equivalence 
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1230
  classes, say @{text "X"} and @{text Y}, in @{term "UNIV // R\<^isub>2"} are equal, provided
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1231
  @{text "f X = f Y"}. For @{text "X = Y"} to be equal, we have to find two elements
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1232
  @{text "x \<in> X"} and @{text "y \<in> Y"} such that they are @{text R\<^isub>2} related.
135
604518f0127f final polished
urbanc
parents: 134
diff changeset
  1233
  We know there exists a @{text "x \<in> X"} with \mbox{@{term "X = R\<^isub>2 `` {x}"}}. 
604518f0127f final polished
urbanc
parents: 134
diff changeset
  1234
  From the latter fact we can infer that @{term "R\<^isub>1 ``{x} \<in> f X"}
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1235
  and further @{term "R\<^isub>1 ``{x} \<in> f Y"}. This means we can obtain a @{text y}
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1236
  such that @{term "R\<^isub>1 `` {x} = R\<^isub>1 `` {y}"} holds. Consequently @{text x} and @{text y}
118
c3fa11ee776e first proof
urbanc
parents: 117
diff changeset
  1237
  are @{text "R\<^isub>1"}-related. Since by assumption @{text "R\<^isub>1"} refines @{text "R\<^isub>2"},
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1238
  they must also be @{text "R\<^isub>2"}-related, as we need to show.
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1239
  \end{proof}
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1240
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1241
  \noindent
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1242
  Chaining Lem.~\ref{finone} and \ref{fintwo} together, means in order to show
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1243
  that @{term "UNIV // \<approx>(lang r)"} is finite, we have to construct a tagging-function whose
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1244
  range can be shown to be finite and whose tagging-relation refines @{term "\<approx>(lang r)"}.
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1245
  Let us attempt the @{const PLUS}-case first. We take as tagging-function 
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1246
 
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1247
  \begin{center}
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1248
  @{thm tag_Plus_def[where A="A" and B="B", THEN meta_eq_app]}
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1249
  \end{center}
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1250
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1251
  \noindent
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1252
  where @{text "A"} and @{text "B"} are some arbitrary languages. The reason for this choice 
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1253
  is that we need to establish that @{term "=(tag_Plus A B)="} refines @{term "\<approx>(A \<union> B)"}. 
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1254
  This amounts to showing @{term "x \<approx>A y"} or @{term "x \<approx>B y"} under the assumption
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1255
  @{term "x"}~@{term "=(tag_Plus A B)="}~@{term y}. As we shall see, this definition will 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1256
  provide us with just the right assumptions in order to get the proof through.
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1257
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1258
 \begin{proof}[@{const "PLUS"}-Case]
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1259
  We can show in general, if @{term "finite (UNIV // \<approx>A)"} and @{term "finite
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1260
  (UNIV // \<approx>B)"} then @{term "finite ((UNIV // \<approx>A) \<times> (UNIV // \<approx>B))"}
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1261
  holds. The range of @{term "tag_Plus A B"} is a subset of this product
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1262
  set---so finite. For the refinement proof-obligation, we know that @{term
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1263
  "(\<approx>A `` {x}, \<approx>B `` {x}) = (\<approx>A `` {y}, \<approx>B `` {y})"} holds by assumption. Then
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1264
  clearly either @{term "x \<approx>A y"} or @{term "x \<approx>B y"}, as we needed to
183
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1265
  show. Finally we can discharge this case by setting @{text A} to @{term
c4893e84c88e cleaned up the proofs in Myhill_2
urbanc
parents: 182
diff changeset
  1266
  "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}.
119
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1267
  \end{proof}
ece3f197b92b first two proofs in 2 direction
urbanc
parents: 118
diff changeset
  1268
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1269
  \noindent
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1270
  The @{const TIMES}-case is slightly more complicated. We first prove the
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1271
  following lemma, which will aid the proof about refinement.
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1272
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1273
  \begin{lmm}\label{refinement}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1274
  The relation @{text "\<^raw:$\threesim$>\<^bsub>tag\<^esub>"} refines @{term "\<approx>A"}, provided for
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1275
  all strings @{text x}, @{text y} and @{text z} we have \mbox{@{text "x \<^raw:$\threesim$>\<^bsub>tag\<^esub> y"}}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1276
  and @{term "x @ z \<in> A"} imply @{text "y @ z \<in> A"}.
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1277
  \end{lmm}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1278
109
79b37ef9505f minor updated
urbanc
parents: 108
diff changeset
  1279
121
1cf12a107b03 added directory with the small files and numbers of lines
urbanc
parents: 120
diff changeset
  1280
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1281
  We therefore can analyse how the strings @{text "x @ z"} are in the language
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1282
  @{text A} and then construct an appropriate tagging-function to infer that
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1283
  @{term "y @ z"} are also in @{text A}.  For this we sill need the notion of
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1284
  the set of all possible \emph{partitions} of a string
182
560712a29a36 a version of the proof which dispenses with the notion of string-subtraction
urbanc
parents: 181
diff changeset
  1285
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1286
  \begin{equation}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1287
  @{thm Partitions_def}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1288
  \end{equation}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1289
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1290
  \noindent
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1291
  If we know that @{text "(x\<^isub>p, x\<^isub>s) \<in> Partitions x"}, we will
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1292
  refer to @{text "x\<^isub>p"} as the \emph{prefix} of the string @{text x},
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1293
  respectively to @{text "x\<^isub>s"} as the \emph{suffix}.
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1294
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1295
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1296
  Now assuming  @{term "x @ z \<in> A \<cdot> B"} there are only two possible ways of how to `split' 
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1297
  this string to be in @{term "A \<cdot> B"}:
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
  1298
  %
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1299
  \begin{center}
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1300
  \begin{tabular}{c}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1301
  \scalebox{1}{
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1302
  \begin{tikzpicture}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1303
    \node[draw,minimum height=3.8ex] (x) { $\hspace{4.8em}@{text x}\hspace{4.8em}$ };
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1304
    \node[draw,minimum height=3.8ex, right=-0.03em of x] (za) { $\hspace{0.6em}@{text "z\<^isub>p"}\hspace{0.6em}$ };
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1305
    \node[draw,minimum height=3.8ex, right=-0.03em of za] (zza) { $\hspace{2.6em}@{text "z\<^isub>s"}\hspace{2.6em}$  };
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1306
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1307
    \draw[decoration={brace,transform={yscale=3}},decorate]
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1308
           (x.north west) -- ($(za.north west)+(0em,0em)$)
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1309
               node[midway, above=0.5em]{@{text x}};
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1310
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1311
    \draw[decoration={brace,transform={yscale=3}},decorate]
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1312
           ($(za.north west)+(0em,0ex)$) -- ($(zza.north east)+(0em,0ex)$)
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1313
               node[midway, above=0.5em]{@{text z}};
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1314
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1315
    \draw[decoration={brace,transform={yscale=3}},decorate]
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1316
           ($(x.north west)+(0em,3ex)$) -- ($(zza.north east)+(0em,3ex)$)
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1317
               node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}};
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1318
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1319
    \draw[decoration={brace,transform={yscale=3}},decorate]
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1320
           ($(za.south east)+(0em,0ex)$) -- ($(x.south west)+(0em,0ex)$)
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1321
               node[midway, below=0.5em]{@{text "x @ z\<^isub>p \<in> A"}};
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1322
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1323
    \draw[decoration={brace,transform={yscale=3}},decorate]
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1324
           ($(zza.south east)+(0em,0ex)$) -- ($(za.south east)+(0em,0ex)$)
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1325
               node[midway, below=0.5em]{@{text "z\<^isub>s \<in> B"}};
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1326
  \end{tikzpicture}}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1327
  \\[2mm]
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1328
  \scalebox{1}{
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1329
  \begin{tikzpicture}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1330
    \node[draw,minimum height=3.8ex] (xa) { $\hspace{3em}@{text "x\<^isub>p"}\hspace{3em}$ };
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1331
    \node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.2em}@{text "x\<^isub>s"}\hspace{0.2em}$ };
159
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
  1332
    \node[draw,minimum height=3.8ex, right=-0.03em of xxa] (z) { $\hspace{5em}@{text z}\hspace{5em}$ };
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1333
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1334
    \draw[decoration={brace,transform={yscale=3}},decorate]
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1335
           (xa.north west) -- ($(xxa.north east)+(0em,0em)$)
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1336
               node[midway, above=0.5em]{@{text x}};
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1337
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1338
    \draw[decoration={brace,transform={yscale=3}},decorate]
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1339
           (z.north west) -- ($(z.north east)+(0em,0em)$)
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1340
               node[midway, above=0.5em]{@{text z}};
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1341
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1342
    \draw[decoration={brace,transform={yscale=3}},decorate]
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1343
           ($(xa.north west)+(0em,3ex)$) -- ($(z.north east)+(0em,3ex)$)
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1344
               node[midway, above=0.8em]{@{term "x @ z \<in> A \<cdot> B"}};
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1345
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1346
    \draw[decoration={brace,transform={yscale=3}},decorate]
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1347
           ($(z.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$)
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1348
               node[midway, below=0.5em]{@{term "x\<^isub>s @ z \<in> B"}};
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1349
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1350
    \draw[decoration={brace,transform={yscale=3}},decorate]
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1351
           ($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$)
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1352
               node[midway, below=0.5em]{@{term "x\<^isub>p \<in> A"}};
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1353
  \end{tikzpicture}}
159
990c12ab1562 edits; sqeezed to 16 pages
urbanc
parents: 157
diff changeset
  1354
  \end{tabular}
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1355
  \end{center}
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
  1356
  %
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1357
  \noindent
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1358
  Either @{text x} and a prefix of @{text "z"} is in @{text A} and the rest in @{text B} 
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1359
  (first picture) or there is a prefix of @{text x} in @{text A} and the rest is in @{text B} 
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1360
  (second picture). In both cases we have to show that @{term "y @ z \<in> A \<cdot> B"}. The first case
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1361
  we will only go through if we know that  @{term "x \<approx>A y"} holds @{text "(*)"}. Because then 
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1362
  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"}.
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1363
  In the second case we only know that @{text "x\<^isub>p"} and @{text "x\<^isub>s"} is one possible partition
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1364
  of the string @{text x}. We have to know that both @{text "x\<^isub>p"} and the
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1365
  corresponding partition @{text "y\<^isub>p"} are in @{text "A"}, and that @{text "x\<^isub>s"} is `@{text B}-related' 
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1366
  to @{text "y\<^isub>s"} @{text "(**)"}. From the latter fact we can infer that @{text "y\<^isub>s @ z \<in> B"}.
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1367
  This will solve the second case.
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1368
  Taking the two requirements, @{text "(*)"} and @{text "(**)"}, together we define the
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1369
  tagging-function in the @{const Times}-case as:
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1370
121
1cf12a107b03 added directory with the small files and numbers of lines
urbanc
parents: 120
diff changeset
  1371
  \begin{center}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1372
  @{thm (lhs) tag_Times_def[where ?A="A" and ?B="B"]}~@{text "\<equiv>"}~
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1373
  @{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})"}
121
1cf12a107b03 added directory with the small files and numbers of lines
urbanc
parents: 120
diff changeset
  1374
  \end{center}
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1375
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1376
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1377
  We have to make the assumption for all suffixes @{text "x\<^isub>s"}, since we do 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1378
  not know anything about how the string @{term x} is partitioned.
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1379
  With this definition in place, let us prove the @{const "Times"}-case.
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1380
125
62925473bf6b added pictures for seq-case
urbanc
parents: 124
diff changeset
  1381
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1382
  \begin{proof}[@{const TIMES}-Case]
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1383
  If @{term "finite (UNIV // \<approx>A)"} and @{term "finite (UNIV // \<approx>B)"}
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1384
  then @{term "finite ((UNIV // \<approx>A) \<times> (Pow (UNIV // \<approx>B)))"} holds. The range of
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1385
  @{term "tag_Times A B"} is a subset of this product set, and therefore finite.
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1386
  For the refinement of @{term "\<approx>(A \<cdot> B)"} and @{text "\<^raw:$\threesim$>\<^bsub>\<times>tag A B\<^esub>"}, 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1387
  we have by Lemma \ref{refinement} 
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1388
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1389
  \begin{center}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1390
   @{term "tag_Times A B x = tag_Times A B y"}
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1391
  \end{center}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1392
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1393
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1394
  and @{term "x @ z \<in> A \<cdot> B"}, and have to establish @{term "y @ z \<in> A \<cdot>
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1395
  B"}. As shown in the pictures above, there are two cases to be
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1396
  considered. First, there exists a @{text "z\<^isub>p"} and @{text
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1397
  "z\<^isub>s"} such that @{term "x @ z\<^isub>p \<in> A"} and @{text "z\<^isub>s
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1398
  \<in> B"}.  By the assumption about @{term "tag_Times A B"} we have @{term "\<approx>A
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1399
  `` {x} = \<approx>A `` {y}"} and thus @{term "x \<approx>A y"}. Hence by the Myhill-Nerode
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1400
  relation @{term "y @ z\<^isub>p \<in> A"} holds. Using @{text "z\<^isub>s \<in> B"},
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1401
  we can conclude in this case with @{term "y @ z \<in> A \<cdot> B"} (recall @{text
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1402
  "z\<^isub>p @ z\<^isub>s = z"}).
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1403
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1404
  Second there exists a partition @{text "x\<^isub>p"} and @{text "x\<^isub>s"} with 
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1405
  @{text "x\<^isub>p \<in> A"} and @{text "x\<^isub>s @ z \<in> B"}. We therefore have
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1406
  
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1407
  \begin{center}
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1408
  @{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}"}
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1409
  \end{center}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1410
  
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1411
  \noindent
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1412
  and by the assumption about @{term "tag_Times A B"} also 
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1413
  
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1414
  \begin{center}
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1415
  @{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}"}
127
8440863a9900 seq case finished
urbanc
parents: 126
diff changeset
  1416
  \end{center}
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1417
  
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1418
  \noindent
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1419
  This means there must be a partition @{text "y\<^isub>p"} and @{text "y\<^isub>s"}
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1420
  such that @{term "y\<^isub>p \<in> A"} and @{term "\<approx>B `` {x\<^isub>s} = \<approx>B ``
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1421
  {y\<^isub>s}"}. Unfolding the Myhill-Nerode relation and together with the
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1422
  facts that @{text "x\<^isub>p \<in> A"} and \mbox{@{text "x\<^isub>s @ z \<in> B"}}, we
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1423
  obtain @{term "y\<^isub>p \<in> A"} and @{text "y\<^isub>s @ z \<in> B"}, as needed in
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1424
  this case.  We again can complete the @{const TIMES}-case by setting @{text
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1425
  A} to @{term "lang r\<^isub>1"} and @{text B} to @{term "lang r\<^isub>2"}.
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1426
  \end{proof}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1427
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1428
  \noindent
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1429
  The case for @{const Star} is similar to @{const TIMES}, but poses a few
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1430
  extra challenges.  To deal with them, we define first the notion of a \emph{string
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1431
  prefix} and a \emph{strict string prefix}:
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1432
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1433
  \begin{center}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1434
  \begin{tabular}{l}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1435
  @{text "x \<le> y \<equiv> \<exists>z. y = x @ z"}\\
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1436
  @{text "x < y \<equiv> x \<le> y \<and> x \<noteq> y"}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1437
  \end{tabular}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1438
  \end{center}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1439
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1440
  When analysing the case of @{text "x @ z"} being an element in @{term "A\<star>"}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1441
  and @{text x} is not the empty string, we have the following picture:
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1442
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1443
  \begin{center}
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1444
  \scalebox{1}{
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1445
  \begin{tikzpicture}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1446
    \node[draw,minimum height=3.8ex] (xa) { $\hspace{4em}@{text "x\<^bsub>pmax\<^esub>"}\hspace{4em}$ };
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1447
    \node[draw,minimum height=3.8ex, right=-0.03em of xa] (xxa) { $\hspace{0.5em}@{text "x\<^bsub>s\<^esub>"}\hspace{0.5em}$ };
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1448
    \node[draw,minimum height=3.8ex, right=-0.03em of xxa] (za) { $\hspace{2em}@{text "z\<^isub>a"}\hspace{2em}$ };
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1449
    \node[draw,minimum height=3.8ex, right=-0.03em of za] (zb) { $\hspace{7em}@{text "z\<^isub>b"}\hspace{7em}$ };
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1450
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1451
    \draw[decoration={brace,transform={yscale=3}},decorate]
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1452
           (xa.north west) -- ($(xxa.north east)+(0em,0em)$)
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1453
               node[midway, above=0.5em]{@{text x}};
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1454
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1455
    \draw[decoration={brace,transform={yscale=3}},decorate]
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1456
           (za.north west) -- ($(zb.north east)+(0em,0em)$)
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1457
               node[midway, above=0.5em]{@{text z}};
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1458
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1459
    \draw[decoration={brace,transform={yscale=3}},decorate]
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1460
           ($(xa.north west)+(0em,3ex)$) -- ($(zb.north east)+(0em,3ex)$)
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1461
               node[midway, above=0.8em]{@{term "x @ z \<in> A\<star>"}};
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1462
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1463
    \draw[decoration={brace,transform={yscale=3}},decorate]
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1464
           ($(za.south east)+(0em,0ex)$) -- ($(xxa.south west)+(0em,0ex)$)
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1465
               node[midway, below=0.5em]{@{term "x\<^isub>s @ z\<^isub>a \<in> A"}};
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1466
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1467
    \draw[decoration={brace,transform={yscale=3}},decorate]
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1468
           ($(xa.south east)+(0em,0ex)$) -- ($(xa.south west)+(0em,0ex)$)
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1469
               node[midway, below=0.5em]{@{text "x\<^bsub>pmax\<^esub> \<in> A\<^isup>\<star>"}};
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1470
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1471
    \draw[decoration={brace,transform={yscale=3}},decorate]
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1472
           ($(zb.south east)+(0em,0ex)$) -- ($(zb.south west)+(0em,0ex)$)
136
13b0f3dac9a2 final final polishing
urbanc
parents: 135
diff changeset
  1473
               node[midway, below=0.5em]{@{term "z\<^isub>b \<in> A\<star>"}};
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1474
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1475
    \draw[decoration={brace,transform={yscale=3}},decorate]
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1476
           ($(zb.south east)+(0em,-4ex)$) -- ($(xxa.south west)+(0em,-4ex)$)
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1477
               node[midway, below=0.5em]{@{term "x\<^isub>s @ z \<in> A\<star>"}};
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1478
  \end{tikzpicture}}
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1479
  \end{center}
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
  1480
  %
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1481
  \noindent
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1482
  We can find a strict prefix @{text "x\<^isub>p"} of @{text x} such that @{term "x\<^isub>p \<in> A\<star>"},
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1483
  @{text "x\<^isub>p < x"} and the rest @{term "x\<^isub>s @ z \<in> A\<star>"}. For example the empty string 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1484
  @{text "[]"} would do (recall @{term "x \<noteq> []"}).
135
604518f0127f final polished
urbanc
parents: 134
diff changeset
  1485
  There are potentially many such prefixes, but there can only be finitely many of them (the 
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1486
  string @{text x} is finite). Let us therefore choose the longest one and call it 
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1487
  @{text "x\<^bsub>pmax\<^esub>"}. Now for the rest of the string @{text "x\<^isub>s @ z"} we
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1488
  know it is in @{term "A\<star>"} and cannot be the empty string. By Prop.~\ref{langprops}@{text "(iv)"}, 
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1489
  we can separate
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1490
  this string into two parts, say @{text "a"} and @{text "b"}, such that @{text "a \<noteq> []"}, @{text "a \<in> A"}
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1491
  and @{term "b \<in> A\<star>"}. Now @{text a} must be strictly longer than @{text "x\<^isub>s"},
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1492
  otherwise @{text "x\<^bsub>pmax\<^esub>"} is not the longest prefix. That means @{text a}
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1493
  `overlaps' with @{text z}, splitting it into two components @{text "z\<^isub>a"} and
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1494
   @{text "z\<^isub>b"}. For this we know that @{text "x\<^isub>s @ z\<^isub>a \<in> A"} and
135
604518f0127f final polished
urbanc
parents: 134
diff changeset
  1495
  @{term "z\<^isub>b \<in> A\<star>"}. To cut a story short, we have divided @{term "x @ z \<in> A\<star>"}
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1496
  such that we have a string @{text a} with @{text "a \<in> A"} that lies just on the
184
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1497
  `border' of @{text x} and @{text z}. This string is @{text "x\<^isub>s @ z\<^isub>a"}.
2455db3b06ac more on the paper
urbanc
parents: 183
diff changeset
  1498
135
604518f0127f final polished
urbanc
parents: 134
diff changeset
  1499
  In order to show that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}, we use
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1500
  the following tagging-function:
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
  1501
  %
121
1cf12a107b03 added directory with the small files and numbers of lines
urbanc
parents: 120
diff changeset
  1502
  \begin{center}
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1503
  @{thm (lhs) tag_Star_def[where ?A="A", THEN meta_eq_app]}~@{text "\<equiv>"}~
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1504
  @{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>s, x\<^isub>p) \<in> Partitions x}"}
121
1cf12a107b03 added directory with the small files and numbers of lines
urbanc
parents: 120
diff changeset
  1505
  \end{center}
128
6d2693c78c37 finished picture
urbanc
parents: 127
diff changeset
  1506
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
  1507
  \begin{proof}[@{const Star}-Case]
130
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1508
  If @{term "finite (UNIV // \<approx>A)"} 
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1509
  then @{term "finite (Pow (UNIV // \<approx>A))"} holds. The range of
181
97090fc7aa9f some experiments with the proofs in Myhill_2
urbanc
parents: 180
diff changeset
  1510
  @{term "tag_Star A"} is a subset of this set, and therefore finite.
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1511
  Again we have to show under the assumption @{term "x"}~@{term "=(tag_Star A)="}~@{term y}
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1512
  that @{term "x @ z \<in> A\<star>"} implies @{term "y @ z \<in> A\<star>"}.
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1513
130
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1514
  We first need to consider the case that @{text x} is the empty string.
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1515
  From the assumption about strict prefixes in @{text "\<^raw:$\threesim$>\<^bsub>\<star>tag A\<^esub>"}, we 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1516
  can infer @{text y} is the empty string and
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1517
  then clearly have @{term "y @ z \<in> A\<star>"}. In case @{text x} is not the empty
134
08afbed1c8c7 chunhan's comments
urbanc
parents: 133
diff changeset
  1518
  string, we can divide the string @{text "x @ z"} as shown in the picture 
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1519
  above. By the tagging-function and the facts @{text "x\<^bsub>pmax\<^esub> \<in> A\<^isup>\<star>"} and @{text "x\<^bsub>pmax\<^esub> < x"}, 
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1520
  we have
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1521
130
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1522
  \begin{center}
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1523
  @{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}"}
130
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1524
  \end{center}
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1525
  
130
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1526
  \noindent
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1527
  which by assumption is equal to
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1528
  
130
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1529
  \begin{center}
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1530
  @{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}"}
130
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1531
  \end{center}
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1532
  
130
3e4ad22193e7 pre-final version
urbanc
parents: 129
diff changeset
  1533
  \noindent 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1534
  From this we know there exist partitions @{text "y\<^isub>p"} and @{text
185
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1535
  "y\<^isub>s"} with @{term "y\<^isub>p \<in> A\<star>"} and also @{term "x\<^isub>s \<approx>A
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1536
  y\<^isub>s"}. Unfolding the Myhill-Nerode relation we know @{term
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1537
  "y\<^isub>s @ z\<^isub>a \<in> A"}. We also know that @{term "z\<^isub>b \<in> A\<star>"}.
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1538
  Therefore @{term "y\<^isub>p @ (y\<^isub>s @ z\<^isub>a) @ z\<^isub>b \<in>
8749db46d5e6 completed the taging-function section
urbanc
parents: 184
diff changeset
  1539
  A\<star>"}, which means @{term "y @ z \<in> A\<star>"}. As the last step we have to set
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1540
  @{text "A"} to @{term "lang r"} and thus complete the proof.
121
1cf12a107b03 added directory with the small files and numbers of lines
urbanc
parents: 120
diff changeset
  1541
  \end{proof}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
  1542
*}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
  1543
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1544
section {* Second Part proved using Partial Derivatives *}
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1545
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1546
text {*
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1547
  \noindent
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1548
  As we have seen in the previous section, in order to establish
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1549
  the second direction of the Myhill-Nerode theorem, we need to find 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1550
  a more refined relation than @{term "\<approx>(lang r)"} for which we can
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1551
  show that there are only finitely many equivalence classes. So far we 
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1552
  showed this by induction on @{text "r"}. However, there is also 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1553
  an indirect method to come up with such a refined relation based on
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1554
  derivatives of regular expressions \cite{Brzozowski64}. 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1555
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1556
  Assume the following two definitions for a \emph{left-quotient} of a language,
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1557
  which we write as @{term "Der c A"} and @{term "Ders s A"} where @{text c}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1558
  is a character and @{text s} a string:
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1559
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1560
  \begin{center}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1561
  \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{2mm}}l}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1562
  @{thm (lhs) Der_def}  & @{text "\<equiv>"} & @{thm (rhs) Der_def}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1563
  @{thm (lhs) Ders_def} & @{text "\<equiv>"} & @{thm (rhs) Ders_def}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1564
  \end{tabular}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1565
  \end{center}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1566
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1567
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1568
  In order to aid readability, we shall also make use of the following abbreviation:
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1569
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1570
  \begin{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1571
  @{abbrev "Derss s A"}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1572
  \end{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1573
  
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1574
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1575
  \noindent
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1576
  Clearly we have the following relation between the Myhill-Nerode relation
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1577
  (Def.~\ref{myhillneroderel}) and left-quotients
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1578
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1579
  \begin{equation}\label{mhders}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1580
  @{term "x \<approx>A y"} \hspace{4mm}\text{if and only if}\hspace{4mm} @{term "Ders x A = Ders y A"}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1581
  \end{equation}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1582
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1583
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1584
  It is straightforward to establish the following properties for left-quotients:
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1585
  
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1586
  \begin{equation}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1587
  \mbox{\begin{tabular}{l@ {\hspace{1mm}}c@ {\hspace{2mm}}l}
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1588
  @{thm (lhs) Der_simps(1)} & $=$ & @{thm (rhs) Der_simps(1)}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1589
  @{thm (lhs) Der_simps(2)} & $=$ & @{thm (rhs) Der_simps(2)}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1590
  @{thm (lhs) Der_simps(3)} & $=$ & @{thm (rhs) Der_simps(3)}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1591
  @{thm (lhs) Der_simps(4)} & $=$ & @{thm (rhs) Der_simps(4)}\\
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1592
  @{thm (lhs) Der_conc}  & $=$ & @{thm (rhs) Der_conc}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1593
  @{thm (lhs) Der_star}  & $=$ & @{thm (rhs) Der_star}\\
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1594
  @{thm (lhs) Ders_simps(1)} & $=$ & @{thm (rhs) Ders_simps(1)}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1595
  @{thm (lhs) Ders_simps(2)} & $=$ & @{thm (rhs) Ders_simps(2)}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1596
  %@{thm (lhs) Ders_simps(3)[where ?s1.0="s\<^isub>1" and ?s2.0="s\<^isub>2"]}  & $=$ 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1597
  %   & @{thm (rhs) Ders_simps(3)[where ?s1.0="s\<^isub>1" and ?s2.0="s\<^isub>2"]}\\
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1598
  \end{tabular}}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1599
  \end{equation}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1600
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1601
  \noindent
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1602
  where @{text "\<Delta>"} is a function that tests whether the empty string
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1603
  is in the language and returns @{term "{[]}"} or @{term "{}"}, respectively.
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1604
  The only interesting case above is the last one where we use Prop.~\ref{langprops}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1605
  in order to infer that @{term "Der c (A\<star>) = Der c (A \<cdot> A\<star>)"}. We can 
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1606
  then complete the proof by observing that @{term "Delta A \<cdot> Der c (A\<star>) \<subseteq> (Der c A) \<cdot> A\<star>"}.
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1607
  
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1608
  Brzozowski observed that the left-quotients for languages of regular
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1609
  expressions can be calculated directly via the notion of \emph{derivatives
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1610
  of a regular expression} \cite{Brzozowski64}, which we define in Isabelle/HOL as 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1611
  follows:
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1612
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1613
  \begin{center}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1614
  \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1615
  @{thm (lhs) der.simps(1)}  & @{text "\<equiv>"} & @{thm (rhs) der.simps(1)}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1616
  @{thm (lhs) der.simps(2)}  & @{text "\<equiv>"} & @{thm (rhs) der.simps(2)}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1617
  @{thm (lhs) der.simps(3)[where c'="d"]}  & @{text "\<equiv>"} & @{thm (rhs) der.simps(3)[where c'="d"]}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1618
  @{thm (lhs) der.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}  
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1619
     & @{text "\<equiv>"} & @{thm (rhs) der.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1620
  @{thm (lhs) der.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}  
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
  1621
     & @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^isub>1"}~@{text "then"}~%
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
  1622
       @{term "Plus (Times (der c r\<^isub>1) r\<^isub>2) (der c r\<^isub>2)"}\\
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
  1623
     &             & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~%  
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
  1624
                    @{term "Times (der c r\<^isub>1) r\<^isub>2"}\\ 
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1625
  @{thm (lhs) der.simps(6)}  & @{text "\<equiv>"} & @{thm (rhs) der.simps(6)}\smallskip\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1626
  @{thm (lhs) ders.simps(1)}  & @{text "\<equiv>"} & @{thm (rhs) ders.simps(1)}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1627
  @{thm (lhs) ders.simps(2)}  & @{text "\<equiv>"} & @{thm (rhs) ders.simps(2)}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1628
  \end{tabular}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1629
  \end{center}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1630
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1631
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1632
  The last two clauses extend derivatives for characters to strings (list of
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1633
  characters). The list-cons operator is written \mbox{@{text "_ :: _"}}. The
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1634
  function @{term "nullable r"} needed in the @{const Times}-case tests
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1635
  whether a regular expression can recognise the empty string:
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1636
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1637
  \begin{center}
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
  1638
  \begin{tabular}{c@ {\hspace{10mm}}c}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1639
  \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1640
  @{thm (lhs) nullable.simps(1)}  & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(1)}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1641
  @{thm (lhs) nullable.simps(2)}  & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(2)}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1642
  @{thm (lhs) nullable.simps(3)}  & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(3)}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1643
  \end{tabular} &
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1644
  \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1645
  @{thm (lhs) nullable.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}  
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1646
     & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1647
  @{thm (lhs) nullable.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}  
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1648
     & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1649
  @{thm (lhs) nullable.simps(6)}  & @{text "\<equiv>"} & @{thm (rhs) nullable.simps(6)}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1650
  \end{tabular}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1651
  \end{tabular}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1652
  \end{center}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1653
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1654
  \noindent
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1655
  By induction on the regular expression @{text r}, respectively the string @{text s}, 
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1656
  one can easily show that left-quotients and derivatives relate as follows 
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1657
  \cite{Sakarovitch09}:
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1658
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1659
  \begin{equation}\label{Dersders}
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1660
  \mbox{\begin{tabular}{c}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1661
  @{thm Der_der}\\
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1662
  @{thm Ders_ders}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1663
  \end{tabular}}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1664
  \end{equation}
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1665
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1666
  \noindent
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1667
  The importance in the context of the Myhill-Nerode theorem is that 
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1668
  we can use \eqref{mhders} and \eqref{Dersders} in order to 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1669
  establish that @{term "x \<approx>(lang r) y"} is equivalent to
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1670
  @{term "lang (ders x r) = lang (ders y r)"}. From this we obtain
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1671
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1672
  \begin{equation}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1673
  @{term "x \<approx>(lang r) y"}\hspace{4mm}\mbox{provided}\hspace{4mm}@{term "ders x r = ders y r"}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1674
  \end{equation}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1675
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1676
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1677
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1678
  which means the right-hand side (seen as relation) refines the
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1679
  Myhill-Nerode relation.  Consequently, we can use 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1680
  @{text "\<^raw:$\threesim$>\<^bsub>(\<lambda>x. ders x r)\<^esub>"} as a potential tagging-relation
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1681
  for the regular expression @{text r}. However, in
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1682
  order to be useful in the Myhill-Nerode theorem, we also have to show that
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1683
  for the corresponding language there are only finitely many derivatives---ensuring
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1684
  that there are only finitely many equivalence classes. Unfortunately, this
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1685
  is not true in general. Sakarovitch gives an example where a regular
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1686
  expression  has infinitely many derivatives w.r.t.~a language
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1687
  \cite[Page~141]{Sakarovitch09}. What Brzozowski \cite{Brzozowski64} proved
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1688
  is that for every language there \emph{are} only finitely `dissimilar'
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1689
  derivatives for a regular expression. Two regular expressions are said to be
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1690
  \emph{similar} provided they can be identified using the using the @{text
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1691
  "ACI"}-identities:
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1692
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1693
  \begin{equation}\label{ACI}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1694
  \mbox{\begin{tabular}{cl}
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1695
  (@{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)"}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1696
  (@{text C}) & @{term "Plus r\<^isub>1 r\<^isub>2"} $\equiv$ @{term "Plus r\<^isub>2 r\<^isub>1"}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1697
  (@{text I}) & @{term "Plus r r"} $\equiv$ @{term "r"}\\
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1698
  \end{tabular}}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1699
  \end{equation}
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1700
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1701
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1702
  Carrying this idea through, we must not consider the set of all derivatives,
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1703
  but the ones modulo @{text "ACI"}.  In principle, this can be formally
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1704
  defined, but it is very painful in a theorem prover (since there is no
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1705
  direct characterisation of the set of dissimlar derivatives).
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1706
174
2b414a8a7132 more on the section about derivatives
urbanc
parents: 173
diff changeset
  1707
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1708
  Fortunately, there is a much simpler approach using \emph{partial
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1709
  derivatives}. They were introduced by Antimirov \cite{Antimirov95} and can be defined
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1710
  in Isabelle/HOL as follows:
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1711
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1712
  \begin{center}
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1713
  \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}}
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1714
  @{thm (lhs) pder.simps(1)}  & @{text "\<equiv>"} & @{thm (rhs) pder.simps(1)}\\
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1715
  @{thm (lhs) pder.simps(2)}  & @{text "\<equiv>"} & @{thm (rhs) pder.simps(2)}\\
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1716
  @{thm (lhs) pder.simps(3)[where c'="d"]}  & @{text "\<equiv>"} & @{thm (rhs) pder.simps(3)[where c'="d"]}\\
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1717
  @{thm (lhs) pder.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}  
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1718
     & @{text "\<equiv>"} & @{thm (rhs) pder.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1719
  @{thm (lhs) pder.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}  
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
  1720
     & @{text "\<equiv>"} & @{text "if"}~@{term "nullable r\<^isub>1"}~@{text "then"}~%
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1721
       @{term "(Timess (pder c r\<^isub>1) r\<^isub>2) \<union> (pder c r\<^isub>2)"}\\
177
50cc1a39c990 more one the paper
urbanc
parents: 176
diff changeset
  1722
     & & \phantom{@{text "if"}~@{term "nullable r\<^isub>1"}~}@{text "else"}~%  
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1723
                    @{term "Timess (pder c r\<^isub>1) r\<^isub>2"}\\ 
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1724
  @{thm (lhs) pder.simps(6)}  & @{text "\<equiv>"} & @{thm (rhs) pder.simps(6)}\smallskip\\
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1725
  @{thm (lhs) pders.simps(1)}  & @{text "\<equiv>"} & @{thm (rhs) pders.simps(1)}\\
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1726
  @{thm (lhs) pders.simps(2)}  & @{text "\<equiv>"} & @{text "\<Union> (pders s) ` (pder c r)"}\\
175
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1727
  \end{tabular}
edc642266a82 polished the introduction
urbanc
parents: 174
diff changeset
  1728
  \end{center}
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1729
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1730
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1731
  Again the last two clauses extend partial derivatives from characters to strings. 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1732
  Unlike `simple' derivatives, the functions for partial derivatives return sets of regular
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1733
  expressions. In the @{const Times} and @{const Star} cases we therefore use the
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1734
  auxiliary definition
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1735
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1736
  \begin{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1737
  @{text "TIMESS rs r \<equiv> {TIMES r' r | r' \<in> rs}"}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1738
  \end{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1739
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1740
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1741
  in order to `sequence' a regular expression with a set of regular
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1742
  expressions. Note that in the last clause we first build the set of partial
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1743
  derivatives w.r.t~the character @{text c}, then build the image of this set under the
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1744
  function @{term "pders s"} and finally `union up' all resulting sets. It will be
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1745
  convenient to introduce the following abbreviation
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1746
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1747
  \begin{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1748
  @{abbrev "pderss s A"}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1749
  \end{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1750
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1751
  \noindent
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1752
  which simplifies the last clause of @{const "pders"} to
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1753
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1754
  \begin{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1755
  \begin{tabular}{@ {}l@ {\hspace{1mm}}c@ {\hspace{1.5mm}}l@ {}}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1756
  @{thm (lhs) pders.simps(2)}  & @{text "\<equiv>"} & @{thm (rhs) pders.simps(2)}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1757
  \end{tabular}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1758
  \end{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1759
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1760
  Partial derivatives can be seen as having the @{text "ACI"}-identities already built in: 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1761
  taking the partial derivatives of the
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1762
  regular expressions in \eqref{ACI} gives us in each case
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1763
  equal sets.  Antimirov \cite{Antimirov95} showed a similar result to
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1764
  \eqref{Dersders} for partial derivatives:
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1765
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1766
  \begin{equation}
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1767
  \mbox{\begin{tabular}{lc}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1768
  @{text "(i)"}  & @{thm Der_pder}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1769
  @{text "(ii)"} & @{thm Ders_pders}
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1770
  \end{tabular}}
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1771
  \end{equation} 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1772
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1773
  \begin{proof}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1774
  The first fact is by a simple induction on @{text r}. For the second we slightly
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1775
  modify Antimirov's proof by performing an induction on @{text s} where we
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1776
  genaralise over all @{text r}. That means in the @{text "cons"}-case the 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1777
  induction hypothesis is
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1778
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1779
  \begin{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1780
  @{text "(IH)"}\hspace{3mm}@{term "\<forall>r. Ders s (lang r) = \<Union> lang ` (pders s r)"}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1781
  \end{center}
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1782
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1783
  \noindent
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1784
  With this we can establish
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1785
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1786
  \begin{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1787
  \begin{tabular}{r@ {\hspace{1.5mm}}c@ {\hspace{1.5mm}}ll}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1788
  @{term "Ders (c # s) (lang r)"} 
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1789
    & @{text "="} & @{term "Ders s (Der c (lang r))"} & by def.\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1790
    & @{text "="} & @{term "Ders s (\<Union> lang ` (pder c r))"} & by @{text "(i)"}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1791
    & @{text "="} & @{term "\<Union> (Ders s) ` (lang ` (pder c r))"} & by def.~of @{text "Ders"}\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1792
    & @{text "="} & @{term "\<Union> lang ` (\<Union> pders s ` (pder c r))"} & by IH\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1793
    & @{text "="} & @{term "\<Union> lang ` (pders (c # s) r)"} & by def.\\
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1794
  \end{tabular}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1795
  \end{center}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1796
  
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1797
  \noindent
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1798
  In order to apply the induction hypothesis in the fourth step, we need the generalisation
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1799
  over all regular expressions @{text r}. The case for the empty string is routine and omitted.
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1800
  \end{proof}
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1801
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1802
  Antimirov also proved that for every language and regular expression there are only finitely
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1803
  many partial derivatives.
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1804
*}
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1805
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1806
section {* Closure Properties *}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
  1807
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1808
text {*
187
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1809
  \noindent
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1810
  The real beauty of regular languages is that they are closed
9f46a9571e37 more on the derivatives section
urbanc
parents: 186
diff changeset
  1811
  under almost all set operations. Closure under union, concatenation and Kleene-star
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1812
  are trivial to establish given our definition of regularity (Def.~\ref{regular}).
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1813
  More interesting is the closure under complement, because
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1814
  it seems difficult to construct a regular expression for the complement
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1815
  language by direct means. However the existence of such a regular expression
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1816
  can now be easily proved using the Myhill-Nerode theorem since 
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1817
  
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1818
  \begin{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1819
  @{term "s\<^isub>1 \<approx>A s\<^isub>2"} if and only if @{term "s\<^isub>1 \<approx>(-A) s\<^isub>2"}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1820
  \end{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1821
  
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1822
  \noindent
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1823
  holds for any strings @{text "s\<^isub>1"} and @{text
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1824
  "s\<^isub>2"}. Therefore @{text A} and the complement language @{term "-A"}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1825
  give rise to the same partitions.
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1826
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1827
  Once closure under complement is established, closure under intersection
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1828
  and set difference is also easy, because
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1829
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1830
  \begin{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1831
  \begin{tabular}{c}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1832
  @{term "A \<inter> B = - (- A \<union> - B)"}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1833
  @{term "A - B = - (- A \<union> B)"}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1834
  \end{tabular}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1835
  \end{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1836
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1837
  \noindent
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1838
  Closure of regular languages under reversal, which means 
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1839
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1840
  \begin{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1841
  @{text "A\<^bsup>-1\<^esup> \<equiv> {s\<^bsup>-1\<^esup> | s \<in> A}"}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1842
  \end{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1843
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1844
  \noindent 
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1845
  can be shown with the help of the following operation defined on regular
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1846
  expressions
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1847
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1848
  \begin{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1849
  \begin{tabular}{r@ {\hspace{1mm}}c@ {\hspace{1mm}}l}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1850
  @{thm (lhs) Rev.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) Rev.simps(1)}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1851
  @{thm (lhs) Rev.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) Rev.simps(2)}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1852
  @{thm (lhs) Rev.simps(3)} & @{text "\<equiv>"} & @{thm (rhs) Rev.simps(3)}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1853
  @{thm (lhs) Rev.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} & 
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1854
      @{thm (rhs) Rev.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1855
  @{thm (lhs) Rev.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} & 
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1856
      @{thm (rhs) Rev.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1857
  @{thm (lhs) Rev.simps(6)} & @{text "\<equiv>"} & @{thm (rhs) Rev.simps(6)}\\
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1858
  \end{tabular}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1859
  \end{center}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1860
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1861
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1862
  In connection with left-quotient, the perhaps surprising fact is that
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1863
  regular languages are closed under any left-quotient.
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1864
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1865
  
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1866
*}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1867
117
22ba25b808c8 updated second direction
urbanc
parents: 116
diff changeset
  1868
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
  1869
section {* Conclusion and Related Work *}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
  1870
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
  1871
text {*
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1872
  \noindent
112
62fdb4bf7239 more on the conclusion
urbanc
parents: 111
diff changeset
  1873
  In this paper we took the view that a regular language is one where there
115
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
  1874
  exists a regular expression that matches all of its strings. Regular
145
099e20f25b25 corrected small typo
urbanc
parents: 143
diff changeset
  1875
  expressions can conveniently be defined as a datatype in HOL-based theorem
099e20f25b25 corrected small typo
urbanc
parents: 143
diff changeset
  1876
  provers. For us it was therefore interesting to find out how far we can push
154
7c68b9ad4486 implemented most suggestions from the reviewers
urbanc
parents: 149
diff changeset
  1877
  this point of view. We have established in Isabelle/HOL both directions 
7c68b9ad4486 implemented most suggestions from the reviewers
urbanc
parents: 149
diff changeset
  1878
  of the Myhill-Nerode theorem.
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
  1879
  %
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1880
  \begin{thrm}[The Myhill-Nerode Theorem]\mbox{}\\
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
  1881
  A language @{text A} is regular if and only if @{thm (rhs) Myhill_Nerode}.
167
61d0a412a3ae added a journal version
urbanc
parents: 162
diff changeset
  1882
  \end{thrm}
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1883
  
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
  1884
  \noindent
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1885
  Having formalised this theorem means we pushed our point of view quite
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1886
  far. Using this theorem we can obviously prove when a language is \emph{not}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1887
  regular---by establishing that it has infinitely many equivalence classes
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1888
  generated by the Myhill-Nerode relation (this is usually the purpose of the
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1889
  pumping lemma \cite{Kozen97}).  We can also use it to establish the standard
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1890
  textbook results about closure properties of regular languages. Interesting
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1891
  is the case of closure under complement, because it seems difficult to
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1892
  construct a regular expression for the complement language by direct
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1893
  means. However the existence of such a regular expression can be easily
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1894
  proved using the Myhill-Nerode theorem.  Proving the existence of such a
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1895
  regular expression via automata using the standard method would be quite
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1896
  involved. It includes the steps: regular expression @{text "\<Rightarrow>"}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1897
  non-deterministic automaton @{text "\<Rightarrow>"} deterministic automaton @{text "\<Rightarrow>"}
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1898
  complement automaton @{text "\<Rightarrow>"} regular expression.
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1899
112
62fdb4bf7239 more on the conclusion
urbanc
parents: 111
diff changeset
  1900
116
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1901
  While regular expressions are convenient in formalisations, they have some
122
ab6637008963 my latest version (SEQ and STAR still missing)
urbanc
parents: 121
diff changeset
  1902
  limitations. One is that there seems to be no method of calculating a
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1903
  minimal regular expression (for example in terms of length) for a regular
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1904
  language, like there is
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1905
  for automata. On the other hand, efficient regular expression matching,
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1906
  without using automata, poses no problem \cite{OwensReppyTuron09}.
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1907
  For an implementation of a simple regular expression matcher,
122
ab6637008963 my latest version (SEQ and STAR still missing)
urbanc
parents: 121
diff changeset
  1908
  whose correctness has been formally established, we refer the reader to
ab6637008963 my latest version (SEQ and STAR still missing)
urbanc
parents: 121
diff changeset
  1909
  Owens and Slind \cite{OwensSlind08}.
116
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1910
342983676c8f included comments by Chunhan
urbanc
parents: 115
diff changeset
  1911
143
1cc87efb3b53 formalisation of first direction is now only 780 loc
urbanc
parents: 142
diff changeset
  1912
  Our formalisation consists of 780 lines of Isabelle/Isar code for the first
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1913
  direction and 460 for the second, plus around 300 lines of standard material
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1914
  about regular languages. While this might be seen large, it should be seen
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1915
  in the context of the work done by Constable at al \cite{Constable00} who
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1916
  formalised the Myhill-Nerode theorem in Nuprl using automata. They write
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1917
  that their four-member team needed something on the magnitude of 18 months
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1918
  for their formalisation. The estimate for our formalisation is that we
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1919
  needed approximately 3 months and this included the time to find our proof
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1920
  arguments. Unlike Constable et al, who were able to follow the proofs from
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1921
  \cite{HopcroftUllman69}, we had to find our own arguments.  So for us the
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1922
  formalisation was not the bottleneck. It is hard to gauge the size of a
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1923
  formalisation in Nurpl, but from what is shown in the Nuprl Math Library
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1924
  about their development it seems substantially larger than ours. The code of
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1925
  ours can be found in the Mercurial Repository at
132
f77a7138f791 comments by Xingyuan
urbanc
parents: 131
diff changeset
  1926
  \mbox{\url{http://www4.in.tum.de/~urbanc/regexp.html}}.
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1927
112
62fdb4bf7239 more on the conclusion
urbanc
parents: 111
diff changeset
  1928
186
07a269d9642b added more to the derivatives section
urbanc
parents: 185
diff changeset
  1929
112
62fdb4bf7239 more on the conclusion
urbanc
parents: 111
diff changeset
  1930
  Our proof of the first direction is very much inspired by \emph{Brzozowski's
134
08afbed1c8c7 chunhan's comments
urbanc
parents: 133
diff changeset
  1931
  algebraic method} used to convert a finite automaton to a regular
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1932
  expression \cite{Brzozowski64}. The close connection can be seen by considering the equivalence
111
d65d071798ff first ideas about conclusion
urbanc
parents: 110
diff changeset
  1933
  classes as the states of the minimal automaton for the regular language.
114
c5eb5f3065ae updated bib
urbanc
parents: 113
diff changeset
  1934
  However there are some subtle differences. Since we identify equivalence
111
d65d071798ff first ideas about conclusion
urbanc
parents: 110
diff changeset
  1935
  classes with the states of the automaton, then the most natural choice is to
d65d071798ff first ideas about conclusion
urbanc
parents: 110
diff changeset
  1936
  characterise each state with the set of strings starting from the initial
113
ec774952190c polished everything
urbanc
parents: 112
diff changeset
  1937
  state leading up to that state. Usually, however, the states are characterised as the
123
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1938
  strings starting from that state leading to the terminal states.  The first
23c0e6f2929d polished everywhere...two cases still missing
urbanc
parents: 122
diff changeset
  1939
  choice has consequences about how the initial equational system is set up. We have
115
c5f138b5fc88 added comment from Larry
urbanc
parents: 114
diff changeset
  1940
  the $\lambda$-term on our `initial state', while Brzozowski has it on the
111
d65d071798ff first ideas about conclusion
urbanc
parents: 110
diff changeset
  1941
  terminal states. This means we also need to reverse the direction of Arden's
156
fd39492b187c a few more changes
urbanc
parents: 154
diff changeset
  1942
  Lemma.
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
  1943
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1944
  This is also where our method shines, because we can completely
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1945
  side-step the standard argument \cite{Kozen97} where automata need
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1946
  to be composed, which as stated in the Introduction is not so easy
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1947
  to formalise in a HOL-based theorem prover. However, it is also the
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1948
  direction where we had to spend most of the `conceptual' time, as
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1949
  our proof-argument based on tagging-functions is new for
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1950
  establishing the Myhill-Nerode theorem. All standard proofs of this
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1951
  direction proceed by arguments over automata.\medskip
172
21ee3a852a02 more on the journal paper
urbanc
parents: 170
diff changeset
  1952
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1953
  We expect that the development of Krauss \& Nipkow gets easier by
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1954
  using partial derivatives.\medskip
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1955
  
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1956
  \noindent
173
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1957
  {\bf Acknowledgements:}
d371536861bc more on the introduction of the journal paper
urbanc
parents: 172
diff changeset
  1958
  We are grateful for the comments we received from Larry
162
e93760534354 added directory for journal version; took uptodate version of the theory files
urbanc
parents: 160
diff changeset
  1959
  Paulson.
111
d65d071798ff first ideas about conclusion
urbanc
parents: 110
diff changeset
  1960
92
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
  1961
*}
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
  1962
a9ebc410a5c8 more on paper
urbanc
parents: 90
diff changeset
  1963
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
  1964
(*<*)
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
  1965
end
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
  1966
(*>*)