<p>It is important to remark that a specific boolean circuit only treats inputs of a given size, unlike a Turing Machine that can take inputs of any size.</p>

<p>So a language with inputs of arbitrary size is usually treated by a <em>family</em> of circuits, one for each size of input.
The problem with this definition is that it allows circuit to solve uncomputable problems, since we could for instance answer 1 if $|x|\in H$ and $0$ if $|x|\notin H$, where $H\subseteq \mathbb N$ is any set. Take for instance $H$ to be an enconding of the halting problem.</p>

<p>To circumvent this problem, we usually look at <em>uniform</em> families of circuits, where there is a fixed Turing Machine $M$ which on input $n$ outputs the circuit for size $n$ inputs.</p>

<p>There is now a hope that circuits are equivalent to Turing machines.</p>

<p>Unfortunately, the model of circuits have computations that always halt (or you can define circuits with loops that never halt but they are useless). This limitation alone suffices to prove that they cannot be Turing complete, because any Turing-complete model must allow infinite computation.</p>

<p>However notice that you have a uniform family of circuits for any language that is decided by a total Turing machine: on input $n$ you can build your circuit for size $n$ by listing all inputs of size $n$ accepted by your machine.
The things that you miss are recursively enumerable languages, such as the Halting problem.</p>

CC BY-SA 3.0
2013-09-12T12:44:10.077Z
Thanks for your answer. But couldn't my allowance for an infinite number of gates in the Boolean circuit allow for non-halting problems?
Matthew Matic
CC BY-SA 3.0
2013-09-12T14:22:46.720Z
The acceptance in this setting must be defined precisely, but it seems that if there is an infinite path in your circuit, then it will never stop no matter what the input is, so it is as useless as looping circuits.
Denis
CC BY-SA 3.0
2013-09-12T12:34:50.397Z
2013-09-12T17:48:32.413Z
2013-09-12T17:48:32.413Z
Denis
<p>I hope this doesn't come across as picking holes in the question.</p>

<p>The first point, as raised by dkuper, is that ordinary circuits necessarily implement total functions (every input gives either true or false), whereas Turing machines implement partial functions (inputs lead to acceptance, rejection or "no answer", i.e., non-termination).  If you want to simulate a Turing machine, you're either going to need to add something to your model of circuits that allows them to compute partial functions, or implement separate circuits for, say, "The machine accepts this input", "The machine rejects this input" and "The machine doesn't halt on this input."</p>

<p>The second point is, what does it mean to have a circuit with infinitely many gates? Any circuit with an infinite number of gates and a single output gate must have an infinite path and/or a gate with infinite in-degree. What does it mean to evaluate an infinite path? Can that be done in finite time? Is it OK to have a gate with infinite in-degree, given that such a thing couldn't possibly be realised? (OK, the infinite tape of a Turing machine can't be physically realised but it suffices to have a finite amount of tape and promise to add more whenever the head reaches the end.)</p>

<p>Now let's look at the more specific questions. The version where the Turing machine&nbsp;$M$ and its input&nbsp;$x$ are fixed, is trivial, as are all problems with a finite number of instances (one, in this case).  The circuit is the constant "true" if $M$&nbsp;accepts&nbsp;$x$, the constant "false" if it rejects and, some circuit with no value if it doesn't halt (or whatever you decided to do to represent non-terminating computations in your circuit model).  We know that this circuit exists but, of course, the function that maps $M$ and&nbsp;$x$ to the required circuit is uncomputable.</p>

<p>Finally, the case where the circuit's input is (a coding of) the Turing machine and its input. You have to decide how to code that as the input to an infinite circuit. One way would be to code machine and input as a finite binary string and have the infinite sequence of inputs $x_i$ and $y_i$ ($i&gt;0$) to the circuit such that, the circuit evaluates to false if every $y_i=0$ and, otherwise, putting $\ell=\min\{i\mid y_i=1\}$, the sequence $x_1\dots x_{\ell}$ is the binary string coding the input.  Now, take the infinite set&nbsp;$S$ of pairs $(M_j,x_j)$ ($j&gt;0$) such that $M_j$&nbsp;is a machine that accepts input&nbsp;$x_j$. The required circuit is just an infinite disjunction, where the $j$th disjunct says "My input codes $(M_j,x_j)$"; again, you need to deal with non-terminating computations in some way.</p>

<p>Alternatively, you go the more conventional route of having a family of circuits, one for each input length, as described by dkuper.</p>

