Presentation is loading. Please wait.

Presentation is loading. Please wait.

Alan Mishchenko UC Berkeley (With many thanks to Donald Knuth,

Similar presentations


Presentation on theme: "Alan Mishchenko UC Berkeley (With many thanks to Donald Knuth,"— Presentation transcript:

1 Using Enumeration to Generate All Minimum Circuits for Boolean Functions of 4 and 5 Variables
Alan Mishchenko UC Berkeley (With many thanks to Donald Knuth, TAOCP, Volume 4, Section “Boolean evaluation”)

2 Overview Small Boolean functions (n-functions where n < 6)
Minimum circuits (min-circuits) Enumeration algorithms Exhaustive enumeration of min-circuits Experimental results Conclusions and future work Applications? 2

3 Two Different 12-Node Min-Circuits for The Most Complex 5-Function: 169ae443

4 Terminology Boolean value: 0 or 1 Boolean variable: x  {0,1}
abcd F 0000 0001 0010 0011 1 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Boolean value: 0 or 1 Boolean variable: x  {0,1} A set of Boolean n variables, e.g. n=4, {a,b,c,d} Minterm: a complete assignment of a set of Boolean variables, e.g. {a,b,c,d} = 0011 The total number of minterms = 2^n Boolean function: a complete assignments of all minterms in terms of the set of variables The total number of functions = 2^(2^n) Truth table: a compact representation of Boolean function, e.g

5 NPN Classes Two functions belong to the same NPN class if one of them can be derived from the other by complementing inputs (N), permuting inputs (P), and complementing the output (N)

6 Min-Circuit Types Using terminology introduced in TAOCP by Knuth
C(f): the minimum-node DAG (the most general type) L(f): the minimum-node leaf-DAG (fanout only at inputs) U(f): the minimum-node DAG with logic sharing (fanout) only at inputs and the first logic level D(f): the minimum-level circuit DN(f): the node count in the minimum-level circuit Cm(f): the minimum-node width-n DAG (“minimum memory”) Cm’(f): the same as Cm(f) with one extra generation rule Cm1(f): the minimum-node width-(n+1) DAG

7 Min-Circuit Enumeration Methods
Bottom-up Start with inputs, add gates – leads to L(f) Top-down Start with the output, add gates – leads to Cm(f) Hybrid Hard to define in an intuitive way – leads to C(f)

8 Bottom-Up Enumeration: L(f)
This is Algorithm L from TAOCP by Knuth, modified to work with NPN classes rather than individual functions Maintain a hash table of reached NPN classes Initialize it with constant 0 function and buffer function Consider pairs of classes whose min-circuits have sizes n1 and n2 Add on top one two-input gate (AND/XOR) in five polarities: The polarities are: f1 & f2, f1 & ~f2, ~f1 & f2, ~f1 & ~f2, f1  f2 (One of the classes should be exhaustively permuted/complemented) Check each of the resulting functions among the reached classes If it is there, skip it If not, add the new class and set its min-circuit to have size n1+n2+1 Stop when all NPN classes have been reached Runtime Takes 0.01 sec for 4-input functions Takes 200 sec for 5-input functions Currently infeasible for 6-input functions

9 Other Enumeration Types
The most general one, C(f), leads to the best quality but is the hardest to implement The top-down one, Cm1(f), is easy to implement but runs into problems with NPN classification (because it requires n+1 variable NPN classes) L(f) is a good trade-off between quality, runtime, and the ease of implementation Below we focus on L(f) is discussion and results

10 Min-Circuit Classes of 4-Functions

11 Min-Circuit Classes for 4-Functions (only AND, no XOR)
It is interesting to note that L(f) here has more classes with an odd number of nodes than with an even number of nodes!

12 Computing L(f) for 5-Functions

13 Computing D(f) for 5-Functions

14 Computing Cm(f) for 5-Functions

15 Min-Circuit Types for 5-Functions

16 Counting Min-Circuits
The focus of this presentation is on counting the number of *different* min-circuits for each NPN class (finished) generating all *different* min-circuits (not finished) What min-circuits are considered different? A min-circuit is characterized by the unordered pairs of NPN classes of fanins of the topmost node Two circuits are different, if at least one fanin of the topmost node of the first circuit has NPN class that is not present among the fanins of the second circuit

17 Distribution of Min-Circuit Counts for 4-Functions

18 Distribution of Min-Circuit Counts for 5-Functions
It is interesting to note that among all 11-node NPN classes, there are 5450 classes with a unique min-circuit and one class with exactly 523 different min-circiuts. The next closest to it, is one class with exactly 314 different min-circuits.

19 Future Work Generate all min-circuits for 4- and 5-functions
Finish computation of Cm1(f) for 5-functions This computation is based on Frontier-Based Search (Knuth) Extend all results to (a subset of simple) 6-functions Requires improving exact NPN classification for 6-functions Find good practical applications

20 Conclusion Introduced the problem of min-circuit enumeration
Presented statistics for all min-circuit types for 4- and 5-functions (most of the info available in TAOCP by Knuth) Showed distribution of min-circuits of L(f) (new result)

21 Four 4-Functions That Require 10 AND Nodes (XORs not used)
This slide is borrowed from presentation “Practical SAT” by Niklas Een


Download ppt "Alan Mishchenko UC Berkeley (With many thanks to Donald Knuth,"

Similar presentations


Ads by Google