+ All Categories
Home > Documents > Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set...

Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set...

Date post: 26-Mar-2015
Category:
Upload: owen-bird
View: 219 times
Download: 1 times
Share this document with a friend
Popular Tags:
75
Spring 2003 CMSC 203 - Discrete Structures 1 and now for something and now for something completely different… completely different… Set Theory Set Theory Actually, you will see that Actually, you will see that logic and set theory are logic and set theory are very closely related. very closely related.
Transcript
Page 1: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 1

… … and now for something and now for something completely different…completely different…

Set TheorySet TheoryActually, you will see that logic Actually, you will see that logic and set theory are very closely and set theory are very closely

related.related.

Page 2: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 2

Set TheorySet Theory

• Set: Collection of objects (called Set: Collection of objects (called elementselements))

• aaAA “a is an element of A” “a is an element of A” “a is a member of A” “a is a member of A”

• aaAA “a is not an element of A” “a is not an element of A”

• A = {aA = {a11, a, a22, …, a, …, ann} } “A contains a“A contains a11, …, a, …, ann””

• Order of elements is insignificantOrder of elements is insignificant

• It does not matter how often the same It does not matter how often the same element is listed (repetition doesn’t count).element is listed (repetition doesn’t count).

Page 3: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 3

Set EqualitySet Equality

Sets A and B are equal if and only if they Sets A and B are equal if and only if they contain exactly the same elements.contain exactly the same elements.

Examples:Examples:

• A = {9, 2, 7, -3}, B = {7, 9, -3, A = {9, 2, 7, -3}, B = {7, 9, -3, 2} :2} :

A = BA = B

• A = {dog, cat, horse}, A = {dog, cat, horse}, B = {cat, horse, squirrel, dog} B = {cat, horse, squirrel, dog} ::

A A B B

• A = {dog, cat, horse}, A = {dog, cat, horse}, B = {cat, horse, dog, dog} : B = {cat, horse, dog, dog} : A = BA = B

Page 4: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 4

Examples for SetsExamples for Sets

““Standard” Sets:Standard” Sets:

• Natural numbers Natural numbers NN = {0, 1, 2, 3, …} = {0, 1, 2, 3, …}

• Integers Integers ZZ = {…, -2, -1, 0, 1, 2, …} = {…, -2, -1, 0, 1, 2, …}

• Positive Integers Positive Integers ZZ++ = {1, 2, 3, 4, …} = {1, 2, 3, 4, …}

• Real Numbers Real Numbers RR = {47.3, -12, = {47.3, -12, , …}, …}• Rational Numbers Rational Numbers QQ = {1.5, 2.6, -3.8, 15, = {1.5, 2.6, -3.8, 15,

…}…}

(correct definitions will follow)(correct definitions will follow)

Page 5: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 5

Examples for SetsExamples for Sets

• A = A = “empty set/null set”“empty set/null set”

• A = {z}A = {z} Note: zNote: zA, but z A, but z {z} {z}

• A = {{b, c}, {c, x, d}}A = {{b, c}, {c, x, d}} set of setsset of sets

• A = {{x, y}} A = {{x, y}} Note: {x, y} Note: {x, y} A, but {x, y} A, but {x, y} {{x, y}}{{x, y}}

• A = {x | P(x)} A = {x | P(x)} “set of all x such that P(x)”“set of all x such that P(x)”

P(x) is the P(x) is the membership functionmembership function of set A of set A

x (P(x) x (P(x) x xA)A)

• A = {x | xA = {x | x NN x > 7} = {8, 9, 10, …}x > 7} = {8, 9, 10, …}“set builder notation”“set builder notation”

Page 6: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 6

Examples for SetsExamples for Sets

We are now able to define the set of rational We are now able to define the set of rational numbers Q:numbers Q:

QQ = {a/b | a = {a/b | aZZ bbZZ++}, }, or or

QQ = {a/b | a = {a/b | aZZ bbZ Z bb0} 0}

And how about the set of real numbers R?And how about the set of real numbers R?

RR = {r | r is a real number} = {r | r is a real number}

That is the best we can do. It can neither be That is the best we can do. It can neither be

defined by enumeration nor builder function.defined by enumeration nor builder function.

Page 7: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 7

SubsetsSubsetsA A B B “A is a subset of B” “A is a subset of B”A A B if and only if every element of A is also B if and only if every element of A is also an element of B. an element of B.We can completely formalize this:We can completely formalize this:A A B B x (xx (xA A xxB)B)

Examples:Examples:

A = {3, 9}, B = {5, 9, 1, 3}, A A = {3, 9}, B = {5, 9, 1, 3}, A B ? B ?

truetrue

A = {3, 3, 3, 9}, B = {5, 9, 1, 3}, A A = {3, 3, 3, 9}, B = {5, 9, 1, 3}, A B ? B ?

falsefalse

truetrue

A = {1, 2, 3}, B = {2, 3, 4}, A A = {1, 2, 3}, B = {2, 3, 4}, A B ? B ?

Page 8: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 8

SubsetsSubsetsUseful rules:Useful rules:• A = B A = B (A (A B) B) (B (B A) A) • (A (A B) B) (B (B C) C) A A C C (see Venn Diagram)(see Venn Diagram)

UU

AABB

CC

Page 9: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 9

SubsetsSubsets

Useful rules:Useful rules: A for any set A A for any set A

(but (but A may not hold for any set A) A may not hold for any set A)• AA A for any set A A for any set A

