Problemresearch
Exact synthesis
Also called SAT-based exact synthesis, optimum circuit synthesis.
Find a circuit with the fewest gates or least depth for a small Boolean function, today by encoding the circuit structure as a SAT problem.
Exact synthesis asks for a Boolean circuit with the fewest gates, or the least depth, that computes a given Boolean function over a given set of gate types. The function is small, often 4 to 8 inputs, and is given by its truth table. Unlike the heuristics of multi-level logic synthesis, an exact method must prove that no smaller circuit exists. The decision version, "is there a circuit with at most gates", is in NP for a truth table input, and since 2009 the usual method encodes it as a SAT instance and asks a solver for . The cost grows very fast with , so exact synthesis is used for small cuts of large circuits, for libraries of optimal subcircuits, and for questions in circuit complexity.
In plain words
You have a small logic function, for example "the output is 1 when at least two of the three inputs are 1". You also have a set of allowed gates, for example all gates with two inputs. You want a circuit that uses as few gates as possible, and you want to be sure that nothing smaller exists. Trying all circuits by hand is slow, because their number grows very fast with the number of gates. The modern way is to write the question "is there a circuit with exactly this many gates" as a large logic puzzle and give it to a SAT solver. If the solver says no for 3 gates and finds a circuit for 4, then 4 is the optimum.
Definition
Input. A function given by its truth table, a basis of gate types, and a cost, the number of gates or the depth.
Feasible solutions. A circuit over : a sequence of gates , where are the inputs, each gate applies a function of to earlier signals, and chosen signals (with their complements, if the basis allows free inverters) compute on all inputs. Knuth calls such a sequence a Boolean chain.
Objective. Minimize , the gate count , or the depth , the largest number of gates on a path from an input to an output.
Decision version. Given the truth table of and , does have a circuit over with at most gates? For , all 16 functions of two inputs, this is the minimum circuit size problem (MCSP) of complexity theory.
Variants
- By the basis. , all two-input gates. , the two-input gates without XOR and XNOR. AND with free inverters, the base of an and-inverter graph. Majority of three with free inverters, the base of a majority-inverter graph. All functions of inputs, for LUT mapping.
- By the cost. Fewest gates; least depth; fewest gates under a depth bound; or the number of AND gates only (the multiplicative complexity), which matters for cryptography.
- Multiple outputs. One circuit that computes functions, where shared gates count once.
- Don't-cares. The function is fixed only on a care set. This is the form that appears when a cut of a larger circuit is rewritten.
- Fixed topology. The shape of the circuit is given, and only the gate functions and fanins are unknown. Topology enumeration solves the problem by many such smaller instances.
- Formulas. Each gate may feed only one other gate, so the circuit is a tree.
Examples
All examples use the basis with 3 inputs . The minima below were checked by an exhaustive search over all circuits of each size.
- Three-input XOR. needs 2 gates, since one gate sees at most two inputs.
- Majority. needs exactly 4 gates. No circuit of 3 gates computes it. A circuit of 4 gates is , , , and the output . When , both XORs are 1 and the output is . In every other case, and the output is , which is then the majority.
- Full adder. The two outputs sum and carry need 5 gates together, and 4 do not suffice. A circuit of 5 gates is , sum , , and carry . The sharing of saves one gate against 2 plus 4 gates for the two outputs on their own. This circuit is the cell of a ripple carry adder.
Known algorithms
- Exhaustive enumeration. List all circuits of gates and keep the first one that computes , or, for all functions of inputs at once, grow the set of functions with known cost one gate at a time. Knuth (TAOCP 7.1.2) computes the cost of every function of 4 inputs this way, with the functions grouped into classes under permutation and complementation of inputs, the classes of Boolean matching.
- SAT encoding. Kojevnikov, Kulikov and Yaroslavtsev (2009). For a fixed , there are variables for the two fanins of each gate, for the truth table of each gate's function, and for the value of each gate on each of the input rows. Clauses tie the value of a gate on a row to its fanins and its function, and fix the outputs to . The instance is satisfiable exactly when a circuit with gates exists. A solver such as CDCL is called for until the answer is yes.
- Symmetry breaking. Many circuits are the same up to the order of the gates. Clauses that force a normal form, for example that each gate is used, that the gates are in a fixed order, or that each gate function maps to 0 (the normal chains of Knuth), cut the search without losing an optimum. See symmetry breaking.
- Counterexample-guided encoding. Encode only some rows of the truth table, solve, check the circuit on all rows, and add a row where it fails. This is CEGIS applied to circuits, and it keeps the SAT instances small.
- Topology enumeration. List the possible shapes of a circuit with gates, and solve a small SAT instance for each shape.
Bounds
Upper bounds (proved).
- For a truth table input, the decision version is in NP: a circuit of at most gates is a certificate, and it can be checked on all rows in time polynomial in the table size.
- Every function of inputs has a circuit over with gates (Lupanov 1958).
- The SAT encoding with gates of two inputs, with one variable for each gate and each pair of earlier signals, has fanin variables, or function variables and value variables, and clauses. Each call of the solver can take time exponential in this size.
Lower bounds (proved).
- Most functions are hard: by Shannon's counting argument (1949), the number of circuits with gates is far less than when is a bit less than , so almost every function of inputs needs about gates. The argument does not name a hard function.
- For functions with many outputs given by truth tables, the minimum circuit size problem is NP-hard (Ilango, Loff and Oliveira 2020).
- For a function with one output, it is not known whether MCSP is NP-hard. Kabanets and Cai (2000) showed that certain natural reductions cannot prove it without proving new circuit lower bounds. So exact synthesis has no proof of NP-hardness in its most common form, and no polynomial-time algorithm either.
Measured. The SAT method and its variants find optimum circuits for small functions, and published runs report that the solver time grows very fast with the number of gates . This is an observation from runs on small benchmark functions, not a proved bound. Exact synthesis tools in practice are used on cuts with few inputs for this reason.
Reductions
- To SAT. For each , "is there a circuit of gates for " reduces to a SAT instance of size , as above. The optimum is found with at most such calls, or with calls by binary search.
- To QBF. When is given by a specification and not by a table, the question is "there exists a circuit such that for all inputs it agrees with ", an formula, that is a QBF with two quantifier blocks. CEGIS solves it by a loop of SAT calls.
- Inside synthesis. Exact synthesis is the Boolean case of superoptimization and of syntax-guided synthesis, where the grammar is a set of gate types.
- From MCSP. The decision version over with a truth table input and one output is exactly MCSP, so any hardness result for MCSP holds for it.
Applications
- Rewriting libraries. AIG rewriting replaces a small cut of a large circuit by a precomputed optimum circuit for the cut's function. The library is built by exact synthesis, one entry per class of functions of 4 inputs.
- Resynthesis of cuts. For cuts with 5 to 8 inputs, exact synthesis is run on the fly, with the don't-cares of the cut, to find a smaller replacement.
- Majority logic. Libraries and rewriting for majority-inverter graphs use exact MIG synthesis.
- Cryptography. Small circuits with few gates or few AND gates for S-boxes, for fast software and for masking against side channels.
- Circuit complexity. Exact values of for small functions test conjectures and give upper bounds that hold for all when a small circuit is used as a block.
References
- Arist Kojevnikov, Alexander S. Kulikov and Grigory Yaroslavtsev, Finding efficient circuits using SAT-solvers, Theory and Applications of Satisfiability Testing (SAT 2009), LNCS 5584, 32 to 44, 2009, the SAT encoding of "f has a circuit of r gates" with selection, gate function and simulation variables
- Donald E. Knuth, The Art of Computer Programming, Volume 4A, Combinatorial Algorithms, Part 1, Addison-Wesley, 2011, Section 7.1.2, Boolean Evaluation (Boolean chains, the cost of small functions found by exhaustive search, and the exercises on SAT encodings)
- Rahul Ilango, Bruno Loff and Igor C. Oliveira, NP-hardness of circuit minimization for multi-output functions, Computational Complexity Conference (CCC 2020), LIPIcs 169, 22:1 to 22:36, 2020, the NP-hardness of the minimum circuit size problem for functions with many outputs given by truth tables
- Circuit minimization problem, the minimum circuit size problem for a function given by its truth table, and why its NP-hardness is hard to prove (general locator)
- The synthesis of two-terminal switching circuits, the counting argument that most functions of n variables need large circuits
- A method of circuit synthesis, the upper bound of about 2^n / n gates for every function of n variables (general locator)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag EFS5EC Edit this page History Report an error Markdown