Discrete Mathematics CS 2610

18
Discrete Mathematics CS 2610 February 12, 2009

description

Discrete Mathematics CS 2610. February 12, 2009. Agenda. Previously Finished functions Began Boolean algebras And now Continue with Boolean algebras. But First. p  q  r, is NOT true when only one of p, q, or r is true. Why not? It is true for (p Λ ¬q Λ ¬r) - PowerPoint PPT Presentation

Transcript of Discrete Mathematics CS 2610

Page 1: Discrete Mathematics   CS 2610

Discrete Mathematics CS 2610

February 12, 2009

Page 2: Discrete Mathematics   CS 2610

2

Agenda

Previously Finished functions Began Boolean algebras

And now Continue with Boolean algebras

Page 3: Discrete Mathematics   CS 2610

3

But First

p q r, is NOT true when only one of p, q, or r is true. Why not?

It is true for (p Λ ¬q Λ ¬r)It is true for (¬p Λ q Λ ¬r)It is true for (¬p Λ ¬q Λ r)

So what’s wrong? Raise your hand when you know.

Page 4: Discrete Mathematics   CS 2610

4

Injective Functions (one-to-one)

If function f : A B is 1-to-1 then every b B has 0 or 1 pre-image.Proof (bwoc): Say f is 1-to-1 and b B has 2 or more pre-images.Then a1, a2 st a1 A and a2 A, and a1 ≠ a2.

So f(a1) = b and f(a2) = b, meaning f(a1) = f(a2).

This contradicts the definition of an injection since when a1 ≠ a2 we know f(a1) ≠ f(a2).

Page 5: Discrete Mathematics   CS 2610

5

Boolean Algebras (Chapter 11)

Boolean algebra provides the operations and the rules for working with the set {0, 1}.

These are the rules that underlie electronic and optical circuits, and the methods we will discuss are fundamental to VLSI design.

Page 6: Discrete Mathematics   CS 2610

6

Boolean Algebra

The minimal Boolean algebra is the algebra formed over the set of truth values {0, 1} by using the operations functions +, ·, - (sum, product, complement).

The minimal Boolean algebra is equivalent to propositional logic where O corresponds to False 1 corresponds to True corresponds logical operator AND + corresponds logical operator OR - corresponds logical operator NOT

Page 7: Discrete Mathematics   CS 2610

7

Boolean Algebra Tables

x

0

0

1

1

y

0

1

0

1

x + y

0

1

1

1

xy

0

0

0

1

x

0

1

x

1

0

x,y are Boolean variables – they assume values 0 or 1

Page 8: Discrete Mathematics   CS 2610

8

Boolean n-Tuples

Let B = {0, 1}, the set of Boolean values.

Let Bn = { (x1,x2,…xn) | xi B, i=1,..,n}

.

B1= { (x1) | x1 B,}

B2= { (x1, x2), | xi B, i=1,2}

Bn= { ((x1,x2,…xn) | xi B, i=1,..,n,}

For all nZ+, any function f:Bn→B is called a Boolean function of degree n.

Page 9: Discrete Mathematics   CS 2610

9

Example Boolean Function

x

0

0

0

0

1

1

1

1

y

0

0

1

1

0

0

1

1

z

0

1

0

1

0

1

0

1

F(x,y,z)=x(y+z)

F(x,y,z) =B3B

B3 has 8 triplets

0

0

0

0

1

1

0

1

Page 10: Discrete Mathematics   CS 2610

10

Number of Boolean Functions

How many different Boolean functions of degree 1 are there?How many different Boolean functions of degree 2 are there?How many different functions of degree n are there ? There are 22ⁿ distinct Boolean functions of

degree n.

Page 11: Discrete Mathematics   CS 2610

11

Combining Boolean Functions

Let F and G be two Booleans functions of degree n.

• Complement of F: F (x1,..xn) = F (x1,..xn)

• Boolean Sum : (F + G)(x1,..xn) = F (x1,..xn) + G (x1,..xn)

• Boolean Product: (F·G)(x1,..xn) = F(x1,..xn)·G(x1,..xn)

Page 12: Discrete Mathematics   CS 2610

12

Equal Boolean Functions

Two Boolean functions F and G of degree n are equal iff for all (x1,..xn) Bn, F (x1,..xn) = G (x1,..xn)

Example: F(x,y,z) = x(y+z), G(x,y,z) = xy + zx

Page 13: Discrete Mathematics   CS 2610

13

Boolean ExpressionsLet x1, …, xn be n different Boolean variables.

A Boolean expression is a string of one of the following forms (recursive definition): 0, 1, x1, …, or xn. are Boolean Expressions If E1 and E2 are Boolean expressions then -E1,

(E1E2), or (E1+E2) are Boolean expressions.

Example:E1 = x

E2 = y

E3 = z

E4 = E1 + E2= x + y

E5 = E1E2= x y

E6 = -E3 = -z

E7 = E6 + E4 = -z + x + y

E8 = E6 E4 = -z ( x + y)

Note: equivalent notation: -E = E for complement

Page 14: Discrete Mathematics   CS 2610

14

Functions and Expressions

F(x1,x2,x3)

1110

1010

0100

1000

x3x2x1

0001

0101

0011

1111

A Boolean expression represents a Boolean function.

Furthermore, every Boolean function (of a given degree) can be represented by a Boolean expression with n variables.

F(x1,x2,x3) = x1(x2+x3)+x1x2x3

Page 15: Discrete Mathematics   CS 2610

15

Boolean Functions

Two Boolean expressions e1 and e2 that represent the exact same function F are called equivalent

F(x1,x2,x3)

1110

1010

0100

1000

x3x2x1

0001

0101

0011

1111

F(x1,x2,x3) = x1(x2+x3)+x1x2x3

F(x1,x2,x3) = x1x2+x1x3+x1x2x3

Page 16: Discrete Mathematics   CS 2610

16

Representing Boolean Functions

How to construct a Boolean expression that represents a Boolean Function ?

1110

1010

0100

0000

zyx

0001

1101

0011

1111

F

(-x)(y)(-z) + (-x)yz + x(-y)z + xyz

F(x, y, z) = 1 if and only if:

What about a 2-input multiplexer?

Page 17: Discrete Mathematics   CS 2610

17

Boolean Identities

Double complement:x = x

Idempotent laws:x + x = x, x · x = x

Identity laws:x + 0 = x, x · 1 = x

Domination laws:x + 1 = 1, x · 0 = 0

Commutative laws:x + y = y + x, x · y = y ·

x

Associative laws:x + (y + z) = (x + y) + zx · (y · z) = (x · y) · z

Distributive laws:x + y ·z = (x + y)·(x + z)x · (y + z) = x ·y + x ·z

De Morgan’s laws:(x · y) = x + y, (x + y) =

x · yAbsorption laws:x + x ·y = x, x · (x + y) =

x

the Unit Property: x + x = 1 and Zero Property: x ·x = 0

Page 18: Discrete Mathematics   CS 2610

18

Boolean Identities

Absorption law:

Show that x ·(x + y) = x

1) x ·(x + y) = (x + 0) ·(x + y) identity2) = x + 0 ·y distributive *3) = x + y · 0 commutative4) = x + 0 domination5) = x identity