Changes: OnePass Alg now upholds reduced circuit invariant, argument updated for SampleMonomial Runtime Analysis, text explaining reduced cirucit.

This commit is contained in:
Aaron Huber 2021-03-02 12:27:26 -05:00
parent 40b38acbc6
commit 22ab0d9607
3 changed files with 88 additions and 108 deletions

View file

@ -446,59 +446,13 @@ Applying this bound in the runtime bound in~\Cref{lem:approx-alg} gives the firs
\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 \prt, \lwght and \rwght have been initialized to Null across all gates.
{\bf The subsequent paragraph may not be properly placed, but I don't want to mess up the page length of the paper, so am waiting for suggestions.}
For technical reasons, we require the invariant that every subcircuit \subcircuit of parameter circuit \circuit has an input $\subcircuit_i$ such that $\subcircuit_i.\degval \geq 1$. If this is not the case, \onepass then rewrites \subcircuit into an equaivalent subcircuit \subcircuit' by iteratively combining non-variable leaf nodes bottom-up until a parent node is reached which has an input of type \var. It is trivial to see in such a case that $\subcircuit \equiv \subcircuit'$.
}
%\oldstuff{
%
%\begin{algorithm}[h!]
% \caption{\onepass$(\revision{\circuit})$}
% \label{alg:one-pass}
%\begin{algorithmic}[1]
% \Require \revision{\circuit}: \revision{Circuit}
% \Ensure \revision{\circuit}: \revision{Circuit}
% \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{$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 + input.\prt$}\label{alg:one-pass-revisit1}
% \EndIf
% \EndFor
% \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.\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{$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 input.\prt$}\label{alg:one-pass-revisit2}
% \EndIf
% \EndFor
% \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.\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.\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}
@ -563,44 +517,6 @@ level 2/.style={sibling distance=0.7cm},
\label{fig:expr-tree-T-wght}
\end{figure}
%\oldstuff{
%\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 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.}
%
%\subsection{Proof of~\Cref{lem:one-pass}}
%
%\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.
%
%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}, \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 \prt, \lwght, and \rwght 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 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.\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}
%The runtime for \textsc{OnePass} is fairly straight forward. \revision{
%Note that due to the property of each gate having potentially a linear number of outputs in the size of the circuit, each node can be upper bounded to being visited $\numvar$ times for a circuit of size $\numvar$. However, we can produce a tighter bound based on the property that each gate has at most $2$ inputs. This implies that there exist at most $2\numvar$ edges, and $O(\numvar)$ edges implies a total of $< 2\numvar$ node visitations (recall that source nodes have no inputs). It is therefore the case that we still have $O(\numvar)$ visitations across the entire circuit.
%}
%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{\onepass}
\revision{
@ -614,12 +530,29 @@ level 2/.style={sibling distance=0.7cm},
\For{\gate in \topord(\circuit)}\label{alg:one-pass-loop}\Comment{\topord($\cdot$) is the topological order of \circuit}
\If{\gate.\type $=$ \var}
\State \gate.\degval $\gets 1$
\State \gate.\prt $\gets 1$\label{alg:one-pass-var}
\ElsIf{\gate.\type $=$ \tnum}
\State \gate.\prt $\gets \abs{\gate.\val}$\label{alg:one-pass-num}
\ElsIf{\gate.\type $= \circmult$}
\revision{
\State \gate.\degval $\gets \gate_\linput.\degval + \gate_\rinput.\degval$
\If{\gate.\degval $= 0$}
\State \gate.\type $\gets \tnum$
\State $\gate.\val \gets \gate_\linput.\val \times \gate_\rinput.\val$
\State $\gate_\linput, \gate_\rinput \gets \nullval$
\EndIf
}
\State \gate.\prt $\gets \gate_\linput.\prt \times \gate_\rinput.\prt$\label{alg:one-pass-mult}
\Else %\Comment{\gate.\type $= \circplus$}
\revision{
\State \gate.\degval $\gets \max(\gate_\linput.\degval, \gate_\rinput.\degval)$
\If{\gate.\degval $= 0$}
\State \gate.\type $\gets \tnum$
\State $\gate.\val \gets \gate_\linput.\val + \gate_\rinput.\val$
\State $\gate_\linput, \gate_\rinput \gets \nullval$
\EndIf
}
\State \gate.\prt $\gets \gate_\linput.\prt + \gate_\rinput.\prt$\label{alg:one-pass-plus}
\State \gate.\lwght $\gets \frac{\gate_\linput.\prt}{\gate.\prt}$\label{alg:one-pass-lwght}
\State \gate.\rwght $\gets \frac{\gate_\rinput.\prt}{\gate.\prt}$\label{alg:one-pass-rwght}
@ -649,6 +582,10 @@ When $\gate_{k+1}.\type = \circplus$, then by line ~\ref{alg:one-pass-plus} $\ga
When $\gate_{k+1}.\type = \circmult$, then line ~\ref{alg:one-pass-mult} computes $\gate_{k+1}.\prt = \gate_{{k+1}_\lchild.\prt} \circmult \gate_{{k+1}_\rchild}.\prt$, which indeed is correct, as per ~\ref{eq:T-all-ones}.
%We first note that all DAGs have a topological ordering. By definition, for a graph $G = (V, E)$, a topological ordering $\topord(G)$ orders the elements of V in correspondence to the directed edges of $E$, such that for each edge $(u, v)$ the gate $u$ will be ordered before gate $v$, since the edge goes from $u$ to $v$. Since the directed edges of circuit \circuit go from the children to the parent, it is then invariant in $\topord(G)$ that all the children $v_\linput$ and/or $v_\rinput$ appear before their parental internal gate $v \in V$ in $\topord(G)$. Since \onepass follows $\topord(\circuit)$ (~\Cref{alg:one-pass-loop}), it has to be the case that before an internal gate is visited, both of its subcircuits $\subcircuit_\linput$ and $\subcircuit_\rinput$ will have previously been visited, computing \prt, \lwght, and \rwght values in a bottom-up traversal. When the node visited by \onepass is a source node, it is trivial to see in ~\Cref{alg:one-pass-var} and ~\Cref{alg:one-pass-num} that such a child node's \prt value is correctly computed. This implies the correctness of the \prt annotations across all gates in both $\subcircuit_\linput$ and $\subcircuit_\rinput$. Recall that all internal gates are either $\circplus$ or $\circmult$. When an internal gate \subcircuit is visited in \topord(\circuit), if \subcircuit.\type is $\circplus$, \onepass will add the values of the two source nodes $\subcircuit_\linput.\prt + \subcircuit_\rinput.\prt$ to correctly annotate \subcircuit.\prt. Further \subcircuit.\lwght will be computed correctly as $\frac{\subcircuit_\linput.\prt}{\subcircuit.\prt}$ and analogously for \subcircuit.\rwght. If the parent gate \subcircuit visited is a $\circmult$, then \onepass will correctly annotate \subcircuit.\prt as $\subcircuit_\linput.\prt \times \subcircuit_\rinput.\prt$. As gates further in the order are subsequently visited, note that it is the case that all previous gates visited will always contain the correct \prt values and it follows that all subsequent gates visited in \topord(\circuit) will correctly compute their respective \prt values. Since \lwght and \rwght are computed dependent only on \prt values, it follows that all \lwght and \rwght values will then be computed correctly.
\emph{The following needs to be incorporated into the proof BUT I am waiting for @atri's comments on the proof (since he has yet to see it) before I make any further adjustments.}
By the same argument, it must also be the case that \circuit.\degval is also annotated correctly and \subcircuit transformed into \subcircuit' when necessary.
\paragraph{\onepass Runtime}
It is known that $\topord(G)$ is computable in linear time. Next, each of the $\numvar$ iterations of the loop in ~\Cref{alg:one-pass-loop} take $O(1)$ time, thus yielding a runtime of $O\left(\size(\circuit)\right)$.
@ -717,35 +654,76 @@ Let \cost be a function that models an upper bound on the number of gates that c
First note that the runtime of \sampmon is $O\left(\cost(\circuit)\right)$. When \sampmon visits a gate such that \circuit.\type $ =\circmult$, line ~\ref{alg:sample-times-for-loop} visits each input of \circuit. For the case when \circuit.\type $= \circplus$, line ~\ref{alg:sample-plus-bsamp} visits exactly one of the input gates. Finally, it is trivial to see that when \circuit.\type $\in \{\var, \tnum\}$, i.e., a source gate, that only one gate is visited.
We prove $(\degree(\circuit) + 1) \cdot (\depth(\circuit) + 1) \geq \cost(\circuit)$ for the number of gates traversed in \sampmon using induction over $\depth(\circuit)$.
We prove the following inequality
\begin{equation}
(\degree(\circuit) + 1) \cdot (\depth(\circuit) + 1) + \min\left(\depth(\circuit_\linput), \depth(\circuit_\rinput)\right) \geq \cost(\circuit)\label{eq:strict-upper-bound}
\end{equation}
for the number of gates traversed in \sampmon holds, using induction over $\depth(\circuit)$. Recall that \onepass has imposed the invariant that all subcircuits \subcircuit in \circuit must have at least one input such that $\subcircuit_i.\degval \geq 1$.
For the base case $\degree(\circuit) = \depth(\circuit) = 0$, $\cost(\circuit) = 1$, and it is trivial to see that the inequality $(\degree(\circuit) + 1) \cdot (\depth(\circuit) + 1) \geq \cost(\circuit)$ holds.
For the inductive hypothesis, we assume the bound holds for a circuit where $0 \leq \depth(\circuit) \leq \ell$.
For the inductive hypothesis, we assume the bound holds for a circuit where $\ell \geq \depth(\circuit) \geq 0$.
Now consider the case when \sampmon has an arbitrary circuit \circuit input with $\depth(\circuit) \leq \ell + 1$. By the hypothesis, we know all inputs of the sink gate \circuit uphold the bound. It is true then that $\depth(\circuit_\linput) \leq \depth(\circuit)$ and $\depth(\circuit_\rinput) \leq \depth(\circuit)$ where at least one of the inequalities is a strict equality.
%Fix $\degree(\circuit_\linput) = k'$ and $\degree(\circuit_\rinput) = k''$.
If \circuit.\type $= \circplus$, then $\degree(\circuit) = \max\left(\degree(\circuit_\linput), \degree(\circuit_\rinput)\right)$. Otherwise \circuit.\type = $\circmult$ and $\degree(\circuit) = \degree(\circuit_\linput) + \degree(\circuit_\rinput)$. For both cases it is true that $\depth(\circuit) = \max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1$, and there exist the inequalities $(\degree(\circuit_\linput) + 1) \cdot (\depth(\circuit_\linput) + 1) \geq \cost(\circuit_\linput)$, and $(\degree(\circuit_\rinput) + 1) \cdot (\depth(\circuit_\rinput) + 1) \geq \cost(\circuit_\rinput)$. Further note that a parent gate always will have a depth that is at least $1$ greater than either of its inputs.
If \circuit.\type $= \circplus$, then $\degree(\circuit) = \max\left(\degree(\circuit_\linput), \degree(\circuit_\rinput)\right)$. Otherwise \circuit.\type = $\circmult$ and $\degree(\circuit) = \degree(\circuit_\linput) + \degree(\circuit_\rinput)$. For both cases it is true that $\depth(\circuit) = \max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1$, and there exist the inequalities $(\degree(\circuit_\linput) + 1) \cdot (\depth(\circuit_\linput) + 1) \geq \cost(\circuit_\linput)$, and $(\degree(\circuit_\rinput) + 1) \cdot (\depth(\circuit_\rinput) + 1) \geq \cost(\circuit_\rinput)$.
If \circuit.\type $= \circmult$, then,
%$\degree(\circuit) = \degree(\circuit_\linput) + \degree(\circuit_\linput), \depth(\circuit) = \max(\depth(\circuit_\linput), \depth(\circuit_\rinput))$, and there exist inequalities $\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) \geq \cost(\circuit_\linput)$ and $\degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) \geq \cost(\circuit_\rinput)$. Then
substituing values, we have that
\begin{align*}
&\left(\degree(\circuit_\linput) + \degree(\circuit_\rinput) + 1\right) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 2\right)\\
&\qquad\geq (\degree(\circuit_\linput) + 1) \cdot (\depth(\circuit_\linput) + 1) + (\degree(\circuit_\rinput) + 1) \cdot (\depth(\circuit_\rinput) + 1) + 1 \\
&\qquad\qquad\geq 1 + \cost(\circuit_\linput) + \cost(\circuit_\rinput).
\end{align*}
The left inequality holds since it is always the case that $(\degree(\circuit_i) + 1) \cdot (\depth(\circuit_i) + 2) > (\degree(\circuit_i) + 1) \cdot (\depth(\circuit_i) + 1)$ for $\degree(\circuit_i), \depth(\circuit_i) \geq 0$ . The second inequality holds by I.H. It follows that $\degree(\circuit) \cdot \depth(\circuit) \geq \cost(\circuit)$.
substituing values, the following should hold,
\begin{align}
&\left(\degree(\circuit_\linput) + \degree(\circuit_\rinput) + 1\right) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 2\right) +\nonumber\\
&\qquad \min(\depth(\circuit_\linput), \depth(\circuit_\rinput))\label{eq:times-lhs}\\
&\qquad\geq (\degree(\circuit_\linput) + 1) \cdot (\depth(\circuit_\linput) + 1) + (\degree(\circuit_\rinput) + 1) \cdot\nonumber\\
&\qquad\text{ } (\depth(\circuit_\rinput) + 1) + 1\label{eq:times-middle} \\
&\qquad\qquad\geq 1 + \cost(\circuit_\linput) + \cost(\circuit_\rinput)\label{eq:times-rhs}.
\end{align}
Note that the rhs inequality \Cref{eq:times-middle} $\geq$ \Cref{eq:times-rhs} follows by the I.H., with \Cref{eq:times-middle} being a simple substitution of \Cref{eq:strict-upper-bound} for each $\cost(\circuit_i)$ on the RHS.
Let us expand ~\ref{eq:times-lhs},
\begin{align}
(\ref{eq:times-lhs}) &= \degree(\circuit_\linput)\depth_{\max}(\circuit_i) + \degree(\circuit_\rinput)\depth_{\max}(\circuit_i) + \depth_{\max}(\circuit_i) +\nonumber \\
& 2\degree(\circuit_\linput) + 2\degree(\circuit_\rinput) + 2 + \depth_{\min}(\circuit_i)\label{eq:times-lhs-expanded}
\end{align}
where $\depth_{\max}(\circuit_i)$ is used to denote the maximum depth of the two input subcircuits.
Next, expand ~\ref{eq:times-middle}.
\begin{align}
(\ref{eq:times-middle}) &= \degree(\circuit_\linput)\depth(\circuit_\linput) + \degree(\circuit_\linput) + \depth(\circuit_\linput) + 1 + \degree(\circuit_\rinput)\depth(\circuit_\rinput) +\nonumber\\
&\qquad \degree(\circuit_\rinput) + \depth(\circuit_\rinput) + 1 + 1\nonumber\\
&= \degree(\circuit_\linput)\depth(\circuit_\linput) + \degree(\circuit_\linput) + \depth_{\max}(\circuit_i) + \degree(\circuit_\rinput)\depth(\circuit_\rinput) +\nonumber\\
&\qquad \degree(\circuit_\rinput) + \depth_{\min}(\circuit_i) + 3\label{eq:times-middle-expanded}
\end{align}
Note that we can arbitrarily choose one of $\circuit_\linput$ or $\circuit_\rinput$ to have either the $\min$ or $\max$ \depth and the other to have the opposite \depth without loss of generality.
Upon inspection, one can note that we have the following simplified LHS inequality of (\ref{eq:times-lhs}$\geq$\ref{eq:times-middle}.
\begin{equation}
\degree(\circuit_\linput) + \degree(\circuit_\rinput) \geq 1,
\end{equation}
and by the constraint that given a circuit \circuit, at least one input must have $\degree(\circuit_i) \geq 1$, the inequality is upheld.
%The left inequality holds since it is always the case that $(\degree(\circuit_i) + 1) \cdot (\depth(\circuit_i) + 2) > (\degree(\circuit_i) + 1) \cdot (\depth(\circuit_i) + 1)$ for $\degree(\circuit_i), \depth(\circuit_i) \geq 0$ . The second inequality holds by I.H. It follows that $\degree(\circuit) \cdot \depth(\circuit) \geq \cost(\circuit)$.
% we have already seen that \sampmon visits all inputs of \circuit. Then \sampmon visits at most $\cost(\circuit) = 1 + \cost(\circuit_\linput) + \cost(\circuit_\rinput)$ gates. Since we have that $\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) \geq \cost(\circuit_\linput)$ for $\circuit_\linput$ and $\degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) \geq \cost(\circuit_\rinput)$ for $\circuit_\rinput$, then we have that $\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + \degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput)$ gates have been traversed. It is trivial to see that the sink gate \circuit has $\leq k$ gates, thus holding the $O(k\cdot d)\geq\cost(\circuit)$ bound.
If \circuit.\type $= \circplus$, then substituting values yields
\begin{align*}
&(\max(\degree(\circuit_\linput), \degree(\circuit_\rinput)) + 1) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 2\right)\\
&\qquad \geq \max\left((\degree(\circuit_\linput) + 1) \cdot \left(\depth(\circuit_\linput) + 1\right), \left(\degree(\circuit_\rinput) + 1\right) \cdot \left(\depth(\circuit_\linput) + 1\right)\right)\\
&\qquad \text{ } + 1\\
&\qquad\qquad \geq 1 + \max(\cost(\circuit_\linput), \cost(\circuit_\rinput))
\end{align*}
The above inequalities hold for the same reasons as for the case $\circuit.\type = \circmult$. Thus, $\degree(\circuit)\cdot\depth(\circuit) \geq \cost(\circuit)$.
%\sampmon samples exactly one of its inputs. Then it follows that $\cost(\circuit) = 1 + max\left(\cost(\circuit_\linput), \cost(\circuit_\rinput)\right)$. Suppose that $max\left(\cost(\circuit_\linput), \cost(\circuit_\rinput)\right) = \circuit_\linput$, then it is the case that $k \geq k'$, with a bound $O(k' \cdot d - 1)\geq \cost(\circuit_\linput)$ on $\circuit_\linput$, and this implies a bound of $O\left(k \cdot d\right)\geq \cost(\circuit)$ on \circuit since sink gate \circuit has $\leq k$ nodes.
\begin{align}
&(\max(\degree(\circuit_\linput), \degree(\circuit_\rinput)) + 1) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 2\right)\label{eq:plus-lhs-inequality}\\
&\qquad \geq \max\left((\degree(\circuit_\linput) + 1) \cdot \left(\depth(\circuit_\linput) + 1\right),\right.\nonumber\\
&\qquad \left.\left(\degree(\circuit_\rinput) + 1\right) \cdot \left(\depth(\circuit_\linput) + 1\right)\right)\nonumber\\
&\qquad \text{ } + 1\label{eq:plus-middle}\\
&\qquad\qquad \geq 1 + \max(\cost(\circuit_\linput), \cost(\circuit_\rinput))\nonumber
\end{align}
We can rewrite \Cref{eq:plus-lhs-inequality} as
\begin{equation}
\degree_{\max}(\circuit_i)\depth_{\max}(\circuit_j) + 2\degree_{\max}(\circuit_i) + \depth_{\max}(\circuit_j) + 2.\label{eq:plus-lhs-expanded}
\end{equation}
Similarly, \Cref{eq:plus-middle} is upper bounded by
\begin{equation}
\leq \degree_{\max}(\circuit_i)\depth_{\max}(\circuit_j) + \degree_{\max}(\circuit_i) + \depth_{\max}(\circuit_j) + 2.\label{eq:plus-middle-expanded}
\end{equation}
It can be readily seen that \Cref{eq:plus-lhs-expanded} $\geq$ \Cref{eq:plus-middle-expanded} and the inequalities are upheld. This proves the claimed upper bound.
}
%\sampmon samples exactly one of its inputs. Then it follows that $\cost(\circuit) = 1 + max\left(\cost(\circuit_\linput), \cost(\circuit_\rinput)\right)$. Suppose that $max\left(\cost(\circuit_\linput), \cost(\circuit_\rinput)\right) = \circuit_\linput$, then it is the case that $k \geq k'$, with a bound $O(k' \cdot d - 1)\geq \cost(\circuit_\linput)$ on $\circuit_\linput$, and this implies a bound of $O\left(k \cdot d\right)\geq \cost(\circuit)$ on \circuit since sink gate \circuit has $\leq k$ nodes.
%}
%\revision{
%\begin{Definition}[Equivalent Expression Tree]\label{def:eet}
%Given an arbitrary circuit \circuit, there exists an equivalent expression tree \etree such that \etree is a copy of \circuit for all gates \gate where \gate has an outdegree $\leq 1$. When \gate has an outdegree greater than one, \gate is duplicated to be a subtree for each `extra' parent of \gate. We define this recursively as follows.

View file

@ -296,9 +296,11 @@
\newcommand{\lwght}{\vari{Lweight}}
\newcommand{\rwght}{\vari{Rweight}}
\newcommand{\prt}{\vari{partial}}
\newcommand{\degval}{\vari{degree}}
\newcommand{\type}{\vari{type}}
\newcommand{\subgraph}{\vari{S}_{\equivtree(\circuit)}}
\newcommand{\cost}{\func{Cost}}
\newcommand{\nullval}{NULL}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Sets

View file

@ -109,7 +109,7 @@ 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 nodes and sink node of $\circuit$ have binary input and are either sum ($\circplus$) or product ($\circmult$) gates.
$\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 (a constant or variable), 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 (with edges pointing towards the root), we will refer to the structure as an expression tree \etree. Note that in such a case, the root of \etree is analogous to the sink of the \circuit.
$\circuit$ additionally has the following members: \type, \val, \vari{partial}, \vari{input}, \degval 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 (a constant or variable), and \vari{input} is the list of \circuit 's inputs where $\circuit_\linput$ is the left input and $\circuit_\rinput$ the right input. The member \degval holds the degree of \circuit. When the underlying DAG is a tree (with edges pointing towards the root), we will refer to the structure as an expression tree \etree. Note that in such a case, the root of \etree is analogous to the sink of the \circuit.
\end{Definition}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%