+ All Categories
Home > Documents > Propositional Calculus: Boolean Algebra and...

Propositional Calculus: Boolean Algebra and...

Date post: 08-Jun-2019
Category:
Upload: phungdang
View: 214 times
Download: 0 times
Share this document with a friend
21
Propositional Calculus: Boolean Algebra and Simplification CS 270: Mathematical Foundations of Computer Science Jeremy Johnson
Transcript
Page 1: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Propositional Calculus:Boolean Algebra and

Simplification

CS 270: Mathematical Foundations of Computer Science

Jeremy Johnson

Page 2: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Propositional Calculus

TopicsMotivation: Simplifying Conditional

ExpressionsRules of Boolean AlgebraEquational ReasoningProofs Using Truth TablesTautologies and Automatic Verification of

TautologiesSatisfiability and Truth Trees

Page 3: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

3

Programming Example Boolean expressions arise in conditional statements. It is

possible to abstract the relations with boolean variables (propositions that are either true or false). Using this abstraction one can reason and simplify conditional statements.

if ((a < b) || ((a >= b) && (c == d))) then { … } else { … } Let p denote the relation (a<b) and q denote the relation

(c == d). The above expression is then equal to

p || !p && q

Page 4: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

4

Programming Example (cont) The previous expression is equivalent (two expressions are

equivalent if they are true for the same values of the variables occurring in the expressions) to a simpler expression

(p || !p && q) ≡ p || q

We can see this since if p is true both expressions are true, and if p is false, then !p is true and (!p && q) is true exactly when q is true.

Page 5: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Boolean Algebra

The Boolean operators ∨ and ∧ are analogous to addition and multiplication with true and false playing the roles of 1 and 0. Complement is used for negation.

This provides a compact notation and suggests appropriate algebraic simplification

Similar properties hold such as the associative, commutative, and distributive identities.

Page 6: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

6

Sums of Products Disjunctive normal form, using the notation of

Boolean Algebra, corresponds to a sum of products

E.G. (multiplexor function)

s x0 x1 f

0 0 0 0

0 0 1 0

0 1 0 1

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 0

1 1 1 1

Page 7: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Properties of Boolean Algebra Boolean expressions can be simplified using rules of Boolean

algebra Identity law: A + 0 = A and A ● 1 = A. Zero and One laws: A + 1 = 1 and A ● 0 = 0 Inverse laws: Idempotent laws: A + A = A = A ● A Commutative laws: A + B = B + A and A ● B = B ● A. Associative laws:A + (B + C) = (A + B) + C and A ● (B ● C) = (A ● B) ● C. Distributive laws: A ● (B + C) = (A ● B) + (A ● C) and

A + (B ● C) = (A + B) ● (A + C)

Double Negation: ̅�̅�𝐴 = 𝐴𝐴 DeMorgan’s laws:

Page 8: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

8

Simplification of Boolean Expressions

Simplifying multiplexor expression using Boolean algebra

Equational reasoning: replace subexpressions by equivalent expressions Reflexive, Symmetric, Transitive

Verify that the boolean function corresponding to this expression as the same truth table as the original function.

Page 9: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Nand is functionally complete

Using DeMorgan’s Law, ¬ and ∧ are enough to generate all Boolean functionsAll boolean functions can be implemented

using nand gates (and, or and not can be implemented using nand)not:

and:

or:

x y x | y

0 0 1

0 1 1

1 0 1

1 1 0

Page 10: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

10

Conjunctive Normal FormConjunctive normal form (products of

sums) Conjunction of clauses (disjunction of literals)

For each row in the truth table where the output is false, write a sum such that the corresponding input not in that row Alternatively use Demorgan’s law for the

negation of dnf for ¬f (zero rows) Duality (swap and/or true/false)

E.G. (multiplexor function)(𝑠𝑠 + 𝑥𝑥0 + 𝑥𝑥1)⋅(𝑠𝑠 + 𝑥𝑥0 + 𝑥𝑥1)⋅(�̅�𝑠 + 𝑥𝑥0 + 𝑥𝑥1)⋅ (�̅�𝑠 +𝑥𝑥0 + 𝑥𝑥1)

s x0 x1 f

0 0 0 0

0 0 1 0

0 1 0 1

0 1 1 1

1 0 0 0

1 0 1 1

1 1 0 0

1 1 1 1

Page 11: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

11

Additional Notation Several additional Boolean functions of two variables have

special meaning and are given special notation. By our previous results we know that all boolean functions can be expressed with not, and, and or; so the additional notation is simply a convenience.

