From: Ulya Trofimovich Date: Mon, 18 Jun 2018 22:14:22 +0000 (+0100) Subject: Paper: added an example of IRE construction. X-Git-Tag: 1.1~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c83179e53bb1c0d839b3a402767b590d27da0386;p=re2c Paper: added an example of IRE construction. --- diff --git a/re2c/doc/tdfa_v2/img/trees.tex b/re2c/doc/tdfa_v2/img/trees.tex index c26a9cd7..34ff56ec 100644 --- a/re2c/doc/tdfa_v2/img/trees.tex +++ b/re2c/doc/tdfa_v2/img/trees.tex @@ -9,13 +9,14 @@ \usegdlibrary{trees} \usepackage{stix} +\newcommand{\IRE}{I\!RE} \begin{document} %\begin{tikzpicture}[>=stealth, every node/.style={rectangle, rounded corners, draw, minimum size=0.1in}] \begin{tikzpicture}[>=stealth, every node/.style={draw=none, minimum size=0.1}] -\begin{scope}[xshift=2in] +\begin{scope}[xshift=2.5in] % \node [rectangle, rounded corners, draw, minimum width=3.7in, minimum height=1.9in, yshift=-0.7in] {}; % \node[yshift=0.3in, draw=none] {$t_1: T(T(\varnothing, T(a)), T(\varnothing))$}; \graph [tree layout, grow=down, fresh nodes] { @@ -36,20 +37,9 @@ }; \node[xshift=0in, yshift=-1.5in, draw=none] {\small{$ - \Big(1, 1, - \big(2, 2, - (0, 0, \epsilon ) \mid - (0, 0, - (0, 0, a)^{0, \infty} - ) - \big) \cdot - \big(3, 0, - (4, 3, - (0, 0, a) \mid - (0, 0, \epsilon) - )^{0, \infty} - \big) - \Big)$}}; + \IRE ((\epsilon|a^{0,\infty})(\epsilon|a)^{0,\infty} )) = (1,1,(2,2,(0,0,\epsilon) \mid (0,0,(0,0,a)^{0,\infty})) + \cdot (3,0,(4,3,(0,0,\epsilon) \mid (0,0,a))^{0,\infty})) + $}}; % \node[xshift=0in, yshift=-1.7in, draw=none] {$(\epsilon | a^{0,\infty})(a | \epsilon)^{0,\infty}$}; \end{scope} diff --git a/re2c/doc/tdfa_v2/part_1_tnfa.tex b/re2c/doc/tdfa_v2/part_1_tnfa.tex index ee2fac64..69f6ca9b 100644 --- a/re2c/doc/tdfa_v2/part_1_tnfa.tex +++ b/re2c/doc/tdfa_v2/part_1_tnfa.tex @@ -407,29 +407,92 @@ we can transform IRE back to RE by erasing all indices and adding parentheses around subexpressions with nonzero explicit submatch index. Therefore RE and IRE are equivalent representations. -\\ +% +Below is an example of IRE construction for RE $(\epsilon|a^{0,\infty})(\epsilon|a)^{0,\infty} )$ +(the resulting IRE can be seen on figure \ref{fig_parse_trees}): -Just like REs denote sets of PTs, IREs denote sets of \emph{IPTs} --- \emph{indexed parse trees}, -which are exactly like PTs except that each IPT is superscripted with -the implicit submatch index inherited from the corresponding IRE node. + \begin{align*} + &\begin{aligned} + & mark ( (\epsilon|a^{0,\infty})(\epsilon|a)^{0,\infty} ) ) = \big[ \\ + % + & \quad mark ( (\epsilon|a^{0,\infty}) ) = \big[ \\ + & \quad mark ( \epsilon|a^{0,\infty} ) = \big[ \\ + & \quad\quad\quad mark ( \epsilon ) = (0,0,\epsilon), \\ + & \quad\quad\quad mark ( a^{0,\infty} ) = \big[ \\ + & \quad\quad\quad\quad mark ( a ) = (0,0,a) \\ + & \quad\quad\quad \big] = (0,0,(0,0,a)^{0,\infty}) \\ + & \quad\quad \big] = (0,0,(0,0,\epsilon) \mid (0,0,(0,0,a)^{0,\infty})) \\ + & \quad \big] = (1,1,(0,0,\epsilon)|(0,0,(0,0,a)^{0,\infty})) \\ + % + & \quad mark ( (\epsilon|a)^{0,\infty} ) = \big[ \\ + & \quad\quad mark ( (\epsilon|a) ) = \big[ \\ + & \quad\quad\quad mark ( \epsilon|a ) = \big [ \\ + & \quad\quad\quad\quad mark ( \epsilon ) = (0,0,\epsilon) \\ + & \quad\quad\quad\quad mark ( a ) = (0,0,a) \\ + & \quad\quad\quad \big] = (0,0,(0,0,\epsilon)|(0,0,a)) \\ + & \quad\quad \big] = (1,1,(0,0,\epsilon) \mid (0,0,a)) \\ + & \quad \big] = (1,0,(1,1,(0,0,\epsilon) \mid (0,0,a))^{0,\infty}) \\ + % + & \big] = (1,1, + (1,1,(0,0,\epsilon) \mid (0,0,(0,0,a)^{0,\infty})) \\ + & \quad\quad\quad \cdot (1,0,(1,1,(0,0,\epsilon) \mid (0,0,a))^{0,\infty}) + ) + \end{aligned} + % + &&\begin{aligned} + & enum (1,1,(1,1, + (1,1,(0,0,\epsilon) \mid (0,0,(0,0,a)^{0,\infty})) \\ + & \quad\quad\quad\quad\quad \cdot (1,0,(1,1,(0,0,\epsilon) \mid (0,0,a))^{0,\infty}))) = \big[ \\ + & \quad enum (2,2,(1,1,(0,0,\epsilon) \mid (0,0,(0,0,a)^{0,\infty}))) = \big[ \\ + & \quad\quad enum (3,3,(0,0,\epsilon)) = (3,3,(0,0,\epsilon)) \\ + & \quad\quad enum (3,3,(0,0,(0,0,a)^{0,\infty})) = \big[ \\ + & \quad\quad\quad enum (3,3,(0,0,a)) = (3,3,(0,0,a)) \\ + & \quad\quad \big] = (3,3,(0,0,(0,0,a)^{0,\infty})) \\ + & \quad \big] = (3,3,(2,2,(0,0,\epsilon) \mid (0,0,(0,0,a)^{0,\infty}))) \\ + % + & \quad enum (3,3, (1,0,(1,1,(0,0,\epsilon) \mid (0,0,a))^{0,\infty}) ) = \big[ \\ + & \quad\quad enum (4,3, (1,1,(0,0,\epsilon) \mid (0,0,a)) ) = \big[ \\ + & \quad\quad\quad enum (5,4, (0,0,\epsilon) ) = (0,0,\epsilon) \\ + & \quad\quad\quad enum (5,4, (0,0,a) ) = (0,0,a) \\ + & \quad\quad \big] = (5,4,(4,3,(0,0,\epsilon) \mid (0,0,a))) \\ + & \quad \big] = (5,4,(3,0,(4,3,(0,0,\epsilon) \mid (0,0,a))^{0,\infty})) \\ + % + & \big] = (5,4,(1,1, + (2,2,(0,0,\epsilon) \mid (0,0,(0,0,a)^{0,\infty})) \\ + & \quad\quad\quad\quad\quad \cdot (3,0,(4,3,(0,0,\epsilon) \mid (0,0,a))^{0,\infty}) + )) + \end{aligned} + \end{align*} + +Just like REs denote sets of PTs, IREs denote sets of \emph{IPTs} --- \emph{indexed parse trees}. +The only difference between PTs and IPTs is that each node of an IPT has an associated number --- +the implicit submatch index inherited from the corresponding IRE node (denoted with a superscript). Explicit submatch index is not used in IPTs. -The set of all IPTs is denoted $\XIT$. -% -% \begin{Xdef} -% \emph{Parse trees (PT)} over finite alphabet $\Sigma$, denoted $\XT_\Sigma$, are: -% \begin{enumerate} -% \item Atomic PT: -% \emph{nil tree} ${\varnothing}^i \in \XT_\Sigma$, -% \emph{empty tree} ${\epsilon}^i \in \XT_\Sigma$ and -% \emph{unit tree} ${\alpha}^i \in \XT_\Sigma$, where $\alpha \in \Sigma$ and $i \in \YZ$. -% \item Compound PT: if $t_1, \dots, t_n \in \XT_\Sigma$, where $n \geq 1$, and $i \in \YZ$, then -% ${T}^i(t_1, \dots, t_n) \in \XT_\Sigma$. -% \end{enumerate} -% \end{Xdef} -% -The operator $\IPT: \XIR_\Sigma \rightarrow 2^{\XIT_\Sigma}$ gives the set of all IPTs denoted by the given IRE -(its definition is very similar to the one of operator $PT$): + \begin{Xdef} + \emph{Indexed parse trees (IPT)} over finite alphabet $\Sigma$, denoted $\XIT_\Sigma$, are: + \begin{enumerate} + \item Atomic IPTs: + \emph{nil tree} ${\varnothing}^i \in \XIT_\Sigma$, + \emph{empty tree} ${\epsilon}^i \in \XIT_\Sigma$ and + \emph{unit tree} ${\alpha}^i \in \XIT_\Sigma$, where $\alpha \in \Sigma$ and $i \in \YZ$. + \item Compound IPTs: if $t_1, \dots, t_n \in \XIT_\Sigma$, where $n \geq 1$, and $i \in \YZ$, then + ${T}^i(t_1, \dots, t_n) \in \XIT_\Sigma$. + \end{enumerate} + \end{Xdef} + +\iffalse +\begin{figure}\label{fig_mark_enum} +\includegraphics[width=\linewidth]{img/mark_enum.pdf} +\caption{ +The process of constructing IRE for RE $(\epsilon|a^{0,\infty})(\epsilon|a)^{0,\infty} )$ +and the result visualized as a tree. +} +\end{figure} +\fi + +The operator $\IPT: \XIR_\Sigma \rightarrow 2^{\XIT_\Sigma}$ gives the set of all IPTs denoted by the given IRE: +%(its definition is very similar to the one of operator $PT$): \begin{align*} \IPT\big((i, \Xund, \epsilon)\big) &= \{ {\epsilon}^{i} \} \\