Problemadvanced
Boolean matching
Also called Boolean match problem, NPN matching.
Decide whether a library cell implements a given function under a permutation and negation of its inputs, as in technology mapping.
Boolean matching asks whether two Boolean functions are the same up to a renaming of the inputs, a negation of some inputs and, in the common NPN form, a negation of the output. In technology mapping, one function is the function of a small part of the circuit and the other is the function of a library cell, and a match means that the cell can replace that part, with the inputs wired in the found order and with inverters where the found negations are. Unlike structural matching, which compares the shape of a pattern with the circuit, Boolean matching compares functions, so it finds a cell however the part is built. The NPN equivalence classes of functions of inputs number 1, 2, 4, 14, 222 and 616126 for to , so matching reduces a library and the set of functions that a mapper meets to a small number of classes. For functions given as truth tables of a few inputs the problem is easy in practice. For functions given as formulas or circuits it is co-NP-hard and lies in .
In plain words
A library cell computes a fixed rule of its inputs. A part of a circuit also computes a rule of its inputs. The question is whether the cell can do the part's job if you are free to choose which wire goes to which input of the cell, to put an inverter on some of the wires, and to put an inverter on the cell's output.
If the answer is yes, the cell can replace the part. Many rules look different but become the same after such changes, so a short list of cells can cover many parts.
Definition
Write , a permutation of , a vector and a bit . The NPN transform maps a function of inputs to
Input. Two functions and of inputs, given as truth tables, as BDDs, or as formulas or circuits.
Feasible solutions. The transforms such that . There are transforms.
Objective. None: the problem is a decision problem, and a transform with is the answer when one exists.
Decision version. Is there a transform with ? Then and are NPN-equivalent.
The transforms form a group under composition, so NPN-equivalence is an equivalence relation, and its classes are the NPN classes. The P, NP and PN forms allow only the permutation, the permutation and the input negations, or the permutation and the output negation.
Variants
-
By the transforms. P-matching (permutations only), NP-matching, NPN-matching. The number of classes for is:
P classes NP classes NPN classes 0 2 2 1 1 4 3 2 2 12 6 4 3 80 22 14 4 3984 402 222 5 37333248 1228158 616126 These values were computed for this page by Burnside's lemma over the transforms, and checked against an exhaustive count of the classes for .
-
Different numbers of inputs. A function of inputs matches a cell of inputs when the cell, with inputs tied to constants or to other inputs, computes up to a transform.
-
With don't-cares. is given with a set of input values where its value does not matter, and must agree with only on the care set. The don't-cares come from the rest of the circuit, as in observability don't-cares.
-
Library matching. Given and a library, find every cell that matches , or the cheapest one. With a canonical form for each class, this becomes a lookup in a table indexed by the form.
-
Canonical form. Given , compute a fixed member of its class, for example the smallest truth table in the class, so that two functions are equivalent exactly when their forms are equal. This is a form of canonical labeling.
-
Multiple outputs. Match several functions at once, with one transform of the shared inputs.
Examples
Truth tables below use the convention of the AIG pages: is the high bit of the row index.
- AND with a negated input. and $g = $ AND2. The transform $\pi = $ identity, , gives . In a mapping, this is AND2 with an inverter on .
- OR from NAND. and $g = $ NAND2: , so , . They are NP-equivalent.
- XOR and XNOR. XOR2 has the table and XNOR2 has . They are equivalent by , and also by , .
- Multiplexer. and are P-equivalent, with , and .
- A non-example. AND3 and the majority function MAJ3 do not match. A change of inputs keeps the number of rows where the function is 1, and a negation of the output turns such rows into . AND3 has 1 such row, so every function in its class has 1 or 7, and MAJ3 has 4.
- The two-input classes. The 16 functions of two inputs fall into 4 NPN classes: the constants, the single variables, the AND-type functions (8 of them, such as AND, OR, NAND and ) and the XOR-type functions (XOR and XNOR).
Known algorithms
- Exhaustive search over the transforms, practical for small .
- Pruning with invariants, values that every transform keeps, such as the number of 1 rows and the numbers of 1 rows of the cofactors of each input, before the search.
- Canonical forms computed for both functions and compared, with precomputed tables of the classes for , as in AIG rewriting.
- BDD-based matching, as in Mailhot and De Micheli (1993).
- SAT or QBF solvers on the formula "there is a transform such that for all inputs the two functions agree".
Bounds
Upper bounds (proved).
- Truth table input of inputs. Each transform is checked in steps, so the exhaustive search takes steps. With the size of a table, this is , at most quasi-polynomial in the input size.
- Formula or circuit input. The decision version is in , the second level of the polynomial hierarchy: guess , then check for all that , a co-NP check.
- For formulas under a permutation of the variables, Agrawal and Thierauf (2000) showed that the problem is not -complete unless the polynomial hierarchy collapses. See their paper for the exact class.
Lower bounds (proved, as hardness).
- Formula or circuit input: the decision version is co-NP-hard, in all of the P, NP and NPN forms. Proof: a formula of variables is a tautology exactly when , with a new variable , is equivalent to the constant 1 of inputs. A transform of a constant is a constant, so a function matches the constant 1 exactly when it is constant. If is a tautology, . If not, for some , and is 0 at and 1 at , so it is not constant. The map from to takes polynomial time, and tautology is co-NP-complete.
- Formula input: graph isomorphism reduces to P-matching. A graph with edge set gives the monotone formula . The clauses are the prime implicates of this monotone function, so the function determines , and two such formulas match under a permutation exactly when the graphs are isomorphic.
Measured. Nothing on this page. Mappers report the time spent in matching on their benchmark sets.
Reductions
- From equivalence checking. Boolean equivalence checking is Boolean matching with fixed to the identity, so every hardness result for equivalence checking of circuits carries over, as the proof above shows.
- To canonical forms. A canonical form for NPN classes reduces matching to two form computations and a comparison, and library matching to one form computation and a table lookup.
- From graph isomorphism. As above, for formula input.
- To QBF with two levels. "There is such that for all , " is a formula once is encoded in bits, which shows membership in .
Applications
- Technology mapping into cells. Cut-based mappers compute the truth table of each cut and look up the cells that match it.
- AIG rewriting. Rewriting looks up the best known AIG for the NPN class of each 4-input cut, from a table of the 222 classes.
- LUT-based structures. Matching cuts against configurable cells or LUT structures with a fixed internal wiring.
- Verification with unknown input order. Checking two blocks for equality when the correspondence of their inputs is not known.
- Exact synthesis databases. Tables of the smallest circuits of all functions of up to 4 or 5 inputs are stored per NPN class, as in exact synthesis.
References
- Frederic Mailhot and Giovanni De Micheli, Algorithms for technology mapping based on binary decision diagrams and on Boolean operations, IEEE Transactions on Computer-Aided Design 12(5), 1993, pages 599 to 620; Boolean matching of cluster functions against library cells in technology mapping, with BDDs and don't-cares
- The formula isomorphism problem, pages 990 to 1009; formula isomorphism is in Sigma_2^p and is not Sigma_2^p-complete unless the polynomial hierarchy collapses (general locator for the exact statements)
- Giovanni De Micheli, Synthesis and Optimization of Digital Circuits, McGraw-Hill, 1994, chapter 10, Boolean matching in library binding (general locator, not checked)
Where this leads
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 5HJMPV Edit this page History Report an error Markdown