369
|
1 |
%
|
|
2 |
\begin{isabellebody}%
|
|
3 |
\setisabellecontext{Paper}%
|
|
4 |
%
|
|
5 |
\isadelimtheory
|
|
6 |
%
|
|
7 |
\endisadelimtheory
|
|
8 |
%
|
|
9 |
\isatagtheory
|
|
10 |
%
|
|
11 |
\endisatagtheory
|
|
12 |
{\isafoldtheory}%
|
|
13 |
%
|
|
14 |
\isadelimtheory
|
|
15 |
%
|
|
16 |
\endisadelimtheory
|
|
17 |
%
|
|
18 |
\isadelimproof
|
|
19 |
%
|
|
20 |
\endisadelimproof
|
|
21 |
%
|
|
22 |
\isatagproof
|
|
23 |
%
|
|
24 |
\endisatagproof
|
|
25 |
{\isafoldproof}%
|
|
26 |
%
|
|
27 |
\isadelimproof
|
|
28 |
%
|
|
29 |
\endisadelimproof
|
|
30 |
%
|
|
31 |
\isadelimproof
|
|
32 |
%
|
|
33 |
\endisadelimproof
|
|
34 |
%
|
|
35 |
\isatagproof
|
|
36 |
%
|
|
37 |
\endisatagproof
|
|
38 |
{\isafoldproof}%
|
|
39 |
%
|
|
40 |
\isadelimproof
|
|
41 |
%
|
|
42 |
\endisadelimproof
|
|
43 |
%
|
|
44 |
\isadelimdocument
|
|
45 |
%
|
|
46 |
\endisadelimdocument
|
|
47 |
%
|
|
48 |
\isatagdocument
|
|
49 |
%
|
371
|
50 |
\isamarkupsection{Core of the proof%
|
369
|
51 |
}
|
|
52 |
\isamarkuptrue%
|
|
53 |
%
|
|
54 |
\endisatagdocument
|
|
55 |
{\isafolddocument}%
|
|
56 |
%
|
|
57 |
\isadelimdocument
|
|
58 |
%
|
|
59 |
\endisadelimdocument
|
|
60 |
%
|
|
61 |
\begin{isamarkuptext}%
|
|
62 |
This works builds on previous work by Ausaf and Urban using
|
|
63 |
regular expression'd bit-coded derivatives to do lexing that
|
|
64 |
is both fast and satisfied the POSIX specification.
|
|
65 |
In their work, a bit-coded algorithm introduced by Sulzmann and Lu
|
|
66 |
was formally verified in Isabelle, by a very clever use of
|
|
67 |
flex function and retrieve to carefully mimic the way a value is
|
|
68 |
built up by the injection funciton.
|
|
69 |
|
|
70 |
In the previous work, Ausaf and Urban established the below equality:
|
|
71 |
\begin{lemma}
|
371
|
72 |
\isa{{\normalsize{}If\,}\ v\ {\isacharcolon}{\kern0pt}\ r{\isacharbackslash}{\kern0pt}s\ {\normalsize \,then\,}\ Some\ {\isacharparenleft}{\kern0pt}flex\ r\ id\ s\ v{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ decode\ {\isacharparenleft}{\kern0pt}retrieve\ {\isacharparenleft}{\kern0pt}r\mbox{$^\uparrow$}\mbox{$\bbslash$}s{\isacharparenright}{\kern0pt}\ v{\isacharparenright}{\kern0pt}\ r{\isachardot}{\kern0pt}}
|
|
73 |
\end{lemma}
|
|
74 |
|
|
75 |
This lemma establishes a link with the lexer without bit-codes.
|
|
76 |
|
|
77 |
With it we get the correctness of bit-coded algorithm.
|
|
78 |
\begin{lemma}
|
|
79 |
\isa{lexer\mbox{$_b$}\ r\ s\ {\isacharequal}{\kern0pt}\ lexer\ r\ s}
|
369
|
80 |
\end{lemma}
|
|
81 |
|
371
|
82 |
However what is not certain is whether we can add simplification
|
|
83 |
to the bit-coded algorithm, without breaking the correct lexing output.
|
|
84 |
This might sound trivial in the case of producing a YES/NO answer,
|
|
85 |
but once we require a lexing output to be produced (which is required
|
|
86 |
in applications like compiler front-end, malicious attack domain extraction,
|
|
87 |
etc.), it is not straightforward if we still extract what is needed according
|
|
88 |
to the POSIX standard.
|
|
89 |
|
|
90 |
By simplification, we mean specifically the following rules:
|
|
91 |
|
|
92 |
\begin{center}
|
|
93 |
\begin{tabular}{lcl}
|
|
94 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{ASEQ\ bs\ AZERO\ r\isactrlsub {\isadigit{2}}\ {\isasymleadsto}\ AZERO}}}\\
|
|
95 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{ASEQ\ bs\ r\isactrlsub {\isadigit{1}}\ AZERO\ {\isasymleadsto}\ AZERO}}}\\
|
|
96 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{ASEQ\ bs\ {\isacharparenleft}{\kern0pt}AONE\ bs\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymleadsto}\ fuse\ {\isacharparenleft}{\kern0pt}bs\ {\isacharat}{\kern0pt}\ bs\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}}}\\
|
|
97 |
\isa{\mbox{}\inferrule{\mbox{bs\ {\isasymleadsto}\ r\isactrlsub {\isadigit{1}}}}{\mbox{ASEQ\ bs\ bs\ r{\isadigit{3}}{\isachardot}{\kern0pt}{\isadigit{0}}\ {\isasymleadsto}\ ASEQ\ bs\ r\isactrlsub {\isadigit{1}}\ r{\isadigit{3}}{\isachardot}{\kern0pt}{\isadigit{0}}}}}\\
|
|
98 |
\isa{\mbox{}\inferrule{\mbox{bs\ {\isasymleadsto}\ r\isactrlsub {\isadigit{2}}}}{\mbox{ASEQ\ bs\ r{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\ bs\ {\isasymleadsto}\ ASEQ\ bs\ r{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\ r\isactrlsub {\isadigit{2}}}}}\\
|
|
99 |
\isa{\mbox{}\inferrule{\mbox{bs\ {\isasymleadsto}\ r\isactrlsub {\isadigit{1}}}}{\mbox{AALTs\ bs\ {\isacharparenleft}{\kern0pt}rs{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\ {\isacharat}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}bs{\isacharbrackright}{\kern0pt}\ {\isacharat}{\kern0pt}\ rs{\isadigit{2}}{\isachardot}{\kern0pt}{\isadigit{0}}{\isacharparenright}{\kern0pt}\ {\isasymleadsto}\ AALTs\ bs\ {\isacharparenleft}{\kern0pt}rs{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\ {\isacharat}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbrackright}{\kern0pt}\ {\isacharat}{\kern0pt}\ rs{\isadigit{2}}{\isachardot}{\kern0pt}{\isadigit{0}}{\isacharparenright}{\kern0pt}}}}\\
|
|
100 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{AALTs\ bs\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}\ {\isacharat}{\kern0pt}\ AZERO\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}rsb{\isacharparenright}{\kern0pt}\ {\isasymleadsto}\ AALTs\ bs\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}\ {\isacharat}{\kern0pt}\ rsb{\isacharparenright}{\kern0pt}}}}\\
|
|
101 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{AALTs\ bs\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ AALTs\ bs{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\ rs{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}rsb{\isacharparenright}{\kern0pt}\ {\isasymleadsto}\ AALTs\ bs\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ map\ {\isacharparenleft}{\kern0pt}fuse\ bs{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}{\isacharparenright}{\kern0pt}\ rs{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\ {\isacharat}{\kern0pt}\ rsb{\isacharparenright}{\kern0pt}}}}\\
|
|
102 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{AALTs\ bs\ {\isacharparenleft}{\kern0pt}map\ {\isacharparenleft}{\kern0pt}fuse\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ rs{\isacharparenright}{\kern0pt}\ {\isasymleadsto}\ AALTs\ {\isacharparenleft}{\kern0pt}bs\ {\isacharat}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ rs}}}\\
|
|
103 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{AALTs\ {\isacharparenleft}{\kern0pt}bs\ {\isacharat}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ rs\ {\isasymleadsto}\ AALTs\ bs\ {\isacharparenleft}{\kern0pt}map\ {\isacharparenleft}{\kern0pt}fuse\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ rs{\isacharparenright}{\kern0pt}}}}\\
|
|
104 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{AALTs\ bs\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymleadsto}\ AZERO}}}\\
|
|
105 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{AALTs\ bs\ {\isacharbrackleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbrackright}{\kern0pt}\ {\isasymleadsto}\ fuse\ bs\ r\isactrlsub {\isadigit{1}}}}}\\
|
|
106 |
\isa{\mbox{}\inferrule{\mbox{bs\mbox{$^\downarrow$}\ {\isacharequal}{\kern0pt}\ r\isactrlsub {\isadigit{2}}\mbox{$^\downarrow$}}}{\mbox{AALTs\ bs\ {\isacharparenleft}{\kern0pt}rsa\ {\isacharat}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}bs{\isacharbrackright}{\kern0pt}\ {\isacharat}{\kern0pt}\ rsb\ {\isacharat}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharbrackright}{\kern0pt}\ {\isacharat}{\kern0pt}\ rsc{\isacharparenright}{\kern0pt}\ {\isasymleadsto}\ AALTs\ bs\ {\isacharparenleft}{\kern0pt}rsa\ {\isacharat}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}bs{\isacharbrackright}{\kern0pt}\ {\isacharat}{\kern0pt}\ rsb\ {\isacharat}{\kern0pt}\ rsc{\isacharparenright}{\kern0pt}}}}\\
|
|
107 |
|
|
108 |
|
|
109 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{Empty\ {\isacharcolon}{\kern0pt}\ \isactrlbold {\isadigit{1}}}}} &
|
|
110 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{Char\ c\ {\isacharcolon}{\kern0pt}\ c}}}\\[4mm]
|
|
111 |
\isa{\mbox{}\inferrule{\mbox{v\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}}{\mbox{Left\ v\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}}}} &
|
|
112 |
\isa{\mbox{}\inferrule{\mbox{v\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}}{\mbox{Right\ v\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{2}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}}}\\[4mm]
|
|
113 |
\isa{\mbox{}\inferrule{\mbox{v\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}\\\ \mbox{v\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{2}}}}{\mbox{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}}}} &
|
|
114 |
\isa{\mbox{}\inferrule{\mbox{{\isasymforall}v{\isasymin}vs{\isachardot}{\kern0pt}\ v\ {\isacharcolon}{\kern0pt}\ r\ {\isasymand}\ {\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}}{\mbox{Stars\ vs\ {\isacharcolon}{\kern0pt}\ r\isactrlsup {\isasymstar}}}}
|
|
115 |
|
|
116 |
|
|
117 |
\end{tabular}
|
|
118 |
\end{center}
|
|
119 |
|
369
|
120 |
|
371
|
121 |
And these can be made compact by the following simplification function:
|
|
122 |
|
|
123 |
\begin{center}
|
|
124 |
\begin{tabular}{lcl}
|
|
125 |
\isa{bsimp\ {\isacharparenleft}{\kern0pt}ASEQ\ bs\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{bsimp{\isacharunderscore}{\kern0pt}ASEQ\ bs\ {\isacharparenleft}{\kern0pt}bsimp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}bsimp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
126 |
\isa{bsimp\ {\isacharparenleft}{\kern0pt}AALTs\ bs{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\ rs{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{bsimp{\isacharunderscore}{\kern0pt}AALTs\ bs{\isadigit{1}}{\isachardot}{\kern0pt}{\isadigit{0}}\ {\isacharparenleft}{\kern0pt}distinctBy\ {\isacharparenleft}{\kern0pt}flts\ {\isacharparenleft}{\kern0pt}map\ bsimp\ rs{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ erase\ {\isasymemptyset}{\isacharparenright}{\kern0pt}}\\
|
|
127 |
\isa{bsimp\ AZERO} & $\dn$ & \isa{AZERO}\\
|
|
128 |
\isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\mbox{$^\uparrow$}} & $\dn$ & \isa{AALT\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}fuse\ {\isacharbrackleft}{\kern0pt}Z{\isacharbrackright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\mbox{$^\uparrow$}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}fuse\ {\isacharbrackleft}{\kern0pt}S{\isacharbrackright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}\mbox{$^\uparrow$}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}}\\
|
|
129 |
\end{tabular}
|
|
130 |
\end{center}
|
|
131 |
|
|
132 |
The core idea of the proof is that two regular expressions,
|
|
133 |
if "isomorphic" up to a finite number of rewrite steps, will
|
|
134 |
remain so when we take derivative on both of them.
|
|
135 |
This can be expressed by the following rewrite relation lemma:
|
|
136 |
\begin{lemma}
|
|
137 |
\isa{{\isacharparenleft}{\kern0pt}r\mbox{$\bbslash$}s{\isacharparenright}{\kern0pt}\ {\isasymleadsto}{\isacharasterisk}{\kern0pt}\ bders{\isacharunderscore}{\kern0pt}simp\ r\ s}
|
|
138 |
\end{lemma}%
|
|
139 |
\end{isamarkuptext}\isamarkuptrue%
|
|
140 |
%
|
|
141 |
\isadelimdocument
|
|
142 |
%
|
|
143 |
\endisadelimdocument
|
|
144 |
%
|
|
145 |
\isatagdocument
|
|
146 |
%
|
|
147 |
\isamarkupsection{Introduction%
|
|
148 |
}
|
|
149 |
\isamarkuptrue%
|
|
150 |
%
|
|
151 |
\endisatagdocument
|
|
152 |
{\isafolddocument}%
|
|
153 |
%
|
|
154 |
\isadelimdocument
|
|
155 |
%
|
|
156 |
\endisadelimdocument
|
|
157 |
%
|
|
158 |
\begin{isamarkuptext}%
|
369
|
159 |
Brzozowski \cite{Brzozowski1964} introduced the notion of the {\em
|
|
160 |
derivative} \isa{r{\isacharbackslash}{\kern0pt}c} of a regular expression \isa{r} w.r.t.\
|
|
161 |
a character~\isa{c}, and showed that it gave a simple solution to the
|
|
162 |
problem of matching a string \isa{s} with a regular expression \isa{r}: if the derivative of \isa{r} w.r.t.\ (in succession) all the
|
|
163 |
characters of the string matches the empty string, then \isa{r}
|
|
164 |
matches \isa{s} (and {\em vice versa}). The derivative has the
|
|
165 |
property (which may almost be regarded as its specification) that, for
|
|
166 |
every string \isa{s} and regular expression \isa{r} and character
|
|
167 |
\isa{c}, one has \isa{cs\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}} if and only if \mbox{\isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}}}.
|
|
168 |
The beauty of Brzozowski's derivatives is that
|
|
169 |
they are neatly expressible in any functional language, and easily
|
|
170 |
definable and reasoned about in theorem provers---the definitions just
|
|
171 |
consist of inductive datatypes and simple recursive functions. A
|
|
172 |
mechanised correctness proof of Brzozowski's matcher in for example HOL4
|
|
173 |
has been mentioned by Owens and Slind~\cite{Owens2008}. Another one in
|
|
174 |
Isabelle/HOL is part of the work by Krauss and Nipkow \cite{Krauss2011}.
|
|
175 |
And another one in Coq is given by Coquand and Siles \cite{Coquand2012}.
|
|
176 |
|
|
177 |
If a regular expression matches a string, then in general there is more
|
|
178 |
than one way of how the string is matched. There are two commonly used
|
|
179 |
disambiguation strategies to generate a unique answer: one is called
|
|
180 |
GREEDY matching \cite{Frisch2004} and the other is POSIX
|
|
181 |
matching~\cite{POSIX,Kuklewicz,OkuiSuzuki2010,Sulzmann2014,Vansummeren2006}.
|
|
182 |
For example consider the string \isa{xy} and the regular expression
|
|
183 |
\mbox{\isa{{\isacharparenleft}{\kern0pt}x\ {\isacharplus}{\kern0pt}\ y\ {\isacharplus}{\kern0pt}\ xy{\isacharparenright}{\kern0pt}\isactrlsup {\isasymstar}}}. Either the string can be
|
|
184 |
matched in two `iterations' by the single letter-regular expressions
|
|
185 |
\isa{x} and \isa{y}, or directly in one iteration by \isa{xy}. The
|
|
186 |
first case corresponds to GREEDY matching, which first matches with the
|
|
187 |
left-most symbol and only matches the next symbol in case of a mismatch
|
|
188 |
(this is greedy in the sense of preferring instant gratification to
|
|
189 |
delayed repletion). The second case is POSIX matching, which prefers the
|
|
190 |
longest match.
|
|
191 |
|
|
192 |
In the context of lexing, where an input string needs to be split up
|
|
193 |
into a sequence of tokens, POSIX is the more natural disambiguation
|
|
194 |
strategy for what programmers consider basic syntactic building blocks
|
|
195 |
in their programs. These building blocks are often specified by some
|
|
196 |
regular expressions, say \isa{r\isactrlbsub key\isactrlesub } and \isa{r\isactrlbsub id\isactrlesub } for recognising keywords and identifiers,
|
|
197 |
respectively. There are a few underlying (informal) rules behind
|
|
198 |
tokenising a string in a POSIX \cite{POSIX} fashion:
|
|
199 |
|
|
200 |
\begin{itemize}
|
|
201 |
\item[$\bullet$] \emph{The Longest Match Rule} (or \emph{``{M}aximal {M}unch {R}ule''}):
|
|
202 |
The longest initial substring matched by any regular expression is taken as
|
|
203 |
next token.\smallskip
|
|
204 |
|
|
205 |
\item[$\bullet$] \emph{Priority Rule:}
|
|
206 |
For a particular longest initial substring, the first (leftmost) regular expression
|
|
207 |
that can match determines the token.\smallskip
|
|
208 |
|
|
209 |
\item[$\bullet$] \emph{Star Rule:} A subexpression repeated by ${}^\star$ shall
|
|
210 |
not match an empty string unless this is the only match for the repetition.\smallskip
|
|
211 |
|
|
212 |
\item[$\bullet$] \emph{Empty String Rule:} An empty string shall be considered to
|
|
213 |
be longer than no match at all.
|
|
214 |
\end{itemize}
|
|
215 |
|
|
216 |
\noindent Consider for example a regular expression \isa{r\isactrlbsub key\isactrlesub } for recognising keywords such as \isa{if},
|
|
217 |
\isa{then} and so on; and \isa{r\isactrlbsub id\isactrlesub }
|
|
218 |
recognising identifiers (say, a single character followed by
|
|
219 |
characters or numbers). Then we can form the regular expression
|
|
220 |
\isa{{\isacharparenleft}{\kern0pt}r\isactrlbsub key\isactrlesub \ {\isacharplus}{\kern0pt}\ r\isactrlbsub id\isactrlesub {\isacharparenright}{\kern0pt}\isactrlsup {\isasymstar}}
|
|
221 |
and use POSIX matching to tokenise strings, say \isa{iffoo} and
|
|
222 |
\isa{if}. For \isa{iffoo} we obtain by the Longest Match Rule
|
|
223 |
a single identifier token, not a keyword followed by an
|
|
224 |
identifier. For \isa{if} we obtain by the Priority Rule a keyword
|
|
225 |
token, not an identifier token---even if \isa{r\isactrlbsub id\isactrlesub }
|
|
226 |
matches also. By the Star Rule we know \isa{{\isacharparenleft}{\kern0pt}r\isactrlbsub key\isactrlesub \ {\isacharplus}{\kern0pt}\ r\isactrlbsub id\isactrlesub {\isacharparenright}{\kern0pt}\isactrlsup {\isasymstar}} matches \isa{iffoo},
|
|
227 |
respectively \isa{if}, in exactly one `iteration' of the star. The
|
|
228 |
Empty String Rule is for cases where, for example, the regular expression
|
|
229 |
\isa{{\isacharparenleft}{\kern0pt}a\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}\isactrlsup {\isasymstar}} matches against the
|
|
230 |
string \isa{bc}. Then the longest initial matched substring is the
|
|
231 |
empty string, which is matched by both the whole regular expression
|
|
232 |
and the parenthesised subexpression.
|
|
233 |
|
|
234 |
|
|
235 |
One limitation of Brzozowski's matcher is that it only generates a
|
|
236 |
YES/NO answer for whether a string is being matched by a regular
|
|
237 |
expression. Sulzmann and Lu~\cite{Sulzmann2014} extended this matcher
|
|
238 |
to allow generation not just of a YES/NO answer but of an actual
|
|
239 |
matching, called a [lexical] {\em value}. Assuming a regular
|
|
240 |
expression matches a string, values encode the information of
|
|
241 |
\emph{how} the string is matched by the regular expression---that is,
|
|
242 |
which part of the string is matched by which part of the regular
|
|
243 |
expression. For this consider again the string \isa{xy} and
|
|
244 |
the regular expression \mbox{\isa{{\isacharparenleft}{\kern0pt}x\ {\isacharplus}{\kern0pt}\ {\isacharparenleft}{\kern0pt}y\ {\isacharplus}{\kern0pt}\ xy{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\isactrlsup {\isasymstar}}}
|
|
245 |
(this time fully parenthesised). We can view this regular expression
|
|
246 |
as tree and if the string \isa{xy} is matched by two Star
|
|
247 |
`iterations', then the \isa{x} is matched by the left-most
|
|
248 |
alternative in this tree and the \isa{y} by the right-left alternative. This
|
|
249 |
suggests to record this matching as
|
|
250 |
|
|
251 |
\begin{center}
|
|
252 |
\isa{Stars\ {\isacharbrackleft}{\kern0pt}Left\ {\isacharparenleft}{\kern0pt}Char\ x{\isacharparenright}{\kern0pt}{\isacharcomma}{\kern0pt}\ Right\ {\isacharparenleft}{\kern0pt}Left\ {\isacharparenleft}{\kern0pt}Char\ y{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isacharbrackright}{\kern0pt}}
|
|
253 |
\end{center}
|
|
254 |
|
|
255 |
\noindent where \isa{Stars}, \isa{Left}, \isa{Right} and \isa{Char} are constructors for values. \isa{Stars} records how many
|
|
256 |
iterations were used; \isa{Left}, respectively \isa{Right}, which
|
|
257 |
alternative is used. This `tree view' leads naturally to the idea that
|
|
258 |
regular expressions act as types and values as inhabiting those types
|
|
259 |
(see, for example, \cite{HosoyaVouillonPierce2005}). The value for
|
|
260 |
matching \isa{xy} in a single `iteration', i.e.~the POSIX value,
|
|
261 |
would look as follows
|
|
262 |
|
|
263 |
\begin{center}
|
|
264 |
\isa{Stars\ {\isacharbrackleft}{\kern0pt}Seq\ {\isacharparenleft}{\kern0pt}Char\ x{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}Char\ y{\isacharparenright}{\kern0pt}{\isacharbrackright}{\kern0pt}}
|
|
265 |
\end{center}
|
|
266 |
|
|
267 |
\noindent where \isa{Stars} has only a single-element list for the
|
|
268 |
single iteration and \isa{Seq} indicates that \isa{xy} is matched
|
|
269 |
by a sequence regular expression.
|
|
270 |
|
|
271 |
%, which we will in what follows
|
|
272 |
%write more formally as \isa{x\ {\isasymcdot}\ y}.
|
|
273 |
|
|
274 |
|
|
275 |
Sulzmann and Lu give a simple algorithm to calculate a value that
|
|
276 |
appears to be the value associated with POSIX matching. The challenge
|
|
277 |
then is to specify that value, in an algorithm-independent fashion,
|
|
278 |
and to show that Sulzmann and Lu's derivative-based algorithm does
|
|
279 |
indeed calculate a value that is correct according to the
|
|
280 |
specification. The answer given by Sulzmann and Lu
|
|
281 |
\cite{Sulzmann2014} is to define a relation (called an ``order
|
|
282 |
relation'') on the set of values of \isa{r}, and to show that (once
|
|
283 |
a string to be matched is chosen) there is a maximum element and that
|
|
284 |
it is computed by their derivative-based algorithm. This proof idea is
|
|
285 |
inspired by work of Frisch and Cardelli \cite{Frisch2004} on a GREEDY
|
|
286 |
regular expression matching algorithm. However, we were not able to
|
|
287 |
establish transitivity and totality for the ``order relation'' by
|
|
288 |
Sulzmann and Lu. There are some inherent problems with their approach
|
|
289 |
(of which some of the proofs are not published in
|
|
290 |
\cite{Sulzmann2014}); perhaps more importantly, we give in this paper
|
|
291 |
a simple inductive (and algorithm-independent) definition of what we
|
|
292 |
call being a {\em POSIX value} for a regular expression \isa{r} and
|
|
293 |
a string \isa{s}; we show that the algorithm by Sulzmann and Lu
|
|
294 |
computes such a value and that such a value is unique. Our proofs are
|
|
295 |
both done by hand and checked in Isabelle/HOL. The experience of
|
|
296 |
doing our proofs has been that this mechanical checking was absolutely
|
|
297 |
essential: this subject area has hidden snares. This was also noted by
|
|
298 |
Kuklewicz \cite{Kuklewicz} who found that nearly all POSIX matching
|
|
299 |
implementations are ``buggy'' \cite[Page 203]{Sulzmann2014} and by
|
|
300 |
Grathwohl et al \cite[Page 36]{CrashCourse2014} who wrote:
|
|
301 |
|
|
302 |
\begin{quote}
|
|
303 |
\it{}``The POSIX strategy is more complicated than the greedy because of
|
|
304 |
the dependence on information about the length of matched strings in the
|
|
305 |
various subexpressions.''
|
|
306 |
\end{quote}
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
\noindent {\bf Contributions:} We have implemented in Isabelle/HOL the
|
|
311 |
derivative-based regular expression matching algorithm of
|
|
312 |
Sulzmann and Lu \cite{Sulzmann2014}. We have proved the correctness of this
|
|
313 |
algorithm according to our specification of what a POSIX value is (inspired
|
|
314 |
by work of Vansummeren \cite{Vansummeren2006}). Sulzmann
|
|
315 |
and Lu sketch in \cite{Sulzmann2014} an informal correctness proof: but to
|
|
316 |
us it contains unfillable gaps.\footnote{An extended version of
|
|
317 |
\cite{Sulzmann2014} is available at the website of its first author; this
|
|
318 |
extended version already includes remarks in the appendix that their
|
|
319 |
informal proof contains gaps, and possible fixes are not fully worked out.}
|
|
320 |
Our specification of a POSIX value consists of a simple inductive definition
|
|
321 |
that given a string and a regular expression uniquely determines this value.
|
|
322 |
We also show that our definition is equivalent to an ordering
|
|
323 |
of values based on positions by Okui and Suzuki \cite{OkuiSuzuki2010}.
|
|
324 |
|
|
325 |
%Derivatives as calculated by Brzozowski's method are usually more complex
|
|
326 |
%regular expressions than the initial one; various optimisations are
|
|
327 |
%possible. We prove the correctness when simplifications of \isa{\isactrlbold {\isadigit{0}}\ {\isacharplus}{\kern0pt}\ r},
|
|
328 |
%\isa{r\ {\isacharplus}{\kern0pt}\ \isactrlbold {\isadigit{0}}}, \isa{\isactrlbold {\isadigit{1}}\ {\isasymcdot}\ r} and \isa{r\ {\isasymcdot}\ \isactrlbold {\isadigit{1}}} to
|
|
329 |
%\isa{r} are applied.
|
|
330 |
|
|
331 |
We extend our results to ??? Bitcoded version??%
|
|
332 |
\end{isamarkuptext}\isamarkuptrue%
|
|
333 |
%
|
|
334 |
\isadelimdocument
|
|
335 |
%
|
|
336 |
\endisadelimdocument
|
|
337 |
%
|
|
338 |
\isatagdocument
|
|
339 |
%
|
|
340 |
\isamarkupsection{Preliminaries%
|
|
341 |
}
|
|
342 |
\isamarkuptrue%
|
|
343 |
%
|
|
344 |
\endisatagdocument
|
|
345 |
{\isafolddocument}%
|
|
346 |
%
|
|
347 |
\isadelimdocument
|
|
348 |
%
|
|
349 |
\endisadelimdocument
|
|
350 |
%
|
|
351 |
\begin{isamarkuptext}%
|
|
352 |
\noindent Strings in Isabelle/HOL are lists of characters with
|
|
353 |
the empty string being represented by the empty list, written \isa{{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}, and list-cons being written as \isa{\underline{\hspace{2mm}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}\underline{\hspace{2mm}}}. Often
|
|
354 |
we use the usual bracket notation for lists also for strings; for
|
|
355 |
example a string consisting of just a single character \isa{c} is
|
|
356 |
written \isa{{\isacharbrackleft}{\kern0pt}c{\isacharbrackright}{\kern0pt}}. We use the usual definitions for
|
|
357 |
\emph{prefixes} and \emph{strict prefixes} of strings. By using the
|
|
358 |
type \isa{char} for characters we have a supply of finitely many
|
|
359 |
characters roughly corresponding to the ASCII character set. Regular
|
|
360 |
expressions are defined as usual as the elements of the following
|
|
361 |
inductive datatype:
|
|
362 |
|
|
363 |
\begin{center}
|
|
364 |
\isa{r\ {\isacharcolon}{\kern0pt}{\isacharequal}{\kern0pt}}
|
|
365 |
\isa{\isactrlbold {\isadigit{0}}} $\mid$
|
|
366 |
\isa{\isactrlbold {\isadigit{1}}} $\mid$
|
|
367 |
\isa{c} $\mid$
|
|
368 |
\isa{r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}} $\mid$
|
|
369 |
\isa{r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}} $\mid$
|
|
370 |
\isa{r\isactrlsup {\isasymstar}}
|
|
371 |
\end{center}
|
|
372 |
|
|
373 |
\noindent where \isa{\isactrlbold {\isadigit{0}}} stands for the regular expression that does
|
|
374 |
not match any string, \isa{\isactrlbold {\isadigit{1}}} for the regular expression that matches
|
|
375 |
only the empty string and \isa{c} for matching a character literal. The
|
|
376 |
language of a regular expression is also defined as usual by the
|
|
377 |
recursive function \isa{L} with the six clauses:
|
|
378 |
|
|
379 |
\begin{center}
|
|
380 |
\begin{tabular}{l@ {\hspace{4mm}}rcl}
|
|
381 |
\textit{(1)} & \isa{L{\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{0}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isasymemptyset}}\\
|
|
382 |
\textit{(2)} & \isa{L{\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{1}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}}\\
|
|
383 |
\textit{(3)} & \isa{L{\isacharparenleft}{\kern0pt}c{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}c{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}}\\
|
|
384 |
\textit{(4)} & \isa{L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ &
|
|
385 |
\isa{L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharat}{\kern0pt}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
386 |
\textit{(5)} & \isa{L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ &
|
|
387 |
\isa{L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymunion}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
388 |
\textit{(6)} & \isa{L{\isacharparenleft}{\kern0pt}r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isasymstar}}\\
|
|
389 |
\end{tabular}
|
|
390 |
\end{center}
|
|
391 |
|
|
392 |
\noindent In clause \textit{(4)} we use the operation \isa{\underline{\hspace{2mm}}\ {\isacharat}{\kern0pt}\ \underline{\hspace{2mm}}} for the concatenation of two languages (it is also list-append for
|
|
393 |
strings). We use the star-notation for regular expressions and for
|
|
394 |
languages (in the last clause above). The star for languages is defined
|
|
395 |
inductively by two clauses: \isa{{\isacharparenleft}{\kern0pt}i{\isacharparenright}{\kern0pt}} the empty string being in
|
|
396 |
the star of a language and \isa{{\isacharparenleft}{\kern0pt}ii{\isacharparenright}{\kern0pt}} if \isa{s\isactrlsub {\isadigit{1}}} is in a
|
|
397 |
language and \isa{s\isactrlsub {\isadigit{2}}} in the star of this language, then also \isa{s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}} is in the star of this language. It will also be convenient
|
|
398 |
to use the following notion of a \emph{semantic derivative} (or \emph{left
|
|
399 |
quotient}) of a language defined as
|
|
400 |
%
|
|
401 |
\begin{center}
|
|
402 |
\isa{Der\ c\ A\ {\isasymequiv}\ {\isacharbraceleft}{\kern0pt}s\ \mbox{\boldmath$\mid$}\ c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s\ {\isasymin}\ A{\isacharbraceright}{\kern0pt}}\;.
|
|
403 |
\end{center}
|
|
404 |
|
|
405 |
\noindent
|
|
406 |
For semantic derivatives we have the following equations (for example
|
|
407 |
mechanically proved in \cite{Krauss2011}):
|
|
408 |
%
|
|
409 |
\begin{equation}\label{SemDer}
|
|
410 |
\begin{array}{lcl}
|
|
411 |
\isa{Der\ c\ {\isasymemptyset}} & \dn & \isa{{\isasymemptyset}}\\
|
|
412 |
\isa{Der\ c\ {\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}} & \dn & \isa{{\isasymemptyset}}\\
|
|
413 |
\isa{Der\ c\ {\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}d{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}} & \dn & \isa{\textrm{if}\ c\ {\isacharequal}{\kern0pt}\ d\ \textrm{then}\ {\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ \textrm{else}\ {\isasymemptyset}}\\
|
|
414 |
\isa{Der\ c\ {\isacharparenleft}{\kern0pt}A\ {\isasymunion}\ B{\isacharparenright}{\kern0pt}} & \dn & \isa{Der\ c\ A\ {\isasymunion}\ Der\ c\ B}\\
|
|
415 |
\isa{Der\ c\ {\isacharparenleft}{\kern0pt}A\ {\isacharat}{\kern0pt}\ B{\isacharparenright}{\kern0pt}} & \dn & \isa{{\isacharparenleft}{\kern0pt}Der\ c\ A\ {\isacharat}{\kern0pt}\ B{\isacharparenright}{\kern0pt}\ {\isasymunion}\ {\isacharparenleft}{\kern0pt}\textrm{if}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymin}\ A\ \textrm{then}\ Der\ c\ B\ \textrm{else}\ {\isasymemptyset}{\isacharparenright}{\kern0pt}}\\
|
|
416 |
\isa{Der\ c\ {\isacharparenleft}{\kern0pt}A{\isasymstar}{\isacharparenright}{\kern0pt}} & \dn & \isa{Der\ c\ A\ {\isacharat}{\kern0pt}\ A{\isasymstar}}
|
|
417 |
\end{array}
|
|
418 |
\end{equation}
|
|
419 |
|
|
420 |
|
|
421 |
\noindent \emph{\Brz's derivatives} of regular expressions
|
|
422 |
\cite{Brzozowski1964} can be easily defined by two recursive functions:
|
|
423 |
the first is from regular expressions to booleans (implementing a test
|
|
424 |
when a regular expression can match the empty string), and the second
|
|
425 |
takes a regular expression and a character to a (derivative) regular
|
|
426 |
expression:
|
|
427 |
|
|
428 |
\begin{center}
|
|
429 |
\begin{tabular}{lcl}
|
|
430 |
\isa{nullable\ {\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{0}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{False}\\
|
|
431 |
\isa{nullable\ {\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{1}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{True}\\
|
|
432 |
\isa{nullable\ {\isacharparenleft}{\kern0pt}c{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{False}\\
|
|
433 |
\isa{nullable\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{nullable\ r\isactrlsub {\isadigit{1}}\ {\isasymor}\ nullable\ r\isactrlsub {\isadigit{2}}}\\
|
|
434 |
\isa{nullable\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{nullable\ r\isactrlsub {\isadigit{1}}\ {\isasymand}\ nullable\ r\isactrlsub {\isadigit{2}}}\\
|
|
435 |
\isa{nullable\ {\isacharparenleft}{\kern0pt}r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{True}\medskip\\
|
|
436 |
|
|
437 |
% \end{tabular}
|
|
438 |
% \end{center}
|
|
439 |
|
|
440 |
% \begin{center}
|
|
441 |
% \begin{tabular}{lcl}
|
|
442 |
|
|
443 |
\isa{\isactrlbold {\isadigit{0}}{\isacharbackslash}{\kern0pt}c} & $\dn$ & \isa{\isactrlbold {\isadigit{0}}}\\
|
|
444 |
\isa{\isactrlbold {\isadigit{1}}{\isacharbackslash}{\kern0pt}c} & $\dn$ & \isa{\isactrlbold {\isadigit{0}}}\\
|
|
445 |
\isa{d{\isacharbackslash}{\kern0pt}c} & $\dn$ & \isa{\textrm{if}\ c\ {\isacharequal}{\kern0pt}\ d\ \textrm{then}\ \isactrlbold {\isadigit{1}}\ \textrm{else}\ \isactrlbold {\isadigit{0}}}\\
|
|
446 |
\isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isacharplus}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}}\\
|
|
447 |
\isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c} & $\dn$ & \isa{\textrm{if}\ nullable\ r\isactrlsub {\isadigit{1}}\ \textrm{then}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}\ {\isacharplus}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ \textrm{else}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}}\\
|
|
448 |
\isa{{\isacharparenleft}{\kern0pt}r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsup {\isasymstar}}
|
|
449 |
\end{tabular}
|
|
450 |
\end{center}
|
|
451 |
|
|
452 |
\noindent
|
|
453 |
We may extend this definition to give derivatives w.r.t.~strings:
|
|
454 |
|
|
455 |
\begin{center}
|
|
456 |
\begin{tabular}{lcl}
|
|
457 |
\isa{r{\isacharbackslash}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} & $\dn$ & \isa{r}\\
|
|
458 |
\isa{r{\isacharbackslash}{\kern0pt}{\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}s}\\
|
|
459 |
\end{tabular}
|
|
460 |
\end{center}
|
|
461 |
|
|
462 |
\noindent Given the equations in \eqref{SemDer}, it is a relatively easy
|
|
463 |
exercise in mechanical reasoning to establish that
|
|
464 |
|
|
465 |
\begin{proposition}\label{derprop}\mbox{}\\
|
|
466 |
\begin{tabular}{ll}
|
|
467 |
\textit{(1)} & \isa{nullable\ r} if and only if
|
|
468 |
\isa{{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}}, and \\
|
|
469 |
\textit{(2)} & \isa{L{\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ Der\ c\ {\isacharparenleft}{\kern0pt}L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}}.
|
|
470 |
\end{tabular}
|
|
471 |
\end{proposition}
|
|
472 |
|
|
473 |
\noindent With this in place it is also very routine to prove that the
|
|
474 |
regular expression matcher defined as
|
|
475 |
%
|
|
476 |
\begin{center}
|
|
477 |
\isa{match\ r\ s\ {\isasymequiv}\ nullable\ {\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}s{\isacharparenright}{\kern0pt}}
|
|
478 |
\end{center}
|
|
479 |
|
|
480 |
\noindent gives a positive answer if and only if \isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}}.
|
|
481 |
Consequently, this regular expression matching algorithm satisfies the
|
|
482 |
usual specification for regular expression matching. While the matcher
|
|
483 |
above calculates a provably correct YES/NO answer for whether a regular
|
|
484 |
expression matches a string or not, the novel idea of Sulzmann and Lu
|
|
485 |
\cite{Sulzmann2014} is to append another phase to this algorithm in order
|
|
486 |
to calculate a [lexical] value. We will explain the details next.%
|
|
487 |
\end{isamarkuptext}\isamarkuptrue%
|
|
488 |
%
|
|
489 |
\isadelimdocument
|
|
490 |
%
|
|
491 |
\endisadelimdocument
|
|
492 |
%
|
|
493 |
\isatagdocument
|
|
494 |
%
|
|
495 |
\isamarkupsection{POSIX Regular Expression Matching\label{posixsec}%
|
|
496 |
}
|
|
497 |
\isamarkuptrue%
|
|
498 |
%
|
|
499 |
\endisatagdocument
|
|
500 |
{\isafolddocument}%
|
|
501 |
%
|
|
502 |
\isadelimdocument
|
|
503 |
%
|
|
504 |
\endisadelimdocument
|
|
505 |
%
|
|
506 |
\begin{isamarkuptext}%
|
|
507 |
There have been many previous works that use values for encoding
|
|
508 |
\emph{how} a regular expression matches a string.
|
|
509 |
The clever idea by Sulzmann and Lu \cite{Sulzmann2014} is to
|
|
510 |
define a function on values that mirrors (but inverts) the
|
|
511 |
construction of the derivative on regular expressions. \emph{Values}
|
|
512 |
are defined as the inductive datatype
|
|
513 |
|
|
514 |
\begin{center}
|
|
515 |
\isa{v\ {\isacharcolon}{\kern0pt}{\isacharequal}{\kern0pt}}
|
|
516 |
\isa{Empty} $\mid$
|
|
517 |
\isa{Char\ c} $\mid$
|
|
518 |
\isa{Left\ v} $\mid$
|
|
519 |
\isa{Right\ v} $\mid$
|
|
520 |
\isa{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}} $\mid$
|
|
521 |
\isa{Stars\ vs}
|
|
522 |
\end{center}
|
|
523 |
|
|
524 |
\noindent where we use \isa{vs} to stand for a list of
|
|
525 |
values. (This is similar to the approach taken by Frisch and
|
|
526 |
Cardelli for GREEDY matching \cite{Frisch2004}, and Sulzmann and Lu
|
|
527 |
for POSIX matching \cite{Sulzmann2014}). The string underlying a
|
|
528 |
value can be calculated by the \isa{flat} function, written
|
|
529 |
\isa{{\isacharbar}{\kern0pt}\underline{\hspace{2mm}}{\isacharbar}{\kern0pt}} and defined as:
|
|
530 |
|
|
531 |
\begin{center}
|
|
532 |
\begin{tabular}[t]{lcl}
|
|
533 |
\isa{{\isacharbar}{\kern0pt}Empty{\isacharbar}{\kern0pt}} & $\dn$ & \isa{{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}\\
|
|
534 |
\isa{{\isacharbar}{\kern0pt}Char\ c{\isacharbar}{\kern0pt}} & $\dn$ & \isa{{\isacharbrackleft}{\kern0pt}c{\isacharbrackright}{\kern0pt}}\\
|
|
535 |
\isa{{\isacharbar}{\kern0pt}Left\ v{\isacharbar}{\kern0pt}} & $\dn$ & \isa{{\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}}\\
|
|
536 |
\isa{{\isacharbar}{\kern0pt}Right\ v{\isacharbar}{\kern0pt}} & $\dn$ & \isa{{\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}}
|
|
537 |
\end{tabular}\hspace{14mm}
|
|
538 |
\begin{tabular}[t]{lcl}
|
|
539 |
\isa{{\isacharbar}{\kern0pt}Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}} & $\dn$ & \isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharat}{\kern0pt}\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}}\\
|
|
540 |
\isa{{\isacharbar}{\kern0pt}Stars\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbar}{\kern0pt}} & $\dn$ & \isa{{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}\\
|
|
541 |
\isa{{\isacharbar}{\kern0pt}Stars\ {\isacharparenleft}{\kern0pt}v\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}vs{\isacharparenright}{\kern0pt}{\isacharbar}{\kern0pt}} & $\dn$ & \isa{{\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}\ {\isacharat}{\kern0pt}\ {\isacharbar}{\kern0pt}Stars\ vs{\isacharbar}{\kern0pt}}\\
|
|
542 |
\end{tabular}
|
|
543 |
\end{center}
|
|
544 |
|
|
545 |
\noindent We will sometimes refer to the underlying string of a
|
|
546 |
value as \emph{flattened value}. We will also overload our notation and
|
|
547 |
use \isa{{\isacharbar}{\kern0pt}vs{\isacharbar}{\kern0pt}} for flattening a list of values and concatenating
|
|
548 |
the resulting strings.
|
|
549 |
|
|
550 |
Sulzmann and Lu define
|
|
551 |
inductively an \emph{inhabitation relation} that associates values to
|
|
552 |
regular expressions. We define this relation as
|
|
553 |
follows:\footnote{Note that the rule for \isa{Stars} differs from
|
|
554 |
our earlier paper \cite{AusafDyckhoffUrban2016}. There we used the
|
|
555 |
original definition by Sulzmann and Lu which does not require that
|
|
556 |
the values \isa{v\ {\isasymin}\ vs} flatten to a non-empty
|
|
557 |
string. The reason for introducing the more restricted version of
|
|
558 |
lexical values is convenience later on when reasoning about an
|
|
559 |
ordering relation for values.}
|
|
560 |
|
|
561 |
\begin{center}
|
|
562 |
\begin{tabular}{c@ {\hspace{12mm}}c}\label{prfintros}
|
|
563 |
\\[-8mm]
|
|
564 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{Empty\ {\isacharcolon}{\kern0pt}\ \isactrlbold {\isadigit{1}}}}} &
|
|
565 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{Char\ c\ {\isacharcolon}{\kern0pt}\ c}}}\\[4mm]
|
|
566 |
\isa{\mbox{}\inferrule{\mbox{v\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}}{\mbox{Left\ v\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}}}} &
|
|
567 |
\isa{\mbox{}\inferrule{\mbox{v\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}}{\mbox{Right\ v\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{2}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}}}\\[4mm]
|
|
568 |
\isa{\mbox{}\inferrule{\mbox{v\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}\\\ \mbox{v\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{2}}}}{\mbox{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}}}} &
|
|
569 |
\isa{\mbox{}\inferrule{\mbox{{\isasymforall}v{\isasymin}vs{\isachardot}{\kern0pt}\ v\ {\isacharcolon}{\kern0pt}\ r\ {\isasymand}\ {\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}}{\mbox{Stars\ vs\ {\isacharcolon}{\kern0pt}\ r\isactrlsup {\isasymstar}}}}
|
|
570 |
\end{tabular}
|
|
571 |
\end{center}
|
|
572 |
|
|
573 |
\noindent where in the clause for \isa{Stars} we use the
|
|
574 |
notation \isa{v\ {\isasymin}\ vs} for indicating that \isa{v} is a
|
|
575 |
member in the list \isa{vs}. We require in this rule that every
|
|
576 |
value in \isa{vs} flattens to a non-empty string. The idea is that
|
|
577 |
\isa{Stars}-values satisfy the informal Star Rule (see Introduction)
|
|
578 |
where the $^\star$ does not match the empty string unless this is
|
|
579 |
the only match for the repetition. Note also that no values are
|
|
580 |
associated with the regular expression \isa{\isactrlbold {\isadigit{0}}}, and that the
|
|
581 |
only value associated with the regular expression \isa{\isactrlbold {\isadigit{1}}} is
|
|
582 |
\isa{Empty}. It is routine to establish how values ``inhabiting''
|
|
583 |
a regular expression correspond to the language of a regular
|
|
584 |
expression, namely
|
|
585 |
|
|
586 |
\begin{proposition}\label{inhabs}
|
|
587 |
\isa{L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbraceleft}{\kern0pt}{\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}\ \mbox{\boldmath$\mid$}\ v\ {\isacharcolon}{\kern0pt}\ r{\isacharbraceright}{\kern0pt}}
|
|
588 |
\end{proposition}
|
|
589 |
|
|
590 |
\noindent
|
|
591 |
Given a regular expression \isa{r} and a string \isa{s}, we define the
|
|
592 |
set of all \emph{Lexical Values} inhabited by \isa{r} with the underlying string
|
|
593 |
being \isa{s}:\footnote{Okui and Suzuki refer to our lexical values
|
|
594 |
as \emph{canonical values} in \cite{OkuiSuzuki2010}. The notion of \emph{non-problematic
|
|
595 |
values} by Cardelli and Frisch \cite{Frisch2004} is related, but not identical
|
|
596 |
to our lexical values.}
|
|
597 |
|
|
598 |
\begin{center}
|
|
599 |
\isa{LV\ r\ s\ {\isasymequiv}\ {\isacharbraceleft}{\kern0pt}v\ \mbox{\boldmath$\mid$}\ v\ {\isacharcolon}{\kern0pt}\ r\ {\isasymand}\ {\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ s{\isacharbraceright}{\kern0pt}}
|
|
600 |
\end{center}
|
|
601 |
|
|
602 |
\noindent The main property of \isa{LV\ r\ s} is that it is alway finite.
|
|
603 |
|
|
604 |
\begin{proposition}
|
|
605 |
\isa{finite\ {\isacharparenleft}{\kern0pt}LV\ r\ s{\isacharparenright}{\kern0pt}}
|
|
606 |
\end{proposition}
|
|
607 |
|
|
608 |
\noindent This finiteness property does not hold in general if we
|
|
609 |
remove the side-condition about \isa{{\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} in the
|
|
610 |
\isa{Stars}-rule above. For example using Sulzmann and Lu's
|
|
611 |
less restrictive definition, \isa{LV\ {\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{1}}\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} would contain
|
|
612 |
infinitely many values, but according to our more restricted
|
|
613 |
definition only a single value, namely \isa{LV\ {\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{1}}\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbraceleft}{\kern0pt}Stars\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}}.
|
|
614 |
|
|
615 |
If a regular expression \isa{r} matches a string \isa{s}, then
|
|
616 |
generally the set \isa{LV\ r\ s} is not just a singleton set. In
|
|
617 |
case of POSIX matching the problem is to calculate the unique lexical value
|
|
618 |
that satisfies the (informal) POSIX rules from the Introduction.
|
|
619 |
Graphically the POSIX value calculation algorithm by Sulzmann and Lu
|
|
620 |
can be illustrated by the picture in Figure~\ref{Sulz} where the
|
|
621 |
path from the left to the right involving \isa{derivatives}/\isa{nullable} is the first phase of the algorithm
|
|
622 |
(calculating successive \Brz's derivatives) and \isa{mkeps}/\isa{inj}, the path from right to left, the second
|
|
623 |
phase. This picture shows the steps required when a regular
|
|
624 |
expression, say \isa{r\isactrlsub {\isadigit{1}}}, matches the string \isa{{\isacharbrackleft}{\kern0pt}a{\isacharcomma}{\kern0pt}\ b{\isacharcomma}{\kern0pt}\ c{\isacharbrackright}{\kern0pt}}. We first build the three derivatives (according to
|
|
625 |
\isa{a}, \isa{b} and \isa{c}). We then use \isa{nullable}
|
|
626 |
to find out whether the resulting derivative regular expression
|
|
627 |
\isa{r\isactrlsub {\isadigit{4}}} can match the empty string. If yes, we call the
|
|
628 |
function \isa{mkeps} that produces a value \isa{v\isactrlsub {\isadigit{4}}}
|
|
629 |
for how \isa{r\isactrlsub {\isadigit{4}}} can match the empty string (taking into
|
|
630 |
account the POSIX constraints in case there are several ways). This
|
|
631 |
function is defined by the clauses:
|
|
632 |
|
|
633 |
\begin{figure}[t]
|
|
634 |
\begin{center}
|
|
635 |
\begin{tikzpicture}[scale=2,node distance=1.3cm,
|
|
636 |
every node/.style={minimum size=6mm}]
|
|
637 |
\node (r1) {\isa{r\isactrlsub {\isadigit{1}}}};
|
|
638 |
\node (r2) [right=of r1]{\isa{r\isactrlsub {\isadigit{2}}}};
|
|
639 |
\draw[->,line width=1mm](r1)--(r2) node[above,midway] {\isa{\underline{\hspace{2mm}}{\isacharbackslash}{\kern0pt}a}};
|
|
640 |
\node (r3) [right=of r2]{\isa{r\isactrlsub {\isadigit{3}}}};
|
|
641 |
\draw[->,line width=1mm](r2)--(r3) node[above,midway] {\isa{\underline{\hspace{2mm}}{\isacharbackslash}{\kern0pt}b}};
|
|
642 |
\node (r4) [right=of r3]{\isa{r\isactrlsub {\isadigit{4}}}};
|
|
643 |
\draw[->,line width=1mm](r3)--(r4) node[above,midway] {\isa{\underline{\hspace{2mm}}{\isacharbackslash}{\kern0pt}c}};
|
|
644 |
\draw (r4) node[anchor=west] {\;\raisebox{3mm}{\isa{nullable}}};
|
|
645 |
\node (v4) [below=of r4]{\isa{v\isactrlsub {\isadigit{4}}}};
|
|
646 |
\draw[->,line width=1mm](r4) -- (v4);
|
|
647 |
\node (v3) [left=of v4] {\isa{v\isactrlsub {\isadigit{3}}}};
|
|
648 |
\draw[->,line width=1mm](v4)--(v3) node[below,midway] {\isa{inj\ r\isactrlsub {\isadigit{3}}\ c}};
|
|
649 |
\node (v2) [left=of v3]{\isa{v\isactrlsub {\isadigit{2}}}};
|
|
650 |
\draw[->,line width=1mm](v3)--(v2) node[below,midway] {\isa{inj\ r\isactrlsub {\isadigit{2}}\ b}};
|
|
651 |
\node (v1) [left=of v2] {\isa{v\isactrlsub {\isadigit{1}}}};
|
|
652 |
\draw[->,line width=1mm](v2)--(v1) node[below,midway] {\isa{inj\ r\isactrlsub {\isadigit{1}}\ a}};
|
|
653 |
\draw (r4) node[anchor=north west] {\;\raisebox{-8mm}{\isa{mkeps}}};
|
|
654 |
\end{tikzpicture}
|
|
655 |
\end{center}
|
|
656 |
\mbox{}\\[-13mm]
|
|
657 |
|
|
658 |
\caption{The two phases of the algorithm by Sulzmann \& Lu \cite{Sulzmann2014},
|
|
659 |
matching the string \isa{{\isacharbrackleft}{\kern0pt}a{\isacharcomma}{\kern0pt}\ b{\isacharcomma}{\kern0pt}\ c{\isacharbrackright}{\kern0pt}}. The first phase (the arrows from
|
|
660 |
left to right) is \Brz's matcher building successive derivatives. If the
|
|
661 |
last regular expression is \isa{nullable}, then the functions of the
|
|
662 |
second phase are called (the top-down and right-to-left arrows): first
|
|
663 |
\isa{mkeps} calculates a value \isa{v\isactrlsub {\isadigit{4}}} witnessing
|
|
664 |
how the empty string has been recognised by \isa{r\isactrlsub {\isadigit{4}}}. After
|
|
665 |
that the function \isa{inj} ``injects back'' the characters of the string into
|
|
666 |
the values.
|
|
667 |
\label{Sulz}}
|
|
668 |
\end{figure}
|
|
669 |
|
|
670 |
\begin{center}
|
|
671 |
\begin{tabular}{lcl}
|
|
672 |
\isa{mkeps\ \isactrlbold {\isadigit{1}}} & $\dn$ & \isa{Empty}\\
|
|
673 |
\isa{mkeps\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{Seq\ {\isacharparenleft}{\kern0pt}mkeps\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}mkeps\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
674 |
\isa{mkeps\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{\textrm{if}\ nullable\ r\isactrlsub {\isadigit{1}}\ \textrm{then}\ Left\ {\isacharparenleft}{\kern0pt}mkeps\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ \textrm{else}\ Right\ {\isacharparenleft}{\kern0pt}mkeps\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
675 |
\isa{mkeps\ {\isacharparenleft}{\kern0pt}r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{Stars\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}\\
|
|
676 |
\end{tabular}
|
|
677 |
\end{center}
|
|
678 |
|
|
679 |
\noindent Note that this function needs only to be partially defined,
|
|
680 |
namely only for regular expressions that are nullable. In case \isa{nullable} fails, the string \isa{{\isacharbrackleft}{\kern0pt}a{\isacharcomma}{\kern0pt}\ b{\isacharcomma}{\kern0pt}\ c{\isacharbrackright}{\kern0pt}} cannot be matched by \isa{r\isactrlsub {\isadigit{1}}} and the null value \isa{None} is returned. Note also how this function
|
|
681 |
makes some subtle choices leading to a POSIX value: for example if an
|
|
682 |
alternative regular expression, say \isa{r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}}, can
|
|
683 |
match the empty string and furthermore \isa{r\isactrlsub {\isadigit{1}}} can match the
|
|
684 |
empty string, then we return a \isa{Left}-value. The \isa{Right}-value will only be returned if \isa{r\isactrlsub {\isadigit{1}}} cannot match the empty
|
|
685 |
string.
|
|
686 |
|
|
687 |
The most interesting idea from Sulzmann and Lu \cite{Sulzmann2014} is
|
|
688 |
the construction of a value for how \isa{r\isactrlsub {\isadigit{1}}} can match the
|
|
689 |
string \isa{{\isacharbrackleft}{\kern0pt}a{\isacharcomma}{\kern0pt}\ b{\isacharcomma}{\kern0pt}\ c{\isacharbrackright}{\kern0pt}} from the value how the last derivative, \isa{r\isactrlsub {\isadigit{4}}} in Fig.~\ref{Sulz}, can match the empty string. Sulzmann and
|
|
690 |
Lu achieve this by stepwise ``injecting back'' the characters into the
|
|
691 |
values thus inverting the operation of building derivatives, but on the level
|
|
692 |
of values. The corresponding function, called \isa{inj}, takes three
|
|
693 |
arguments, a regular expression, a character and a value. For example in
|
|
694 |
the first (or right-most) \isa{inj}-step in Fig.~\ref{Sulz} the regular
|
|
695 |
expression \isa{r\isactrlsub {\isadigit{3}}}, the character \isa{c} from the last
|
|
696 |
derivative step and \isa{v\isactrlsub {\isadigit{4}}}, which is the value corresponding
|
|
697 |
to the derivative regular expression \isa{r\isactrlsub {\isadigit{4}}}. The result is
|
|
698 |
the new value \isa{v\isactrlsub {\isadigit{3}}}. The final result of the algorithm is
|
|
699 |
the value \isa{v\isactrlsub {\isadigit{1}}}. The \isa{inj} function is defined by recursion on regular
|
|
700 |
expressions and by analysing the shape of values (corresponding to
|
|
701 |
the derivative regular expressions).
|
|
702 |
%
|
|
703 |
\begin{center}
|
|
704 |
\begin{tabular}{l@ {\hspace{5mm}}lcl}
|
|
705 |
\textit{(1)} & \isa{inj\ d\ c\ {\isacharparenleft}{\kern0pt}Empty{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{Char\ d}\\
|
|
706 |
\textit{(2)} & \isa{inj\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ c\ {\isacharparenleft}{\kern0pt}Left\ v\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}} & $\dn$ &
|
|
707 |
\isa{Left\ {\isacharparenleft}{\kern0pt}inj\ r\isactrlsub {\isadigit{1}}\ c\ v\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}}\\
|
|
708 |
\textit{(3)} & \isa{inj\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ c\ {\isacharparenleft}{\kern0pt}Right\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ &
|
|
709 |
\isa{Right\ {\isacharparenleft}{\kern0pt}inj\ r\isactrlsub {\isadigit{2}}\ c\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
710 |
\textit{(4)} & \isa{inj\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ c\ {\isacharparenleft}{\kern0pt}Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$
|
|
711 |
& \isa{Seq\ {\isacharparenleft}{\kern0pt}inj\ r\isactrlsub {\isadigit{1}}\ c\ v\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ v\isactrlsub {\isadigit{2}}}\\
|
|
712 |
\textit{(5)} & \isa{inj\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ c\ {\isacharparenleft}{\kern0pt}Left\ {\isacharparenleft}{\kern0pt}Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}} & $\dn$
|
|
713 |
& \isa{Seq\ {\isacharparenleft}{\kern0pt}inj\ r\isactrlsub {\isadigit{1}}\ c\ v\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ v\isactrlsub {\isadigit{2}}}\\
|
|
714 |
\textit{(6)} & \isa{inj\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ c\ {\isacharparenleft}{\kern0pt}Right\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$
|
|
715 |
& \isa{Seq\ {\isacharparenleft}{\kern0pt}mkeps\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}inj\ r\isactrlsub {\isadigit{2}}\ c\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
716 |
\textit{(7)} & \isa{inj\ {\isacharparenleft}{\kern0pt}r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}\ c\ {\isacharparenleft}{\kern0pt}Seq\ v\ {\isacharparenleft}{\kern0pt}Stars\ vs{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}} & $\dn$
|
|
717 |
& \isa{Stars\ {\isacharparenleft}{\kern0pt}inj\ r\ c\ v\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}vs{\isacharparenright}{\kern0pt}}\\
|
|
718 |
\end{tabular}
|
|
719 |
\end{center}
|
|
720 |
|
|
721 |
\noindent To better understand what is going on in this definition it
|
|
722 |
might be instructive to look first at the three sequence cases (clauses
|
|
723 |
\textit{(4)} -- \textit{(6)}). In each case we need to construct an ``injected value'' for
|
|
724 |
\isa{r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}}. This must be a value of the form \isa{Seq\ \underline{\hspace{2mm}}\ \underline{\hspace{2mm}}}\,. Recall the clause of the \isa{derivative}-function
|
|
725 |
for sequence regular expressions:
|
|
726 |
|
|
727 |
\begin{center}
|
|
728 |
\isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c} $\dn$ \isa{\textrm{if}\ nullable\ r\isactrlsub {\isadigit{1}}\ \textrm{then}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}\ {\isacharplus}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ \textrm{else}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}}
|
|
729 |
\end{center}
|
|
730 |
|
|
731 |
\noindent Consider first the \isa{else}-branch where the derivative is \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}}. The corresponding value must therefore
|
|
732 |
be of the form \isa{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}}, which matches the left-hand
|
|
733 |
side in clause~\textit{(4)} of \isa{inj}. In the \isa{if}-branch the derivative is an
|
|
734 |
alternative, namely \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}\ {\isacharplus}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}}. This means we either have to consider a \isa{Left}- or
|
|
735 |
\isa{Right}-value. In case of the \isa{Left}-value we know further it
|
|
736 |
must be a value for a sequence regular expression. Therefore the pattern
|
|
737 |
we match in the clause \textit{(5)} is \isa{Left\ {\isacharparenleft}{\kern0pt}Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}},
|
|
738 |
while in \textit{(6)} it is just \isa{Right\ v\isactrlsub {\isadigit{2}}}. One more interesting
|
|
739 |
point is in the right-hand side of clause \textit{(6)}: since in this case the
|
|
740 |
regular expression \isa{r\isactrlsub {\isadigit{1}}} does not ``contribute'' to
|
|
741 |
matching the string, that means it only matches the empty string, we need to
|
|
742 |
call \isa{mkeps} in order to construct a value for how \isa{r\isactrlsub {\isadigit{1}}}
|
|
743 |
can match this empty string. A similar argument applies for why we can
|
|
744 |
expect in the left-hand side of clause \textit{(7)} that the value is of the form
|
|
745 |
\isa{Seq\ v\ {\isacharparenleft}{\kern0pt}Stars\ vs{\isacharparenright}{\kern0pt}}---the derivative of a star is \isa{{\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsup {\isasymstar}}. Finally, the reason for why we can ignore the second argument
|
|
746 |
in clause \textit{(1)} of \isa{inj} is that it will only ever be called in cases
|
|
747 |
where \isa{c\ {\isacharequal}{\kern0pt}\ d}, but the usual linearity restrictions in patterns do
|
|
748 |
not allow us to build this constraint explicitly into our function
|
|
749 |
definition.\footnote{Sulzmann and Lu state this clause as \isa{inj\ c\ c\ {\isacharparenleft}{\kern0pt}Empty{\isacharparenright}{\kern0pt}} $\dn$ \isa{Char\ c},
|
|
750 |
but our deviation is harmless.}
|
|
751 |
|
|
752 |
The idea of the \isa{inj}-function to ``inject'' a character, say
|
|
753 |
\isa{c}, into a value can be made precise by the first part of the
|
|
754 |
following lemma, which shows that the underlying string of an injected
|
|
755 |
value has a prepended character \isa{c}; the second part shows that
|
|
756 |
the underlying string of an \isa{mkeps}-value is always the empty
|
|
757 |
string (given the regular expression is nullable since otherwise
|
|
758 |
\isa{mkeps} might not be defined).
|
|
759 |
|
|
760 |
\begin{lemma}\mbox{}\smallskip\\\label{Prf_injval_flat}
|
|
761 |
\begin{tabular}{ll}
|
|
762 |
(1) & \isa{{\normalsize{}If\,}\ v\ {\isacharcolon}{\kern0pt}\ r{\isacharbackslash}{\kern0pt}c\ {\normalsize \,then\,}\ {\isacharbar}{\kern0pt}inj\ r\ c\ v{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}{\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}{\isachardot}{\kern0pt}}\\
|
|
763 |
(2) & \isa{{\normalsize{}If\,}\ nullable\ r\ {\normalsize \,then\,}\ {\isacharbar}{\kern0pt}mkeps\ r{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isachardot}{\kern0pt}}
|
|
764 |
\end{tabular}
|
|
765 |
\end{lemma}
|
|
766 |
|
|
767 |
\begin{proof}
|
|
768 |
Both properties are by routine inductions: the first one can, for example,
|
|
769 |
be proved by induction over the definition of \isa{derivatives}; the second by
|
|
770 |
an induction on \isa{r}. There are no interesting cases.\qed
|
|
771 |
\end{proof}
|
|
772 |
|
|
773 |
Having defined the \isa{mkeps} and \isa{inj} function we can extend
|
|
774 |
\Brz's matcher so that a value is constructed (assuming the
|
|
775 |
regular expression matches the string). The clauses of the Sulzmann and Lu lexer are
|
|
776 |
|
|
777 |
\begin{center}
|
|
778 |
\begin{tabular}{lcl}
|
|
779 |
\isa{lexer\ r\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} & $\dn$ & \isa{\textrm{if}\ nullable\ r\ \textrm{then}\ Some\ {\isacharparenleft}{\kern0pt}mkeps\ r{\isacharparenright}{\kern0pt}\ \textrm{else}\ None}\\
|
|
780 |
\isa{lexer\ r\ {\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{case} \isa{lexer\ {\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ s} \isa{of}\\
|
|
781 |
& & \phantom{$|$} \isa{None} \isa{{\isasymRightarrow}} \isa{None}\\
|
|
782 |
& & $|$ \isa{Some\ v} \isa{{\isasymRightarrow}} \isa{Some\ {\isacharparenleft}{\kern0pt}inj\ r\ c\ v{\isacharparenright}{\kern0pt}}
|
|
783 |
\end{tabular}
|
|
784 |
\end{center}
|
|
785 |
|
|
786 |
\noindent If the regular expression does not match the string, \isa{None} is
|
|
787 |
returned. If the regular expression \emph{does}
|
|
788 |
match the string, then \isa{Some} value is returned. One important
|
|
789 |
virtue of this algorithm is that it can be implemented with ease in any
|
|
790 |
functional programming language and also in Isabelle/HOL. In the remaining
|
|
791 |
part of this section we prove that this algorithm is correct.
|
|
792 |
|
|
793 |
The well-known idea of POSIX matching is informally defined by some
|
|
794 |
rules such as the Longest Match and Priority Rules (see
|
|
795 |
Introduction); as correctly argued in \cite{Sulzmann2014}, this
|
|
796 |
needs formal specification. Sulzmann and Lu define an ``ordering
|
|
797 |
relation'' between values and argue that there is a maximum value,
|
|
798 |
as given by the derivative-based algorithm. In contrast, we shall
|
|
799 |
introduce a simple inductive definition that specifies directly what
|
|
800 |
a \emph{POSIX value} is, incorporating the POSIX-specific choices
|
|
801 |
into the side-conditions of our rules. Our definition is inspired by
|
|
802 |
the matching relation given by Vansummeren~\cite{Vansummeren2006}.
|
|
803 |
The relation we define is ternary and
|
|
804 |
written as \mbox{\isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}}, relating
|
|
805 |
strings, regular expressions and values; the inductive rules are given in
|
|
806 |
Figure~\ref{POSIXrules}.
|
|
807 |
We can prove that given a string \isa{s} and regular expression \isa{r}, the POSIX value \isa{v} is uniquely determined by \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}.
|
|
808 |
|
|
809 |
%
|
|
810 |
\begin{figure}[t]
|
|
811 |
\begin{center}
|
|
812 |
\begin{tabular}{c}
|
|
813 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{{\isacharparenleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharcomma}{\kern0pt}\ \isactrlbold {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Empty}}}\isa{P}\isa{\isactrlbold {\isadigit{1}}} \qquad
|
|
814 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{{\isacharparenleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}c{\isacharbrackright}{\kern0pt}{\isacharcomma}{\kern0pt}\ c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Char\ c}}}\isa{P}\isa{c}\medskip\\
|
|
815 |
\isa{\mbox{}\inferrule{\mbox{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}}{\mbox{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Left\ v}}}\isa{P{\isacharplus}{\kern0pt}L}\qquad
|
|
816 |
\isa{\mbox{}\inferrule{\mbox{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}\\\ \mbox{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}}}{\mbox{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Right\ v}}}\isa{P{\isacharplus}{\kern0pt}R}\medskip\\
|
|
817 |
$\mprset{flushleft}
|
|
818 |
\inferrule
|
|
819 |
{\isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub {\isadigit{1}}} \qquad
|
|
820 |
\isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub {\isadigit{2}}} \\\\
|
|
821 |
\isa{{\isasymnexists}s\isactrlsub {\isadigit{3}}\ s\isactrlsub {\isadigit{4}}{\isachardot}{\kern0pt}a{\isachardot}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{3}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{4}}\ {\isacharequal}{\kern0pt}\ s\isactrlsub {\isadigit{2}}\ {\isasymand}\ s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{4}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}}
|
|
822 |
{\isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}}}$\isa{PS}\\
|
|
823 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{{\isacharparenleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharcomma}{\kern0pt}\ r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Stars\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}}}\isa{P{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}\medskip\\
|
|
824 |
$\mprset{flushleft}
|
|
825 |
\inferrule
|
|
826 |
{\isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v} \qquad
|
|
827 |
\isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Stars\ vs} \qquad
|
|
828 |
\isa{{\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} \\\\
|
|
829 |
\isa{{\isasymnexists}s\isactrlsub {\isadigit{3}}\ s\isactrlsub {\isadigit{4}}{\isachardot}{\kern0pt}a{\isachardot}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{3}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{4}}\ {\isacharequal}{\kern0pt}\ s\isactrlsub {\isadigit{2}}\ {\isasymand}\ s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{4}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}}}
|
|
830 |
{\isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Stars\ {\isacharparenleft}{\kern0pt}v\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}vs{\isacharparenright}{\kern0pt}}}$\isa{P{\isasymstar}}
|
|
831 |
\end{tabular}
|
|
832 |
\end{center}
|
|
833 |
\caption{Our inductive definition of POSIX values.}\label{POSIXrules}
|
|
834 |
\end{figure}
|
|
835 |
|
|
836 |
|
|
837 |
|
|
838 |
\begin{theorem}\mbox{}\smallskip\\\label{posixdeterm}
|
|
839 |
\begin{tabular}{ll}
|
|
840 |
(1) & If \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v} then \isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}} and \isa{{\isacharbar}{\kern0pt}v{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ s}.\\
|
|
841 |
(2) & \isa{{\normalsize{}If\,}\ \mbox{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}\ {\normalsize \,and\,}\ \mbox{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v{\isacharprime}{\kern0pt}}\ {\normalsize \,then\,}\ v\ {\isacharequal}{\kern0pt}\ v{\isacharprime}{\kern0pt}{\isachardot}{\kern0pt}}
|
|
842 |
\end{tabular}
|
|
843 |
\end{theorem}
|
|
844 |
|
|
845 |
\begin{proof} Both by induction on the definition of \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}.
|
|
846 |
The second parts follows by a case analysis of \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v{\isacharprime}{\kern0pt}} and
|
|
847 |
the first part.\qed
|
|
848 |
\end{proof}
|
|
849 |
|
|
850 |
\noindent
|
|
851 |
We claim that our \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v} relation captures the idea behind the four
|
|
852 |
informal POSIX rules shown in the Introduction: Consider for example the
|
|
853 |
rules \isa{P{\isacharplus}{\kern0pt}L} and \isa{P{\isacharplus}{\kern0pt}R} where the POSIX value for a string
|
|
854 |
and an alternative regular expression, that is \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}},
|
|
855 |
is specified---it is always a \isa{Left}-value, \emph{except} when the
|
|
856 |
string to be matched is not in the language of \isa{r\isactrlsub {\isadigit{1}}}; only then it
|
|
857 |
is a \isa{Right}-value (see the side-condition in \isa{P{\isacharplus}{\kern0pt}R}).
|
|
858 |
Interesting is also the rule for sequence regular expressions (\isa{PS}). The first two premises state that \isa{v\isactrlsub {\isadigit{1}}} and \isa{v\isactrlsub {\isadigit{2}}}
|
|
859 |
are the POSIX values for \isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}} and \isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}
|
|
860 |
respectively. Consider now the third premise and note that the POSIX value
|
|
861 |
of this rule should match the string \mbox{\isa{s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}}}. According to the
|
|
862 |
Longest Match Rule, we want that the \isa{s\isactrlsub {\isadigit{1}}} is the longest initial
|
|
863 |
split of \mbox{\isa{s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}}} such that \isa{s\isactrlsub {\isadigit{2}}} is still recognised
|
|
864 |
by \isa{r\isactrlsub {\isadigit{2}}}. Let us assume, contrary to the third premise, that there
|
|
865 |
\emph{exist} an \isa{s\isactrlsub {\isadigit{3}}} and \isa{s\isactrlsub {\isadigit{4}}} such that \isa{s\isactrlsub {\isadigit{2}}}
|
|
866 |
can be split up into a non-empty string \isa{s\isactrlsub {\isadigit{3}}} and a possibly empty
|
|
867 |
string \isa{s\isactrlsub {\isadigit{4}}}. Moreover the longer string \isa{s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{3}}} can be
|
|
868 |
matched by \isa{r\isactrlsub {\isadigit{1}}} and the shorter \isa{s\isactrlsub {\isadigit{4}}} can still be
|
|
869 |
matched by \isa{r\isactrlsub {\isadigit{2}}}. In this case \isa{s\isactrlsub {\isadigit{1}}} would \emph{not} be the
|
|
870 |
longest initial split of \mbox{\isa{s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}}} and therefore \isa{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}} cannot be a POSIX value for \isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}.
|
|
871 |
The main point is that our side-condition ensures the Longest
|
|
872 |
Match Rule is satisfied.
|
|
873 |
|
|
874 |
A similar condition is imposed on the POSIX value in the \isa{P{\isasymstar}}-rule. Also there we want that \isa{s\isactrlsub {\isadigit{1}}} is the longest initial
|
|
875 |
split of \isa{s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}} and furthermore the corresponding value
|
|
876 |
\isa{v} cannot be flattened to the empty string. In effect, we require
|
|
877 |
that in each ``iteration'' of the star, some non-empty substring needs to
|
|
878 |
be ``chipped'' away; only in case of the empty string we accept \isa{Stars\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} as the POSIX value. Indeed we can show that our POSIX values
|
|
879 |
are lexical values which exclude those \isa{Stars} that contain subvalues
|
|
880 |
that flatten to the empty string.
|
|
881 |
|
|
882 |
\begin{lemma}\label{LVposix}
|
|
883 |
\isa{{\normalsize{}If\,}\ {\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\ {\normalsize \,then\,}\ v\ {\isasymin}\ LV\ r\ s{\isachardot}{\kern0pt}}
|
|
884 |
\end{lemma}
|
|
885 |
|
|
886 |
\begin{proof}
|
|
887 |
By routine induction on \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}.\qed
|
|
888 |
\end{proof}
|
|
889 |
|
|
890 |
\noindent
|
|
891 |
Next is the lemma that shows the function \isa{mkeps} calculates
|
|
892 |
the POSIX value for the empty string and a nullable regular expression.
|
|
893 |
|
|
894 |
\begin{lemma}\label{lemmkeps}
|
|
895 |
\isa{{\normalsize{}If\,}\ nullable\ r\ {\normalsize \,then\,}\ {\isacharparenleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ mkeps\ r{\isachardot}{\kern0pt}}
|
|
896 |
\end{lemma}
|
|
897 |
|
|
898 |
\begin{proof}
|
|
899 |
By routine induction on \isa{r}.\qed
|
|
900 |
\end{proof}
|
|
901 |
|
|
902 |
\noindent
|
|
903 |
The central lemma for our POSIX relation is that the \isa{inj}-function
|
|
904 |
preserves POSIX values.
|
|
905 |
|
|
906 |
\begin{lemma}\label{Posix2}
|
|
907 |
\isa{{\normalsize{}If\,}\ {\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\ {\normalsize \,then\,}\ {\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ inj\ r\ c\ v{\isachardot}{\kern0pt}}
|
|
908 |
\end{lemma}
|
|
909 |
|
|
910 |
\begin{proof}
|
|
911 |
By induction on \isa{r}. We explain two cases.
|
|
912 |
|
|
913 |
\begin{itemize}
|
|
914 |
\item[$\bullet$] Case \isa{r\ {\isacharequal}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}}. There are
|
|
915 |
two subcases, namely \isa{{\isacharparenleft}{\kern0pt}a{\isacharparenright}{\kern0pt}} \mbox{\isa{v\ {\isacharequal}{\kern0pt}\ Left\ v{\isacharprime}{\kern0pt}}} and \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v{\isacharprime}{\kern0pt}}; and \isa{{\isacharparenleft}{\kern0pt}b{\isacharparenright}{\kern0pt}} \isa{v\ {\isacharequal}{\kern0pt}\ Right\ v{\isacharprime}{\kern0pt}}, \isa{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}} and \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v{\isacharprime}{\kern0pt}}. In \isa{{\isacharparenleft}{\kern0pt}a{\isacharparenright}{\kern0pt}} we
|
|
916 |
know \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v{\isacharprime}{\kern0pt}}, from which we can infer \isa{{\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ inj\ r\isactrlsub {\isadigit{1}}\ c\ v{\isacharprime}{\kern0pt}} by induction hypothesis and hence \isa{{\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ inj\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ c\ {\isacharparenleft}{\kern0pt}Left\ v{\isacharprime}{\kern0pt}{\isacharparenright}{\kern0pt}} as needed. Similarly
|
|
917 |
in subcase \isa{{\isacharparenleft}{\kern0pt}b{\isacharparenright}{\kern0pt}} where, however, in addition we have to use
|
|
918 |
Proposition~\ref{derprop}(2) in order to infer \isa{c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}} from \isa{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}}.\smallskip
|
|
919 |
|
|
920 |
\item[$\bullet$] Case \isa{r\ {\isacharequal}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}}. There are three subcases:
|
|
921 |
|
|
922 |
\begin{quote}
|
|
923 |
\begin{description}
|
|
924 |
\item[\isa{{\isacharparenleft}{\kern0pt}a{\isacharparenright}{\kern0pt}}] \isa{v\ {\isacharequal}{\kern0pt}\ Left\ {\isacharparenleft}{\kern0pt}Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} and \isa{nullable\ r\isactrlsub {\isadigit{1}}}
|
|
925 |
\item[\isa{{\isacharparenleft}{\kern0pt}b{\isacharparenright}{\kern0pt}}] \isa{v\ {\isacharequal}{\kern0pt}\ Right\ v\isactrlsub {\isadigit{1}}} and \isa{nullable\ r\isactrlsub {\isadigit{1}}}
|
|
926 |
\item[\isa{{\isacharparenleft}{\kern0pt}c{\isacharparenright}{\kern0pt}}] \isa{v\ {\isacharequal}{\kern0pt}\ Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}} and \isa{{\isasymnot}\ nullable\ r\isactrlsub {\isadigit{1}}}
|
|
927 |
\end{description}
|
|
928 |
\end{quote}
|
|
929 |
|
|
930 |
\noindent For \isa{{\isacharparenleft}{\kern0pt}a{\isacharparenright}{\kern0pt}} we know \isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub {\isadigit{1}}} and
|
|
931 |
\isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub {\isadigit{2}}} as well as
|
|
932 |
%
|
|
933 |
\[\isa{{\isasymnexists}s\isactrlsub {\isadigit{3}}\ s\isactrlsub {\isadigit{4}}{\isachardot}{\kern0pt}a{\isachardot}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{3}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{4}}\ {\isacharequal}{\kern0pt}\ s\isactrlsub {\isadigit{2}}\ {\isasymand}\ s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{4}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\]
|
|
934 |
|
|
935 |
\noindent From the latter we can infer by Proposition~\ref{derprop}(2):
|
|
936 |
%
|
|
937 |
\[\isa{{\isasymnexists}s\isactrlsub {\isadigit{3}}\ s\isactrlsub {\isadigit{4}}{\isachardot}{\kern0pt}a{\isachardot}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{3}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{4}}\ {\isacharequal}{\kern0pt}\ s\isactrlsub {\isadigit{2}}\ {\isasymand}\ c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{4}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\]
|
|
938 |
|
|
939 |
\noindent We can use the induction hypothesis for \isa{r\isactrlsub {\isadigit{1}}} to obtain
|
|
940 |
\isa{{\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ inj\ r\isactrlsub {\isadigit{1}}\ c\ v\isactrlsub {\isadigit{1}}}. Putting this all together allows us to infer
|
|
941 |
\isa{{\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Seq\ {\isacharparenleft}{\kern0pt}inj\ r\isactrlsub {\isadigit{1}}\ c\ v\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ v\isactrlsub {\isadigit{2}}}. The case \isa{{\isacharparenleft}{\kern0pt}c{\isacharparenright}{\kern0pt}}
|
|
942 |
is similar.
|
|
943 |
|
|
944 |
For \isa{{\isacharparenleft}{\kern0pt}b{\isacharparenright}{\kern0pt}} we know \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub {\isadigit{1}}} and
|
|
945 |
\isa{s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}. From the former
|
|
946 |
we have \isa{{\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ inj\ r\isactrlsub {\isadigit{2}}\ c\ v\isactrlsub {\isadigit{1}}} by induction hypothesis
|
|
947 |
for \isa{r\isactrlsub {\isadigit{2}}}. From the latter we can infer
|
|
948 |
%
|
|
949 |
\[\isa{{\isasymnexists}s\isactrlsub {\isadigit{3}}\ s\isactrlsub {\isadigit{4}}{\isachardot}{\kern0pt}a{\isachardot}{\kern0pt}\ s\isactrlsub {\isadigit{3}}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{3}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{4}}\ {\isacharequal}{\kern0pt}\ c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s\ {\isasymand}\ s\isactrlsub {\isadigit{3}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymand}\ s\isactrlsub {\isadigit{4}}\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\]
|
|
950 |
|
|
951 |
\noindent By Lemma~\ref{lemmkeps} we know \isa{{\isacharparenleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ mkeps\ r\isactrlsub {\isadigit{1}}}
|
|
952 |
holds. Putting this all together, we can conclude with \isa{{\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Seq\ {\isacharparenleft}{\kern0pt}mkeps\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}inj\ r\isactrlsub {\isadigit{2}}\ c\ v\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}}, as required.
|
|
953 |
|
|
954 |
Finally suppose \isa{r\ {\isacharequal}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\isactrlsup {\isasymstar}}. This case is very similar to the
|
|
955 |
sequence case, except that we need to also ensure that \isa{{\isacharbar}{\kern0pt}inj\ r\isactrlsub {\isadigit{1}}\ c\ v\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isasymnoteq}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}. This follows from \isa{{\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ inj\ r\isactrlsub {\isadigit{1}}\ c\ v\isactrlsub {\isadigit{1}}} (which in turn follows from \isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub {\isadigit{1}}} and the induction hypothesis).\qed
|
|
956 |
\end{itemize}
|
|
957 |
\end{proof}
|
|
958 |
|
|
959 |
\noindent
|
|
960 |
With Lemma~\ref{Posix2} in place, it is completely routine to establish
|
|
961 |
that the Sulzmann and Lu lexer satisfies our specification (returning
|
|
962 |
the null value \isa{None} iff the string is not in the language of the regular expression,
|
|
963 |
and returning a unique POSIX value iff the string \emph{is} in the language):
|
|
964 |
|
|
965 |
\begin{theorem}\mbox{}\smallskip\\\label{lexercorrect}
|
|
966 |
\begin{tabular}{ll}
|
|
967 |
(1) & \isa{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}} if and only if \isa{lexer\ r\ s\ {\isacharequal}{\kern0pt}\ None}\\
|
|
968 |
(2) & \isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}} if and only if \isa{{\isasymexists}v{\isachardot}{\kern0pt}\ lexer\ r\ s\ {\isacharequal}{\kern0pt}\ Some\ v\ {\isasymand}\ {\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}\\
|
|
969 |
\end{tabular}
|
|
970 |
\end{theorem}
|
|
971 |
|
|
972 |
\begin{proof}
|
|
973 |
By induction on \isa{s} using Lemma~\ref{lemmkeps} and \ref{Posix2}.\qed
|
|
974 |
\end{proof}
|
|
975 |
|
|
976 |
\noindent In \textit{(2)} we further know by Theorem~\ref{posixdeterm} that the
|
|
977 |
value returned by the lexer must be unique. A simple corollary
|
|
978 |
of our two theorems is:
|
|
979 |
|
|
980 |
\begin{corollary}\mbox{}\smallskip\\\label{lexercorrectcor}
|
|
981 |
\begin{tabular}{ll}
|
|
982 |
(1) & \isa{lexer\ r\ s\ {\isacharequal}{\kern0pt}\ None} if and only if \isa{{\isasymnexists}v{\isachardot}{\kern0pt}a{\isachardot}{\kern0pt}\ {\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}\\
|
|
983 |
(2) & \isa{lexer\ r\ s\ {\isacharequal}{\kern0pt}\ Some\ v} if and only if \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}\\
|
|
984 |
\end{tabular}
|
|
985 |
\end{corollary}
|
|
986 |
|
|
987 |
\noindent This concludes our correctness proof. Note that we have
|
|
988 |
not changed the algorithm of Sulzmann and Lu,\footnote{All
|
|
989 |
deviations we introduced are harmless.} but introduced our own
|
|
990 |
specification for what a correct result---a POSIX value---should be.
|
|
991 |
In the next section we show that our specification coincides with
|
|
992 |
another one given by Okui and Suzuki using a different technique.%
|
|
993 |
\end{isamarkuptext}\isamarkuptrue%
|
|
994 |
%
|
|
995 |
\isadelimdocument
|
|
996 |
%
|
|
997 |
\endisadelimdocument
|
|
998 |
%
|
|
999 |
\isatagdocument
|
|
1000 |
%
|
|
1001 |
\isamarkupsection{Ordering of Values according to Okui and Suzuki%
|
|
1002 |
}
|
|
1003 |
\isamarkuptrue%
|
|
1004 |
%
|
|
1005 |
\endisatagdocument
|
|
1006 |
{\isafolddocument}%
|
|
1007 |
%
|
|
1008 |
\isadelimdocument
|
|
1009 |
%
|
|
1010 |
\endisadelimdocument
|
|
1011 |
%
|
|
1012 |
\begin{isamarkuptext}%
|
|
1013 |
While in the previous section we have defined POSIX values directly
|
|
1014 |
in terms of a ternary relation (see inference rules in Figure~\ref{POSIXrules}),
|
|
1015 |
Sulzmann and Lu took a different approach in \cite{Sulzmann2014}:
|
|
1016 |
they introduced an ordering for values and identified POSIX values
|
|
1017 |
as the maximal elements. An extended version of \cite{Sulzmann2014}
|
|
1018 |
is available at the website of its first author; this includes more
|
|
1019 |
details of their proofs, but which are evidently not in final form
|
|
1020 |
yet. Unfortunately, we were not able to verify claims that their
|
|
1021 |
ordering has properties such as being transitive or having maximal
|
|
1022 |
elements.
|
|
1023 |
|
|
1024 |
Okui and Suzuki \cite{OkuiSuzuki2010,OkuiSuzukiTech} described
|
|
1025 |
another ordering of values, which they use to establish the
|
|
1026 |
correctness of their automata-based algorithm for POSIX matching.
|
|
1027 |
Their ordering resembles some aspects of the one given by Sulzmann
|
|
1028 |
and Lu, but overall is quite different. To begin with, Okui and
|
|
1029 |
Suzuki identify POSIX values as minimal, rather than maximal,
|
|
1030 |
elements in their ordering. A more substantial difference is that
|
|
1031 |
the ordering by Okui and Suzuki uses \emph{positions} in order to
|
|
1032 |
identify and compare subvalues. Positions are lists of natural
|
|
1033 |
numbers. This allows them to quite naturally formalise the Longest
|
|
1034 |
Match and Priority rules of the informal POSIX standard. Consider
|
|
1035 |
for example the value \isa{v}
|
|
1036 |
|
|
1037 |
\begin{center}
|
|
1038 |
\isa{v\ {\isasymequiv}\ Stars\ {\isacharbrackleft}{\kern0pt}Seq\ {\isacharparenleft}{\kern0pt}Char\ x{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}Char\ y{\isacharparenright}{\kern0pt}{\isacharcomma}{\kern0pt}\ Char\ z{\isacharbrackright}{\kern0pt}}
|
|
1039 |
\end{center}
|
|
1040 |
|
|
1041 |
\noindent
|
|
1042 |
At position \isa{{\isacharbrackleft}{\kern0pt}{\isadigit{0}}{\isacharcomma}{\kern0pt}{\isadigit{1}}{\isacharbrackright}{\kern0pt}} of this value is the
|
|
1043 |
subvalue \isa{Char\ y} and at position \isa{{\isacharbrackleft}{\kern0pt}{\isadigit{1}}{\isacharbrackright}{\kern0pt}} the
|
|
1044 |
subvalue \isa{Char\ z}. At the `root' position, or empty list
|
|
1045 |
\isa{{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}}, is the whole value \isa{v}. Positions such as \isa{{\isacharbrackleft}{\kern0pt}{\isadigit{0}}{\isacharcomma}{\kern0pt}{\isadigit{1}}{\isacharcomma}{\kern0pt}{\isadigit{0}}{\isacharbrackright}{\kern0pt}} or \isa{{\isacharbrackleft}{\kern0pt}{\isadigit{2}}{\isacharbrackright}{\kern0pt}} are outside of \isa{v}. If it exists, the subvalue of \isa{v} at a position \isa{p}, written \isa{v\mbox{$\downharpoonleft$}\isactrlbsub p\isactrlesub }, can be recursively defined by
|
|
1046 |
|
|
1047 |
\begin{center}
|
|
1048 |
\begin{tabular}{r@ {\hspace{0mm}}lcl}
|
|
1049 |
\isa{v} & \isa{{\isasymdownharpoonleft}\isactrlbsub {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\isactrlesub } & \isa{{\isasymequiv}}& \isa{v}\\
|
|
1050 |
\isa{Left\ v} & \isa{{\isasymdownharpoonleft}\isactrlbsub {\isadigit{0}}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}ps\isactrlesub } & \isa{{\isasymequiv}}& \isa{v\mbox{$\downharpoonleft$}\isactrlbsub ps\isactrlesub }\\
|
|
1051 |
\isa{Right\ v} & \isa{{\isasymdownharpoonleft}\isactrlbsub {\isadigit{1}}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}ps\isactrlesub } & \isa{{\isasymequiv}} &
|
|
1052 |
\isa{v\mbox{$\downharpoonleft$}\isactrlbsub ps\isactrlesub }\\
|
|
1053 |
\isa{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}} & \isa{{\isasymdownharpoonleft}\isactrlbsub {\isadigit{0}}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}ps\isactrlesub } & \isa{{\isasymequiv}} &
|
|
1054 |
\isa{v\isactrlsub {\isadigit{1}}\mbox{$\downharpoonleft$}\isactrlbsub ps\isactrlesub } \\
|
|
1055 |
\isa{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}} & \isa{{\isasymdownharpoonleft}\isactrlbsub {\isadigit{1}}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}ps\isactrlesub }
|
|
1056 |
& \isa{{\isasymequiv}} &
|
|
1057 |
\isa{v\isactrlsub {\isadigit{2}}\mbox{$\downharpoonleft$}\isactrlbsub ps\isactrlesub } \\
|
|
1058 |
\isa{Stars\ vs} & \isa{{\isasymdownharpoonleft}\isactrlbsub n{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}ps\isactrlesub } & \isa{{\isasymequiv}}& \isa{vs\ensuremath{_{[\mathit{n}]}}\mbox{$\downharpoonleft$}\isactrlbsub ps\isactrlesub }\\
|
|
1059 |
\end{tabular}
|
|
1060 |
\end{center}
|
|
1061 |
|
|
1062 |
\noindent In the last clause we use Isabelle's notation \isa{vs\ensuremath{_{[\mathit{n}]}}} for the
|
|
1063 |
\isa{n}th element in a list. The set of positions inside a value \isa{v},
|
|
1064 |
written \isa{Pos\ v}, is given by
|
|
1065 |
|
|
1066 |
\begin{center}
|
|
1067 |
\begin{tabular}{lcl}
|
|
1068 |
\isa{Pos\ {\isacharparenleft}{\kern0pt}Empty{\isacharparenright}{\kern0pt}} & \isa{{\isasymequiv}} & \isa{{\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}}\\
|
|
1069 |
\isa{Pos\ {\isacharparenleft}{\kern0pt}Char\ c{\isacharparenright}{\kern0pt}} & \isa{{\isasymequiv}} & \isa{{\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}}\\
|
|
1070 |
\isa{Pos\ {\isacharparenleft}{\kern0pt}Left\ v{\isacharparenright}{\kern0pt}} & \isa{{\isasymequiv}} & \isa{{\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isasymunion}\ {\isacharbraceleft}{\kern0pt}{\isadigit{0}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\ \mbox{\boldmath$\mid$}\ ps\ {\isasymin}\ Pos\ v{\isacharbraceright}{\kern0pt}}\\
|
|
1071 |
\isa{Pos\ {\isacharparenleft}{\kern0pt}Right\ v{\isacharparenright}{\kern0pt}} & \isa{{\isasymequiv}} & \isa{{\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isasymunion}\ {\isacharbraceleft}{\kern0pt}{\isadigit{1}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\ \mbox{\boldmath$\mid$}\ ps\ {\isasymin}\ Pos\ v{\isacharbraceright}{\kern0pt}}\\
|
|
1072 |
\isa{Pos\ {\isacharparenleft}{\kern0pt}Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}
|
|
1073 |
& \isa{{\isasymequiv}}
|
|
1074 |
& \isa{{\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isasymunion}\ {\isacharbraceleft}{\kern0pt}{\isadigit{0}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\ \mbox{\boldmath$\mid$}\ ps\ {\isasymin}\ Pos\ v\isactrlsub {\isadigit{1}}{\isacharbraceright}{\kern0pt}\ {\isasymunion}\ {\isacharbraceleft}{\kern0pt}{\isadigit{1}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\ \mbox{\boldmath$\mid$}\ ps\ {\isasymin}\ Pos\ v\isactrlsub {\isadigit{2}}{\isacharbraceright}{\kern0pt}}\\
|
|
1075 |
\isa{Pos\ {\isacharparenleft}{\kern0pt}Stars\ vs{\isacharparenright}{\kern0pt}} & \isa{{\isasymequiv}} & \isa{{\isacharbraceleft}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isasymunion}\ {\isacharparenleft}{\kern0pt}{\isasymUnion}n\ {\isacharless}{\kern0pt}\ len\ vs\ {\isacharbraceleft}{\kern0pt}n\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\ \mbox{\boldmath$\mid$}\ ps\ {\isasymin}\ Pos\ vs\ensuremath{_{[\mathit{n}]}}{\isacharbraceright}{\kern0pt}{\isacharparenright}{\kern0pt}}\\
|
|
1076 |
\end{tabular}
|
|
1077 |
\end{center}
|
|
1078 |
|
|
1079 |
\noindent
|
|
1080 |
whereby \isa{len} in the last clause stands for the length of a list. Clearly
|
|
1081 |
for every position inside a value there exists a subvalue at that position.
|
|
1082 |
|
|
1083 |
|
|
1084 |
To help understanding the ordering of Okui and Suzuki, consider again
|
|
1085 |
the earlier value
|
|
1086 |
\isa{v} and compare it with the following \isa{w}:
|
|
1087 |
|
|
1088 |
\begin{center}
|
|
1089 |
\begin{tabular}{l}
|
|
1090 |
\isa{v\ {\isasymequiv}\ Stars\ {\isacharbrackleft}{\kern0pt}Seq\ {\isacharparenleft}{\kern0pt}Char\ x{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}Char\ y{\isacharparenright}{\kern0pt}{\isacharcomma}{\kern0pt}\ Char\ z{\isacharbrackright}{\kern0pt}}\\
|
|
1091 |
\isa{w\ {\isasymequiv}\ Stars\ {\isacharbrackleft}{\kern0pt}Char\ x{\isacharcomma}{\kern0pt}\ Char\ y{\isacharcomma}{\kern0pt}\ Char\ z{\isacharbrackright}{\kern0pt}}
|
|
1092 |
\end{tabular}
|
|
1093 |
\end{center}
|
|
1094 |
|
|
1095 |
\noindent Both values match the string \isa{xyz}, that means if
|
|
1096 |
we flatten these values at their respective root position, we obtain
|
|
1097 |
\isa{xyz}. However, at position \isa{{\isacharbrackleft}{\kern0pt}{\isadigit{0}}{\isacharbrackright}{\kern0pt}}, \isa{v} matches
|
|
1098 |
\isa{xy} whereas \isa{w} matches only the shorter \isa{x}. So
|
|
1099 |
according to the Longest Match Rule, we should prefer \isa{v},
|
|
1100 |
rather than \isa{w} as POSIX value for string \isa{xyz} (and
|
|
1101 |
corresponding regular expression). In order to
|
|
1102 |
formalise this idea, Okui and Suzuki introduce a measure for
|
|
1103 |
subvalues at position \isa{p}, called the \emph{norm} of \isa{v}
|
|
1104 |
at position \isa{p}. We can define this measure in Isabelle as an
|
|
1105 |
integer as follows
|
|
1106 |
|
|
1107 |
\begin{center}
|
|
1108 |
\isa{{\isasymparallel}v{\isasymparallel}\isactrlbsub p\isactrlesub \ {\isasymequiv}\ \textrm{if}\ p\ {\isasymin}\ Pos\ v\ \textrm{then}\ len\ {\isacharbar}{\kern0pt}v\mbox{$\downharpoonleft$}\isactrlbsub p\isactrlesub {\isacharbar}{\kern0pt}\ \textrm{else}\ {\isacharminus}{\kern0pt}\ {\isadigit{1}}}
|
|
1109 |
\end{center}
|
|
1110 |
|
|
1111 |
\noindent where we take the length of the flattened value at
|
|
1112 |
position \isa{p}, provided the position is inside \isa{v}; if
|
|
1113 |
not, then the norm is \isa{{\isacharminus}{\kern0pt}{\isadigit{1}}}. The default for outside
|
|
1114 |
positions is crucial for the POSIX requirement of preferring a
|
|
1115 |
\isa{Left}-value over a \isa{Right}-value (if they can match the
|
|
1116 |
same string---see the Priority Rule from the Introduction). For this
|
|
1117 |
consider
|
|
1118 |
|
|
1119 |
\begin{center}
|
|
1120 |
\isa{v\ {\isasymequiv}\ Left\ {\isacharparenleft}{\kern0pt}Char\ x{\isacharparenright}{\kern0pt}} \qquad and \qquad \isa{w\ {\isasymequiv}\ Right\ {\isacharparenleft}{\kern0pt}Char\ x{\isacharparenright}{\kern0pt}}
|
|
1121 |
\end{center}
|
|
1122 |
|
|
1123 |
\noindent Both values match \isa{x}. At position \isa{{\isacharbrackleft}{\kern0pt}{\isadigit{0}}{\isacharbrackright}{\kern0pt}}
|
|
1124 |
the norm of \isa{v} is \isa{{\isadigit{1}}} (the subvalue matches \isa{x}),
|
|
1125 |
but the norm of \isa{w} is \isa{{\isacharminus}{\kern0pt}{\isadigit{1}}} (the position is outside
|
|
1126 |
\isa{w} according to how we defined the `inside' positions of
|
|
1127 |
\isa{Left}- and \isa{Right}-values). Of course at position
|
|
1128 |
\isa{{\isacharbrackleft}{\kern0pt}{\isadigit{1}}{\isacharbrackright}{\kern0pt}}, the norms \isa{{\isasymparallel}v{\isasymparallel}\isactrlbsub {\isacharbrackleft}{\kern0pt}{\isadigit{1}}{\isacharbrackright}{\kern0pt}\isactrlesub } and \isa{{\isasymparallel}w{\isasymparallel}\isactrlbsub {\isacharbrackleft}{\kern0pt}{\isadigit{1}}{\isacharbrackright}{\kern0pt}\isactrlesub } are reversed, but the point is that subvalues
|
|
1129 |
will be analysed according to lexicographically ordered
|
|
1130 |
positions. According to this ordering, the position \isa{{\isacharbrackleft}{\kern0pt}{\isadigit{0}}{\isacharbrackright}{\kern0pt}}
|
|
1131 |
takes precedence over \isa{{\isacharbrackleft}{\kern0pt}{\isadigit{1}}{\isacharbrackright}{\kern0pt}} and thus also \isa{v} will be
|
|
1132 |
preferred over \isa{w}. The lexicographic ordering of positions, written
|
|
1133 |
\isa{\underline{\hspace{2mm}}\ {\isasymprec}\isactrlbsub lex\isactrlesub \ \underline{\hspace{2mm}}}, can be conveniently formalised
|
|
1134 |
by three inference rules
|
|
1135 |
|
|
1136 |
\begin{center}
|
|
1137 |
\begin{tabular}{ccc}
|
|
1138 |
\isa{\mbox{}\inferrule{\mbox{}}{\mbox{{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ {\isasymprec}\isactrlbsub lex\isactrlesub \ p\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps}}}\hspace{1cm} &
|
|
1139 |
\isa{\mbox{}\inferrule{\mbox{p\isactrlsub {\isadigit{1}}\ {\isacharless}{\kern0pt}\ p\isactrlsub {\isadigit{2}}}}{\mbox{p\isactrlsub {\isadigit{1}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\isactrlsub {\isadigit{1}}\ {\isasymprec}\isactrlbsub lex\isactrlesub \ p\isactrlsub {\isadigit{2}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\isactrlsub {\isadigit{2}}}}}\hspace{1cm} &
|
|
1140 |
\isa{\mbox{}\inferrule{\mbox{ps\isactrlsub {\isadigit{1}}\ {\isasymprec}\isactrlbsub lex\isactrlesub \ ps\isactrlsub {\isadigit{2}}}}{\mbox{p\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\isactrlsub {\isadigit{1}}\ {\isasymprec}\isactrlbsub lex\isactrlesub \ p\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}ps\isactrlsub {\isadigit{2}}}}}
|
|
1141 |
\end{tabular}
|
|
1142 |
\end{center}
|
|
1143 |
|
|
1144 |
With the norm and lexicographic order in place,
|
|
1145 |
we can state the key definition of Okui and Suzuki
|
|
1146 |
\cite{OkuiSuzuki2010}: a value \isa{v\isactrlsub {\isadigit{1}}} is \emph{smaller at position \isa{p}} than
|
|
1147 |
\isa{v\isactrlsub {\isadigit{2}}}, written \isa{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\isactrlbsub p\isactrlesub \ v\isactrlsub {\isadigit{2}}},
|
|
1148 |
if and only if $(i)$ the norm at position \isa{p} is
|
|
1149 |
greater in \isa{v\isactrlsub {\isadigit{1}}} (that is the string \isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}\mbox{$\downharpoonleft$}\isactrlbsub p\isactrlesub {\isacharbar}{\kern0pt}} is longer
|
|
1150 |
than \isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}\mbox{$\downharpoonleft$}\isactrlbsub p\isactrlesub {\isacharbar}{\kern0pt}}) and $(ii)$ all subvalues at
|
|
1151 |
positions that are inside \isa{v\isactrlsub {\isadigit{1}}} or \isa{v\isactrlsub {\isadigit{2}}} and that are
|
|
1152 |
lexicographically smaller than \isa{p}, we have the same norm, namely
|
|
1153 |
|
|
1154 |
\begin{center}
|
|
1155 |
\begin{tabular}{c}
|
|
1156 |
\isa{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\isactrlbsub p\isactrlesub \ v\isactrlsub {\isadigit{2}}}
|
|
1157 |
\isa{{\isasymequiv}}
|
|
1158 |
$\begin{cases}
|
|
1159 |
(i) & \isa{{\isasymparallel}v\isactrlsub {\isadigit{2}}{\isasymparallel}\isactrlbsub p\isactrlesub \ {\isacharless}{\kern0pt}\ {\isasymparallel}v\isactrlsub {\isadigit{1}}{\isasymparallel}\isactrlbsub p\isactrlesub } \quad\text{and}\smallskip \\
|
|
1160 |
(ii) & \isa{{\isasymforall}q{\isasymin}Pos\ v\isactrlsub {\isadigit{1}}\ {\isasymunion}\ Pos\ v\isactrlsub {\isadigit{2}}{\isachardot}{\kern0pt}\ q\ {\isasymprec}\isactrlbsub lex\isactrlesub \ p\ {\isasymlongrightarrow}\ {\isasymparallel}v\isactrlsub {\isadigit{1}}{\isasymparallel}\isactrlbsub q\isactrlesub \ {\isacharequal}{\kern0pt}\ {\isasymparallel}v\isactrlsub {\isadigit{2}}{\isasymparallel}\isactrlbsub q\isactrlesub }
|
|
1161 |
\end{cases}$
|
|
1162 |
\end{tabular}
|
|
1163 |
\end{center}
|
|
1164 |
|
|
1165 |
\noindent The position \isa{p} in this definition acts as the
|
|
1166 |
\emph{first distinct position} of \isa{v\isactrlsub {\isadigit{1}}} and \isa{v\isactrlsub {\isadigit{2}}}, where both values match strings of different length
|
|
1167 |
\cite{OkuiSuzuki2010}. Since at \isa{p} the values \isa{v\isactrlsub {\isadigit{1}}} and \isa{v\isactrlsub {\isadigit{2}}} match different strings, the
|
|
1168 |
ordering is irreflexive. Derived from the definition above
|
|
1169 |
are the following two orderings:
|
|
1170 |
|
|
1171 |
\begin{center}
|
|
1172 |
\begin{tabular}{l}
|
|
1173 |
\isa{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{2}}\ {\isasymequiv}\ {\isasymexists}p{\isachardot}{\kern0pt}\ v\isactrlsub {\isadigit{1}}\ {\isasymprec}\isactrlbsub p\isactrlesub \ v\isactrlsub {\isadigit{2}}}\\
|
|
1174 |
\isa{v\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ v\isactrlsub {\isadigit{2}}\ {\isasymequiv}\ v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{2}}\ {\isasymor}\ v\isactrlsub {\isadigit{1}}\ {\isacharequal}{\kern0pt}\ v\isactrlsub {\isadigit{2}}}
|
|
1175 |
\end{tabular}
|
|
1176 |
\end{center}
|
|
1177 |
|
|
1178 |
While we encountered a number of obstacles for establishing properties like
|
|
1179 |
transitivity for the ordering of Sulzmann and Lu (and which we failed
|
|
1180 |
to overcome), it is relatively straightforward to establish this
|
|
1181 |
property for the orderings
|
|
1182 |
\isa{\underline{\hspace{2mm}}\ {\isasymprec}\ \underline{\hspace{2mm}}} and \isa{\underline{\hspace{2mm}}\ \mbox{$\preccurlyeq$}\ \underline{\hspace{2mm}}}
|
|
1183 |
by Okui and Suzuki.
|
|
1184 |
|
|
1185 |
\begin{lemma}[Transitivity]\label{transitivity}
|
|
1186 |
\isa{{\normalsize{}If\,}\ \mbox{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{2}}}\ {\normalsize \,and\,}\ \mbox{v\isactrlsub {\isadigit{2}}\ {\isasymprec}\ v\isactrlsub {\isadigit{3}}}\ {\normalsize \,then\,}\ v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{3}}{\isachardot}{\kern0pt}}
|
|
1187 |
\end{lemma}
|
|
1188 |
|
|
1189 |
\begin{proof} From the assumption we obtain two positions \isa{p}
|
|
1190 |
and \isa{q}, where the values \isa{v\isactrlsub {\isadigit{1}}} and \isa{v\isactrlsub {\isadigit{2}}} (respectively \isa{v\isactrlsub {\isadigit{2}}} and \isa{v\isactrlsub {\isadigit{3}}}) are `distinct'. Since \isa{{\isasymprec}\isactrlbsub lex\isactrlesub } is trichotomous, we need to consider
|
|
1191 |
three cases, namely \isa{p\ {\isacharequal}{\kern0pt}\ q}, \isa{p\ {\isasymprec}\isactrlbsub lex\isactrlesub \ q} and
|
|
1192 |
\isa{q\ {\isasymprec}\isactrlbsub lex\isactrlesub \ p}. Let us look at the first case. Clearly
|
|
1193 |
\isa{{\isasymparallel}v\isactrlsub {\isadigit{2}}{\isasymparallel}\isactrlbsub p\isactrlesub \ {\isacharless}{\kern0pt}\ {\isasymparallel}v\isactrlsub {\isadigit{1}}{\isasymparallel}\isactrlbsub p\isactrlesub } and \isa{{\isasymparallel}v\isactrlsub {\isadigit{3}}{\isasymparallel}\isactrlbsub p\isactrlesub \ {\isacharless}{\kern0pt}\ {\isasymparallel}v\isactrlsub {\isadigit{2}}{\isasymparallel}\isactrlbsub p\isactrlesub } imply \isa{{\isasymparallel}v\isactrlsub {\isadigit{3}}{\isasymparallel}\isactrlbsub p\isactrlesub \ {\isacharless}{\kern0pt}\ {\isasymparallel}v\isactrlsub {\isadigit{1}}{\isasymparallel}\isactrlbsub p\isactrlesub }. It remains to show
|
|
1194 |
that for a \isa{p{\isacharprime}{\kern0pt}\ {\isasymin}\ Pos\ v\isactrlsub {\isadigit{1}}\ {\isasymunion}\ Pos\ v\isactrlsub {\isadigit{3}}}
|
|
1195 |
with \isa{p{\isacharprime}{\kern0pt}\ {\isasymprec}\isactrlbsub lex\isactrlesub \ p} that \isa{{\isasymparallel}v\isactrlsub {\isadigit{1}}{\isasymparallel}\isactrlbsub p{\isacharprime}{\kern0pt}\isactrlesub \ {\isacharequal}{\kern0pt}\ {\isasymparallel}v\isactrlsub {\isadigit{3}}{\isasymparallel}\isactrlbsub p{\isacharprime}{\kern0pt}\isactrlesub } holds. Suppose \isa{p{\isacharprime}{\kern0pt}\ {\isasymin}\ Pos\ v\isactrlsub {\isadigit{1}}}, then we can infer from the first assumption that \isa{{\isasymparallel}v\isactrlsub {\isadigit{1}}{\isasymparallel}\isactrlbsub p{\isacharprime}{\kern0pt}\isactrlesub \ {\isacharequal}{\kern0pt}\ {\isasymparallel}v\isactrlsub {\isadigit{2}}{\isasymparallel}\isactrlbsub p{\isacharprime}{\kern0pt}\isactrlesub }. But this means
|
|
1196 |
that \isa{p{\isacharprime}{\kern0pt}} must be in \isa{Pos\ v\isactrlsub {\isadigit{2}}} too (the norm
|
|
1197 |
cannot be \isa{{\isacharminus}{\kern0pt}{\isadigit{1}}} given \isa{p{\isacharprime}{\kern0pt}\ {\isasymin}\ Pos\ v\isactrlsub {\isadigit{1}}}).
|
|
1198 |
Hence we can use the second assumption and
|
|
1199 |
infer \isa{{\isasymparallel}v\isactrlsub {\isadigit{2}}{\isasymparallel}\isactrlbsub p{\isacharprime}{\kern0pt}\isactrlesub \ {\isacharequal}{\kern0pt}\ {\isasymparallel}v\isactrlsub {\isadigit{3}}{\isasymparallel}\isactrlbsub p{\isacharprime}{\kern0pt}\isactrlesub },
|
|
1200 |
which concludes this case with \isa{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{3}}}. The reasoning in the other cases is similar.\qed
|
|
1201 |
\end{proof}
|
|
1202 |
|
|
1203 |
\noindent
|
|
1204 |
The proof for $\preccurlyeq$ is similar and omitted.
|
|
1205 |
It is also straightforward to show that \isa{{\isasymprec}} and
|
|
1206 |
$\preccurlyeq$ are partial orders. Okui and Suzuki furthermore show that they
|
|
1207 |
are linear orderings for lexical values \cite{OkuiSuzuki2010} of a given
|
|
1208 |
regular expression and given string, but we have not formalised this in Isabelle. It is
|
|
1209 |
not essential for our results. What we are going to show below is
|
|
1210 |
that for a given \isa{r} and \isa{s}, the orderings have a unique
|
|
1211 |
minimal element on the set \isa{LV\ r\ s}, which is the POSIX value
|
|
1212 |
we defined in the previous section. We start with two properties that
|
|
1213 |
show how the length of a flattened value relates to the \isa{{\isasymprec}}-ordering.
|
|
1214 |
|
|
1215 |
\begin{proposition}\mbox{}\smallskip\\\label{ordlen}
|
|
1216 |
\begin{tabular}{@ {}ll}
|
|
1217 |
(1) &
|
|
1218 |
\isa{{\normalsize{}If\,}\ v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{2}}\ {\normalsize \,then\,}\ len\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}\ {\isasymle}\ len\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}{\isachardot}{\kern0pt}}\\
|
|
1219 |
(2) &
|
|
1220 |
\isa{{\normalsize{}If\,}\ len\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}\ {\isacharless}{\kern0pt}\ len\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\normalsize \,then\,}\ v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{2}}{\isachardot}{\kern0pt}}
|
|
1221 |
\end{tabular}
|
|
1222 |
\end{proposition}
|
|
1223 |
|
|
1224 |
\noindent Both properties follow from the definition of the ordering. Note that
|
|
1225 |
\textit{(2)} entails that a value, say \isa{v\isactrlsub {\isadigit{2}}}, whose underlying
|
|
1226 |
string is a strict prefix of another flattened value, say \isa{v\isactrlsub {\isadigit{1}}}, then
|
|
1227 |
\isa{v\isactrlsub {\isadigit{1}}} must be smaller than \isa{v\isactrlsub {\isadigit{2}}}. For our proofs it
|
|
1228 |
will be useful to have the following properties---in each case the underlying strings
|
|
1229 |
of the compared values are the same:
|
|
1230 |
|
|
1231 |
\begin{proposition}\mbox{}\smallskip\\\label{ordintros}
|
|
1232 |
\begin{tabular}{ll}
|
|
1233 |
\textit{(1)} &
|
|
1234 |
\isa{{\normalsize{}If\,}\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}\ {\normalsize \,then\,}\ Left\ v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ Right\ v\isactrlsub {\isadigit{2}}{\isachardot}{\kern0pt}}\\
|
|
1235 |
\textit{(2)} & If
|
|
1236 |
\isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}} \;then\;
|
|
1237 |
\isa{Left\ v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ Left\ v\isactrlsub {\isadigit{2}}} \;iff\;
|
|
1238 |
\isa{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{2}}}\\
|
|
1239 |
\textit{(3)} & If
|
|
1240 |
\isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}} \;then\;
|
|
1241 |
\isa{Right\ v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ Right\ v\isactrlsub {\isadigit{2}}} \;iff\;
|
|
1242 |
\isa{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{2}}}\\
|
|
1243 |
\textit{(4)} & If
|
|
1244 |
\isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}w\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}} \;then\;
|
|
1245 |
\isa{Seq\ v\ v\isactrlsub {\isadigit{2}}\ {\isasymprec}\ Seq\ v\ w\isactrlsub {\isadigit{2}}} \;iff\;
|
|
1246 |
\isa{v\isactrlsub {\isadigit{2}}\ {\isasymprec}\ w\isactrlsub {\isadigit{2}}}\\
|
|
1247 |
\textit{(5)} & If
|
|
1248 |
\isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharat}{\kern0pt}\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}w\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharat}{\kern0pt}\ {\isacharbar}{\kern0pt}w\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}} \;and\;
|
|
1249 |
\isa{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ w\isactrlsub {\isadigit{1}}} \;then\;
|
|
1250 |
\isa{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}\ {\isasymprec}\ Seq\ w\isactrlsub {\isadigit{1}}\ w\isactrlsub {\isadigit{2}}}\\
|
|
1251 |
\textit{(6)} & If
|
|
1252 |
\isa{{\isacharbar}{\kern0pt}vs\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}vs\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}} \;then\;
|
|
1253 |
\isa{Stars\ {\isacharparenleft}{\kern0pt}vs\ {\isacharat}{\kern0pt}\ vs\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymprec}\ Stars\ {\isacharparenleft}{\kern0pt}vs\ {\isacharat}{\kern0pt}\ vs\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} \;iff\;
|
|
1254 |
\isa{Stars\ vs\isactrlsub {\isadigit{1}}\ {\isasymprec}\ Stars\ vs\isactrlsub {\isadigit{2}}}\\
|
|
1255 |
|
|
1256 |
\textit{(7)} & If
|
|
1257 |
\isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{1}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}vs\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}vs\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}} \;and\;
|
|
1258 |
\isa{v\isactrlsub {\isadigit{1}}\ {\isasymprec}\ v\isactrlsub {\isadigit{2}}} \;then\;
|
|
1259 |
\isa{Stars\ {\isacharparenleft}{\kern0pt}v\isactrlsub {\isadigit{1}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}vs\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isasymprec}\ Stars\ {\isacharparenleft}{\kern0pt}v\isactrlsub {\isadigit{2}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}vs\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
1260 |
\end{tabular}
|
|
1261 |
\end{proposition}
|
|
1262 |
|
|
1263 |
\noindent One might prefer that statements \textit{(4)} and \textit{(5)}
|
|
1264 |
(respectively \textit{(6)} and \textit{(7)})
|
|
1265 |
are combined into a single \textit{iff}-statement (like the ones for \isa{Left} and \isa{Right}). Unfortunately this cannot be done easily: such
|
|
1266 |
a single statement would require an additional assumption about the
|
|
1267 |
two values \isa{Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}} and \isa{Seq\ w\isactrlsub {\isadigit{1}}\ w\isactrlsub {\isadigit{2}}}
|
|
1268 |
being inhabited by the same regular expression. The
|
|
1269 |
complexity of the proofs involved seems to not justify such a
|
|
1270 |
`cleaner' single statement. The statements given are just the properties that
|
|
1271 |
allow us to establish our theorems without any difficulty. The proofs
|
|
1272 |
for Proposition~\ref{ordintros} are routine.
|
|
1273 |
|
|
1274 |
|
|
1275 |
Next we establish how Okui and Suzuki's orderings relate to our
|
|
1276 |
definition of POSIX values. Given a \isa{POSIX} value \isa{v\isactrlsub {\isadigit{1}}}
|
|
1277 |
for \isa{r} and \isa{s}, then any other lexical value \isa{v\isactrlsub {\isadigit{2}}} in \isa{LV\ r\ s} is greater or equal than \isa{v\isactrlsub {\isadigit{1}}}, namely:
|
|
1278 |
|
|
1279 |
|
|
1280 |
\begin{theorem}\label{orderone}
|
|
1281 |
\isa{{\normalsize{}If\,}\ \mbox{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub {\isadigit{1}}}\ {\normalsize \,and\,}\ \mbox{v\isactrlsub {\isadigit{2}}\ {\isasymin}\ LV\ r\ s}\ {\normalsize \,then\,}\ v\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ v\isactrlsub {\isadigit{2}}{\isachardot}{\kern0pt}}
|
|
1282 |
\end{theorem}
|
|
1283 |
|
|
1284 |
\begin{proof} By induction on our POSIX rules. By
|
|
1285 |
Theorem~\ref{posixdeterm} and the definition of \isa{LV}, it is clear
|
|
1286 |
that \isa{v\isactrlsub {\isadigit{1}}} and \isa{v\isactrlsub {\isadigit{2}}} have the same
|
|
1287 |
underlying string \isa{s}. The three base cases are
|
|
1288 |
straightforward: for example for \isa{v\isactrlsub {\isadigit{1}}\ {\isacharequal}{\kern0pt}\ Empty}, we have
|
|
1289 |
that \isa{v\isactrlsub {\isadigit{2}}\ {\isasymin}\ LV\ \isactrlbold {\isadigit{1}}\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} must also be of the form
|
|
1290 |
\mbox{\isa{v\isactrlsub {\isadigit{2}}\ {\isacharequal}{\kern0pt}\ Empty}}. Therefore we have \isa{v\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ v\isactrlsub {\isadigit{2}}}. The inductive cases for
|
|
1291 |
\isa{r} being of the form \isa{r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}} and
|
|
1292 |
\isa{r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}} are as follows:
|
|
1293 |
|
|
1294 |
|
|
1295 |
\begin{itemize}
|
|
1296 |
|
|
1297 |
\item[$\bullet$] Case \isa{P{\isacharplus}{\kern0pt}L} with \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Left\ w\isactrlsub {\isadigit{1}}}: In this case the value
|
|
1298 |
\isa{v\isactrlsub {\isadigit{2}}} is either of the
|
|
1299 |
form \isa{Left\ w\isactrlsub {\isadigit{2}}} or \isa{Right\ w\isactrlsub {\isadigit{2}}}. In the
|
|
1300 |
latter case we can immediately conclude with \mbox{\isa{v\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ v\isactrlsub {\isadigit{2}}}} since a \isa{Left}-value with the
|
|
1301 |
same underlying string \isa{s} is always smaller than a
|
|
1302 |
\isa{Right}-value by Proposition~\ref{ordintros}\textit{(1)}.
|
|
1303 |
In the former case we have \isa{w\isactrlsub {\isadigit{2}}\ {\isasymin}\ LV\ r\isactrlsub {\isadigit{1}}\ s} and can use the induction hypothesis to infer
|
|
1304 |
\isa{w\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ w\isactrlsub {\isadigit{2}}}. Because \isa{w\isactrlsub {\isadigit{1}}} and \isa{w\isactrlsub {\isadigit{2}}} have the same underlying string
|
|
1305 |
\isa{s}, we can conclude with \isa{Left\ w\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ Left\ w\isactrlsub {\isadigit{2}}} using
|
|
1306 |
Proposition~\ref{ordintros}\textit{(2)}.\smallskip
|
|
1307 |
|
|
1308 |
\item[$\bullet$] Case \isa{P{\isacharplus}{\kern0pt}R} with \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Right\ w\isactrlsub {\isadigit{1}}}: This case similar to the previous
|
|
1309 |
case, except that we additionally know \isa{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}}. This is needed when \isa{v\isactrlsub {\isadigit{2}}} is of the form
|
|
1310 |
\mbox{\isa{Left\ w\isactrlsub {\isadigit{2}}}}. Since \mbox{\isa{{\isacharbar}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}w\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}} \isa{{\isacharequal}{\kern0pt}\ s}} and \isa{w\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}}, we can derive a contradiction for \mbox{\isa{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}}} using
|
|
1311 |
Proposition~\ref{inhabs}. So also in this case \mbox{\isa{v\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ v\isactrlsub {\isadigit{2}}}}.\smallskip
|
|
1312 |
|
|
1313 |
\item[$\bullet$] Case \isa{PS} with \isa{{\isacharparenleft}{\kern0pt}s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Seq\ w\isactrlsub {\isadigit{1}}\ w\isactrlsub {\isadigit{2}}}: We can assume \isa{v\isactrlsub {\isadigit{2}}\ {\isacharequal}{\kern0pt}\ Seq\ u\isactrlsub {\isadigit{1}}\ u\isactrlsub {\isadigit{2}}} with \isa{u\isactrlsub {\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{1}}} and \mbox{\isa{u\isactrlsub {\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ r\isactrlsub {\isadigit{2}}}}. We have \isa{s\isactrlsub {\isadigit{1}}\ {\isacharat}{\kern0pt}\ s\isactrlsub {\isadigit{2}}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}u\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}\ {\isacharat}{\kern0pt}\ {\isacharbar}{\kern0pt}u\isactrlsub {\isadigit{2}}{\isacharbar}{\kern0pt}}. By the side-condition of the
|
|
1314 |
\isa{PS}-rule we know that either \isa{s\isactrlsub {\isadigit{1}}\ {\isacharequal}{\kern0pt}\ {\isacharbar}{\kern0pt}u\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}} or that \isa{{\isacharbar}{\kern0pt}u\isactrlsub {\isadigit{1}}{\isacharbar}{\kern0pt}} is a strict prefix of
|
|
1315 |
\isa{s\isactrlsub {\isadigit{1}}}. In the latter case we can infer \isa{w\isactrlsub {\isadigit{1}}\ {\isasymprec}\ u\isactrlsub {\isadigit{1}}} by
|
|
1316 |
Proposition~\ref{ordlen}\textit{(2)} and from this \isa{v\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ v\isactrlsub {\isadigit{2}}} by Proposition~\ref{ordintros}\textit{(5)}
|
|
1317 |
(as noted above \isa{v\isactrlsub {\isadigit{1}}} and \isa{v\isactrlsub {\isadigit{2}}} must have the
|
|
1318 |
same underlying string).
|
|
1319 |
In the former case we know
|
|
1320 |
\isa{u\isactrlsub {\isadigit{1}}\ {\isasymin}\ LV\ r\isactrlsub {\isadigit{1}}\ s\isactrlsub {\isadigit{1}}} and \isa{u\isactrlsub {\isadigit{2}}\ {\isasymin}\ LV\ r\isactrlsub {\isadigit{2}}\ s\isactrlsub {\isadigit{2}}}. With this we can use the
|
|
1321 |
induction hypotheses to infer \isa{w\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ u\isactrlsub {\isadigit{1}}} and \isa{w\isactrlsub {\isadigit{2}}\ \mbox{$\preccurlyeq$}\ u\isactrlsub {\isadigit{2}}}. By
|
|
1322 |
Proposition~\ref{ordintros}\textit{(4,5)} we can again infer
|
|
1323 |
\isa{v\isactrlsub {\isadigit{1}}\ \mbox{$\preccurlyeq$}\ v\isactrlsub {\isadigit{2}}}.
|
|
1324 |
|
|
1325 |
\end{itemize}
|
|
1326 |
|
|
1327 |
\noindent The case for \isa{P{\isasymstar}} is similar to the \isa{PS}-case and omitted.\qed
|
|
1328 |
\end{proof}
|
|
1329 |
|
|
1330 |
\noindent This theorem shows that our \isa{POSIX} value for a
|
|
1331 |
regular expression \isa{r} and string \isa{s} is in fact a
|
|
1332 |
minimal element of the values in \isa{LV\ r\ s}. By
|
|
1333 |
Proposition~\ref{ordlen}\textit{(2)} we also know that any value in
|
|
1334 |
\isa{LV\ r\ s{\isacharprime}{\kern0pt}}, with \isa{s{\isacharprime}{\kern0pt}} being a strict prefix, cannot be
|
|
1335 |
smaller than \isa{v\isactrlsub {\isadigit{1}}}. The next theorem shows the
|
|
1336 |
opposite---namely any minimal element in \isa{LV\ r\ s} must be a
|
|
1337 |
\isa{POSIX} value. This can be established by induction on \isa{r}, but the proof can be drastically simplified by using the fact
|
|
1338 |
from the previous section about the existence of a \isa{POSIX} value
|
|
1339 |
whenever a string \isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}}.
|
|
1340 |
|
|
1341 |
|
|
1342 |
\begin{theorem}
|
|
1343 |
\isa{{\normalsize{}If\,}\ \mbox{v\isactrlsub {\isadigit{1}}\ {\isasymin}\ LV\ r\ s}\ {\normalsize \,and\,}\ \mbox{{\isasymforall}v\isactrlsub {\isadigit{2}}{\isasymin}LV\ r\ s{\isachardot}{\kern0pt}\ v\isactrlsub {\isadigit{2}}\ \mbox{$\not\prec$}\ v\isactrlsub {\isadigit{1}}}\ {\normalsize \,then\,}\ {\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub {\isadigit{1}}{\isachardot}{\kern0pt}}
|
|
1344 |
\end{theorem}
|
|
1345 |
|
|
1346 |
\begin{proof}
|
|
1347 |
If \isa{v\isactrlsub {\isadigit{1}}\ {\isasymin}\ LV\ r\ s} then
|
|
1348 |
\isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}} by Proposition~\ref{inhabs}. Hence by Theorem~\ref{lexercorrect}(2)
|
|
1349 |
there exists a
|
|
1350 |
\isa{POSIX} value \isa{v\isactrlsub P} with \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\isactrlsub P}
|
|
1351 |
and by Lemma~\ref{LVposix} we also have \mbox{\isa{v\isactrlsub P\ {\isasymin}\ LV\ r\ s}}.
|
|
1352 |
By Theorem~\ref{orderone} we therefore have
|
|
1353 |
\isa{v\isactrlsub P\ \mbox{$\preccurlyeq$}\ v\isactrlsub {\isadigit{1}}}. If \isa{v\isactrlsub P\ {\isacharequal}{\kern0pt}\ v\isactrlsub {\isadigit{1}}} then
|
|
1354 |
we are done. Otherwise we have \isa{v\isactrlsub P\ {\isasymprec}\ v\isactrlsub {\isadigit{1}}}, which
|
|
1355 |
however contradicts the second assumption about \isa{v\isactrlsub {\isadigit{1}}} being the smallest
|
|
1356 |
element in \isa{LV\ r\ s}. So we are done in this case too.\qed
|
|
1357 |
\end{proof}
|
|
1358 |
|
|
1359 |
\noindent
|
|
1360 |
From this we can also show
|
|
1361 |
that if \isa{LV\ r\ s} is non-empty (or equivalently \isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}}) then
|
|
1362 |
it has a unique minimal element:
|
|
1363 |
|
|
1364 |
\begin{corollary}
|
|
1365 |
\isa{{\normalsize{}If\,}\ LV\ r\ s\ {\isasymnoteq}\ {\isasymemptyset}\ {\normalsize \,then\,}\ {\isasymexists}{\isacharbang}{\kern0pt}vmin{\isachardot}{\kern0pt}\ vmin\ {\isasymin}\ LV\ r\ s\ {\isasymand}\ {\isacharparenleft}{\kern0pt}{\isasymforall}v{\isasymin}LV\ r\ s{\isachardot}{\kern0pt}\ vmin\ \mbox{$\preccurlyeq$}\ v{\isacharparenright}{\kern0pt}{\isachardot}{\kern0pt}}
|
|
1366 |
\end{corollary}
|
|
1367 |
|
|
1368 |
|
|
1369 |
|
|
1370 |
\noindent To sum up, we have shown that the (unique) minimal elements
|
|
1371 |
of the ordering by Okui and Suzuki are exactly the \isa{POSIX}
|
|
1372 |
values we defined inductively in Section~\ref{posixsec}. This provides
|
|
1373 |
an independent confirmation that our ternary relation formalises the
|
|
1374 |
informal POSIX rules.%
|
|
1375 |
\end{isamarkuptext}\isamarkuptrue%
|
|
1376 |
%
|
|
1377 |
\isadelimdocument
|
|
1378 |
%
|
|
1379 |
\endisadelimdocument
|
|
1380 |
%
|
|
1381 |
\isatagdocument
|
|
1382 |
%
|
|
1383 |
\isamarkupsection{Bitcoded Lexing%
|
|
1384 |
}
|
|
1385 |
\isamarkuptrue%
|
|
1386 |
%
|
|
1387 |
\endisatagdocument
|
|
1388 |
{\isafolddocument}%
|
|
1389 |
%
|
|
1390 |
\isadelimdocument
|
|
1391 |
%
|
|
1392 |
\endisadelimdocument
|
|
1393 |
%
|
|
1394 |
\begin{isamarkuptext}%
|
|
1395 |
Incremental calculation of the value. To simplify the proof we first define the function
|
|
1396 |
\isa{flex} which calculates the ``iterated'' injection function. With this we can
|
|
1397 |
rewrite the lexer as
|
|
1398 |
|
|
1399 |
\begin{center}
|
|
1400 |
\isa{lexer\ r\ s\ {\isacharequal}{\kern0pt}\ {\isacharparenleft}{\kern0pt}\textrm{if}\ nullable\ {\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}s{\isacharparenright}{\kern0pt}\ \textrm{then}\ Some\ {\isacharparenleft}{\kern0pt}flex\ r\ id\ s\ {\isacharparenleft}{\kern0pt}mkeps\ {\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}s{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ \textrm{else}\ None{\isacharparenright}{\kern0pt}}
|
|
1401 |
\end{center}%
|
|
1402 |
\end{isamarkuptext}\isamarkuptrue%
|
|
1403 |
%
|
|
1404 |
\isadelimdocument
|
|
1405 |
%
|
|
1406 |
\endisadelimdocument
|
|
1407 |
%
|
|
1408 |
\isatagdocument
|
|
1409 |
%
|
|
1410 |
\isamarkupsection{Optimisations%
|
|
1411 |
}
|
|
1412 |
\isamarkuptrue%
|
|
1413 |
%
|
|
1414 |
\endisatagdocument
|
|
1415 |
{\isafolddocument}%
|
|
1416 |
%
|
|
1417 |
\isadelimdocument
|
|
1418 |
%
|
|
1419 |
\endisadelimdocument
|
|
1420 |
%
|
|
1421 |
\begin{isamarkuptext}%
|
|
1422 |
Derivatives as calculated by \Brz's method are usually more complex
|
|
1423 |
regular expressions than the initial one; the result is that the
|
|
1424 |
derivative-based matching and lexing algorithms are often abysmally slow.
|
|
1425 |
However, various optimisations are possible, such as the simplifications
|
|
1426 |
of \isa{\isactrlbold {\isadigit{0}}\ {\isacharplus}{\kern0pt}\ r}, \isa{r\ {\isacharplus}{\kern0pt}\ \isactrlbold {\isadigit{0}}}, \isa{\isactrlbold {\isadigit{1}}\ {\isasymcdot}\ r} and
|
|
1427 |
\isa{r\ {\isasymcdot}\ \isactrlbold {\isadigit{1}}} to \isa{r}. These simplifications can speed up the
|
|
1428 |
algorithms considerably, as noted in \cite{Sulzmann2014}. One of the
|
|
1429 |
advantages of having a simple specification and correctness proof is that
|
|
1430 |
the latter can be refined to prove the correctness of such simplification
|
|
1431 |
steps. While the simplification of regular expressions according to
|
|
1432 |
rules like
|
|
1433 |
|
|
1434 |
\begin{equation}\label{Simpl}
|
|
1435 |
\begin{array}{lcllcllcllcl}
|
|
1436 |
\isa{\isactrlbold {\isadigit{0}}\ {\isacharplus}{\kern0pt}\ r} & \isa{{\isasymRightarrow}} & \isa{r} \hspace{8mm}%\\
|
|
1437 |
\isa{r\ {\isacharplus}{\kern0pt}\ \isactrlbold {\isadigit{0}}} & \isa{{\isasymRightarrow}} & \isa{r} \hspace{8mm}%\\
|
|
1438 |
\isa{\isactrlbold {\isadigit{1}}\ {\isasymcdot}\ r} & \isa{{\isasymRightarrow}} & \isa{r} \hspace{8mm}%\\
|
|
1439 |
\isa{r\ {\isasymcdot}\ \isactrlbold {\isadigit{1}}} & \isa{{\isasymRightarrow}} & \isa{r}
|
|
1440 |
\end{array}
|
|
1441 |
\end{equation}
|
|
1442 |
|
|
1443 |
\noindent is well understood, there is an obstacle with the POSIX value
|
|
1444 |
calculation algorithm by Sulzmann and Lu: if we build a derivative regular
|
|
1445 |
expression and then simplify it, we will calculate a POSIX value for this
|
|
1446 |
simplified derivative regular expression, \emph{not} for the original (unsimplified)
|
|
1447 |
derivative regular expression. Sulzmann and Lu \cite{Sulzmann2014} overcome this obstacle by
|
|
1448 |
not just calculating a simplified regular expression, but also calculating
|
|
1449 |
a \emph{rectification function} that ``repairs'' the incorrect value.
|
|
1450 |
|
|
1451 |
The rectification functions can be (slightly clumsily) implemented in
|
|
1452 |
Isabelle/HOL as follows using some auxiliary functions:
|
|
1453 |
|
|
1454 |
\begin{center}
|
|
1455 |
\begin{tabular}{lcl}
|
|
1456 |
\isa{F\isactrlbsub Right\isactrlesub \ f\ v} & $\dn$ & \isa{Right\ {\isacharparenleft}{\kern0pt}f\ v{\isacharparenright}{\kern0pt}}\\
|
|
1457 |
\isa{F\isactrlbsub Left\isactrlesub \ f\ v} & $\dn$ & \isa{Left\ {\isacharparenleft}{\kern0pt}f\ v{\isacharparenright}{\kern0pt}}\\
|
|
1458 |
|
|
1459 |
\isa{F\isactrlbsub Alt\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}\ {\isacharparenleft}{\kern0pt}Right\ v{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{Right\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{2}}\ v{\isacharparenright}{\kern0pt}}\\
|
|
1460 |
\isa{F\isactrlbsub Alt\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}\ {\isacharparenleft}{\kern0pt}Left\ v{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{Left\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{1}}\ v{\isacharparenright}{\kern0pt}}\\
|
|
1461 |
|
|
1462 |
\isa{F\isactrlbsub Seq{\isadigit{1}}\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}\ v} & $\dn$ & \isa{Seq\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{1}}\ {\isacharparenleft}{\kern0pt}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{2}}\ v{\isacharparenright}{\kern0pt}}\\
|
|
1463 |
\isa{F\isactrlbsub Seq{\isadigit{2}}\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}\ v} & $\dn$ & \isa{Seq\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{1}}\ v{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{2}}\ {\isacharparenleft}{\kern0pt}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}}\\
|
|
1464 |
\isa{F\isactrlbsub Seq\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}\ {\isacharparenleft}{\kern0pt}Seq\ v\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{Seq\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{2}}\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\medskip\\
|
|
1465 |
%\end{tabular}
|
|
1466 |
%
|
|
1467 |
%\begin{tabular}{lcl}
|
|
1468 |
\isa{simp\isactrlbsub Alt\isactrlesub \ {\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{0}}{\isacharcomma}{\kern0pt}\ \underline{\hspace{2mm}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ F\isactrlbsub Right\isactrlesub \ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
1469 |
\isa{simp\isactrlbsub Alt\isactrlesub \ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{0}}{\isacharcomma}{\kern0pt}\ \underline{\hspace{2mm}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ F\isactrlbsub Left\isactrlesub \ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}}\\
|
|
1470 |
\isa{simp\isactrlbsub Alt\isactrlesub \ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ F\isactrlbsub Alt\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
1471 |
\isa{simp\isactrlbsub Seq\isactrlesub \ {\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ F\isactrlbsub Seq{\isadigit{1}}\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
1472 |
\isa{simp\isactrlbsub Seq\isactrlesub \ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}\isactrlbold {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ F\isactrlbsub Seq{\isadigit{2}}\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
1473 |
\isa{simp\isactrlbsub Seq\isactrlesub \ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ F\isactrlbsub Seq\isactrlesub \ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
1474 |
\end{tabular}
|
|
1475 |
\end{center}
|
|
1476 |
|
|
1477 |
\noindent
|
|
1478 |
The functions \isa{simp\isactrlbsub Alt\isactrlesub } and \isa{simp\isactrlbsub Seq\isactrlesub } encode the simplification rules
|
|
1479 |
in \eqref{Simpl} and compose the rectification functions (simplifications can occur
|
|
1480 |
deep inside the regular expression). The main simplification function is then
|
|
1481 |
|
|
1482 |
\begin{center}
|
|
1483 |
\begin{tabular}{lcl}
|
|
1484 |
\isa{simp\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{simp\isactrlbsub Alt\isactrlesub \ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
1485 |
\isa{simp\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} & $\dn$ & \isa{simp\isactrlbsub Seq\isactrlesub \ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}}\\
|
|
1486 |
\isa{simp\ r} & $\dn$ & \isa{{\isacharparenleft}{\kern0pt}r{\isacharcomma}{\kern0pt}\ id{\isacharparenright}{\kern0pt}}\\
|
|
1487 |
\end{tabular}
|
|
1488 |
\end{center}
|
|
1489 |
|
|
1490 |
\noindent where \isa{id} stands for the identity function. The
|
|
1491 |
function \isa{simp} returns a simplified regular expression and a corresponding
|
|
1492 |
rectification function. Note that we do not simplify under stars: this
|
|
1493 |
seems to slow down the algorithm, rather than speed it up. The optimised
|
|
1494 |
lexer is then given by the clauses:
|
|
1495 |
|
|
1496 |
\begin{center}
|
|
1497 |
\begin{tabular}{lcl}
|
|
1498 |
\isa{lexer\isactrlsup {\isacharplus}{\kern0pt}\ r\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} & $\dn$ & \isa{\textrm{if}\ nullable\ r\ \textrm{then}\ Some\ {\isacharparenleft}{\kern0pt}mkeps\ r{\isacharparenright}{\kern0pt}\ \textrm{else}\ None}\\
|
|
1499 |
\isa{lexer\isactrlsup {\isacharplus}{\kern0pt}\ r\ {\isacharparenleft}{\kern0pt}c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s{\isacharparenright}{\kern0pt}} & $\dn$ &
|
|
1500 |
\isa{let\ {\isacharparenleft}{\kern0pt}r\isactrlsub s{\isacharcomma}{\kern0pt}\ f\isactrlsub r{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ simp\ {\isacharparenleft}{\kern0pt}r}$\backslash$\isa{c{\isacharparenright}{\kern0pt}\ in}\\
|
|
1501 |
& & \isa{case} \isa{lexer\isactrlsup {\isacharplus}{\kern0pt}\ r\isactrlsub s\ s} \isa{of}\\
|
|
1502 |
& & \phantom{$|$} \isa{None} \isa{{\isasymRightarrow}} \isa{None}\\
|
|
1503 |
& & $|$ \isa{Some\ v} \isa{{\isasymRightarrow}} \isa{Some\ {\isacharparenleft}{\kern0pt}inj\ r\ c\ {\isacharparenleft}{\kern0pt}f\isactrlsub r\ v{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}}
|
|
1504 |
\end{tabular}
|
|
1505 |
\end{center}
|
|
1506 |
|
|
1507 |
\noindent
|
|
1508 |
In the second clause we first calculate the derivative \isa{r{\isacharbackslash}{\kern0pt}c}
|
|
1509 |
and then simpli
|
|
1510 |
|
|
1511 |
text \isa{\ \ Incremental\ calculation\ of\ the\ value{\isachardot}{\kern0pt}\ To\ simplify\ the\ proof\ we\ first\ define\ the\ function\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}const\ flex{\isacharbraceright}{\kern0pt}\ which\ calculates\ the\ {\isacharbackquote}{\kern0pt}{\isacharbackquote}{\kern0pt}iterated{\isacharprime}{\kern0pt}{\isacharprime}{\kern0pt}\ injection\ function{\isachardot}{\kern0pt}\ With\ this\ we\ can\ rewrite\ the\ lexer\ as\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ lexer{\isacharunderscore}{\kern0pt}flex{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ {\isachardoublequote}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ {\isachardoublequote}{\kern0pt}v\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}v\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{7}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ code{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{7}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ areg{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}{\isacharequal}{\kern0pt}{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}AZERO{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}mid{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}AONE\ bs{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}mid{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}ACHAR\ bs\ c{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}mid{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}AALT\ bs\ r{\isadigit{1}}\ r{\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}mid{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}ASEQ\ bs\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}mid{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}ASTAR\ bs\ r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ intern{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ erase{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ Some\ simple\ facts\ about\ erase\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}lemma{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}mbox{\isacharbraceleft}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ erase{\isacharunderscore}{\kern0pt}bder{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ erase{\isacharunderscore}{\kern0pt}intern{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}lemma{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bnullable{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}medskip{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ \ {\isacharpercent}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharpercent}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ {\isacharpercent}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharpercent}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ \ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{5}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bder{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{6}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bmkeps{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bmkeps{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bmkeps{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bmkeps{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bmkeps{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bmkeps{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{3}}{\isacharparenright}{\kern0pt}{\isacharbrackleft}{\kern0pt}of\ bs\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}\ {\isachardoublequote}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ bmkeps{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ bmkeps{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{4}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}medskip{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ \ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharbrackleft}{\kern0pt}mode{\isacharequal}{\kern0pt}IfThen{\isacharbrackright}{\kern0pt}\ bder{\isacharunderscore}{\kern0pt}retrieve{\isacharbraceright}{\kern0pt}\ \ By\ induction\ on\ {\isasymopen}r{\isasymclose}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}theorem{\isacharbraceright}{\kern0pt}{\isacharbrackleft}{\kern0pt}Main\ Lemma{\isacharbrackright}{\kern0pt}{\isacharbackslash}{\kern0pt}mbox{\isacharbraceleft}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharbrackleft}{\kern0pt}mode{\isacharequal}{\kern0pt}IfThen{\isacharbrackright}{\kern0pt}\ MAIN{\isacharunderscore}{\kern0pt}decode{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}theorem{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}noindent\ Definition\ of\ the\ bitcoded\ lexer\ \ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ blexer{\isacharunderscore}{\kern0pt}def{\isacharbraceright}{\kern0pt}\ \ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}theorem{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ blexer{\isacharunderscore}{\kern0pt}correctness{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}theorem{\isacharbraceright}{\kern0pt}\ \ }
|
|
1512 |
|
|
1513 |
section \isa{Optimisations}
|
|
1514 |
|
|
1515 |
text \isa{\ \ Derivatives\ as\ calculated\ by\ {\isacharbackslash}{\kern0pt}Brz{\isacharprime}{\kern0pt}s\ method\ are\ usually\ more\ complex\ regular\ expressions\ than\ the\ initial\ one{\isacharsemicolon}{\kern0pt}\ the\ result\ is\ that\ the\ derivative{\isacharminus}{\kern0pt}based\ matching\ and\ lexing\ algorithms\ are\ often\ abysmally\ slow{\isachardot}{\kern0pt}\ However{\isacharcomma}{\kern0pt}\ various\ optimisations\ are\ possible{\isacharcomma}{\kern0pt}\ such\ as\ the\ simplifications\ of\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}ALT\ ZERO\ r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharcomma}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}ALT\ r\ ZERO{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharcomma}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}SEQ\ ONE\ r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ and\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}SEQ\ r\ ONE{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ to\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ r{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ These\ simplifications\ can\ speed\ up\ the\ algorithms\ considerably{\isacharcomma}{\kern0pt}\ as\ noted\ in\ {\isacharbackslash}{\kern0pt}cite{\isacharbraceleft}{\kern0pt}Sulzmann{\isadigit{2}}{\isadigit{0}}{\isadigit{1}}{\isadigit{4}}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ One\ of\ the\ advantages\ of\ having\ a\ simple\ specification\ and\ correctness\ proof\ is\ that\ the\ latter\ can\ be\ refined\ to\ prove\ the\ correctness\ of\ such\ simplification\ steps{\isachardot}{\kern0pt}\ While\ the\ simplification\ of\ regular\ expressions\ according\ to\ rules\ like\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}equation{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}label{\isacharbraceleft}{\kern0pt}Simpl{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}array{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcllcllcllcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}ALT\ ZERO\ r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}{\isasymRightarrow}{\isasymclose}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ r{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}hspace{\isacharbraceleft}{\kern0pt}{\isadigit{8}}mm{\isacharbraceright}{\kern0pt}{\isacharpercent}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}ALT\ r\ ZERO{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}{\isasymRightarrow}{\isasymclose}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ r{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}hspace{\isacharbraceleft}{\kern0pt}{\isadigit{8}}mm{\isacharbraceright}{\kern0pt}{\isacharpercent}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}SEQ\ ONE\ r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ \ {\isacharampersand}{\kern0pt}\ {\isasymopen}{\isasymRightarrow}{\isasymclose}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ r{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}hspace{\isacharbraceleft}{\kern0pt}{\isadigit{8}}mm{\isacharbraceright}{\kern0pt}{\isacharpercent}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}SEQ\ r\ ONE{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ \ {\isacharampersand}{\kern0pt}\ {\isasymopen}{\isasymRightarrow}{\isasymclose}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ r{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}array{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}equation{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}noindent\ is\ well\ understood{\isacharcomma}{\kern0pt}\ there\ is\ an\ obstacle\ with\ the\ POSIX\ value\ calculation\ algorithm\ by\ Sulzmann\ and\ Lu{\isacharcolon}{\kern0pt}\ if\ we\ build\ a\ derivative\ regular\ expression\ and\ then\ simplify\ it{\isacharcomma}{\kern0pt}\ we\ will\ calculate\ a\ POSIX\ value\ for\ this\ simplified\ derivative\ regular\ expression{\isacharcomma}{\kern0pt}\ {\isacharbackslash}{\kern0pt}emph{\isacharbraceleft}{\kern0pt}not{\isacharbraceright}{\kern0pt}\ for\ the\ original\ {\isacharparenleft}{\kern0pt}unsimplified{\isacharparenright}{\kern0pt}\ derivative\ regular\ expression{\isachardot}{\kern0pt}\ Sulzmann\ and\ Lu\ {\isacharbackslash}{\kern0pt}cite{\isacharbraceleft}{\kern0pt}Sulzmann{\isadigit{2}}{\isadigit{0}}{\isadigit{1}}{\isadigit{4}}{\isacharbraceright}{\kern0pt}\ overcome\ this\ obstacle\ by\ not\ just\ calculating\ a\ simplified\ regular\ expression{\isacharcomma}{\kern0pt}\ but\ also\ calculating\ a\ {\isacharbackslash}{\kern0pt}emph{\isacharbraceleft}{\kern0pt}rectification\ function{\isacharbraceright}{\kern0pt}\ that\ {\isacharbackquote}{\kern0pt}{\isacharbackquote}{\kern0pt}repairs{\isacharprime}{\kern0pt}{\isacharprime}{\kern0pt}\ the\ incorrect\ value{\isachardot}{\kern0pt}\ \ The\ rectification\ functions\ can\ be\ {\isacharparenleft}{\kern0pt}slightly\ clumsily{\isacharparenright}{\kern0pt}\ implemented\ \ in\ Isabelle{\isacharslash}{\kern0pt}HOL\ as\ follows\ using\ some\ auxiliary\ functions{\isacharcolon}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}RIGHT{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}Right\ {\isacharparenleft}{\kern0pt}f\ v{\isacharparenright}{\kern0pt}{\isasymclose}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}LEFT{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}Left\ {\isacharparenleft}{\kern0pt}f\ v{\isacharparenright}{\kern0pt}{\isasymclose}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ \ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}ALT{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}Right\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{2}}\ v{\isacharparenright}{\kern0pt}{\isasymclose}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}ALT{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}Left\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{1}}\ v{\isacharparenright}{\kern0pt}{\isasymclose}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ \ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}SEQ{\isadigit{1}}{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}Seq\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{1}}\ {\isacharparenleft}{\kern0pt}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{2}}\ v{\isacharparenright}{\kern0pt}{\isasymclose}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}SEQ{\isadigit{2}}{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}Seq\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{1}}\ v{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{2}}\ {\isacharparenleft}{\kern0pt}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isasymclose}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}SEQ{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}Seq\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{1}}\ v\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}f\isactrlsub {\isadigit{2}}\ v\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isasymclose}{\isacharbackslash}{\kern0pt}medskip{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharpercent}{\kern0pt}{\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharpercent}{\kern0pt}\ {\isacharpercent}{\kern0pt}{\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp{\isacharunderscore}{\kern0pt}ALT\ {\isacharparenleft}{\kern0pt}ZERO{\isacharcomma}{\kern0pt}\ DUMMY{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}RIGHT\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp{\isacharunderscore}{\kern0pt}ALT\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}ZERO{\isacharcomma}{\kern0pt}\ DUMMY{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}LEFT\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp{\isacharunderscore}{\kern0pt}ALT\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}{\isacharparenleft}{\kern0pt}ALT\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}ALT\ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp{\isacharunderscore}{\kern0pt}SEQ\ {\isacharparenleft}{\kern0pt}ONE{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}SEQ{\isadigit{1}}\ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp{\isacharunderscore}{\kern0pt}SEQ\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}ONE{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}SEQ{\isadigit{2}}\ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp{\isacharunderscore}{\kern0pt}SEQ\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}{\isacharparenleft}{\kern0pt}SEQ\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isacharcomma}{\kern0pt}\ F{\isacharunderscore}{\kern0pt}SEQ\ f\isactrlsub {\isadigit{1}}\ f\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}noindent\ The\ functions\ {\isasymopen}simp\isactrlbsub Alt\isactrlesub {\isasymclose}\ and\ {\isasymopen}simp\isactrlbsub Seq\isactrlesub {\isasymclose}\ encode\ the\ simplification\ rules\ in\ {\isacharbackslash}{\kern0pt}eqref{\isacharbraceleft}{\kern0pt}Simpl{\isacharbraceright}{\kern0pt}\ and\ compose\ the\ rectification\ functions\ {\isacharparenleft}{\kern0pt}simplifications\ can\ occur\ deep\ inside\ the\ regular\ expression{\isacharparenright}{\kern0pt}{\isachardot}{\kern0pt}\ The\ main\ simplification\ function\ is\ then\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}ALT\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp{\isacharunderscore}{\kern0pt}ALT\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}SEQ\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp{\isacharunderscore}{\kern0pt}SEQ\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}simp\ r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}{\isacharparenleft}{\kern0pt}r{\isacharcomma}{\kern0pt}\ id{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}noindent\ where\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}id{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ stands\ for\ the\ identity\ function{\isachardot}{\kern0pt}\ The\ function\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}const\ simp{\isacharbraceright}{\kern0pt}\ returns\ a\ simplified\ regular\ expression\ and\ a\ corresponding\ rectification\ function{\isachardot}{\kern0pt}\ Note\ that\ we\ do\ not\ simplify\ under\ stars{\isacharcolon}{\kern0pt}\ this\ seems\ to\ slow\ down\ the\ algorithm{\isacharcomma}{\kern0pt}\ rather\ than\ speed\ it\ up{\isachardot}{\kern0pt}\ The\ optimised\ lexer\ is\ then\ given\ by\ the\ clauses{\isacharcolon}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}lcl{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ slexer{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}rhs{\isacharparenright}{\kern0pt}\ slexer{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ {\isacharparenleft}{\kern0pt}lhs{\isacharparenright}{\kern0pt}\ slexer{\isachardot}{\kern0pt}simps{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}dn{\isachardollar}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}let\ {\isacharparenleft}{\kern0pt}r\isactrlsub s{\isacharcomma}{\kern0pt}\ f\isactrlsub r{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ simp\ {\isacharparenleft}{\kern0pt}r\ {\isasymclose}{\isachardollar}{\kern0pt}{\isacharbackslash}{\kern0pt}backslash{\isachardollar}{\kern0pt}{\isasymopen}\ c{\isacharparenright}{\kern0pt}\ in{\isasymclose}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isasymopen}case{\isasymclose}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}slexer\ r\isactrlsub s\ s{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isasymopen}of{\isasymclose}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharbackslash}{\kern0pt}phantom{\isacharbraceleft}{\kern0pt}{\isachardollar}{\kern0pt}{\isacharbar}{\kern0pt}{\isachardollar}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}None{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ \ {\isasymopen}{\isasymRightarrow}{\isasymclose}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ None{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isachardollar}{\kern0pt}{\isacharbar}{\kern0pt}{\isachardollar}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}Some\ v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ {\isasymopen}{\isasymRightarrow}{\isasymclose}\ {\isasymopen}Some\ {\isacharparenleft}{\kern0pt}inj\ r\ c\ {\isacharparenleft}{\kern0pt}f\isactrlsub r\ v{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isasymclose}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}center{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}noindent\ In\ the\ second\ clause\ we\ first\ calculate\ the\ derivative\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}der\ c\ r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ and\ then\ simplify\ the\ result{\isachardot}{\kern0pt}\ This\ gives\ us\ a\ simplified\ derivative\ {\isasymopen}r\isactrlsub s{\isasymclose}\ and\ a\ rectification\ function\ {\isasymopen}f\isactrlsub r{\isasymclose}{\isachardot}{\kern0pt}\ The\ lexer\ is\ then\ recursively\ called\ with\ the\ simplified\ derivative{\isacharcomma}{\kern0pt}\ but\ before\ we\ inject\ the\ character\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ c{\isacharbraceright}{\kern0pt}\ into\ the\ value\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ v{\isacharbraceright}{\kern0pt}{\isacharcomma}{\kern0pt}\ we\ need\ to\ rectify\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ v{\isacharbraceright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}that\ is\ construct\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}f\isactrlsub r\ v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isachardot}{\kern0pt}\ Before\ we\ can\ establish\ the\ correctness\ of\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}slexer{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharcomma}{\kern0pt}\ we\ need\ to\ show\ that\ simplification\ preserves\ the\ language\ and\ simplification\ preserves\ our\ POSIX\ relation\ once\ the\ value\ is\ rectified\ {\isacharparenleft}{\kern0pt}recall\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}const\ {\isachardoublequote}{\kern0pt}simp{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ generates\ a\ {\isacharparenleft}{\kern0pt}regular\ expression{\isacharcomma}{\kern0pt}\ rectification\ function{\isacharparenright}{\kern0pt}\ pair{\isacharparenright}{\kern0pt}{\isacharcolon}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}lemma{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}mbox{\isacharbraceleft}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}smallskip{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}label{\isacharbraceleft}{\kern0pt}slexeraux{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}{\isacharbraceleft}{\kern0pt}ll{\isacharbraceright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ L{\isacharunderscore}{\kern0pt}fst{\isacharunderscore}{\kern0pt}simp{\isacharbrackleft}{\kern0pt}symmetric{\isacharbrackright}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharbackslash}{\kern0pt}{\isacharbackslash}{\kern0pt}\ {\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isacharampersand}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm{\isacharbrackleft}{\kern0pt}mode{\isacharequal}{\kern0pt}IfThen{\isacharbrackright}{\kern0pt}\ Posix{\isacharunderscore}{\kern0pt}simp{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}tabular{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}lemma{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}proof{\isacharbraceright}{\kern0pt}\ Both\ are\ by\ induction\ on\ {\isasymopen}r{\isasymclose}{\isachardot}{\kern0pt}\ There\ is\ no\ interesting\ case\ for\ the\ first\ statement{\isachardot}{\kern0pt}\ For\ the\ second\ statement{\isacharcomma}{\kern0pt}\ of\ interest\ are\ the\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}r\ {\isacharequal}{\kern0pt}\ ALT\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ and\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}r\ {\isacharequal}{\kern0pt}\ SEQ\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ cases{\isachardot}{\kern0pt}\ In\ each\ case\ we\ have\ to\ analyse\ four\ subcases\ whether\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ and\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ equals\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}const\ ZERO{\isacharbraceright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}respectively\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}const\ ONE{\isacharbraceright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isachardot}{\kern0pt}\ For\ example\ for\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}r\ {\isacharequal}{\kern0pt}\ ALT\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharcomma}{\kern0pt}\ consider\ the\ subcase\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ ZERO{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ and\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymnoteq}\ ZERO{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ By\ assumption\ we\ know\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ fst\ {\isacharparenleft}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}ALT\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ From\ this\ we\ can\ infer\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ and\ by\ IH\ also\ {\isacharparenleft}{\kern0pt}{\isacharasterisk}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ r\isactrlsub {\isadigit{2}}\ {\isasymrightarrow}\ {\isacharparenleft}{\kern0pt}snd\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ v{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ Given\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ ZERO{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ we\ know\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}L\ {\isacharparenleft}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isacharbraceleft}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ By\ the\ first\ statement\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}L\ r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ is\ the\ empty\ set{\isacharcomma}{\kern0pt}\ meaning\ {\isacharparenleft}{\kern0pt}{\isacharasterisk}{\kern0pt}{\isacharasterisk}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymnotin}\ L\ r\isactrlsub {\isadigit{1}}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ Taking\ {\isacharparenleft}{\kern0pt}{\isacharasterisk}{\kern0pt}{\isacharparenright}{\kern0pt}\ and\ {\isacharparenleft}{\kern0pt}{\isacharasterisk}{\kern0pt}{\isacharasterisk}{\kern0pt}{\isacharparenright}{\kern0pt}\ together\ gives\ by\ the\ {\isacharbackslash}{\kern0pt}mbox{\isacharbraceleft}{\kern0pt}{\isasymopen}P{\isacharplus}{\kern0pt}R{\isasymclose}{\isacharbraceright}{\kern0pt}{\isacharminus}{\kern0pt}rule\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ ALT\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}\ {\isasymrightarrow}\ Right\ {\isacharparenleft}{\kern0pt}snd\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ v{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ In\ turn\ this\ gives\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ ALT\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}\ {\isasymrightarrow}\ snd\ {\isacharparenleft}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}ALT\ r\isactrlsub {\isadigit{1}}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ as\ we\ need\ to\ show{\isachardot}{\kern0pt}\ The\ other\ cases\ are\ similar{\isachardot}{\kern0pt}{\isacharbackslash}{\kern0pt}qed\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}proof{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}noindent\ We\ can\ now\ prove\ relatively\ straightforwardly\ that\ the\ optimised\ lexer\ produces\ the\ expected\ result{\isacharcolon}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}theorem{\isacharbraceright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}thm\ slexer{\isacharunderscore}{\kern0pt}correctness{\isacharbraceright}{\kern0pt}\ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}theorem{\isacharbraceright}{\kern0pt}\ \ {\isacharbackslash}{\kern0pt}begin{\isacharbraceleft}{\kern0pt}proof{\isacharbraceright}{\kern0pt}\ By\ induction\ on\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ s{\isacharbraceright}{\kern0pt}\ generalising\ over\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ r{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ The\ case\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ is\ trivial{\isachardot}{\kern0pt}\ For\ the\ cons{\isacharminus}{\kern0pt}case\ suppose\ the\ string\ is\ of\ the\ form\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}c\ {\isacharhash}{\kern0pt}\ s{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ By\ induction\ hypothesis\ we\ know\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}slexer\ r\ s\ {\isacharequal}{\kern0pt}\ lexer\ r\ s{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ holds\ for\ all\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ r{\isacharbraceright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}in\ particular\ for\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ being\ the\ derivative\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}der\ c\ r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isachardot}{\kern0pt}\ Let\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}r\isactrlsub s{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ be\ the\ simplified\ derivative\ regular\ expression{\isacharcomma}{\kern0pt}\ that\ is\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}der\ c\ r{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharcomma}{\kern0pt}\ and\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}f\isactrlsub r{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ be\ the\ rectification\ function{\isacharcomma}{\kern0pt}\ that\ is\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}snd\ {\isacharparenleft}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}der\ c\ r{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ \ We\ distinguish\ the\ cases\ whether\ {\isacharparenleft}{\kern0pt}{\isacharasterisk}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ L\ {\isacharparenleft}{\kern0pt}der\ c\ r{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ or\ not{\isachardot}{\kern0pt}\ In\ the\ first\ case\ we\ have\ by\ Theorem{\isachartilde}{\kern0pt}{\isacharbackslash}{\kern0pt}ref{\isacharbraceleft}{\kern0pt}lexercorrect{\isacharbraceright}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}\ a\ value\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ so\ that\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}lexer\ {\isacharparenleft}{\kern0pt}der\ c\ r{\isacharparenright}{\kern0pt}\ s\ {\isacharequal}{\kern0pt}\ Some\ v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ and\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ der\ c\ r\ {\isasymrightarrow}\ v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ hold{\isachardot}{\kern0pt}\ By\ Lemma{\isachartilde}{\kern0pt}{\isacharbackslash}{\kern0pt}ref{\isacharbraceleft}{\kern0pt}slexeraux{\isacharbraceright}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}\ we\ can\ also\ infer\ from{\isachartilde}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isacharasterisk}{\kern0pt}{\isacharparenright}{\kern0pt}\ that\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ L\ r\isactrlsub s{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ holds{\isachardot}{\kern0pt}\ \ Hence\ we\ know\ by\ Theorem{\isachartilde}{\kern0pt}{\isacharbackslash}{\kern0pt}ref{\isacharbraceleft}{\kern0pt}lexercorrect{\isacharbraceright}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}\ that\ there\ exists\ a\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}v{\isacharprime}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ with\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}lexer\ r\isactrlsub s\ s\ {\isacharequal}{\kern0pt}\ Some\ v{\isacharprime}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ and\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ r\isactrlsub s\ {\isasymrightarrow}\ v{\isacharprime}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ From\ the\ latter\ we\ know\ by\ Lemma{\isachartilde}{\kern0pt}{\isacharbackslash}{\kern0pt}ref{\isacharbraceleft}{\kern0pt}slexeraux{\isacharbraceright}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isadigit{2}}{\isacharparenright}{\kern0pt}\ that\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymin}\ der\ c\ r\ {\isasymrightarrow}\ {\isacharparenleft}{\kern0pt}f\isactrlsub r\ v{\isacharprime}{\kern0pt}{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ holds{\isachardot}{\kern0pt}\ By\ the\ uniqueness\ of\ the\ POSIX\ relation\ {\isacharparenleft}{\kern0pt}Theorem{\isachartilde}{\kern0pt}{\isacharbackslash}{\kern0pt}ref{\isacharbraceleft}{\kern0pt}posixdeterm{\isacharbraceright}{\kern0pt}{\isacharparenright}{\kern0pt}\ we\ can\ infer\ that\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ v{\isacharbraceright}{\kern0pt}\ is\ equal\ to\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}f\isactrlsub r\ v{\isacharprime}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isacharminus}{\kern0pt}{\isacharminus}{\kern0pt}{\isacharminus}{\kern0pt}that\ is\ the\ rectification\ function\ applied\ to\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}v{\isacharprime}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ produces\ the\ original\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}v{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ \ Now\ the\ case\ follows\ by\ the\ definitions\ of\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}const\ lexer{\isacharbraceright}{\kern0pt}\ and\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}const\ slexer{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ \ In\ the\ second\ case\ where\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymnotin}\ L\ {\isacharparenleft}{\kern0pt}der\ c\ r{\isacharparenright}{\kern0pt}{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ we\ have\ that\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}lexer\ {\isacharparenleft}{\kern0pt}der\ c\ r{\isacharparenright}{\kern0pt}\ s\ {\isacharequal}{\kern0pt}\ None{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ by\ Theorem{\isachartilde}{\kern0pt}{\isacharbackslash}{\kern0pt}ref{\isacharbraceleft}{\kern0pt}lexercorrect{\isacharbraceright}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}{\isachardot}{\kern0pt}\ \ We\ also\ know\ by\ Lemma{\isachartilde}{\kern0pt}{\isacharbackslash}{\kern0pt}ref{\isacharbraceleft}{\kern0pt}slexeraux{\isacharbraceright}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}\ that\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}s\ {\isasymnotin}\ L\ r\isactrlsub s{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ Hence\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}lexer\ r\isactrlsub s\ s\ {\isacharequal}{\kern0pt}\ None{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}\ by\ Theorem{\isachartilde}{\kern0pt}{\isacharbackslash}{\kern0pt}ref{\isacharbraceleft}{\kern0pt}lexercorrect{\isacharbraceright}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isadigit{1}}{\isacharparenright}{\kern0pt}\ and\ by\ IH\ then\ also\ {\isacharat}{\kern0pt}{\isacharbraceleft}{\kern0pt}term\ {\isachardoublequote}{\kern0pt}slexer\ r\isactrlsub s\ s\ {\isacharequal}{\kern0pt}\ None{\isachardoublequote}{\kern0pt}{\isacharbraceright}{\kern0pt}{\isachardot}{\kern0pt}\ With\ this\ we\ can\ conclude\ in\ this\ case\ too{\isachardot}{\kern0pt}{\isacharbackslash}{\kern0pt}qed\ \ {\isacharbackslash}{\kern0pt}end{\isacharbraceleft}{\kern0pt}proof{\isacharbraceright}{\kern0pt}\ \ }
|
|
1516 |
fy the result. This gives us a simplified derivative
|
|
1517 |
\isa{r\isactrlsub s} and a rectification function \isa{f\isactrlsub r}. The lexer
|
|
1518 |
is then recursively called with the simplified derivative, but before
|
|
1519 |
we inject the character \isa{c} into the value \isa{v}, we need to rectify
|
|
1520 |
\isa{v} (that is construct \isa{f\isactrlsub r\ v}). Before we can establish the correctness
|
|
1521 |
of \isa{lexer\isactrlsup {\isacharplus}{\kern0pt}}, we need to show that simplification preserves the language
|
|
1522 |
and simplification preserves our POSIX relation once the value is rectified
|
|
1523 |
(recall \isa{simp} generates a (regular expression, rectification function) pair):
|
|
1524 |
|
|
1525 |
\begin{lemma}\mbox{}\smallskip\\\label{slexeraux}
|
|
1526 |
\begin{tabular}{ll}
|
|
1527 |
(1) & \isa{L{\isacharparenleft}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ r{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ L{\isacharparenleft}{\kern0pt}r{\isacharparenright}{\kern0pt}}\\
|
|
1528 |
(2) & \isa{{\normalsize{}If\,}\ {\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ fst\ {\isacharparenleft}{\kern0pt}simp\ r{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v\ {\normalsize \,then\,}\ {\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ snd\ {\isacharparenleft}{\kern0pt}simp\ r{\isacharparenright}{\kern0pt}\ v{\isachardot}{\kern0pt}}
|
|
1529 |
\end{tabular}
|
|
1530 |
\end{lemma}
|
|
1531 |
|
|
1532 |
\begin{proof} Both are by induction on \isa{r}. There is no
|
|
1533 |
interesting case for the first statement. For the second statement,
|
|
1534 |
of interest are the \isa{r\ {\isacharequal}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}} and \isa{r\ {\isacharequal}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isasymcdot}\ r\isactrlsub {\isadigit{2}}} cases. In each case we have to analyse four subcases whether
|
|
1535 |
\isa{fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}} and \isa{fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}} equals \isa{\isactrlbold {\isadigit{0}}} (respectively \isa{\isactrlbold {\isadigit{1}}}). For example for \isa{r\ {\isacharequal}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}}, consider the subcase \isa{fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ \isactrlbold {\isadigit{0}}} and
|
|
1536 |
\isa{fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymnoteq}\ \isactrlbold {\isadigit{0}}}. By assumption we know \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ fst\ {\isacharparenleft}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}. From this we can infer \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v}
|
|
1537 |
and by IH also (*) \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ snd\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ v}. Given \isa{fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ \isactrlbold {\isadigit{0}}}
|
|
1538 |
we know \isa{L{\isacharparenleft}{\kern0pt}fst\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharequal}{\kern0pt}\ {\isasymemptyset}}. By the first statement
|
|
1539 |
\isa{L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}} is the empty set, meaning (**) \isa{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}{\isacharparenright}{\kern0pt}}.
|
|
1540 |
Taking (*) and (**) together gives by the \mbox{\isa{P{\isacharplus}{\kern0pt}R}}-rule
|
|
1541 |
\isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ Right\ {\isacharparenleft}{\kern0pt}snd\ {\isacharparenleft}{\kern0pt}simp\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ v{\isacharparenright}{\kern0pt}}. In turn this
|
|
1542 |
gives \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ snd\ {\isacharparenleft}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\ {\isacharplus}{\kern0pt}\ r\isactrlsub {\isadigit{2}}{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ v} as we need to show.
|
|
1543 |
The other cases are similar.\qed
|
|
1544 |
\end{proof}
|
|
1545 |
|
|
1546 |
\noindent We can now prove relatively straightforwardly that the
|
|
1547 |
optimised lexer produces the expected result:
|
|
1548 |
|
|
1549 |
\begin{theorem}
|
|
1550 |
\isa{lexer\isactrlsup {\isacharplus}{\kern0pt}\ r\ s\ {\isacharequal}{\kern0pt}\ lexer\ r\ s}
|
|
1551 |
\end{theorem}
|
|
1552 |
|
|
1553 |
\begin{proof} By induction on \isa{s} generalising over \isa{r}. The case \isa{{\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}} is trivial. For the cons-case suppose the
|
|
1554 |
string is of the form \isa{c\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}s}. By induction hypothesis we
|
|
1555 |
know \isa{lexer\isactrlsup {\isacharplus}{\kern0pt}\ r\ s\ {\isacharequal}{\kern0pt}\ lexer\ r\ s} holds for all \isa{r} (in
|
|
1556 |
particular for \isa{r} being the derivative \isa{r{\isacharbackslash}{\kern0pt}c}). Let \isa{r\isactrlsub s} be the simplified derivative regular expression, that is \isa{fst\ {\isacharparenleft}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}}, and \isa{f\isactrlsub r} be the rectification
|
|
1557 |
function, that is \isa{snd\ {\isacharparenleft}{\kern0pt}simp\ {\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}}. We distinguish the cases
|
|
1558 |
whether (*) \isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}} or not. In the first case we
|
|
1559 |
have by Theorem~\ref{lexercorrect}(2) a value \isa{v} so that \isa{lexer\ {\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ s\ {\isacharequal}{\kern0pt}\ Some\ v} and \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v} hold.
|
|
1560 |
By Lemma~\ref{slexeraux}(1) we can also infer from~(*) that \isa{s\ {\isasymin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub s{\isacharparenright}{\kern0pt}} holds. Hence we know by Theorem~\ref{lexercorrect}(2) that
|
|
1561 |
there exists a \isa{v{\isacharprime}{\kern0pt}} with \isa{lexer\ r\isactrlsub s\ s\ {\isacharequal}{\kern0pt}\ Some\ v{\isacharprime}{\kern0pt}} and
|
|
1562 |
\isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r\isactrlsub s{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ v{\isacharprime}{\kern0pt}}. From the latter we know by
|
|
1563 |
Lemma~\ref{slexeraux}(2) that \isa{{\isacharparenleft}{\kern0pt}s{\isacharcomma}{\kern0pt}\ r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymrightarrow}\ f\isactrlsub r\ v{\isacharprime}{\kern0pt}} holds.
|
|
1564 |
By the uniqueness of the POSIX relation (Theorem~\ref{posixdeterm}) we
|
|
1565 |
can infer that \isa{v} is equal to \isa{f\isactrlsub r\ v{\isacharprime}{\kern0pt}}---that is the
|
|
1566 |
rectification function applied to \isa{v{\isacharprime}{\kern0pt}}
|
|
1567 |
produces the original \isa{v}. Now the case follows by the
|
|
1568 |
definitions of \isa{lexer} and \isa{lexer\isactrlsup {\isacharplus}{\kern0pt}}.
|
|
1569 |
|
|
1570 |
In the second case where \isa{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}} we have that
|
|
1571 |
\isa{lexer\ {\isacharparenleft}{\kern0pt}r{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ s\ {\isacharequal}{\kern0pt}\ None} by Theorem~\ref{lexercorrect}(1). We
|
|
1572 |
also know by Lemma~\ref{slexeraux}(1) that \isa{s\ {\isasymnotin}\ L{\isacharparenleft}{\kern0pt}r\isactrlsub s{\isacharparenright}{\kern0pt}}. Hence
|
|
1573 |
\isa{lexer\ r\isactrlsub s\ s\ {\isacharequal}{\kern0pt}\ None} by Theorem~\ref{lexercorrect}(1) and
|
|
1574 |
by IH then also \isa{lexer\isactrlsup {\isacharplus}{\kern0pt}\ r\isactrlsub s\ s\ {\isacharequal}{\kern0pt}\ None}. With this we can
|
|
1575 |
conclude in this case too.\qed
|
|
1576 |
|
|
1577 |
\end{proof}%
|
|
1578 |
\end{isamarkuptext}\isamarkuptrue%
|
|
1579 |
%
|
|
1580 |
\isadelimdocument
|
|
1581 |
%
|
|
1582 |
\endisadelimdocument
|
|
1583 |
%
|
|
1584 |
\isatagdocument
|
|
1585 |
%
|
|
1586 |
\isamarkupsection{HERE%
|
|
1587 |
}
|
|
1588 |
\isamarkuptrue%
|
|
1589 |
%
|
|
1590 |
\endisatagdocument
|
|
1591 |
{\isafolddocument}%
|
|
1592 |
%
|
|
1593 |
\isadelimdocument
|
|
1594 |
%
|
|
1595 |
\endisadelimdocument
|
|
1596 |
%
|
|
1597 |
\begin{isamarkuptext}%
|
|
1598 |
\begin{lemma}
|
|
1599 |
\isa{{\normalsize{}If\,}\ v\ {\isacharcolon}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c\ {\normalsize \,then\,}\ retrieve\ {\isacharparenleft}{\kern0pt}r\mbox{$\bbslash$}c{\isacharparenright}{\kern0pt}\ v\ {\isacharequal}{\kern0pt}\ retrieve\ r\ {\isacharparenleft}{\kern0pt}inj\ {\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}\ c\ v{\isacharparenright}{\kern0pt}{\isachardot}{\kern0pt}}
|
|
1600 |
\end{lemma}
|
|
1601 |
|
|
1602 |
\begin{proof}
|
|
1603 |
By induction on the definition of \isa{r\mbox{$^\downarrow$}}. The cases for rule 1) and 2) are
|
|
1604 |
straightforward as \isa{\isactrlbold {\isadigit{0}}{\isacharbackslash}{\kern0pt}c} and \isa{\isactrlbold {\isadigit{1}}{\isacharbackslash}{\kern0pt}c} are both equal to
|
|
1605 |
\isa{\isactrlbold {\isadigit{0}}}. This means \isa{v\ {\isacharcolon}{\kern0pt}\ \isactrlbold {\isadigit{0}}} cannot hold. Similarly in case of rule 3)
|
|
1606 |
where \isa{r} is of the form \isa{ACHAR\ d} with \isa{c\ {\isacharequal}{\kern0pt}\ d}. Then by assumption
|
|
1607 |
we know \isa{v\ {\isacharcolon}{\kern0pt}\ \isactrlbold {\isadigit{1}}}, which implies \isa{v\ {\isacharequal}{\kern0pt}\ Empty}. The equation follows by
|
|
1608 |
simplification of left- and right-hand side. In case \isa{c\ {\isasymnoteq}\ d} we have again
|
|
1609 |
\isa{v\ {\isacharcolon}{\kern0pt}\ \isactrlbold {\isadigit{0}}}, which cannot hold.
|
|
1610 |
|
|
1611 |
For rule 4a) we have again \isa{v\ {\isacharcolon}{\kern0pt}\ \isactrlbold {\isadigit{0}}}. The property holds by IH for rule 4b).
|
|
1612 |
The induction hypothesis is
|
|
1613 |
\[
|
|
1614 |
\isa{retrieve\ {\isacharparenleft}{\kern0pt}r\mbox{$\bbslash$}c{\isacharparenright}{\kern0pt}\ v\ {\isacharequal}{\kern0pt}\ retrieve\ r\ {\isacharparenleft}{\kern0pt}inj\ {\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}\ c\ v{\isacharparenright}{\kern0pt}}
|
|
1615 |
\]
|
|
1616 |
which is what left- and right-hand side simplify to. The slightly more interesting case
|
|
1617 |
is for 4c). By assumption we have
|
|
1618 |
\isa{v\ {\isacharcolon}{\kern0pt}\ {\isacharparenleft}{\kern0pt}{\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isacharplus}{\kern0pt}\ {\isacharparenleft}{\kern0pt}{\isacharparenleft}{\kern0pt}{\isacharparenleft}{\kern0pt}AALTs\ bs\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}rs{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}}. This means we
|
|
1619 |
have either (*) \isa{v{\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{1}}\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c} with \isa{v\ {\isacharequal}{\kern0pt}\ Left\ v{\isadigit{1}}} or
|
|
1620 |
(**) \isa{v{\isadigit{2}}\ {\isacharcolon}{\kern0pt}\ {\isacharparenleft}{\kern0pt}{\isacharparenleft}{\kern0pt}AALTs\ bs\ {\isacharparenleft}{\kern0pt}r\isactrlsub {\isadigit{2}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}rs{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c} with \isa{v\ {\isacharequal}{\kern0pt}\ Right\ v{\isadigit{2}}}.
|
|
1621 |
The former case is straightforward by simplification. The second case is \ldots TBD.
|
|
1622 |
|
|
1623 |
Rule 5) TBD.
|
|
1624 |
|
|
1625 |
Finally for rule 6) the reasoning is as follows: By assumption we have
|
|
1626 |
\isa{v\ {\isacharcolon}{\kern0pt}\ {\isacharparenleft}{\kern0pt}{\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c{\isacharparenright}{\kern0pt}\ {\isasymcdot}\ {\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}\isactrlsup {\isasymstar}}. This means we also have
|
|
1627 |
\isa{v\ {\isacharequal}{\kern0pt}\ Seq\ v{\isadigit{1}}\ v{\isadigit{2}}}, \isa{v{\isadigit{1}}\ {\isacharcolon}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}{\isacharbackslash}{\kern0pt}c} and \isa{v{\isadigit{2}}\ {\isacharequal}{\kern0pt}\ Stars\ vs}.
|
|
1628 |
We want to prove
|
|
1629 |
\begin{align}
|
|
1630 |
& \isa{retrieve\ {\isacharparenleft}{\kern0pt}ASEQ\ bs\ {\isacharparenleft}{\kern0pt}fuse\ {\isacharbrackleft}{\kern0pt}Z{\isacharbrackright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\mbox{$\bbslash$}c{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}ASTAR\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ r{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ v}\\
|
|
1631 |
&= \isa{retrieve\ {\isacharparenleft}{\kern0pt}ASTAR\ bs\ r{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}inj\ {\isacharparenleft}{\kern0pt}{\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}\isactrlsup {\isasymstar}{\isacharparenright}{\kern0pt}\ c\ v{\isacharparenright}{\kern0pt}}
|
|
1632 |
\end{align}
|
|
1633 |
The right-hand side \isa{inj}-expression is equal to
|
|
1634 |
\isa{Stars\ {\isacharparenleft}{\kern0pt}inj\ {\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}\ c\ v{\isadigit{1}}\mbox{$\,$}{\isacharcolon}{\kern0pt}{\isacharcolon}{\kern0pt}\mbox{$\,$}vs{\isacharparenright}{\kern0pt}}, which means the \isa{retrieve}-expression
|
|
1635 |
simplifies to
|
|
1636 |
\[
|
|
1637 |
\isa{bs\ {\isacharat}{\kern0pt}\ {\isacharbrackleft}{\kern0pt}Z{\isacharbrackright}{\kern0pt}\ {\isacharat}{\kern0pt}\ retrieve\ r\ {\isacharparenleft}{\kern0pt}inj\ {\isacharparenleft}{\kern0pt}r\mbox{$^\downarrow$}{\isacharparenright}{\kern0pt}\ c\ v{\isadigit{1}}{\isacharparenright}{\kern0pt}\ {\isacharat}{\kern0pt}\ retrieve\ {\isacharparenleft}{\kern0pt}ASTAR\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}Stars\ vs{\isacharparenright}{\kern0pt}}
|
|
1638 |
\]
|
|
1639 |
The left-hand side (3) above simplifies to
|
|
1640 |
\[
|
|
1641 |
\isa{bs\ {\isacharat}{\kern0pt}\ retrieve\ {\isacharparenleft}{\kern0pt}fuse\ {\isacharbrackleft}{\kern0pt}Z{\isacharbrackright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}r\mbox{$\bbslash$}c{\isacharparenright}{\kern0pt}{\isacharparenright}{\kern0pt}\ v{\isadigit{1}}\ {\isacharat}{\kern0pt}\ retrieve\ {\isacharparenleft}{\kern0pt}ASTAR\ {\isacharbrackleft}{\kern0pt}{\isacharbrackright}{\kern0pt}\ r{\isacharparenright}{\kern0pt}\ {\isacharparenleft}{\kern0pt}Stars\ vs{\isacharparenright}{\kern0pt}}
|
|
1642 |
\]
|
|
1643 |
We can move out the \isa{fuse\ {\isacharbrackleft}{\kern0pt}Z{\isacharbrackright}{\kern0pt}} and then use the IH to show that left-hand side
|
|
1644 |
and right-hand side are equal. This completes the proof.
|
|
1645 |
\end{proof}
|
|
1646 |
|
|
1647 |
|
|
1648 |
|
|
1649 |
\bibliographystyle{plain}
|
|
1650 |
\bibliography{root}%
|
|
1651 |
\end{isamarkuptext}\isamarkuptrue%
|
|
1652 |
%
|
|
1653 |
\isadelimtheory
|
|
1654 |
%
|
|
1655 |
\endisadelimtheory
|
|
1656 |
%
|
|
1657 |
\isatagtheory
|
|
1658 |
%
|
|
1659 |
\endisatagtheory
|
|
1660 |
{\isafoldtheory}%
|
|
1661 |
%
|
|
1662 |
\isadelimtheory
|
|
1663 |
\isanewline
|
|
1664 |
%
|
|
1665 |
\endisadelimtheory
|
|
1666 |
%
|
|
1667 |
\end{isabellebody}%
|
|
1668 |
\endinput
|
|
1669 |
%:%file=~/Dropbox/Workspace/journalpaper/lexing/thys2/Journal/Paper.thy%:%
|
371
|
1670 |
%:%50=134%:%
|
|
1671 |
%:%62=136%:%
|
|
1672 |
%:%63=137%:%
|
|
1673 |
%:%64=138%:%
|
|
1674 |
%:%65=139%:%
|
|
1675 |
%:%66=140%:%
|
|
1676 |
%:%67=141%:%
|
|
1677 |
%:%68=142%:%
|
|
1678 |
%:%69=143%:%
|
|
1679 |
%:%70=144%:%
|
|
1680 |
%:%71=145%:%
|
|
1681 |
%:%72=146%:%
|
|
1682 |
%:%73=147%:%
|
|
1683 |
%:%74=148%:%
|
|
1684 |
%:%75=149%:%
|
|
1685 |
%:%76=150%:%
|
|
1686 |
%:%77=151%:%
|
|
1687 |
%:%78=152%:%
|
|
1688 |
%:%79=153%:%
|
|
1689 |
%:%80=154%:%
|
|
1690 |
%:%81=155%:%
|
|
1691 |
%:%82=156%:%
|
|
1692 |
%:%83=157%:%
|
|
1693 |
%:%84=158%:%
|
|
1694 |
%:%85=159%:%
|
|
1695 |
%:%86=160%:%
|
|
1696 |
%:%87=161%:%
|
|
1697 |
%:%88=162%:%
|
|
1698 |
%:%89=163%:%
|
|
1699 |
%:%90=164%:%
|
|
1700 |
%:%91=165%:%
|
|
1701 |
%:%92=166%:%
|
|
1702 |
%:%93=167%:%
|
|
1703 |
%:%94=168%:%
|
|
1704 |
%:%95=169%:%
|
|
1705 |
%:%96=170%:%
|
|
1706 |
%:%97=171%:%
|
|
1707 |
%:%98=172%:%
|
|
1708 |
%:%99=173%:%
|
|
1709 |
%:%100=174%:%
|
|
1710 |
%:%101=175%:%
|
|
1711 |
%:%102=176%:%
|
|
1712 |
%:%103=177%:%
|
|
1713 |
%:%104=178%:%
|
|
1714 |
%:%105=179%:%
|
|
1715 |
%:%106=180%:%
|
|
1716 |
%:%107=181%:%
|
|
1717 |
%:%108=182%:%
|
|
1718 |
%:%109=183%:%
|
|
1719 |
%:%110=184%:%
|
|
1720 |
%:%111=185%:%
|
|
1721 |
%:%112=186%:%
|
|
1722 |
%:%113=187%:%
|
|
1723 |
%:%114=188%:%
|
|
1724 |
%:%115=189%:%
|
|
1725 |
%:%116=190%:%
|
|
1726 |
%:%117=191%:%
|
|
1727 |
%:%118=192%:%
|
|
1728 |
%:%119=193%:%
|
|
1729 |
%:%120=194%:%
|
|
1730 |
%:%121=195%:%
|
|
1731 |
%:%122=196%:%
|
|
1732 |
%:%123=197%:%
|
|
1733 |
%:%124=198%:%
|
|
1734 |
%:%125=199%:%
|
|
1735 |
%:%126=200%:%
|
|
1736 |
%:%127=201%:%
|
|
1737 |
%:%128=202%:%
|
|
1738 |
%:%129=203%:%
|
|
1739 |
%:%130=204%:%
|
|
1740 |
%:%131=205%:%
|
|
1741 |
%:%132=206%:%
|
|
1742 |
%:%133=207%:%
|
|
1743 |
%:%134=208%:%
|
|
1744 |
%:%135=209%:%
|
|
1745 |
%:%136=210%:%
|
|
1746 |
%:%137=211%:%
|
|
1747 |
%:%138=212%:%
|
|
1748 |
%:%147=217%:%
|
|
1749 |
%:%159=223%:%
|
|
1750 |
%:%160=224%:%
|
|
1751 |
%:%161=225%:%
|
|
1752 |
%:%162=226%:%
|
|
1753 |
%:%162=227%:%
|
|
1754 |
%:%163=228%:%
|
|
1755 |
%:%164=229%:%
|
|
1756 |
%:%165=230%:%
|
|
1757 |
%:%166=231%:%
|
|
1758 |
%:%167=232%:%
|
|
1759 |
%:%168=233%:%
|
|
1760 |
%:%169=234%:%
|
|
1761 |
%:%170=235%:%
|
|
1762 |
%:%171=236%:%
|
|
1763 |
%:%172=237%:%
|
|
1764 |
%:%173=238%:%
|
|
1765 |
%:%174=239%:%
|
|
1766 |
%:%175=240%:%
|
|
1767 |
%:%176=241%:%
|
|
1768 |
%:%177=242%:%
|
|
1769 |
%:%178=243%:%
|
|
1770 |
%:%179=244%:%
|
|
1771 |
%:%180=245%:%
|
|
1772 |
%:%181=246%:%
|
|
1773 |
%:%182=247%:%
|
|
1774 |
%:%183=248%:%
|
|
1775 |
%:%184=249%:%
|
|
1776 |
%:%185=250%:%
|
|
1777 |
%:%186=251%:%
|
|
1778 |
%:%187=252%:%
|
|
1779 |
%:%188=253%:%
|
|
1780 |
%:%189=254%:%
|
|
1781 |
%:%190=255%:%
|
|
1782 |
%:%191=256%:%
|
|
1783 |
%:%192=257%:%
|
|
1784 |
%:%193=258%:%
|
|
1785 |
%:%194=259%:%
|
|
1786 |
%:%195=260%:%
|
|
1787 |
%:%196=261%:%
|
|
1788 |
%:%197=262%:%
|
|
1789 |
%:%198=263%:%
|
|
1790 |
%:%199=264%:%
|
|
1791 |
%:%200=265%:%
|
|
1792 |
%:%201=266%:%
|
|
1793 |
%:%202=267%:%
|
|
1794 |
%:%203=268%:%
|
|
1795 |
%:%204=269%:%
|
|
1796 |
%:%205=270%:%
|
|
1797 |
%:%206=271%:%
|
|
1798 |
%:%207=272%:%
|
|
1799 |
%:%208=273%:%
|
|
1800 |
%:%209=274%:%
|
|
1801 |
%:%210=275%:%
|
|
1802 |
%:%211=276%:%
|
|
1803 |
%:%212=277%:%
|
|
1804 |
%:%213=278%:%
|
|
1805 |
%:%214=279%:%
|
|
1806 |
%:%215=280%:%
|
|
1807 |
%:%216=281%:%
|
|
1808 |
%:%217=282%:%
|
|
1809 |
%:%218=283%:%
|
|
1810 |
%:%219=284%:%
|
|
1811 |
%:%220=285%:%
|
|
1812 |
%:%221=286%:%
|
|
1813 |
%:%222=287%:%
|
|
1814 |
%:%223=288%:%
|
|
1815 |
%:%224=289%:%
|
|
1816 |
%:%225=290%:%
|
|
1817 |
%:%226=291%:%
|
|
1818 |
%:%226=292%:%
|
|
1819 |
%:%227=293%:%
|
|
1820 |
%:%228=294%:%
|
|
1821 |
%:%229=295%:%
|
|
1822 |
%:%230=296%:%
|
|
1823 |
%:%231=297%:%
|
|
1824 |
%:%232=298%:%
|
|
1825 |
%:%233=299%:%
|
|
1826 |
%:%234=300%:%
|
|
1827 |
%:%235=301%:%
|
|
1828 |
%:%236=302%:%
|
|
1829 |
%:%237=303%:%
|
|
1830 |
%:%238=304%:%
|
|
1831 |
%:%239=305%:%
|
|
1832 |
%:%240=306%:%
|
|
1833 |
%:%241=307%:%
|
|
1834 |
%:%242=308%:%
|
|
1835 |
%:%243=309%:%
|
|
1836 |
%:%244=310%:%
|
|
1837 |
%:%245=311%:%
|
|
1838 |
%:%246=312%:%
|
|
1839 |
%:%247=313%:%
|
|
1840 |
%:%248=314%:%
|
|
1841 |
%:%249=315%:%
|
|
1842 |
%:%250=316%:%
|
|
1843 |
%:%251=317%:%
|
|
1844 |
%:%252=318%:%
|
|
1845 |
%:%253=319%:%
|
|
1846 |
%:%254=320%:%
|
|
1847 |
%:%255=321%:%
|
|
1848 |
%:%256=322%:%
|
|
1849 |
%:%257=323%:%
|
|
1850 |
%:%258=324%:%
|
|
1851 |
%:%259=325%:%
|
|
1852 |
%:%260=326%:%
|
|
1853 |
%:%261=327%:%
|
|
1854 |
%:%262=328%:%
|
|
1855 |
%:%263=329%:%
|
|
1856 |
%:%264=330%:%
|
|
1857 |
%:%265=331%:%
|
|
1858 |
%:%266=332%:%
|
|
1859 |
%:%267=333%:%
|
|
1860 |
%:%268=334%:%
|
|
1861 |
%:%269=335%:%
|
|
1862 |
%:%270=336%:%
|
369
|
1863 |
%:%271=337%:%
|
|
1864 |
%:%272=338%:%
|
371
|
1865 |
%:%273=339%:%
|
|
1866 |
%:%274=340%:%
|
|
1867 |
%:%275=341%:%
|
|
1868 |
%:%276=342%:%
|
|
1869 |
%:%277=343%:%
|
|
1870 |
%:%278=344%:%
|
|
1871 |
%:%279=345%:%
|
|
1872 |
%:%280=346%:%
|
|
1873 |
%:%281=347%:%
|
|
1874 |
%:%282=348%:%
|
|
1875 |
%:%283=349%:%
|
|
1876 |
%:%284=350%:%
|
|
1877 |
%:%285=351%:%
|
|
1878 |
%:%286=352%:%
|
|
1879 |
%:%287=353%:%
|
|
1880 |
%:%288=354%:%
|
|
1881 |
%:%289=355%:%
|
|
1882 |
%:%290=356%:%
|
|
1883 |
%:%291=357%:%
|
|
1884 |
%:%292=358%:%
|
|
1885 |
%:%293=359%:%
|
|
1886 |
%:%294=360%:%
|
|
1887 |
%:%295=361%:%
|
|
1888 |
%:%296=362%:%
|
|
1889 |
%:%297=363%:%
|
|
1890 |
%:%298=364%:%
|
|
1891 |
%:%299=365%:%
|
|
1892 |
%:%300=366%:%
|
|
1893 |
%:%301=367%:%
|
|
1894 |
%:%302=368%:%
|
|
1895 |
%:%303=369%:%
|
|
1896 |
%:%304=370%:%
|
|
1897 |
%:%305=371%:%
|
|
1898 |
%:%306=372%:%
|
|
1899 |
%:%307=373%:%
|
|
1900 |
%:%308=374%:%
|
|
1901 |
%:%309=375%:%
|
|
1902 |
%:%310=376%:%
|
|
1903 |
%:%311=377%:%
|
|
1904 |
%:%312=378%:%
|
|
1905 |
%:%313=379%:%
|
|
1906 |
%:%314=380%:%
|
|
1907 |
%:%315=381%:%
|
|
1908 |
%:%316=382%:%
|
|
1909 |
%:%317=383%:%
|
|
1910 |
%:%318=384%:%
|
|
1911 |
%:%319=385%:%
|
|
1912 |
%:%320=386%:%
|
|
1913 |
%:%321=387%:%
|
|
1914 |
%:%322=388%:%
|
|
1915 |
%:%323=389%:%
|
|
1916 |
%:%324=390%:%
|
|
1917 |
%:%325=391%:%
|
|
1918 |
%:%326=392%:%
|
|
1919 |
%:%327=393%:%
|
|
1920 |
%:%328=394%:%
|
|
1921 |
%:%329=395%:%
|
|
1922 |
%:%330=396%:%
|
|
1923 |
%:%331=397%:%
|
|
1924 |
%:%340=404%:%
|
|
1925 |
%:%352=406%:%
|
|
1926 |
%:%353=407%:%
|
|
1927 |
%:%353=408%:%
|
|
1928 |
%:%354=409%:%
|
|
1929 |
%:%355=410%:%
|
|
1930 |
%:%356=411%:%
|
|
1931 |
%:%357=412%:%
|
|
1932 |
%:%358=413%:%
|
|
1933 |
%:%359=414%:%
|
|
1934 |
%:%360=415%:%
|
|
1935 |
%:%361=416%:%
|
|
1936 |
%:%362=417%:%
|
|
1937 |
%:%363=418%:%
|
|
1938 |
%:%364=419%:%
|
|
1939 |
%:%365=420%:%
|
|
1940 |
%:%366=421%:%
|
|
1941 |
%:%367=422%:%
|
|
1942 |
%:%368=423%:%
|
|
1943 |
%:%369=424%:%
|
|
1944 |
%:%370=425%:%
|
|
1945 |
%:%371=426%:%
|
|
1946 |
%:%372=427%:%
|
|
1947 |
%:%373=428%:%
|
|
1948 |
%:%374=429%:%
|
|
1949 |
%:%375=430%:%
|
|
1950 |
%:%376=431%:%
|
|
1951 |
%:%377=432%:%
|
|
1952 |
%:%378=433%:%
|
|
1953 |
%:%379=434%:%
|
|
1954 |
%:%380=435%:%
|
|
1955 |
%:%381=436%:%
|
|
1956 |
%:%382=437%:%
|
|
1957 |
%:%383=438%:%
|
|
1958 |
%:%384=439%:%
|
|
1959 |
%:%385=440%:%
|
|
1960 |
%:%386=441%:%
|
|
1961 |
%:%387=442%:%
|
|
1962 |
%:%388=443%:%
|
|
1963 |
%:%389=444%:%
|
|
1964 |
%:%390=445%:%
|
|
1965 |
%:%391=446%:%
|
|
1966 |
%:%392=447%:%
|
|
1967 |
%:%392=448%:%
|
|
1968 |
%:%393=449%:%
|
|
1969 |
%:%394=450%:%
|
|
1970 |
%:%395=451%:%
|
|
1971 |
%:%396=452%:%
|
|
1972 |
%:%397=453%:%
|
|
1973 |
%:%397=454%:%
|
|
1974 |
%:%398=455%:%
|
|
1975 |
%:%399=456%:%
|
|
1976 |
%:%400=457%:%
|
|
1977 |
%:%401=458%:%
|
|
1978 |
%:%402=459%:%
|
|
1979 |
%:%403=460%:%
|
|
1980 |
%:%404=461%:%
|
|
1981 |
%:%405=462%:%
|
|
1982 |
%:%406=463%:%
|
|
1983 |
%:%407=464%:%
|
|
1984 |
%:%408=465%:%
|
|
1985 |
%:%409=466%:%
|
|
1986 |
%:%410=467%:%
|
|
1987 |
%:%411=468%:%
|
|
1988 |
%:%412=469%:%
|
|
1989 |
%:%413=470%:%
|
|
1990 |
%:%414=471%:%
|
|
1991 |
%:%415=472%:%
|
|
1992 |
%:%416=473%:%
|
|
1993 |
%:%417=474%:%
|
|
1994 |
%:%418=475%:%
|
|
1995 |
%:%419=476%:%
|
|
1996 |
%:%420=477%:%
|
|
1997 |
%:%421=478%:%
|
|
1998 |
%:%422=479%:%
|
|
1999 |
%:%423=480%:%
|
|
2000 |
%:%424=481%:%
|
|
2001 |
%:%425=482%:%
|
|
2002 |
%:%426=483%:%
|
|
2003 |
%:%427=484%:%
|
|
2004 |
%:%428=485%:%
|
|
2005 |
%:%429=486%:%
|
|
2006 |
%:%430=487%:%
|
|
2007 |
%:%431=488%:%
|
|
2008 |
%:%432=489%:%
|
|
2009 |
%:%433=490%:%
|
|
2010 |
%:%434=491%:%
|
|
2011 |
%:%435=492%:%
|
|
2012 |
%:%436=493%:%
|
|
2013 |
%:%437=494%:%
|
|
2014 |
%:%438=495%:%
|
|
2015 |
%:%439=496%:%
|
|
2016 |
%:%440=497%:%
|
|
2017 |
%:%441=498%:%
|
|
2018 |
%:%442=499%:%
|
|
2019 |
%:%443=500%:%
|
|
2020 |
%:%444=501%:%
|
|
2021 |
%:%445=502%:%
|
|
2022 |
%:%446=503%:%
|
|
2023 |
%:%447=504%:%
|
|
2024 |
%:%448=505%:%
|
|
2025 |
%:%449=506%:%
|
|
2026 |
%:%450=507%:%
|
|
2027 |
%:%451=508%:%
|
|
2028 |
%:%452=509%:%
|
|
2029 |
%:%453=510%:%
|
|
2030 |
%:%454=511%:%
|
|
2031 |
%:%455=512%:%
|
|
2032 |
%:%456=513%:%
|
|
2033 |
%:%457=514%:%
|
|
2034 |
%:%458=515%:%
|
|
2035 |
%:%459=516%:%
|
|
2036 |
%:%460=517%:%
|
|
2037 |
%:%461=518%:%
|
|
2038 |
%:%462=519%:%
|
|
2039 |
%:%463=520%:%
|
|
2040 |
%:%464=521%:%
|
|
2041 |
%:%465=522%:%
|
|
2042 |
%:%466=523%:%
|
|
2043 |
%:%467=524%:%
|
|
2044 |
%:%468=525%:%
|
|
2045 |
%:%469=526%:%
|
|
2046 |
%:%470=527%:%
|
|
2047 |
%:%471=528%:%
|
|
2048 |
%:%472=529%:%
|
|
2049 |
%:%473=530%:%
|
|
2050 |
%:%474=531%:%
|
|
2051 |
%:%475=532%:%
|
|
2052 |
%:%476=533%:%
|
|
2053 |
%:%477=534%:%
|
|
2054 |
%:%478=535%:%
|
|
2055 |
%:%479=536%:%
|
|
2056 |
%:%480=537%:%
|
|
2057 |
%:%481=538%:%
|
|
2058 |
%:%482=539%:%
|
|
2059 |
%:%483=540%:%
|
|
2060 |
%:%484=541%:%
|
|
2061 |
%:%485=542%:%
|
|
2062 |
%:%486=543%:%
|
|
2063 |
%:%495=547%:%
|
|
2064 |
%:%507=551%:%
|
|
2065 |
%:%508=552%:%
|
|
2066 |
%:%509=553%:%
|
|
2067 |
%:%510=554%:%
|
|
2068 |
%:%511=555%:%
|
|
2069 |
%:%512=556%:%
|
|
2070 |
%:%513=557%:%
|
|
2071 |
%:%514=558%:%
|
|
2072 |
%:%515=559%:%
|
|
2073 |
%:%516=560%:%
|
|
2074 |
%:%517=561%:%
|
|
2075 |
%:%518=562%:%
|
|
2076 |
%:%519=563%:%
|
|
2077 |
%:%520=564%:%
|
|
2078 |
%:%521=565%:%
|
|
2079 |
%:%522=566%:%
|
|
2080 |
%:%523=567%:%
|
|
2081 |
%:%524=568%:%
|
|
2082 |
%:%525=569%:%
|
|
2083 |
%:%526=570%:%
|
|
2084 |
%:%527=571%:%
|
|
2085 |
%:%528=572%:%
|
|
2086 |
%:%529=573%:%
|
|
2087 |
%:%530=574%:%
|
|
2088 |
%:%531=575%:%
|
|
2089 |
%:%532=576%:%
|
|
2090 |
%:%533=577%:%
|
|
2091 |
%:%534=578%:%
|
|
2092 |
%:%535=579%:%
|
|
2093 |
%:%536=580%:%
|
|
2094 |
%:%537=581%:%
|
|
2095 |
%:%538=582%:%
|
|
2096 |
%:%539=583%:%
|
|
2097 |
%:%540=584%:%
|
|
2098 |
%:%541=585%:%
|
|
2099 |
%:%542=586%:%
|
|
2100 |
%:%543=587%:%
|
|
2101 |
%:%544=588%:%
|
|
2102 |
%:%545=589%:%
|
|
2103 |
%:%546=590%:%
|
|
2104 |
%:%547=591%:%
|
|
2105 |
%:%548=592%:%
|
|
2106 |
%:%549=593%:%
|
|
2107 |
%:%550=594%:%
|
|
2108 |
%:%551=595%:%
|
|
2109 |
%:%552=596%:%
|
|
2110 |
%:%553=597%:%
|
|
2111 |
%:%554=598%:%
|
|
2112 |
%:%555=599%:%
|
|
2113 |
%:%556=600%:%
|
|
2114 |
%:%557=601%:%
|
|
2115 |
%:%558=602%:%
|
|
2116 |
%:%559=603%:%
|
|
2117 |
%:%560=604%:%
|
|
2118 |
%:%561=605%:%
|
|
2119 |
%:%562=606%:%
|
|
2120 |
%:%563=607%:%
|
|
2121 |
%:%564=608%:%
|
|
2122 |
%:%565=609%:%
|
|
2123 |
%:%566=610%:%
|
|
2124 |
%:%567=611%:%
|
|
2125 |
%:%568=612%:%
|
|
2126 |
%:%569=613%:%
|
|
2127 |
%:%570=614%:%
|
|
2128 |
%:%571=615%:%
|
|
2129 |
%:%572=616%:%
|
|
2130 |
%:%573=617%:%
|
|
2131 |
%:%574=618%:%
|
|
2132 |
%:%575=619%:%
|
|
2133 |
%:%576=620%:%
|
|
2134 |
%:%577=621%:%
|
|
2135 |
%:%578=622%:%
|
|
2136 |
%:%579=623%:%
|
|
2137 |
%:%580=624%:%
|
|
2138 |
%:%581=625%:%
|
|
2139 |
%:%582=626%:%
|
|
2140 |
%:%583=627%:%
|
|
2141 |
%:%584=628%:%
|
|
2142 |
%:%585=629%:%
|
|
2143 |
%:%586=630%:%
|
|
2144 |
%:%587=631%:%
|
|
2145 |
%:%588=632%:%
|
|
2146 |
%:%589=633%:%
|
|
2147 |
%:%590=634%:%
|
|
2148 |
%:%591=635%:%
|
|
2149 |
%:%592=636%:%
|
|
2150 |
%:%593=637%:%
|
|
2151 |
%:%594=638%:%
|
|
2152 |
%:%595=639%:%
|
|
2153 |
%:%596=640%:%
|
|
2154 |
%:%597=641%:%
|
|
2155 |
%:%598=642%:%
|
|
2156 |
%:%599=643%:%
|
|
2157 |
%:%600=644%:%
|
|
2158 |
%:%601=645%:%
|
|
2159 |
%:%602=646%:%
|
|
2160 |
%:%603=647%:%
|
|
2161 |
%:%604=648%:%
|
|
2162 |
%:%605=649%:%
|
|
2163 |
%:%606=650%:%
|
|
2164 |
%:%607=651%:%
|
|
2165 |
%:%608=652%:%
|
|
2166 |
%:%609=653%:%
|
|
2167 |
%:%610=654%:%
|
|
2168 |
%:%611=655%:%
|
|
2169 |
%:%612=656%:%
|
|
2170 |
%:%613=657%:%
|
|
2171 |
%:%614=658%:%
|
|
2172 |
%:%615=659%:%
|
|
2173 |
%:%616=660%:%
|
|
2174 |
%:%617=661%:%
|
|
2175 |
%:%618=662%:%
|
|
2176 |
%:%619=663%:%
|
|
2177 |
%:%620=664%:%
|
|
2178 |
%:%621=665%:%
|
|
2179 |
%:%621=666%:%
|
|
2180 |
%:%622=667%:%
|
|
2181 |
%:%622=668%:%
|
|
2182 |
%:%623=669%:%
|
|
2183 |
%:%624=670%:%
|
|
2184 |
%:%624=671%:%
|
|
2185 |
%:%625=672%:%
|
|
2186 |
%:%626=673%:%
|
|
2187 |
%:%627=674%:%
|
|
2188 |
%:%628=675%:%
|
|
2189 |
%:%629=676%:%
|
|
2190 |
%:%630=677%:%
|
|
2191 |
%:%631=678%:%
|
|
2192 |
%:%632=679%:%
|
|
2193 |
%:%633=680%:%
|
|
2194 |
%:%634=681%:%
|
|
2195 |
%:%635=682%:%
|
|
2196 |
%:%636=683%:%
|
|
2197 |
%:%637=684%:%
|
|
2198 |
%:%638=685%:%
|
|
2199 |
%:%639=686%:%
|
|
2200 |
%:%640=687%:%
|
|
2201 |
%:%641=688%:%
|
|
2202 |
%:%642=689%:%
|
|
2203 |
%:%643=690%:%
|
|
2204 |
%:%644=691%:%
|
|
2205 |
%:%645=692%:%
|
|
2206 |
%:%646=693%:%
|
|
2207 |
%:%647=694%:%
|
|
2208 |
%:%648=695%:%
|
|
2209 |
%:%649=696%:%
|
|
2210 |
%:%650=697%:%
|
|
2211 |
%:%651=698%:%
|
|
2212 |
%:%652=699%:%
|
|
2213 |
%:%653=700%:%
|
|
2214 |
%:%654=701%:%
|
|
2215 |
%:%655=702%:%
|
|
2216 |
%:%656=703%:%
|
|
2217 |
%:%657=704%:%
|
|
2218 |
%:%658=705%:%
|
|
2219 |
%:%659=706%:%
|
|
2220 |
%:%660=707%:%
|
|
2221 |
%:%661=708%:%
|
|
2222 |
%:%662=709%:%
|
|
2223 |
%:%663=710%:%
|
|
2224 |
%:%664=711%:%
|
|
2225 |
%:%665=712%:%
|
|
2226 |
%:%666=713%:%
|
|
2227 |
%:%667=714%:%
|
|
2228 |
%:%668=715%:%
|
|
2229 |
%:%669=716%:%
|
|
2230 |
%:%670=717%:%
|
|
2231 |
%:%671=718%:%
|
|
2232 |
%:%672=719%:%
|
|
2233 |
%:%673=720%:%
|
|
2234 |
%:%674=721%:%
|
|
2235 |
%:%675=722%:%
|
|
2236 |
%:%676=723%:%
|
|
2237 |
%:%677=724%:%
|
|
2238 |
%:%678=725%:%
|
|
2239 |
%:%679=726%:%
|
|
2240 |
%:%680=727%:%
|
|
2241 |
%:%680=728%:%
|
|
2242 |
%:%680=729%:%
|
|
2243 |
%:%681=730%:%
|
|
2244 |
%:%682=731%:%
|
|
2245 |
%:%683=732%:%
|
|
2246 |
%:%684=733%:%
|
|
2247 |
%:%685=734%:%
|
|
2248 |
%:%686=735%:%
|
|
2249 |
%:%687=736%:%
|
|
2250 |
%:%688=737%:%
|
|
2251 |
%:%689=738%:%
|
|
2252 |
%:%689=739%:%
|
|
2253 |
%:%690=740%:%
|
|
2254 |
%:%691=741%:%
|
|
2255 |
%:%692=742%:%
|
|
2256 |
%:%693=743%:%
|
|
2257 |
%:%694=744%:%
|
|
2258 |
%:%695=745%:%
|
|
2259 |
%:%696=746%:%
|
|
2260 |
%:%697=747%:%
|
|
2261 |
%:%698=748%:%
|
|
2262 |
%:%699=749%:%
|
|
2263 |
%:%700=750%:%
|
|
2264 |
%:%701=751%:%
|
|
2265 |
%:%702=752%:%
|
|
2266 |
%:%703=753%:%
|
|
2267 |
%:%704=754%:%
|
|
2268 |
%:%705=755%:%
|
|
2269 |
%:%706=756%:%
|
|
2270 |
%:%707=757%:%
|
|
2271 |
%:%708=758%:%
|
|
2272 |
%:%709=759%:%
|
|
2273 |
%:%710=760%:%
|
|
2274 |
%:%711=761%:%
|
|
2275 |
%:%712=762%:%
|
|
2276 |
%:%713=763%:%
|
|
2277 |
%:%714=764%:%
|
|
2278 |
%:%715=765%:%
|
|
2279 |
%:%716=766%:%
|
|
2280 |
%:%717=767%:%
|
|
2281 |
%:%718=768%:%
|
|
2282 |
%:%719=769%:%
|
|
2283 |
%:%720=770%:%
|
|
2284 |
%:%721=771%:%
|
|
2285 |
%:%722=772%:%
|
|
2286 |
%:%723=773%:%
|
|
2287 |
%:%724=774%:%
|
|
2288 |
%:%724=775%:%
|
|
2289 |
%:%725=776%:%
|
|
2290 |
%:%726=777%:%
|
|
2291 |
%:%727=778%:%
|
|
2292 |
%:%728=779%:%
|
|
2293 |
%:%729=780%:%
|
|
2294 |
%:%730=781%:%
|
|
2295 |
%:%731=782%:%
|
|
2296 |
%:%731=783%:%
|
|
2297 |
%:%732=784%:%
|
|
2298 |
%:%733=785%:%
|
|
2299 |
%:%734=786%:%
|
|
2300 |
%:%734=787%:%
|
|
2301 |
%:%735=788%:%
|
|
2302 |
%:%736=789%:%
|
|
2303 |
%:%737=790%:%
|
|
2304 |
%:%738=791%:%
|
|
2305 |
%:%739=792%:%
|
|
2306 |
%:%740=793%:%
|
|
2307 |
%:%741=794%:%
|
|
2308 |
%:%742=795%:%
|
|
2309 |
%:%743=796%:%
|
|
2310 |
%:%744=797%:%
|
|
2311 |
%:%745=798%:%
|
|
2312 |
%:%745=799%:%
|
|
2313 |
%:%746=800%:%
|
|
2314 |
%:%747=801%:%
|
|
2315 |
%:%748=802%:%
|
|
2316 |
%:%749=803%:%
|
|
2317 |
%:%749=804%:%
|
|
2318 |
%:%750=805%:%
|
|
2319 |
%:%751=806%:%
|
|
2320 |
%:%752=807%:%
|
|
2321 |
%:%753=808%:%
|
|
2322 |
%:%754=809%:%
|
|
2323 |
%:%755=810%:%
|
|
2324 |
%:%756=811%:%
|
|
2325 |
%:%757=812%:%
|
|
2326 |
%:%758=813%:%
|
|
2327 |
%:%759=814%:%
|
|
2328 |
%:%760=815%:%
|
|
2329 |
%:%761=816%:%
|
|
2330 |
%:%762=817%:%
|
|
2331 |
%:%763=818%:%
|
|
2332 |
%:%764=819%:%
|
|
2333 |
%:%765=820%:%
|
|
2334 |
%:%766=821%:%
|
|
2335 |
%:%767=822%:%
|
|
2336 |
%:%768=823%:%
|
|
2337 |
%:%769=824%:%
|
|
2338 |
%:%770=825%:%
|
|
2339 |
%:%771=826%:%
|
|
2340 |
%:%772=827%:%
|
|
2341 |
%:%773=828%:%
|
|
2342 |
%:%774=829%:%
|
|
2343 |
%:%775=830%:%
|
|
2344 |
%:%776=831%:%
|
|
2345 |
%:%777=832%:%
|
|
2346 |
%:%778=833%:%
|
|
2347 |
%:%779=834%:%
|
|
2348 |
%:%780=835%:%
|
|
2349 |
%:%781=836%:%
|
|
2350 |
%:%782=837%:%
|
|
2351 |
%:%783=838%:%
|
|
2352 |
%:%784=839%:%
|
|
2353 |
%:%785=840%:%
|
|
2354 |
%:%786=841%:%
|
|
2355 |
%:%787=842%:%
|
|
2356 |
%:%788=843%:%
|
|
2357 |
%:%789=844%:%
|
|
2358 |
%:%790=845%:%
|
|
2359 |
%:%791=846%:%
|
|
2360 |
%:%792=847%:%
|
|
2361 |
%:%793=848%:%
|
|
2362 |
%:%794=849%:%
|
|
2363 |
%:%795=850%:%
|
|
2364 |
%:%796=851%:%
|
|
2365 |
%:%797=852%:%
|
|
2366 |
%:%798=853%:%
|
|
2367 |
%:%799=854%:%
|
|
2368 |
%:%800=855%:%
|
|
2369 |
%:%801=856%:%
|
|
2370 |
%:%802=857%:%
|
|
2371 |
%:%803=858%:%
|
|
2372 |
%:%804=859%:%
|
|
2373 |
%:%805=860%:%
|
|
2374 |
%:%806=861%:%
|
|
2375 |
%:%807=862%:%
|
|
2376 |
%:%807=863%:%
|
|
2377 |
%:%808=864%:%
|
|
2378 |
%:%809=865%:%
|
|
2379 |
%:%810=866%:%
|
|
2380 |
%:%811=867%:%
|
|
2381 |
%:%812=868%:%
|
|
2382 |
%:%813=869%:%
|
|
2383 |
%:%814=870%:%
|
|
2384 |
%:%815=871%:%
|
|
2385 |
%:%816=872%:%
|
|
2386 |
%:%817=873%:%
|
|
2387 |
%:%818=874%:%
|
|
2388 |
%:%819=875%:%
|
|
2389 |
%:%820=876%:%
|
|
2390 |
%:%821=877%:%
|
|
2391 |
%:%822=878%:%
|
|
2392 |
%:%823=879%:%
|
|
2393 |
%:%824=880%:%
|
|
2394 |
%:%825=881%:%
|
|
2395 |
%:%826=882%:%
|
|
2396 |
%:%827=883%:%
|
|
2397 |
%:%828=884%:%
|
|
2398 |
%:%829=885%:%
|
|
2399 |
%:%830=886%:%
|
|
2400 |
%:%831=887%:%
|
|
2401 |
%:%832=888%:%
|
|
2402 |
%:%833=889%:%
|
|
2403 |
%:%834=890%:%
|
|
2404 |
%:%835=891%:%
|
|
2405 |
%:%836=892%:%
|
|
2406 |
%:%837=893%:%
|
|
2407 |
%:%838=894%:%
|
|
2408 |
%:%839=895%:%
|
|
2409 |
%:%840=896%:%
|
|
2410 |
%:%840=897%:%
|
|
2411 |
%:%841=898%:%
|
|
2412 |
%:%842=899%:%
|
|
2413 |
%:%843=900%:%
|
|
2414 |
%:%844=901%:%
|
|
2415 |
%:%845=902%:%
|
|
2416 |
%:%846=903%:%
|
|
2417 |
%:%847=904%:%
|
|
2418 |
%:%848=905%:%
|
|
2419 |
%:%849=906%:%
|
|
2420 |
%:%850=907%:%
|
|
2421 |
%:%851=908%:%
|
|
2422 |
%:%852=909%:%
|
|
2423 |
%:%853=910%:%
|
|
2424 |
%:%854=911%:%
|
|
2425 |
%:%855=912%:%
|
|
2426 |
%:%856=913%:%
|
|
2427 |
%:%857=914%:%
|
|
2428 |
%:%858=915%:%
|
|
2429 |
%:%859=916%:%
|
|
2430 |
%:%860=917%:%
|
|
2431 |
%:%861=918%:%
|
|
2432 |
%:%862=919%:%
|
|
2433 |
%:%863=920%:%
|
|
2434 |
%:%864=921%:%
|
|
2435 |
%:%865=922%:%
|
|
2436 |
%:%866=923%:%
|
|
2437 |
%:%867=924%:%
|
|
2438 |
%:%868=925%:%
|
|
2439 |
%:%869=926%:%
|
|
2440 |
%:%870=927%:%
|
|
2441 |
%:%870=928%:%
|
|
2442 |
%:%871=929%:%
|
|
2443 |
%:%872=930%:%
|
|
2444 |
%:%873=931%:%
|
|
2445 |
%:%874=932%:%
|
|
2446 |
%:%875=933%:%
|
|
2447 |
%:%876=934%:%
|
|
2448 |
%:%877=935%:%
|
|
2449 |
%:%878=936%:%
|
|
2450 |
%:%878=937%:%
|
|
2451 |
%:%879=938%:%
|
|
2452 |
%:%880=939%:%
|
|
2453 |
%:%881=940%:%
|
|
2454 |
%:%882=941%:%
|
|
2455 |
%:%883=942%:%
|
|
2456 |
%:%884=943%:%
|
|
2457 |
%:%885=944%:%
|
|
2458 |
%:%886=945%:%
|
|
2459 |
%:%887=946%:%
|
|
2460 |
%:%888=947%:%
|
|
2461 |
%:%889=948%:%
|
|
2462 |
%:%890=949%:%
|
|
2463 |
%:%891=950%:%
|
|
2464 |
%:%892=951%:%
|
|
2465 |
%:%893=952%:%
|
|
2466 |
%:%894=953%:%
|
|
2467 |
%:%895=954%:%
|
|
2468 |
%:%896=955%:%
|
|
2469 |
%:%897=956%:%
|
|
2470 |
%:%898=957%:%
|
|
2471 |
%:%899=958%:%
|
|
2472 |
%:%900=959%:%
|
|
2473 |
%:%901=960%:%
|
|
2474 |
%:%902=961%:%
|
|
2475 |
%:%903=962%:%
|
|
2476 |
%:%904=963%:%
|
|
2477 |
%:%905=964%:%
|
|
2478 |
%:%906=965%:%
|
|
2479 |
%:%907=966%:%
|
|
2480 |
%:%908=967%:%
|
|
2481 |
%:%909=968%:%
|
|
2482 |
%:%910=969%:%
|
|
2483 |
%:%911=970%:%
|
|
2484 |
%:%912=971%:%
|
|
2485 |
%:%913=972%:%
|
|
2486 |
%:%914=973%:%
|
|
2487 |
%:%915=974%:%
|
|
2488 |
%:%915=975%:%
|
|
2489 |
%:%915=976%:%
|
|
2490 |
%:%916=977%:%
|
|
2491 |
%:%916=978%:%
|
|
2492 |
%:%916=979%:%
|
|
2493 |
%:%917=980%:%
|
|
2494 |
%:%918=981%:%
|
|
2495 |
%:%918=982%:%
|
|
2496 |
%:%919=983%:%
|
|
2497 |
%:%920=984%:%
|
|
2498 |
%:%921=985%:%
|
|
2499 |
%:%922=986%:%
|
|
2500 |
%:%923=987%:%
|
|
2501 |
%:%924=988%:%
|
|
2502 |
%:%925=989%:%
|
|
2503 |
%:%926=990%:%
|
|
2504 |
%:%927=991%:%
|
|
2505 |
%:%928=992%:%
|
|
2506 |
%:%929=993%:%
|
|
2507 |
%:%930=994%:%
|
|
2508 |
%:%931=995%:%
|
|
2509 |
%:%932=996%:%
|
|
2510 |
%:%933=997%:%
|
|
2511 |
%:%934=998%:%
|
|
2512 |
%:%935=999%:%
|
|
2513 |
%:%936=1000%:%
|
|
2514 |
%:%937=1001%:%
|
|
2515 |
%:%938=1002%:%
|
|
2516 |
%:%939=1003%:%
|
|
2517 |
%:%940=1004%:%
|
|
2518 |
%:%941=1005%:%
|
|
2519 |
%:%942=1006%:%
|
|
2520 |
%:%943=1007%:%
|
|
2521 |
%:%944=1008%:%
|
|
2522 |
%:%945=1009%:%
|
|
2523 |
%:%946=1010%:%
|
|
2524 |
%:%947=1011%:%
|
|
2525 |
%:%948=1012%:%
|
|
2526 |
%:%949=1013%:%
|
|
2527 |
%:%950=1014%:%
|
|
2528 |
%:%951=1015%:%
|
|
2529 |
%:%952=1016%:%
|
|
2530 |
%:%952=1017%:%
|
|
2531 |
%:%953=1018%:%
|
|
2532 |
%:%954=1019%:%
|
|
2533 |
%:%955=1020%:%
|
|
2534 |
%:%955=1021%:%
|
369
|
2535 |
%:%955=1022%:%
|
371
|
2536 |
%:%955=1023%:%
|
|
2537 |
%:%956=1024%:%
|
|
2538 |
%:%957=1025%:%
|
|
2539 |
%:%958=1026%:%
|
|
2540 |
%:%959=1027%:%
|
|
2541 |
%:%960=1028%:%
|
|
2542 |
%:%961=1029%:%
|
|
2543 |
%:%962=1030%:%
|
|
2544 |
%:%963=1031%:%
|
|
2545 |
%:%964=1032%:%
|
|
2546 |
%:%965=1033%:%
|
|
2547 |
%:%966=1034%:%
|
|
2548 |
%:%967=1035%:%
|
|
2549 |
%:%968=1036%:%
|
|
2550 |
%:%969=1037%:%
|
|
2551 |
%:%970=1038%:%
|
|
2552 |
%:%971=1039%:%
|
|
2553 |
%:%972=1040%:%
|
|
2554 |
%:%973=1041%:%
|
|
2555 |
%:%974=1042%:%
|
|
2556 |
%:%975=1043%:%
|
|
2557 |
%:%976=1044%:%
|
|
2558 |
%:%977=1045%:%
|
|
2559 |
%:%978=1046%:%
|
|
2560 |
%:%979=1047%:%
|
|
2561 |
%:%980=1048%:%
|
|
2562 |
%:%981=1049%:%
|
|
2563 |
%:%982=1050%:%
|
|
2564 |
%:%983=1051%:%
|
|
2565 |
%:%984=1052%:%
|
|
2566 |
%:%985=1053%:%
|
|
2567 |
%:%986=1054%:%
|
|
2568 |
%:%987=1055%:%
|
|
2569 |
%:%988=1056%:%
|
|
2570 |
%:%989=1057%:%
|
|
2571 |
%:%990=1058%:%
|
|
2572 |
%:%991=1059%:%
|
|
2573 |
%:%992=1060%:%
|
|
2574 |
%:%1001=1064%:%
|
|
2575 |
%:%1013=1068%:%
|
|
2576 |
%:%1014=1069%:%
|
|
2577 |
%:%1015=1070%:%
|
|
2578 |
%:%1016=1071%:%
|
|
2579 |
%:%1017=1072%:%
|
|
2580 |
%:%1018=1073%:%
|
|
2581 |
%:%1019=1074%:%
|
|
2582 |
%:%1020=1075%:%
|
|
2583 |
%:%1021=1076%:%
|
|
2584 |
%:%1022=1077%:%
|
|
2585 |
%:%1023=1078%:%
|
|
2586 |
%:%1024=1079%:%
|
|
2587 |
%:%1025=1080%:%
|
|
2588 |
%:%1026=1081%:%
|
|
2589 |
%:%1027=1082%:%
|
|
2590 |
%:%1028=1083%:%
|
|
2591 |
%:%1029=1084%:%
|
|
2592 |
%:%1030=1085%:%
|
|
2593 |
%:%1031=1086%:%
|
|
2594 |
%:%1032=1087%:%
|
|
2595 |
%:%1033=1088%:%
|
|
2596 |
%:%1034=1089%:%
|
|
2597 |
%:%1035=1090%:%
|
|
2598 |
%:%1036=1091%:%
|
|
2599 |
%:%1037=1092%:%
|
|
2600 |
%:%1038=1093%:%
|
|
2601 |
%:%1039=1094%:%
|
|
2602 |
%:%1040=1095%:%
|
|
2603 |
%:%1041=1096%:%
|
|
2604 |
%:%1042=1097%:%
|
|
2605 |
%:%1043=1098%:%
|
|
2606 |
%:%1044=1099%:%
|
|
2607 |
%:%1045=1100%:%
|
|
2608 |
%:%1046=1101%:%
|
|
2609 |
%:%1047=1102%:%
|
|
2610 |
%:%1048=1103%:%
|
|
2611 |
%:%1049=1104%:%
|
|
2612 |
%:%1050=1105%:%
|
|
2613 |
%:%1051=1106%:%
|
|
2614 |
%:%1052=1107%:%
|
|
2615 |
%:%1053=1108%:%
|
|
2616 |
%:%1054=1109%:%
|
|
2617 |
%:%1055=1110%:%
|
|
2618 |
%:%1056=1111%:%
|
|
2619 |
%:%1057=1112%:%
|
|
2620 |
%:%1058=1113%:%
|
|
2621 |
%:%1059=1114%:%
|
|
2622 |
%:%1060=1115%:%
|
|
2623 |
%:%1061=1116%:%
|
|
2624 |
%:%1062=1117%:%
|
|
2625 |
%:%1063=1118%:%
|
|
2626 |
%:%1064=1119%:%
|
|
2627 |
%:%1065=1120%:%
|
|
2628 |
%:%1066=1121%:%
|
|
2629 |
%:%1067=1122%:%
|
|
2630 |
%:%1068=1123%:%
|
|
2631 |
%:%1069=1124%:%
|
|
2632 |
%:%1070=1125%:%
|
|
2633 |
%:%1071=1126%:%
|
|
2634 |
%:%1072=1127%:%
|
|
2635 |
%:%1073=1128%:%
|
|
2636 |
%:%1074=1129%:%
|
|
2637 |
%:%1075=1130%:%
|
|
2638 |
%:%1076=1131%:%
|
|
2639 |
%:%1077=1132%:%
|
|
2640 |
%:%1078=1133%:%
|
|
2641 |
%:%1079=1134%:%
|
|
2642 |
%:%1080=1135%:%
|
|
2643 |
%:%1081=1136%:%
|
|
2644 |
%:%1082=1137%:%
|
|
2645 |
%:%1083=1138%:%
|
|
2646 |
%:%1084=1139%:%
|
|
2647 |
%:%1085=1140%:%
|
|
2648 |
%:%1086=1141%:%
|
|
2649 |
%:%1087=1142%:%
|
|
2650 |
%:%1088=1143%:%
|
|
2651 |
%:%1089=1144%:%
|
|
2652 |
%:%1090=1145%:%
|
|
2653 |
%:%1091=1146%:%
|
|
2654 |
%:%1092=1147%:%
|
|
2655 |
%:%1093=1148%:%
|
|
2656 |
%:%1094=1149%:%
|
|
2657 |
%:%1095=1150%:%
|
|
2658 |
%:%1096=1151%:%
|
|
2659 |
%:%1097=1152%:%
|
|
2660 |
%:%1098=1153%:%
|
|
2661 |
%:%1099=1154%:%
|
|
2662 |
%:%1100=1155%:%
|
|
2663 |
%:%1101=1156%:%
|
|
2664 |
%:%1102=1157%:%
|
|
2665 |
%:%1103=1158%:%
|
|
2666 |
%:%1104=1159%:%
|
|
2667 |
%:%1105=1160%:%
|
|
2668 |
%:%1106=1161%:%
|
|
2669 |
%:%1107=1162%:%
|
|
2670 |
%:%1108=1163%:%
|
|
2671 |
%:%1109=1164%:%
|
|
2672 |
%:%1110=1165%:%
|
|
2673 |
%:%1111=1166%:%
|
|
2674 |
%:%1112=1167%:%
|
|
2675 |
%:%1113=1168%:%
|
|
2676 |
%:%1114=1169%:%
|
|
2677 |
%:%1115=1170%:%
|
|
2678 |
%:%1116=1171%:%
|
|
2679 |
%:%1117=1172%:%
|
|
2680 |
%:%1118=1173%:%
|
|
2681 |
%:%1119=1174%:%
|
|
2682 |
%:%1120=1175%:%
|
|
2683 |
%:%1121=1176%:%
|
|
2684 |
%:%1122=1177%:%
|
|
2685 |
%:%1123=1178%:%
|
|
2686 |
%:%1124=1179%:%
|
|
2687 |
%:%1125=1180%:%
|
|
2688 |
%:%1126=1181%:%
|
|
2689 |
%:%1127=1182%:%
|
|
2690 |
%:%1128=1183%:%
|
|
2691 |
%:%1128=1184%:%
|
|
2692 |
%:%1129=1185%:%
|
|
2693 |
%:%1130=1186%:%
|
|
2694 |
%:%1131=1187%:%
|
|
2695 |
%:%1132=1188%:%
|
|
2696 |
%:%1133=1189%:%
|
|
2697 |
%:%1134=1190%:%
|
|
2698 |
%:%1135=1191%:%
|
|
2699 |
%:%1136=1192%:%
|
|
2700 |
%:%1137=1193%:%
|
|
2701 |
%:%1138=1194%:%
|
|
2702 |
%:%1139=1195%:%
|
|
2703 |
%:%1139=1196%:%
|
|
2704 |
%:%1140=1197%:%
|
|
2705 |
%:%1141=1198%:%
|
|
2706 |
%:%1142=1199%:%
|
|
2707 |
%:%1143=1200%:%
|
|
2708 |
%:%1144=1201%:%
|
|
2709 |
%:%1145=1202%:%
|
|
2710 |
%:%1146=1203%:%
|
|
2711 |
%:%1147=1204%:%
|
|
2712 |
%:%1148=1205%:%
|
|
2713 |
%:%1149=1206%:%
|
|
2714 |
%:%1150=1207%:%
|
|
2715 |
%:%1151=1208%:%
|
|
2716 |
%:%1152=1209%:%
|
|
2717 |
%:%1153=1210%:%
|
|
2718 |
%:%1154=1211%:%
|
|
2719 |
%:%1155=1212%:%
|
|
2720 |
%:%1156=1213%:%
|
|
2721 |
%:%1157=1214%:%
|
|
2722 |
%:%1158=1215%:%
|
|
2723 |
%:%1159=1216%:%
|
|
2724 |
%:%1160=1217%:%
|
|
2725 |
%:%1161=1218%:%
|
|
2726 |
%:%1162=1219%:%
|
|
2727 |
%:%1163=1220%:%
|
|
2728 |
%:%1164=1221%:%
|
|
2729 |
%:%1165=1222%:%
|
|
2730 |
%:%1166=1223%:%
|
|
2731 |
%:%1167=1224%:%
|
|
2732 |
%:%1168=1225%:%
|
|
2733 |
%:%1169=1226%:%
|
|
2734 |
%:%1170=1227%:%
|
|
2735 |
%:%1171=1228%:%
|
|
2736 |
%:%1172=1229%:%
|
|
2737 |
%:%1173=1230%:%
|
|
2738 |
%:%1174=1231%:%
|
|
2739 |
%:%1175=1232%:%
|
|
2740 |
%:%1176=1233%:%
|
|
2741 |
%:%1177=1234%:%
|
|
2742 |
%:%1178=1235%:%
|
|
2743 |
%:%1179=1236%:%
|
|
2744 |
%:%1180=1237%:%
|
|
2745 |
%:%1181=1238%:%
|
|
2746 |
%:%1182=1239%:%
|
|
2747 |
%:%1183=1240%:%
|
|
2748 |
%:%1184=1241%:%
|
|
2749 |
%:%1185=1242%:%
|
|
2750 |
%:%1186=1243%:%
|
|
2751 |
%:%1187=1244%:%
|
|
2752 |
%:%1188=1245%:%
|
|
2753 |
%:%1189=1246%:%
|
|
2754 |
%:%1190=1247%:%
|
|
2755 |
%:%1191=1248%:%
|
|
2756 |
%:%1192=1249%:%
|
|
2757 |
%:%1193=1250%:%
|
|
2758 |
%:%1193=1251%:%
|
|
2759 |
%:%1193=1252%:%
|
|
2760 |
%:%1194=1253%:%
|
|
2761 |
%:%1195=1254%:%
|
|
2762 |
%:%1195=1255%:%
|
|
2763 |
%:%1195=1256%:%
|
|
2764 |
%:%1195=1257%:%
|
|
2765 |
%:%1196=1258%:%
|
|
2766 |
%:%1197=1259%:%
|
|
2767 |
%:%1198=1260%:%
|
|
2768 |
%:%1199=1261%:%
|
|
2769 |
%:%1200=1262%:%
|
|
2770 |
%:%1200=1263%:%
|
|
2771 |
%:%1201=1264%:%
|
|
2772 |
%:%1202=1265%:%
|
|
2773 |
%:%1203=1266%:%
|
|
2774 |
%:%1204=1267%:%
|
|
2775 |
%:%1205=1268%:%
|
|
2776 |
%:%1206=1269%:%
|
|
2777 |
%:%1207=1270%:%
|
|
2778 |
%:%1208=1271%:%
|
|
2779 |
%:%1209=1272%:%
|
|
2780 |
%:%1210=1273%:%
|
|
2781 |
%:%1211=1274%:%
|
|
2782 |
%:%1212=1275%:%
|
|
2783 |
%:%1213=1276%:%
|
|
2784 |
%:%1214=1277%:%
|
|
2785 |
%:%1215=1278%:%
|
|
2786 |
%:%1216=1279%:%
|
|
2787 |
%:%1217=1280%:%
|
|
2788 |
%:%1218=1281%:%
|
|
2789 |
%:%1219=1282%:%
|
|
2790 |
%:%1220=1283%:%
|
|
2791 |
%:%1221=1284%:%
|
|
2792 |
%:%1222=1285%:%
|
|
2793 |
%:%1223=1286%:%
|
|
2794 |
%:%1224=1287%:%
|
|
2795 |
%:%1225=1288%:%
|
|
2796 |
%:%1226=1289%:%
|
|
2797 |
%:%1227=1290%:%
|
|
2798 |
%:%1228=1291%:%
|
|
2799 |
%:%1229=1292%:%
|
|
2800 |
%:%1230=1293%:%
|
|
2801 |
%:%1231=1294%:%
|
|
2802 |
%:%1232=1295%:%
|
|
2803 |
%:%1233=1296%:%
|
|
2804 |
%:%1234=1297%:%
|
|
2805 |
%:%1235=1298%:%
|
|
2806 |
%:%1236=1299%:%
|
|
2807 |
%:%1237=1300%:%
|
|
2808 |
%:%1238=1301%:%
|
|
2809 |
%:%1239=1302%:%
|
|
2810 |
%:%1240=1303%:%
|
|
2811 |
%:%1241=1304%:%
|
|
2812 |
%:%1242=1305%:%
|
|
2813 |
%:%1243=1306%:%
|
|
2814 |
%:%1244=1307%:%
|
|
2815 |
%:%1245=1308%:%
|
|
2816 |
%:%1246=1309%:%
|
|
2817 |
%:%1247=1310%:%
|
|
2818 |
%:%1248=1311%:%
|
|
2819 |
%:%1248=1312%:%
|
|
2820 |
%:%1249=1313%:%
|
|
2821 |
%:%1249=1314%:%
|
|
2822 |
%:%1250=1315%:%
|
|
2823 |
%:%1250=1316%:%
|
|
2824 |
%:%1251=1317%:%
|
|
2825 |
%:%1252=1318%:%
|
|
2826 |
%:%1253=1319%:%
|
|
2827 |
%:%1254=1320%:%
|
|
2828 |
%:%1255=1321%:%
|
|
2829 |
%:%1256=1322%:%
|
|
2830 |
%:%1257=1323%:%
|
|
2831 |
%:%1257=1324%:%
|
|
2832 |
%:%1258=1325%:%
|
|
2833 |
%:%1258=1326%:%
|
|
2834 |
%:%1259=1327%:%
|
|
2835 |
%:%1259=1328%:%
|
|
2836 |
%:%1260=1329%:%
|
|
2837 |
%:%1261=1330%:%
|
|
2838 |
%:%1262=1331%:%
|
|
2839 |
%:%1263=1332%:%
|
|
2840 |
%:%1264=1333%:%
|
|
2841 |
%:%1265=1334%:%
|
|
2842 |
%:%1266=1335%:%
|
|
2843 |
%:%1267=1336%:%
|
|
2844 |
%:%1268=1337%:%
|
|
2845 |
%:%1269=1338%:%
|
|
2846 |
%:%1270=1339%:%
|
|
2847 |
%:%1271=1340%:%
|
|
2848 |
%:%1272=1341%:%
|
|
2849 |
%:%1273=1342%:%
|
|
2850 |
%:%1274=1343%:%
|
|
2851 |
%:%1275=1344%:%
|
|
2852 |
%:%1276=1345%:%
|
|
2853 |
%:%1277=1346%:%
|
|
2854 |
%:%1278=1347%:%
|
|
2855 |
%:%1279=1348%:%
|
|
2856 |
%:%1280=1349%:%
|
|
2857 |
%:%1281=1350%:%
|
|
2858 |
%:%1282=1351%:%
|
|
2859 |
%:%1283=1352%:%
|
|
2860 |
%:%1284=1353%:%
|
|
2861 |
%:%1285=1354%:%
|
|
2862 |
%:%1286=1355%:%
|
|
2863 |
%:%1287=1356%:%
|
|
2864 |
%:%1288=1357%:%
|
|
2865 |
%:%1289=1358%:%
|
|
2866 |
%:%1290=1359%:%
|
|
2867 |
%:%1290=1360%:%
|
|
2868 |
%:%1291=1361%:%
|
|
2869 |
%:%1292=1362%:%
|
|
2870 |
%:%1293=1363%:%
|
|
2871 |
%:%1294=1364%:%
|
|
2872 |
%:%1295=1365%:%
|
|
2873 |
%:%1296=1366%:%
|
|
2874 |
%:%1297=1367%:%
|
|
2875 |
%:%1297=1368%:%
|
|
2876 |
%:%1298=1369%:%
|
|
2877 |
%:%1299=1370%:%
|
|
2878 |
%:%1300=1371%:%
|
|
2879 |
%:%1300=1372%:%
|
|
2880 |
%:%1301=1373%:%
|
|
2881 |
%:%1302=1374%:%
|
|
2882 |
%:%1303=1375%:%
|
|
2883 |
%:%1303=1376%:%
|
|
2884 |
%:%1304=1377%:%
|
|
2885 |
%:%1304=1378%:%
|
|
2886 |
%:%1305=1379%:%
|
|
2887 |
%:%1305=1380%:%
|
|
2888 |
%:%1306=1381%:%
|
|
2889 |
%:%1307=1382%:%
|
|
2890 |
%:%1308=1383%:%
|
|
2891 |
%:%1308=1384%:%
|
|
2892 |
%:%1309=1385%:%
|
|
2893 |
%:%1309=1386%:%
|
|
2894 |
%:%1310=1387%:%
|
|
2895 |
%:%1310=1388%:%
|
|
2896 |
%:%1310=1389%:%
|
|
2897 |
%:%1310=1390%:%
|
|
2898 |
%:%1311=1391%:%
|
|
2899 |
%:%1311=1392%:%
|
|
2900 |
%:%1312=1393%:%
|
|
2901 |
%:%1313=1394%:%
|
|
2902 |
%:%1313=1396%:%
|
|
2903 |
%:%1313=1397%:%
|
|
2904 |
%:%1313=1398%:%
|
|
2905 |
%:%1313=1399%:%
|
|
2906 |
%:%1313=1400%:%
|
|
2907 |
%:%1314=1401%:%
|
|
2908 |
%:%1314=1402%:%
|
|
2909 |
%:%1315=1403%:%
|
|
2910 |
%:%1315=1404%:%
|
|
2911 |
%:%1316=1405%:%
|
|
2912 |
%:%1316=1406%:%
|
|
2913 |
%:%1317=1407%:%
|
|
2914 |
%:%1318=1408%:%
|
|
2915 |
%:%1319=1409%:%
|
|
2916 |
%:%1320=1410%:%
|
|
2917 |
%:%1320=1411%:%
|
|
2918 |
%:%1321=1412%:%
|
|
2919 |
%:%1321=1413%:%
|
|
2920 |
%:%1322=1414%:%
|
|
2921 |
%:%1323=1415%:%
|
|
2922 |
%:%1323=1416%:%
|
|
2923 |
%:%1324=1417%:%
|
|
2924 |
%:%1325=1418%:%
|
|
2925 |
%:%1326=1419%:%
|
|
2926 |
%:%1327=1420%:%
|
|
2927 |
%:%1328=1421%:%
|
|
2928 |
%:%1329=1422%:%
|
|
2929 |
%:%1330=1423%:%
|
|
2930 |
%:%1331=1424%:%
|
|
2931 |
%:%1332=1425%:%
|
|
2932 |
%:%1333=1426%:%
|
|
2933 |
%:%1334=1427%:%
|
|
2934 |
%:%1335=1428%:%
|
|
2935 |
%:%1336=1429%:%
|
|
2936 |
%:%1337=1430%:%
|
|
2937 |
%:%1338=1431%:%
|
|
2938 |
%:%1339=1432%:%
|
|
2939 |
%:%1340=1433%:%
|
|
2940 |
%:%1341=1434%:%
|
|
2941 |
%:%1342=1435%:%
|
|
2942 |
%:%1343=1436%:%
|
|
2943 |
%:%1344=1437%:%
|
|
2944 |
%:%1345=1438%:%
|
|
2945 |
%:%1346=1439%:%
|
|
2946 |
%:%1347=1440%:%
|
|
2947 |
%:%1348=1441%:%
|
|
2948 |
%:%1349=1442%:%
|
|
2949 |
%:%1350=1443%:%
|
|
2950 |
%:%1351=1444%:%
|
|
2951 |
%:%1352=1445%:%
|
|
2952 |
%:%1353=1446%:%
|
|
2953 |
%:%1354=1447%:%
|
|
2954 |
%:%1355=1448%:%
|
|
2955 |
%:%1356=1449%:%
|
|
2956 |
%:%1357=1450%:%
|
|
2957 |
%:%1358=1451%:%
|
|
2958 |
%:%1359=1452%:%
|
|
2959 |
%:%1360=1453%:%
|
|
2960 |
%:%1361=1454%:%
|
|
2961 |
%:%1362=1455%:%
|
|
2962 |
%:%1363=1456%:%
|
|
2963 |
%:%1364=1457%:%
|
|
2964 |
%:%1365=1458%:%
|
|
2965 |
%:%1366=1459%:%
|
|
2966 |
%:%1367=1460%:%
|
|
2967 |
%:%1368=1461%:%
|
|
2968 |
%:%1369=1462%:%
|
|
2969 |
%:%1370=1463%:%
|
|
2970 |
%:%1371=1464%:%
|
|
2971 |
%:%1372=1465%:%
|
|
2972 |
%:%1373=1466%:%
|
|
2973 |
%:%1374=1467%:%
|
|
2974 |
%:%1383=1471%:%
|
369
|
2975 |
%:%1395=1478%:%
|
|
2976 |
%:%1396=1479%:%
|
|
2977 |
%:%1397=1480%:%
|
|
2978 |
%:%1398=1481%:%
|
|
2979 |
%:%1399=1482%:%
|
|
2980 |
%:%1400=1483%:%
|
|
2981 |
%:%1401=1484%:%
|
371
|
2982 |
%:%1410=1489%:%
|
|
2983 |
%:%1422=1493%:%
|
|
2984 |
%:%1423=1494%:%
|
|
2985 |
%:%1424=1495%:%
|
|
2986 |
%:%1425=1496%:%
|
|
2987 |
%:%1426=1497%:%
|
|
2988 |
%:%1427=1498%:%
|
|
2989 |
%:%1428=1499%:%
|
|
2990 |
%:%1429=1500%:%
|
|
2991 |
%:%1430=1501%:%
|
|
2992 |
%:%1431=1502%:%
|
|
2993 |
%:%1432=1503%:%
|
|
2994 |
%:%1433=1504%:%
|
|
2995 |
%:%1434=1505%:%
|
|
2996 |
%:%1435=1506%:%
|
|
2997 |
%:%1436=1507%:%
|
|
2998 |
%:%1437=1508%:%
|
|
2999 |
%:%1438=1509%:%
|
|
3000 |
%:%1439=1510%:%
|
|
3001 |
%:%1440=1511%:%
|
|
3002 |
%:%1441=1512%:%
|
|
3003 |
%:%1442=1513%:%
|
|
3004 |
%:%1443=1514%:%
|
|
3005 |
%:%1444=1515%:%
|
|
3006 |
%:%1445=1516%:%
|
|
3007 |
%:%1446=1517%:%
|
|
3008 |
%:%1447=1518%:%
|
|
3009 |
%:%1448=1519%:%
|
|
3010 |
%:%1449=1520%:%
|
|
3011 |
%:%1450=1521%:%
|
|
3012 |
%:%1451=1522%:%
|
|
3013 |
%:%1452=1523%:%
|
|
3014 |
%:%1453=1524%:%
|
|
3015 |
%:%1454=1525%:%
|
|
3016 |
%:%1455=1526%:%
|
|
3017 |
%:%1456=1527%:%
|
|
3018 |
%:%1457=1528%:%
|
|
3019 |
%:%1458=1529%:%
|
|
3020 |
%:%1459=1530%:%
|
|
3021 |
%:%1460=1531%:%
|
|
3022 |
%:%1461=1532%:%
|
|
3023 |
%:%1462=1533%:%
|
|
3024 |
%:%1463=1534%:%
|
|
3025 |
%:%1464=1535%:%
|
|
3026 |
%:%1465=1536%:%
|
|
3027 |
%:%1466=1537%:%
|
|
3028 |
%:%1467=1538%:%
|
|
3029 |
%:%1468=1539%:%
|
|
3030 |
%:%1469=1540%:%
|
|
3031 |
%:%1470=1541%:%
|
|
3032 |
%:%1471=1542%:%
|
|
3033 |
%:%1472=1543%:%
|
|
3034 |
%:%1473=1544%:%
|
|
3035 |
%:%1474=1545%:%
|
|
3036 |
%:%1475=1546%:%
|
|
3037 |
%:%1476=1547%:%
|
|
3038 |
%:%1477=1548%:%
|
|
3039 |
%:%1478=1549%:%
|
|
3040 |
%:%1479=1550%:%
|
|
3041 |
%:%1480=1551%:%
|
|
3042 |
%:%1481=1552%:%
|
|
3043 |
%:%1482=1553%:%
|
|
3044 |
%:%1483=1554%:%
|
|
3045 |
%:%1484=1555%:%
|
|
3046 |
%:%1485=1556%:%
|
|
3047 |
%:%1486=1557%:%
|
|
3048 |
%:%1487=1558%:%
|
|
3049 |
%:%1488=1559%:%
|
|
3050 |
%:%1489=1560%:%
|
|
3051 |
%:%1490=1561%:%
|
|
3052 |
%:%1491=1562%:%
|
|
3053 |
%:%1492=1563%:%
|
|
3054 |
%:%1493=1564%:%
|
|
3055 |
%:%1494=1565%:%
|
|
3056 |
%:%1495=1566%:%
|
|
3057 |
%:%1496=1567%:%
|
|
3058 |
%:%1497=1568%:%
|
|
3059 |
%:%1498=1569%:%
|
|
3060 |
%:%1499=1570%:%
|
|
3061 |
%:%1500=1571%:%
|
|
3062 |
%:%1501=1572%:%
|
|
3063 |
%:%1502=1573%:%
|
|
3064 |
%:%1503=1574%:%
|
|
3065 |
%:%1504=1575%:%
|
|
3066 |
%:%1505=1576%:%
|
|
3067 |
%:%1506=1577%:%
|
|
3068 |
%:%1507=1578%:%
|
|
3069 |
%:%1508=1579%:%
|
|
3070 |
%:%1509=1580%:%
|
|
3071 |
%:%1510=1581%:%
|
|
3072 |
%:%1511=1582%:%
|
|
3073 |
%:%1511=1698%:%
|
|
3074 |
%:%1512=1699%:%
|
|
3075 |
%:%1513=1700%:%
|
|
3076 |
%:%1514=1701%:%
|
|
3077 |
%:%1515=1702%:%
|
|
3078 |
%:%1515=1863%:%
|
|
3079 |
%:%1516=1864%:%
|
|
3080 |
%:%1517=1865%:%
|
|
3081 |
%:%1518=1866%:%
|
|
3082 |
%:%1519=1867%:%
|
|
3083 |
%:%1520=1868%:%
|
|
3084 |
%:%1521=1869%:%
|
|
3085 |
%:%1522=1870%:%
|
|
3086 |
%:%1523=1871%:%
|
|
3087 |
%:%1524=1872%:%
|
|
3088 |
%:%1525=1873%:%
|
|
3089 |
%:%1526=1874%:%
|
|
3090 |
%:%1527=1875%:%
|
|
3091 |
%:%1528=1876%:%
|
|
3092 |
%:%1529=1877%:%
|
|
3093 |
%:%1530=1878%:%
|
|
3094 |
%:%1531=1879%:%
|
|
3095 |
%:%1532=1880%:%
|
|
3096 |
%:%1533=1881%:%
|
|
3097 |
%:%1534=1882%:%
|
|
3098 |
%:%1534=1883%:%
|
|
3099 |
%:%1535=1884%:%
|
|
3100 |
%:%1535=1885%:%
|
|
3101 |
%:%1535=1886%:%
|
|
3102 |
%:%1536=1887%:%
|
|
3103 |
%:%1536=1888%:%
|
|
3104 |
%:%1537=1889%:%
|
|
3105 |
%:%1538=1890%:%
|
|
3106 |
%:%1539=1891%:%
|
|
3107 |
%:%1540=1892%:%
|
|
3108 |
%:%1541=1893%:%
|
|
3109 |
%:%1542=1894%:%
|
|
3110 |
%:%1543=1895%:%
|
|
3111 |
%:%1544=1896%:%
|
|
3112 |
%:%1545=1897%:%
|
|
3113 |
%:%1546=1898%:%
|
|
3114 |
%:%1547=1899%:%
|
|
3115 |
%:%1548=1900%:%
|
|
3116 |
%:%1549=1901%:%
|
|
3117 |
%:%1550=1902%:%
|
|
3118 |
%:%1551=1903%:%
|
|
3119 |
%:%1552=1904%:%
|
|
3120 |
%:%1553=1905%:%
|
|
3121 |
%:%1553=1906%:%
|
|
3122 |
%:%1554=1907%:%
|
|
3123 |
%:%1555=1908%:%
|
|
3124 |
%:%1556=1909%:%
|
|
3125 |
%:%1556=1910%:%
|
|
3126 |
%:%1556=1911%:%
|
|
3127 |
%:%1557=1912%:%
|
|
3128 |
%:%1558=1913%:%
|
|
3129 |
%:%1559=1914%:%
|
|
3130 |
%:%1559=1915%:%
|
|
3131 |
%:%1560=1916%:%
|
369
|
3132 |
%:%1560=1917%:%
|
|
3133 |
%:%1561=1918%:%
|
|
3134 |
%:%1562=1919%:%
|
|
3135 |
%:%1563=1920%:%
|
|
3136 |
%:%1564=1921%:%
|
|
3137 |
%:%1565=1922%:%
|
|
3138 |
%:%1566=1923%:%
|
|
3139 |
%:%1567=1924%:%
|
|
3140 |
%:%1568=1925%:%
|
|
3141 |
%:%1569=1926%:%
|
371
|
3142 |
%:%1570=1927%:%
|
|
3143 |
%:%1571=1928%:%
|
|
3144 |
%:%1572=1929%:%
|
|
3145 |
%:%1573=1930%:%
|
|
3146 |
%:%1574=1931%:%
|
|
3147 |
%:%1575=1932%:%
|
|
3148 |
%:%1576=1933%:%
|
|
3149 |
%:%1577=1934%:%
|
|
3150 |
%:%1586=1939%:%
|
|
3151 |
%:%1598=1943%:%
|
|
3152 |
%:%1599=1944%:%
|
|
3153 |
%:%1600=1945%:%
|
|
3154 |
%:%1601=1946%:%
|
|
3155 |
%:%1602=1947%:%
|
|
3156 |
%:%1603=1948%:%
|
|
3157 |
%:%1604=1949%:%
|
|
3158 |
%:%1605=1950%:%
|
|
3159 |
%:%1606=1951%:%
|
|
3160 |
%:%1607=1952%:%
|
|
3161 |
%:%1608=1953%:%
|
|
3162 |
%:%1609=1954%:%
|
|
3163 |
%:%1610=1955%:%
|
|
3164 |
%:%1611=1956%:%
|
|
3165 |
%:%1612=1957%:%
|
|
3166 |
%:%1613=1958%:%
|
|
3167 |
%:%1614=1959%:%
|
|
3168 |
%:%1615=1960%:%
|
|
3169 |
%:%1616=1961%:%
|
|
3170 |
%:%1617=1962%:%
|
|
3171 |
%:%1618=1963%:%
|
|
3172 |
%:%1619=1964%:%
|
|
3173 |
%:%1620=1965%:%
|
|
3174 |
%:%1621=1966%:%
|
|
3175 |
%:%1622=1967%:%
|
|
3176 |
%:%1623=1968%:%
|
|
3177 |
%:%1624=1969%:%
|
|
3178 |
%:%1625=1970%:%
|
|
3179 |
%:%1626=1971%:%
|
|
3180 |
%:%1627=1972%:%
|
|
3181 |
%:%1628=1973%:%
|
|
3182 |
%:%1629=1974%:%
|
|
3183 |
%:%1630=1975%:%
|
|
3184 |
%:%1631=1976%:%
|
|
3185 |
%:%1632=1977%:%
|
|
3186 |
%:%1633=1978%:%
|
|
3187 |
%:%1634=1979%:%
|
|
3188 |
%:%1635=1980%:%
|
|
3189 |
%:%1636=1981%:%
|
|
3190 |
%:%1637=1982%:%
|
|
3191 |
%:%1638=1983%:%
|
|
3192 |
%:%1639=1984%:%
|
|
3193 |
%:%1640=1985%:%
|
|
3194 |
%:%1641=1986%:%
|
|
3195 |
%:%1642=1987%:%
|
|
3196 |
%:%1643=1988%:%
|
|
3197 |
%:%1644=1989%:%
|
|
3198 |
%:%1645=1990%:%
|
|
3199 |
%:%1646=1991%:%
|
|
3200 |
%:%1647=1992%:%
|
|
3201 |
%:%1648=1993%:%
|
|
3202 |
%:%1649=1994%:%
|
|
3203 |
%:%1650=1995%:%
|
|
3204 |
%:%1663=2001%:% |