author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Tue, 01 Mar 2016 12:10:11 +0000 | |
changeset 108 | 73f7dc60c285 |
parent 107 | 6adda4a667b1 |
child 109 | 2c38f10643ae |
permissions | -rw-r--r-- |
95
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
(*<*) |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
theory Paper |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
3 |
imports "../ReStar" "~~/src/HOL/Library/LaTeXsugar" |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
begin |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
5 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
6 |
declare [[show_question_marks = false]] |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
7 |
|
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
8 |
abbreviation |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
9 |
"der_syn r c \<equiv> der c r" |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
10 |
|
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
11 |
notation (latex output) |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
12 |
If ("(\<^raw:\textrm{>if\<^raw:}> (_)/ \<^raw:\textrm{>then\<^raw:}> (_)/ \<^raw:\textrm{>else\<^raw:}> (_))" 10) and |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
13 |
Cons ("_\<^raw:\mbox{$\,$}>::\<^raw:\mbox{$\,$}>_" [78,77] 73) and |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
14 |
ZERO ("\<^raw:\textrm{0}>" 78) and |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
15 |
ONE ("\<^raw:\textrm{1}>" 78) and |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
16 |
CHAR ("_" [1000] 10) and |
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
17 |
ALT ("_ + _" [77,77] 78) and |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
18 |
SEQ ("_ \<cdot> _" [77,77] 78) and |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
19 |
STAR ("_\<^sup>\<star>" [1000] 78) and |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
20 |
val.Char ("Char _" [1000] 78) and |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
21 |
val.Left ("Left _" [1000] 78) and |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
22 |
val.Right ("Right _" [1000] 78) and |
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
23 |
L ("L'(_')" [10] 78) and |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
24 |
der_syn ("_\\_" [1000, 1000] 78) and |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
25 |
flat ("|_|" [70] 73) and |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
26 |
Sequ ("_ @ _" [78,77] 63) and |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
27 |
injval ("inj _ _ _" [1000,77,1000] 77) and |
102
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
28 |
projval ("proj _ _ _" [1000,77,1000] 77) and |
105
80218dddbb15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
103
diff
changeset
|
29 |
length ("len _" [78] 73) |
80218dddbb15
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
103
diff
changeset
|
30 |
(* and ValOrd ("_ \<succeq>\<^bsub>_\<^esub> _" [78,77,77] 73) *) |
95
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
31 |
(*>*) |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
32 |
|
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
33 |
section {* Introduction *} |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
34 |
|
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
35 |
text {* |
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
36 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
37 |
Brzozowski \cite{Brzozowski1964} introduced the notion of the {\em |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
38 |
derivative} @{term "der c r"} of a regular expression @{text r} w.r.t.\ a |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
39 |
character~@{text c}, and showed that it gave a simple solution to the |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
40 |
problem of matching a string @{term s} with a regular expression @{term r}: |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
41 |
if the derivative of @{term r} w.r.t.\ (in succession) all the characters of |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
42 |
the string matches the empty string $\mts$, then @{term r} matches @{term s} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
43 |
(and {\em vice versa}). The derivative has the property (which may be |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
44 |
regarded as its specification) that, for every string @{term s} and regular |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
45 |
expression @{term r} and character @{term c}, one has @{term "cs \<in> L(r)"} if |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
46 |
and only if \mbox{@{term "s \<in> L(der c r)"}}. The beauty of Brzozowski's |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
47 |
derivatives is that they are neatly expressible in any functional language, and |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
48 |
very easy to be defined and reasoned about in a theorem prover---the |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
49 |
definitions consist just of inductive datatypes and recursive functions. A |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
50 |
completely formalised proof of this matcher has for example been given in |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
51 |
\cite{Owens2008}. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
52 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
53 |
One limitation of Brzozowski's matcher is that it only generates a YES/NO |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
54 |
answer for a string being matched by a regular expression. Sulzmann and Lu |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
55 |
\cite{Sulzmann2014} extended this matcher to allow generation not just of a |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
56 |
YES/NO answer but of an actual matching, called a [lexical] {\em value}. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
57 |
They give a still very simple algorithm to calculate a value that appears to |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
58 |
be the value associated with POSIX lexing (posix) %%\cite{posix}. The |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
59 |
challenge then is to specify that value, in an algorithm-independent |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
60 |
fashion, and to show that Sulzamman and Lu's derivative-based algorithm does |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
61 |
indeed calculate a value that is correct according to the specification. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
62 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
63 |
Inspired by work of Frisch and Cardelli \cite{Frisch2004} on a GREEDY |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
64 |
regular expression matching algorithm, the answer given in |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
65 |
\cite{Sulzmann2014} is to define a relation (called an ``Order Relation'') |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
66 |
on the set of values of @{term r}, and to show that (once a string to be |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
67 |
matched is chosen) there is a maximum element and that it is computed by the |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
68 |
derivative-based algorithm. Beginning with our observations that, without |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
69 |
evidence that it is transitive, it cannot be called an ``order relation'', |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
70 |
and that the relation is called a ``total order'' despite being evidently |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
71 |
not total\footnote{\textcolor{green}{Why is it not total?}}, we identify |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
72 |
problems with this approach (of which some of the proofs are not published |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
73 |
in \cite{Sulzmann2014}); perhaps more importantly, we give a simple |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
74 |
inductive (and algorithm-independent) definition of what we call being a |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
75 |
{\em POSIX value} for a regular expression @{term r} and a string @{term s}; |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
76 |
we show that the algorithm computes such a value and that such a value is |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
77 |
unique. Proofs are both done by hand and checked in {\em Isabelle} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
78 |
%\cite{isabelle}. Our experience of doing our proofs has been that this |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
79 |
mechanical checking was absolutely essential: this subject area has hidden |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
80 |
snares. This was also noted by Kuklewitz \cite{Kuklewicz} who found that |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
81 |
nearly all POSIX matching implementations are ``buggy'' \cite[Page |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
82 |
203]{Sulzmann2014}. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
83 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
84 |
\textcolor{green}{Say something about POSIX lexing} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
85 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
86 |
An extended version of \cite{Sulzmann2014} is available at the website |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
87 |
of its first author; this includes some ``proofs'', claimed in |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
88 |
\cite{Sulzmann2014} to be ``rigorous''. Since these are evidently not in |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
89 |
final form, we make no comment thereon, preferring to give general |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
90 |
reasons for our belief that the approach of \cite{Sulzmann2014} is |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
91 |
problematic rather than to discuss details of unpublished work. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
92 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
93 |
Derivatives as calculated by Brzozowski's method are usually more |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
94 |
complex regular expressions than the initial one; various optimisations |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
95 |
are possible, such as the simplifications of @{term "ALT ZERO r"}, |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
96 |
@{term "ALT r ZERO"}, @{term "SEQ ONE r"} and @{term "SEQ r ONE"} to |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
97 |
@{term r}. One of the advantages of having a simple specification and |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
98 |
correctness proof is that the latter can be refined to allow for such |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
99 |
optimisations and simple correctness proof. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
100 |
|
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
101 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
102 |
Sulzmann and Lu \cite{Sulzmann2014} |
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
103 |
\cite{Brzozowski1964} |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
104 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
105 |
there are two commonly used |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
106 |
disambiguation strategies to create a unique matching tree: |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
107 |
one is called \emph{greedy} matching \cite{Frisch2004} and the |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
108 |
other is \emph{POSIX} matching~\cite{Kuklewicz,Sulzmann2014}. |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
109 |
For the latter there are two rough rules: |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
110 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
111 |
\begin{itemize} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
112 |
\item The Longest Match Rule (or ``maximal munch rule''):\smallskip\\ The |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
113 |
longest initial substring matched by any regular |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
114 |
expression is taken as next token. |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
115 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
116 |
\item Rule Priority:\smallskip\\ For a particular longest initial |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
117 |
substring, the first regular expression that can match |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
118 |
determines the token. |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
119 |
\end{itemize} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
120 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
121 |
\noindent In the context of lexing, POSIX is the more |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
122 |
interesting disambiguation strategy as it produces longest |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
123 |
matches, which is necessary for tokenising programs. For |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
124 |
example the string \textit{iffoo} should not match the keyword |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
125 |
\textit{if} and the rest, but as one string \textit{iffoo}, |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
126 |
which might be a variable name in a program. As another |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
127 |
example consider the string $xy$ and the regular expression |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
128 |
\mbox{$(x + y + xy)^*$}. Either the input string can be |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
129 |
matched in two `iterations' by the single letter-regular |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
130 |
expressions $x$ and $y$, or directly in one iteration by $xy$. |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
131 |
The first case corresponds to greedy matching, which first |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
132 |
matches with the left-most symbol and only matches the next |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
133 |
symbol in case of a mismatch. The second case is POSIX |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
134 |
matching, which prefers the longest match. In case more than |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
135 |
one (longest) matches exist, only then it prefers the |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
136 |
left-most match. While POSIX matching seems natural, it turns |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
137 |
out to be much more subtle than greedy matching in terms of |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
138 |
implementations and in terms of proving properties about it. |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
139 |
If POSIX matching is implemented using automata, then one has |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
140 |
to follow transitions (according to the input string) until |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
141 |
one finds an accepting state, record this state and look for |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
142 |
further transition which might lead to another accepting state |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
143 |
that represents a longer input initial substring to be |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
144 |
matched. Only if none can be found, the last accepting state |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
145 |
is returned. |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
146 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
147 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
148 |
Sulzmann and Lu's paper \cite{Sulzmann2014} targets POSIX |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
149 |
regular expression matching. They write that it is known to be |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
150 |
to be a non-trivial problem and nearly all POSIX matching |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
151 |
implementations are ``buggy'' \cite[Page 203]{Sulzmann2014}. |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
152 |
For this they cite a study by Kuklewicz \cite{Kuklewicz}. My |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
153 |
current work is about formalising the proofs in the paper by |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
154 |
Sulzmann and Lu. Specifically, they propose in this paper a |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
155 |
POSIX matching algorithm and give some details of a |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
156 |
correctness proof for this algorithm inside the paper and some |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
157 |
more details in an appendix. This correctness proof is |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
158 |
unformalised, meaning it is just a ``pencil-and-paper'' proof, |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
159 |
not done in a theorem prover. Though, the paper and presumably |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
160 |
the proof have been peer-reviewed. Unfortunately their proof |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
161 |
does not give enough details such that it can be |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
162 |
straightforwardly implemented in a theorem prover, say |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
163 |
Isabelle. In fact, the purported proof they outline does not |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
164 |
work in central places. We discovered this when filling in |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
165 |
many gaps and attempting to formalise the proof in Isabelle. |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
166 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
167 |
|
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
168 |
\medskip\noindent |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
169 |
{\bf Contributions:} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
170 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
171 |
*} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
172 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
173 |
section {* Preliminaries *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
174 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
175 |
text {* \noindent Strings in Isabelle/HOL are lists of characters with |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
176 |
the empty string being represented by the empty list, written @{term |
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
177 |
"[]"}, and list-cons being written as @{term "DUMMY # DUMMY"}. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
178 |
Often we use the usual bracket notation for strings; for example a |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
179 |
string consiting of a single character is written @{term "[c]"}. By |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
180 |
using the type @{type char} for characters we have a supply of |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
181 |
finitely many characters roughly corresponding to the ASCII |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
182 |
character set. Regular expression are as usual and defined as the |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
183 |
following inductive datatype: |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
184 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
185 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
186 |
@{text "r :="} |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
187 |
@{const "ZERO"} $\mid$ |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
188 |
@{const "ONE"} $\mid$ |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
189 |
@{term "CHAR c"} $\mid$ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
190 |
@{term "ALT r\<^sub>1 r\<^sub>2"} $\mid$ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
191 |
@{term "SEQ r\<^sub>1 r\<^sub>2"} $\mid$ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
192 |
@{term "STAR r"} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
193 |
\end{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
194 |
|
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
195 |
\noindent where @{const ZERO} stands for the regular expression that |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
196 |
does not macth any string and @{const ONE} for the regular |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
197 |
expression that matches only the empty string. The language of a regular expression |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
198 |
is again defined as usual by the following clauses |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
199 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
200 |
\begin{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
201 |
\begin{tabular}{rcl} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
202 |
@{thm (lhs) L.simps(1)} & $\dn$ & @{thm (rhs) L.simps(1)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
203 |
@{thm (lhs) L.simps(2)} & $\dn$ & @{thm (rhs) L.simps(2)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
204 |
@{thm (lhs) L.simps(3)} & $\dn$ & @{thm (rhs) L.simps(3)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
205 |
@{thm (lhs) L.simps(4)[of "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) L.simps(4)[of "r\<^sub>1" "r\<^sub>2"]}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
206 |
@{thm (lhs) L.simps(5)[of "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) L.simps(5)[of "r\<^sub>1" "r\<^sub>2"]}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
207 |
@{thm (lhs) L.simps(6)} & $\dn$ & @{thm (rhs) L.simps(6)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
208 |
\end{tabular} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
209 |
\end{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
210 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
211 |
\noindent We use the star-notation for regular expressions and sets of strings. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
212 |
The Kleene-star on sets is defined inductively. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
213 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
214 |
\emph{Semantic derivatives} of sets of strings are defined as |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
215 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
216 |
\begin{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
217 |
\begin{tabular}{lcl} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
218 |
@{thm (lhs) Der_def} & $\dn$ & @{thm (rhs) Der_def}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
219 |
@{thm (lhs) Ders_def} & $\dn$ & @{thm (rhs) Ders_def}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
220 |
\end{tabular} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
221 |
\end{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
222 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
223 |
\noindent where the second definitions lifts the notion of semantic |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
224 |
derivatives from characters to strings. |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
225 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
226 |
\noindent |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
227 |
The nullable function |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
228 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
229 |
\begin{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
230 |
\begin{tabular}{lcl} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
231 |
@{thm (lhs) nullable.simps(1)} & $\dn$ & @{thm (rhs) nullable.simps(1)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
232 |
@{thm (lhs) nullable.simps(2)} & $\dn$ & @{thm (rhs) nullable.simps(2)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
233 |
@{thm (lhs) nullable.simps(3)} & $\dn$ & @{thm (rhs) nullable.simps(3)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
234 |
@{thm (lhs) nullable.simps(4)[of "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) nullable.simps(4)[of "r\<^sub>1" "r\<^sub>2"]}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
235 |
@{thm (lhs) nullable.simps(5)[of "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) nullable.simps(5)[of "r\<^sub>1" "r\<^sub>2"]}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
236 |
@{thm (lhs) nullable.simps(6)} & $\dn$ & @{thm (rhs) nullable.simps(6)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
237 |
\end{tabular} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
238 |
\end{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
239 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
240 |
\noindent |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
241 |
The derivative function for characters and strings |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
242 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
243 |
\begin{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
244 |
\begin{tabular}{lcp{7.5cm}} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
245 |
@{thm (lhs) der.simps(1)} & $\dn$ & @{thm (rhs) der.simps(1)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
246 |
@{thm (lhs) der.simps(2)} & $\dn$ & @{thm (rhs) der.simps(2)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
247 |
@{thm (lhs) der.simps(3)} & $\dn$ & @{thm (rhs) der.simps(3)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
248 |
@{thm (lhs) der.simps(4)[of c "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) der.simps(4)[of c "r\<^sub>1" "r\<^sub>2"]}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
249 |
@{thm (lhs) der.simps(5)[of c "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) der.simps(5)[of c "r\<^sub>1" "r\<^sub>2"]}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
250 |
@{thm (lhs) der.simps(6)} & $\dn$ & @{thm (rhs) der.simps(6)}\medskip\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
251 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
252 |
@{thm (lhs) ders.simps(1)} & $\dn$ & @{thm (rhs) ders.simps(1)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
253 |
@{thm (lhs) ders.simps(2)} & $\dn$ & @{thm (rhs) ders.simps(2)}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
254 |
\end{tabular} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
255 |
\end{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
256 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
257 |
It is a relatively easy exercise to prove that |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
258 |
|
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
259 |
\begin{center} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
260 |
\begin{tabular}{l} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
261 |
@{thm[mode=IfThen] nullable_correctness}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
262 |
@{thm[mode=IfThen] der_correctness}\\ |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
263 |
\end{tabular} |
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
264 |
\end{center} |
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
265 |
*} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
266 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
267 |
section {* POSIX Regular Expression Matching *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
268 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
269 |
section {* The Argument by Sulzmmann and Lu *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
270 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
271 |
section {* Conclusion *} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
272 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
273 |
text {* |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
274 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
275 |
Nipkow lexer from 2000 |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
276 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
277 |
*} |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
278 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
279 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
280 |
text {* |
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
281 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
282 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
283 |
|
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
284 |
|
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
285 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
286 |
Values |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
287 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
288 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
289 |
@{text "v :="} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
290 |
@{const "Void"} $\mid$ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
291 |
@{term "val.Char c"} $\mid$ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
292 |
@{term "Left v"} $\mid$ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
293 |
@{term "Right v"} $\mid$ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
294 |
@{term "Seq v\<^sub>1 v\<^sub>2"} $\mid$ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
295 |
@{term "Stars vs"} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
296 |
\end{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
297 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
298 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
299 |
The language of a regular expression |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
300 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
301 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
302 |
\begin{tabular}{lcl} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
303 |
@{thm (lhs) L.simps(1)} & $\dn$ & @{thm (rhs) L.simps(1)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
304 |
@{thm (lhs) L.simps(2)} & $\dn$ & @{thm (rhs) L.simps(2)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
305 |
@{thm (lhs) L.simps(3)} & $\dn$ & @{thm (rhs) L.simps(3)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
306 |
@{thm (lhs) L.simps(4)[of "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) L.simps(4)[of "r\<^sub>1" "r\<^sub>2"]}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
307 |
@{thm (lhs) L.simps(5)[of "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) L.simps(5)[of "r\<^sub>1" "r\<^sub>2"]}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
308 |
@{thm (lhs) L.simps(6)} & $\dn$ & @{thm (rhs) L.simps(6)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
309 |
\end{tabular} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
310 |
\end{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
311 |
|
108
73f7dc60c285
updated paper
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
107
diff
changeset
|
312 |
|
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
313 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
314 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
315 |
The @{const flat} function for values |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
316 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
317 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
318 |
\begin{tabular}{lcl} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
319 |
@{thm (lhs) flat.simps(1)} & $\dn$ & @{thm (rhs) flat.simps(1)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
320 |
@{thm (lhs) flat.simps(2)} & $\dn$ & @{thm (rhs) flat.simps(2)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
321 |
@{thm (lhs) flat.simps(3)} & $\dn$ & @{thm (rhs) flat.simps(3)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
322 |
@{thm (lhs) flat.simps(4)} & $\dn$ & @{thm (rhs) flat.simps(4)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
323 |
@{thm (lhs) flat.simps(5)[of "v\<^sub>1" "v\<^sub>2"]} & $\dn$ & @{thm (rhs) flat.simps(5)[of "v\<^sub>1" "v\<^sub>2"]}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
324 |
@{thm (lhs) flat.simps(6)} & $\dn$ & @{thm (rhs) flat.simps(6)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
325 |
@{thm (lhs) flat.simps(7)} & $\dn$ & @{thm (rhs) flat.simps(7)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
326 |
\end{tabular} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
327 |
\end{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
328 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
329 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
330 |
The @{const mkeps} function |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
331 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
332 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
333 |
\begin{tabular}{lcl} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
334 |
@{thm (lhs) mkeps.simps(1)} & $\dn$ & @{thm (rhs) mkeps.simps(1)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
335 |
@{thm (lhs) mkeps.simps(2)[of "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) mkeps.simps(2)[of "r\<^sub>1" "r\<^sub>2"]}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
336 |
@{thm (lhs) mkeps.simps(3)[of "r\<^sub>1" "r\<^sub>2"]} & $\dn$ & @{thm (rhs) mkeps.simps(3)[of "r\<^sub>1" "r\<^sub>2"]}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
337 |
@{thm (lhs) mkeps.simps(4)} & $\dn$ & @{thm (rhs) mkeps.simps(4)}\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
338 |
\end{tabular} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
339 |
\end{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
340 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
341 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
342 |
The @{text inj} function |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
343 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
344 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
345 |
\begin{tabular}{lcl} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
346 |
@{thm (lhs) injval.simps(1)} & $\dn$ & @{thm (rhs) injval.simps(1)}\\ |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
347 |
@{thm (lhs) injval.simps(2)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>1"]} & $\dn$ & |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
348 |
@{thm (rhs) injval.simps(2)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>1"]}\\ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
349 |
@{thm (lhs) injval.simps(3)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>2"]} & $\dn$ & |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
350 |
@{thm (rhs) injval.simps(3)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>2"]}\\ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
351 |
@{thm (lhs) injval.simps(4)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>1" "v\<^sub>2"]} & $\dn$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
352 |
& @{thm (rhs) injval.simps(4)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>1" "v\<^sub>2"]}\\ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
353 |
@{thm (lhs) injval.simps(5)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>1" "v\<^sub>2"]} & $\dn$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
354 |
& @{thm (rhs) injval.simps(5)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>1" "v\<^sub>2"]}\\ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
355 |
@{thm (lhs) injval.simps(6)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>2"]} & $\dn$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
356 |
& @{thm (rhs) injval.simps(6)[of "r\<^sub>1" "r\<^sub>2" "c" "v\<^sub>2"]}\\ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
357 |
@{thm (lhs) injval.simps(7)[of "r" "c" "v" "vs"]} & $\dn$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
358 |
& @{thm (rhs) injval.simps(7)[of "r" "c" "v" "vs"]}\\ |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
359 |
\end{tabular} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
360 |
\end{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
361 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
362 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
363 |
The inhabitation relation: |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
364 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
365 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
366 |
\begin{tabular}{c} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
367 |
@{thm[mode=Rule] Prf.intros(1)[of "v\<^sub>1" "r\<^sub>1" "v\<^sub>2" "r\<^sub>2"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
368 |
@{thm[mode=Rule] Prf.intros(2)[of "v\<^sub>1" "r\<^sub>1" "r\<^sub>2"]} \qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
369 |
@{thm[mode=Rule] Prf.intros(3)[of "v\<^sub>2" "r\<^sub>1" "r\<^sub>2"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
370 |
@{thm[mode=Axiom] Prf.intros(4)} \qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
371 |
@{thm[mode=Axiom] Prf.intros(5)[of "c"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
372 |
@{thm[mode=Axiom] Prf.intros(6)[of "r"]} \qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
373 |
@{thm[mode=Rule] Prf.intros(7)[of "v" "r" "vs"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
374 |
\end{tabular} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
375 |
\end{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
376 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
377 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
378 |
We have also introduced a slightly restricted version of this relation |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
379 |
where the last rule is restricted so that @{term "flat v \<noteq> []"}. |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
380 |
This relation for \emph{non-problematic} is written @{term "\<Turnstile> v : r"}. |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
381 |
\bigskip |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
382 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
383 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
384 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
385 |
Our Posix relation @{term "s \<in> r \<rightarrow> v"} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
386 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
387 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
388 |
\begin{tabular}{c} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
389 |
@{thm[mode=Axiom] PMatch.intros(1)} \qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
390 |
@{thm[mode=Axiom] PMatch.intros(2)}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
391 |
@{thm[mode=Rule] PMatch.intros(3)[of "s" "r\<^sub>1" "v" "r\<^sub>2"]}\qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
392 |
@{thm[mode=Rule] PMatch.intros(4)[of "s" "r\<^sub>2" "v" "r\<^sub>1"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
393 |
\multicolumn{1}{p{5cm}}{@{thm[mode=Rule] PMatch.intros(5)[of "s\<^sub>1" "r\<^sub>1" "v\<^sub>1" "s\<^sub>2" "r\<^sub>2" "v\<^sub>2"]}}\medskip\\ |
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
394 |
@{thm[mode=Rule] PMatch.intros(6)[of "s\<^sub>1" "r" "v" "s\<^sub>2" "vs"]}\medskip\\ |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
395 |
@{thm[mode=Axiom] PMatch.intros(7)}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
396 |
\end{tabular} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
397 |
\end{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
398 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
399 |
\noindent |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
400 |
Our version of Sulzmann's ordering relation |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
401 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
402 |
\begin{center} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
403 |
\begin{tabular}{c} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
404 |
@{thm[mode=Rule] ValOrd.intros(2)[of "v\<^sub>1" "r\<^sub>1" "v\<^sub>1'" "v\<^sub>2" "r\<^sub>2" "v\<^sub>2'"]} \qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
405 |
@{thm[mode=Rule] ValOrd.intros(1)[of "v\<^sub>2" "r\<^sub>2" "v\<^sub>2'" "v\<^sub>1" "r\<^sub>1"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
406 |
@{thm[mode=Rule] ValOrd.intros(3)[of "v\<^sub>1" "v\<^sub>2" "r\<^sub>1" "r\<^sub>2"]} \qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
407 |
@{thm[mode=Rule] ValOrd.intros(4)[of "v\<^sub>2" "v\<^sub>1" "r\<^sub>1" "r\<^sub>2"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
408 |
@{thm[mode=Rule] ValOrd.intros(5)[of "v\<^sub>2" "r\<^sub>2" "v\<^sub>2'" "r\<^sub>1"]} \qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
409 |
@{thm[mode=Rule] ValOrd.intros(6)[of "v\<^sub>1" "r\<^sub>1" "v\<^sub>1'" "r\<^sub>2"]} \medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
410 |
@{thm[mode=Axiom] ValOrd.intros(7)}\qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
411 |
@{thm[mode=Axiom] ValOrd.intros(8)[of "c"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
412 |
@{thm[mode=Rule] ValOrd.intros(9)[of "v" "vs" "r"]}\qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
413 |
@{thm[mode=Rule] ValOrd.intros(10)[of "v" "vs" "r"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
414 |
@{thm[mode=Rule] ValOrd.intros(11)[of "v\<^sub>1" "r" "v\<^sub>2" "vs\<^sub>1" "vs\<^sub>2"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
415 |
@{thm[mode=Rule] ValOrd.intros(12)[of "vs\<^sub>1" "r" "vs\<^sub>2" "v"]}\qquad |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
416 |
@{thm[mode=Axiom] ValOrd.intros(13)[of "r"]}\medskip\\ |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
417 |
\end{tabular} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
418 |
\end{center} |
98
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
419 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
420 |
\noindent |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
421 |
A prefix of a string s |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
422 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
423 |
\begin{center} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
424 |
\begin{tabular}{c} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
425 |
@{thm prefix_def[of "s\<^sub>1" "s\<^sub>2"]} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
426 |
\end{tabular} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
427 |
\end{center} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
428 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
429 |
\noindent |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
430 |
Values and non-problematic values |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
431 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
432 |
\begin{center} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
433 |
\begin{tabular}{c} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
434 |
@{thm Values_def}\medskip\\ |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
435 |
\end{tabular} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
436 |
\end{center} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
437 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
438 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
439 |
\noindent |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
440 |
The point is that for a given @{text s} and @{text r} there are only finitely many |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
441 |
non-problematic values. |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
442 |
*} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
443 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
444 |
text {* |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
445 |
\noindent |
98
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
446 |
Some lemmas we have proved:\bigskip |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
447 |
|
98
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
448 |
@{thm L_flat_Prf} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
449 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
450 |
@{thm L_flat_NPrf} |
97
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
451 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
452 |
@{thm[mode=IfThen] mkeps_nullable} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
453 |
|
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
454 |
@{thm[mode=IfThen] mkeps_flat} |
38696f516c6b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
95
diff
changeset
|
455 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
456 |
@{thm[mode=IfThen] Prf_injval} |
98
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
457 |
|
107
6adda4a667b1
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
105
diff
changeset
|
458 |
@{thm[mode=IfThen] Prf_injval_flat} |
98
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
459 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
460 |
@{thm[mode=IfThen] PMatch_mkeps} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
461 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
462 |
@{thm[mode=IfThen] PMatch1(2)} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
463 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
464 |
@{thm[mode=IfThen] PMatch1N} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
465 |
|
100
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
466 |
@{thm[mode=IfThen] PMatch_determ(1)[of "s" "r" "v\<^sub>1" "v\<^sub>2"]} |
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
467 |
|
8b919b3d753e
strengthened PMatch to get determ
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
99
diff
changeset
|
468 |
\medskip |
98
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
469 |
\noindent |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
470 |
This is the main theorem that lets us prove that the algorithm is correct according to |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
471 |
@{term "s \<in> r \<rightarrow> v"}: |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
472 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
473 |
@{thm[mode=IfThen] PMatch2} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
474 |
|
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
475 |
\mbox{}\bigskip |
102
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
476 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
477 |
\noindent {\bf Proof} The proof is by induction on the definition of |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
478 |
@{const der}. Other inductions would go through as well. The |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
479 |
interesting case is for @{term "SEQ r\<^sub>1 r\<^sub>2"}. First we analyse the |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
480 |
case where @{term "nullable r\<^sub>1"}. We have by induction hypothesis |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
481 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
482 |
\[ |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
483 |
\begin{array}{l} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
484 |
(IH1)\quad @{text "\<forall>s v."} \text{\;if\;} @{term "s \<in> der c r\<^sub>1 \<rightarrow> v"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
485 |
\text{\;then\;} @{term "(c # s) \<in> r\<^sub>1 \<rightarrow> injval r\<^sub>1 c v"}\\ |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
486 |
(IH2)\quad @{text "\<forall>s v."} \text{\;if\;} @{term "s \<in> der c r\<^sub>2 \<rightarrow> v"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
487 |
\text{\;then\;} @{term "(c # s) \<in> r\<^sub>2 \<rightarrow> injval r\<^sub>2 c v"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
488 |
\end{array} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
489 |
\] |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
490 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
491 |
\noindent |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
492 |
and have |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
493 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
494 |
\[ |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
495 |
@{term "s \<in> ALT (SEQ (der c r\<^sub>1) r\<^sub>2) (der c r\<^sub>2) \<rightarrow> v"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
496 |
\] |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
497 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
498 |
\noindent |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
499 |
There are two cases what @{term v} can be: (1) @{term "Left v'"} and (2) @{term "Right v'"}. |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
500 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
501 |
\begin{itemize} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
502 |
\item[(1)] We know @{term "s \<in> SEQ (der c r\<^sub>1) r\<^sub>2 \<rightarrow> v'"} holds, from which we |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
503 |
can infer that there are @{text "s\<^sub>1"}, @{term "s\<^sub>2"}, @{text "v\<^sub>1"}, @{term "v\<^sub>2"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
504 |
with |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
505 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
506 |
\[ |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
507 |
@{term "s\<^sub>1 \<in> der c r\<^sub>1 \<rightarrow> v\<^sub>1"} \qquad\text{and}\qquad @{term "s\<^sub>2 \<in> r\<^sub>2 \<rightarrow> v\<^sub>2"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
508 |
\] |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
509 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
510 |
and also |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
511 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
512 |
\[ |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
513 |
@{term "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s\<^sub>2 \<and> s\<^sub>1 @ s\<^sub>3 \<in> L (der c r\<^sub>1) \<and> s\<^sub>4 \<in> L r\<^sub>2)"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
514 |
\] |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
515 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
516 |
\noindent |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
517 |
and have to prove |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
518 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
519 |
\[ |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
520 |
@{term "((c # s\<^sub>1) @ s\<^sub>2) \<in> SEQ r\<^sub>1 r\<^sub>2 \<rightarrow> Seq (injval r\<^sub>1 c v\<^sub>1) v\<^sub>2"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
521 |
\] |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
522 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
523 |
\noindent |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
524 |
The two requirements @{term "(c # s\<^sub>1) \<in> r\<^sub>1 \<rightarrow> injval r\<^sub>1 c v\<^sub>1"} and |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
525 |
@{term "s\<^sub>2 \<in> r\<^sub>2 \<rightarrow> v\<^sub>2"} can be proved by the induction hypothese (IH1) and the |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
526 |
fact above. |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
527 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
528 |
\noindent |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
529 |
This leaves to prove |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
530 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
531 |
\[ |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
532 |
@{term "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s\<^sub>2 \<and> (c # s\<^sub>1) @ s\<^sub>3 \<in> L r\<^sub>1 \<and> s\<^sub>4 \<in> L r\<^sub>2)"} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
533 |
\] |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
534 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
535 |
\noindent |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
536 |
which holds because @{term "(c # s\<^sub>1) @ s\<^sub>3 \<in> L r\<^sub>1 "} implies @{term "s\<^sub>1 @ s\<^sub>3 \<in> L (der c r\<^sub>1) "} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
537 |
|
103
ffe5d850df62
added some slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
102
diff
changeset
|
538 |
\item[(2)] This case is similar. |
102
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
539 |
\end{itemize} |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
540 |
|
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
541 |
\noindent |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
542 |
The final case is that @{term " \<not> nullable r\<^sub>1"} holds. This case again similar |
7f589bfecffa
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
101
diff
changeset
|
543 |
to the cases above. |
98
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
544 |
*} |
8b4c8cdd0b51
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
97
diff
changeset
|
545 |
|
95
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
546 |
|
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
547 |
text {* |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
548 |
%\noindent |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
549 |
%{\bf Acknowledgements:} |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
550 |
%We are grateful for the comments we received from anonymous |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
551 |
%referees. |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
552 |
|
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
553 |
\bibliographystyle{plain} |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
554 |
\bibliography{root} |
101
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
555 |
|
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
556 |
\section{Roy's Rules} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
557 |
|
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
558 |
\newcommand{\abs}[1]{\mid\!\! #1\!\! \mid} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
559 |
%%\newcommand{\mts}{\textit{``''} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
560 |
\newcommand{\tl}{\ \triangleleft\ } |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
561 |
$$\inferrule[]{Void \tl \epsilon}{} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
562 |
\quad\quad |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
563 |
\inferrule[]{Char\ c \tl Lit\ c}{} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
564 |
$$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
565 |
$$\inferrule |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
566 |
{v_1 \tl r_1} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
567 |
{Left\ v_1 \tl r_1 + r_2} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
568 |
\quad\quad |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
569 |
\inferrule[] |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
570 |
{ v_2 \tl r_2 \\ \abs{v_2}\ \not\in\ L(r_1)} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
571 |
{Right\ v_2 \tl r_1 + r_2} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
572 |
$$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
573 |
$$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
574 |
\inferrule |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
575 |
{v_1 \tl r_1\\ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
576 |
v_2 \tl r_2\\ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
577 |
s \in\ L(r_1\backslash\! \abs{v_1}) \ \land\ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
578 |
\abs{v_2}\!\backslash s\ \epsilon\ L(r_2) |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
579 |
\ \Rightarrow\ s = [] |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
580 |
} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
581 |
{(v_1, v_2) \tl r_1 \cdot r_2} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
582 |
$$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
583 |
$$\inferrule |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
584 |
{ v \tl r \\ vs \tl r^* \\ \abs{v}\ \not=\ []} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
585 |
{ (v :: vs) \tl r^* } |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
586 |
\quad\quad |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
587 |
\inferrule{} |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
588 |
{ [] \tl r^* } |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
589 |
$$ |
7f4f8c34da95
fixed inj function
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
100
diff
changeset
|
590 |
|
95
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
591 |
*} |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
592 |
|
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
593 |
|
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
594 |
(*<*) |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
595 |
end |
a33d3040bf7e
started a paper and moved cruft to Attic
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
596 |
(*>*) |