Skip to content

Commit

Permalink
update pairing function
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Jun 16, 2024
1 parent cdd14c8 commit adcb90a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
Binary file modified latex/lafi2024/acmart.pdf
Binary file not shown.
43 changes: 30 additions & 13 deletions latex/lafi2024/acmart.tex
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
\end{footnotesize}
\end{equation*}

\noindent This initializes the superdiagonal entries, enabling us to compute the fixpoint $M_\infty$ by redefining $\oplus, \otimes: \mathbb{T}_3 \times \mathbb{T}_3 \rightarrow \mathbb{T}_3$ as:
\noindent This initializes the superdiagonal, enabling us to compute the fixpoint $M_\infty$ by redefining $\oplus, \otimes: \mathbb{T}_3 \times \mathbb{T}_3 \rightarrow \mathbb{T}_3$ as:

\begin{equation*}
\begin{footnotesize}
Expand Down Expand Up @@ -210,7 +210,7 @@ \subsection{Sampling trees with replacement}\label{sec:replacement}
\caption{A partial $\mathbb{T}_2$ for the grammar with productions $P=\{S \rightarrow BC \mid \ldots \mid AB, B\rightarrow RD \mid \ldots, A\rightarrow QC \mid \ldots\}$.}
\end{figure}

The number of binary trees inhabiting a single instance of $\mathbb{T}_2$ is sensititive to the number of nonterminals and rule expansions in the grammar. To obtain the total number of trees with breadth $n$, we abstractly parse the porous string using the algebra defined in \S~\ref{sec:method}, letting $T=\Lambda_{\underline\sigma}^* \circ S$, and compute the total number of trees using the recurrence:
To obtain the total number of trees with breadth $n$, we abstractly parse the porous string using the algebra defined in \S~\ref{sec:method}, and compute the total number of trees using:

\begin{equation*}
|T: \mathbb{T}_2| \mapsto \begin{cases}
Expand All @@ -223,18 +223,35 @@ \subsection{Sampling trees with replacement}\label{sec:replacement}
To sample all trees in a given $T: \mathbb{T}_2$ uniformly without replacement, we then construct a modular pairing function $\varphi: \mathbb{T}_2 \rightarrow \mathbb{Z}_{|T|} \rightarrow \texttt{BTree}$, which is defined as follows:

\begin{small}
\begin{equation*}
\varphi(T: \mathbb{T}_2, i: \mathbb{Z}_{|T|}) \mapsto \begin{cases}
\Big\langle\texttt{BTree}\big(\texttt{root}(T)\big), i\Big\rangle & \text{if $T$ is a leaf,} \vspace{5pt}\\
\text{Let } b = |\texttt{children}(T)|,\\
\phantom{\text{Let }} q_1, r=\big\langle\lfloor\frac{i}{b}\rfloor, i \pmod{b}\big\rangle,\\
\phantom{\text{Let }} lb, rb = \texttt{children}[r],\\
\phantom{\text{Let }} T_1, q_2 = \varphi(lb, q_1),\\
\phantom{\text{Let }} T_2, q_3 = \varphi(rb, q_2) \text{ in } \\
\Big\langle\texttt{BTree}\big(\texttt{root}(T), T_1, T_2\big), q_3\Big\rangle & \text{otherwise.} \\
\end{cases}
\begin{equation*}\label{eq:pairing}
\varphi(T: \mathbb{T}_2, i: \mathbb{Z}_{|T|}) \mapsto \begin{cases}
\texttt{BTree}\big(\texttt{root}(T)\big) \text{ if $T$ is a leaf,} \vspace{5pt}\\
\text{Let } r = |\texttt{children}(T)|,\\
\phantom{\text{Let }} F(n) = \sum_{\langle l, r\rangle \in \texttt{children}[0 \ldots n]}}|l|\cdot|r|,\\
\phantom{\text{Let }} F^{-1}(u)=\inf \big\{x \mid u \leq F(x)\big\},\\
\phantom{\text{Let }} q=i - F(F^{-1}(i)),\\
\phantom{\text{Let }} l, r = \texttt{children}[t],\\
\phantom{\text{Let }} q_1, q_2 =\big\langle\lfloor\frac{q}{|r|}\rfloor, q \pmod{|r|}\big\rangle,\\
\phantom{\text{Let }} T_1 = \varphi(l, q_1),\\
\phantom{\text{Let }} T_2 = \varphi(r, q_2) \text{ in } \\
\texttt{BTree}\big(\texttt{root}(T), T_1, T_2\big) \text{ otherwise.} \\
\end{cases}
\end{equation*}
\end{small}
\begin{small}

%\begin{small}
%\begin{equation*}
% \varphi(T: \mathbb{T}_2, i: \mathbb{Z}_{|T|}) \mapsto \begin{cases}
% \Big\langle\texttt{BTree}\big(\texttt{root}(T)\big), i\Big\rangle & \text{if $T$ is a leaf,} \vspace{5pt}\\
% \text{Let } b = |\texttt{children}(T)|,\\
% \phantom{\text{Let }} q_1, r=\big\langle\lfloor\frac{i}{b}\rfloor, i \pmod{b}\big\rangle,\\
% \phantom{\text{Let }} lb, rb = \texttt{children}[r],\\
% \phantom{\text{Let }} T_1, q_2 = \varphi(lb, q_1),\\
% \phantom{\text{Let }} T_2, q_3 = \varphi(rb, q_2) \text{ in } \\
% \Big\langle\texttt{BTree}\big(\texttt{root}(T), T_1, T_2\big), q_3\Big\rangle & \text{otherwise.} \\
% \end{cases}
%\end{equation*}
%\end{small}

Then, instead of sampling trees, we can simply sample integers uniformly without replacement from $\mathbb{Z}_{|T|}$ using the construction defined in \S~\ref{sec:method}, and lazily decode them into trees.

Expand Down
2 changes: 1 addition & 1 deletion latex/splash2024/splash.tex
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@
L(p) = 1 + p L(p) \phantom{addspace} P(a) = \Sigma + V + V L\big(V^2P(a)^2\big)
\end{equation}

Depicted in Fig.~\ref{fig:ptree} is a partial $\mathbb{T}_2$, where red nodes are \texttt{root}s and blue nodes are \texttt{children}. The shape of type $\mathbb{T}_2$ is congruent with an acyclic CFG in Chomsky Normal Form, i.e., $\mathbb{T}_2\cong\mathcal{G}'$, so assuming the CFG recognizes a finite language, as is the case for $G_\cap'$, we can translate it directly. If the language is infinite, we slice the CFL, $\mathcal{L}(G)\cap \Sigma^n$, and compute the fixpoint for each slice.
Depicted in Fig.~\ref{fig:ptree} is a partial $\mathbb{T}_2$, where red nodes are \texttt{root}s and blue nodes are \texttt{children}. The shape of type $\mathbb{T}_2$ is congruent with an acyclic CFG in Chomsky Normal Form, i.e., $\mathbb{T}_2\cong\mathcal{G}'$, so assuming the CFG recognizes a finite language, as is the case for $G_\cap'$, we can translate it directly. If the language is infinite, we slice the CFL, $\mathcal{L}(G)\cap \Sigma^n$, and solve the fixpoint for each slice $n \in [2, n]$.

Given a porous string $\sigma: \underline\Sigma^n$ representing the slice, we can construct $\mathbb{T}_2$ from the bottom-up, and read off structures from the top-down. We construct the first upper diagonal $\hat\sigma_r = \Lambda(\sigma_r)$ as follows:

Expand Down

0 comments on commit adcb90a

Please sign in to comment.