TXT

# Discrete Math2-Set Theory

By Jacob Olson,2014-05-27 16:04
9 views 0
Discrete Math2-Set Theory

??ÎÄÓÉyinger090807??Ï×

pptÎÄµµ?ÉÄÜÔÚWAP?Ëä?ÀÀÌåÑé???Ñ????ÒéÄúÓÅÏÈÑ?ÔñTXT???òÏÂÔØÔ?ÎÄ?þµ????ú?é????

Set Theory

Agenda

Concepts Representations Properties of sets Operations Actually, you will see that logic and set theory are very closely related.

Copyright 2007 @ by Xu Dezhi 2

Sets

Set = a collection of distinct unordered objects Members of a set are called elements How to determine a set Listing: Example: A = {1,3,5,7} = {7, 5, 3, 1, 3} Description Example: B = {x | x=2k+1, 0 < k < 30}

Copyright 2007 @ by Xu Dezhi 3

Set Theory

x?ÊA x?A ??x is an element of A?? ??x is a member of A?? ??x is not an element of A?? ??A contains????

A = {x1, x2, ??, xn}

Order of elements is meaningless. It does not matter how often the same element is listed.

Copyright 2007 @ by Xu Dezhi

4

Set Equality

Sets A and B are equal if and only if they contain exactly the same elements. Examples: A = {9, 2, 7, -3}, B = {7, 9, -3, 2} : A = B A = {dog, cat, horse}, B = {cat, horse, squirrel, dog} : A ?Ù B A = {dog, cat, horse}, B = {cat, horse, dog, dog} : A = B

Copyright 2007 @ by Xu Dezhi 5

Examples for Sets

??Standard?? Sets:

Natural numbers: N = {0, 1, 2, 3, ??} Integers: Z = {??, -2, -1, 0, 1, 2, ??} Positive Integers: Z+ = {1, 2, 3, 4, ??} Real Numbers: R = {47.3, -12, ?Ð, ??} Rational Numbers: Q = {1.5, 2.6, -3.8, 15, ??} (correct definition will follow)

Copyright 2007 @ by Xu Dezhi 6

Examples for Sets

A=? A = {z} A = {{x, y}} Note: {x, y} ?ÊA, but {x, y} ?Ù {{x, y}} A = {x | P(x)} ??set of all x such that P(x)?? A = {x | x?ÊN ?Ä x > 7} = {8, 9, 10, ??} ??set builder notation??

Copyright 2007 @ by Xu Dezhi 7

??empty set/null set?? Note: z?ÊA, but z ?Ù {z}

A = {{b, c}, {c, x, d}}

Examples for Sets

We are now able to define the set of rational numbers Q: Q = {a/b

| a?ÊZ ?Ä b?ÊZ+} or Q = {a/b | a?ÊZ ?Ä b?ÊZ ?Ä b?Ù0} And how about the set of real numbers R? R = {r | r is a real number} That is the best we can do.

Copyright 2007 @ by Xu Dezhi

8

Finite and infinite sets

Finite sets Examples: A = {1, 2, 3, 4} B = {x | x is an integer, 1 < x < 4} Infinite sets Examples: Z = {integers} = {??, -3, -2, -1, 0, 1, 2, 3,??} S={x| x is a real number and 1 < x < 4} = [0, 4]

Copyright 2007 @ by Xu Dezhi 9

Some important sets

The empty set ? = { } has no elements. Also called null set or void set. Universal set: the set of all elements about which we make assertions. Examples: U = {all natural numbers} U = {all real numbers} U = {x| x is a natural number and 1< x<10}

Copyright 2007 @ by Xu Dezhi 10

When talking about a set, a universal set (universe of reference or universal discourse) needs to be specified. Even though a set is defined by the elements which it contains, those elements cannot be arbitrary. If arbitrary elements are allowed, paradoxes can result arising from self reference.

11

We have several ways to express Russell paradox. Here, two of them are given. We also give a vivid example of Russell paradox. Way 1: If we allow arbitrary elements, we should also allow sets to be elements, and sets of sets, and so on. So it would be perfectly reasonable to consider the following set: S = the set containing all sets which do not contain themselves Claim: The set S cannot exist.

12

Way 2: Two types of set Inclusive set //containing itself as its element Exclusive set // otherwise Let S be a set containing all exclusive sets, i.e. S={x|x?ÙS} Which type does S belong to??? Vivid E.g.: the barber??s worry.

Copyright 2007 @ by Xu Dezhi