CC BY-SA 3.0
2013-09-12T21:01:28.450Z
One quibble: it seems quite feasible to realise a finite-but-extendable AND, as a series of transistors.  This takes longer and longer to settle as one adds inputs, but then a Turing machine also takes longer the more tape we add, waiting for the one-cell-at-a-time mechanics of the machine.
András Salamon
CC BY-SA 3.0
2013-09-12T21:10:36.747Z
@AndrásSalamon To me, adding more tape feels like supplying consumables, whereas extending an AND gate feels like changing the definition of the circuit. On the other hand, I accept that the concept of consumables appears nowhere in the actual definition of Turing machines, so the distinction is artificial. On the gripping hand, you'd have to define what operations are allowed when extending the AND gate which, itself, feels like computation; with the Turing machine, the "operation" is just "glue more tape on the end."
David Richerby
CC BY-SA 3.0
2013-09-12T18:03:30.990Z
2013-09-12T18:03:30.990Z
David Richerby
<p>Any Turing machine doing any finite amount of compution can be perfectly emulated with a finite circuit. If you allow the output to become the input in a loop, it becomes Turing machine equivalent.</p>

CC BY-SA 4.0
2019-06-24T09:27:43.880Z
2019-06-24T09:27:43.880Z
Jon
<p>I have a question, but I don't seem to know enough computer science terminology in order to look up an answer. So I wonder if you guys could help a poor physicist like me.</p>

<p>I would like to know if Boolean circuits are what I would call universal. By this I mean that, given an infinite number of NAND gates and wires, could I solve any problem on any input?</p>

<p>Equivalently (I think) could I simulate any given instance of a universal Turing machine using some particular Boolean circuit? By 'a given instance' I mean that the action table and input tape are set in stone, so we know exactly what process that our Boolean circuit is to simulate before we start wiring all the NAND's together.</p>

