Paper/Paper.thy
author urbanc
Tue, 08 Feb 2011 09:51:49 +0000
changeset 77 63bc9f9d96ba
parent 75 d63baacbdb16
child 79 bba9c80735f9
permissions -rw-r--r--
small additions
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
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
     3
imports "../Myhill" "LaTeXsugar"
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
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
    15
notation (latex output)
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    16
  str_eq_rel ("\<approx>\<^bsub>_\<^esub>") and
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
    17
  str_eq ("_ \<approx>\<^bsub>_\<^esub> _") and
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    18
  Seq (infixr "\<cdot>" 100) and
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    19
  Star ("_\<^bsup>\<star>\<^esup>") and
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    20
  pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
    21
  Suc ("_+1" [100] 100) and
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
    22
  quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    23
  REL ("\<approx>") and
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
    24
  UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90) and
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
    25
  L ("L'(_')" [0] 101) and
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
    26
  Lam ("\<lambda>'(_')" [100] 100) and 
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
    27
  Trn ("_, _" [100, 100] 100) and 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
    28
  EClass ("\<lbrakk>_\<rbrakk>\<^bsub>_\<^esub>" [100, 100] 100) and
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
    29
  transition ("_ \<^raw:\ensuremath{\stackrel{\text{>_\<^raw:}}{\Longmapsto}}> _" [100, 100, 100] 100)
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    30
(*>*)
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    31
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
    32
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    33
section {* Introduction *}
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    34
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    35
text {*
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
    36
  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
    37
  Science, with many beautiful theorems and many useful algorithms. There is a
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    38
  wide range of textbooks on this subject, many of which are aimed at students
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    39
  and contain very detailed ``pencil-and-paper'' proofs
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
    40
  (e.g.~\cite{Kozen97}). It seems natural to exercise theorem provers by
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
    41
  formalising these theorems and by verifying formally the algorithms.
59
fc35eb54fdc9 more on the intro
urbanc
parents: 58
diff changeset
    42
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    43
  There is however a problem: the typical approach to regular languages is to
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    44
  introduce finite automata and then define everything in terms of them.  For
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    45
  example, a regular language is normally defined as one whose strings are
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    46
  recognised by a finite deterministic automaton. This approach has many
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
    47
  benefits. Among them is the fact that it is easy to convince oneself that
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    48
  regular languages are closed under complementation: one just has to exchange
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    49
  the accepting and non-accepting states in the corresponding automaton to
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    50
  obtain an automaton for the complement language.  The problem, however, lies with
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
    51
  formalising such reasoning in a HOL-based theorem prover, in our case
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
    52
  Isabelle/HOL. Automata are build up from states and transitions that 
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
    53
  need to be represented as graphs or matrices, neither
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    54
  of which can be defined as inductive datatype.\footnote{In some works
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    55
  functions are used to represent state transitions, but also they are not
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    56
  inductive datatypes.} This means we have to build our own reasoning
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    57
  infrastructure for them, as neither Isabelle/HOL nor HOL4 nor HOLlight support
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    58
  them with libraries.
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    59
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    60
  Even worse, reasoning about graphs and matrices can be a real hassle in HOL-based
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    61
  theorem provers.  Consider for example the operation of sequencing 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    62
  two automata, say $A_1$ and $A_2$, by connecting the
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
    63
  accepting states of $A_1$ to the initial state of $A_2$:
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
    64
  
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
    65
  
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
    66
  \begin{center}
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    67
  \begin{tabular}{ccc}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    68
  \begin{tikzpicture}[scale=0.8]
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    69
  %\draw[step=2mm] (-1,-1) grid (1,1);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    70
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    71
  \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
    72
  \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
    73
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    74
  \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
    75
  \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
    76
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    77
  \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
    78
  \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
    79
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    80
  \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
    81
  \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
    82
  \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
    83
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    84
  \draw (-0.6,0.0) node {\footnotesize$A_1$};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    85
  \draw ( 0.6,0.0) node {\footnotesize$A_2$};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    86
  \end{tikzpicture}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    87
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    88
  & 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    89
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    90
  \raisebox{1.1mm}{\bf\Large$\;\;\;\Rightarrow\,\;\;$}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    91
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    92
  &
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    93
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    94
  \begin{tikzpicture}[scale=0.8]
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    95
  %\draw[step=2mm] (-1,-1) grid (1,1);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    96
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    97
  \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
    98
  \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
    99
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   100
  \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
   101
  \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
   102
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   103
  \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
   104
  \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
   105
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   106
  \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
   107
  \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
   108
  \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
   109
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   110
  \draw (C) to [very thick, bend left=45] (B);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   111
  \draw (D) to [very thick, bend right=45] (B);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   112
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   113
  \draw (-0.6,0.0) node {\footnotesize$A_1$};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   114
  \draw ( 0.6,0.0) node {\footnotesize$A_2$};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   115
  \end{tikzpicture}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   116
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   117
  \end{tabular}
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   118
  \end{center}
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   119
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   120
  \noindent
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   121
  On ``paper'' we can define the corresponding graph in terms of the disjoint 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   122
  union of the state nodes. Unfortunately in HOL, the definition for disjoint 
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   123
  union, namely 
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   124
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   125
  \begin{center}
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   126
  @{term "UPLUS A\<^isub>1 A\<^isub>2 \<equiv> {(1, x) | x. x \<in> A\<^isub>1} \<union> {(2, y) | y. y \<in> A\<^isub>2}"}
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   127
  \end{center}
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   128
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   129
  \noindent
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   130
  changes the type---the disjoint union is not a set, but a set of pairs. 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   131
  Using this definition for disjoint unions means we do not have a single type for automata
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   132
  and hence will not be able to state properties about \emph{all}
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   133
  automata, since there is no type quantification available in HOL. An
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   134
  alternative, which provides us with a single type for automata, is to give every 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   135
  state node an identity, for example a natural
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   136
  number, and then be careful to rename these identities apart whenever
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   137
  connecting two automata. This results in clunky proofs
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   138
  establishing that properties are invariant under renaming. Similarly,
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   139
  connecting two automata represented as matrices results in very adhoc
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   140
  constructions, which are not pleasant to reason about.
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   141
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   142
  Because of these problems to do with representing automata, there seems
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   143
  to be no substantial formalisation of automata theory and regular languages 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   144
  carried out in a HOL-based theorem prover. We are only aware of the 
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   145
  large formalisation of automata theory in Nuprl \cite{Constable00} and 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   146
  some smaller formalisations in Coq (for example \cite{Filliatre97}).
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   147
  
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   148
  In this paper, we will not attempt to formalise automata theory, but take a completely 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   149
  different approach to regular languages. Instead of defining a regular language as one 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   150
  where there exists an automaton that recognises all strings of the language, we define 
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   151
  a regular language as:
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   152
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   153
  \begin{definition}[A Regular Language]
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   154
  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
   155
  strings of @{text "A"}.
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   156
  \end{definition}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   157
  
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   158
  \noindent
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   159
  The reason is that regular expressions, unlike graphs and matrices, can
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   160
  be easily defined as inductive datatype. Consequently a corresponding reasoning 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   161
  infrastructure comes for free. This has recently been exploited in HOL4 with a formalisation
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   162
  of regular expression matching based on derivatives \cite{OwensSlind08}.  The purpose of this paper is to
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   163
  show that a central result about regular languages---the Myhill-Nerode theorem---can 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   164
  be recreated by only using regular expressions. This theorem gives necessary
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   165
  and sufficient conditions for when a language is regular. As a corollary of this
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   166
  theorem we can easily establish the usual closure properties, including 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   167
  complementation, for regular languages.\smallskip
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   168
  
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   169
  \noindent
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   170
  {\bf Contributions:} To our knowledge, our proof of the Myhill-Nerode theorem is the
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   171
  first that is based on regular expressions, only. We prove the part of this theorem 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   172
  stating that a regular expression has only finitely many partitions using certain 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   173
  tagging-functions. Again to our best knowledge, these tagging functions have
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   174
  not been used before to establish the Myhill-Nerode theorem.
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   175
*}
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   176
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   177
section {* Preliminaries *}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   178
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   179
text {*
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   180
  Strings in Isabelle/HOL are lists of characters with the \emph{empty string}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   181
  being represented by the empty list, written @{term "[]"}. \emph{Languages}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   182
  are sets of strings. The language containing all strings is written in
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   183
  Isabelle/HOL as @{term "UNIV::string set"}. The concatenation of two languages 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   184
  is written @{term "A ;; B"} and a language raised to the power $n$ is written 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   185
  @{term "A \<up> n"}. Their definitions are
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   186
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   187
  \begin{center}
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   188
  @{thm Seq_def[THEN eq_reflection, where A1="A" and B1="B"]}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   189
  \hspace{7mm}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   190
  @{thm pow.simps(1)[THEN eq_reflection, where A1="A"]}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   191
  \hspace{7mm}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   192
  @{thm 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
   193
  \end{center}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   194
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   195
  \noindent
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   196
  where @{text "@"} is the usual list-append operation. The Kleene-star of a language @{text A}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   197
  is defined as the union over all powers, namely @{thm Star_def}. In the paper
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   198
  we will often make use of the following properties.
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   199
  
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   200
  \begin{proposition}\label{langprops}\mbox{}\\
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   201
  \begin{tabular}{@ {}ll@ {\hspace{10mm}}ll}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   202
  (i)   & @{thm star_cases}      & (ii)  & @{thm[mode=IfThen] pow_length}\\
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   203
  (iii) & @{thm seq_Union_left}  & 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   204
  \end{tabular}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   205
  \end{proposition}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   206
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   207
  \noindent
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   208
  We omit the proofs of these properties, but invite the reader to consult
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   209
  our formalisation.\footnote{Available at ???}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   210
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   211
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   212
  The notation for the quotient of a language @{text A} according to an 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   213
  equivalence relation @{term REL} is @{term "A // REL"}. We will write 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   214
  @{text "\<lbrakk>x\<rbrakk>\<^isub>\<approx>"} for the equivalence class defined 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   215
  as @{text "{y | y \<approx> x}"}.
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   216
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   217
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   218
  Central to our proof will be the solution of equational systems
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   219
  involving sets of languages. For this we will use Arden's lemma \cite{Brzozowski64}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   220
  which solves equations of the form @{term "X = A ;; X \<union> B"} provided
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   221
  @{term "[] \<notin> A"}. However we will need the following ``reverse'' 
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   222
  version of Arden's lemma.
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   223
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   224
  \begin{lemma}[Reverse Arden's Lemma]\label{arden}\mbox{}\\
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   225
  If @{thm (prem 1) ardens_revised} then
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   226
  @{thm (lhs) ardens_revised} has the unique solution
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   227
  @{thm (rhs) ardens_revised}.
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   228
  \end{lemma}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   229
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   230
  \begin{proof}
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   231
  For the right-to-left direction we assume @{thm (rhs) ardens_revised} and show
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   232
  that @{thm (lhs) ardens_revised} holds. From Prop.~\ref{langprops}@{text "(i)"} 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   233
  we have @{term "A\<star> = {[]} \<union> A ;; A\<star>"},
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   234
  which is equal to @{term "A\<star> = {[]} \<union> A\<star> ;; A"}. Adding @{text B} to both 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   235
  sides gives @{term "B ;; A\<star> = B ;; ({[]} \<union> A\<star> ;; A)"}, whose right-hand side
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   236
  is equal to @{term "(B ;; A\<star>) ;; A \<union> B"}. This completes this direction. 
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   237
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   238
  For the other direction we assume @{thm (lhs) ardens_revised}. By a simple induction
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   239
  on @{text n}, we can establish the property
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   240
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   241
  \begin{center}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   242
  @{text "(*)"}\hspace{5mm} @{thm (concl) ardens_helper}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   243
  \end{center}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   244
  
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   245
  \noindent
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   246
  Using this property we can show that @{term "B ;; (A \<up> n) \<subseteq> X"} holds for
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   247
  all @{text n}. From this we can infer @{term "B ;; A\<star> \<subseteq> X"} using the definition
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   248
  of @{text "\<star>"}.
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   249
  For the inclusion in the other direction we assume a string @{text s}
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   250
  with length @{text k} is element in @{text X}. Since @{thm (prem 1) ardens_revised}
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   251
  we know by Prop.~\ref{langprops}@{text "(ii)"} that 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   252
  @{term "s \<notin> X ;; (A \<up> Suc k)"} since its length is only @{text k}
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   253
  (the strings in @{term "X ;; (A \<up> Suc k)"} are all longer). 
53
da85feadb8e3 small typo
urbanc
parents: 52
diff changeset
   254
  From @{text "(*)"} it follows then that
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   255
  @{term s} must be element in @{term "(\<Union>m\<in>{0..k}. B ;; (A \<up> m))"}. This in turn
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   256
  implies that @{term s} is in @{term "(\<Union>n. B ;; (A \<up> n))"}. Using Prop.~\ref{langprops}@{text "(iii)"} 
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   257
  this is equal to @{term "B ;; A\<star>"}, as we needed to show.\qed
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   258
  \end{proof}
67
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   259
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   260
  \noindent
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   261
  Regular expressions are defined as the following inductive datatype
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   262
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   263
  \begin{center}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   264
  @{text r} @{text "::="}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   265
  @{term NULL}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   266
  @{term EMPTY}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   267
  @{term "CHAR c"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   268
  @{term "SEQ r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   269
  @{term "ALT r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   270
  @{term "STAR r"}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   271
  \end{center}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   272
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   273
  \noindent
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   274
  The language matched by a regular expression is defined as usual:
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   275
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   276
  \begin{center}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   277
  \begin{tabular}{c@ {\hspace{10mm}}c}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   278
  \begin{tabular}{rcl}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   279
  @{thm (lhs) L_rexp.simps(1)} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(1)}\\
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   280
  @{thm (lhs) L_rexp.simps(2)} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(2)}\\
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   281
  @{thm (lhs) L_rexp.simps(3)[where c="c"]} & @{text "\<equiv>"} & @{thm (rhs) L_rexp.simps(3)[where c="c"]}\\
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   282
  \end{tabular}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   283
  &
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   284
  \begin{tabular}{rcl}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   285
  @{thm (lhs) L_rexp.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} &
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   286
       @{thm (rhs) L_rexp.simps(4)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   287
  @{thm (lhs) L_rexp.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]} & @{text "\<equiv>"} &
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   288
       @{thm (rhs) L_rexp.simps(5)[where ?r1.0="r\<^isub>1" and ?r2.0="r\<^isub>2"]}\\
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   289
  @{thm (lhs) L_rexp.simps(6)[where r="r"]} & @{text "\<equiv>"} &
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   290
      @{thm (rhs) L_rexp.simps(6)[where r="r"]}\\
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   291
  \end{tabular}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   292
  \end{tabular}
7478be786f87 more intro
urbanc
parents: 66
diff changeset
   293
  \end{center}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   294
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   295
*}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   296
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   297
section {* Finite Partitions Imply Regularity of a Language *}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   298
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   299
text {*
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   300
  The key definition in the Myhill-Nerode theorem is the
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   301
  \emph{Myhill-Nerode relation}, which states that w.r.t.~a language two 
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   302
  strings are related, provided there is no distinguishing extension in this
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   303
  language. This can be defined as:
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   304
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   305
  \begin{definition}[Myhill-Nerode Relation]\mbox{}\\
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   306
  @{thm str_eq_def[simplified str_eq_rel_def Pair_Collect]}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   307
  \end{definition}
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   308
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   309
  \noindent
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   310
  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
   311
  partitions the set of all strings, @{text "UNIV"}, into a set of disjoint
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   312
  equivalence classes. One direction of the Myhill-Nerode theorem establishes 
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   313
  that if there are finitely many equivalence classes, then the language is 
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   314
  regular. In our setting we therefore have to show:
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   315
  
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   316
  \begin{theorem}\label{myhillnerodeone}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   317
  @{thm[mode=IfThen] hard_direction}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   318
  \end{theorem}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   319
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   320
  \noindent
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   321
  To prove this theorem, we define the set @{term "finals A"} as those equivalence
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   322
  classes that contain strings of @{text A}, namely
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   323
  %
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   324
  \begin{equation} 
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   325
  @{thm finals_def}
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   326
  \end{equation}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   327
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   328
  \noindent
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   329
  It is straightforward to show that @{thm lang_is_union_of_finals} and 
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   330
  @{thm finals_included_in_UNIV} hold. 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   331
  Therefore if we know that there exists a regular expression for every
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   332
  equivalence class in @{term "finals A"} (which by assumption must be
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   333
  a finite set), then we can combine these regular expressions with @{const ALT}
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   334
  and obtain a regular expression that matches every string in @{text A}.
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   335
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   336
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   337
  We prove Thm.~\ref{myhillnerodeone} by giving a method that can calculate a
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   338
  regular expression for \emph{every} equivalence classe, not just the ones 
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   339
  in @{term "finals A"}. We
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   340
  first define a notion of \emph{transition} between equivalence classes
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   341
  %
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   342
  \begin{equation} 
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   343
  @{thm transition_def}
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   344
  \end{equation}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   345
71
426070e68b21 more on the paper
urbanc
parents: 70
diff changeset
   346
  \noindent
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   347
  which means that if we concatenate all strings matching the regular expression @{text r} 
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   348
  to the end of all strings in the equivalence class @{text Y}, we obtain a subset of 
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   349
  @{text X}. Note that we do not define an automaton here, we merely relate two sets
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   350
  (w.r.t.~a regular expression). 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   351
  
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   352
  Next we build an equational system that
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   353
  contains an equation for each equivalence class. Suppose we have 
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   354
  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
   355
  contains the empty string @{text "[]"} (since equivalence classes are disjoint).
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   356
  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
   357
  
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   358
  \begin{center}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   359
  \begin{tabular}{rcl}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   360
  @{text "X\<^isub>1"} & @{text "="} & @{text "(Y\<^isub>1\<^isub>1, CHAR c\<^isub>1\<^isub>1) + \<dots> + (Y\<^isub>1\<^isub>p, CHAR c\<^isub>1\<^isub>p) + \<lambda>(EMPTY)"} \\
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   361
  @{text "X\<^isub>2"} & @{text "="} & @{text "(Y\<^isub>2\<^isub>1, CHAR c\<^isub>2\<^isub>1) + \<dots> + (Y\<^isub>2\<^isub>o, CHAR c\<^isub>2\<^isub>o)"} \\
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   362
  & $\vdots$ \\
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   363
  @{text "X\<^isub>n"} & @{text "="} & @{text "(Y\<^isub>n\<^isub>1, CHAR c\<^isub>n\<^isub>1) + \<dots> + (Y\<^isub>n\<^isub>q, CHAR c\<^isub>n\<^isub>q)"}\\
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   364
  \end{tabular}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   365
  \end{center}
70
8ab3a06577cf slightly more on the paper
urbanc
parents: 67
diff changeset
   366
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   367
  \noindent
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   368
  where the pairs @{text "(Y\<^isub>i\<^isub>j, r\<^isub>i\<^isub>j)"} stand for all transitions 
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   369
  @{term "Y\<^isub>i\<^isub>j \<Turnstile>r\<^isub>i\<^isub>j\<Rightarrow> X\<^isub>i"}.  The term @{text "\<lambda>(EMPTY)"} acts as a marker for the equivalence
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   370
  class containing @{text "[]"}. (Note that we mark, roughly speaking, the
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   371
  single ``initial'' state in the equational system, which is different from
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   372
  the method by Brzozowski \cite{Brzozowski64}, since for his purposes he needs to mark 
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   373
  the ``terminal'' states.) Overloading the function @{text L} for the two kinds of terms in the 
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   374
  equational system as follows
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   375
  
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   376
  \begin{center}
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   377
  @{thm L_rhs_e.simps(2)[where X="Y" and r="r", THEN eq_reflection]}\hspace{10mm}
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   378
  @{thm L_rhs_e.simps(1)[where r="r", THEN eq_reflection]}
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   379
  \end{center}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   380
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   381
  \noindent
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   382
  we can prove for @{text "X\<^isub>2\<^isub>.\<^isub>.\<^isub>n"} that the following equations
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   383
  %
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   384
  \begin{equation}\label{inv1}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   385
  @{text "X\<^isub>i = L(Y\<^isub>i\<^isub>1, CHAR c\<^isub>i\<^isub>1) \<union> \<dots> \<union> L(Y\<^isub>i\<^isub>q, CHAR c\<^isub>i\<^isub>q)"}.
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   386
  \end{equation}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   387
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   388
  \noindent
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   389
  hold. Similarly for @{text "X\<^isub>1"} we can show the following equation
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   390
  %
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   391
  \begin{equation}\label{inv2}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   392
  @{text "X\<^isub>1 = L(Y\<^isub>i\<^isub>1, CHAR c\<^isub>i\<^isub>1) \<union> \<dots> \<union> L(Y\<^isub>i\<^isub>p, CHAR c\<^isub>i\<^isub>p) \<union> L(\<lambda>(EMPTY))"}.
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   393
  \end{equation}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   394
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   395
  \noindent
77
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   396
  The reason for adding the @{text \<lambda>}-marker to our equational system is 
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   397
  to obtain this equation, which only holds in this form since none of 
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   398
  the other terms contain the empty string. 
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   399
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   400
63bc9f9d96ba small additions
urbanc
parents: 75
diff changeset
   401
  Our proof of Thm.~\ref{myhillnerodeone}
75
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   402
  will be by transforming the equational system into a \emph{solved form}
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   403
  maintaining the invariants \eqref{inv1} and \eqref{inv2}. From the solved
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   404
  form we will be able to read off the regular expressions using our 
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   405
  variant of Arden's Lemma (Lem.~\ref{arden}).
d63baacbdb16 parts of the 3 section
urbanc
parents: 71
diff changeset
   406
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   407
*}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   408
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   409
section {* Regular Expressions Generate Finitely Many Partitions *}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   410
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   411
text {*
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   412
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   413
  \begin{theorem}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   414
  Given @{text "r"} is a regular expressions, then @{thm rexp_imp_finite}.
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   415
  \end{theorem}  
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   416
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   417
  \begin{proof}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   418
  By induction on the structure of @{text r}. The cases for @{const NULL}, @{const EMPTY}
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   419
  and @{const CHAR} are straightforward, because we can easily establish
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   420
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   421
  \begin{center}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   422
  \begin{tabular}{l}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   423
  @{thm quot_null_eq}\\
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   424
  @{thm quot_empty_subset}\\
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   425
  @{thm quot_char_subset}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   426
  \end{tabular}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   427
  \end{center}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   428
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   429
  \end{proof}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   430
*}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   431
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   432
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   433
section {* Conclusion and Related Work *}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   434
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   435
(*<*)
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   436
end
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   437
(*>*)