13

Proof: If it existed, it would either contain itself, or not. Let??s consider both cases:

1.

2.

S contains itself as an element. Therefore, since the elements of

S do not contain themselves as elements, it does not contain S. This contradicts the assumption, so that the first case cannot happen. S doesn??t contain itself. Therefore, since S contains all sets not containing themselves, it must contain S. This contradicts the assumption, so that the second case cannot happen.

Copyright 2007 @ by Xu Dezhi 14

As neither case can happen, S cannot exist.

It is of paramount importance that when a set is specified by stating certain conditions, that it ought to exist as a set. The set could be empty, but that??s fine, as long as it actually exists. EG: The set of all pigs which can fly. The condition is not achievable so that this set is the empty set ?. It is still a set, however. To guarantee set existentiality, a universal set U should always be fixed.

15

Q: Is there a universe of reference in which the set of all sets not containing themselves is well-defined? A: Yes. In fact any universe. For example U ={ {1,2} , {1,2,{1,2}} , {1,2,{1,2},{3}} } Q: What is the set S of all sets not containing themselves in this case? A: S = U

16

If arbitrary elements are allowed, another famous paradox can happen. Cantor Theorem |P(M)|>|M| Universal set U |P(U)|>|U|, according to the Theorem on cardinality of power set |P(U)|<|U|, too, because U is a universal set ???

Copyright 2007 @ by Xu Dezhi 17

Cardinality

Cardinality of a set A (in symbols |A|) is the number of elements in A Examples: If A = {1, 2, 3} then |A| = 3 If B = {x | x is a natural number and 1< x< 9}, then |B| = 9 Infinite cardinality Countable (e.g., natural numbers, integers) Uncountable (e.g., real numbers)

Copyright 2007 @ by Xu Dezhi 18

Cardinality of Sets

If a set S contains n distinct elements, n?ÊN, we call S a finite set with cardinality n. Examples: A = {Mercedes, BMW, Porsche}, |A| = 3 B = {1, {2, 3}, {4, 5}, 6} C=? D ={ x?ÊN | x ?Ü 7000 } E = { x?ÊN | x ?Ý 7000 }

Copyright 2007 @ by Xu Dezhi

|B| = 4 |C| = 0 |D| = 7001 E is infinite!

19

Subsets

A is a subset of B if every element of A is also contained in B (in

symbols A ? B) Equality: A = B if A ? B and B ? A, i.e., A = B whenever x ?Ê A, then x ?Ê B, and whenever x ?Ê B, then x ?Ê A A is a proper subset of B if A ? B but B ? A Observation: ? is a subset of every set Note: Every set representation can be transformed into an equivalent logical expression and vice versa.

Copyright 2007 @ by Xu Dezhi 20

Subsets

A?B ??A is a subset of B?? A?B iff every element of A is also an element of B. We can completely formalize this: A ? B ? ?x (x?ÊA ?ú x?ÊB) Examples: A = {3, 9}, B = {5, 9, 1, 3}, A ? B ? True A = {3, 3, 3, 9}, B = {5, 9, 1, 3}, A ? B ? True A = {1, 2, 3}, B = {2, 3, 4}, A ? B ? false

Copyright 2007 @ by Xu Dezhi 21

Venn diagrams

A Venn diagram provides a graphic view of sets Venn diagrams are useful in representing sets and set operations which can be easily and visually identified. Various sets are represented by circles inside a big rectangle representing the universal set.

A

U

Copyright 2007 @ by Xu Dezhi

22

Subsets

Useful rules: A = B ? (A ? B) ?Ä (B ? A) (A ? B) ?Ä (B ? C) ? A ? C (next Venn Diagram)

U B A C

Copyright 2007 @ by Xu Dezhi

23

Subsets

Useful rules: ? ? A for any set A A ? A for any set A Proper subsets: A?B ??A is a proper subset of B?? A ? B ? ?x (x?ÊA ?ú x?ÊB) ?Ä ?x (x?ÊB ?Ä x?A) or A ? B ? ?x (x?ÊA ?ú x?ÊB) ?Ä ??x (x?ÊB ?ú x?ÊA)

Copyright 2007 @ by Xu Dezhi 24

Power set

The power set of A is the set of all subsets of A, in symbols P(A), i.e. P(A)= {X | X ? A} Example: if A = {1, 2, 3}, then P(A) = {?, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}} Theorem: If |A| = n, then |P(A)| = 2n. Read proof in textbook

