Paper/Paper.thy
author urbanc
Fri, 04 Feb 2011 22:54:29 +0000
changeset 66 828ea293b61f
parent 61 070f543e2560
child 67 7478be786f87
permissions -rw-r--r--
more on the introduction
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
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
    12
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
    13
notation (latex output)
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    14
  str_eq_rel ("\<approx>\<^bsub>_\<^esub>") and
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    15
  Seq (infixr "\<cdot>" 100) and
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    16
  Star ("_\<^bsup>\<star>\<^esup>") and
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
    17
  pow ("_\<^bsup>_\<^esup>" [100, 100] 100) and
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
    18
  Suc ("_+1" [100] 100) and
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
    19
  quotient ("_ \<^raw:\ensuremath{\!\sslash\!}> _" [90, 90] 90) and
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    20
  REL ("\<approx>") and
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    21
  UPLUS ("_ \<^raw:\ensuremath{\uplus}> _" [90, 90] 90)
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    22
(*>*)
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    23
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    24
section {* Introduction *}
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    25
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
    26
text {*
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
    27
  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
    28
  Science, with many beautiful theorems and many useful algorithms. There is a
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    29
  wide range of textbooks on this subject, many of which are aimed at students
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    30
  and contain very detailed ``pencil-and-paper'' proofs
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
    31
  (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
    32
  formalising these theorems and by verifying formally the algorithms.
59
fc35eb54fdc9 more on the intro
urbanc
parents: 58
diff changeset
    33
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    34
  There is however a problem: the typical approach to regular languages is to
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    35
  introduce finite automata and then define everything in terms of them.  For
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    36
  example, a regular language is normally defined as one whose strings are
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    37
  recognised by a finite deterministic automaton. This approach has many
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    38
  benefits. Among them is that it is easy to convince oneself from the fact that
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    39
  regular languages are closed under complementation: one just has to exchange
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    40
  the accepting and non-accepting states in the corresponding automaton to
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    41
  obtain an automaton for the complement language.  The problem, however, lies with
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    42
  formalising such reasoning in a theorem prover, in our case
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    43
  Isabelle/HOL. Automata need to be represented as graphs or matrices, neither
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    44
  of which can be defined as inductive datatype.\footnote{In some works
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    45
  functions are used to represent state transitions, but also they are not
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    46
  inductive datatypes.} This means we have to build our own reasoning
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    47
  infrastructure for them, as neither Isabelle/HOL nor HOL4 nor HOLlight support
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    48
  them with libraries.
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    49
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    50
  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
    51
  theorem provers.  Consider for example the operation of sequencing 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    52
  two automata, say $A_1$ and $A_2$, by connecting the
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    53
  accepting states of one atomaton to the 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    54
  initial state of the other:
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
    55
  
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
    56
  
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
    57
  \begin{center}
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    58
  \begin{tabular}{ccc}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    59
  \begin{tikzpicture}[scale=0.8]
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    60
  %\draw[step=2mm] (-1,-1) grid (1,1);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    61
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    62
  \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
    63
  \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
    64
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    65
  \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
    66
  \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
    67
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    68
  \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
    69
  \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
    70
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    71
  \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
    72
  \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
    73
  \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
    74
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    75
  \draw (-0.6,0.0) node {\footnotesize$A_1$};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    76
  \draw ( 0.6,0.0) node {\footnotesize$A_2$};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    77
  \end{tikzpicture}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    78
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    79
  & 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    80
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    81
  \raisebox{1.1mm}{\bf\Large$\;\;\;\Rightarrow\,\;\;$}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    82
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    83
  &
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    84
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    85
  \begin{tikzpicture}[scale=0.8]
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    86
  %\draw[step=2mm] (-1,-1) grid (1,1);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    87
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    88
  \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
    89
  \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
    90
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    91
  \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
    92
  \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
    93
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    94
  \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
    95
  \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
    96
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
    97
  \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
    98
  \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
    99
  \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
   100
  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   101
  \draw (C) to [very thick, bend left=45] (B);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   102
  \draw (D) to [very thick, bend right=45] (B);
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   103
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   104
  \draw (-0.6,0.0) node {\footnotesize$A_1$};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   105
  \draw ( 0.6,0.0) node {\footnotesize$A_2$};
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   106
  \end{tikzpicture}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   107
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   108
  \end{tabular}
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   109
  \end{center}
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   110
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   111
  \noindent
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   112
  On ``paper'' we can build the corresponding graph using the disjoint union of 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   113
  the state nodes and add 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   114
  two more nodes for the new initial state and the new accepting 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   115
  state. Unfortunately in HOL, the definition for disjoint 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   116
  union, namely 
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   117
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   118
  \begin{center}
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   119
  @{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
   120
  \end{center}
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   121
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   122
  \noindent
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   123
  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
   124
  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
   125
  and hence will not be able to state properties about \emph{all}
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   126
  automata, since there is no type quantification available in HOL. A working
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   127
  alternative is to give every state node an identity, for example a natural
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   128
  number, and then be careful renaming these identities apart whenever
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   129
  connecting two automata. This results in very clunky proofs
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   130
  establishing that properties are invariant under renaming. Similarly,
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   131
  combining two automata represented as matrices results in very adhoc
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   132
  constructions, which are not pleasant to reason about.
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   133
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   134
  Because of these problems to do with representing automata, there seems
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   135
  to be no substantial formalisation of automata theory and regular languages 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   136
  carried out in a HOL-based theorem prover. We are only aware of the 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   137
  large formalisation of the automata theory in Nuprl \cite{Constable00} and 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   138
  some smaller in Coq \cite{Filliatre97}.
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   139
  
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   140
  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
   141
  different approach to regular languages. Instead of defining a regular language as one 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   142
  where there exists an automaton that recognises all strings of the language, we define 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   143
  a regular language as
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   144
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   145
  \begin{definition}[A Regular Language]
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   146
  A language @{text A} is regular, provided there is a regular expression that matches all
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   147
  strings of @{text "A"}.
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   148
  \end{definition}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   149
  
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   150
  \noindent
66
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   151
  The reason is that regular expressions, unlike graphs and matrices, can
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   152
  be easily defined as inductive datatype. Therefore a corresponding reasoning 
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   153
  infrastructure comes in Isabelle for free. The purpose of this paper is to
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   154
  show that a central result about regular languages, the Myhill-Nerode theorem,  
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   155
  can be recreated by only using regular expressions. A corollary of this
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   156
  theorem will be the usual closure properties, including complementation,
828ea293b61f more on the introduction
urbanc
parents: 61
diff changeset
   157
  of regular languages.
61
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   158
  
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   159
070f543e2560 more to the intro
urbanc
parents: 60
diff changeset
   160
  \noindent
60
fb08f41ca33d a bit more tuning on the introduction
urbanc
parents: 59
diff changeset
   161
  {\bf Contributions:} A proof of the Myhill-Nerode Theorem based on regular expressions. The 
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   162
  finiteness part of this theorem is proved using tagging-functions (which to our knowledge
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   163
  are novel in this context).
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   164
  
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   165
*}
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   166
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   167
section {* Preliminaries *}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   168
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   169
text {*
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   170
  Strings in Isabelle/HOL are lists of characters and the
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   171
  \emph{empty string} is the empty list, written @{term "[]"}. \emph{Languages} are sets of 
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   172
  strings. The language containing all strings is written in Isabelle/HOL as @{term "UNIV::string set"}.
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   173
  The notation for the quotient of a language @{text A} according to a relation @{term REL} is
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   174
  @{term "A // REL"}. The concatenation of two languages is written @{term "A ;; B"}; a language 
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   175
  raised  tow the power $n$ is written @{term "A \<up> n"}. Both concepts are defined as
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   176
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   177
  \begin{center}
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   178
  @{thm Seq_def[THEN eq_reflection, where A1="A" and B1="B"]}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   179
  \hspace{7mm}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   180
  @{thm pow.simps(1)[THEN eq_reflection, where A1="A"]}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   181
  \hspace{7mm}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   182
  @{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
   183
  \end{center}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   184
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   185
  \noindent
58
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   186
  where @{text "@"} is the usual list-append operation. The Kleene-star of a language @{text A}
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   187
  is defined as the union over all powers, namely @{thm Star_def}.
0d4d5bb321dc a little bit in the introduction
urbanc
parents: 54
diff changeset
   188
  
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   189
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   190
  Regular expressions are defined as the following datatype
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   191
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   192
  \begin{center}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   193
  @{text r} @{text "::="}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   194
  @{term NULL}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   195
  @{term EMPTY}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   196
  @{term "CHAR c"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   197
  @{term "SEQ r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   198
  @{term "ALT r r"}\hspace{1.5mm}@{text"|"}\hspace{1.5mm} 
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   199
  @{term "STAR r"}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   200
  \end{center}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   201
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   202
  Central to our proof will be the solution of equational systems
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   203
  involving regular expressions. For this we will use the following ``reverse'' 
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   204
  version of Arden's lemma.
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   205
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   206
  \begin{lemma}[Reverse Arden's Lemma]\mbox{}\\
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   207
  If @{thm (prem 1) ardens_revised} then
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   208
  @{thm (lhs) ardens_revised} has the unique solution
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   209
  @{thm (rhs) ardens_revised}.
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   210
  \end{lemma}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   211
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   212
  \begin{proof}
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   213
  For the right-to-left direction we assume @{thm (rhs) ardens_revised} and show
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   214
  that @{thm (lhs) ardens_revised} holds. From Lemma ??? we have @{term "A\<star> = {[]} \<union> A ;; A\<star>"},
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   215
  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
   216
  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
   217
  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
   218
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   219
  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
   220
  on @{text n}, we can establish the property
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   221
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   222
  \begin{center}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   223
  @{text "(*)"}\hspace{5mm} @{thm (concl) ardens_helper}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   224
  \end{center}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   225
  
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   226
  \noindent
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   227
  Using this property we can show that @{term "B ;; (A \<up> n) \<subseteq> X"} holds for
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   228
  all @{text n}. From this we can infer @{term "B ;; A\<star> \<subseteq> X"} using Lemma ???.
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   229
  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
   230
  with length @{text k} is element in @{text X}. Since @{thm (prem 1) ardens_revised}
51
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   231
  we know that @{term "s \<notin> X ;; (A \<up> Suc k)"} since its length is only @{text k}
6cfb92de4654 some tuning of the paper
urbanc
parents: 50
diff changeset
   232
  (the strings in @{term "X ;; (A \<up> Suc k)"} are all longer). 
53
da85feadb8e3 small typo
urbanc
parents: 52
diff changeset
   233
  From @{text "(*)"} it follows then that
50
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   234
  @{term s} must be element in @{term "(\<Union>m\<in>{0..k}. B ;; (A \<up> m))"}. This in turn
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   235
  implies that @{term s} is in @{term "(\<Union>n. B ;; (A \<up> n))"}. Using Lemma ??? this
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   236
  is equal to @{term "B ;; A\<star>"}, as we needed to show.\qed
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   237
  \end{proof}
32bff8310071 revised proof of Ardens lemma
urbanc
parents: 39
diff changeset
   238
*}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   239
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   240
section {* Finite Partitions Imply Regularity of a Language *}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   241
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   242
text {*
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   243
  \begin{theorem}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   244
  Given a language @{text A}.
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   245
  @{thm[mode=IfThen] hard_direction[where Lang="A"]}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   246
  \end{theorem}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   247
*}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   248
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   249
section {* Regular Expressions Generate Finitely Many Partitions *}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   250
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   251
text {*
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   252
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   253
  \begin{theorem}
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   254
  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
   255
  \end{theorem}  
39
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   256
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   257
  \begin{proof}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   258
  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
   259
  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
   260
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   261
  \begin{center}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   262
  \begin{tabular}{l}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   263
  @{thm quot_null_eq}\\
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   264
  @{thm quot_empty_subset}\\
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   265
  @{thm quot_char_subset}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   266
  \end{tabular}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   267
  \end{center}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   268
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   269
  \end{proof}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   270
*}
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   271
a59473f0229d tuned a little bit the section about finite partitions
urbanc
parents: 37
diff changeset
   272
54
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   273
section {* Conclusion and Related Work *}
c19d2fc2cc69 a bit more on the paper
urbanc
parents: 53
diff changeset
   274
24
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   275
(*<*)
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   276
end
f72c82bf59e5 added paper
urbanc
parents:
diff changeset
   277
(*>*)