Algorithm Search⌘K

Definitionintro

Sum of products

Also called SOP form, two-level AND-OR form.

A Boolean formula that is an OR of product terms, each an AND of literals, the form of two-level logic and of programmable logic arrays.

A sum of products (SOP) is a Boolean formula that is an OR of product terms, where each product term is an AND of literals. A literal is a variable xix_i or its complement xˉi\bar{x}_i. An example is x1x2+xˉ1x3x_1 x_2 + \bar{x}_1 x_3. Each product term is true on a subcube of {0,1}n\{0,1\}^n, so an SOP is also a set of cubes, called a cover. Every Boolean function has an SOP: take one term for each input where the function is 1. In logic the same form is the disjunctive normal form (DNF). In hardware it is two-level logic: one AND gate for each term and one OR gate, or one row of a programmable logic array (PLA) for each term. The number of terms and the number of literals are the usual costs, and making them small is two-level logic minimization.

Definition

Let x1,…,xnx_1, \ldots, x_n be Boolean variables. A literal is xix_i or xˉi\bar{x}_i. In a product, xix_i is true when xi=1x_i = 1 and xˉi\bar{x}_i is true when xi=0x_i = 0.

Product term, or cube. A product term is an AND of literals in which no variable occurs twice. The term with no literal is the constant 1. A term tt with kk literals is true on a set of 2n−k2^{n-k} points of {0,1}n\{0,1\}^n. This set is a subcube of dimension n−kn - k, and we use the same word, cube, for the term and for its set of points. A cube has a positional notation: a string c∈{0,1,−}nc \in \{0, 1, -\}^n, where ci=1c_i = 1 means the literal xix_i, ci=0c_i = 0 means xˉi\bar{x}_i, and ci=−c_i = - means that xix_i does not occur. So x1xˉ3x_1 \bar{x}_3 over three variables is 1−01{-}0. There are 3n3^n cubes. A minterm is a cube with all nn literals, that is, one point of {0,1}n\{0,1\}^n. We number the minterms by the binary number x1x2⋯xnx_1 x_2 \cdots x_n, with x1x_1 as the high bit.

Sum of products. A sum of products is a finite set C={c1,…,cm}C = \{c_1, \ldots, c_m\} of cubes, read as the formula

fC(x)=⋁j=1mcj(x).f_C(x) = \bigvee_{j=1}^{m} c_j(x).

The empty set is the constant 0. The set of points where fCf_C is 1 is the union of the cubes of CC. If fC=ff_C = f, then CC is an SOP of ff, or a cover of ff.

Cost. The cost of CC is the pair (number of cubes mm, number of literals ∑j∣cj∣\sum_j |c_j|), where ∣c∣|c| is the number of literals of cc. Two-level tools compare the number of cubes first and the literals second. The number of cubes is the number of AND gates, or of PLA rows. The number of literals is the number of AND inputs.

Canonical SOP. The canonical SOP, or sum of minterms, of ff has one minterm for each point aa with f(a)=1f(a) = 1. It is unique, and it is the only SOP of ff that has only minterms. One writes f=∑m(…)f = \sum m(\ldots) with the list of minterm numbers.

Examples and non-examples

Sums of products.

  • f=x1x2+xˉ1x3f = x_1 x_2 + \bar{x}_1 x_3 is the cover {11−, 0−1}\{11{-},\ 0{-}1\}. It is 1 on the minterms {6,7}∪{1,3}\{6, 7\} \cup \{1, 3\}, so f=∑m(1,3,6,7)f = \sum m(1, 3, 6, 7). Its cost is 2 cubes and 4 literals.
  • The majority of three inputs is x1x2+x1x3+x2x3x_1 x_2 + x_1 x_3 + x_2 x_3, 3 cubes and 6 literals. Its canonical SOP ∑m(3,5,6,7)\sum m(3, 5, 6, 7) has 4 cubes and 12 literals.
  • One function has many SOPs. The cover x1+xˉ1x2x_1 + \bar{x}_1 x_2 and the cover x1+x2x_1 + x_2 both give the OR of x1x_1 and x2x_2. The second one has fewer literals because x2x_2 is a larger cube than xˉ1x2\bar{x}_1 x_2.
  • The constant 1 is the cover {−−⋯−}\{{-}{-}\cdots{-}\} with one cube and no literal. The constant 0 is the empty cover.
  • Parity x1⊕⋯⊕xnx_1 \oplus \cdots \oplus x_n needs 2n−12^{n-1} cubes in every SOP. A cube that misses a variable xjx_j contains two points that differ only in xjx_j, and parity is 0 at one of them. So every cube of a parity SOP is a minterm, and parity has 2n−12^{n-1} minterms. The Shannon expansion page gives the same proof and compares it with the BDD of parity, which has 2n+12n + 1 nodes.

Non-examples.

  • x1(x2+x3)x_1 (x_2 + x_3) is an AND of sums, not an SOP. Multiplied out it is the SOP x1x2+x1x3x_1 x_2 + x_1 x_3. An AND of sums of literals is the conjunctive normal form, the dual form.
  • x1x2‾\overline{x_1 x_2} is not an SOP, because the complement covers a product, not a literal. By De Morgan's law it is the SOP xˉ1+xˉ2\bar{x}_1 + \bar{x}_2.
  • x1xˉ1x2x_1 \bar{x}_1 x_2 is not a product term in the sense above, because x1x_1 occurs twice. It is the constant 0, the empty set of points, and covers write it as no cube at all.
  • x1⊕x2x_1 \oplus x_2 is not an SOP as written. Its SOP is x1xˉ2+xˉ1x2x_1 \bar{x}_2 + \bar{x}_1 x_2.

SOP and CNF sizes. The two forms can differ by an exponential factor. The SOP f=x1y1+x2y2+⋯+xkykf = x_1 y_1 + x_2 y_2 + \cdots + x_k y_k has kk cubes. Let DD be a clause of a CNF of ff. Set each variable that is a positive literal of DD to 0 and each other variable to 1. Then DD is false, so ff must be 0, so for each ii the clause DD has the positive literal xix_i or yiy_i. Now pick one variable ziz_i from each pair, and let aa be the point with all zi=0z_i = 0 and all other variables 1. Then f(a)=0f(a) = 0, so some clause is false at aa. Its positive literals hit every pair and are all 0 at aa, so they are exactly z1,…,zkz_1, \ldots, z_k. The 2k2^k choices give 2k2^k different clauses, so every CNF of ff has at least 2k2^k clauses. Parity has 2n−12^{n-1} clauses in every CNF too, by the same argument as for its SOP.

References

  1. Robert K. Brayton, Gary D. Hachtel, Curtis T. McMullen and Alberto L. Sangiovanni-Vincentelli, Logic Minimization Algorithms for VLSI Synthesis, Kluwer, 1984, Chapter 2, Basic Definitions, Section 2.3, Cubes and Covers
  2. Giovanni De Micheli, Synthesis and Optimization of Digital Circuits, McGraw-Hill, 1994, Chapter 7, Two-Level Combinational Logic Optimization
  3. Gary D. Hachtel and Fabio Somenzi, Logic Synthesis and Verification Algorithms, Kluwer, 1996, Chapter 4, Synthesis of Two-Level Circuits
  4. Donald E. Knuth, The Art of Computer Programming, Volume 4A, Combinatorial Algorithms, Part 1, Addison-Wesley, 2011, Section 7.1.1, Boolean basics (disjunctive normal forms)

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.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/M58QRA/text.yaml