Restructured SampMonomial proof (num nodes visited)

master
Aaron Huber 2021-04-09 16:13:35 -04:00
parent 9dade793f7
commit 6c76d17ca5
5 changed files with 115 additions and 88 deletions

View File

@ -176,6 +176,7 @@ Now consider the case when the sink node is $+$, we get that
&\leq 2^{2^kN}.
\end{align*}
In the above the first inequality follows from the inductive hypothesis while the second inequality follows from the facts that $k_\linput,k_\rinput\le k$ and $N_\linput,N_\rinput\le N-1$. The final inequality follows from the fact that $k\ge 0$.
\qed
\end{proof}
Finally, we consider the case when $\circuit$ encodes the run of the algorithm from~\cite{DBLP:conf/pods/KhamisNR16} on an FAQ query. We cannot handle the full generality of an FAQ query but we can handle an FAQ query that has a ``core'' join query on $k$ relations and then a subset of the $k$ attributes are ``summed'' out (e.g. the sum could be because of projecting out a subset of attributes from the join query). While the algorithm~\cite{DBLP:conf/pods/KhamisNR16} essentially figures out when to `push in' the sums, in our case since we only care about $\abs{\circuit}(1,\dots,1)$ we will consider the obvious circuit that computes the ``inner join'' using a worst-case optimal join (WCOJ) algorithm like~\cite{NPRR} and then adding in the addition gates. The basic idea is very simple: we will argue that the there are at most $\size(\circuit)^k$ tuples in the join output (each with having a value of $1$ in $\abs{\circuit}(1,\dots,1)$). Then the largest value we can see in $\abs{\circuit}(1,\dots,1)$ is by summing up these at most $\size(\circuit)^k$ values of $1$. Note that this immediately implies the claimed bound in~\Cref{lem:val-ub}.

View File

@ -7,33 +7,35 @@ Please note that it is \textit{assumed} that the original call to \onepass consi
\input{app_one-pass-eval-notes}
\begin{Definition}[Equivalence ($\equiv$)]
A circuit \circuit is equivalent to a circuit \circuit' if and only if $\polyf(\circuit) = \polyf(\circuit')$.
\end{Definition}
%%%%%%%%%%%REDUCE ALGO%%%%%%%%%%%%%%%%%%%
%\begin{Definition}[Equivalence ($\equiv$)]
%A circuit \circuit is equivalent to a circuit \circuit' if and only if $\polyf(\circuit) = \polyf(\circuit')$.
%\end{Definition}
For technical reasons, we require the invariant that every subcircuit \subcircuit corresponding to an internal gate of \circuit has $\degree\left(\subcircuit\right) \geq 1$. \revision{\textbf{AARON:} This is now trivially satisfied by the new definition of $\deg(\circuit)$ so please update this part to remove the stuff on $\reduce$. --Atri} 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'$.
\begin{Lemma}\label{lem:reduce}
In $O(\size(\circuit))$, algorithm \reduce inspects input circuit \circuit and outputs an equivalent version \circuit' of \circuit such that all subcircuits \subcircuit of \circuit' have $\degree(\subcircuit) \geq 1$.
\end{Lemma}
\begin{proof}[Proof of \Cref{lem:reduce}]
~\paragraph{\reduce correctness}
Note that for a source gate \gate, only when $\gate.\type = \var$ is it the case that $\degree(\gate) = 1$, and otherwise $\degree(\gate) = 0$. Lines~\ref{alg:reduce-add-deg} and~\ref{alg:reduce-no-deg} compute \gate.\degval.
We prove an equivalent circuit \circuit' by induction over the iteration of \topord. For the base case, consider when we have one node. In such a case, no rewriting occurs, and \reduce returns \circuit. It is trivial to note that $\circuit \equiv \circuit$.
For the inductive hypothesis, we assume that for $k \geq 0$ nodes in \topord, the modified circuit $\circuit_k' \equiv \circuit_k$, where $\circuit_k'$ denotes the circuit at the end of iteration $k$. Similarly, when discussing \Cref{alg:reduce} pseudocode, $\gate_{k}$ denotes the gate in position $k$ of \topord, and $\gate_{k_\linput}$ ($\gate_{k_\rinput}$) denotes the left (right) input of $\gate_{k}$.
We now prove for $k + 1$ gates in \topord that $\circuit_{k + 1}' \equiv \circuit_{k + 1}$. Note that if the gate $\gate_{k + 1}$ is a source node, then this is again the base case and we are finished. If $\gate_{k + 1}$ is an internal node, then $\gate_{k + 1}.\type$ must either be $\circmult$ or $\circplus$.
When $\gate_{k + 1}$ is $\circmult$, then it is the case that either $\degree(\gate_{{k + 1}_\linput}) \geq 1$ or $\gate_{{k + 1}_\linput}.\type$ is $\tnum$ and likewise for $\gate_{{k + 1}_\rinput}$. There are then four possibilities, only one of which will prompt a rewrite, namely when we have that both inputs have $\degree(\gate_{{k + 1}_i}) = 0$. In such a case, $\gate_{k + 1}.\val \gets \gate_{{k + 1}_\linput}.\val \times \gate_{{k + 1}_\rinput}.\val$, and the inputs are deleted. Note that since $\gate_{{k + 1}_\linput}.\type = \gate_{{k + 1}_\rinput}.\type = \tnum$ that we have two constants being multiplied, and that for subcircuit $\subcircuit = (\times, \tnum_1, \tnum_2)$ and $\tnum' = \tnum_1 \times \tnum_2$, $\polyf(\subcircuit) = \polyf(\tnum')$ which implies that for the rewritten \subcircuit', $\subcircuit \equiv \subcircuit'$.
A analogous argument applies when $\gate_{k + 1}.\type$ is $\circplus$.\qed
\paragraph{\reduce Run-time Analysis}.
$O(\size(\circuit))$ trivially follows by the single iterative pass over the \topord of \circuit, where, as can be seen in lines~\ref{alg:reduce-var},~\ref{alg:reduce-num},~\ref{alg:reduce-mult}, and~\ref{alg:reduce-plus} a constant number of operations are performed on each node.\qed
\end{proof}
%For technical reasons, we require the invariant that every subcircuit \subcircuit corresponding to an internal gate of \circuit has $\degree\left(\subcircuit\right) \geq 1$. \revision{\textbf{AARON:} This is now trivially satisfied by the new definition of $\deg(\circuit)$ so please update this part to remove the stuff on $\reduce$. --Atri} 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'$.
%
%\begin{Lemma}\label{lem:reduce}
%In $O(\size(\circuit))$, algorithm \reduce inspects input circuit \circuit and outputs an equivalent version \circuit' of \circuit such that all subcircuits \subcircuit of \circuit' have $\degree(\subcircuit) \geq 1$.
%\end{Lemma}
%
%\begin{proof}[Proof of \Cref{lem:reduce}]
%~\paragraph{\reduce correctness}
%Note that for a source gate \gate, only when $\gate.\type = \var$ is it the case that $\degree(\gate) = 1$, and otherwise $\degree(\gate) = 0$. Lines~\ref{alg:reduce-add-deg} and~\ref{alg:reduce-no-deg} compute \gate.\degval.
%
%We prove an equivalent circuit \circuit' by induction over the iteration of \topord. For the base case, consider when we have one node. In such a case, no rewriting occurs, and \reduce returns \circuit. It is trivial to note that $\circuit \equiv \circuit$.
%
%For the inductive hypothesis, we assume that for $k \geq 0$ nodes in \topord, the modified circuit $\circuit_k' \equiv \circuit_k$, where $\circuit_k'$ denotes the circuit at the end of iteration $k$. Similarly, when discussing \Cref{alg:reduce} pseudocode, $\gate_{k}$ denotes the gate in position $k$ of \topord, and $\gate_{k_\linput}$ ($\gate_{k_\rinput}$) denotes the left (right) input of $\gate_{k}$.
%
%We now prove for $k + 1$ gates in \topord that $\circuit_{k + 1}' \equiv \circuit_{k + 1}$. Note that if the gate $\gate_{k + 1}$ is a source node, then this is again the base case and we are finished. If $\gate_{k + 1}$ is an internal node, then $\gate_{k + 1}.\type$ must either be $\circmult$ or $\circplus$.
%
%When $\gate_{k + 1}$ is $\circmult$, then it is the case that either $\degree(\gate_{{k + 1}_\linput}) \geq 1$ or $\gate_{{k + 1}_\linput}.\type$ is $\tnum$ and likewise for $\gate_{{k + 1}_\rinput}$. There are then four possibilities, only one of which will prompt a rewrite, namely when we have that both inputs have $\degree(\gate_{{k + 1}_i}) = 0$. In such a case, $\gate_{k + 1}.\val \gets \gate_{{k + 1}_\linput}.\val \times \gate_{{k + 1}_\rinput}.\val$, and the inputs are deleted. Note that since $\gate_{{k + 1}_\linput}.\type = \gate_{{k + 1}_\rinput}.\type = \tnum$ that we have two constants being multiplied, and that for subcircuit $\subcircuit = (\times, \tnum_1, \tnum_2)$ and $\tnum' = \tnum_1 \times \tnum_2$, $\polyf(\subcircuit) = \polyf(\tnum')$ which implies that for the rewritten \subcircuit', $\subcircuit \equiv \subcircuit'$.
%
%A analogous argument applies when $\gate_{k + 1}.\type$ is $\circplus$.\qed
%
%\paragraph{\reduce Run-time Analysis}.
%$O(\size(\circuit))$ trivially follows by the single iterative pass over the \topord of \circuit, where, as can be seen in lines~\ref{alg:reduce-var},~\ref{alg:reduce-num},~\ref{alg:reduce-mult}, and~\ref{alg:reduce-plus} a constant number of operations are performed on each node.\qed
%\end{proof}
\subsection{$\onepass$ Example}
\begin{Example}\label{example:one-pass}
@ -100,36 +102,37 @@ level 2/.style={sibling distance=0.7cm},
\subsection{\onepass}
\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}\label{alg:reduce-var}
\State \gate.\degval $\gets 1$\label{alg:reduce-add-deg}
\ElsIf{\gate.\type $=$ \tnum}\label{alg:reduce-num}
\State \gate.\degval $\gets 0$\label{alg:reduce-no-deg}
\ElsIf{\gate.\type $= \circmult$}\label{alg:reduce-mult}
\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 \label{alg:reduce-plus}
\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}
%%%%%%%%%%%%%%%%REDUCE ALGO PSEUDOCODE%%%%%%%%%%%
%\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}\label{alg:reduce-var}
% \State \gate.\degval $\gets 1$\label{alg:reduce-add-deg}
% \ElsIf{\gate.\type $=$ \tnum}\label{alg:reduce-num}
% \State \gate.\degval $\gets 0$\label{alg:reduce-no-deg}
% \ElsIf{\gate.\type $= \circmult$}\label{alg:reduce-mult}
% \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 \label{alg:reduce-plus}
% \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}
\begin{algorithm}[h!]
\caption{\onepass$(\circuit)$}
@ -158,7 +161,7 @@ level 2/.style={sibling distance=0.7cm},
\end{algorithm}
\subsection{Proof of ~\Cref{lem:one-pass}}\label{sec:proof-one-pass}
\paragraph{\onepass Correctness}
\begin{proof}
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 \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.
@ -172,14 +175,16 @@ 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 \Cref{eq:T-all-ones}.
\paragraph{\onepass Runtime}
\paragraph*{Runtime Analysis}
It is known that $\topord(G)$ is computable in linear time. Next, each of the $\size(\circuit)$ iterations of the loop in \cref{alg:one-pass-loop} take $O\left( \multc{\log\left(\abs{\circuit(1\ldots, 1)}\right)}{\log{\size(\circuit)}}\right)$ time. It is easy to see that each of all the numbers which the algorithm computes is at most $\abs{\circuit}(1,\dots,1)$. Hence, by definition each such operation takes $\multc{\log\left(\abs{\circuit(1\ldots, 1)}\right)}{\log{\size(\circuit)}}$ time, which proves the claimed runtime.
\qed
\end{proof}
%In general it is known that an arithmetic computation which requires $M$ bits takes $O(\frac{\log{M}}{\log{N}})$ time for an input size $N$. Since each of the arithmetic operations at a given gate has a bit size of $O(\log{\abs{\circuit}(1,\ldots, 1)})$, thus, we obtain the general runtime of $O\left(\size(\circuit)\cdot \frac{\log{\abs{\circuit}(1,\ldots, 1)}}{\log{\size(\circuit)}}\right)$.
%%%Moved the stuff below to earlier in the appendix
\iffalse
\paragraph{Sufficient condition for $\abs{\circuit}(1,\ldots, 1)$ to be size $O(N)$}
\paragraph*{Sufficient condition for $\abs{\circuit}(1,\ldots, 1)$ to be size $O(N)$}
For our runtime results to be relevant, it must be the case that the sum of the coefficients computed by \onepass is indeed size $O(N)$ since there are $O(\log{N})$ bits in the RAM model where $N$ is the size of the input. The size of the input here is \size(\circuit). We show that when \size$(\circuit_\linput) = N_\linput$, \size$(\circuit_\rinput) = N_\rinput$, where $N_\linput + N_\rinput \leq N$, this is indeed the case.
\begin{proof}%[Proof of $\abs{\circuit}(1,\ldots, 1)$ is size $O(N)$]

View File

@ -52,7 +52,7 @@ and we obtain the desired result.
%\paragraph*{Run-time Analysis}
\paragraph*{Run-time Analysis}
It is easy to check that except for lines~\ref{alg:sample-times-union} and~\ref{alg:sample-plus-bsamp}, all lines take $O(1)$ time. For \Cref{alg:sample-times-union}, consider an execution of~\Cref{alg:sample-times-union}. We note that 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 $\degree(\circuit)$, each gate visited takes $O(\log{\degree(\circuit)})$. For \Cref{alg:sample-plus-bsamp}, note that we pick $\circuit_\linput$ with probability $\frac a{a+b}$ where $a=\circuit.\vari{Lweight}$ and $b=\circuit.\vari{Rweight}$. We can implement this step by picking a random number $r\in[a+b]$ and then checking if $r\le a$. It is easy to check that $a+b\le \abs{\circuit}(1,\dots,1)$. This means we need to add and compare $\log{\abs{\circuit}(1,\ldots, 1)}$-bit numbers, which can certainly be done in time $\multc{\log\left(\abs{\circuit(1\ldots, 1)}\right)}{\log{\size(\circuit)}}$ (note that this is an over-estimate).
% we have $> O(1)$ time when $\abs{\circuit}(1,\ldots, 1) > \size(\circuit)$. when this is the case that for each sample, we have $\frac{\log{\abs{\circuit}(1,\ldots, 1)}}{\log{\size(\circuit)}}$ operations, since we need to read in and then compare numbers of of $\log{{\abs{\circuit}(1,\ldots, 1)}}$ bits.
Denote \cost(\circuit) (\Cref{eq:cost-sampmon}) to be an upper bound of the number of nodes visited by \sampmon. Then the runtime is $O\left(\cost(\circuit)\cdot \log{\degree(\circuit)}\cdot \multc{\log\left(\abs{\circuit(1\ldots, 1)}\right)}{\log{\size(\circuit)}}\right)$.
@ -74,74 +74,95 @@ First note that the number of gates visited in \sampmon is $\leq\cost(\circuit)$
We prove the following inequality holds.
\begin{equation}
2\degree(\circuit) \cdot \depth(\circuit) + 1 \geq \cost(\circuit)\label{eq:strict-upper-bound}
2\left(\degree(\circuit) + 1\right) \cdot \depth(\circuit) + 1 \geq \cost(\circuit)\label{eq:strict-upper-bound}
\end{equation}
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 $\subcircuit.\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 how degree is defined in \cref{def:degree}.
For the base case $\degree(\circuit) = \depth(\circuit) = 0$, $\cost(\circuit) = 1$, and it is trivial to see that the inequality $2\degree(\circuit) \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 1$.
Now consider the case when \sampmon has an arbitrary circuit \circuit input with $\depth(\circuit) = \ell + 1$. By definition \circuit.\type $\in \{\circplus, \circmult\}$. Note that since $\depth(\circuit) \geq 2$, \circuit must have inputs. Further we know that by the inductive hypothesis the inputs $\circuit_i$ for $i \in \{\linput, \rinput\}$ of the sink gate \circuit uphold the bound
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) = \ell + 1$. By definition \circuit.\type $\in \{\circplus, \circmult\}$. Note that since $\depth(\circuit) \geq 1$, \circuit must have input(s). Further we know that by the inductive hypothesis the inputs $\circuit_i$ for $i \in \{\linput, \rinput\}$ of the sink gate \circuit uphold the bound
\begin{equation}
2\degree(\circuit_i)\cdot \depth(\circuit_i) + 1 \geq \cost(\circuit_i).\label{eq:ih-bound-cost}
2\left(\degree(\circuit_i) + 1\right)\cdot \depth(\circuit_i) + 1 \geq \cost(\circuit_i).\label{eq:ih-bound-cost}
\end{equation}
It is also true 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 $= \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) + 1$. In either case it is true that $\depth(\circuit) = \max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1$.
If \circuit.\type $= \circmult$, then,
substituting values, the following should hold,
\begin{align}
&2\left(\degree(\circuit_\linput) + \degree(\circuit_\rinput)\right) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1\right) + 1 \nonumber\\%\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} \\
&2\left(\degree(\circuit_\linput) + \degree(\circuit_\rinput) + 2\right) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1\right) + 1 \nonumber\\%\label{eq:times-lhs}\\
&\qquad\geq 2\left(\degree(\circuit_\linput) + 1\right) \cdot \depth(\circuit_\linput) + 2\left(\degree(\circuit_\rinput) + 1\right)\cdot \depth(\circuit_\rinput) + 3\label{eq:times-middle} \\
&\qquad\geq 1 + \cost(\circuit_\linput) + \cost(\circuit_\rinput) = \cost(\circuit) (\ref{eq:cost-sampmon})\label{eq:times-rhs}.
\end{align}
To prove (\ref{eq:times-middle}), first, the LHS expands to, %\Cref{eq:times-lhs},
\begin{equation}
%(\ref{eq:times-lhs})
2\degree(\circuit_\linput)\depth_{\max} + 2\degree(\circuit_\rinput)\depth_{\max} + 2\degree(\circuit_\linput) + 2\degree(\circuit_\rinput) + 1\label{eq:times-lhs-expanded}
2\degree(\circuit_\linput)\cdot\depth_{\max} + 2\degree(\circuit_\rinput)\cdot\depth_{\max} + 4\depth_{\max} + 2\degree(\circuit_\linput) + 2\degree(\circuit_\rinput) + 4 + 1\label{eq:times-lhs-expanded}
\end{equation}
where $\depth_{\max}$ is used to denote the maximum depth of the two input subcircuits. The RHS expands to
\begin{equation}
2\degree(\circuit_\linput)\cdot\depth(\circuit_\linput) + 2\depth(\circuit_\linput) + 2\degree(\circuit_\rinput)\depth(\circuit_\rinput) + 2\depth(\circuit_\rinput) + 3\label{eq:times-middle-expanded}
\end{equation}
where $\depth_{\max}$ is used to denote the maximum depth of the two input subcircuits.
Let us now simplify the inequality (\ref{eq:times-middle}).
Putting \cref{eq:times-lhs-expanded} and \cref{eq:times-middle-expanded} together we get
\begin{align}
&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}
&2\degree(\circuit_\linput)\cdot\depth_{\max} + 2\degree(\circuit_\rinput)\cdot\depth_{\max} + 4\depth_{\max} + 2\degree(\circuit_\linput) + 2\degree(\circuit_\rinput) + 5\nonumber\\
&\qquad 2\degree(\circuit_\linput)\cdot\depth(\circuit_\linput) + 2\depth(\circuit_\linput) + 2\degree(\circuit_\rinput)\depth(\circuit_\rinput) + 2\depth(\circuit_\rinput) + 3\label{eq:times-lhs-middle}
\end{align}
Note that by the \emph{reduced} invariant of \reduce, a circuit \circuit with $\depth(\circuit) \geq 1$ will always have at least one input with $\degree(\circuit_i) \geq 1$. Thus, \Cref{eq:times-lhs-middle-step1} follows, and the inequality is upheld.
Now to justify (\ref{eq:times-rhs}) which holds for the following reasons. First, the RHS%\Cref{eq:times-rhs}
Since the following is always true,
\begin{align*}
&2\degree(\circuit_\linput)\cdot\depth_{\max} + 2\degree(\circuit_\rinput)\cdot\depth_{\max} + 4\depth_{\max} + 5\\
&\qquad \geq 2\degree(\circuit_\linput)\cdot\depth(\circuit_\linput) + 2\degree(\circuit_\rinput)\depth(\circuit_\rinput) + 2\depth(\circuit_\linput) + 2\depth(\circuit_\rinput) + 3,
\end{align*}
then it is the case that \cref{eq:times-lhs-middle} is \emph{always} true.
%Let us now simplify the inequality (\ref{eq:times-middle}).
%\begin{align}
%&2\degree(\circuit_\linput)\cdot\depth_{\max} + 2\degree(\circuit_\rinput)\cdot\depth_{\max} + 2\degree(\circuit_\linput) + 2\degree(\circuit_\rinput) + 2\depth_{\max} + 3 \nonumber\\
%&\qquad \geq 2\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + 2 \degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) + 3\label{eq:times-lhs-middle-step1}
%%&\implies 2\degree(\circuit_\linput) + 2\degree(\circuit_\rinput) + 1 \geq 3
%\end{align}
%Note that it is always the case that
%\begin{equation*}
%2\degree(\circuit_\linput)\cdot\depth_{\max} + 2\degree(\circuit_\rinput)\cdot\depth_{\max} + 3 \geq 2\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + 2 \degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) + 3
%\end{equation*}
%and \Cref{eq:times-lhs-middle-step1} follows.
Now to justify (\ref{eq:times-rhs}) which holds for the following reasons. First, the RHS %\Cref{eq:times-rhs}
is the result of \Cref{eq:cost-sampmon} when $\circuit.\type = \circmult$. The LHS %\Cref{eq:times-middle}
is then produced by substituting the upperbound of (\ref{eq:ih-bound-cost}) for each $\cost(\circuit_i)$, trivially establishing the upper bound of (\ref{eq:times-rhs}). This proves \Cref{eq:strict-upper-bound} for the $\circmult$ case.
For the case when \circuit.\type $= \circplus$, substituting values yields
\begin{align}
&2\max(\degree(\circuit_\linput), \degree(\circuit_\rinput)) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1\right) +1\nonumber\\%\label{eq:plus-lhs-inequality}\\
&\qquad \geq \max\left(2\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + 1, 2\degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) +1\right) + 1\label{eq:plus-middle}\\
&2\left(\max(\degree(\circuit_\linput), \degree(\circuit_\rinput)) + 1\right) \cdot \left(\max(\depth(\circuit_\linput), \depth(\circuit_\rinput)) + 1\right) +1\nonumber\\%\label{eq:plus-lhs-inequality}\\
&\qquad \geq \max\left(2\left(\degree(\circuit_\linput) + 1\right) \cdot \depth(\circuit_\linput) + 1, 2\left(\degree(\circuit_\rinput) + 1\right) \cdot \depth(\circuit_\rinput) +1\right) + 1\label{eq:plus-middle}\\
&\qquad \geq 1 + \max(\cost(\circuit_\linput), \cost(\circuit_\rinput)) = \cost(\circuit)\label{eq:plus-rhs}
\end{align}
To prove (\ref{eq:plus-middle}), we can rewrite the LHS as %(\ref{eq:plus-lhs-inequality}) as
To prove (\ref{eq:plus-middle}), the LHS expands to %(\ref{eq:plus-lhs-inequality}) as
\begin{equation}
2\degree_{\max}\depth_{\max} + 2\degree_{\max} + 1.\label{eq:plus-lhs-expanded}
2\degree_{\max}\depth_{\max} + 2\degree_{\max} + 2\depth_{\max} + 2 + 1.\label{eq:plus-lhs-expanded}
\end{equation}
Since $\degree_{\max} \cdot \depth_{\max} \geq \degree(\circuit_i)\cdot \depth(\circuit_i),$ the following upper bound holds for the RHS of (\ref{eq:plus-middle}):
Since $\degree_{\max} \cdot \depth_{\max} \geq \degree(\circuit_i)\cdot \depth(\circuit_i),$ the following upper bound holds for the expanded RHS of (\ref{eq:plus-middle}):
\begin{equation}
2\degree_{\max}\depth_{\max} + 2 \geq \max\left(2\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + 1, 2\degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) +1\right) + 1.\label{eq:plus-middle-expanded}
2\degree_{\max}\depth_{\max} + 2\depth_{\max} + 2 %\geq \max\left(2\degree(\circuit_\linput) \cdot \depth(\circuit_\linput) + 1, 2\degree(\circuit_\rinput) \cdot \depth(\circuit_\rinput) +1\right) + 1.
\label{eq:plus-middle-expanded}
\end{equation}
Substituting the upperbound (LHS) of (\ref{eq:plus-middle-expanded}) in for the RHS of (\ref{eq:plus-middle}) we obtain the following for (\ref{eq:plus-middle}):
Putting it together we obtain the following for (\ref{eq:plus-middle}):
\begin{align}
&2\degree_{\max}\depth_{\max} + 2\degree_{\max} + 1 \geq 2\degree_{\max}\depth_{\max} + 2\nonumber\\
&\implies 2\degree_{\max} + 1 \geq 2\label{eq:plus-upper-bound-final}.
&2\degree_{\max}\depth_{\max} + 2\degree_{\max} + 2\depth_{\max} + 3\nonumber\\
&\qquad \geq 2\degree_{\max}\depth_{\max} + 2\depth_{\max} + 2, \label{eq:plus-upper-bound-final}
\end{align}
As in the $\circmult$ case the \emph{reduced} invariant of \reduce implies that $\degree_{\max} \geq 1$, and (\ref{eq:plus-upper-bound-final}) follows. This proves (\ref{eq:plus-middle}).
where it can be readily seen that the inequality stand and (\ref{eq:plus-upper-bound-final}) follows. This proves (\ref{eq:plus-middle}).
Similar to the case of $\circuit.\type = \circmult$, (\ref{eq:plus-rhs}) follows by equations $(\ref{eq:cost-sampmon})$ and $(\ref{eq:ih-bound-cost})$.
This proves (\ref{eq:strict-upper-bound}) for the $\circplus$ case, as desired.
This proves (\ref{eq:strict-upper-bound}) as desired.
\qed
\end{proof}
% and thus the claimed $O(k\log{k}\cdot \frac{\log{\abs{\circuit}(1,\ldots, 1)}}{\size(\circuit)}\cdot\depth(\circuit))$ runtime for $k = \degree(\circuit)$ follows.

View File

@ -46,7 +46,7 @@ The function \size~ takes a circuit $\circuit$ as input and outputs the number o
The function \depth~ has circuit $\circuit$ as input and outputs the number of levels in \circuit.
\end{Definition}
\begin{Definition}[$\degree(\cdot)$]\footnote{Note that the degree of $\polyf(\abs{\circuit})$ is always upper bounded by $\deg(\circuit)$ and the latter can be strictly larger (e.g. consider the case when $\circuit$ multiplies two copies of the constant $1$-- here we have $\deg(\circuit)=1$ but degree of $\polyf(\abs{\circuit})$ is $0$).}
\begin{Definition}[$\degree(\cdot)$]\label{def:degree}\footnote{Note that the degree of $\polyf(\abs{\circuit})$ is always upper bounded by $\deg(\circuit)$ and the latter can be strictly larger (e.g. consider the case when $\circuit$ multiplies two copies of the constant $1$-- here we have $\deg(\circuit)=1$ but degree of $\polyf(\abs{\circuit})$ is $0$).}
$\degree(\circuit)$ is defined recursively as follows:
\[\degree(\circuit)=
\begin{cases}

View File

@ -63,7 +63,7 @@ $\semNX$-relations are closed under $\raPlus$ (\cref{fig:nxDBSemantics}).
\begin{figure}
\begin{align*}
\evald{\project_A(\rel)}{\db}(\tup) =& \sum_{\tup': \project_A(\tup') = \tup} \evald{\rel}{\db}(\tup') &
\evald{\project_A(\rel)}{\db}(\tup) =& \bigoplus_{\tup': \project_A(\tup') = \tup} \evald{\rel}{\db}(\tup') &
\evald{(\rel_1 \union \rel_2)}{\db}(\tup) =& \evald{\rel_1}{\db}(\tup) + \evald{\rel_2}{\db}(\tup)\\
\evald{\select_\theta(\rel)}{\db}(\tup) =& \begin{cases}
\evald{\rel}{\db}(\tup) & \text{if }\theta(\tup) \\