Copyright 2007 @ by Xu Dezhi 25

The Power Set

2A or P(A) 2A = {X | X ? A} Examples: A = {x, y, z} 2A = {?, {x}, {y}, {z}, {x,y}, {x,z}, {y,z}, {x,y,z}} ? A=? 2A = {?} Note: |A| = 0, |2A| = 1

Copyright 2007 @ by Xu Dezhi 26

??power set of A?? (contains all subsets of A)

The Power Set

Cardinality of power sets: | 2A | = 2|A| Imagine each element in A has an ??on/off?? switch Each possible switch configuration in A corresponds to one element in 2A

A x y z 1 x y z 2 x y z 3 x y z 4 x y z 5 x y z 6 x y z 7 x y z 8 x y z

For 3 elements in A, there are 2?Á2?Á2 = 8 ?Á ?Á elements in 2A

Copyright 2007 @ by Xu Dezhi 27

Set Operations

Union: Elements in at least one of the two sets. A?ÈB = {x | x?ÊA ?Å x?ÊB} Example: A = {a, b}, B = {b, c, d} A?ÈB = {a, b, c, d} A?ÈB ?È U

A

B

Copyright 2007 @ by Xu Dezhi

28

Set Operations

Intersection: Elements in exactly one of the two sets. A?ÉB = {x | x?ÊA ?Ä x?ÊB} Example: A = {a, b}, B = {b, c, d} A?ÉB = {b} U

?É A A?ÉB B

Copyright 2007 @ by Xu Dezhi

29

Set Operations

Difference: Elements in first set but not second. Difference is also called the relative complement of B in A. A-B = {x | x?ÊA ?Ä x?B} Example A = {a, b}, B = {b, c, d} A-B = {a} A-B A U B

30

Copyright 2007 @ by Xu Dezhi

Set Operations

Symmetric Difference: Elements in exactly one of the two sets. A?’B = { x | x?ÊA ?’ x?ÊB } = (A?CB) ?È (A?CB) Example: A = {a, b}, B = {b, c, d} A?’B = {a,c,d} A?’B U A B

31

Copyright 2007 @ by Xu Dezhi

Set Operations

Complement: Elements not in the set (unary operator). Ac = { x | x ? A } Example: U = N, A = {250, 251, 252, ??} Ac = {0, 1, 2, ??, 248, 249} U Ac A

Copyright 2007 @ by Xu Dezhi

32

Disjoint Sets

Disjoint: If A and B have no common elements, they are said to be disjoint. A ?ÉB = ?

U A B

Copyright 2007 @ by Xu Dezhi

33

Examples for set operations

If A={1, 4, 7, 10}, B={1, 2, 3, 4, 5} A ?È B =? A ?É B =? A ?C B =? B ?C A =? A ?’ B =?

Copyright 2007 @ by Xu Dezhi 34

Example for set operations

If A={1, 4, 7, 10}, B={1, 2, 3, 4, 5} A ?È B = {1, 2, 3, 4, 5, 7, 10} A ?É B = {1, 4} A ?C B = {7, 10} B ?C A = {2, 3, 5} A ?’ B = (A?ÈB) ?C (A?ÉB) = {2, 3, 5, 7, 10}

Copyright 2007 @ by Xu Dezhi 35

Properties of set operations (1)

Theorem: Let U be a universal set, and A, B and C subsets of U. The following properties hold: a) Associativity: (A ?È B) ?È C = A ?È (B ?È C) (A ?É B) ?É C = A ?É (B ?ÉC) b) Commutativity: A?ÈB=B?ÈA A?ÉB=B?ÉA

Copyright 2007 @ by Xu Dezhi 36

Properties of set operations (2)

c) Distributive laws: A?È(B?ÉC) = (A?ÈB)?É(A?ÈC) A?É(B?ÈC) = (A?ÉB)?È(A?ÉC) d) Identity laws: A?ÉU=A e) Complement laws: A?ÈAc = U A?ÉAc = ?

Copyright 2007 @ by Xu Dezhi 37

A?È? = A

Properties of set operations (3)

f) Idempotent laws: A?ÈA = A g) Bound laws: A?ÈU = U h) Absorption laws: A?È(A?ÉB) = A A?É(A?ÈB) = A

38

A?ÉA = A

A?É? = ?

Copyright 2007 @ by Xu Dezhi

Properties of set operations (4)

i) Double complementation /Involution law: (Ac)c = A j0/1 laws: ?c = U Uc = ?

