<p>I'd consider it unlikely that such a trick is easy to find and/or will give you significant gains, as it would give nontrivial satisfiability algorithms. Here's how:</p>

<p>First of all, while ostensibly easier, your problem can actually solve the more general problem of, given a circuit $C$ and $N$ inputs $x_0, \ldots, x_{N-1}$, evaluate $C$ at all the inputs faster than $\tilde{O}(N\cdot|C|)$ time. The reason is that we can tweak $C$ into a circuit $C'$ of size $|C| + \tilde{O}(Nn)$ which, on input $0^i10^{N-1-i}$, outputs $C(x_{i})$. Basically, we just make a little lookup table that sends $0^i10^{N-1-i}$ to $x_i$, and wire it into $C$.</p>

<p>Nontrivial algorithms for batch evaluation of boolean-circuits can then be used to make fast satisfiability algorithms. Here's an example in the simple case where we suppose we have an algorithm doing evaluation in time $\tilde{O}(|C|^{2-\epsilon} + (N\cdot|C|)^{1-\epsilon/2} + N^{2-\epsilon})$ for any constant $\epsilon &gt; 0$. On input a circuit $C$, we can decide satisfiability by expanding $C$ into a circuit $C'$ of size $2^{n/2}\cdot |C|$ which is just the OR over all possible choices of the first $n/2$ inputs to $C$ (leaving the other inputs free). We then batch-evaluate $C'$ on all of its $2^{n/2}$ inputs. The end result is that we find a satisfying assignment to $C'$ iff $C$ is satisfiable. The running time is $\tilde{O}(2^{(n/2)(2-\epsilon)}\cdot |C|^{2-\epsilon}) = \tilde{O}(2^{n(1-\epsilon/2)}\cdot \textrm{poly}(|C|))$.</p>

CC BY-SA 3.0
2016-08-11T04:48:31.523Z
2016-08-11T04:48:31.523Z
Andrew Morgan
<p>Suppose I have a boolean circuit $C$ that computes some function $f:\{0,1\}^n \to \{0,1\}$.  Assume the circuit is composed of AND, OR, and NOT gates with fan-in and fan-out at most 2.</p>

<p>Let $x \in \{0,1\}^n$ be a given input.  Given $C$ and $x$, I want to evaluate $C$ on the $n$ inputs that differ from $x$ in a single bit position, i.e., to compute the $n$ values $C(x^1),C(x^2),\dots,C(x^n)$ where $x^i$ is the same as $x$ except that its $i$th bit is flipped.</p>

<p>Is there a way to do this that is more efficient that independently evaluating $C$ $n$ times on the $n$ different inputs?</p>

<p>Assume $C$ contains $m$ gates.  Then independently evaluating $C$ on all $n$ inputs will take $O(mn)$ time.  Is there a way to compute $C(x^1),C(x^2),\dots,C(x^n)$ in $o(mn)$ time?</p>

<hr>

<p>Optional context: If we had an <em>arithmetic</em> circuit (whose gates are multiplication, addition, and negation) over $\mathbb{R}$, then it would be possible to compute the $n$ directional derivatives ${\partial f \over \partial x_i}(x)$ in $O(m)$ time.  Basically, we could use standard methods for computation of the gradient (back-propagation / chain rule), in $O(m)$ time.  That works because the corresponding function is continuous and differentiable.  I'm wondering whether something similar can be done for boolean circuits.  Boolean circuits aren't continuous and differentiable, so you can't do the same trick, but maybe there is some other clever technique one can use?  Maybe some kind of Fourier trick, or something?</p>

<p>(Variant question: if we have boolean gates with unbounded fan-in and bounded fan-out, can you do do asymptotically better than evaluating $C$ $n$ times?)</p>

CC BY-SA 3.0
2016-08-12T17:24:33.350Z
Since Andrew answered your question pretty well, I'll just leave a comment. If $m$ is large (like $O(2^n/n)$) and you're evaluating $C$ on many inputs (up to $2^{o(n/\log n)}$) then there is a $C'$ of size only $O(2^n/n)$ which can evaluate $C$ on any $m$ inputs. (The problem is also called "mass production" in the literature.) See Uhlig, "On the synthesis of self-correcting schemes from functional elements with a small number of reliable elements." Math.Notes Acad.Sci. USSR 15, 558--562. So in some cases you can do better with non-uniformity.
Ryan Williams
<ds.algorithms><circuit-complexity><boolean-functions><circuits>
Evaluate boolean circuit on batch of similar inputs
D.W.
# Evaluate boolean circuit on batch of similar inputs

