ChengsongTanPhdThesis/Chapters/Bitcoded1.tex
changeset 536 aff7bf93b9c7
parent 532 cc54ce075db5
child 537 50e590823220
equal deleted inserted replaced
535:ce91c29d2885 536:aff7bf93b9c7
   391 \end{center}
   391 \end{center}
   392 
   392 
   393 \noindent
   393 \noindent
   394 This algorithm keeps the regular expression size small, for example,
   394 This algorithm keeps the regular expression size small, for example,
   395 with this simplification our previous $(a + aa)^*$ example's 8000 nodes
   395 with this simplification our previous $(a + aa)^*$ example's 8000 nodes
   396 will be reduced to just 6 and stays constant, no matter how long the
   396 will be reduced to just 17 and stays constant, no matter how long the
   397 input string is.
   397 input string is.
   398 
   398 
   399 
   399 
   400 
   400 
   401 
   401 
   425 \section{Correctness of Bit-coded Algorithm (Without Simplification)}
   425 \section{Correctness of Bit-coded Algorithm (Without Simplification)}
   426 We now give the proof the correctness of the algorithm with bit-codes.
   426 We now give the proof the correctness of the algorithm with bit-codes.
   427 
   427 
   428 Ausaf and Urban cleverly defined an auxiliary function called $\flex$,
   428 Ausaf and Urban cleverly defined an auxiliary function called $\flex$,
   429 defined as
   429 defined as
   430 \[
   430 \begin{center}
   431 \flex \; r \; f \; [] \; v \; = \; f\; v
   431 \begin{tabular}{lcr}
   432 \flex \; r \; f \; c :: s \; v =  \flex r \; \lambda v. \, f (\inj \; r\; c\; v)\; s \; v
   432 $\flex \; r \; f \; [] \; v$       &  $=$ &   $f\; v$\\
   433 \]
   433 $\flex \; r \; f \; c :: s \; v$ &  $=$ &   $\flex \; r \; \lambda v. \, f (\inj \; r\; c\; v)\; s \; v$
       
   434 \end{tabular}
       
   435 \end{center}
   434 which accumulates the characters that needs to be injected back, 
   436 which accumulates the characters that needs to be injected back, 
   435 and does the injection in a stack-like manner (last taken derivative first injected).
   437 and does the injection in a stack-like manner (last taken derivative first injected).
   436 $\flex$ is connected to the $\lexer$:
   438 $\flex$ is connected to the $\lexer$:
   437 \begin{lemma}
   439 \begin{lemma}
   438 $\flex \; r \; \textit{id}\; s \; \mkeps (r\backslash s) = \lexer \; r \; s$
   440 $\flex \; r \; \textit{id}\; s \; \mkeps (r\backslash s) = \lexer \; r \; s$