More revision of OnePass per @atri 020421 comments/feedback

master
Aaron Huber 2021-02-05 11:43:01 -05:00
parent c302088621
commit 3b6dbf35d9
4 changed files with 95 additions and 70 deletions

View File

@ -29,29 +29,29 @@ We now introduce useful definitions and notation related to polynomials. We use
%\end{Definition}
%Note that $\circuit$ need not encode an expression in the standard monomial basis. For instance, $\circuit$ could represent a compressed form of the polynomial in~\Cref{eq:poly-eg}, such as $(x + 2y)(2x - y)$.
\revision{
\begin{Definition}[$\polyf(\cdot)$]\label{def:poly-func}
Denote \revision{$\polyf(\circuit)$}~ to be the function from circuit \revision{$\circuit$}~ to its corresponding polynomial. $\polyf(\cdot)$ is recursively defined on \revision{$\circuit$}~ as follows, with addition and multiplication following the standard interpretation for polynomials:
\begin{equation*}
\polyf(\revision{\circuit}) = \begin{cases}
\polyf(\revision{\circuit_\lchild}) + \polyf(\revision{\circuit_\rchild}) &\text{ if \revision{\circuit}.\type } = \revision{\circplus}\\
\polyf(\revision{\circuit_\lchild}) \cdot \polyf(\revision{\circuit_\rchild}) &\text{ if \revision{\circuit}.\type } = \revision{\circmult}\\
\revision{\circuit.\val} &\text{ if \revision{\circuit}.\type } = \var \text{ OR } \tnum.
\end{cases}
\end{equation*}
\begin{Definition}[Reduced Polynomial]
For an arbitrary polynomial $\poly$, we say that $\poly$ is reduced when all exponents $e$ occurring throughout the monomials of $\poly$ such that $e > 1$ are \textit{reduced} to $1$.
\end{Definition}
\begin{Definition}[Pure Expansion]
The pure expansion of a polynomial $\poly$ is formed by computing all product of sums occurring in $\poly$, without combining like monomials. The pure expansion of $\poly$ generalizes ~\Cref{def:smb} by allowing monomials $m_i = m_j$ for $i \neq j$.
\end{Definition}
}
\begin{Definition}[Expanded \revision{\circuit}]\label{def:expand-circuit}
\revision{$\expansion{\circuit}$} is the reduced sum of products expansion of $\revision{\circuit}$.
The logical view of \revision{\expansion{\circuit}} is a list of tuples $(\monom, \coef)$, where $\monom$ is a set of variables and $\coef$ is in $\reals$.
\revision{\expansion{\circuit}} has the following recursive definition ($\circ$ is list concatenation).
\revision{$\expansion{\circuit}$} is the reduced pure expansion of $\revision{\circuit}$.
The logical view of \revision{$\expansion{\circuit}$} is a list of tuples $(\monom, \coef)$, where $\monom$ is a set of variables and $\coef$ is in $\reals$.
\revision{$\expansion{\circuit}$} has the following recursive definition ($\circ$ is list concatenation).
{\small
\begin{multline*}
\expansion{\circuit} =
\begin{cases}
\revision{\expansion{\circuit_\lchild} \circ \expansion{\circuit_\rchild}} &\textbf{ if }\revision{\circuit.\type = \circplus}\\
\left\{(\monom_\lchild \cup \monom_\rchild, \coef_\lchild \cdot \coef_\rchild) ~|~\right.&\\ \quad \left.(\monom_\lchild, \coef_\lchild) \in \revision{\expansion{\circuit_\lchild}}, (\monom_\rchild, \coef_\rchild) \in \revision{\expansion{\circuit_\rchild}}\right\} &\textbf{ if }\revision{\circuit.\type = \circmult}\\
\revision{\expansion{\circuit_\linput} \circ \expansion{\circuit_\rinput}} &\textbf{ if }\revision{\circuit.\type = \circplus}\\
\left\{(\monom_\linput \cup \monom_\rinput, \coef_\linput \cdot \coef_\rinput) ~|~\right.&\\ \quad \left.(\monom_\linput, \coef_\linput) \in \revision{\expansion{\circuit_\linput}}, (\monom_\rinput, \coef_\rinput) \in \revision{\expansion{\circuit_\rinput}}\right\} &\textbf{ if }\revision{\circuit.\type = \circmult}\\
\elist{(\emptyset, \revision{\circuit.\val})} &\textbf{ if }\revision{\circuit}.\type = \tnum\\
\elist{(\{\revision{\circuit}.\val\}, 1)} &\textbf{ if }\revision{\circuit}.\type = \var.\\
\end{cases}
@ -101,7 +101,7 @@ Note, however, that unlike $\rpoly$, $\expansion{\circuit}$ does not need to be
};
% \node[below=2pt of neg-leaf, inner sep=1pt, blue] (neg-comment) {\textbf{Negation pushed to leaf nodes}};
% \draw[<-|, blue] (neg-leaf) -- (neg-comment);
\node[above right=0.7cm of TR, highlight_color, inner sep=0pt, font=\bfseries] (tr-label) {$\circuit_\rchild$};
\node[above right=0.7cm of TR, highlight_color, inner sep=0pt, font=\bfseries] (tr-label) {$\circuit_\rinput$};
\node[above right=0.7cm of root, highlight_color, inner sep=0pt, font=\bfseries] (t-label) {$\circuit$};
\draw[<-|, highlight_color] (TR) -- (tr-label);
\draw[<-|, highlight_color] (root) -- (t-label);
@ -128,6 +128,19 @@ Using the same factorization from ~\Cref{example:expr-tree-T}, $\polyf(\abs{\cir
Given an expression tree $\circuit$ and a valuation $\vct{a} \in \mathbb{R}^\numvar$, we define the evaluation of $\circuit$ on $\vct{a}$ as $\circuit(\vct{a}) = \polyf(\circuit)(\vct{a})$.
\end{Definition}
\begin{Definition}[\size($\cdot$)]
The function \size~ takes a circuit $\circuit$ or expression tree $\etree$ as input and outputs the number of gates (nodes) in \circuit(\etree).
\end{Definition}
\begin{Definition}[\depth($\cdot$)]
The function \depth~ has input of either circuit $\circuit$ or expression tree $\etree$ and outputs the depth of \circuit(\etree).
\end{Definition}
\begin{Definition}[Subcircuit]
A subcircuit of a circuit $\circuit$ is a circuit \subcircuit such that the underlying DAG of \subcircuit is a \textit{subgraph} of the DAG representing \circuit.
\end{Definition}
}
\subsection{Our main result}
@ -140,7 +153,7 @@ Let \revision{\circuit be a circuit} for a UCQ over \bi and define $\poly(\vct{X
%Let $\poly(\vct{X})$ be a query polynomial corresponding to the output of a UCQ in a \bi.
Then an estimate $\mathcal{E}$ %=\approxq(\circuit, P_1,\dots,p_\numvar), \conf, \error')$
of $\rpoly(\prob_1,\ldots, \prob_\numvar)$ can be computed in time
\[O\left(\revision{\size(\circuit)} + \frac{\log{\frac{1}{\conf}}\cdot \abs{\circuit}^2(1,\ldots, 1)\cdot k\cdot \log{k} \cdot depth(\circuit))}{\inparen{\error'}^2\cdot\rpoly^2(\prob_1,\ldots, \prob_\numvar)}\right)\]
\[O\left(\revision{\size(\circuit)} + \frac{\log{\frac{1}{\conf}}\cdot \abs{\circuit}^2(1,\ldots, 1)\cdot k\cdot \log{k} \cdot \depth(\circuit))}{\inparen{\error'}^2\cdot\rpoly^2(\prob_1,\ldots, \prob_\numvar)}\right)\]
such that
\begin{equation}
\label{eq:approx-algo-bound}
@ -164,7 +177,7 @@ Given an expression tree $\circuit$, define
\begin{Corollary}
\label{cor:approx-algo-const-p}
Let $\poly(\vct{X})$ be as in~\Cref{lem:approx-alg} and let $\gamma=\gamma(\circuit)$. Further let it be the case that $\prob_i\ge \prob_0$ for all $i\in[\numvar]$. Then an estimate $\mathcal{E}$ of $\rpoly(\prob_1,\ldots, \prob_\numvar)$ satisfying~\Cref{eq:approx-algo-bound} can be computed in time
\[O\left(\revision{\size(\circuit)} + \frac{\log{\frac{1}{\conf}}\cdot k\cdot \log{k} \cdot depth(\circuit))}{\inparen{\error'}^2\cdot(1-\gamma)^2\cdot \prob_0^{2k}}\right)\]
\[O\left(\revision{\size(\circuit)} + \frac{\log{\frac{1}{\conf}}\cdot k\cdot \log{k} \cdot \depth(\circuit))}{\inparen{\error'}^2\cdot(1-\gamma)^2\cdot \prob_0^{2k}}\right)\]
In particular, if $\prob_0>0$ and $\gamma<1$ are absolute constants then the above runtime simplifies to $O_k\left(\frac 1{\inparen{\error'}^2}\cdot\size(\circuit)\cdot \log{\frac{1}{\conf}}\right)$.
\end{Corollary}
@ -331,7 +344,7 @@ we first state the lemmas that summarize the relevant properties of $\onepass$ a
\begin{Lemma}\label{lem:one-pass}
The $\onepass$ function completes in $O(size(\circuit))$ time. $\onepass$ guarantees two post conditions: First, for each subcircuit $\vari{S}$ of $\circuit$, we have that $\vari{S}.\vari{partial}$ is set to $\abs{\vari{S}}(1,\ldots, 1)$. Second, when $\vari{S}.\type = \circplus$, for each $\vari{child}$ of $\vari{S}$, $\vari{child}.\vari{weight}$ is set to $\frac{\abs{\vari{S}_{\vari{child}}}(1,\ldots, 1)}{\abs{\vari{S}}(1,\ldots, 1)}$. % is correctly computed for each child of $\vari{S}.$
The $\onepass$ function completes in $O(size(\circuit))$ time. $\onepass$ guarantees two post conditions: First, for each subcircuit $\vari{S}$ of $\circuit$, we have that $\vari{S}.\vari{partial}$ is set to $\abs{\vari{S}}(1,\ldots, 1)$. Second, when $\vari{S}.\type = \circplus$, for each $\vari{input}$ of $\vari{S}$, $\vari{input}.\vari{weight}$ is set to $\frac{\abs{\vari{S}_{\vari{input}}}(1,\ldots, 1)}{\abs{\vari{S}}(1,\ldots, 1)}$. % is correctly computed for each child of $\vari{S}.$
\end{Lemma}
To prove correctness of~\Cref{alg:mon-sam}, we only use the following fact that follows from the above lemma: for the modified circuit ($\circuit_{\vari{mod}}$), $\circuit_{\vari{mod}}$, $\circuit_{\vari{mod}}.\vari{partial}=\abs{\circuit}(1,\dots,1)$.
%\AH{I'm wondering if there is a better notation to use here. I myself got confused by my own notation of $\circuit_{\vari{mod}}$. \emph{But}, we need to to be referencing the modified $\circuit$ returned by $\onepass$ in the algorithm, so maybe this is the best we can do?}
@ -339,7 +352,7 @@ To prove correctness of~\Cref{alg:mon-sam}, we only use the following fact that
%At the conclusion of $\onepass$, $\circuit.\vari{partial}$ will hold the sum of all coefficients in $\expansion{\abs{\circuit}}$, i.e., $\sum\limits_{(\monom, \coef) \in \expansion{\abs{\circuit}}}\coef$. $\circuit.\vari{weight}$ will hold the weighted probability that $\circuit$ is sampled from from its parent $+$ node.
\begin{Lemma}\label{lem:sample}
The function $\sampmon$ completes in $O(\log{k} \cdot k \cdot depth(\circuit))$ time, where $k = \degree(poly(\abs{\circuit})$. Upon completion, every $\left(\monom, sign(\coef)\right)\in \expansion{\abs{\circuit}}$ is returned with probability $\frac{|\coef|}{\abs{\circuit}(1,\ldots, 1)}$. %, $\sampmon$ returns the sampled term $\left(\monom, sign(\coef)\right)$ from $\expansion{\abs{\circuit}}$.
The function $\sampmon$ completes in $O(\log{k} \cdot k \cdot \depth(\circuit))$ time, where $k = \degree(poly(\abs{\circuit})$. Upon completion, every $\left(\monom, sign(\coef)\right)\in \expansion{\abs{\circuit}}$ is returned with probability $\frac{|\coef|}{\abs{\circuit}(1,\ldots, 1)}$. %, $\sampmon$ returns the sampled term $\left(\monom, sign(\coef)\right)$ from $\expansion{\abs{\circuit}}$.
\end{Lemma}
Armed with the above two lemmas, we are ready to argue the following result (proof in~\Cref{sec:proofs-approx-alg}):
@ -348,7 +361,7 @@ Armed with the above two lemmas, we are ready to argue the following result (pro
For any $\circuit$ with $\degree(poly(|\circuit|)) = k$, algorithm \ref{alg:mon-sam} outputs an estimate $\vari{acc}$ of $\rpoly(\prob_1,\ldots, \prob_\numvar)$ such that %$\expct\pbox{\empmean} = \frac{\rpoly(\prob_1,\ldots, \prob_\numvar)\cdot(1 - \gamma)}{\abs{\circuit}(1,\ldots, 1)}$. %within an additive $\error \cdot \abs{\circuit}(1,\ldots, 1)$ error with
%$\empmean$ has bounds
\[\probOf\left(\left|\vari{acc} - \rpoly(\prob_1,\ldots, \prob_\numvar)\right|> \error \cdot \abs{\circuit}(1,\ldots, 1)\right) \leq \conf,\]
in $O\left(\size(\circuit)\right.$ $+$ $\left.\left(\frac{\log{\frac{1}{\conf}}}{\error^2} \cdot k \cdot\log{k} \cdot depth(\circuit)\right)\right)$ time.
in $O\left(\size(\circuit)\right.$ $+$ $\left.\left(\frac{\log{\frac{1}{\conf}}}{\error^2} \cdot k \cdot\log{k} \cdot \depth(\circuit)\right)\right)$ time.
\end{Theorem}
@ -358,14 +371,14 @@ For any $\circuit$ with $\degree(poly(|\circuit|)) = k$, algorithm \ref{alg:mon-
%\subsubsection{Description}
%Algorithm ~\ref{alg:one-pass} satisfies the requirements of lemma ~\ref{lem:one-pass}.
The evaluation of $\abs{\circuit}(1,\ldots, 1)$ can be defined recursively, as follows (where $\circuit_\lchild$ and $\circuit_\rchild$ are the `left' and `right' children of $\circuit$ if they exist):
The evaluation of $\abs{\circuit}(1,\ldots, 1)$ can be defined recursively, as follows (where $\circuit_\linput$ and $\circuit_\rinput$ are the `left' and `right' inputs of $\circuit$ if they exist):
{\small
\begin{align}
\label{eq:T-all-ones}
\abs{\circuit}(1,\ldots, 1) = \begin{cases}
\abs{\circuit_\lchild}(1,\ldots, 1) \cdot \abs{\circuit_\rchild}(1,\ldots, 1) &\textbf{if }\circuit.\type = \revision{\circmult}\\
\abs{\circuit_\lchild}(1,\ldots, 1) + \abs{\circuit_\rchild}(1,\ldots, 1) &\textbf{if }\circuit.\type = \revision{\circplus} \\
\abs{\circuit_\linput}(1,\ldots, 1) \cdot \abs{\circuit_\rinput}(1,\ldots, 1) &\textbf{if }\circuit.\type = \revision{\circmult}\\
\abs{\circuit_\linput}(1,\ldots, 1) + \abs{\circuit_\rinput}(1,\ldots, 1) &\textbf{if }\circuit.\type = \revision{\circplus} \\
|\circuit.\val| &\textbf{if }\circuit.\type = \tnum\\
1 &\textbf{if }\circuit.\type = \var.
\end{cases}
@ -384,8 +397,8 @@ It turns out that for proof of~\Cref{lem:sample}, we need to argue that when $\c
\begin{align}
\label{eq:T-weights}
%&\abs{\circuit_\lchild}(1,\ldots, 1) + \abs{\circuit_\rchild}(1,\ldots, 1); &\textbf{if }\circuit.\type = + \\
\circuit_\lchild.\vari{weight} &\gets \frac{\abs{\circuit_\lchild}(1,\ldots, 1)}{\abs{\circuit_\lchild}(1,\ldots, 1) + \abs{\circuit_\rchild}(1,\ldots, 1)};\\
\circuit_\rchild.\vari{weight} &\gets \frac{\abs{\circuit_\rchild}(1,\ldots, 1)}{\abs{\circuit_\lchild}(1,\ldots, 1)+ \abs{\circuit_\rchild}(1,\ldots, 1)}
\circuit_\linput.\vari{weight} &\gets \frac{\abs{\circuit_\linput}(1,\ldots, 1)}{\abs{\circuit_\linput}(1,\ldots, 1) + \abs{\circuit_\rinput}(1,\ldots, 1)};\\
\circuit_\rinput.\vari{weight} &\gets \frac{\abs{\circuit_\rinput}(1,\ldots, 1)}{\abs{\circuit_\linput}(1,\ldots, 1)+ \abs{\circuit_\rinput}(1,\ldots, 1)}
\end{align}
%\begin{align*}
@ -408,8 +421,8 @@ A naive (slow) implementation of \sampmon\ would first compute $\expansion{\circ
% However, this would be too time consuming.
%
Instead, \Cref{alg:sample} selects a monomial from $\expansion{\circuit}$ by top-down traversal.
For a parent $+$ node, the child to be visited is sampled from the weighted distribution precomputed by \onepass.
When a parent $\times$ node is visited, both children are visited.
For a parent $+$ gate, the input to be visited is sampled from the weighted distribution precomputed by \onepass.
When a parent $\times$ node is visited, both inputs are visited.
The algorithm computes two properties: the set of all variable leaf nodes visited, and the product of signs of visited coefficient leaf nodes.
We will assume the TreeSet data structure to maintain sets with logarithmic time insertion and linear time traversal of its elements.
@ -426,13 +439,13 @@ $\sampmon$ is given in \Cref{alg:sample}, and a proof of its correctness (via \C
\Comment{\Cref{alg:one-pass} should have been run before this one} % algorithm ~\ref{alg:sample}}
\State $\vari{vars} \gets \emptyset$ \label{alg:sample-global1}
\If{$\circuit.\type = +$}\Comment{Sample at every $+$ node}
\State $\circuit_{\vari{samp}} \gets$ Sample from left subtree ($\circuit_{\lchild}$) and right subtree ($\circuit_{\rchild}$) w.p. $\circuit_\lchild.\wght$ and $\circuit_\rchild.\wght$. \label{alg:sample-plus-bsamp}
\State $\circuit_{\vari{samp}} \gets$ Sample from left input ($\circuit_{\linput}$) and right input ($\circuit_{\rinput}$) w.p. $\circuit_\linput.\wght$ and $\circuit_\rinput.\wght$. \label{alg:sample-plus-bsamp} \Comment{Each call to \sampmon uses fresh randomness}
\State $(\vari{v}, \vari{s}) \gets \sampmon(\circuit_{\vari{samp}})$\label{alg:sample-plus-traversal}
\State $\Return ~(\vari{v}, \vari{s})$
\ElsIf{$\circuit.\type = \times$}\Comment{Multiply the sampled values of all subtree children}
\ElsIf{$\circuit.\type = \times$}\Comment{Multiply the sampled values of all inputs}
\State $\vari{sgn} \gets 1$\label{alg:sample-global2}
\For {$child$ in $\circuit.\vari{children}$}
\State $(\vari{v}, \vari{s}) \gets \sampmon(child)$
\For {$input$ in $\circuit.\vari{input}$}
\State $(\vari{v}, \vari{s}) \gets \sampmon(input)$
\State $\vari{vars} \gets \vari{vars} \cup \{\vari{v}\}$\label{alg:sample-times-union}
\State $\vari{sgn} \gets \vari{sgn} \times \vari{s}$\label{alg:sample-times-product}
\EndFor

View File

@ -442,6 +442,10 @@ Applying this bound in the runtime bound in~\Cref{lem:approx-alg} gives the firs
\subsection{$\onepass$ Pseudocode}
\revision{
Please note that it is \textit{assumed} that the original call to \onepass consists of a call on an input circuit \circuit such that the values of members \vari{partial}, \vari{Lweight} and \vari{Rweight} have been initialized to Null across all gates.
}
\begin{algorithm}[h!]
\caption{\onepass$(\revision{\circuit})$}
\label{alg:one-pass}
@ -456,13 +460,13 @@ Applying this bound in the runtime bound in~\Cref{lem:approx-alg} gives the firs
\State $(child, \vari{s}) \gets \onepass(child)$
\State $\accum \gets \accum + \vari{s}$\label{alg:one-pass-plus-add}
\Else
\State \revision{$\accum \gets \accum + child.\vari{partial}$}
\State \revision{$\accum \gets \accum + child.\vari{partial}$}\label{alg:one-pass-revisit1}
\EndIf
\EndFor
\State $\circuit.\vari{partial} \gets \accum$\label{alg:one-pass-plus-assign2}
\For{$child$ in $\revision{\circuit}.\vari{children}$}\Comment{Record distributions for each child}
\If{\revision{$child.\vari{weight} =$ Null}}
\State $child.\vari{weight} \gets \frac{child.\vari{partial}}{\etree.\vari{partial}}$\label{alg:one-pass-plus-prob}
\State $child.\vari{weight} \gets \frac{child.\vari{partial}}{\circuit.\vari{partial}}$\label{alg:one-pass-plus-prob}
\EndIf
\EndFor
%\State $\vari{sum} \gets \etree.\vari{partial}$\label{alg:one-pass-plus-assign3}
@ -474,7 +478,7 @@ Applying this bound in the runtime bound in~\Cref{lem:approx-alg} gives the firs
\State $(child, \vari{s}) \gets \onepass(child)$
\State $\accum \gets \accum \times \vari{s}$\label{alg:one-pass-times-product}
\Else
\State \revision{$\accum \gets \accum \times child.\vari{partial}$}
\State \revision{$\accum \gets \accum \times child.\vari{partial}$}\label{alg:one-pass-revisit2}
\EndIf
\EndFor
\State $\revision{\circuit}.\vari{partial}\gets \accum$\label{alg:one-pass-times-assign2}
@ -555,8 +559,12 @@ level 2/.style={sibling distance=0.7cm},
\end{figure}
\subsection{\onepass Notes}
\revision{RE:[\onepass pseudocode] One thing to note here, is now that we are using circuits, a check is needed for each internal node, to see if the child (in the case of duplicate children) partial and weight values have already been recursively computed. Otherwise, this algorithm is in $\size(\etree)$ instead of the improved $\size(\circuit)$.
Another consideration is the possibility where a gate may have inputs from the same gate, or a gate might have two parents. Note that this doesn't change the results described above, and in such a case, noting the reduction descibed susequently to an expression tree, an equivalent expression tree would repeated subtrees in either case, which is the equivalent of this possibility.}
\subsection{Proof of~\Cref{lem:one-pass}}
\revision{RE:[\onepass pseudocode] One thing to note here, is now that we are using circuits, a check is needed for each internal node, to see if the child (in the case of duplicate children) partial and weight values have already been recursively computed. Otherwise, this algorithm is in $\size(\etree)$ instead of the improved $\size(\circuit)$.}
\revision{1st iteration (reduction to expression tree)} --\oldstuff{
Let us first show that there exists an equivalent expression tree representation \etree for any arbitrary circuit \circuit. Note that by definition, it must be the case that each upstream node has at most two dependencies, and therefore the DAG structure is binary, and indeed a binary expression tree if there are no upstream gates (nodes) sharing the same dependency. When there exists multiple upstream gates that all share the same dependency, an equivalent expression tree duplicates the sub-circuit (as a sub-tree) in each gate (node) which depends on it. Note that this can be done, since \circuit is indeed binary. Finally, note that the evaluation of a subtree with root \etree which has a `duplicated' subtree will be the same computation over the same input data as the original circuit \circuit, since the operation of \etree is the same as its respective counterpart in \circuit, and both \circuit and \etree are working on the exact same inputs.
@ -564,19 +572,29 @@ Let us first show that there exists an equivalent expression tree representation
Thus, using the above, we construct the proof, noting that \onepass treats the input \circuit as the equivalent expression tree described above. This also allows for a unbiased weight computation across the monomials \monom in each (\monom, \coef) in \expansion{\circuit}.
}
We prove the first part of lemma ~\ref{lem:one-pass}, i.e., correctness, by structural induction over the depth $d$ of the \revision{circuit \circuit}.
We prove the first part of lemma ~\ref{lem:one-pass}, i.e., correctness, by structural induction over the depth $d$ of the \revision{circuit \circuit}, \revision{
\textit{specifically} after the first call to \onepass on \circuit. Note by the recursive nature of \onepass that it is a fact that after this first call, all subcircuits \subcircuit will have their repsective \vari{partial}, \vari{Lweight}, and \vari{Rweight} members set to values other than Null.
}
For the base case, $d = 0$, it is the case that the node is a leaf and therefore by definition ~\ref{def:express-tree} must be a variable or coefficient. When it is a variable, \textsc{OnePass} returns $1$, and we have in this case that $\polyf(\revision{\circuit}) = X_i = \polyf(\abs{\revision{\circuit}})$ for some $i$ in $[\numvar]$, and this evaluated at all $1$'s indeed gives $1$, verifying the correctness of the returned value of $\abs{\revision{\circuit}}(1,\ldots, 1) = 1$. When the root is a coefficient, the absolute value of the coefficient is returned, which is indeed $\abs{\revision{\circuit}}(1,\ldots, 1)$. This proves the base case.
%\AH{The inductive step assumes $k \geq 0$ rather than $k \geq 1$, correct?}
%\AR{yep!}
For the inductive hypothesis, assume that for $d \leq k$ for some $k \geq 0$,~\Cref{lem:one-pass} is true for~\Cref{alg:one-pass}.
Now prove that lemma ~\ref{lem:one-pass} holds for $k + 1$. Notice that $\revision{\circuit}$ has at most two children, $\revision{\circuit}_\lchild$ and $\revision{\circuit}_\rchild$. Note also, that for each child, it is the case that $d \leq k$. Then, by inductive hypothesis, lemma ~\ref{lem:one-pass} holds for each existing child, and we are left with two possibilities for $\revision{\circuit}$. The first case is when $\revision{\circuit}$ is a \revision{$\circplus$} node. When this happens,~\Cref{alg:one-pass} computes $|\revision{\circuit}_\lchild|(1,\ldots, 1) + |\revision{\circuit}_\rchild|(1,\ldots, 1)$ on line ~\ref{alg:one-pass-plus-add} which by definition is $\abs{\revision{\circuit}}(1,\ldots, 1)$ and hence the inductive hypothesis holds in this case. For the weight computation of the children of $\revision{\circplus}$, by lines ~\ref{alg:one-pass-plus-add}, ~\ref{alg:one-pass-plus-assign2}, and ~\ref{alg:one-pass-plus-prob} algorithm ~\ref{alg:one-pass} computes $\revision{\circuit}_i.\wght = \frac{|\revision{\circuit}_i|(1,\ldots, 1)}{|\revision{\circuit}_\lchild|(1,\ldots, 1) + |\revision{\circuit}_\rchild|(1,\ldots, 1)}$ which is indeed as claimed. The second case is when the $\revision{\circuit}.\val = \times$. By inductive hypothesis, it is the case that both $\abs{\revision{\circuit}_\lchild}\polyinput{1}{1}$ and $\abs{\revision{\circuit}_\rchild}\polyinput{1}{1}$ have been correctly computed. On line~\ref{alg:one-pass-times-product} algorithm ~\ref{alg:one-pass} then computes the product of the children's partial values, $|\revision{\circuit}_\lchild|(1,\ldots, 1) \cdot |\revision{\circuit}_\rchild|(1,\ldots, 1)$ which by definition is $\abs{\revision{\circuit}}(1,\ldots, 1)$.
Now prove that the inductive hypothesis holds for $k + 1$. Notice that $\revision{\circuit}$ has at most two inputs, $\revision{\circuit}_\lchild$ and $\revision{\circuit}_\rchild$. Note also, that for each input, it is the case that $d \leq k$. Then,
\revision{
by inductive hypothesis, all gates in all subcircuits \subcircuit of \circuit have been correctly annotated.
}
% lemma ~\ref{lem:one-pass} holds for each existing input, and we are left
This leaves us with two possibilities for $\revision{\circuit}$. The first case is when $\revision{\circuit}$ is a \revision{$\circplus$} node. When this happens,~\Cref{alg:one-pass} computes $|\revision{\circuit}_\lchild|(1,\ldots, 1) + |\revision{\circuit}_\rchild|(1,\ldots, 1)$ on line ~\ref{alg:one-pass-plus-add} which by definition is $\abs{\revision{\circuit}}(1,\ldots, 1)$ and hence the inductive hypothesis holds in this case. For the weight computation of the inputs of $\revision{\circplus}$, by lines ~\ref{alg:one-pass-plus-add}, ~\ref{alg:one-pass-plus-assign2}, and ~\ref{alg:one-pass-plus-prob} algorithm ~\ref{alg:one-pass} computes $\revision{\circuit}_i.\wght = \frac{|\revision{\circuit}_i|(1,\ldots, 1)}{|\revision{\circuit}_\lchild|(1,\ldots, 1) + |\revision{\circuit}_\rchild|(1,\ldots, 1)}$ which is indeed as claimed. The second case is when the $\revision{\circuit}.\val = \times$. By inductive hypothesis, it is the case that both $\abs{\revision{\circuit}_\lchild}\polyinput{1}{1}$ and $\abs{\revision{\circuit}_\rchild}\polyinput{1}{1}$ have been correctly computed. On line~\ref{alg:one-pass-times-product} algorithm ~\ref{alg:one-pass} then computes \circuit.\vari{partial} as the product of the inputs' partial values, $|\revision{\circuit}_\lchild|(1,\ldots, 1) \cdot |\revision{\circuit}_\rchild|(1,\ldots, 1)$ which by definition is $\abs{\revision{\circuit}}(1,\ldots, 1)$.
\revision{A final note to deal with the possibility where, in the inductive case, the source gate may have children who are output from the same gate. Note that this doesn't change the results described above, and in such a case, an equivalent expression tree would consist of two identical sub-trees, which is the equivalent of this possibility.}
\paragraph{Run-time Analysis}
The runtime for \textsc{OnePass} is fairly straight forward. Note first that each node is visited at most one time. Second, for each type of node visited, it can be trivially verified that there are only a constant number of operations. This concludes then with a $O\left(\size(\revision{\circuit})\right)$ runtime.
The runtime for \textsc{OnePass} is fairly straight forward. \revision{
Note first that each gate is visited at most two times. If the internal gate is revisited, then it is true by lines ~\ref{alg:one-pass-revisit1} and ~\ref{alg:one-pass-revisit2} that there are no recursive calls on its subcircuits.
}
Next consider for each type of node visited, it can be trivially verified that there are only a constant number of operations. This concludes then with a $O\left(\size(\revision{\circuit})\right)$ runtime.
\subsection{Proof of~\Cref{lem:sample}}

View File

@ -113,6 +113,7 @@
\newcommand{\evalmp}{\func{eval}}
\newcommand{\degree}{\func{deg}}
\newcommand{\size}{\func{size}}
\newcommand{\depth}{\func{depth}}
%saving \treesize for now to keep latex from breaking
\newcommand{\treesize}{\func{size}}
\newcommand{\sign}{\func{sgn}}
@ -280,10 +281,14 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Circuit Notation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\circuit}{\vari{C}\xspace}
\newcommand{\circuit}{\vari{C}}
\newcommand{\circuitset}[1]{\vari{CSet}(#1)}
\newcommand{\circmult}{\times}
\newcommand{\circplus}{+}
%formally \rchild and \lchild
\newcommand{\rinput}{\vari{R}}
\newcommand{\linput}{\vari{L}}
\newcommand{\subcircuit}{\vari{S}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Sets

View File

@ -103,41 +103,30 @@ tree, whose internal nodes are from the set $\{+, \times\}$, with leaf nodes bei
\revision{
\begin{Definition}[Circuit]\label{def:circuit}
A circuit $\circuit$ is a data structure which consists of a Directed Acyclic Graph (DAG) whose source nodes (in degree of $0$) consist of elements in either $\reals$ or $\vct{X}$. The internal and sink nodes of $\circuit$ have binary input and are either sum ($\circplus$) or product ($\circmult$) gates. Further, the out degree of any internal node can grow with the circuit size.
A circuit $\circuit$ is a Directed Acyclic Graph (DAG) whose source nodes (in degree of $0$) consist of elements in either $\reals$ or $\vct{X}$. The internal and sink nodes of $\circuit$ have binary input and are either sum ($\circplus$) or product ($\circmult$) gates.
Circuit $\circuit$ additionally has the following members: \type, \val, \vari{partial}, \vari{children}, and \vari{weight}, where \type is the type of value stored in the node $\circuit$ (i.e. one of $\{\circplus, \circmult, \var, \tnum\}$, \val is the value stored, and \vari{children} is the list of \circuit 's children where $\circuit_\lchild$ is the left child and $\circuit_\rchild$ the right child.
Circuit $\circuit$ additionally has the following members: \type, \val, \vari{partial}, \vari{input}, and \vari{weight}, where \type is the type of value stored in the node $\circuit$ (i.e. one of $\{\circplus, \circmult, \var, \tnum\}$, \val is the value stored, and \vari{input} is the list of \circuit 's inputs where $\circuit_\linput$ is the left input and $\circuit_\rinput$ the right input. When the underlying DAG is a tree, we will refer to the structure as an expression tree.
\end{Definition}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
We ignore the remaining fields (\vari{partial} and \vari{weight}) until \Cref{sec:algo}.
The semantics of \revision{circuits} ~follows the obvious interpretation; We define \revision{the realtionship with polynomials } formally with \Cref{def:poly-func} in \Cref{sec:algo}.
We ignore the remaining fields (\vari{partial} and \vari{weight}) until \Cref{sec:algo}. Also note that the out degree of any internal node can grow with the circuit size.
The semantics of \revision{circuits} ~follows the obvious interpretation. We \revision{next} define \revision{the realtionship with polynomials } formally:
\begin{Definition}[$\polyf(\cdot)$]\label{def:poly-func}
Denote \revision{$\polyf(\circuit)$}~ to be the function from circuit \revision{$\circuit$}~ to its corresponding polynomial. $\polyf(\cdot)$ is recursively defined on \revision{$\circuit$}~ as follows, with addition and multiplication following the standard interpretation for polynomials:
\begin{equation*}
\polyf(\revision{\circuit}) = \begin{cases}
\polyf(\revision{\circuit_\lchild}) + \polyf(\revision{\circuit_\rchild}) &\text{ if \revision{\circuit}.\type } = \revision{\circplus}\\
\polyf(\revision{\circuit_\lchild}) \cdot \polyf(\revision{\circuit_\rchild}) &\text{ if \revision{\circuit}.\type } = \revision{\circmult}\\
\revision{\circuit.\val} &\text{ if \revision{\circuit}.\type } = \var \text{ OR } \tnum.
\end{cases}
\end{equation*}
\end{Definition}
Note that $\circuit$ need not encode an expression in standard monomial basis. For instance, $\circuit$ could represent a compressed form of the running example, such as $(X + 2Y)(2X - Y)$.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{Definition}[poly$(\cdot)$]\label{def:poly-func}
%Denote $poly(\etree)$ to be the function that takes as input expression tree $\etree$ and outputs its corresponding polynomial in \abbrSMB. We define $poly(\cdot)$ recursively on $\etree$ as follows, where $\etree_\lchild$ and $\etree_\rchild$ denote the left/right child of $\etree$ respectively.
%%
%% \begin{align*}
%% &\etree.\type = +\mapsto&& \polyf(\etree_\lchild) + \polyf(\etree_\rchild)\\
%% &\etree.\type = \times\mapsto&& \polyf(\etree_\lchild) \cdot \polyf(\etree_\rchild)\\
%% &\etree.\type = \var \text{ OR } \tnum\mapsto&& \etree.\val
%% \end{align*}
%%
%\begin{equation*}
% \polyf(\etree) = \begin{cases}
% \polyf(\etree_\lchild) + \polyf(\etree_\rchild) &\text{ if \etree.\type } = +\\
% \polyf(\etree_\lchild) \cdot \polyf(\etree_\rchild) &\text{ if \etree.\type } = \times\\
% \etree.\val &\text{ if \etree.\type } = \var \text{ OR } \tnum.
% \end{cases}
%\end{equation*}
%\end{Definition}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Note that addition and multiplication above follow the standard interpretation over polynomials.
%Specifically, when adding two monomials whose variables and respective exponents agree, the coefficients corresponding to the monomials are added and their sum is multiplied to the monomial. Multiplication here is denoted by concatenation of the monomial and coefficient. When two monomials are multiplied, the product of each corresponding coefficient is computed, and the variables in each monomial are multiplied, i.e., the exponents of like variables are added. Again we notate this by the direct product of coefficient product and all disitinct variables in the two monomials, with newly computed exponents.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\oldstuff{
\begin{Definition}[Expression Tree Set]\label{def:express-tree-set}$\etreeset{\smb}$ is the set of all possible expression trees $\etree$, such that $poly(\etree) = \poly(\vct{X})$.
\end{Definition}
@ -149,7 +138,7 @@ $\circuitset{\smb}$ is the set of all possible circuits $\circuit$ such that $\p
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
For our running example, $\circuitset{\smb} = \{2X^2 + 3XY - 2Y^2, (X + 2Y)(2X - Y), X(2X - Y) + 2Y(2X - Y), 2X(X + 2Y) - Y(X + 2Y)\}$. Note that \cref{def:express-tree-set} implies that \revision{$\circuit \in \circuitset{\polyf(\circuit)}$}.
For our running example, $\circuitset{\smb} = \{2X^2 + 3XY - 2Y^2, (X + 2Y)(2X - Y), X(2X - Y) + 2Y(2X - Y), 2X(X + 2Y) - Y(X + 2Y)\}$. Note that ~\Cref{def:express-tree-set} implies that \revision{$\circuit \in \circuitset{\polyf(\circuit)}$}.
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\medskip