Finished all @atri 030421 and 030521 changes.

This commit is contained in:
Aaron Huber 2021-03-05 16:42:12 -05:00
parent 71d1fd44d7
commit c77ae26066
2 changed files with 79 additions and 106 deletions

View file

@ -447,9 +447,8 @@ 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'$.
For technical reasons, we require the invariant that every subcircuit \subcircuit corresponding to an internal gate of \circuit has an input $\subcircuit_i$ such that $\degree\left(\polyf(\subcircuit_i)\right) \geq 1$. To ensure this, auxiliary algorithm ~\ref{alg:reduce} (\reduce) is called to perform any rewrites to \circuit, where an equivalent circuit \circuit' is created and returned by iteratively combining non-variable leaf nodes bottom-up until a parent node is reached which has an input \subcircuit whose subcircuit contains at least one leaf of type \var. It is trivial to see in such a case that $\subcircuit \equiv \subcircuit'$, and this implies $\circuit \equiv \circuit'$.
}
@ -520,6 +519,38 @@ level 2/.style={sibling distance=0.7cm},
\subsection{\onepass}
\revision{
\begin{algorithm}[h!]
\caption{\reduce$(\circuit)$}
\label{alg:reduce}
\begin{algorithmic}[1]
\Require \circuit: Circuit
\Ensure \circuit: Reduced Circuit
\For{\gate in \topord(\circuit)}\label{alg:reduce-loop}\Comment{\topord($\cdot$) is the topological order of \circuit}
\If{\gate.\type $=$ \var}
\State \gate.\degval $\gets 1$
\ElsIf{\gate.\type $=$ \tnum}
\State \gate.\degval $\gets 0$
\ElsIf{\gate.\type $= \circmult$}
\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
\Else
\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
\EndIf
\EndFor
\State \Return $\circuit$
\end{algorithmic}
\end{algorithm}
}
\revision{
\begin{algorithm}[h!]
\caption{\onepass$(\circuit)$}
\label{alg:one-pass-iter}
@ -530,29 +561,12 @@ 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
}
\ElsIf{\gate.\type $= \circmult$}
\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
}
\Else
\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}
@ -570,21 +584,16 @@ level 2/.style={sibling distance=0.7cm},
\paragraph{\onepass Correctness}
We prove the correct computation of \prt, \lwght, \rwght values on \circuit by induction over the number of iterations in line ~\ref{alg:one-pass-loop} over the topological order \topord of the input circuit \circuit. Note that \topord is the standard definition of a topological ordering over the DAG structure of \circuit.
For the base case, we have only one gate, which by definition is a source gate and must be either \var or \tnum. In this case, as per ~\ref{eq:T-all-ones}, lines ~\ref{alg:one-pass-var} and ~\ref{alg:one-pass-num} correctly compute \circuit.\prt as $1$ and \circuit.\val respectively.
For the base case, we have only one gate, which by definition is a source gate and must be either \var or \tnum. In this case, as per \Cref{eq:T-all-ones}, lines ~\ref{alg:one-pass-var} and ~\ref{alg:one-pass-num} correctly compute \circuit.\prt as $1$ and \circuit.\val respectively.
For the inductive hypothesis, assume that \onepass correctly computes \subcircuit.\prt, \subcircuit.\lwght, and \subcircuit.\rwght for all gates \subcircuit in \circuit with $k > 0$ iterations over \topord.
For the inductive hypothesis, assume that \onepass correctly computes \subcircuit.\prt, \subcircuit.\lwght, and \subcircuit.\rwght for all gates \gate in \circuit with $k > 0$ iterations over \topord.
We now prove for $k + 1$ iterations that \onepass correctly computes the \prt, \lwght, and \rwght values for each gate $\gate_\vari{i}$ in \circuit. %By the hypothesis the first $k$ gates (alternatively \textit{iterations}) have correctly computed values.
Note that the $\gate_\vari{k + 1}$ must be in the last ordering of all gates $\gate_\vari{i}$ for $i \in [k + 1]$. It is also the case that $\gate_{k+1}$ has at most two children. Finally, note that for \size(\circuit) > 1, $\gate_{k+1}$ is an internal node and implying that $\gate_\vari{s}.\type = \circplus$ or $\gate_\vari{s}.\type = \circmult$.
Note that the $\gate_\vari{k + 1}$ must be in the last ordering of all gates $\gate_\vari{i}$ for $i \in [k + 1]$. It is also the case that $\gate_{k+1}$ has two inputs. Finally, note that for \size(\circuit) > 1, if $\gate_{k+1}$ is a leaf node, we are back to the base case. Otherwise $\gate_{k + 1}$ is an internal node $\gate_\vari{s}.\type = \circplus$ or $\gate_\vari{s}.\type = \circmult$.
When $\gate_{k+1}.\type = \circplus$, then by line ~\ref{alg:one-pass-plus} $\gate_{k+1}.\prt = \gate_{{k+1}_\lchild}.\prt + \gate_{{k+1}_\rchild}.\prt$, a correct computation, as per ~\ref{eq:T-all-ones}. Further, lines ~\ref{alg:one-pass-lwght} and ~\ref{alg:one-pass-rwght} compute $\gate_{{k+1}}.\lwght = \frac{\gate_{{k+1}_\lchild}.\prt}{\gate_{{k+1}}.\prt}$ and analogously for $\gate_{{k+1}}.\rwght$. Note that all values needed for each computation have been correctly computed by the I.H.
When $\gate_{k+1}.\type = \circplus$, then by line ~\ref{alg:one-pass-plus} $\gate_{k+1}$.\prt $= \gate_{{k+1}_\lchild}$.\prt $+ \gate_{{k+1}_\rchild}$.\prt, a correct computation, as per \Cref{eq:T-all-ones}. Further, lines ~\ref{alg:one-pass-lwght} and ~\ref{alg:one-pass-rwght} compute $\gate_{{k+1}}.\lwght = \frac{\gate_{{k+1}_\lchild}.\prt}{\gate_{{k+1}}.\prt}$ and analogously for $\gate_{{k+1}}.\rwght$. Note that all values needed for each computation have been correctly computed by the I.H.
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.
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 \Cref{eq:T-all-ones}.
\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)$.
@ -639,116 +648,79 @@ 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)$.
\revision{
We now bound the number of recursive calls in $\sampmon$ by $O\left(k\cdot \depth(\circuit)\right)$.
Let \cost be a function that models an upper bound on the number of gates that can be visited in the run of \sampmon. We define \cost recursively as follows.
\begin{equation*}
\begin{equation}
\cost(\circuit) =
\begin{cases}
1 + \cost(\circuit_\linput) + \cost(\circuit_\rinput) & \textbf{if } \text{\circuit.\type = }\circmult\\
1 + \max\left(\cost(\circuit_\linput), \cost(\circuit_\rinput)\right) & \textbf{if } \text{\circuit.\type = \circplus}\\
1 & \textbf{otherwise}
\end{cases}
\end{equation*}
\end{cases}\label{eq:cost-sampmon}
\end{equation}
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.
First note that the runtime of \sampmon is $O\left(\cost(\circuit)\right)$. To show that \Cref{eq:cost-sampmon} is correct, note that 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 the following inequality
We prove the following inequality holds.
\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}
2\degree(\circuit) \cdot \depth(\circuit) + 1 \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$.
Note that \Cref{eq:strict-upper-bound} implies the claimed runtime. We prove \Cref{eq:strict-upper-bound} for the number of gates traversed in \sampmon using induction over $\depth(\circuit)$. Recall that \reduce 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 $\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)$.
Now consider the case when \sampmon has an arbitrary circuit \circuit input with $\depth(\circuit) = \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) - 1$ and $\depth(\circuit_\rinput) \leq \depth(\circuit) - 1$.
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)$. In either case it is true that $\depth(\circuit) = \max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1$.
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, 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}.
&2\left(\degree(\circuit_\linput) + \degree(\circuit_\rinput)\right) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1\right) \label{eq:times-lhs}\\
&\qquad\geq 2\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + 2 \degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) + 3\label{eq:times-middle} \\
&\qquad\qquad\geq 1 + \cost(\circuit_\linput) + \cost(\circuit_\rinput) = \cost(\circuit)\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.
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},
Let us expand \Cref{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}
(\ref{eq:times-lhs}) &= 2\degree(\circuit_\linput)\depth_{\max} + 2\degree(\circuit_\rinput)\depth_{\max} + 2\degree(\circuit_\linput) +\nonumber \\
& 2\degree(\circuit_\rinput) + 1\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}.
where $\depth_{\max}$ is used to denote the maximum depth of the two input subcircuits.
Let us simplify the inequality $(\ref{eq:times-lhs}) \geq (\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}
&2\degree(\circuit_\linput)\depth_{\max} + 2\degree(\circuit_\rinput)\depth_{\max} + 2\degree(\circuit_\linput) + 2\degree(\circuit_\rinput) + 1 \nonumber\\
&\qquad \geq 2\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + 2 \degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) + 3\nonumber\\
&\implies 2\degree(\circuit_\linput) + 2\degree(\circuit_\rinput) + 1 \geq 3\label{eq:times-lhs-middle-step1}
\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.
Note that by the \emph{reduced} invariant of \reduce, a circuit \circuit with $\depth(\circuit) > 1$ will always have at least one input with $\degree(\circuit_i) \geq 1$. Thus, the inequality is upheld.
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)\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
&2\max(\degree(\circuit_\linput), \degree(\circuit_\rinput)) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1\right) +1\label{eq:plus-lhs-inequality}\\
&\qquad \geq \max\left(2\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + 1,\degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) +1\right)\label{eq:plus-middle}\\
&\qquad\qquad \geq 1 + \max(\cost(\circuit_\linput), \cost(\circuit_\rinput)) = \cost(\circuit)\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}
2\degree_{\max}\depth_{\max} + 2\degree_{\max}.\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}
\leq 2\degree_{\max}\depth_{\max} + 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.
%\end{Definition}
%$\equivtree(\circuit) =
% \begin{cases}
% \emptyset & \textbf{if } \text{\circuit does not exist}\\
% \left(\circuit.\val, \equivtree(\circuit_\linput), \equivtree(\circuit_\rinput)\right) & \textbf{if } \text{\circuit is an iternal node}\\
% \circuit.\val & \textbf{otherwise}
%\end{cases}$
%
%\begin{Definition}[Expression Tree Subgraph]\label{def:etree-subgraph}
%Given an arbitrary circuit \circuit, the union of corresponding paths in $\equivtree(\circuit)$ traversed in \sampmon(\circuit) for all variables forming the output sampled in \sampmon constitutes the Expression Tree Subgraph.
%\end{Definition}
%
%For an arbitrary circuit \circuit with $\degree(k)$, it must be the case that the subgraph $\subgraph$ of $\equivtree(\circuit)$ has at most $k$ nodes at each level. This is true by the fact that for each internal node at least one or more children nodes will be visited by \sampmon all the way down to the leaves, and by definition, there are $O(k)$ leaf nodes in a polynomial with $\degree(k)$. Since it is also the case that $\equivtree(\circuit)$ has \depth(d), this then implies a bound of $O\left(k \cdot \depth(d)\right)$.
%
%We now prove that \depth(\circuit) = \depth($\equivtree(\circuit)$).
%}
%\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.
%}
%
Simplifying the inequality $(\ref{eq:plus-lhs-expanded}) \geq (\ref{eq:plus-middle-expanded})$, we obtain
\begin{align}
&2\degree_{\max}\depth_{\max} + 2\degree_{\max} \geq 2\degree_{\max}\depth_{\max} + 2\nonumber\\
&\implies 2\degree_{\max} \geq 2\label{eq:plus-upper-bound-final}.
\end{align}
For the same reason as in the $\times$ case \Cref{eq:plus-upper-bound-final} holds, and this proves the claimed upper bound.
It is easy to check that except for~\Cref{alg:sample-times-union}, all other lines take $O(1)$ time. Thus, overall all lines except for~\Cref{alg:sample-times-union} take $O(k\cdot \depth(\circuit))$ time. Now consider all executions of~\Cref{alg:sample-times-union} together. We note that at each level we will be adding a given set of variables to some set at most once: since the sum of the sizes of the sets at a given level is at most $k$, each level involves $O(k\log{k})$ time. Thus, overall all executions of~\Cref{alg:sample-times-union} takes $O(k\log{k}\cdot \depth(\circuit))$ time, as desired.

View file

@ -73,6 +73,7 @@
\newcommand{\approxq}{\algname{Approximate$\rpoly$}}
\newcommand{\onepass}{\algname{OnePass}}
\newcommand{\sampmon}{\algname{SampleMonomial}}
\newcommand{\reduce}{\algname{Reduce}}
\newcommand{\ceil}[1]{\left\lceil #1 \right\rceil}
\newcommand{\vari}[1]{\texttt{#1}\xspace}
\newcommand{\accum}{\vari{acc}}