Finished @atri 021821 suggestions modulo element Qs.

master
Aaron Huber 2021-02-11 12:33:57 -05:00
parent d2f628fbc9
commit d4717bc249
5 changed files with 70 additions and 63 deletions

View File

@ -38,7 +38,7 @@ The pure expansion of a polynomial $\poly$ is formed by computing all product of
\begin{Definition}[Expanded \revision{\circuit}]\label{def:expand-circuit}
\revision{$\expansion{\circuit}$} is the reduced pure expansion of $\revision{\circuit}$.
%\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
@ -55,7 +55,7 @@ The logical view of \revision{$\expansion{\circuit}$} is a list of tuples $(\mon
\end{Definition}
\revision{
Note that $\expansion{\circuit}$ reduces all exponents $e > 1$ to $e = 1$, as seen in ~\Cref{def:reduced-bi-poly}.
Note that $\expansion{\circuit}$ reduces all variable exponents $e > 1$ to $e = 1$, as seen in ~\Cref{def:reduced-bi-poly}.
}
In the following, we abuse notation and write $\monom$ to denote the monomial obtained as the products of the variables in the set.
@ -125,15 +125,15 @@ Given an expression tree $\circuit$ and a valuation $\vct{a} \in \mathbb{R}^\num
\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).
The function \size~ takes a circuit $\circuit$ 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).
The function \depth~ has input of either circuit $\circuit$ and outputs the number of levels in \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.
A subcircuit of a circuit $\circuit$ is a circuit \subcircuit such that \subcircuit is a DAG \textit{subgraph} of the DAG representing \circuit. The sink of \subcircuit has exactly one gate \gate.
\end{Definition}
@ -435,7 +435,7 @@ $\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 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 $\circuit_{\vari{samp}} \gets$ Sample from left input ($\circuit_{\linput}$) and right input ($\circuit_{\rinput}$) w.p. $\circuit_\vari{Lweight}$ and $\circuit_\vari{Rweight}$. \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 inputs}

View File

@ -1,6 +1,6 @@
%!TEX root=./main.tex
\revision{
\section{Need a good title for this section}
\section{More on Circuits and Moments}
}
\label{sec:gen}
%In this section, we consider generalizations/corollaries of our results.

View File