k) De Morgan??s laws: (A?ÈB)c = Ac?ÉBc (A?ÉB)c = Ac?ÈBc

Copyright 2007 @ by Xu Dezhi 39

Proof for set properties

In fact, the logical identities create the set identities by applying the definitions of the various set operations. For example: (A?ÈB )?ÈC = A?È(B ?ÈC ) Proof : (A?ÈB )?ÈC = {x | x ?Ê A ?ÈB ?Å x ?Ê C } = {x | (x ?Ê A ?Å x ?Ê B ) ?Å x ?Ê C } = {x | x ?Ê A ?Å ( x ?Ê B ?Å x ?Ê C ) } = {x | x ?Ê A ?Å (x ?Ê B ?È C ) } = A?È(B ?ÈC ) Other identities are derived similarly.

Copyright 2007 @ by Xu Dezhi 40

(by def.) (by def.) (logic law) (by def.) (by def.)

Proof for set properties

It??s often simpler to understand an identity by drawing a Venn

Diagram. For example: DeMorgan??s DeMorgan s first law

A?ÈB = A?ÉB

can be visualized as follows:

Copyright 2007 @ by Xu Dezhi 41

Visual DeMorgan

A: B:

42

Visual DeMorgan

A: B:

A?ÈB :

43

Visual DeMorgan

A: B:

A?ÈB :

A?ÈB:

44

Visual DeMorgan

A: B:

45

Visual DeMorgan

A: B:

A:

B:

46

Visual DeMorgan

A: B:

A:

B:

A?ÉB :

47

Visual DeMorgan

A?ÈB =

A?ÉB =

48

Using properties of set operations

Table in textbook shows many useful equations. How can we prove

A?È(B?ÉC) = (A?ÈB)?É(A?ÈC)? Method I: x?ÊA?È(B?ÉC)

? ?

x?ÊA ?Å x?Ê(B?ÉC) x?ÊA ?Å (x?ÊB ?Ä x?ÊC) (x?ÊA ?Å x?ÊB) ?Ä (x?ÊA

?Å x?ÊC) x?Ê(A?ÈB) ?Ä x?Ê(A?ÈC) x?Ê(A?ÈB)?É(A?ÈC)

Copyright 2007 @ by Xu Dezhi 49

(distributive law for logical expressions)

?

Using properties of set operations

Method II: Membership table 1 means ??x is an element of this set?? 0 means ??x is not an element of this set??

A 0 0 0 0 1 1 1 1 B 0 0 1 1 0 0 1 1 C B?ÉC ?É 0 1 0 1 0 1 0 1 0 0 0 1 0 0 0 1 A?È(B?ÉC) ?È ?É 0 0 0 1 1 1 1 1 A?ÈB ?È 0 0 1 1 1 1 1 1 A?ÈC ?È 0 1 0 1 1 1 1 1 (A?ÈB) ?É(A?ÈC) ?È ?È 0 0 0 1 1 1 1 1

50

Copyright 2007 @ by Xu Dezhi

ordered n-tuple

The ordered n-tuple (a1, a2, a3, ??, an) is an ordered collection of objects. Two ordered n-tuples (a1, a2, a3, ??, an) and (b1, b2, b3, ??, bn) are equal if and only if they contain exactly the same elements in the same order i.e. ai = bi for 1 ?Ü i ?Ü n

Copyright 2007 @ by Xu Dezhi

51

Cartesian Product

The Cartesian product of two sets A and B is defined as: A?ÁB = {(a, b) | a?ÊA ?Ä b?ÊB} Example: A = {x, y}, B = {a, b, c} A?ÁB = {(x, a), (x, b), (x, c), (y, a), (y, b), (y, c)}

Copyright 2007 @ by Xu Dezhi 52

Cartesian Product

Note that: A?Á? = ? ??ÁA = ? For non-empty sets A and B: A?ÙB ? A?ÁB?ÙB?ÁA |A?ÁB| = |A|?|B| The Cartesian product of two or more sets is defined as: A1?ÁA2?Á???ÁAn = {(a1, a2, ??, an) | ai?ÊAi for 1 ?Ü i ?Ü n}

Copyright 2007 @ by Xu Dezhi 53

Sequences and strings

A sequence is an ordered list of numbers, usually defined according to a formula function. If s is a sequence {sn|n = 1, 2, 3,??}, s1 denotes the first element, s2 the second element, sn the nth element???? {n} is called the indexing set of the sequence. Usually the indexing set is N (natural numbers) or an infinite subset of N.

