Docsity

Boolean Satisfiability: An Introduction to Boolean Algebra and the CNF SAT Problem - Prof., Study notes of Computer Architecture and Organization

Partial preview of the text

Download Boolean Satisfiability: An Introduction to Boolean Algebra and the CNF SAT Problem - Prof. and more Study notes Computer Architecture and Organization in PDF only on Docsity!

and Related Problems

Edward L. Bosworth, Ph.D.

TSYS Department of Computer Science

Columbus State University

Columbus, GA 31907

[email protected]

Contents

  1. Brief discussion of Boolean algebra.
  2. Definition of standard Boolean forms.
  3. SAT: The Boolean Satisfiability Problem
  4. Relation of SAT to Boolean simplification.
  5. Discussion of Karnaugh maps as a method for Boolean simplification.

Basic Boolean Operators

Boolean algebra is defined in terms of two constants (defined above), which we call “0” and “1”. Other courses will call these values “F” and “T”. Boolean algebra is defined in terms of three basic operators: NOT, AND, & OR. Each of these three basic operators can be implemented by a basic electronic device called a “logic gate”. We present the gates along with the definition. NOT This function takes one input and produces one output. The gate is shown below. The circle at the right end of the triangle is important. Algebraically, this function is denoted f(X) = X’ or f(X) = X The evaluation of the function is simple: 0 = 1 and 1 = 0.

Basic Boolean Operators (Part 2)

Logic OR This is a function of two Boolean variables. We denote the logical OR of two Boolean variables X and Y by “X + Y”. Some logic books will use “X  Y”. The evaluation of the logical OR function is shown by a truth table X Y X + Y 0 0 0 0 1 1 1 0 1 1 1 1 The logical OR is extended to three or more inputs by noting that the function has value 1 if any of its inputs has value 1, and has value 0 only if all of its inputs have value 0.

Standard Boolean Forms

Standard forms are either canonical forms or normal forms.
The standard expressions are written in one of the two standard forms:
SOP S um o f P roducts form, also called Disjunctive Normal Form
POS P roduct o f S ums form, also called Conjunctive Normal Form.
Each of the two forms may be canonical or normal, so that we have:
Canonical Sum of Products
Normal Sum of Products
Canonical Product of Sums
Normal Product of Sums
IMPORTANT: These forms use only the 3 basic Boolean functions:
AND, OR, NOT. Specifically, XOR is not used.

Variables and Literals

We start with the idea of a Boolean variable. It is a simple variable that can take
one of only two values: 0 (False) or 1 (True).
Following standard digital design practice, we use the values 0 and 1.
Following standard teaching practice, we denote all Boolean variables by
single letters; normally “A”, “B”, “C”, “D”, or “W”, “X”, “Y”, “Z”.
A literal is either a Boolean variable or its complement.
Literals based on the variable X: X and X^.
Literals based on the variable Y: Y and Y^.
NOTE: X and X^ represent the same variable,
but they are not the same literal.
X and Y^ represent different variables, and are distinct literals.

Sum of Products and Product of Sums

A SOP (Sum of Products) expression is the logical OR of product terms.
A POS (Product of Sums) expression is the logical AND of sum terms.
Sample SOP expressions
F1(X, Y) = XY + X^  Y
G1(X, Y) = X^ Y + X Y
Sample POS expressions
F2(X, Y) = (X+Y)  ( X^ + Y^ )
G2(X, Y) = ( X^ +Y)  (X+ Y^ )
Note: POS expressions almost always have parentheses to indicate the
correct evaluation.

Inclusion

A product term T 1 is included in a product term T 2
if every literal in T 1 is also in T 2.
A sum term T 1 is included in a sum term T 2
if every literal in T 1 is also in T 2.
Consider the following examples:
F(A, B, C) = AB + AC + ABC
Each of AB and AC is included in ABC.
G(A, B, C) = (A + B)(A + C)(A + B + C)
Each of (A + B) and (A + C) is included in (A + B + C).
There is no inclusion in the next expression
F(A, B, C) = AB + AC + A BC
The literal A does no appear in the third term.
The literal B does not appear in the second term.
The inclusion rule is based on literals, not just variables.

Last Word on Inclusion

If a SOP or POS expression has included terms, it can be simplified.
F1(A, B, C) = AB + AC + ABC is identically equal to
F2(A, B, C) = AB + AC
G1(A, B, C) = (A + B)(A + C)(A + B + C) is identically equal to
G2(A, B, C) = (A + B)(A + C)
The conclusion is that Boolean expressions with included terms are needlessly
complicated. We can simplify them by the application of trivial rules.
Note that duplication is a form of inclusion.
The expression F3(A, B) = AB + AB has 2 terms, each included in the other.

Normal and Canonical Forms

A Normal SOP expression is a Sum of Products expression
with no included product terms.
A Normal POS expression is a Product of Sums expression
with no included sum terms.
A Canonical SOP expression over a set of Boolean variables is
a Normal SOP expression in which each product term contains
a literal for each of the Boolean variables.
A Canonical POS expression over a set of Boolean variables is
a Normal POS expression in which each sum term contains
a literal for each of the Boolean variables.
Note: A canonical expression on N Boolean variables is made up
of terms, each of which has exactly N literals.

CNF Satisfiability: Two Easy Examples

Consider the following two examples of CNF SAT. B 1 = ^ X^ ^ Y^ X^ ^ Y^ X^ Y B 2 = ^ X^ ^ Y^ X^ ^ Y^ X^ ^ Y(X + Y) The expression B 1 is easily seen to be satisfiable. If X = 0 and Y = 0 then B 1 = ^0 ^0 ^0 ^0 ^0 ^0  = (1 + 1)(1 + 0)(0 + 1) = 1 1 1 = 1 The expression B 2 is shown to be not satisfiable, but this requires a bit more work. We shall show that on the next slide. NOTE : Each of these two is easy for two reasons.

  1. It is a small problem instance.
  2. It is expressed in Canonical POS. It is easy to show that a CNF expression over N Boolean variables, expressed in Canonical POS form, is satisfiable if and only if it has less than 2 N terms.

CNF Satisfiability: Two Easy Examples (Part 2)

If X = 0 and Y = 0 then B 2 = ^0 ^0 ^0 ^0 ^0 ^0 (0 + 0) = (1 + 1)(1 + 0)(0 + 1)(0 + 0) = 1 1  1 0 = 0 If X = 0 and Y = 1 then B 2 = ^0 ^1 ^0 ^1 ^0 ^1 (0 + 1) = (1 + 0)(1 + 1)(0 + 0)(0 + 1) = 1 1  0 1 = 0 If X = 1 and Y = 0 then B 2 = ^1 ^0 ^1 ^0 ^1 ^0 (1 + 0) = (0 + 1)(0 + 0)(1 + 1)(1 + 0) = 1 0  1 1 = 0 If X = 1 and Y = 1 then B 2 = ^1 ^1 ^1 ^1 ^1 ^1 (1 + 1) = (0 + 0)(0 + 1)(1 +0)(1 + 1) = 0 1  1 1 = 0

3–SAT

The problem 3–SAT refers to the determination of whether or not a Boolean expression in 3–conjunctive normal form is satisfiable. Recall that a Boolean expression over N Boolean variables is said to be in 3–CNF if each of its terms contains exactly three literals. There are a number of significant facts about 3–CNF satisfiability.

  1. It can be shown that any Boolean expression over N Boolean variables can be converted to a logically equivalent Boolean expression in 3–CNF.
  2. There is no known polynomial algorithm that will determine whether or not a 3–CNF expression is satisfiable.
  3. To date, there has been no proof that the problem is intractable ; that is, that no polynomial algorithm can solve it.
  4. This problem was first posed in 1971, and has been examined extensively since that time. In a theoretical sense, the 3–SAT problem is just as difficult as any variety of the problem. As it is easier to discuss, it is the more popular variant.

Circuit Satisfiability

As a problem, SAT originated in formal logic and migrated into Boolean algebra. The problem can be expressed in terms of Boolean combinational circuits that are used in digital design and commonly discussed in courses on Computer Organization and Computer Architecture. A Boolean combinational circuit with N Boolean inputs is said to be satisfiable if and only if there is a truth assignment to the inputs that causes the output to be 1. The Circuit Satisfiability Problem is thus: “Given a Boolean combinational circuit composed of AND, OR, and NOT gates, is it satisfiable?” One of the interesting results of this equivalence is that one can use some of the tools developed for simplification of Boolean expressions in digital design to determine the satisfiability of any Boolean expression. Put another way, both Karnaugh Maps and the Quine–McCluskey methods will solve the 3–SAT problem. Unfortunately, neither is very good at that. We now discuss Karnaugh Maps, also called “K–Maps”, and then apply the results to an understanding of Boolean satisfiability.