x y x → y

0 0 1

0 1 1

1 0 0

1 1 1

implication

x y x ≡ y

0 0 1

0 1 0

1 0 0

1 1 1

equivalence

x y x ⊕ y

0 0 0

0 1 1

1 0 1

1 1 0

xor

Page 12: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

12

TautologiesA tautology is a boolean expression that is always

true, independent of the values of the variables occurring in the expression. The properties of Boolean Algebra are examples of tautologies.

Tautologies can be verified using truth tables. The truth table below shows that x → y ≡ ¬ x ∨ y

x y x → y ¬ x ∨ y

0 0 1 1

0 1 1 1

1 0 0 0

1 1 1 1

Page 13: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

13

Exercise

Derive the tautology x → y ≡ ¬ x ∨ yfrom the sum of products expression obtained from the truth table for x → y. You will need to use properties of Boolean algebra to simplify the sum of products expression to obtain the desired equivalence.

Page 14: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

14

Solution

Derive the tautology x → y ≡ ¬ x ∨ y

𝑥𝑥 → 𝑦𝑦 ≡ (¬𝑥𝑥 ∧ ¬𝑦𝑦) ∨ ¬𝑥𝑥 ∧ 𝑦𝑦 ∨ 𝑥𝑥 ∧ 𝑦𝑦≡ (¬𝑥𝑥 ∧ ¬𝑦𝑦) ∨ (¬𝑥𝑥 ∧ 𝑦𝑦) ∨ ¬𝑥𝑥 ∧ 𝑦𝑦 ∨ 𝑥𝑥 ∧ 𝑦𝑦≡ ¬𝑥𝑥 ∧ (¬𝑦𝑦 ∨ 𝑦𝑦) ∨ ¬𝑥𝑥 ∨ 𝑥𝑥 ∧ 𝑦𝑦≡ (¬𝑥𝑥 ∧ 𝑇𝑇) ∨ (𝑇𝑇 ∧ 𝑦𝑦)≡ ¬𝑥𝑥 ∨ 𝑦𝑦

x y x → y

0 0 1

0 1 1

1 0 0

1 1 1

Page 15: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

15

Tautology Checker A program can be written to check to see if a Boolean

expression is a tautology.

Simply generate all possible truth assignments for the variables occurring in the expression and evaluate the expression with its variables set to each of these assignments. If the evaluated expressions are always true, then the given Boolean expression is a tautology.

A similar program can be written to check if any two Boolean expressions E1 and E2 are equivalent, i.e. if E1 ≡ E2. Such a program will be written later in the term.

Page 16: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Satisfiability

A formula is satisfiable if there is an assignment to the variables that make the formula true

A formula is unsatisfiable if all assignments to variables eval to false

A formula is falsifiable if there is an assignment to the variables that make the formula false

A formula is valid if all assignments to variables eval to true (a valid formula is a theorem or tautology)

Page 17: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Satisfiability

Checking to see if a formula f is satisfiable can be done by searching a truth table for a true entry or truth tree construction Exponential in the number of variables Does not appear to be a polynomial time algorithm

(satisfiability is NP-complete) There are efficient satisfiability checkers that work

well on many practical problems

Checking whether f is satisfiable can be done by checking if ¬ f is not valid

An assignment that evaluates to false provides a counter example to validity

Page 18: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Expression Trees

Boolean expressions can be represented by a binary tree

Internal nodes are operatorsLeaf nodes are operandsConsider p ∧ (T ∨ ¬ q):

p ∨

T ¬

q

Page 19: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Truth Tree Construction

• ϕ ∧ ψ

• ϕ ∨ ψ

• ϕ→ ψ

(ϕ ∧ ψ) ϕψ

(ϕ ∨ ψ)

ϕ ψ

(ϕ → ψ)

¬ϕ ψ

Page 20: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Truth Tree Construction

• ¬(ϕ ∧ ψ)

• ¬(ϕ ∨ ψ)

• ¬(ϕ→ ψ)

• ¬ ¬ ϕ

¬(ϕ ∧ ψ)

¬ϕ ¬ψ

¬(ϕ ∨ ψ) ¬ϕ¬ψ

¬(ϕ → ψ) ϕ

¬ψ

¬¬ϕ ϕ

Page 21: Propositional Calculus: Boolean Algebra and Simplificationjjohnson/2015-16/spring/CS270/Lectures/1/BoolAlg.pdf · 10. Conjunctive Normal Form Conjunctive normal form (products of

Example Truth Tree


Recommended