@ -444,7 +444,7 @@ 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.
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 \prt, \lwght and \rwght have been initialized to Null across all gates.
}
@ -457,49 +457,49 @@ Please note that it is \textit{assumed} that the original call to \onepass consi
\Ensure \vari{sum} $\in \reals$
\If{$\revision{\circuit}.\type = \revision{\circplus}$}\label{alg:one-pass-equality1}
\State $\accum \gets 0$\label{alg:one-pass-plus-assign1}
\For{$child$ in $\revision{\circuit}.\vari{children}$}\Comment{Sum up all children coefficients}
\If{\revision{$child.\vari{partial} = $Null}}
\State $(child, \vari{s}) \gets \onepass(child)$
\For{$input$ in $\revision{\circuit}.\inputs$}\Comment{Sum up all input coefficients}
\If{\revision{$input.\prt = $Null}}
\State $(input, \vari{s}) \gets \onepass(input)$
\State $\accum \gets \accum + \vari{s}$\label{alg:one-pass-plus-add}
\Else
\State \revision{$\accum \gets \accum + child.\vari{partial}$}\label{alg:one-pass-revisit1}
\State \revision{$\accum \gets \accum + input.\prt$}\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}}{\circuit.\vari{partial}}$\label{alg:one-pass-plus-prob}
\State $\circuit.\prt \gets \accum$\label{alg:one-pass-plus-assign2}
\For{$input$ in $\revision{\circuit}.\inputs$}\Comment{Record distributions for each input}
\If{\revision{$input\vari{weight} =$ Null}}
\State $input.\vari{weight} \gets \frac{input.\prt}{\circuit.\prt}$\label{alg:one-pass-plus-prob}
\EndIf
\EndFor
%\State $\vari{sum} \gets \etree.\vari{partial}$\label{alg:one-pass-plus-assign3}
\State \Return (\revision{\circuit, \circuit}.\vari{partial})
%\State $\vari{sum} \gets \etree.\prt$\label{alg:one-pass-plus-assign3}
\State \Return (\revision{\circuit, \circuit}.\prt)
\ElsIf{$\revision{\circuit}.\type = \revision{\circmult}$}\label{alg:one-pass-equality2}
\State $\accum \gets 1$\label{alg:one-pass-times-assign1}
\For{$child \text{ in } \revision{\circuit}.\vari{children}$}\Comment{Compute the product of all children coefficients}
\If{\revision{$child.\vari{partial} =$ Null}}
\State $(child, \vari{s}) \gets \onepass(child)$
\For{$input\text{ in } \revision{\circuit}.\inputs$}\Comment{Compute the product of all input coefficients}
\If{\revision{$input.\prt =$ Null}}
\State $(input, \vari{s}) \gets \onepass(input)$
\State $\accum \gets \accum \times \vari{s}$\label{alg:one-pass-times-product}
\Else
\State \revision{$\accum \gets \accum \times child.\vari{partial}$}\label{alg:one-pass-revisit2}
\State \revision{$\accum \gets \accum \times input.\prt$}\label{alg:one-pass-revisit2}
\EndIf
\EndFor
\State $\revision{\circuit}.\vari{partial}\gets \accum$\label{alg:one-pass-times-assign2}
%\State $\vari{sum} \gets \etree.\vari{partial}$\label{alg:one-pass-times-assign3}
\State \Return (\revision{\circuit, \circuit}.\vari{partial})
\State $\revision{\circuit}.\prt\gets \accum$\label{alg:one-pass-times-assign2}
%\State $\vari{sum} \gets \etree.\prt$\label{alg:one-pass-times-assign3}
\State \Return (\revision{\circuit, \circuit}.\prt)
\ElsIf{$\revision{\circuit}.\type = numeric$}\Comment{Base case}\label{alg:one-pass-equality3}
\State \revision{$\circuit.\vari{partial} \gets |\revision{\circuit}.\val|$}\label{alg:one-pass-leaf-assign1}\Comment{This step effectively converts $\circuit$ into $\abs{\revision{\circuit}}$}
\State \Return (\revision{\circuit}, \circuit.\vari{partial})
\State \revision{$\circuit.\prt \gets |\revision{\circuit}.\val|$}\label{alg:one-pass-leaf-assign1}\Comment{This step effectively converts $\circuit$ into $\abs{\revision{\circuit}}$}
\State \Return (\revision{\circuit}, \circuit.\prt)
\Else\Comment{$\revision{\circuit}.\type = \var$}\label{alg:one-pass-equality4}
%\State $\vari{sum} \gets 1$\label{alg:one-pass-global-assign}
\State \revision{\circuit.\vari{partial} $\gets 1$}
\State \Return (\revision{\circuit}, \circuit.\vari{partial}) % \vari{sum})
\State \revision{\circuit.\prt $\gets 1$}
\State \Return (\revision{\circuit}, \circuit.\prt) % \vari{sum})
\EndIf
\end{algorithmic}
\end{algorithm}
\subsection{$\onepass$ Example}
\begin{Example}\label{example:one-pass}
Let $\etree$ encode the expression $(X_1 + X_2)(X_1 - X_2) + X_2^2$. After one pass, \cref{alg:one-pass} would have computed the following weight distribution. For the two children of the root $+$ node $\etree$, $\etree_\lchild.\wght = \frac{4}{5}$ and $\etree_\rchild.\wght = \frac{1}{5}$. Similarly, let $\stree$ denote the left-subtree of $\etree_{\lchild}$, $\stree_\lchild.\wght = \stree_\rchild.\wght = \frac{1}{2}$. This is depicted in~\Cref{fig:expr-tree-T-wght}. %Note that in this example, the sampling probabilities for the children of each inner $+$ node of $\stree$ are equal to one another because both parents have the same number of children, and, in each case, the children of each parent $+$ node share the same $|\coef_i|$.
Let $\etree$ encode the expression $(X_1 + X_2)(X_1 - X_2) + X_2^2$. After one pass, \cref{alg:one-pass} would have computed the following weight distribution. For the two inputs of the root $+$ node $\etree$, $\etree_\lchild.\wght = \frac{4}{5}$ and $\etree_\rchild.\wght = \frac{1}{5}$. Similarly, let $\stree$ denote the left-subtree of $\etree_{\lchild}$, $\stree_\lchild.\wght = \stree_\rchild.\wght = \frac{1}{2}$. This is depicted in~\Cref{fig:expr-tree-T-wght}. %Note that in this example, the sampling probabilities for the children of each inner $+$ node of $\stree$ are equal to one another because both parents have the same number of children, and, in each case, the children of each parent $+$ node share the same $|\coef_i|$.
\end{Example}
\begin{figure}[h!]
@ -562,7 +562,7 @@ level 2/.style={sibling distance=0.7cm},
\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)$.
\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 input (in the case of duplicate inputs) 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.}
@ -575,7 +575,7 @@ Thus, using the above, we construct the proof, noting that \onepass treats the i
}
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.
\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 \prt, \lwght, and \rwght members set to values other than Null.
}
@ -589,7 +589,7 @@ Now prove that the inductive hypothesis holds for $k + 1$. Notice that $\revisi
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)$.
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.\prt 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)$.
\paragraph{Run-time Analysis}
@ -608,21 +608,21 @@ Next consider for each type of node visited, it can be trivially verified that t
\Ensure \circuit: Annotated Circuit
\Ensure \vari{sum} $\in \reals$
\For{\circuit in \topord(\circuit)}\Comment{\topord($\cdot$) is the topological order of \circuit}
\If{\circuit.\vari{type} $=$ \var}
\State \circuit.\vari{partial} $\gets 1$
\ElsIf{\circuit.\vari{type} $=$ \tnum}
\State \circuit.\vari{partial} $\gets \abs{\circuit.\val}$
\ElsIf{\circuit.\vari{type} $= \circmult$}
\State \circuit.\vari{partial} $\gets \circuit_\linput \times \circuit_\rinput$
\Else \Comment{\circuit.\vari{type} $= \circplus$}
\State \circuit.\vari{partial} $\gets \circuit_\linput + \circuit_\rinput$
\State \circuit.\vari{Lweight} $\gets \frac{\circuit_\linput.\vari{partial}}{\circuit.\vari{partial}}$
\State \circuit.\vari{Rweight} $\gets \frac{\circuit_\rinput.\vari{partial}}{\circuit.\vari{partial}}$
\For{\gate in \topord(\circuit)}\Comment{\topord($\cdot$) is the topological order of \circuit}
\If{\gate.\type $=$ \var}
\State \gate.\prt $\gets 1$
\ElsIf{\gate.\type $=$ \tnum}
\State \gate.\prt $\gets \abs{\gate.\val}$
\ElsIf{\gate.\type $= \circmult$}
\State \gate.\prt $\gets \gate_\linput.\prt \times \gate_\rinput.\prt$
\Else \Comment{\gate.\type $= \circplus$}
\State \gate.\prt $\gets \gate_\linput.\prt + \gate_\rinput.\prt$
\State \gate.\lwght $\gets \frac{\gate_\linput.\prt}{\gate.\prt}$
\State \circuit.\rwght $\gets \frac{\gate_\rinput.\prt}{\gate.\prt}$
\EndIf
\State \vari{sum} $\gets \circuit.\vari{partial}$
\State \vari{sum} $\gets \gate.\prt$
\EndFor
\State \Return \vari{sum}
\State \Return (\vari{sum}, $\circuit_{\vari{Mod}}$) \Comment{$\circuit_{\vari{Mod}}$ is the modified \circuit}
\end{algorithmic}
\end{algorithm}
}
@ -634,7 +634,7 @@ Next consider for each type of node visited, it can be trivially verified that t
\revision{
While we would like to take advantage of the space efficiency gained in using a circuit \circuit instead an expression tree \etree, we do not know that such a method exists when computing a sample of the input polynomial representation.
The efficiency gains of circuits over trees is found in the multiplication of the same product of sum terms in the factorized polynomial that \circuit models. However, to avoid biased sampling, it is imperative to sample from both children of a multiplication gate, independently. When we perform separate, independent sampling of both children, the result is the same as performing the sampling computation over the space inefficient expression tree. However, this doesn't harm us, since as we show, that the bounded run time is not dependent on the size of the equivalent expression tree of the input circuit \circuit, but rather on the expression tree's depth, which is the same as the depth of \circuit.
The efficiency gains of circuits over trees is found in the capability of circuits to only require space for each \emph{distinct} term in the compressed representation. This saves space in such polynomials containing non-distinct terms multiplied or added to each other, e.g., $x^4$. However, to avoid biased sampling, it is imperative to sample from both inputs of a multiplication gate, independently. When we perform separate, independent sampling of both inputs, the result is the same as performing the sampling computation over the space inefficient expression tree. (Note that an expression tree \etree is a special case of a circuit with the restriction of one output per node.) However, this doesn't harm us, since as we show, that the bounded run time is not dependent on the size of the equivalent expression tree of the input circuit \circuit, but rather on the expression tree's depth, which is the same as the depth of \circuit.
}
@ -646,26 +646,26 @@ For the base case, let the depth $d$ of $\circuit$ be $0$. We have that the roo
For the inductive hypothesis, assume that for $d \leq k$ for some $k \geq 0$, that it is indeed the case that $\sampmon$ returns a monomial.
For the inductive step, let us take a circuit $\circuit$ with $d \leq k + 1$. Note that each child has depth $d \leq k$, and by inductive hypothesis both of them return a valid monomial. Then the root can be either a $\circplus$ or $\circmult$ node. For the case of a $\circplus$ root node, line ~\ref{alg:sample-plus-bsamp} of $\sampmon$ will choose one of the children of the root. Since by inductive hypothesis it is the case that a monomial is being returned from either child, and only one of these monomials is selected, we have for the case of $+$ root node that a valid monomial is returned by $\sampmon$. When the root is a $\circmult$ node, line ~\ref{alg:sample-times-union} %and ~\ref{alg:sample-times-product} multiply
computes the set union of the monomials returned by the two children of the root, and it is trivial to see
For the inductive step, let us take a circuit $\circuit$ with $d = k + 1$. Note that each input has depth $d \leq k$, and by inductive hypothesis both of them return a valid monomial. Then the root can be either a $\circplus$ or $\circmult$ node. For the case of a $\circplus$ root node, line ~\ref{alg:sample-plus-bsamp} of $\sampmon$ will choose one of the inputs of the root. By inductive hypothesis it is the case that a monomial in \expansion(\circuit) is being returned from either input. Then it follows that for the case of $+$ root node a valid monomial is returned by $\sampmon$. When the root is a $\circmult$ node, line ~\ref{alg:sample-times-union} %and ~\ref{alg:sample-times-product} multiply
computes the set union of the monomials returned by the two inputs of the root, and it is trivial to see
%by definition ~\ref{def:monomial}
%the product of two monomials is also a monomial, and
by ~\cref{def:expand-circuit} that \monom is a valid monomial in some $(\monom, \coef) \in \expansion{\circuit}$.
by ~\Cref{def:expand-circuit} that \monom is a valid monomial in some $(\monom, \coef) \in \expansion{\circuit}$.
We will next prove by induction on the depth $d$ of $\circuit$ that the $(\monom,\coef) \in \expansion{\circuit}$ to which the \monom returned by $\sampmon$ matches, has a probability %`that is in accordance with the monomial sampled,
We will next prove by induction on the depth $d$ of $\circuit$ that the $(\monom,\coef) \in \expansion{\circuit}$ is the \monom returned by $\sampmon$ with a probability %`that is in accordance with the monomial sampled,
$\frac{|\coef|}{\abs{\circuit}\polyinput{1}{1}}$.
For the base case $d = 0$, by definition ~\ref{def:express-tree} we know that the root has to be either a coefficient or a variable. For either case, the probability of the value returned is $1$ since there is only one value to sample from. When the root is a variable $x$ the algorithm correctly returns $(\{x\}, 1 )$. When the root is a coefficient, \sampmon ~correctly returns $(\{~\}, sign(\coef_i))$.
For the inductive hypothesis, assume that for $d \leq k$ and $k \geq 0$ $\sampmon$ indeed samples $\monom$ in $(\monom, \coef)$ in $\expansion{\circuit}$ with probability $\frac{|\coef|}{\abs{\circuit}\polyinput{1}{1}}$.%bove is true.%lemma ~\ref{lem:sample} is true.
We prove now for $k + 1$ the inductive step holds. It is the case that the root of $\circuit$ has up to two children $\circuit_\lchild$ and $\circuit_\rchild$. Since $\circuit_\lchild$ and $\circuit_\rchild$ are both depth $d \leq k$, by inductive hypothesis, $\sampmon$ will sample both monomials $\monom_\lchild$ in $(\monom_\lchild, \coef_\lchild)$ of $\expansion{\circuit_\lchild}$ and $\monom_\rchild$ in $(\monom_\rchild, \coef_\rchild)$ of $\expansion{\circuit_\rchild}$, from $\circuit_\lchild$ and $\circuit_\rchild$ with probability $\frac{|\coef_\lchild|}{\abs{\circuit_\lchild}\polyinput{1}{1}}$ and $\frac{|\coef_\rchild|}{\abs{\circuit_\rchild}\polyinput{1}{1}}$.
We prove now for $d = k + 1$ the inductive step holds. It is the case that the root of $\circuit$ has up to two inputs $\circuit_\lchild$ and $\circuit_\rchild$. Since $\circuit_\lchild$ and $\circuit_\rchild$ are both depth $d \leq k$, by inductive hypothesis, $\sampmon$ will sample both monomials $\monom_\lchild$ in $(\monom_\lchild, \coef_\lchild)$ of $\expansion{\circuit_\lchild}$ and $\monom_\rchild$ in $(\monom_\rchild, \coef_\rchild)$ of $\expansion{\circuit_\rchild}$, from $\circuit_\lchild$ and $\circuit_\rchild$ with probability $\frac{|\coef_\lchild|}{\abs{\circuit_\lchild}\polyinput{1}{1}}$ and $\frac{|\coef_\rchild|}{\abs{\circuit_\rchild}\polyinput{1}{1}}$.
The root has to be either a $\circplus$ or $\circmult$ node.
Consider the case when the root is $\circmult$. Note that we are sampling a term from $\expansion{\circuit}$. Consider $(\monom, \coef)$ in $\expansion{\circuit}$, where $\monom$ is the sampled monomial. Notice also that it is the case that $\monom = \monom_\lchild \circmult \monom_\rchild$, where $\monom_\lchild$ is coming from $\circuit_\lchild$ and $\monom_\rchild$ from $\circuit_\rchild$. The probability that \sampmon$(\circuit_{\lchild})$ returns $\monom_\lchild$ is $\frac{|\coef_{\monom_\lchild}|}{|\circuit_\lchild|(1,\ldots, 1)}$ and $\frac{|\coef_{\monom_\rchild}|}{\abs{\circuit_\rchild}\polyinput{1}{1}}$ for $\monom_\rchild$. Since both $\monom_\lchild$ and $\monom_\rchild$ are sampled with independent randomness, the final probability for sample $\monom$ is then $\frac{|\coef_{\monom_\lchild}| \cdot |\coef_{\monom_\rchild}|}{|\circuit_\lchild|(1,\ldots, 1) \cdot |\circuit_\rchild|(1,\ldots, 1)}$. For $(\monom, \coef)$ in \expansion{\circuit}, it is indeed the case that $|\coef_i| = |\coef_{\monom_\lchild}| \cdot |\coef_{\monom_\rchild}|$ and that $\abs{\circuit}(1,\ldots, 1) = |\circuit_\lchild|(1,\ldots, 1) \cdot |\circuit_\rchild|(1,\ldots, 1)$, and therefore $\monom$ is sampled with correct probability $\frac{|\coef_i|}{\abs{\circuit}(1,\ldots, 1)}$.
Consider the case when the root is $\circmult$. Note that we are sampling a term from $\expansion{\circuit}$. Consider $(\monom, \coef)$ in $\expansion{\circuit}$, where $\monom$ is the sampled monomial. Notice also that it is the case that $\monom = \monom_\lchild \circmult \monom_\rchild$, where $\monom_\lchild$ is coming from $\circuit_\lchild$ and $\monom_\rchild$ from $\circuit_\rchild$. The probability that \sampmon$(\circuit_{\lchild})$ returns $\monom_\lchild$ is $\frac{|\coef_{\monom_\lchild}|}{|\circuit_\lchild|(1,\ldots, 1)}$ and $\frac{|\coef_{\monom_\rchild}|}{\abs{\circuit_\rchild}\polyinput{1}{1}}$ for $\monom_\rchild$. Since both $\monom_\lchild$ and $\monom_\rchild$ are sampled with independent randomness, the final probability for sample $\monom$ is then $\frac{|\coef_{\monom_\lchild}| \cdot |\coef_{\monom_\rchild}|}{|\circuit_\lchild|(1,\ldots, 1) \cdot |\circuit_\rchild|(1,\ldots, 1)}$. For $(\monom, \coef)$ in \expansion{\circuit}, it is indeed the case that $|\coef| = |\coef_{\monom_\lchild}| \cdot |\coef_{\monom_\rchild}|$ and that $\abs{\circuit}(1,\ldots, 1) = |\circuit_\lchild|(1,\ldots, 1) \cdot |\circuit_\rchild|(1,\ldots, 1)$, and therefore $\monom$ is sampled with correct probability $\frac{|\coef|}{\abs{\circuit}(1,\ldots, 1)}$.
For the case when $\circuit.\val = \circplus$, \sampmon ~will sample monomial $\monom$ from one of its children. By inductive hypothesis we know that any $\monom_\lchild$ in $\expansion{\circuit_\lchild}$ and any $\monom_\rchild$ in $\expansion{\circuit_\rchild}$ will both be sampled with correct probability $\frac{|\coef_{\monom_\lchild}|}{\circuit_{\lchild}(1,\ldots, 1)}$ and $\frac{|\coef_{\monom_\rchild}|}{|\circuit_\rchild|(1,\ldots, 1)}$, where either $\monom_\lchild$ or $\monom_\rchild$ will equal $\monom$, depending on whether $\circuit_\lchild$ or $\circuit_\rchild$ is sampled. Assume that $\monom$ is sampled from $\circuit_\lchild$, and note that a symmetric argument holds for the case when $\monom$ is sampled from $\circuit_\rchild$. Notice also that the probability of choosing $\circuit_\lchild$ from $\circuit$ is $\frac{\abs{\circuit_\lchild}\polyinput{1}{1}}{\abs{\circuit_\lchild}\polyinput{1}{1} + \abs{\circuit_\rchild}\polyinput{1}{1}}$ as computed by $\onepass$. Then, since $\sampmon$ goes top-down, and each sampling choice is independent (which follows from the randomness in the root of $\circuit$ being independent from the randomness used in its subtrees), the probability for $\monom$ to be sampled from $\circuit$ is equal to the product of the probability that $\circuit_\lchild$ is sampled from $\circuit$ and $\monom$ is sampled in $\circuit_\lchild$, and
For the case when $\circuit.\val = \circplus$, \sampmon ~will sample monomial $\monom$ from one of its inputs. By inductive hypothesis we know that any $\monom_\lchild$ in $\expansion{\circuit_\lchild}$ and any $\monom_\rchild$ in $\expansion{\circuit_\rchild}$ will both be sampled with correct probability $\frac{|\coef_{\monom_\lchild}|}{\circuit_{\lchild}(1,\ldots, 1)}$ and $\frac{|\coef_{\monom_\rchild}|}{|\circuit_\rchild|(1,\ldots, 1)}$, where either $\monom_\lchild$ or $\monom_\rchild$ will equal $\monom$, depending on whether $\circuit_\lchild$ or $\circuit_\rchild$ is sampled. Assume that $\monom$ is sampled from $\circuit_\lchild$, and note that a symmetric argument holds for the case when $\monom$ is sampled from $\circuit_\rchild$. Notice also that the probability of choosing $\circuit_\lchild$ from $\circuit$ is $\frac{\abs{\circuit_\lchild}\polyinput{1}{1}}{\abs{\circuit_\lchild}\polyinput{1}{1} + \abs{\circuit_\rchild}\polyinput{1}{1}}$ as computed by $\onepass$. Then, since $\sampmon$ goes top-down, and each sampling choice is independent (which follows from the randomness in the root of $\circuit$ being independent from the randomness used in its subtrees), the probability for $\monom$ to be sampled from $\circuit$ is equal to the product of the probability that $\circuit_\lchild$ is sampled from $\circuit$ and $\monom$ is sampled in $\circuit_\lchild$, and
\begin{align*}
&\probOf(\sampmon(\circuit) = \monom) = \\
&\probOf(\sampmon(\circuit_\lchild) = \monom) \cdot \probOf(SampledChild(\circuit) = \circuit_\lchild)\\
@ -677,7 +677,9 @@ and we obtain the desired result.
\paragraph{Run-time Analysis}
We now bound the number of recursive calls in $\sampmon$ by $O\left(k\cdot depth(\circuit)\right)$. Note that a sampled monomial corresponds to a subcircuit of $\circuit$. Take an arbitrary sample subcircuit \subcircuit of circuit $\circuit$ and note that since every monomial has degree at most $k$, the \subcircuit has $O(k)$ leaves and the number of recursive calls in each layer as one goes from leaves to the root can only go down. Since \subcircuit has depth at most $\depth(\circuit)$ and that each level has $O(k)$ nodes, the subcircuit has $O(k\cdot \depth(\circuit))$ nodes in it. \revision{
We now bound the number of recursive calls in $\sampmon$ by $O\left(k\cdot depth(\circuit)\right)$.
\revision{
Note that a sampled monomial corresponds to a subtree of the equivalent expression tree \etree of $\circuit$. Take an arbitrary sample subtree \stree of \etree and note that since every monomial has degree at most $k$, \stree has $O(k)$ leaves and the number of recursive calls in each layer as one goes from leaves to the root can only go down. Note that \depth(\etree) = \depth(\circuit) since any gate \gate in \circuit with more than one output is simply duplicated (\gate') in \etree, where \gate' is input into its additional parent. This can only increase the breadth of \etree and not the depth, since \gate is input at least one level up, and therefore \gate' would be at the same level or higher in \etree. (Note that the \depth(\circuit) is considered as the longest path from a sink node to a source node.) It follows that adding a child subtree \gate' as input to a parent one or more levels higher can only increase the breadth. Since \stree has depth at most $\depth(\etree) = \depth(\circuit)$ and that each level has $O(k)$ nodes, the subcircuit has $O(k\cdot \depth(\circuit))$ nodes in it.
It is important to note that since there are $O(k)$ recursive calls at any given level, the case of more than one recursive call to an arbitrary gate is accounted for in this bound, i.e., on any given level, there cannot be more than $\numvar$ calls on a particular gate such that the sum of all other calls on other gates is $m$ and $\numvar + m = k$. This yields the desired bound.
}

View File

@ -86,7 +86,6 @@
\newcommand{\rchild}{\vari{R}}
%members of T
\newcommand{\val}{\vari{val}\xspace}
\newcommand{\type}{\vari{type}\xspace}
\newcommand{\wght}{\vari{weight}\xspace}
\newcommand{\vpartial}{\vari{partial}\xspace}
%types of T
@ -289,7 +288,14 @@
%formally \rchild and \lchild
\newcommand{\rinput}{\vari{R}}
\newcommand{\linput}{\vari{L}}
\newcommand{\inp}{\vari{input}}
\newcommand{\inputs}{\vari{inputs}}
\newcommand{\subcircuit}{\vari{S}}
\newcommand{\gate}{\vari{g}}
\newcommand{\lwght}{\vari{Lweight}}
\newcommand{\rwght}{\vari{Rweight}}
\newcommand{\prt}{\vari{partial}}
\newcommand{\type}{\vari{type}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Sets

View File

@ -103,7 +103,7 @@ tree, whose internal nodes are from the set $\{+, \times\}$, with leaf nodes bei
\end{Definition}}
\revision{
We could consider polynomials to be represented as an expression tree.
As in the introduction, we could consider polynomials to be represented as an expression tree.
However, they do not capture many of the compressed polynomial representations that we can get from query processing algorithms on bags, including the recent work on worst-case optimal join algorithms~\cite{ngo-survey,skew}, factorized databases~\cite{factorized-db}, and FAQ~\cite{DBLP:conf/pods/KhamisNR16}. Intuitively, the main reason is that an expression tree does not allow for `sharing' of intermediate results, which is crucial for these algorithms (and other query processing methods as well).
We represent query polynomials via {\em arithmetic circuits}~\cite{arith-complexity}, a standard way to represent polynomials over fields (particularly in the field of algebraic complexity) that we use for polynomials over $\mathbb N$ in the obvious way.
@ -111,21 +111,20 @@ We represent query polynomials via {\em arithmetic circuits}~\cite{arith-complex
\begin{Definition}[Circuit]\label{def:circuit}
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{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.
Circuit $\circuit$ additionally has the following members: \type, \val, \vari{partial}, \vari{input}, and \vari{Lweight}, \vari{Rweight}, 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 present a formal treatment of {\em circuit}s in~\Cref{sec:circuits-formal}.
As stated in ~\Cref{def:circuit}, a circuit is represented by a DAG, where each source node corresponds to either one of the input variables or a constant, and the sinks to output tuples.
Every other node has at most two in-edges, is labeled as an addition or a multiplication node, and has no limit on its outdegree.
As stated in ~\Cref{def:circuit}, every internal node has at most two in-edges, is labeled as an addition or a multiplication node, and has no limit on its outdegree.
Note that if we limit the outdegree to one, then we get expression trees.
We ignore the remaining fields (\vari{partial} and \vari{weight}) until \Cref{sec:algo}.
We ignore the remaining fields (\vari{partial}, \vari{Lweight}, and \vari{Rweight}) 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:
The semantics of \revision{circuits} ~follows the obvious interpretation. We \revision{next} define \revision{its 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: