author | Chengsong |
Sat, 06 Jul 2019 19:48:20 +0100 | |
changeset 59 | 8ff7b7508824 |
parent 17 | 3241b1e71633 |
child 73 | 569280c1f56c |
permissions | -rw-r--r-- |
8 | 1 |
\documentclass{article} |
2 |
\usepackage[utf8]{inputenc} |
|
3 |
\usepackage[english]{babel} |
|
4 |
\usepackage{listings} |
|
5 |
\usepackage{amsthm} |
|
9 | 6 |
\usepackage{hyperref} |
8 | 7 |
\usepackage[margin=0.5in]{geometry} |
10 | 8 |
\usepackage{pmboxdraw} |
9 |
||
8 | 10 |
\theoremstyle{theorem} |
11 |
\newtheorem{theorem}{Theorem} |
|
12 |
||
13 |
\theoremstyle{lemma} |
|
14 |
\newtheorem{lemma}{Lemma} |
|
15 |
||
9 | 16 |
\newcommand{\lemmaautorefname}{Lemma} |
17 |
||
8 | 18 |
\theoremstyle{definition} |
19 |
\newtheorem{definition}{Definition} |
|
20 |
\begin{document} |
|
17 | 21 |
This is an outline of the structure of the paper with a little bit of flesh in it. |
22 |
\section{The Flow of thought process} |
|
8 | 23 |
|
24 |
||
17 | 25 |
\begin{definition}{Regular Expressions and values} |
8 | 26 |
\begin{verbatim} |
17 | 27 |
TODO |
8 | 28 |
\end{verbatim} |
29 |
\end{definition} |
|
30 |
||
17 | 31 |
Value is.a parse tree for the regular expression matching the string. |
32 |
||
33 |
||
34 |
||
35 |
\begin{definition}{nullable} |
|
8 | 36 |
\begin{verbatim} |
17 | 37 |
TODO |
38 |
\end{verbatim} |
|
39 |
\end{definition} |
|
40 |
The idea behind nullable: whether it contains the empty string. |
|
41 |
||
42 |
\begin{definition}{derivatives} |
|
43 |
TODO |
|
44 |
||
45 |
\end{definition} |
|
46 |
||
47 |
This definition can be used for matching algorithm. |
|
48 |
||
49 |
\begin{definition}{matcher} |
|
50 |
TODO |
|
51 |
\end{definition} |
|
52 |
||
53 |
\begin{definition}{POSIX values} |
|
54 |
TODO |
|
55 |
\end{definition} |
|
56 |
||
57 |
\begin{definition}{POSIX lexer algorithm} |
|
58 |
TODO |
|
59 |
\end{definition} |
|
60 |
||
61 |
\begin{definition}{POSIX lexer algorithm with simplification} |
|
62 |
TODO |
|
63 |
\end{definition} |
|
64 |
This simplification algorithm is rather complicated as it entangles derivative, simplification and value reconstruction. We need to split the regular expression structure of the information for lexing so that simplifcation only changes the regex but does not destroy the information for reconstructing the resulting value.\\ |
|
65 |
||
66 |
Introduce regex with auxiliary information: |
|
67 |
||
68 |
\begin{definition}{annotated regular expression} |
|
69 |
TODO |
|
70 |
\end{definition} |
|
71 |
||
72 |
\begin{definition}{encoding} |
|
73 |
TODO |
|
74 |
\end{definition} |
|
75 |
Encoding translates values into bit codes with some information loss. |
|
76 |
||
77 |
\begin{definition}{decoding} |
|
78 |
TODO |
|
79 |
\end{definition} |
|
80 |
Decoding translates bitcodes back into values with the help of regex to recover the structure.\\ |
|
81 |
||
82 |
During different phases of lexing, we sometimes already know what the value would look like if we match the branch of regex with the string(e.g. a STAR with 1 more iteration, a left/right value), so we can partially encode the value at diffferent phases of the algorithm for later decoding. |
|
83 |
\\ |
|
84 |
Examples of such partial encoding: |
|
85 |
||
86 |
\begin{definition}{internalise} |
|
87 |
TODO |
|
88 |
\end{definition} |
|
89 |
When doing internalise on ALT:\\ |
|
90 |
Whichever branch is chosen, we know exactly the shape of the value, and therefore can get the bit code for such a value: Left corresponds to Z and Right to S |
|
91 |
||
92 |
\begin{definition}{bmkeps} |
|
93 |
TODO |
|
94 |
\end{definition} |
|
95 |
bmkeps on the STAR case:\\ |
|
96 |
We know there could be no more iteration for a star if we want to get a POSIX value for an empty string, so the value must be Stars [], corresponding to an S in the bit code. |
|
97 |
||
98 |
\begin{definition}{bder} |
|
99 |
TODO |
|
100 |
\end{definition} |
|
101 |
SEQ case with the first regex nullable:\\ |
|
102 |
bmkeps will extract the value for how a1 mathces the empty string and encode it into a bit sequence. |
|
103 |
||
104 |
\begin{definition}{blexer} |
|
105 |
\begin{verbatim} |
|
106 |
TODO |
|
8 | 107 |
\end{verbatim} |
108 |
\end{definition} |
|
109 |
||
17 | 110 |
adding simplifcation.\\ |
111 |
||
112 |
size of simplified regex: smaller than Antimirov's pder.\\ |
|
8 | 113 |
|
17 | 114 |
|
8 | 115 |
|
17 | 116 |
The rest of the document is the residual from a previous doc and may be deleted.\\ |
8 | 117 |
\begin{definition}{bsimp} |
118 |
\begin{verbatim} |
|
119 |
def bsimp(r: ARexp): ARexp = r match { |
|
120 |
case ASEQ(bs1, r1, r2) => (bsimp(r1), bsimp(r2)) match { |
|
121 |
case (AZERO, _) => AZERO |
|
122 |
case (_, AZERO) => AZERO |
|
123 |
case (AONE(bs2), r2s) => fuse(bs1 ++ bs2, r2s) |
|
124 |
case (r1s, r2s) => ASEQ(bs1, r1s, r2s) |
|
125 |
} |
|
126 |
case AALTS(bs1, rs) => { |
|
127 |
val rs_simp = rs.map(bsimp) |
|
128 |
val flat_res = flats(rs_simp) |
|
129 |
val dist_res = distinctBy(flat_res, erase) |
|
130 |
dist_res match { |
|
131 |
case Nil => AZERO |
|
132 |
case s :: Nil => fuse(bs1, s) |
|
133 |
case rs => AALTS(bs1, rs) |
|
134 |
} |
|
135 |
} |
|
136 |
//case ASTAR(bs, r) => ASTAR(bs, bsimp(r)) |
|
137 |
case r => r |
|
138 |
} |
|
139 |
\end{verbatim} |
|
140 |
\end{definition} |
|
141 |
||
142 |
\begin{definition}{sub-parts of bsimp} |
|
143 |
\begin{itemize} |
|
144 |
\item{flats}\\ |
|
145 |
flattens the list. |
|
146 |
\item{dB}\\ |
|
147 |
means distinctBy |
|
148 |
\item{Co}\\ |
|
9 | 149 |
The last matching clause of the function bsimp, with a slight modification to suit later reasoning. |
150 |
\begin{verbatim} |
|
151 |
def Co(bs1, rs): ARexp = { |
|
152 |
rs match { |
|
8 | 153 |
case Nil => AZERO |
154 |
case s :: Nil => fuse(bs1, s) |
|
155 |
case rs => AALTS(bs1, rs) |
|
156 |
} |
|
9 | 157 |
\end{verbatim} |
8 | 158 |
\end{itemize} |
159 |
\end{definition} |
|
160 |
||
161 |
\begin{definition}{fuse} |
|
162 |
\begin{verbatim} |
|
163 |
def fuse(bs: Bits, r: ARexp) : ARexp = r match { |
|
164 |
case AZERO => AZERO |
|
165 |
case AONE(cs) => AONE(bs ++ cs) |
|
166 |
case ACHAR(cs, f) => ACHAR(bs ++ cs, f) |
|
167 |
case AALTS(cs, rs) => AALTS(bs ++ cs, rs) |
|
168 |
case ASEQ(cs, r1, r2) => ASEQ(bs ++ cs, r1, r2) |
|
169 |
case ASTAR(cs, r) => ASTAR(bs ++ cs, r) |
|
170 |
} |
|
171 |
\end{verbatim} |
|
172 |
\end{definition} |
|
173 |
||
174 |
||
175 |
\begin{definition}{mkepsBC} |
|
176 |
\begin{verbatim} |
|
177 |
def mkepsBC(r: ARexp) : Bits = r match { |
|
178 |
case AONE(bs) => bs |
|
179 |
case AALTS(bs, rs) => { |
|
180 |
val n = rs.indexWhere(bnullable) |
|
181 |
bs ++ mkepsBC(rs(n)) |
|
182 |
} |
|
183 |
case ASEQ(bs, r1, r2) => bs ++ mkepsBC(r1) ++ mkepsBC(r2) |
|
184 |
case ASTAR(bs, r) => bs ++ List(Z) |
|
185 |
} |
|
186 |
\end{verbatim} |
|
187 |
\end{definition} |
|
188 |
||
189 |
\begin{definition}{mkepsBC equicalence} |
|
190 |
\\ |
|
191 |
Given 2 nullable annotated regular expressions r1, r2, if mkepsBC(r1) == mkepsBC(r2) |
|
192 |
then r1 and r2 are mkepsBC equivalent, denoted as r1 $\sim_{m\epsilon}$ r2 |
|
193 |
\end{definition} |
|
194 |
||
195 |
\begin{definition}{shorthand notation for ders} |
|
196 |
\\For the sake of reducing verbosity, we sometimes use the shorthand notation |
|
197 |
$d_{c}(r)$ for the function application bder(c, r) and $s(r)$(s here stands for simplification) for the function application bsimp(r) . |
|
198 |
\\We omit the subscript when it is clear from context what that character is and write $d(r)$ instead of $d_{c}(r)$. |
|
199 |
\\And we omit the parentheses when no confusion can be caused. For example ders\_simp(c, r) can be written as $s(d_{c}(r))$ or even $s d r$ as we know the derivative operation is w.r.t the character c. Here the s and d are more like operators that take an annotated regular expression as an input and return an annotated regular expression as an output |
|
200 |
||
201 |
\end{definition} |
|
202 |
||
203 |
||
204 |
||
205 |
\begin{definition}{distinctBy operation expressed in a different way--how it transforms the list}\\ |
|
206 |
Given two lists rs1 and rs2, we define the operation $--$:\\ |
|
207 |
$rs1 -- rs2 := [r \in rs1 | r \notin rs2]$ |
|
9 | 208 |
Note that the order each term appears in $rs_1 -- rs_2$ is preserved as in the original list. |
8 | 209 |
\end{definition} |
210 |
||
211 |
||
212 |
\section{Main Result} |
|
9 | 213 |
|
214 |
\begin{lemma}{simplification function does not simplify an already simplified regex}\label{lma1}\\ |
|
8 | 215 |
bsimp(r) == bsimp(bsimp(r)) holds for any annotated regular expression r. |
216 |
\end{lemma} |
|
217 |
||
9 | 218 |
\begin{lemma}{simp and mkeps}\label{lma2}\\ |
8 | 219 |
When r is nullable, we have that |
220 |
mkeps(bsimp(r)) == mkeps(r) |
|
221 |
\end{lemma} |
|
222 |
||
9 | 223 |
|
224 |
%\begin{theorem}See~\cref{lma1}.\end{theorem} |
|
225 |
%\begin{lemma}\label{lma1}\lipsum[2]\end{lemma} |
|
226 |
||
227 |
\begin{lemma}{mkeps equivalence w.r.t some syntactically different regular expressions(1 ALTS)}\label{lma3}\\ |
|
228 |
When one of the 2 regular expressions $s(r_1)$ and $s(r_2)$ is of the form ALTS(bs1, rs1), we have that $ds(ALTS(bs, r1, r2)) \sim_{m\epsilon} d(ALTS(bs, sr_1, sr_2))$ |
|
8 | 229 |
\end{lemma} |
230 |
\begin{proof} |
|
9 | 231 |
By opening up one of the alts and show no additional changes are made.\\ |
232 |
Details: $ds(ALTS(bs, r1, r2)) = d Co( bs, dB(flats(sr1, sr2)) )$ |
|
8 | 233 |
\end{proof} |
234 |
||
9 | 235 |
|
236 |
\begin{lemma}{mkepsBC invariant manipulation of bits and notation}\label{lma7}\\ |
|
237 |
ALTS(bs, ALTS(bs1, rs1), ALTS(bs2, rs2)) $\sim_{m\epsilon}$ ALTS(bs, rs1.map(fuse(bs1, \_)) ++ rs2.map(fuse(bs2, \_)) ). \\ |
|
238 |
We also use $bs2>>rs2 $ as a shorthand notation for rs2.map(fuse(bs2,\_)). |
|
239 |
\end{lemma} |
|
240 |
||
241 |
\begin{lemma}{mkepsBC equivalence w.r.t syntactically different regular expressions(2 ALTS)}\label{lma4}\\ |
|
8 | 242 |
$sr_1 = ALTS(bs1, rs1)$ and $sr_2 = ALTS(bs2, rs2)$ we have $ d(sr_1 +sr_2 ) \sim_{m\epsilon} d(ALTS(bs, bs1>>rs1 ++ bs2>>rs2))$ |
243 |
\end{lemma} |
|
244 |
\begin{proof} |
|
245 |
We are just fusing bits inside here, there is no other structural change. |
|
246 |
\end{proof} |
|
247 |
||
9 | 248 |
\begin{lemma}{What does dB do to two already simplified ALTS}\label{lma5}\\ |
249 |
$d Co(ALTS(bs, dB(bs1>>rs1 ++ bs2>>rs2))) = d Co(ALTS(bs, bs1>>rs1 ++ ((bs2>>rs2)--rs1) )) $ |
|
8 | 250 |
\end{lemma} |
251 |
\begin{proof} |
|
9 | 252 |
We prove that $ dB(bs1>>rs1 ++ bs2>>rs2) = bs1>>rs1 ++ ((bs2>>rs2)--rs1)$. |
253 |
||
254 |
||
8 | 255 |
\end{proof} |
256 |
||
9 | 257 |
\begin{lemma}{after opening two previously simplified alts up into terms, length must exceed 2}\label{lma6}\\ |
258 |
If sr1, sr2 are of the form ALTS(bs1, rs1), ALTS(bs2, rs2) respectively, then we have that |
|
259 |
$Co(bs, (bs1>>rs1) ++ (bs2>>rs2)--rs1) = ALTS(bs, bs1>>rs1 ++ (bs2>>rs2)--rs1)$ |
|
8 | 260 |
\end{lemma} |
261 |
\begin{proof} |
|
9 | 262 |
$Co(bs, rs) \sim_{m\epsilon} ALTS(bs, rs)$ if $rs$ is a list of length greater than or equal to 2. |
263 |
As suggested by the title of this lemma, ALTS(bs1, rs1) is a result of simplification, which means that rs1 must be composed of at least 2 distinct regular terms. This alone says that $bs1>>rs1 ++ (bs2>>rs2)--rs1$ is a list of length greater than or equal to 2, as the second operand of the concatenation operator $(bs2>>rs2) -- rs1$ can only contribute a non-negative value to the overall length of the list |
|
264 |
$bs1>>rs1 ++ (bs2>>rs2)--rs1$. |
|
8 | 265 |
\end{proof} |
266 |
||
267 |
||
9 | 268 |
\begin{lemma}{mkepsBC equivalence w.r.t syntactically different regular expressions(2 ALTS+ some deletion after derivatives)}\label{lma8}\\ |
269 |
$d ALTS(bs, bs1>>rs1 ++ bs2>>rs2) \sim_{m\epsilon} d ALTS(bs, bs1>>rs1 ++ ((bs2>>rs2)--rs1) ) $ |
|
270 |
\end{lemma} |
|
271 |
\begin{proof} |
|
272 |
Let's call $bs1>>rs1$ $rs1'$ and $bs2>>rs2$ $rs2'$. Then we need to prove $d ALTS(bs, rs1' ++rs2') \sim_{m\epsilon} d ALTS(bs, rs1'++(rs2' -- rs1') ) $.\\ |
|
273 |
We might as well omit the prime in each rs for simplicty of notation and prove $d ALTS(bs, rs1++rs2) \sim_{m\epsilon} d ALTS(bs, rs1++(rs2 -- rs1) ) $.\\ |
|
274 |
We know that the result of derivative is nullable, so there must exist an r in rs1++rs2 s.t. r is nullable.\\ |
|
275 |
If $r \in rs1$, then equivalence holds. If $r \in rs2 \wedge r \notin rs1$, equivalence holds as well. This completes the proof. |
|
276 |
\end{proof} |
|
8 | 277 |
|
10 | 278 |
\begin{lemma}{nullability relation between a regex and its simplified version}\label{lma9}\\ |
279 |
$r\ nullable \iff sr\ nullable $ |
|
280 |
\end{lemma} |
|
281 |
||
282 |
\begin{lemma}{concatenation + simp invariance of mkepsBC}\label{lma10}\\ |
|
283 |
$mkepsBC r1 \cdot sr2 = mkepsBC r1 \cdot r2$ if both r1 and r2 are nullable. |
|
284 |
\end{lemma} |
|
8 | 285 |
|
286 |
||
287 |
\begin{theorem}{Correctness Result} |
|
288 |
||
289 |
\begin{itemize} |
|
290 |
||
291 |
\item{} |
|
292 |
When s is a string in the language L(ar), \\ |
|
293 |
ders\_simp(ar, s) $\sim_{m\epsilon}$ ders(ar, s), \\ |
|
294 |
\item{} |
|
295 |
when s is not a string of the language L(ar) |
|
296 |
ders\_simp(ar, s) is not nullable |
|
297 |
\end{itemize} |
|
298 |
\end{theorem} |
|
299 |
||
300 |
\begin{proof}{Split into 2 parts.} |
|
301 |
\begin{itemize} |
|
302 |
\item |
|
303 |
||
9 | 304 |
|
8 | 305 |
When we have an annotated regular expression ar and a string s that matches ar, by the correctness of the algorithm ders, we have that ders(ar, s) is nullable, and that mkepsBC will extract the desired bits for decoding the correct value v for the matching, and v is a POSIX value. Now we prove that mkepsBC(ders\_simp(ar, s)) yields the same bitsequence. |
306 |
\\ |
|
307 |
We first open up the ders\_simp function into nested alternating sequences of ders and simp. |
|
308 |
Assume that s = $c_1...c_n$($n \geq 1$ ) where each of the $c_i$ are characters. |
|
309 |
Then $ders\_simp(ar, s)$ = $s(d_{c_n}(...s(d_{c_1}(r))...))$ = $sdsd......sdr$. If we can prove that |
|
9 | 310 |
$sdr \sim_{m\epsilon} dsr$ holds for any regular expression and any character, then we are done. This is because then we can push ders operation inside and move simp operation outside and have that $sdsd...sdr \sim_{m\epsilon} ssddsdsd...sdr \sim_{m\epsilon} ... \sim_{m\epsilon} s....sd....dr$. |
311 |
Using \autoref{lma1} we have that $s...sd....dr = sd...dr$. |
|
312 |
By \autoref{lma2}, we have $RHS \sim_{m\epsilon} d...dr$.\\ |
|
313 |
Notice that we don't actually need \autoref{lma1} here. That is because by \autoref{lma2}, we can have that $s...sd....dr \sim_{m\epsilon} sd...dr$. The equality above can be replaced by mkepsBC |
|
314 |
equivalence without affecting the validity of the whole proof since all we want is mkepsBC equivalence, not equality. |
|
315 |
||
316 |
Now we proceed to prove that $sdr \sim_{m\epsilon} dsr$. This can be reduced to proving $dr \sim_{m\epsilon} dsr$ as we know that $dr \sim_{m\epsilon} sdr$ by \autoref{lma2}.\\ |
|
8 | 317 |
|
318 |
we use an induction proof. Base cases are omitted. Here are the 3 inductive cases. |
|
319 |
\begin{itemize} |
|
320 |
||
10 | 321 |
\item{$r_1+r_2$}\\ |
8 | 322 |
The most difficult case is when $sr1$ and $sr2$ are both ALTS, so that they will be opened up in the flats function and some terms in sr2 might be deleted. Or otherwise we can use the argument that $d(r_1+r_2) = dr_1 + dr_2 \sim_{m\epsilon} dsr_1 + dsr_2 \sim_{m\epsilon} ds(r_1+r_2)$, |
9 | 323 |
the last equivalence being established by \autoref{lma3}. |
8 | 324 |
When $s(r_1), s(r_2)$ are both ALTS, we have to be more careful for the last equivalence step, namelly, $dsr_1 + dsr_2 \sim_{m\epsilon} ds(r_1+r_2)$. \\ |
9 | 325 |
We have that $LHS = dsr_1 + dsr_2 = d(sr_1 +sr_2)$. Since $sr_1 = ALTS(bs1, rs1)$ and $sr_2 = ALTS(bs2, rs2)$ we have $ d(sr_1 +sr_2 ) \sim_{m\epsilon} d(ALTS(bs, bs1>>rs1 ++ bs2>>rs2))$ by \autoref{lma4}. |
326 |
On the other hand, $RHS = ds(ALTS(bs, r1, r2)) = d Co(bs, dB(flats(s(r1), s(r2)) ) ) = d Co(bs, dB(bs1>>rs1 ++ bs2>>rs2))$ by definition of bsimp and flats.\\ |
|
327 |
$d Co(bs, dB(bs1>>rs1 ++ bs2>>rs2)) = d Co(bs, (bs1>>rs1 ++ ((bs2>>rs2)--rs1))) $ by \autoref{lma5}.\\ $d Co(bs, (bs1>>rs1 ++ ((bs2>>rs2)--rs1) )) = d(ALTS(bs, bs1>>rs1 ++ (bs2>>rs2)--rs1))$ by \autoref{lma6}. \\ |
|
328 |
Using \autoref{lma8}, we have $d(ALTS(bs, bs1>>rs1 ++ (bs2>>rs2)--rs1)) \sim_{m\epsilon} d(ALTS(bs, bs1>>rs1 ++ bs2>>rs2)) \sim_{m\epsilon} RHS$.\\ |
|
329 |
%only the last part we don't have an equality here. We use mkeps equivalence instead because these two regexes are indeed different syntactically. However, they have even more in common than just mkeps equal. We might later augment this proof so that this equivalence relation is changed to something like regular expression equivalence. |
|
8 | 330 |
This completes the proof. |
331 |
\item{$r*$}\\ |
|
10 | 332 |
$s(r*) = r*$. Our goal is trivially achieved. |
333 |
\item{$r1 \cdot r2$}\\ |
|
334 |
When r1 is nullable, $ds r1r2 = dsr1 \cdot sr2 + dsr2 \sim_{m\epsilon} dr1 \cdot sr2 + dr2 = dr1 \cdot r2 + dr2 $. The last step uses \autoref{lma10}. |
|
335 |
When r1 is not nullable, $ds r1r2 = dsr1 \cdot sr2 \sim_{m\epsilon} dr1 \cdot sr2 \sim_{m\epsilon} dr1 \cdot r2 $ |
|
8 | 336 |
|
337 |
\end{itemize} |
|
338 |
\item |
|
339 |
Proof of second part of the theorem: use a similar structure of argument as in the first part. |
|
10 | 340 |
|
341 |
\item |
|
342 |
This proof has a major flaw: it assumes all dr is nullable along the path of deriving r by s. But it could be the case that $s\in L(r)$ but $ \exists s' \in Pref(s) \ s.t.\ ders(s', r)$ is not nullable (or equivalently, $s'\notin L(r)$). One remedy for this is to replace the mkepsBC equivalence relation into some other transitive relation that entails mkepsBC equivalence. |
|
8 | 343 |
\end{itemize} |
344 |
\end{proof} |
|
345 |
||
10 | 346 |
\begin{theorem}{ |
347 |
This is a very strong claim that has yet to be more carefully examined and proved. However, experiments suggest a very good hope for this.}\\ |
|
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
348 |
Define pushbits as the following:\\ |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
349 |
\begin{verbatim} |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
350 |
def pushbits(r: ARexp): ARexp = r match { |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
351 |
case AALTS(bs, rs) => AALTS(Nil, rs.map(r=>fuse(bs, pushbits(r)))) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
352 |
case ASEQ(bs, r1, r2) => ASEQ(bs, pushbits(r1), pushbits(r2)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
353 |
case r => r |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
354 |
} |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
355 |
\end{verbatim} |
10 | 356 |
Then we have \mbox{\boldmath$pushbits(ders\_simp(ar, s) ) == simp(ders(ar,s)) \ or\ ders\_simp(ar, s) == simp(ders(ar, s))$}.\\ |
357 |
Unfortunately this does not hold. A counterexample is\\ |
|
358 |
\begin{verbatim} |
|
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
359 |
baa |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
360 |
original regex |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
361 |
STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
362 |
└-ALT |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
363 |
└-STA List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
364 |
| └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
365 |
└-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
366 |
└-b List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
367 |
└-a List(S) |
10 | 368 |
regex after ders simp |
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
369 |
ALT List(S, S, Z, C(b)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
370 |
└-SEQ |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
371 |
| └-STA List(S, Z, S, C(a), S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
372 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
373 |
| └-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
374 |
| └-ALT |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
375 |
| └-STA List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
376 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
377 |
| └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
378 |
| └-b List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
379 |
| └-a List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
380 |
└-SEQ List(S, Z, S, C(a), Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
381 |
└-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
382 |
| └-STA List(Z, S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
383 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
384 |
| └-ONE List(S, S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
385 |
└-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
386 |
└-ALT |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
387 |
└-STA List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
388 |
| └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
389 |
└-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
390 |
└-b List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
391 |
└-a List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
392 |
regex after ders |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
393 |
ALT |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
394 |
└-SEQ |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
395 |
| └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
396 |
| | └-SEQ List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
397 |
| | | └-ZERO |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
398 |
| | | └-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
399 |
| | | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
400 |
| | └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
401 |
| | └-ZERO |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
402 |
| | └-ZERO |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
403 |
| └-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
404 |
| └-ALT |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
405 |
| └-STA List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
406 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
407 |
| └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
408 |
| └-b List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
409 |
| └-a List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
410 |
└-ALT List(S, S, Z, C(b)) |
10 | 411 |
└-SEQ |
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
412 |
| └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
413 |
| | └-ALT List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
414 |
| | | └-SEQ |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
415 |
| | | | └-ZERO |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
416 |
| | | | └-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
417 |
| | | | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
418 |
| | | └-SEQ List(S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
419 |
| | | └-ONE List(S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
420 |
| | | └-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
421 |
| | | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
422 |
| | └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
423 |
| | └-ZERO |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
424 |
| | └-ZERO |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
425 |
| └-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
426 |
| └-ALT |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
427 |
| └-STA List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
428 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
429 |
| └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
430 |
| └-b List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
431 |
| └-a List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
432 |
└-SEQ List(S, Z, S, C(a), Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
433 |
└-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
434 |
| └-SEQ List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
435 |
| | └-ONE List(S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
436 |
| | └-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
437 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
438 |
| └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
439 |
| └-ZERO |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
440 |
| └-ONE List(S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
441 |
└-STA |
10 | 442 |
└-ALT |
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
443 |
└-STA List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
444 |
| └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
445 |
└-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
446 |
└-b List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
447 |
└-a List(S) |
10 | 448 |
regex after ders and then a single simp |
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
449 |
ALT |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
450 |
└-SEQ List(S, S, Z, C(b)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
451 |
| └-STA List(S, Z, S, C(a), S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
452 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
453 |
| └-STA |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
454 |
| └-ALT |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
455 |
| └-STA List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
456 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
457 |
| └-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
458 |
| └-b List(Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
459 |
| └-a List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
460 |
└-SEQ List(S, S, Z, C(b), S, Z, S, C(a), Z) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
461 |
└-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
462 |
| └-STA List(Z, S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
463 |
| | └-a |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
464 |
| └-ONE List(S, S, C(a)) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
465 |
└-STA |
10 | 466 |
└-ALT |
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
467 |
└-STA List(Z) |
10 | 468 |
| └-a |
11
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
469 |
└-ALT List(S) |
9c1ca6d6e190
The C(Char) construct is incompatible with the code and retrieve in Fahad's thesis.
Chengsong
parents:
10
diff
changeset
|
470 |
└-b List(Z) |
10 | 471 |
└-a List(S) |
472 |
\end{verbatim} |
|
473 |
\end{theorem} |
|
474 |
||
8 | 475 |
\end{document} |
476 |
||
477 |
%The second part might still need some more development. |
|
478 |
%When s is not in the set L(ar), we have that s = s1@s2 s.t. s1 $\in$ L(ar), and any longer string that is a prefix of s does not belong to L(ar).\\ |
|
479 |
%By first part of proof, we have ders(ar, s1) $\sim_{m\epsilon}$ ders\_simp(ar, s1) |
|
480 |
%.....somehow show that by correctness, der(c, ders\_simp(ar, s1)) must be not nullable. But this will need that L(ders(ar, s1)) == L(ders\_simp(ar, s1)). By part 1 of proof we only have that for any string s1c s.t. s1c $\in$ L(ar) (which is equivalent to s $\in$ L(ders(ar, s1))), s is also in L(ders\_simp(ar, s1)). That is an inclusion, not an equality. c not in L(ders(ar, s1)) does not imply c not in L(ders\_simp(ar, s1)) |
|
481 |
%So this path stuck here. |