21

Sets

Embed Size (px)

Citation preview

Page 1: Sets
Page 2: Sets

Sets

o A set is an unordered collection of objects.o The objects in a set are called the elements or members of

the set S, and we say S contains its elements.o Sets can be defined by listing their elementse.g. S = {2, 3, 5, 7, 11, 13, 17, 19}, S = {CS1202, CS542, ERG2020, MAT141}

Page 3: Sets

Sets

o Examples of discrete structures built with the help of sets:o Countingo Combinationso Relationso Graphs

Page 4: Sets

Representing Sets by Properties

o It is inconvenient, and sometimes impossible, to define a set by listing all its elements.

o Alternatively, we can define by a set by describing the properties that its elements should satisfy.

{x| x has property P}./ {xA| P(x)}set of elements, x, in A such that x satisfies property P.{x and -2<x<5}E = {x| 50 <= x < 63, x is an even integer}

Page 5: Sets

Alternative Way of Defining Sets

We can implicitly define a set using a predicate to characterize its elements.

A= {x S | P(x)},∈the set of all such thatwhich is read “the set of all x in S such that P of x.”

Define a set using predicate .For example, the set E of even numbers is

the multiples of 3 between 20 and 30

Page 6: Sets

Sets

o Natural numbers:– = {0,1,2,3, …}

o Integers– = {…, -2,-1,0,1,2, …}

o Positive integers– Z+ = {1,2, 3.…}

o Rational numbers – = {p/q | p Z, q Z, q 0}

Page 7: Sets

Set

o Size of a Seto The size of a set S, denoted by |S|, is defined as the number of

elements contained in S.• If S = {2, 3, 5, 7, 11, 13, 17, 19}, then |S|=8.

o NULL SET:o A set which contains no element is called a null set, or an empty set

or a void set. It is denoted by the Greek letter (phi) or { }.A = {x | x is a person taller than 10 feet} = ( Because there does not exist any human being which is taller then 10 feet )B = {x | x2 = 4, x is odd} = (Because we know that there does not exist any odd whose square is 4)

Page 8: Sets

Set

o A Subset– A set A is said to be a subset of B if and only if every element of

A is also an element of B. We use A B to indicate A is a subset ⊆of B.• ∀x, if x A then x B∈ ∈

1. When A B, then B is called a superset of A.2. When A is not subset of B, then there exist at least one x A

such that x B.3. Every set is a subset of itself

is regarded as a subset of every set.

Page 9: Sets

Seto Every Set has necessarily two subsets and the Set itself, these

two subset are known as Improper Subsets and any other subset is called Proper Subset.

o Given two sets A and B, we say A is a proper subset of B, denoted by , if every element of A is an element of B, But there is an element in B that is not contained in A.

Page 10: Sets

Set Equalityo Given sets A and B, A equals B, written A = B, if, and only

if, every element of A is in B and every element of B is in A.

Symbolically:A = B A B and B A.⇔ ⊆ ⊆

Page 11: Sets

Set Equality

o Two sets are called disjoint if their intersection is empty.o Alternate: A and B are disjoint if and only if

A B =

Page 12: Sets

Defining Sets

S=T

S T

S is a proper subset of T.

Page 13: Sets

Set

o UNIVERSAL SET:The set of all elements under consideration is called the Universal Set. The Universal Set is usually denoted by U.

o Finite SetIf it contains exactly m distinct elements where m denotes some non negative integer.

In such case we write |S| = m or n(S) = m

o A set is said to be infinite if it is not finite.

Page 14: Sets

Set OperationsLet A and B be subsets of a universal set U.1. The union of A and B, denoted A B, is the set of all elements that are in at least one of A ∪

or B.2. The intersection of A and B, denoted A ∩ B, is the set of all elements that are common to

both A and B.3. The difference of B minus A (or relative complement of A in B), denoted B − A, is the set of

all elements that are in B and not in A.4. The complement of A, denoted Ac, is the set of all elements in U that are not in A.Symbolically:

A B = {x U | x A or x B},∪ ∈ ∈ ∈A ∩ B = {x U | x A and x B},∈ ∈ ∈

B − A = {x U | x B and xA},∈ ∈Ac = {x U | x A}.∈

Page 15: Sets

Power Set

The power set of a set A is the set of all subsets of A, and is denoted by 2A. That is,2A = {S : SA}.

For example, for A = {2, 4, 17, 23}, we have2A ={, {2}, {4}, {17}, {23}, {2, 4}, {2, 17}, {2, 23}, {4, 17}, {4, 23}, {17, 23},{2, 4, 17}, {2, 4, 23}, {2, 17, 23}, {4, 17, 23}, {2, 4, 17, 23}}

The cardinality of this set is 16,

Page 16: Sets

Set Identities

Page 17: Sets

Functions

• A function f from a set X to a set Y,– Denoted f : X → Y , is a relation from X, the domain, to Y , the co-

domain, – that satisfies two properties:– (1) every element in X is related to some element in Y , and– (2) no element in X is related to more than one element in Y .

Page 18: Sets

Functions

• This arrow diagram does define a function because

1. Every element of X has an arrow coming out of it.2. No element of X has two arrows coming out of it that point to two different elements of Y .

Page 19: Sets

One-to-One Functions

• Let F be a function from a set X to a set Y . F is one-to-one (or injective) if, and only if, for all elements x1 and x2 in X,

• if F(x1) = F(x2), then x1 = x2,

• /equivalently, if x1 = x2, then F(x1) = F(x2).• Symbolically,– F: X → Y is one-to-one ⇔∀x1, x2 ∈ X, if F(x1) = F(x2) then x1 = x2.

Page 20: Sets

On-to Functions

• Let F be a function from a set X to a set Y . • F is onto (or subjective) if, and only if, given any element y in

Y , it is possible to find an element x in X with the property – that y = F(x).

• Symbolically:– F: X → Y is onto ⇔∀y ∈ Y, ∃x ∈ X such that F(x) = y.

Page 21: Sets

• A function is onto – if each element of the co-

domain has an arrow pointing to it from some element of the domain.

• A function is not onto – if at least one element in

its co-domain does not have an arrow pointing to it.