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