Copyright 2007 @ by Xu Dezhi 54

Examples of sequences

Examples: 1. Let s = {sn} be the sequence defined by sn = 1/n , for n = 1, 2, 3,?? The first few elements of the sequence are: 1, 1/2, 1/3, 1/4, 1/5, 1/6,?? 2. Let s = {sn} be the sequence defined by sn = n2 + 1, for n = 1, 2, 3,?? The first few elements of s are: 2, 5, 10, 17, 26, 37, 50,??

Copyright 2007 @ by Xu Dezhi 55

Increasing and decreasing

For every n = 1, 2, 3,?? a sequence s = {sn} is said to be increasing if sn < sn+1 decreasing if sn > sn+1 Examples: Sn = 4 ?C 2n, n = 1,

2, 3,?? is decreasing: 2, 0, -2, -4, -6,?? Sn = 2n -1, n = 1, 2, 3,?? is increasing: 1, 3, 5, 7, 9, ??

Copyright 2007 @ by Xu Dezhi 56

Subsequences

A subsequence of a sequence s = {sn} is a sequence t = {tn} that consists of certain elements of s retained in the original order they had in s Example: let s = {sn = n | n = 1, 2, 3,??} 1, 2, 3, 4, 5, 6, 7, 8,?? Let t = {tn = 2n | n = 1, 2, 3,??} 2, 4, 6, 8, 10, 12, 14, 16,?? t is a subsequence of s

Copyright 2007 @ by Xu Dezhi 57

Sigma notation

If {an} is a sequence, then the sum

?Æa

k=1

m

k

= a1 + a2 + ???? + am

is called the ??sigma notation??, where the Greek letter ?? indicates a sum of terms from the sequence.

Copyright 2007 @ by Xu Dezhi 58

Pi notation

If {an} is a sequence, then the product

k =1

?? ak = a1 a2 ???? am

m

Greek letter ?? indicates a product of terms of the sequence.

is called the ??pi notation??, where the

Copyright 2007 @ by Xu Dezhi

59

Strings

Let A be a nonempty set. A string over A is a finite sequence of elements from A. Example: if A = {a, b, c} Then ?Á = bbaccc is a string over A Notation: bbaccc = b2ac3 The length of a string ?Á is the number of elements of ?Á and is denoted by |?Á|. If ?Á=b2ac3 then |?Á| = 6. The null string is the string with no elements and is denoted by the Greek letter ?Ë (lambda). It has length zero.

Copyright 2007 @ by Xu Dezhi 60

String operations

Let X* = {all strings over X including ?Ë} Let X+ = X* - {?Ë}, the set of all non-null strings Concatenation of two strings ?Á and ?Â is the operation on strings consisting of writing ?Á followed by ?Â to produce a new string ?Á?Â Example: ?Á = bbaccc, ?Â = caaba ?Á?Â = bbaccccaaba = b2ac4a2ba |?Á?Â| = | ?Á| + |?Â|

Copyright 2007 @ by Xu Dezhi 61

Number systems

Binary, hexadecimal and octal number systems. Binary digits: 0 and 1, called bits. Review of decimal system: Example: 45,238 is equal to 8 3 2 5 4 ones tens hundreds thousands ten thousands

Copyright 2007 @ by Xu Dezhi

8 x 1 =8 3 x 10 =30 2 x 100 =200 5 x 1000 =5000 4 x 10000 =40000

62

Binary number system

From binary to decimal: The number 1101011 is equivalent to 1 1 0 1 0 1 1 one two four eight sixteen thirty-two sixty-four 1 x20 = 1 1x21 = 2 0x22 = 0 1x23 = 8 0x24 = 0 1x25 =32 1x26 = 64

107 in decimal base

Copyright 2007 @ by Xu Dezhi 63

From decimal to binary

The number 7310 is equivalent to 73 = 2 x 36 + remainder 1 36 = 2 x 18 + remainder 0 18 = 2 x 9 + remainder 0 9 = 2 x 4 + remainder 1 4 = 2 x 2 + remainder 0 2 = 2 x 1 + remainder 0 7310 = 10010012 Write the remainders in reverse order preceded by the quotient

Copyright 2007 @ by Xu Dezhi 64

Binary addition table ?’ 0 1 0 1 0 1 1 10

1001012 1100112 10110002

Copyright 2007 @ by Xu Dezhi 65

Decimal system

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

0

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F