ChengsongTanPhdThesis/Chapters/Chapter5.tex
changeset 520 26584b9d47f4
equal deleted inserted replaced
519:856d025dbc15 520:26584b9d47f4
       
     1 % Chapter Template
       
     2 
       
     3 \chapter{A Better Bound and Other Extensions} % Main chapter title
       
     4 
       
     5 \label{Chapter5} %In Chapter 5\ref{Chapter5} we discuss stronger simplifications to improve the finite bound
       
     6 %in Chapter 4 to a polynomial one, and demonstrate how one can extend the
       
     7 %algorithm to include constructs such as bounded repetitions and negations.
       
     8  
       
     9 %----------------------------------------------------------------------------------------
       
    10 %	SECTION strongsimp
       
    11 %----------------------------------------------------------------------------------------
       
    12 \section{A Stronger Version of Simplification Inspired by Antimirov}
       
    13 %TODO: search for isabelle proofs of algorithms that check equivalence 
       
    14 
       
    15 
       
    16 
       
    17 %----------------------------------------------------------------------------------------
       
    18 %	SECTION 1
       
    19 %----------------------------------------------------------------------------------------
       
    20 
       
    21 \section{Adding Support for the Negation Construct, and its Correctness Proof}
       
    22 We now add support for the negation regular expression:
       
    23 \[			r ::=   \ZERO \mid  \ONE
       
    24 			 \mid  c  
       
    25 			 \mid  r_1 \cdot r_2
       
    26 			 \mid  r_1 + r_2   
       
    27 			 \mid r^*    
       
    28 			 \mid \sim r
       
    29 \]
       
    30 The $\textit{nullable}$ function's clause for it would be 
       
    31 \[
       
    32 \textit{nullable}(~r) = \neg \nullable(r)
       
    33 \]
       
    34 The derivative would be
       
    35 \[
       
    36 ~r \backslash c = ~ (r \backslash c)
       
    37 \]
       
    38  
       
    39 The most tricky part of lexing for the $~r$ regex
       
    40  is creating a value for it.
       
    41  For other regular expressions, the value aligns with the 
       
    42  structure of the regex:
       
    43  \[
       
    44  \vdash \Seq(\Char(a), \Char(b)) : a \cdot b
       
    45  \]
       
    46 But for the $~r$ regex, $s$ is a member of it if and only if
       
    47 $s$ does not belong to $L(r)$. 
       
    48 That means when there
       
    49 is a match for the not regex, it is not possible to generate how the string $s$ matched
       
    50 with $r$. 
       
    51 What we can do is preserve the information of how $s$ was not matched by $r$,
       
    52 and there are a number of options to do this.
       
    53 
       
    54 We could give a partial value when there is a partial match for the regex inside
       
    55 the $\mathbf{not}$ construct.
       
    56 For example, the string $ab$ is not in the language of $(a\cdot b) \cdot c$,
       
    57 A value for it could be 
       
    58  \[
       
    59  \vdash \textit{Not}(\Seq(\Char(a), \Char(b))) : ~((a \cdot b ) \cdot c)
       
    60  \]
       
    61  The above example demonstrates what value to construct 
       
    62  when the string $s$ is at most a real prefix
       
    63  of the strings in $L(r)$. When $s$ instead is not a prefix of any strings
       
    64  in $L(r)$, it becomes unclear what to return as a value inside the $\textit{Not}$
       
    65  constructor.
       
    66  
       
    67  Another option would be to either store the string $s$ that resulted in 
       
    68  a mis-match for $r$ or a dummy value as a placeholder:
       
    69  \[
       
    70  \vdash \textit{Not}(abcd) : ~(a^*)
       
    71  \]
       
    72 or
       
    73  \[
       
    74  \vdash \textit{Not}(\textit{Dummy}) : ~(a^*)
       
    75  \] 
       
    76  We choose to implement this as it is most straightforward:
       
    77  \[
       
    78  \mkeps(~(r))  = \textit{if}(\nullable(r)) \; \textit{Error} \; \textit{else} \; \textit{Not}(\textit{Dummy})
       
    79  \]
       
    80  
       
    81 %----------------------------------------------------------------------------------------
       
    82 %	SECTION 2
       
    83 %----------------------------------------------------------------------------------------
       
    84 
       
    85 \section{Bounded Repetitions}
       
    86 
       
    87