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