(Asked by: username_0 on 2016-08-11)

Suppose I have a boolean circuit $C$ that computes some function $f:\{0,1\}^n \to \{0,1\}$. Assume the circuit is composed of AND, OR, and NOT gates with fan-in and fan-out at most 2.

Let $x \in \{0,1\}^n$ be a given input. Given $C$ and $x$, I want to evaluate $C$ on the $n$ inputs that differ from $x$ in a single bit position, i.e., to compute the $n$ values $C(x^1),C(x^2),\dots,C(x^n)$ where $x^i$ is the same as $x$ except that its $i$th bit is flipped.

Is there a way to do this that is more efficient that independently evaluating $C$ $n$ times on the $n$ different inputs?

Assume $C$ contains $m$ gates. Then independently evaluating $C$ on all $n$ inputs will take $O(mn)$ time. Is there a way to compute $C(x^1),C(x^2),\dots,C(x^n)$ in $o(mn)$ time?

---

Optional context: If we had an *arithmetic* circuit (whose gates are multiplication, addition, and negation) over $\mathbb{R}$, then it would be possible to compute the $n$ directional derivatives ${\partial f \over \partial x\_i}(x)$ in $O(m)$ time. Basically, we could use standard methods for computation of the gradient (back-propagation / chain rule), in $O(m)$ time. That works because the corresponding function is continuous and differentiable. I'm wondering whether something similar can be done for boolean circuits. Boolean circuits aren't continuous and differentiable, so you can't do the same trick, but maybe there is some other clever technique one can use? Maybe some kind of Fourier trick, or something?

(Variant question: if we have boolean gates with unbounded fan-in and bounded fan-out, can you do do asymptotically better than evaluating $C$ $n$ times?)

**Tags:** ds.algorithms, circuit-complexity, boolean-functions, circuits

> **Comments:**
> **username_1**: Since Andrew answered your question pretty well, I'll just leave a comment. If $m$ is large (like $O(2^n/n)$) and you're evaluating $C$ on many inputs (up to $2^{o(n/\log n)}$) then there is a $C'$ of size only $O(2^n/n)$ which can evaluate $C$ on any $m$ inputs. (The problem is also called "mass production" in the literature.) See Uhlig, "On the synthesis of self-correcting schemes from functional elements with a small number of reliable elements." Math.Notes Acad.Sci. USSR 15, 558--562. So in some cases you can do better with non-uniformity.  

---

## 1 answers

### Answer by username_2 on 2016-08-11. Score: 11 | Accepted answer

I'd consider it unlikely that such a trick is easy to find and/or will give you significant gains, as it would give nontrivial satisfiability algorithms. Here's how:

First of all, while ostensibly easier, your problem can actually solve the more general problem of, given a circuit $C$ and $N$ inputs $x\_0, \ldots, x\_{N-1}$, evaluate $C$ at all the inputs faster than $\tilde{O}(N\cdot|C|)$ time. The reason is that we can tweak $C$ into a circuit $C'$ of size $|C| + \tilde{O}(Nn)$ which, on input $0^i10^{N-1-i}$, outputs $C(x\_{i})$. Basically, we just make a little lookup table that sends $0^i10^{N-1-i}$ to $x\_i$, and wire it into $C$.

Nontrivial algorithms for batch evaluation of boolean-circuits can then be used to make fast satisfiability algorithms. Here's an example in the simple case where we suppose we have an algorithm doing evaluation in time $\tilde{O}(|C|^{2-\epsilon} + (N\cdot|C|)^{1-\epsilon/2} + N^{2-\epsilon})$ for any constant $\epsilon > 0$. On input a circuit $C$, we can decide satisfiability by expanding $C$ into a circuit $C'$ of size $2^{n/2}\cdot |C|$ which is just the OR over all possible choices of the first $n/2$ inputs to $C$ (leaving the other inputs free). We then batch-evaluate $C'$ on all of its $2^{n/2}$ inputs. The end result is that we find a satisfying assignment to $C'$ iff $C$ is satisfiable. The running time is $\tilde{O}(2^{(n/2)(2-\epsilon)}\cdot |C|^{2-\epsilon}) = \tilde{O}(2^{n(1-\epsilon/2)}\cdot \textrm{poly}(|C|))$.


---