Proper subsets:Proper subsets:A A B B “A is a proper subset of B”“A is a proper subset of B” A A B B x (xx (xA A x xB) B) x (xx (xB B x xA)A)ororA A B B x (xx (xA A x xB) B) x (xx (xB B xxA) A)

Page 10: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 10

Cardinality of SetsCardinality of Sets

If a set S contains n If a set S contains n distinctdistinct elements, n elements, nNN,,we call S a we call S a finite setfinite set with with cardinality ncardinality n..

Examples:Examples:

A = {Mercedes, BMW, Porsche}, |A| = 3A = {Mercedes, BMW, Porsche}, |A| = 3

B = {1, {2, 3}, {4, 5}, 6}B = {1, {2, 3}, {4, 5}, 6} |B| = |B| = 44C = C = |C| = 0|C| = 0

D = { xD = { xN N | x | x 7000 } 7000 } |D| = 7001|D| = 7001

E = { xE = { xN N | x | x 7000 } 7000 } E is infinite!E is infinite!

Page 11: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 11

The Power SetThe Power Set

P(A) P(A) “power set of A” (also written as “power set of A” (also written as 22AA))

P(A) = {B | B P(A) = {B | B A} A} (contains all subsets of A)(contains all subsets of A)

Examples:Examples:

A = {x, y, z}A = {x, y, z}

