AND gate 2026-10-25
An AND gate computes for bits . It is irreversible when only its one-bit output is retained. The Toffoli gate embeds the operation reversibly as ; setting preserves the inputs while recording their logical conjunction.
Logic gate 2026-10-25
A physical or idealized component implementing a fixed Boolean function on one or more input bits. For example, an AND gate outputs one exactly when both input bits are one. A Boolean circuit connects logic gates; circuit size counts components and circuit depth measures the longest chain of dependencies.
An AND gate maps four possible pairs to one bit and loses information, so it is not reversible. A reversible embedding retains both inputs and uses a target bit:This is the Toffoli gate; initializing computes while preserving enough information to invert the operation.
Classical reversible gates on one or two bits alone cannot synthesize every such operation. Every permutation of two bits is an invertible affine map over the finite field : there are of them, exactly the permutations. Their extensions to a larger register and their compositions remain affine. The nonlinear term in the Toffoli gate therefore cannot be generated. Three-bit reversible gates remove this obstruction, with ancillary bits initialized appropriately.
There is no conflict with quantum universality: one- and two-qubit gates may pass through quantum superpositions and use relative phases at intermediate steps. They are not restricted to permutations of computational basis states at every step. For example the Hadamard gate, T gate and CNOT gate can decompose a Toffoli gate exactly. Thus the classical affine obstruction does not apply to their intermediate unitary operators.
Use five cascaded banks of 32 two-input multiplexers, for optional shifts of bits. The original circuit schematic below shows one bank per shift-amount bit; this is a left bit shift with zero fill, not a bit rotation.
If , stage selects either its unchanged input or that input shifted left by . For bit position , the shifted candidate comes from position when it exists, and otherwise from zero. Composing the chosen stages shifts by the sum of their distances, so each amount from to is represented exactly by its five binary control bits. There are one-bit multiplexers, with five multiplexer delays along a bit path.
Compute the two complements with the two NOT gates, then form and with the two AND gates. Feed those outputs to the OR gate:Exactly one product is one when the inputs differ; both products are zero when the inputs agree. This uses precisely the allowed two inverters, two two-input AND gates and one two-input OR gate.
Every AND gate and OR gate is a monotone Boolean function: changing an input from zero to one while leaving all other inputs unchanged cannot change the output from one to zero. By structural induction over a Boolean circuit, a composition of these gates is also a monotone Boolean function. Constant inputs do not alter that conclusion.
Logical negation cannot be implemented, since it sends to and to , violating the defining order property. Hence these two gate types alone cannot implement every Boolean function.
The five maximal four-cell groups give the disjunctive normal formFor example, the group wraps between columns and in the bottom two rows. No group of eight cells is entirely one. The five terms are precisely the prime implicants, and each is essential: respectively, the cells are covered by no other prime implicant. Any disjunctive normal form can have its terms enlarged to prime implicants without increasing its size. Therefore all five displayed terms are necessary, proving minimality in number of products; each needs two literals, also giving ten literals in a minimal cover.
For an implementation with AND gates and NOT gates, call these five products . Form the shared complements , calculate each with an AND gate, invert every , and useA five-input conjunction can be replaced by four two-input AND gates. This direct implementation uses nine two-input AND gates and eight NOT gates. That is a valid realization of the minimal disjunctive normal form, rather than a claim that this particular gate count is globally optimal among all factored circuits.
For bits , use two negation logic gates and two AND gates:The two unequal bit pairs activate their respective output; the equal pairs activate neither. In particular, a digital comparator never produces .
Split each input into its more and less significant -bit halves: and . Let the two digital comparators produce and . The more significant halves are equal exactly when . The comparator composition is thereforeImplement with a logical disjunction followed by a negation, then use two AND gates and two more logical disjunction logic gates. If , the difference has magnitude at least , whereas ; hence the more significant comparison decides the result. If , the lower comparison decides it. This proves correctness in every case using a constant number of extra logic gates.