CC BY-SA 3.0
2013-09-12T17:16:26.877Z
suggest migrate to cs.se
vzn
CC BY-SA 3.0
2013-09-12T17:16:57.613Z
[functional completeness](http://en.wikipedia.org/wiki/Functional_completeness), wikipedia
vzn
CC BY-SA 3.0
2013-09-12T17:50:43.617Z
@vzn the question is not aobut that (the OP seems to know that NAND gates are complete), but about equivalence with Turing machines.
Denis
CC BY-SA 3.0
2013-09-12T17:57:53.147Z
still basic/closely related.
vzn
CC BY-SA 3.0
2013-09-12T17:58:57.060Z
or maybe duplicate, [simulating TMs with circuits](http://cstheory.stackexchange.com/questions/2742/simulating-turing-machines-output-included-with-circuits)
vzn
CC BY-SA 3.0
2013-09-12T18:05:19.840Z
some ref to [uniform vs nonuniform circuits](http://en.wikipedia.org/wiki/Circuit_complexity) (key concept here?) on wikipedia. also suggest not using/reinventing the term "universal" here. the question seems to be asking about the existence of _nonuniform_ circuits but in a mixed up way (because nonuniform circuits can solve the halting problem but that is not equivalent to simulating any TM with circuits)
vzn
<cc.complexity-theory><circuit-complexity><boolean-functions>
Are Boolean circuits 'universal'
Matthew Matic
# Are Boolean circuits 'universal'

(Asked by: username_0 on 2013-09-12)

I have a question, but I don't seem to know enough computer science terminology in order to look up an answer. So I wonder if you guys could help a poor physicist like me.

I would like to know if Boolean circuits are what I would call universal. By this I mean that, given an infinite number of NAND gates and wires, could I solve any problem on any input?

Equivalently (I think) could I simulate any given instance of a universal Turing machine using some particular Boolean circuit? By 'a given instance' I mean that the action table and input tape are set in stone, so we know exactly what process that our Boolean circuit is to simulate before we start wiring all the NAND's together.

**Tags:** cc.complexity-theory, circuit-complexity, boolean-functions

> **Comments:**
> **username_1**: suggest migrate to cs.se  
> **username_1**: [functional completeness](http://en.wikipedia.org/wiki/Functional_completeness), wikipedia  
> **username_2**: @username_1 the question is not aobut that (the OP seems to know that NAND gates are complete), but about equivalence with Turing machines.  
> **username_1**: still basic/closely related.  
> **username_1**: or maybe duplicate, [simulating TMs with circuits](http://cstheory.stackexchange.com/questions/2742/simulating-turing-machines-output-included-with-circuits)  
> **username_1**: some ref to [uniform vs nonuniform circuits](http://en.wikipedia.org/wiki/Circuit_complexity) (key concept here?) on wikipedia. also suggest not using/reinventing the term "universal" here. the question seems to be asking about the existence of _nonuniform_ circuits but in a mixed up way (because nonuniform circuits can solve the halting problem but that is not equivalent to simulating any TM with circuits)  

---

## 3 answers

### Answer by username_2 on 2013-09-12. Score: 13

It is important to remark that a specific boolean circuit only treats inputs of a given size, unlike a Turing Machine that can take inputs of any size.

So a language with inputs of arbitrary size is usually treated by a *family* of circuits, one for each size of input.
The problem with this definition is that it allows circuit to solve uncomputable problems, since we could for instance answer 1 if $|x|\in H$ and $0$ if $|x|\notin H$, where $H\subseteq \mathbb N$ is any set. Take for instance $H$ to be an enconding of the halting problem.

To circumvent this problem, we usually look at *uniform* families of circuits, where there is a fixed Turing Machine $M$ which on input $n$ outputs the circuit for size $n$ inputs.

There is now a hope that circuits are equivalent to Turing machines.

Unfortunately, the model of circuits have computations that always halt (or you can define circuits with loops that never halt but they are useless). This limitation alone suffices to prove that they cannot be Turing complete, because any Turing-complete model must allow infinite computation.

However notice that you have a uniform family of circuits for any language that is decided by a total Turing machine: on input $n$ you can build your circuit for size $n$ by listing all inputs of size $n$ accepted by your machine.
The things that you miss are recursively enumerable languages, such as the Halting problem.

> **Comments:**
> **username_0**: Thanks for your answer. But couldn't my allowance for an infinite number of gates in the Boolean circuit allow for non-halting problems?  
> **username_2**: The acceptance in this setting must be defined precisely, but it seems that if there is an infinite path in your circuit, then it will never stop no matter what the input is, so it is as useless as looping circuits.  

---

### Answer by username_3 on 2013-09-12. Score: 5

I hope this doesn't come across as picking holes in the question.

The first point, as raised by dkuper, is that ordinary circuits necessarily implement total functions (every input gives either true or false), whereas Turing machines implement partial functions (inputs lead to acceptance, rejection or "no answer", i.e., non-termination). If you want to simulate a Turing machine, you're either going to need to add something to your model of circuits that allows them to compute partial functions, or implement separate circuits for, say, "The machine accepts this input", "The machine rejects this input" and "The machine doesn't halt on this input."

The second point is, what does it mean to have a circuit with infinitely many gates? Any circuit with an infinite number of gates and a single output gate must have an infinite path and/or a gate with infinite in-degree. What does it mean to evaluate an infinite path? Can that be done in finite time? Is it OK to have a gate with infinite in-degree, given that such a thing couldn't possibly be realised? (OK, the infinite tape of a Turing machine can't be physically realised but it suffices to have a finite amount of tape and promise to add more whenever the head reaches the end.)

Now let's look at the more specific questions. The version where the Turing machine $M$ and its input $x$ are fixed, is trivial, as are all problems with a finite number of instances (one, in this case). The circuit is the constant "true" if $M$ accepts $x$, the constant "false" if it rejects and, some circuit with no value if it doesn't halt (or whatever you decided to do to represent non-terminating computations in your circuit model). We know that this circuit exists but, of course, the function that maps $M$ and $x$ to the required circuit is uncomputable.

Finally, the case where the circuit's input is (a coding of) the Turing machine and its input. You have to decide how to code that as the input to an infinite circuit. One way would be to code machine and input as a finite binary string and have the infinite sequence of inputs $x\_i$ and $y\_i$ ($i>0$) to the circuit such that, the circuit evaluates to false if every $y\_i=0$ and, otherwise, putting $\ell=\min\{i\mid y\_i=1\}$, the sequence $x\_1\dots x\_{\ell}$ is the binary string coding the input. Now, take the infinite set $S$ of pairs $(M\_j,x\_j)$ ($j>0$) such that $M\_j$ is a machine that accepts input $x\_j$. The required circuit is just an infinite disjunction, where the $j$th disjunct says "My input codes $(M\_j,x\_j)$"; again, you need to deal with non-terminating computations in some way.

Alternatively, you go the more conventional route of having a family of circuits, one for each input length, as described by dkuper.

> **Comments:**
> **username_4**: One quibble: it seems quite feasible to realise a finite-but-extendable AND, as a series of transistors.  This takes longer and longer to settle as one adds inputs, but then a Turing machine also takes longer the more tape we add, waiting for the one-cell-at-a-time mechanics of the machine.  
> **username_3**: @AndrásSalamon To me, adding more tape feels like supplying consumables, whereas extending an AND gate feels like changing the definition of the circuit. On the other hand, I accept that the concept of consumables appears nowhere in the actual definition of Turing machines, so the distinction is artificial. On the gripping hand, you'd have to define what operations are allowed when extending the AND gate which, itself, feels like computation; with the Turing machine, the "operation" is just "glue more tape on the end."  

---

### Answer by username_5 on 2019-06-24. Score: 2

Any Turing machine doing any finite amount of compution can be perfectly emulated with a finite circuit. If you allow the output to become the input in a loop, it becomes Turing machine equivalent.


---