P(A)P(A) = {= {, {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, , {x}, {y}, {z}, {x, y}, {x, z}, {y, z}, {x, y, z}}{x, y, z}}

A = A = P(A) = {P(A) = {}}

Note: |A| = 0, |P(A)| = 1Note: |A| = 0, |P(A)| = 1

Page 12: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 12

The Power SetThe Power SetCardinality of power sets: Cardinality of power sets: | P(A) | = 2| P(A) | = 2|A||A|

• Imagine each element in A has an “Imagine each element in A has an “onon//offoff” switch” switch• Each possible switch configuration in A Each possible switch configuration in A

corresponds to one subset of A, thus one element corresponds to one subset of A, thus one element in P(A)in P(A)

zzzzzzzzzzzzzzzzzzyyyyyyyyyyyyyyyyyyxxxxxxxxxxxxxxxxxx8877665544332211AA

• For 3 elements in A, there are For 3 elements in A, there are 22222 = 8 elements in P(A)2 = 8 elements in P(A)

Page 13: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 13

Cartesian ProductCartesian ProductThe The ordered n-tupleordered n-tuple (a (a11, a, a22, a, a33, …, a, …, ann) is an ) is an

ordered collectionordered collection of n objects. of n objects.

Two ordered n-tuples (aTwo ordered n-tuples (a11, a, a22, a, a33, …, a, …, ann) and ) and

(b(b11, b, b22, b, b33, …, b, …, bnn) are equal if and only if they ) are equal if and only if they

contain exactly the same elements contain exactly the same elements in the in the same ordersame order, i.e. a, i.e. aii = b = bii for 1 for 1 i i n. n.

The The Cartesian productCartesian product of two sets is defined of two sets is defined as:as:

AAB = {(a, b) | aB = {(a, b) | aA A b bB}B}

Page 14: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 14

Cartesian ProductCartesian Product

Example:Example:

A = {good, bad}, B = {student, prof}A = {good, bad}, B = {student, prof}

AAB = {B = {(good, student),(good, student), (good, prof),(good, prof), (bad, student),(bad, student), (bad, prof)(bad, prof)}}

(prof, bad)(prof, bad)}} (student, good),(student, good), (prof, good),(prof, good), (student, bad),(student, bad), BBA = A = {{Example:Example: A = {x, y}, B = {a, b, c} A = {x, y}, B = {a, b, c}AAB = {(x, a), (x, b), (x, c), (y, a), (y, b), (y, B = {(x, a), (x, b), (x, c), (y, a), (y, b), (y, c)}c)}

Page 15: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 15

Cartesian ProductCartesian Product

Note that:Note that:

• AA = = • A = A = • For non-empty sets A and B: AFor non-empty sets A and B: AB B A AB B BBAA

• |A|AB| = |A|B| = |A||B||B|

The Cartesian product of The Cartesian product of two or more setstwo or more sets is is defined as:defined as:

AA11AA22……AAnn = {(a = {(a11, a, a22, …, a, …, ann) | a) | aiiAAii for 1 for 1 i i

n} n}

Page 16: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 16

Set OperationsSet Operations

Union: AUnion: AB = {x | xB = {x | xA A x xB}B}

Example:Example: A = {a, b}, B = {b, c, d} A = {a, b}, B = {b, c, d} AAB = {a, b, c, d} B = {a, b, c, d}

Intersection: AIntersection: AB = {x | xB = {x | xA A x xB}B}

Example:Example: A = {a, b}, B = {b, c, d} A = {a, b}, B = {b, c, d} AAB = {b}B = {b}Cardinality: |ACardinality: |AB| = |A| + |B| - |AB| = |A| + |B| - |AB|B|

Page 17: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 17

Set OperationsSet Operations

Two sets are called Two sets are called disjointdisjoint if their intersection if their intersection is empty, that is, they share no elements:is empty, that is, they share no elements:AAB = B =

The The differencedifference between two sets A and B between two sets A and B contains exactly those elements of A that are contains exactly those elements of A that are not in B:not in B:A-B = {x | xA-B = {x | xA A x xB}B}Example: Example: A = {a, b}, B = {b, c, d}, A-B = {a}A = {a, b}, B = {b, c, d}, A-B = {a}

Cardinality: |A-B| = |A| - |ACardinality: |A-B| = |A| - |AB|B|

Page 18: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 18

Set OperationsSet Operations

The The complementcomplement of a set A contains exactly of a set A contains exactly those elements under consideration that are those elements under consideration that are not in A: denoted Anot in A: denoted Ac c (or as in the text)(or as in the text)AAcc = U-A = U-A

Example: Example: U = U = NN, B = {250, 251, 252, …}, B = {250, 251, 252, …} BBcc = {0, 1, 2, …, 248, 249} = {0, 1, 2, …, 248, 249}

A

Page 19: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 19

Logical EquivalenceLogical EquivalenceEquivalence lawsEquivalence laws

– Identity laws, Identity laws, P P T T P, P,

– Domination laws, Domination laws, P P F F F, F,

– Idempotent laws, Idempotent laws, P P P P P, P,

– Double negation law, Double negation law, (( P P) ) P P

– Commutative laws, Commutative laws, P P Q Q Q Q P, P,

– Associative laws, Associative laws, P P (Q (Q R) R) ( (P P Q) Q) R R,,

– Distributive laws, Distributive laws, P P (Q (Q R) R) ( (P P Q) Q) (P (P R) R),,

– De Morgan’s laws, De Morgan’s laws, (P(PQ) Q) (( P) P) ( ( Q)Q)– Law with implicationLaw with implication P P Q Q P P Q Q

Page 20: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 20

Set IdentitySet IdentityTable 1 in Section 1.7 shows many useful equations Table 1 in Section 1.7 shows many useful equations

– Identity laws, Identity laws, AA = A = A, , AAU = AU = A

– Domination laws, Domination laws, AAU = UU = U, , AA = = – Idempotent laws, Idempotent laws, AAA = AA = A, , AAAA = = AA– Complementation law, Complementation law, ((AAcc))cc = A= A

– Commutative laws, Commutative laws, AAB =B = B BA, AA, AB = BB = BAA– Associative laws, Associative laws, AA(B(B C) = (A C) = (AB)B)CC, …, …

– Distributive laws, Distributive laws, AA(B(BC) = (AC) = (AB)B)(A(AC)C), …, …

– De Morgan’s laws, De Morgan’s laws, (A(AB)B)c c = = AAccBBc, c, (A(AB)B)c c = = AAccBBcc

– Absorption laws,Absorption laws, AA(A(AB) = AB) = A, , AA(A(AB) = AB) = A

– Complement laws,Complement laws, AAAAcc = U, A = U, AAAcc = =

Page 21: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 21

Set IdentitySet Identity

How can we prove AHow can we prove A(B(BC) = (AC) = (AB)B)(A(AC)?C)?

Method I:Method I: logical equivalentlogical equivalent

xxAA(B(BC)C) xxA A x x(B(BC)C) xxA A (x (xB B x xC)C) (x(xA A x xB) B) (x (xA A x xC) C) (distributive law)(distributive law) xx(A(AB) B) x x(A(AC)C) xx(A(AB)B)(A(AC)C)

Every logical expression can be transformed into an Every logical expression can be transformed into an equivalent expression in set theory and vice versa.equivalent expression in set theory and vice versa.

Page 22: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 22

Set OperationsSet OperationsMethod II: Membership tableMethod II: Membership table

1 means “x is an element of this set”1 means “x is an element of this set”0 means “x is not an element of this set” 0 means “x is not an element of this set”

11111111111 1 11 1 1

11111111001 1 01 1 0

11111111001 0 11 0 1

11111111001 0 01 0 0

11111111110 1 10 1 1

00001100000 1 00 1 0

00110000000 0 10 0 1

00000000000 0 00 0 0

(A(AB) B) (A(AC)C)AACCAABBAA(B(BC)C)BBCCA B CA B C

Page 23: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 23

… … and the following and the following mathematical appetizer is mathematical appetizer is

about…about…

FunctionsFunctions

Page 24: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 24

FunctionsFunctions

A A functionfunction f from a set A to a set B is an f from a set A to a set B is an assignmentassignment of of exactly oneexactly one element of B to element of B to eacheach element of A.element of A.

We writeWe write

f(a) = bf(a) = b

if b is the unique element of B assigned by the if b is the unique element of B assigned by the function f to the element a of A.function f to the element a of A.

If f is a function from A to B, we writeIf f is a function from A to B, we write

f: Af: ABB

(note: Here, “(note: Here, ““ has nothing to do with if… “ has nothing to do with if… then)then)

Page 25: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 25

FunctionsFunctions

If f:AIf f:AB, we say that A is the B, we say that A is the domaindomain of f and B of f and B is the is the codomaincodomain of f. of f.

If f(a) = b, we say that b is the If f(a) = b, we say that b is the imageimage of a and of a and a is the a is the pre-imagepre-image of b. of b.

The The rangerange of f:A of f:AB is the set of all images of B is the set of all images of allall elements of A. elements of A.

We say that f:AWe say that f:AB B mapsmaps A to B. A to B.

Page 26: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 26

FunctionsFunctions

Let us take a look at the function f:PLet us take a look at the function f:PC withC withP = {Linda, Max, Kathy, Peter}P = {Linda, Max, Kathy, Peter}C = {Boston, New York, Hong Kong, Moscow}C = {Boston, New York, Hong Kong, Moscow}

f(Linda) = Moscowf(Linda) = Moscowf(Max) = Bostonf(Max) = Bostonf(Kathy) = Hong Kongf(Kathy) = Hong Kongf(Peter) = New Yorkf(Peter) = New York

Here, the range of f is C.Here, the range of f is C.

Page 27: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 27

FunctionsFunctions

Let us re-specify f as follows:Let us re-specify f as follows:

f(Linda) = Moscowf(Linda) = Moscow

f(Max) = Bostonf(Max) = Boston

f(Kathy) = Hong Kongf(Kathy) = Hong Kong

f(Peter) = Bostonf(Peter) = Boston

Is f still a function?Is f still a function? yesyes

{Moscow, Boston, Hong {Moscow, Boston, Hong Kong}Kong}

What is its range?What is its range?

Page 28: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 28

FunctionsFunctions

Other ways to represent f:Other ways to represent f:

BostonBostonPeterPeter

Hong Hong KongKongKathyKathy

BostonBostonMaxMax

MoscowMoscowLindaLinda

f(x)f(x)xx LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKong

MoscowMoscow

Page 29: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 29

FunctionsFunctions

If the domain of our function f is large, it is If the domain of our function f is large, it is convenient to specify f with a convenient to specify f with a formulaformula, e.g.:, e.g.:

f:f:RRRR f(x) = 2xf(x) = 2x

This leads to:This leads to:f(1) = 2f(1) = 2f(3) = 6f(3) = 6f(-3) = -6f(-3) = -6……

Page 30: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 30

FunctionsFunctions

Let fLet f11 and f and f22 be functions from A to be functions from A to RR..

Then the Then the sumsum and the and the productproduct of f of f11 and f and f22 are are also functions from A to also functions from A to RR defined by: defined by:

(f(f11 + f + f22)(x) = f)(x) = f11(x) + f(x) + f22(x)(x)

(f(f11ff22)(x) = f)(x) = f11(x) f(x) f22(x)(x)

Example:Example:

ff11(x) = 3x, f(x) = 3x, f22(x) = x + 5(x) = x + 5

(f(f11 + f + f22)(x) = f)(x) = f11(x) + f(x) + f22(x) = 3x + x + 5 = 4x + 5(x) = 3x + x + 5 = 4x + 5

(f(f11ff22)(x) = f)(x) = f11(x) f(x) f22(x) = 3x (x + 5) = 3x(x) = 3x (x + 5) = 3x22 + 15x + 15x

Page 31: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 31

FunctionsFunctions

We already know that the We already know that the rangerange of a function of a function f:Af:AB is the set of all images of elements aB is the set of all images of elements aA.A.

If we only regard a If we only regard a subsetsubset S SA, the set of all A, the set of all images of elements simages of elements sS is called the S is called the imageimage of of S.S.

We denote the image of S by f(S):We denote the image of S by f(S):

f(S) = {f(s) | sf(S) = {f(s) | sS}S}

Page 32: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 32

FunctionsFunctions

Let us look at the following well-known function:Let us look at the following well-known function:

f(Linda) = Moscowf(Linda) = Moscow

f(Max) = Bostonf(Max) = Boston

f(Kathy) = Hong Kongf(Kathy) = Hong Kong

f(Peter) = Bostonf(Peter) = Boston

What is the image of S = {Linda, Max} ?What is the image of S = {Linda, Max} ?

f(S) = {Moscow, Boston}f(S) = {Moscow, Boston}

What is the image of S = {Max, Peter} ?What is the image of S = {Max, Peter} ?

f(S) = {Boston}f(S) = {Boston}

Page 33: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 33

Properties of FunctionsProperties of Functions

A function f:AA function f:AB is said to be B is said to be one-to-oneone-to-one (or (or injectiveinjective), if and only if), if and only if

x, yx, yA (f(x) = f(y) A (f(x) = f(y) x = y) x = y)

In other words:In other words: f is one-to-one if and only if it f is one-to-one if and only if it does not map two distinct elements of A onto does not map two distinct elements of A onto the same element of B.the same element of B.

Page 34: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 34

Properties of FunctionsProperties of Functions

And again…And again…

f(Linda) = Moscowf(Linda) = Moscow

f(Max) = Bostonf(Max) = Boston

f(Kathy) = Hong Kongf(Kathy) = Hong Kong

f(Peter) = Bostonf(Peter) = Boston

Is f one-to-one?Is f one-to-one?

No, Max and Peter are No, Max and Peter are mapped onto the mapped onto the same element of the same element of the image.image.

g(Linda) = Moscowg(Linda) = Moscow

g(Max) = Bostong(Max) = Boston

g(Kathy) = Hong g(Kathy) = Hong KongKong

g(Peter) = New Yorkg(Peter) = New York

Is g one-to-one?Is g one-to-one?

Yes, each element is Yes, each element is assigned a unique assigned a unique element of the element of the image.image.

Page 35: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 35

Properties of FunctionsProperties of Functions

How can we prove that a function f is one-to-How can we prove that a function f is one-to-one?one?

Whenever you want to prove something, first Whenever you want to prove something, first take a look at the relevant definition(s):take a look at the relevant definition(s):

x, yx, yA (f(x) = f(y) A (f(x) = f(y) x = y) x = y)

Example:Example:

f:f:RRRR

f(x) = xf(x) = x22

Disproof by counterexample:

f(3) = f(-3), but 3 f(3) = f(-3), but 3 -3, so f is not one-to-one. -3, so f is not one-to-one.

Page 36: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 36

Properties of FunctionsProperties of Functions

… … and yet another example:and yet another example:

f:f:RRRR

f(x) = 3xf(x) = 3x

One-to-one: One-to-one: x, yx, yA (f(x) = f(y) A (f(x) = f(y) x = y) x = y)

To show:To show: f(x) f(x) f(y) whenever x f(y) whenever x y ( y (indirect proofindirect proof))

x x y y 3x 3x 3y 3y f(x) f(x) f(y), f(y),

so if x so if x y, then f(x) y, then f(x) f(y), that is, f is one-to-one. f(y), that is, f is one-to-one.

Page 37: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 37

Properties of FunctionsProperties of Functions

A function f:AA function f:AB with A,B B with A,B R is called R is called strictly strictly increasingincreasing, if , if

x,yx,yA (x < y A (x < y f(x) < f(y)), f(x) < f(y)),

and and strictly decreasingstrictly decreasing, if, if

x,yx,yA (x < y A (x < y f(x) > f(y)). f(x) > f(y)).

Obviously, a function that is either strictly Obviously, a function that is either strictly increasing or strictly decreasing is increasing or strictly decreasing is one-to-oneone-to-one..

Page 38: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 38

Properties of FunctionsProperties of Functions

A function f:AA function f:AB is called B is called ontoonto, or , or surjectivesurjective, if , if and only if for every element band only if for every element bB there is an B there is an element aelement aA with f(a) = b.A with f(a) = b.

In other words, f is onto if and only if its In other words, f is onto if and only if its rangerange is is its its entire codomainentire codomain..

A function f: AA function f: AB is a B is a one-to-one one-to-one correspondencecorrespondence, or a , or a bijectionbijection, if and only if it is , if and only if it is both one-to-one and onto.both one-to-one and onto.

Obviously, if f is a bijection and A and B are Obviously, if f is a bijection and A and B are finite sets, then |A| = |B|.finite sets, then |A| = |B|.

Page 39: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 39

Properties of FunctionsProperties of Functions

Examples:Examples:

In the following examples, we use the arrow In the following examples, we use the arrow representation to illustrate functions f:Arepresentation to illustrate functions f:AB. B.

In each example, the complete sets A and B are In each example, the complete sets A and B are shown.shown.

Page 40: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 40

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?

No.No.

Is f surjective?Is f surjective?

No.No.

Is f bijective?Is f bijective?

No.No.

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKong

MoscowMoscow

Page 41: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 41

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?

No.No.

Is f surjective?Is f surjective?

Yes.Yes.

Is f bijective?Is f bijective?

No.No.

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKong

MoscowMoscow

PaulPaul

Page 42: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 42

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?

Yes.Yes.

Is f surjective?Is f surjective?

No.No.

Is f bijective?Is f bijective?

No.No.

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKong

MoscowMoscow

LLüübeckbeck

Page 43: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 43

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?

No! f is not evenNo! f is not evena function!a function!

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKong

MoscowMoscow

LLüübeckbeck

Page 44: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 44

Properties of FunctionsProperties of Functions

Is f injective?Is f injective?

Yes.Yes.

Is f surjective?Is f surjective?

Yes.Yes.

Is f bijective?Is f bijective?

Yes.Yes.

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKong

MoscowMoscow

LLüübeckbeckHelenaHelena

Page 45: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 45

InversionInversion

An interesting property of bijections is that An interesting property of bijections is that they have an they have an inverse functioninverse function..

The The inverse functioninverse function of the bijection of the bijection f:Af:AB is the function fB is the function f-1-1:B:BA with A with

ff-1-1(b) = a whenever f(a) = b. (b) = a whenever f(a) = b.

Page 46: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 46

InversionInversion

Example:Example:

f(Linda) = Moscowf(Linda) = Moscow

f(Max) = Bostonf(Max) = Boston

f(Kathy) = Hong f(Kathy) = Hong KongKong

f(Peter) = Lf(Peter) = Lüübeckbeck

f(Helena) = New f(Helena) = New YorkYork

Clearly, f is Clearly, f is bijective.bijective.

The inverse function The inverse function ff-1-1 is given by: is given by:

ff-1-1(Moscow) = Linda(Moscow) = Linda

ff-1-1(Boston) = Max(Boston) = Max

ff-1-1(Hong Kong) = (Hong Kong) = KathyKathy

ff-1-1(L(Lüübeck) = Peterbeck) = Peter

ff-1-1(New York) = (New York) = HelenaHelena

Inversion is only Inversion is only possible for possible for bijectionsbijections(= invertible (= invertible functions)functions)

Page 47: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 47

InversionInversion

LindaLinda

MaxMax

KathyKathy

PeterPeter

BostonBoston

New New YorkYorkHong Hong KongKong

MoscowMoscow

LLüübeckbeckHelenaHelena

ff

ff-1-1

ff-1-1:C:CP is no P is no function, because function, because it is not defined it is not defined for all elements of for all elements of C and assigns two C and assigns two images to the pre-images to the pre-image New York.image New York.

Page 48: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 48

CompositionCompositionThe The compositioncomposition of two functions g:A of two functions g:AB B and f:Band f:BC, denoted by fC, denoted by fg, is defined by g, is defined by

(f(fg)(a) = f(g(a))g)(a) = f(g(a))

This means that This means that • firstfirst, function g is applied to element , function g is applied to element aaA,A, mapping it onto an element of B, mapping it onto an element of B,• thenthen, function f is applied to this element , function f is applied to this element of of B, mapping it onto an element of C. B, mapping it onto an element of C.• ThereforeTherefore, the composite function maps , the composite function maps from A to C. from A to C.

Page 49: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 49

CompositionComposition

Example:Example:

f(x) = 7x – 4, g(x) = 3x,f(x) = 7x – 4, g(x) = 3x,

f:f:RRRR, g:, g:RRRR

(f(fg)(5) = f(g(5)) = f(15) = 105 – 4 = 101g)(5) = f(g(5)) = f(15) = 105 – 4 = 101

(f(fg)(x) = f(g(x)) = f(3x) = 21x - 4g)(x) = f(g(x)) = f(3x) = 21x - 4

Page 50: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 50

CompositionComposition

Composition of a function and its inverse:Composition of a function and its inverse:

(f(f-1-1f)(x) = ff)(x) = f-1-1(f(x)) = x(f(x)) = x

The composition of a function and its The composition of a function and its inverse is the inverse is the identity functionidentity function i(x) = x. i(x) = x.

Page 51: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 51

GraphsGraphs

TheThe graphgraph of a functionof a function f:Af:AB is the set of B is the set of ordered pairs {(a, b) | aordered pairs {(a, b) | aA and f(a) = b}.A and f(a) = b}.

The graph is a subset of AThe graph is a subset of AB that can be B that can be used to visualize f in a two-dimensional used to visualize f in a two-dimensional coordinate system.coordinate system.

Page 52: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 52

Floor and Ceiling FunctionsFloor and Ceiling Functions

The The floorfloor and and ceilingceiling functions map the real functions map the real numbers onto the integers (numbers onto the integers (RRZZ).).

The The floorfloor function assigns to r function assigns to rRR the largest the largest zzZZ with z with z r, denoted by r, denoted by rr..

Examples:Examples: 2.32.3 = 2, = 2, 22 = 2, = 2, 0.50.5 = 0, = 0, -3.5-3.5 = - = -44

The The ceilingceiling function assigns to r function assigns to rRR the the smallest zsmallest zZZ with z with z r, denoted by r, denoted by rr..

Examples:Examples: 2.32.3 = 3, = 3, 22 = 2, = 2, 0.50.5 = 1, = 1, -3.5-3.5 = - = -3 3

Page 53: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 53

Now, something aboutNow, something about

BooleanAlBooleanAlgebragebra(section 10.1)(section 10.1)

Page 54: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 54

Boolean AlgebraBoolean Algebra

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

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

We are going to focus on three operations:We are going to focus on three operations:

• Boolean complementation,Boolean complementation,

• Boolean sum, andBoolean sum, and

• Boolean productBoolean product

Page 55: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 55

Boolean OperationsBoolean Operations

The The complementcomplement is denoted by a bar (on the is denoted by a bar (on the slides, we will use a minus sign). It is defined byslides, we will use a minus sign). It is defined by

-0 = 1 and -1 = 0.-0 = 1 and -1 = 0.

The The Boolean sumBoolean sum, denoted by + or by OR, has , denoted by + or by OR, has the following values:the following values:

1 + 1 = 1, 1 + 0 = 1, 0 + 1 = 1, 0 + 0 = 01 + 1 = 1, 1 + 0 = 1, 0 + 1 = 1, 0 + 0 = 0

The The Boolean productBoolean product, denoted by , denoted by or by or by AND, has the following values:AND, has the following values:

1 1 1 = 1, 1 1 = 1, 1 0 = 0, 0 0 = 0, 0 1 = 0, 0 1 = 0, 0 0 = 0 0 = 0

Page 56: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 56

Boolean Functions and ExpressionsBoolean Functions and Expressions

Definition:Definition: Let B = {0, 1}. The variable x is Let B = {0, 1}. The variable x is called a called a Boolean variableBoolean variable if it assumes values if it assumes values only from B.only from B.

A function from BA function from Bnn, the set {(x, the set {(x11, x, x22, …, x, …, xnn) |x) |xiiB, B,

1 1 i i n}, to B is called a n}, to B is called a Boolean function Boolean function of degree nof degree n..

Boolean functions can be represented using Boolean functions can be represented using expressions made up from the variables and expressions made up from the variables and Boolean operations.Boolean operations.

Page 57: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 57

Boolean Functions and ExpressionsBoolean Functions and Expressions

The The Boolean expressionsBoolean expressions in the variables x in the variables x11, x, x22, , …, x…, xnn are defined recursively as follows: are defined recursively as follows:

• 0, 1, x0, 1, x11, x, x22, …, x, …, xnn are Boolean expressions. are Boolean expressions.

• If EIf E11 and E and E22 are Boolean expressions, then (-E are Boolean expressions, then (-E11), ),

(E (E11EE22), and (E), and (E11 + E + E22) are Boolean expressions.) are Boolean expressions.

Each Boolean expression represents a Boolean Each Boolean expression represents a Boolean function. The values of this function are obtained function. The values of this function are obtained by substituting 0 and 1 for the variables in the by substituting 0 and 1 for the variables in the expression.expression.

Page 58: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 58

Boolean Functions and ExpressionsBoolean Functions and Expressions

For example, we can create Boolean expression For example, we can create Boolean expression in the variables x, y, and z using the “building in the variables x, y, and z using the “building blocks”blocks”0, 1, x, y, and z, and the construction rules:0, 1, x, y, and z, and the construction rules:

Since x and y are Boolean expressions, so is xy.Since x and y are Boolean expressions, so is xy.

Since z is a Boolean expression, so is (-z).Since z is a Boolean expression, so is (-z).

Since xy and (-z) are expressions, so is xy + (-Since xy and (-z) are expressions, so is xy + (-z).z).

… … and so on…and so on…

Page 59: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 59

Boolean Functions and ExpressionsBoolean Functions and Expressions

Example:Example: Give a Boolean expression for the Give a Boolean expression for the Boolean function F(x, y) as defined by the Boolean function F(x, y) as defined by the following table:following table:

111100

000011

001111

000000F(x, y)F(x, y)yyxx

Possible solution:Possible solution: F(x, y) = (-x) F(x, y) = (-x)yy

Page 60: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 60

Boolean Functions and ExpressionsBoolean Functions and ExpressionsAnother Example:Another Example:

Possible solution I:Possible solution I:

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

00001111

F(x, y, z)F(x, y, z)

11001100zz

0000

1100

1100

0000yyxx

00000011

11001100

1111

1111

00110011

Possible solution II:Possible solution II:

F(x, y, z) = (-(xz))(-y)F(x, y, z) = (-(xz))(-y)

Page 61: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 61

Boolean Functions and ExpressionsBoolean Functions and Expressions

There is a simple method for deriving a Boolean There is a simple method for deriving a Boolean expression for a function that is defined by a expression for a function that is defined by a table. This method is based on table. This method is based on mintermsminterms..

Definition:Definition: A A literal literal is a Boolean variable or is a Boolean variable or its complement. A its complement. A mintermminterm of the Boolean of the Boolean variables xvariables x11, x, x22, …, x, …, xnn is a Boolean product is a Boolean product yy11yy22…y…ynn, where y, where yii = x = xii or y or yii = -x = -xii..

Hence, a minterm is a product of n literals, with Hence, a minterm is a product of n literals, with one literal for each variable.one literal for each variable.

Page 62: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 62

Boolean Functions and ExpressionsBoolean Functions and ExpressionsConsider F(x,y,z) again:Consider F(x,y,z) again: F(x, y, z) = 1 if and F(x, y, z) = 1 if and

only if:only if:

x = y = z = 0 orx = y = z = 0 or

x = y = 0, z = 1 orx = y = 0, z = 1 or

x = 1, y = z = 0x = 1, y = z = 0

Therefore,Therefore,

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

00001111

F(x, y, z)F(x, y, z)

11001100zz

0000

1100

1100

0000yyxx

00000011

11001100

1111

1111

00110011

Page 63: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 63

Boolean Functions and ExpressionsBoolean Functions and Expressions

Definition:Definition: The Boolean functions F and G of n The Boolean functions F and G of n variables are variables are equalequal if and only if F(b if and only if F(b11, b, b22, …, b, …, bnn) ) = G(b= G(b11, b, b22, …, b, …, bnn) whenever b) whenever b11, b, b22, …, b, …, bnn belong belong to B.to B.

Two different Boolean expressions that Two different Boolean expressions that represent the same function are called represent the same function are called equivalentequivalent..

For example, the Boolean expressions xy, xy + For example, the Boolean expressions xy, xy + 0, and xy0, and xy1 are equivalent.1 are equivalent.

Page 64: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 64

Boolean Functions and ExpressionsBoolean Functions and Expressions

The The complement complement of the Boolean function F is the of the Boolean function F is the function –F, where –F(bfunction –F, where –F(b11, b, b22, …, b, …, bnn) = ) = -(F(b-(F(b11, b, b22, …, b, …, bnn)).)).

Let F and G be Boolean functions of degree n. The Let F and G be Boolean functions of degree n. The Boolean sum F+GBoolean sum F+G and and Boolean product FGBoolean product FG are then defined byare then defined by

(F + G)(b(F + G)(b11, b, b22, …, b, …, bnn) = F(b) = F(b11, b, b22, …, b, …, bnn) + G(b) + G(b11, b, b22, , …, b…, bnn))

(FG)(b(FG)(b11, b, b22, …, b, …, bnn) = F(b) = F(b11, b, b22, …, b, …, bnn) G(b) G(b11, b, b22, …, b, …, bnn))

Page 65: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 65

Boolean Functions and ExpressionsBoolean Functions and Expressions

Question:Question: How many different Boolean functions of How many different Boolean functions of degree 1 are there?degree 1 are there?

Solution:Solution: There are four of them, F There are four of them, F11, F, F22, F, F33, and F, and F44::

00

11

FF33

11

00

FF22

110011

110000

FF44FF11xx

Page 66: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 66

Boolean Functions and ExpressionsBoolean Functions and Expressions

Question:Question: How many different Boolean How many different Boolean functions of degree 2 are there?functions of degree 2 are there?

Solution:Solution: There are 16 of them, F There are 16 of them, F11, F, F22, …, F, …, F1616::

11000000FF22

00000000FF11

001100

110011

001111

000000FF33yyxx

11111100FF88

00111100FF77

00

00

00

11FF99

00001100FF55

11110000FF44

11

00

11

00FF66

00110011FF1111

11000011FF1010

00

11

11

11FF1212

11001111

FF1414

00001111

FF1313

11

11

00

11

FF1515

11111111FF1616

Page 67: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 67

Boolean Functions and ExpressionsBoolean Functions and Expressions

Question:Question: How many different Boolean How many different Boolean functions of degree n are there?functions of degree n are there?

Solution:Solution:

There are 2There are 2nn different n-tuples of 0s and 1s. different n-tuples of 0s and 1s.

A Boolean function is an assignment of 0 or 1 A Boolean function is an assignment of 0 or 1 to each of these 2to each of these 2nn different n-tuples. different n-tuples.

Therefore, there are Therefore, there are 2222nn different Boolean different Boolean

functions.functions.

Page 68: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 68

DualityDuality

There are useful identities of Boolean There are useful identities of Boolean expressions that can help us to transform an expressions that can help us to transform an expression A into an equivalent expression B expression A into an equivalent expression B (see Table 5 on page 705 in the textbook).(see Table 5 on page 705 in the textbook).

We can derive additional identities with the We can derive additional identities with the help of the help of the dualdual of a Boolean expression. of a Boolean expression.

The dual of a Boolean expression is obtained The dual of a Boolean expression is obtained by interchanging Boolean sums and Boolean by interchanging Boolean sums and Boolean products and interchanging 0s and 1s.products and interchanging 0s and 1s.

Page 69: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 69

DualityDualityExamples:Examples:

The dual of The dual of x(y + z)x(y + z) is is x + yz.x + yz.

The dual of The dual of -x-x1 + (-y + z) 1 + (-y + z) isis (-x + 0)((-y)z).(-x + 0)((-y)z).

The The dual of a Boolean function Fdual of a Boolean function F represented represented by a Boolean expression is the function by a Boolean expression is the function represented by the dual of this expression.represented by the dual of this expression.

This dual function, denoted by FThis dual function, denoted by Fdd, , does not does not dependdepend on the particular Boolean expression on the particular Boolean expression used to represent F.used to represent F.

Page 70: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 70

DualityDuality

Therefore, an identity between functions Therefore, an identity between functions represented by Boolean expressions represented by Boolean expressions remains remains validvalid when the duals of both sides of the when the duals of both sides of the identity are taken.identity are taken.

We can use this fact, called the We can use this fact, called the duality duality principleprinciple, to derive new identities., to derive new identities.

For example, consider the absorption law For example, consider the absorption law x(x + y) = xx(x + y) = x..

By taking the duals of both sides of this By taking the duals of both sides of this identity, we obtain the equation identity, we obtain the equation x + xy = xx + xy = x, , which is also an identity (and also called an which is also an identity (and also called an absorption law).absorption law).

Page 71: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 71

Definition of a Boolean AlgebraDefinition of a Boolean Algebra

All the properties of Boolean functions and All the properties of Boolean functions and expressions that we have discovered also expressions that we have discovered also apply to apply to other mathematical structuresother mathematical structures such as propositions and sets and the such as propositions and sets and the operations defined on them.operations defined on them.

If we can show that a particular structure is a If we can show that a particular structure is a Boolean algebra, then we know that all results Boolean algebra, then we know that all results established about Boolean algebras apply to established about Boolean algebras apply to this structure.this structure.

For this purpose, we need an For this purpose, we need an abstract abstract definitiondefinition of a Boolean algebra. of a Boolean algebra.

Page 72: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 72

Definition of a Boolean AlgebraDefinition of a Boolean AlgebraDefinition:Definition: A Boolean algebra is a set B with two A Boolean algebra is a set B with two binary operations binary operations and and , elements 0 and 1, and , elements 0 and 1, and a unary operation – such that the following a unary operation – such that the following properties hold for all x, y, and z in B:properties hold for all x, y, and z in B:

x x 0 = x and x 0 = x and x 1 = x 1 = x (identity laws)(identity laws)

x x (-x) = 1 and x (-x) = 1 and x (-x) = 0 (-x) = 0 (domination laws)(domination laws)

(x (x y) y) z = x z = x (y (y z) and z) and (x (x y) y) z = x z = x (y (y z) and z) and (associative laws)(associative laws)

x x y = y y = y x and x x and x y = y y = y x x (commutative (commutative laws)laws)

x x (y (y z) = (x z) = (x y) y) (x (x z) and z) andx x (y (y z) = (x z) = (x y) y) (x (x z) z) (distributive laws)(distributive laws)

Page 73: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 73

Logic GatesLogic GatesElectronic circuits consist of so-called gates.Electronic circuits consist of so-called gates.There are three basic types of gates:There are three basic types of gates:

xx

yy

x+x+yy OR gateOR gate

AND gateAND gatexx

yy

xyxy

xx -x-xinverterinverter

Page 74: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 74

Logic GatesLogic GatesExample:Example: How can we build a circuit that How can we build a circuit that computes the function xy + (-x)y ?computes the function xy + (-x)y ?

xy + (-xy + (-x)yx)y

xx

yy

xyxy

xx -x-x

yy

(-x)y(-x)y

Page 75: Spring 2003CMSC 203 - Discrete Structures1 … and now for something completely different… Set Theory Actually, you will see that logic and set theory are.

Spring 2003 CMSC 203 - Discrete Structures 75

Logic, Sets, and Boolean AlgebraLogic, Sets, and Boolean AlgebraLogicLogic SetSet Boolean Boolean AlgebraAlgebra

FalseFalse 00

TrueTrue UU 11

AAB B AABB AABB

AABB AABB A+BA+B

AA AACC

Compare the equivalence laws of themCompare the equivalence laws of them

A


Recommended