SlideShare ist ein Scribd-Unternehmen logo
1 von 97
1
UNIT-3UNIT-3
Set TheorySet Theory
NotationNotation
• S={a, b, c} refers to the set
whose elements are a, b and c.
• a∈S means “a is an element of set S”.
• d∉S means “d is not an element of set S”.
• {x ∈S | P(x)} is the set of all those x from S such that
P(x) is true. E.g., T={x ∈Z | 0<x<10} .
• Notes:
1) {a,b,c}, {b,a,c}, {c,b,a,b,b,c} all represent
the same set.
2) Sets can themselves be elements of other
sets, e.g., S={ {Mary, John}, {Tim,
Ann}, …}
3
Relations between setsRelations between sets
• Definition: Suppose A and B are sets. Then
A is called a subset of B: A ⊆ B
iff every element of A is also an element of B.
Symbolically,
A ⊆B ⇔ ∀x, if x∈A then x ∈B.
• A ⊄ B ⇔ ∃x such that x∈A and x∉B.
BA A
B BA
A ⊆ B A ⊄ B A ⊄ B
4
Relations between setsRelations between sets
• Definition: Suppose A and B are sets. Then
A equals B: A = B
iff every element of A is in B and
every element of B is in A.
Symbolically,
A=B ⇔ A⊆B and B⊆A .
• Example: Let A = {m∈Z | m=2k+3 for some integer k};
B = the set of all odd integers.
Then A=B.
Operations on SetsOperations on Sets
Definition: Let A and B be subsets of a set U.
1. Union of A and B: A ∪ B = {x∈U | x∈A or x∈B}
2. Intersection of A and B:
A ∩ B = {x∈U | x∈A and x∈B}
3. Difference of B minus A: B−A = {x∈U | x∈B and x∉A}
4. Complement of A: Ac
= {x∈U | x∉A}
Ex.: Let U=R, A={x ∈R | 3<x<5}, B ={x ∈R| 4<x<9}.
Then
1) A ∪ B = {x ∈R | 3<x<9}.
2) A ∩ B = {x ∈R | 4<x<5}.
3) B−A = {x ∈R | 5 ≤x<9}, A−B = {x ∈R | 3<x ≤4}.
4) Ac
= {x∈R | x ≤3 or x≥5}, Bc
= {x∈R | x ≤4 or x≥9}
6
Properties of SetsProperties of Sets
Theorem 1 (Some subset relations):
1) A∩B ⊆ A
2) A ⊆ A∪B
3) If A ⊆ B and B ⊆ C, then A ⊆ C .
 To prove that A ⊆ B use the “element argument”:
1. suppose that x is a particular but arbitrarily
chosen element of A,
2. show that x is an element of B.
7
Proving a Set PropertyProving a Set Property
• Theorem 2 (Distributive Law):
For any sets A,B and C:
A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) .
• Proof: We need to show that
(I) A ∪ (B ∩ C) ⊆ (A ∪ B) ∩ (A ∪ C) and
(II) (A ∪ B) ∩ (A ∪ C) ⊆ A ∪ (B ∩ C) .
Let’s show (I).
Suppose x ∈ A ∪ (B ∩ C) (1)
We want to show that x ∈ (A ∪ B) ∩ (A ∪ C) (2)
8
Proving a Set PropertyProving a Set Property
• Proof (cont.):
x ∈ A ∪ (B ∩ C) ⇒ x ∈ A or x ∈ B ∩ C .
(a) Let x ∈ A. Then
x ∈ A∪B and x ∈ A∪C ⇒ x ∈ (A ∪ B) ∩ (A ∪ C)
(b) Let x ∈ B ∩ C. Then x∈B and x∈C.
Thus, (2) is true, and we have shown (I).
(II) is shown similarly (left as exercise). ■
)()( CABAx
CAxCx
BAxBx
∪∩∪∈⇒



∪∈⇒∈
∪∈⇒∈
9
Set PropertiesSet Properties
• Commutative Laws:
• Associative Laws:
• Distributive Laws:
ABBAb
ABBAa
∪=∪
∩=∩
)(
)(
)()()(
)()()(
CBACBAb
CBACBAa
∪∪=∪∪
∩∩=∩∩
)()()()(
)()()()(
CABACBAb
CABACBAa
∩∪∩=∪∩
∪∩∪=∩∪
10
Set PropertiesSet Properties
• Double Complement Law:
• De Morgan’s Laws:
• Absorption Laws:
AA cc
=)(
ccc
ccc
BABAb
BABAa
∩=∪
∪=∩
)()(
)()(
ABAAb
ABAAa
=∪∩
=∩∪
)()(
)()(
11
Showing that an alleged setShowing that an alleged set
property is falseproperty is false
• Statement: For all sets A,B and C,
A−(B−C) = (A−B)−C .
The following counterexample
shows that the statement is false.
• Counterexample:
Let A={1,2,3,4} , B={3,4,5,6} , C={3}.
Then B−C = {4,5,6} and A−(B−C) = {1,2,3} .
On the other hand,
A−B = {1,2} and (A−B)−C = {1,2} .
Thus, for this example
A−(B−C) ≠ (A−B)−C .
12
Empty SetEmpty Set
• The unique set with no elements
is called empty set and denoted by ∅.
• Set Properties that involve ∅ .
For all sets A,
1. ∅ ⊆ A
2. A ∪ ∅ = A
3. A ∩ ∅ = ∅
4. A ∩ Ac
= ∅
13
Disjoint SetsDisjoint Sets
 A and B are called disjoint iff A ∩ B = ∅ .
 Sets A1, A2, …, An are called mutually disjoint
iff for all i,j = 1,2,…, n
Ai ∩ Aj = ∅ whenever i ≠ j .
 Examples:
1) A={1,2} and B={3,4} are disjoint.
2) The sets of even and odd integers are disjoint.
3) A={1,4}, B={2,5}, C={3} are mutually disjoint.
4) A−B, B−A and A∩B are mutually disjoint.
14
PartitionsPartitions
• Definition: A collection of nonempty sets
{A1, A2, …, An} is a partition of a set A iff
1. A = A1 ∪ A2 ∪ … ∪ An
2. A1, A2, …, An are mutually disjoint.
• Examples:
1) {Z+
, Z-
, {0} } is a partition of Z.
2) Let S0={n ∈ Z | n=3k for some integer k}
S1={n ∈ Z | n=3k+1 for some integer k}
S2={n ∈ Z | n=3k+2 for some integer k}
Then {S0, S1, S2} is a partition of Z.
15
Power SetsPower Sets
• Definition: Given a set A,
the power set of A, denoted P (A) ,
is the set of all subsets of A.
• Example: P ({a,b}) = {∅, {a}, {b}, {a,b}} .
• Properties:
1) If A ⊆ B then P (A) ⊆ P (B) .
2) If a set A has n elements
then P (A) has 2n
elements.
16
•Relations
17
Relations
•If we want to describe a relationship between
elements of two sets A and B, we can use ordered
pairs with their first element taken from A and their
second element taken from B.
•Since this is a relation between two sets, it is called
a binary relation.
•Definition: Let A and B be sets. A binary relation
from A to B is a subset of A×B.
•In other words, for a binary relation R we have
R ⊆ A×B. We use the notation aRb to denote that (a,
b)∈R and aRb to denote that (a, b)∉R.
18
Relations
•When (a, b) belongs to R, a is said to be related to b
by R.
•Example: Let P be a set of people, C be a set of
cars, and D be the relation describing which person
drives which car(s).
•P = {Carl, Suzanne, Peter, Carla},
•C = {Mercedes, BMW, tricycle}
•D = {(Carl, Mercedes), (Suzanne, Mercedes),
(Suzanne, BMW), (Peter, tricycle)}
•This means that Carl drives a Mercedes, Suzanne
drives a Mercedes and a BMW, Peter drives a tricycle,
and Carla does not drive any of these vehicles.
19
Functions as Relations
•You might remember that a function f from a set A to
a set B assigns a unique element of B to each
element of A.
•The graph of f is the set of ordered pairs (a, b) such
that b = f(a).
•Since the graph of f is a subset of A×B, it is a
relation from A to B.
•Moreover, for each element a of A, there is exactly
one ordered pair in the graph that has a as its first
element.
20
Functions as Relations
•Conversely, if R is a relation from A to B such that
every element in A is the first element of exactly one
ordered pair of R, then a function can be defined with
R as its graph.
•This is done by assigning to an element a∈A the
unique element b∈B such that (a, b)∈R.
21
Relations on a Set
•Definition: A relation on the set A is a relation from A
to A.
•In other words, a relation on the set A is a subset of
A×A.
•Example: Let A = {1, 2, 3, 4}. Which ordered pairs
are in the relation R = {(a, b) | a < b} ?
22
Relations on a Set
•Solution: R = {(1, 2),(1, 2), (1, 3),(1, 3), (1, 4),(1, 4), (2, 3),(2, 3), (2, 4),(2, 4), (3, 4)}(3, 4)}
RR 11 22 33 44
11
22
33
44
11 11
22
33
44
22
33
44
XX XX XX
XX XX
XX
Fall 2002 23
Relations on a Set
•How many different relations can we define on a
set A with n elements?
•A relation on a set A is a subset of A×A.
•How many elements are in A×A ?
•There are n2
elements in A×A, so how many subsets
(= relations on A) does A×A have?
•The number of subsets that we can form out of a set
with m elements is 2m
. Therefore, 2n2
subsets can be
formed out of A×A.
•Answer: We can define 2n2
different relations
on A.
24
Properties of Relations
•We will now look at some useful ways to classify
relations.
•Definition: A relation R on a set A is called reflexive
if (a, a)∈R for every element a∈A.
•Are the following relations on {1, 2, 3, 4} reflexive?
R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)}R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)} No.No.
R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)}R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)} Yes.Yes.
R = {(1, 1), (2, 2), (3, 3)}R = {(1, 1), (2, 2), (3, 3)} No.No.
Definition:Definition: A relation on a set A is calledA relation on a set A is called irreflexiveirreflexive if (a, a)if (a, a)∉∉R for every elementR for every element
aa∈∈A.A.
25
Properties of Relations
•Definitions:
•A relation R on a set A is called symmetric if (b,
a)∈R whenever (a, b)∈R for all a, b∈A.
•A relation R on a set A is called antisymmetric if
a = b whenever (a, b)∈R and (b, a)∈R.
•A relation R on a set A is called asymmetric if
(a, b)∈R implies that (b, a)∉R for all a, b∈A.
26
Properties of Relations
•Are the following relations on {1, 2, 3, 4}
symmetric, antisymmetric, or asymmetric?
R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)}R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)} symmetricsymmetric
R = {(1, 1)}R = {(1, 1)} sym. andsym. and
antisym.antisym.
R = {(1, 3), (3, 2), (2, 1)}R = {(1, 3), (3, 2), (2, 1)} antisym. andantisym. and
asym.asym.
R = {(4, 4), (3, 3), (1, 4)}R = {(4, 4), (3, 3), (1, 4)} antisym.antisym.
27
Properties of Relations
•Definition: A relation R on a set A is called
transitive if whenever (a, b)∈R and (b, c)∈R, then (a,
c)∈R for a, b, c∈A.
•Are the following relations on {1, 2, 3, 4}
transitive?
R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)}R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)} Yes.Yes.
R = {(1, 3), (3, 2), (2, 1)}R = {(1, 3), (3, 2), (2, 1)} No.No.
R = {(2, 4), (4, 3), (2, 3), (4, 1)}R = {(2, 4), (4, 3), (2, 3), (4, 1)} No.No.
28
Counting Relations
•Example: How many different reflexive relations can
be defined on a set A containing n elements?
•Solution: Relations on R are subsets of A×A, which
contains n2
elements.
•Therefore, different relations on A can be generated
by choosing different subsets out of these n2
elements, so there are 2n2
relations.
•A reflexive relation, however, must contain the n
elements (a, a) for every a∈A.
•Consequently, we can only choose among n2
– n =
n(n – 1) elements to generate reflexive relations, so
there are 2n(n – 1)
of them.
29
Combining Relations
•Relations are sets, and therefore, we can apply the
usual set operations to them.
•If we have two relations R1 and R2, and both of them
are from a set A to a set B, then we can combine
them to R1 ∪ R2, R1 ∩ R2, or R1 – R2.
•In each case, the result will be another relation from
A to B.
Fall 2002 CMSC 203 - Discrete Structures 30
Combining Relations
•… and there is another important way to combine
relations.
•Definition: Let R be a relation from a set A to a set B
and S a relation from B to a set C. The composite of
R and S is the relation consisting of ordered pairs (a,
c), where a∈A, c∈C, and for which there exists an
element b∈B such that (a, b)∈R and
(b, c)∈S. We denote the composite of R and S by
S°R.
•In other words, if relation R contains a pair (a, b) and
relation S contains a pair (b, c), then S°R contains a
pair (a, c).
31
Combining Relations
•Example: Let D and S be relations on A = {1, 2, 3, 4}.
•D = {(a, b) | b = 5 - a} “b equals (5 – a)”
•S = {(a, b) | a < b} “a is smaller than b”
•D = {(1, 4), (2, 3), (3, 2), (4, 1)}
•S = {(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)}
•S°D = {(2, 4),(2, 4), (3, 3),(3, 3), (3, 4),(3, 4), (4, 2),(4, 2), (4, 3),(4, 3),
D maps an element a to the element (5 – a), and afterwards S maps (5 – a) to allD maps an element a to the element (5 – a), and afterwards S maps (5 – a) to all
elements larger than (5 – a), resulting inelements larger than (5 – a), resulting in SS°°D = {(a,b) | b > 5 – a}D = {(a,b) | b > 5 – a} oror SS°°D = {(a,b) | aD = {(a,b) | a
+ b > 5}.+ b > 5}.
(4, 4)}(4, 4)}
32
Combining Relations
•We already know that functions are just special
cases of relations (namely those that map each
element in the domain onto exactly one element in the
codomain).
•If we formally convert two functions into relations, that
is, write them down as sets of ordered pairs, the
composite of these relations will be exactly the same
as the composite of the functions (as defined earlier).
CMSC 203 - Discrete Structures 33
Combining Relations
•Definition: Let R be a relation on the set A. The
powers Rn
, n = 1, 2, 3, …, are defined inductively by
•R1
= R
•Rn+1
= Rn
°R
•In other words:
•Rn
= R°R° … °R (n times the letter R)
Fall 2002 CMSC 203 - Discrete Structures 34
Combining Relations
•Theorem: The relation R on a set A is transitive if
and only if Rn
⊆ R for all positive integers n.
•Remember the definition of transitivity:
•Definition: A relation R on a set A is called transitive
if whenever (a, b)∈R and (b, c)∈R, then (a, c)∈R for
a, b, c∈A.
•The composite of R with itself contains exactly these
pairs (a, c).
•Therefore, for a transitive relation R, R°R does not
contain any pairs that are not in R, so R°R ⊆ R.
•Since R°R does not introduce any pairs that are not
already in R, it must also be true that (R°R)°R ⊆ R, and
so on, so that Rn
⊆ R.
Fall 2002 CMSC 203 - Discrete Structures 35
n-ary Relations
•In order to study an interesting application of
relations, namely databases, we first need to
generalize the concept of binary relations to n-ary
relations.
•Definition: Let A1, A2, …, An be sets. An n-ary
relation on these sets is a subset of A1×A2×…×An.
•The sets A1, A2, …, An are called the domains of the
relation, and n is called its degree.
Fall 2002 CMSC 203 - Discrete Structures 36
n-ary Relations
•Example:
•Let R = {(a, b, c) | a = 2b ∧ b = 2c with a, b, c∈N}
•What is the degree of R?
•The degree of R is 3, so its elements are triples.
•What are its domains?
•Its domains are all equal to the set of integers.
•Is (2, 4, 8) in R?
•No.
•Is (4, 2, 1) in R?
•Yes.
Fall 2002 CMSC 203 - Discrete Structures 37
Databases and Relations
•Let us take a look at a type of database
representation that is based on relations, namely the
relational data model.
•A database consists of n-tuples called records,
which are made up of fields.
•These fields are the entries of the n-tuples.
•The relational data model represents a database as
an n-ary relation, that is, a set of records.
Fall 2002 CMSC 203 - Discrete Structures 38
Databases and Relations
•Example: Consider a database of students, whose
records are represented as 4-tuples with the fields
Student Name, ID Number, Major, and GPA:
•R = {(Ackermann, 231455, CS, 3.88),
(Adams, 888323, Physics, 3.45),
(Chou, 102147, CS, 3.79),
(Goodfriend, 453876, Math, 3.45),
(Rao, 678543, Math, 3.90),
(Stevens, 786576, Psych, 2.99)}
•Relations that represent databases are also called
tables, since they are often displayed as tables.
Fall 2002 CMSC 203 - Discrete Structures 39
Databases and Relations
•A domain of an n-ary relation is called a primary key
if the n-tuples are uniquely determined by their values
from this domain.
•This means that no two records have the same value
from the same primary key.
•In our example, which of the fields Student Name, ID
Number, Major, and GPA are primary keys?
•Student Name and ID Number are primary keys,
because no two students have identical values in
these fields.
•In a real student database, only ID Number would be
a primary key.
Fall 2002 CMSC 203 - Discrete Structures 40
Databases and Relations
•In a database, a primary key should remain one even
if new records are added.
•Therefore, we should use a primary key of the
intension of the database, containing all the n-tuples
that can ever be included in our database.
•Combinations of domains can also uniquely identify
n-tuples in an n-ary relation.
•When the values of a set of domains determine an
n-tuple in a relation, the Cartesian product of these
domains is called a composite key.
Fall 2002 CMSC 203 - Discrete Structures 41
Databases and Relations
•We can apply a variety of operations on n-ary
relations to form new relations.
•Definition: The projection Pi1, i2, …, im
maps the n-tuple
(a1, a2, …, an) to the m-tuple (ai1
, ai2
, …, aim
), where m ≤
n.
•In other words, a projection Pi1, i2, …, im
keeps the m
components ai1
, ai2
, …, aim
of an n-tuple and deletes its
(n – m) other components.
•Example: What is the result when we apply the
projection P2,4 to the student record (Stevens, 786576,
Psych, 2.99) ?
•Solution: It is the pair (786576, 2.99).
Fall 2002 CMSC 203 - Discrete Structures 42
Databases and Relations
•In some cases, applying a projection to an entire
table may not only result in fewer columns, but also in
fewer rows.
•Why is that?
•Some records may only have differed in those fields
that were deleted, so they become identical, and
there is no need to list identical records more than
once.
Fall 2002 CMSC 203 - Discrete Structures 43
Databases and Relations
•We can use the join operation to combine two tables
into one if they share some identical fields.
•Definition: Let R be a relation of degree m and S a
relation of degree n. The join Jp(R, S), where p ≤ m
and p ≤ n, is a relation of degree m + n – p that
consists of all (m + n – p)-tuples
(a1, a2, …, am-p, c1, c2, …, cp, b1, b2, …, bn-p),
where the m-tuple (a1, a2, …, am-p, c1, c2, …, cp) belongs
to R and the n-tuple (c1, c2, …, cp, b1, b2, …, bn-p) belongs
to S.
Fall 2002 CMSC 203 - Discrete Structures 44
Databases and Relations
•In other words, to generate Jp(R, S), we have to find
all the elements in R whose p last components match
the p first components of an element in S.
•The new relation contains exactly these matches,
which are combined to tuples that contain each
matching field only once.
Fall 2002 CMSC 203 - Discrete Structures 45
Databases and Relations
•Example: What is J1(Y, R), where Y contains the
fields Student Name and Year of Birth,
•Y = {(1978, Ackermann),
(1972, Adams),
(1917, Chou),
(1984, Goodfriend),
(1982, Rao),
(1970, Stevens)},
•and R contains the student records as defined before
?
Fall 2002 CMSC 203 - Discrete Structures 46
Databases and Relations
•Solution: The resulting relation is:
• {(1978, Ackermann, 231455, CS, 3.88),
(1972, Adams, 888323, Physics, 3.45),
(1917, Chou, 102147, CS, 3.79),
(1984, Goodfriend, 453876, Math, 3.45),
(1982, Rao, 678543, Math, 3.90),
(1970, Stevens, 786576, Psych, 2.99)}
•Since Y has two fields and R has four, the relation
J1(Y, R) has 2 + 4 – 1 = 5 fields.
Fall 2002 CMSC 203 - Discrete Structures 47
Representing Relations
•We already know different ways of representing
relations. We will now take a closer look at two ways
of representation: Zero-one matrices and directed
graphs.
•If R is a relation from A = {a1, a2, …, am} to B =
{b1, b2, …, bn}, then R can be represented by the zero-
one matrix MR = [mij] with
•mij = 1, if (ai, bj)∈R, and
•mij = 0, if (ai, bj)∉R.
•Note that for creating this matrix we first need to list
the elements in A and B in a particular, but arbitrary
order.
Fall 2002 CMSC 203 - Discrete Structures 48
Representing Relations
•Example: How can we represent the relation
R = {(2, 1), (3, 1), (3, 2)} as a zero-one matrix?
•Solution: The matrix MR is given by










=
11
01
00
RM
Fall 2002 CMSC 203 - Discrete Structures 49
Representing Relations
•What do we know about the matrices representing a
relation on a set (a relation from A to A) ?
•They are square matrices.
•What do we know about matrices representing
reflexive relations?
•All the elements on the diagonal of such matrices Mref
must be 1s.




















=
1
.
.
.
1
1
refM
Fall 2002 CMSC 203 - Discrete Structures 50
Representing Relations
•What do we know about the matrices representing
symmetric relations?
•These matrices are symmetric, that is, MR = (MR)t
.












=
1101
1001
0010
1101
RM
symmetric matrix,symmetric matrix,
symmetric relation.symmetric relation.












=
0011
0011
0011
0011
RM
non-symmetric matrix,non-symmetric matrix,
non-symmetric relation.non-symmetric relation.
Fall 2002 CMSC 203 - Discrete Structures 51
Representing Relations
•The Boolean operations join and meet (you
remember?) can be used to determine the matrices
representing the union and the intersection of two
relations, respectively.
•To obtain the join of two zero-one matrices, we apply
the Boolean “or” function to all corresponding elements
in the matrices.
•To obtain the meet of two zero-one matrices, we
apply the Boolean “and” function to all corresponding
elements in the matrices.
Fall 2002 CMSC 203 - Discrete Structures 52
Representing Relations
•Example: Let the relations R and S be represented
by the matrices










=∨=∪
011
111
101
SRSR MMM










=
001
110
101
SM
What are the matrices representing RWhat are the matrices representing R∪∪S and RS and R∩∩S?S?
Solution:Solution: These matrices are given byThese matrices are given by










=∧=∩
000
000
101
SRSR MMM










=
010
001
101
RM
Fall 2002 CMSC 203 - Discrete Structures 53
Representing Relations Using Matrices
•Example: How can we represent the relation
R = {(2, 1), (3, 1), (3, 2)} as a zero-one matrix?
•Solution: The matrix MR is given by










=
11
01
00
RM
Fall 2002 CMSC 203 - Discrete Structures 54
Representing Relations Using Matrices
•Example: Let the relations R and S be represented
by the matrices










=∨=∪
011
111
101
SRSR MMM










=
001
110
101
SM
What are the matrices representing RWhat are the matrices representing R∪∪S and RS and R∩∩S?S?
Solution:Solution: These matrices are given byThese matrices are given by










=∧=∩
000
000
101
SRSR MMM










=
010
001
101
RM
Fall 2002 CMSC 203 - Discrete Structures 55
Representing Relations Using Matrices
Do you remember theDo you remember the Boolean productBoolean product of two zero-one matrices?of two zero-one matrices?
Let A = [aLet A = [aijij] be an m] be an m××k zero-one matrix andk zero-one matrix and
B = [bB = [bijij] be a k] be a k××n zero-one matrix.n zero-one matrix.
Then theThen the Boolean productBoolean product of A and B, denoted by Aof A and B, denoted by AοοB, is the mB, is the m××n matrix with (i,n matrix with (i,
j)th entry [cj)th entry [cijij], where], where
ccijij = (a= (ai1i1 ∧∧ bb1j1j)) ∨∨ (a(ai2i2 ∧∧ bb2i2i)) ∨∨ …… ∨∨ (a(aikik ∧∧ bbkjkj).).
ccijij = 1 if and only if at least one of the terms= 1 if and only if at least one of the terms
(a(ainin ∧∧ bbnjnj) = 1 for some n; otherwise c) = 1 for some n; otherwise cijij = 0.= 0.
Fall 2002 CMSC 203 - Discrete Structures 56
Representing Relations Using Matrices
Let us now assume that the zero-one matricesLet us now assume that the zero-one matrices
MMAA = [a= [aijij], M], MBB = [b= [bijij] and M] and MCC = [c= [cijij] represent relations A, B, and C, respectively.] represent relations A, B, and C, respectively.
Remember:Remember: For MFor MCC = M= MAAοοMMBB we have:we have:
ccijij = 1 if and only if at least one of the terms= 1 if and only if at least one of the terms
(a(ainin ∧∧ bbnjnj) = 1 for some n; otherwise c) = 1 for some n; otherwise cijij = 0.= 0.
In terms of theIn terms of the relationsrelations, this means that C contains a pair (x, this means that C contains a pair (xii, z, zjj) if and only if there) if and only if there
is an element yis an element ynn such that (xsuch that (xii, y, ynn) is in relation A and) is in relation A and
(y(ynn, z, zjj) is in relation B.) is in relation B.
Therefore, C = BTherefore, C = B°°A (A (compositecomposite of A and B).of A and B).
Fall 2002 CMSC 203 - Discrete Structures 57
Representing Relations Using Matrices
This gives us the following rule:This gives us the following rule:
MMBB°°AA = M= MAAοοMMBB
In other words, the matrix representing theIn other words, the matrix representing the compositecomposite of relations A and B is theof relations A and B is the
Boolean productBoolean product of the matrices representing A and B.of the matrices representing A and B.
Analogously, we can find matrices representing theAnalogously, we can find matrices representing the powers of relationspowers of relations::
MMRRnn = M= MRR
[n][n]
(n-th(n-th Boolean powerBoolean power).).
Fall 2002 CMSC 203 - Discrete Structures 58
Representing Relations Using Matrices
•Example: Find the matrix representing R2
, where the
matrix representing R is given by










=
001
110
010
RM
Solution:Solution: The matrix for RThe matrix for R22
is given byis given by










==
010
111
110
]2[
2 RR
MM
Fall 2002 CMSC 203 - Discrete Structures 59
Representing Relations Using Digraphs
•Definition: A directed graph, or digraph, consists
of a set V of vertices (or nodes) together with a set E
of ordered pairs of elements of V called edges (or
arcs).
•The vertex a is called the initial vertex of the edge
(a, b), and the vertex b is called the terminal vertex
of this edge.
•We can use arrows to display graphs.
Fall 2002 CMSC 203 - Discrete Structures 60
Representing Relations Using Digraphs
•Example: Display the digraph with V = {a, b, c, d},
E = {(a, b), (a, d), (b, b), (b, d), (c, a), (c, b), (d, b)}.
aa
bb
ccdd
An edge of the form (b, b) is called aAn edge of the form (b, b) is called a loop.loop.
Fall 2002 CMSC 203 - Discrete Structures 61
Representing Relations Using Digraphs
•Obviously, we can represent any relation R on a set
A by the digraph with A as its vertices and all pairs (a,
b)∈R as its edges.
•Vice versa, any digraph with vertices V and edges E
can be represented by a relation on V containing all
the pairs in E.
•This one-to-one correspondence between relations
and digraphs means that any statement about
relations also applies to digraphs, and vice versa.
Fall 2002 CMSC 203 - Discrete Structures 62
Equivalence Relations
•Equivalence relations are used to relate objects that
are similar in some way.
•Definition: A relation on a set A is called an
equivalence relation if it is reflexive, symmetric, and
transitive.
•Two elements that are related by an equivalence
relation R are called equivalent.
Fall 2002 CMSC 203 - Discrete Structures 63
Equivalence Relations
•Since R is symmetric, a is equivalent to b whenever
b is equivalent to a.
•Since R is reflexive, every element is equivalent to
itself.
•Since R is transitive, if a and b are equivalent and b
and c are equivalent, then a and c are equivalent.
•Obviously, these three properties are necessary for a
reasonable definition of equivalence.
Fall 2002 CMSC 203 - Discrete Structures 64
Equivalence Relations
•Example: Suppose that R is the relation on the set of
strings that consist of English letters such that aRb if
and only if l(a) = l(b), where l(x) is the length of the
string x. Is R an equivalence relation?
•Solution:
• R is reflexive, because l(a) = l(a) and therefore
aRa for any string a.
• R is symmetric, because if l(a) = l(b) then l(b) =
l(a), so if aRb then bRa.
• R is transitive, because if l(a) = l(b) and l(b) = l(c),
then l(a) = l(c), so aRb and bRc implies aRc.
•R is an equivalence relation.
Fall 2002 CMSC 203 - Discrete Structures 65
Equivalence Classes
•Definition: Let R be an equivalence relation on a set
A. The set of all elements that are related to an
element a of A is called the equivalence class
of a.
•The equivalence class of a with respect to R is
denoted by [a]R.
•When only one relation is under consideration, we
will delete the subscript R and write [a] for this
equivalence class.
•If b∈[a]R, b is called a representative of this
equivalence class.
Fall 2002 CMSC 203 - Discrete Structures 66
Equivalence Classes
•Example: In the previous example (strings of
identical length), what is the equivalence class of the
word mouse, denoted by [mouse] ?
•Solution: [mouse] is the set of all English words
containing five letters.
•For example, ‘horse’ would be a representative of this
equivalence class.
•
Fall 2002 CMSC 203 - Discrete Structures 67
Equivalence Classes
•Theorem: Let R be an equivalence relation on a set
A. The following statements are equivalent:
• aRb
• [a] = [b]
• [a] ∩ [b] ≠ ∅
•Definition: A partition of a set S is a collection of
disjoint nonempty subsets of S that have S as their
union. In other words, the collection of subsets Ai,
i∈I, forms a partition of S if and only if
(i) Ai ≠ ∅ for i∈I
• Ai ∩ Aj = ∅, if i ≠ j
• ∪i∈I Ai = S
Fall 2002 CMSC 203 - Discrete Structures 68
Equivalence Classes
•Examples: Let S be the set {u, m, b, r, o, c, k, s}.
Do the following collections of sets partition S ?
{{m, o, c, k}, {r, u, b, s}}{{m, o, c, k}, {r, u, b, s}} yes.yes.
{{c, o, m, b}, {u, s}, {r}}{{c, o, m, b}, {u, s}, {r}} no (k is missing).no (k is missing).
{{b, r, o, c, k}, {m, u, s, t}}{{b, r, o, c, k}, {m, u, s, t}} no (t is not in S).no (t is not in S).
{{u, m, b, r, o, c, k, s}}{{u, m, b, r, o, c, k, s}} yes.yes.
{{b, o, o, k}, {r, u, m}, {c, s}}{{b, o, o, k}, {r, u, m}, {c, s}} yes ({b,o,o,k} = {b,o,k}).yes ({b,o,o,k} = {b,o,k}).
{{u, m, b}, {r, o, c, k, s},{{u, m, b}, {r, o, c, k, s}, ∅∅}} no (no (∅∅ not allowed).not allowed).
Fall 2002 CMSC 203 - Discrete Structures 69
Equivalence Classes
•Theorem: Let R be an equivalence relation on a
set S. Then the equivalence classes of R form a
partition of S. Conversely, given a partition
{Ai | i∈I} of the set S, there is an equivalence relation R
that has the sets Ai, i∈I, as its equivalence classes.
Fall 2002 CMSC 203 - Discrete Structures 70
Equivalence Classes
•Example: Let us assume that Frank, Suzanne and
George live in Boston, Stephanie and Max live in
Lübeck, and Jennifer lives in Sydney.
•Let R be the equivalence relation {(a, b) | a and b
live in the same city} on the set P = {Frank, Suzanne,
George, Stephanie, Max, Jennifer}.
•Then R = {(Frank, Frank), (Frank, Suzanne),
(Frank, George), (Suzanne, Frank), (Suzanne,
Suzanne), (Suzanne, George), (George, Frank),
(George, Suzanne), (George, George), (Stephanie,
Stephanie), (Stephanie, Max), (Max, Stephanie),
(Max, Max), (Jennifer, Jennifer)}.
Fall 2002 CMSC 203 - Discrete Structures 71
Equivalence Classes
•Then the equivalence classes of R are:
•{{Frank, Suzanne, George}, {Stephanie, Max},
{Jennifer}}.
•This is a partition of P.
•The equivalence classes of any equivalence relation
R defined on a set S constitute a partition of S,
because every element in S is assigned to exactly
one of the equivalence classes.
Fall 2002 CMSC 203 - Discrete Structures 72
Equivalence Classes
•Another example: Let R be the relation
{(a, b) | a ≡ b (mod 3)} on the set of integers.
•Is R an equivalence relation?
•Yes, R is reflexive, symmetric, and transitive.
•What are the equivalence classes of R ?
•{{…, -6, -3, 0, 3, 6, …},
{…, -5, -2, 1, 4, 7, …},
{…, -4, -1, 2, 5, 8, …}}
73
Functions
74
Definition of Functions
• Given any sets A, B, a function f from (or
“mapping”) A to B (f:A→B) is an
assignment of exactly one element
f(x)∈B
to each element x∈A.
75
Graphical Representations
• Functions can be represented graphically
in several ways:
• •
A
B
a b
f
f
•
•
•
•
•
•
•
•
•
x
y
Plot
Graph
Like Venn diagrams
A B
76
Definition of Functions (cont’d)
• Formally: given f:A→B
“x is a function” :≡ (¬∃x,y: x=y ∧ f(x) ≠ f(y)) or
“x is a function” :≡ (∀ x,y: ¬(x=y) ∨ ¬(f(x) ≠ f(y))) or
“x is a function” :≡ (∀ x,y: ¬(x=y) ∨ (f(x) = f(y))) or
“x is a function” :≡ (∀ x,y: (x=y) → (f(x) = f(y))) or
“x is a function” :≡ (∀ x,y: (f(x) ≠ f(y)) → (x ≠ y))
77
Some Function Terminology
• If f:A→B, and f(a)=b (where a∈A & b∈B),
then:
– A is the domain of f.
– B is the codomain of f.
– b is the image of a under f.
– a is a pre-image of b under f.
• In general, b may have more than one pre-image.
– The range R⊆B of f is {b | ∃a f(a)=b }.
78
Function Addition/Multiplication
• We can add and multiply functions
f,g:R→R:
– (f + g):R→R, where (f + g)(x) = f(x) + g(x)
– (f × g):R→R, where (f × g)(x) = f(x) × g(x)
79
Function Composition
• For functions g:A→B and f:B→C, there is a
special operator called compose (“○”).
– It composes (i.e., creates) a new function out of f,g
by applying f to the result of g.
(f○g):A→C, where (f○g)(a) = f(g(a)).
– Note g(a)∈B, so f(g(a)) is defined and ∈C.
– The range of g must be a subset of f’s
domain!!
– Note that ○ (like Cartesian ×, but unlike +,∧,∪) is
non-commuting. (In general, f○g ≠ g○f.)
80
Function Composition
81
Images of Sets under Functions
• Given f:A→B, and S⊆A,
• The image of S under f is simply the set of
all images (under f) of the elements of S.
f(S) :≡ {f(s) | s∈S}
:≡ {b | ∃ s∈S: f(s)=b}.
• Note the range of f can be defined as
simply the image (under f) of f’s domain!
82
One-to-One Functions
• A function is one-to-one (1-1), or
injective, or an injection, iff every
element of its range has only one pre-
image.
• Only one element of the domain is
mapped to any given one element of
the range.
– Domain & range have same cardinality.
What about codomain?
83
One-to-One Functions (cont’d)
• Formally: given f:A→B
“x is injective” :≡ (¬∃x,y: x≠y ∧ f(x)=f(y)) or
“x is injective” :≡ (∀ x,y: ¬(x≠y) ∨ ¬(f(x)=f(y)))
or
“x is injective” :≡ (∀ x,y: ¬(x≠y) ∨ (f(x) ≠ f(y)))
or
“x is injective” :≡ (∀ x,y: (x≠y) → (f(x) ≠ f(y)))
or
“x is injective” :≡ (∀ x,y: (f(x)=f(y)) → (x =y))
84
One-to-One Illustration
• Graph representations of functions that
are (or not) one-to-one:
•
•
•
•
•
•
•
•
•
One-to-one
•
•
•
•
•
•
•
•
•
Not one-to-one
•
•
•
•
•
•
•
•
•
Not even a
function!
85
Sufficient Conditions for 1-
1ness
• Definitions (for functions f over
numbers):
– f is strictly (or monotonically) increasing iff
x>y → f(x)>f(y) for all x,y in domain;
– f is strictly (or monotonically) decreasing iff
x>y → f(x)<f(y) for all x,y in domain;
• If f is either strictly increasing or strictly
decreasing, then f is one-to-one.
– e.g. f(x)=x3
86
Onto (Surjective) Functions
• A function f:A→B is onto or surjective or
a surjection iff its range is equal to its
codomain (∀b∈B, ∃a∈A: f(a)=b).
• An onto function maps the set A onto
(over, covering) the entirety of the set B,
not just over a piece of it.
– e.g., for domain & codomain R, x3
is onto,
whereas x2
isn’t. (Why not?)
87
Illustration of Onto
• Some functions that are or are not onto
their codomains:
Onto
(but not 1-1)
•
•
•
•
•
•
•
•
•
Not Onto
(or 1-1)
•
•
•
•
•
•
•
•
•
Both 1-1
and onto
•
•
•
•
•
•
•
•
1-1 but
not onto
•
•
•
•
•
•
•
•
•
88
Bijections
• A function f is a one-to-one
correspondence, or a bijection, or
reversible, or invertible, iff it is both one-
to-one and onto.
89
Inverse of a Function
• For bijections f:A→B, there exists an
inverse of f, written f −1
:B→A, which is the
unique function such that:
Iff =−
1
90
Inverse of a function (cont’d)
91
The Identity Function
• For any domain A, the identity function
I:A→A (variously written, IA, 1, 1A) is the
unique function such that ∀a∈A: I(a)=a.
• Some identity functions you’ve seen:
∧ing with T, ∨ing with F, ∪ing with ∅, ∩ing
with U.
• Note that the identity function is both one-
to-one and onto (bijective).
92
• The identity function:
Identity Function Illustrations
•
•
•
•
•
•
•
•
•
Domain and range x
y
93
Graphs of Functions
• We can represent a function f:A→B as a
set of ordered pairs {(a,f(a)) | a∈A}.
• Note that ∀a, there is only one pair (a,
f(a)).
• For functions over numbers, we can
represent an ordered pair (x,y) as a
point on a plane. A function is then
drawn as a curve (set of points) with
only one y for each x.
94
Graphs of Functions
95
A Couple of Key Functions
• In discrete math, we frequently use the
following functions over real numbers:
x (“floor of x”) is the largest integer ≤ x.
x (“ceiling of x”) is the smallest integer ≥ x.
96
Visualizing Floor & Ceiling
• Real numbers “fall to their floor” or “rise to
their ceiling.”
• Note that if x∉Z,
−x ≠ − x &
−x ≠ − x
• Note that if x∈Z,
x = x = x.
0
−1
1
2
3
−2
−3
.
.
.
.
.
.
. . .
1.6
1.6=2
−1.4= −2
−1.4
−1.4= −1
1.6=1
−3
−3=−3= −3
97
Plots with floor/ceiling:
Example
• Plot of graph of function f(x) = x/3:
x
f(x)
Set of points (x, f(x))
+3
−2
+2
−3

Weitere ähnliche Inhalte

Was ist angesagt?

6.4 inverse matrices
6.4 inverse matrices6.4 inverse matrices
6.4 inverse matrices
math260
 

Was ist angesagt? (20)

Inverse function
Inverse functionInverse function
Inverse function
 
Relation and function
Relation and functionRelation and function
Relation and function
 
Relations
RelationsRelations
Relations
 
Taylor series in 1 and 2 variable
Taylor series in 1 and 2 variableTaylor series in 1 and 2 variable
Taylor series in 1 and 2 variable
 
INTRODUCTION TO MATRICES, TYPES OF MATRICES,
INTRODUCTION TO MATRICES, TYPES OF MATRICES, INTRODUCTION TO MATRICES, TYPES OF MATRICES,
INTRODUCTION TO MATRICES, TYPES OF MATRICES,
 
Differential calculus maxima minima
Differential calculus  maxima minimaDifferential calculus  maxima minima
Differential calculus maxima minima
 
Venn Diagram
Venn DiagramVenn Diagram
Venn Diagram
 
CMSC 56 | Lecture 6: Sets & Set Operations
CMSC 56 | Lecture 6: Sets & Set OperationsCMSC 56 | Lecture 6: Sets & Set Operations
CMSC 56 | Lecture 6: Sets & Set Operations
 
4.1 Defining and visualizing binary relations
4.1 Defining and visualizing binary relations4.1 Defining and visualizing binary relations
4.1 Defining and visualizing binary relations
 
34 polar coordinate and equations
34 polar coordinate and equations34 polar coordinate and equations
34 polar coordinate and equations
 
Set theory
Set theory Set theory
Set theory
 
Relations
RelationsRelations
Relations
 
6.4 inverse matrices
6.4 inverse matrices6.4 inverse matrices
6.4 inverse matrices
 
Cayley-Hamilton Theorem, Eigenvalues, Eigenvectors and Eigenspace.
Cayley-Hamilton Theorem, Eigenvalues, Eigenvectors and Eigenspace.Cayley-Hamilton Theorem, Eigenvalues, Eigenvectors and Eigenspace.
Cayley-Hamilton Theorem, Eigenvalues, Eigenvectors and Eigenspace.
 
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
 
Relations
RelationsRelations
Relations
 
Relations & Functions
Relations & FunctionsRelations & Functions
Relations & Functions
 
Sets in Maths (Complete Topic)
Sets in Maths (Complete Topic)Sets in Maths (Complete Topic)
Sets in Maths (Complete Topic)
 
3.2 Power sets
3.2 Power sets3.2 Power sets
3.2 Power sets
 
2.1 Union, intersection and complement
2.1 Union, intersection and complement2.1 Union, intersection and complement
2.1 Union, intersection and complement
 

Ähnlich wie Set theory

Relational Algebra (1).pptx
Relational Algebra (1).pptxRelational Algebra (1).pptx
Relational Algebra (1).pptx
SarowarSuman
 
dm_13_RelationsAndTheirProperties (1).pdf
dm_13_RelationsAndTheirProperties (1).pdfdm_13_RelationsAndTheirProperties (1).pdf
dm_13_RelationsAndTheirProperties (1).pdf
SanjanaAdri
 
05 tat math class xi_r&f-1_for website
05 tat math class xi_r&f-1_for website05 tat math class xi_r&f-1_for website
05 tat math class xi_r&f-1_for website
Varun Kumar
 

Ähnlich wie Set theory (20)

Toc chapter 1 srg
Toc chapter 1 srgToc chapter 1 srg
Toc chapter 1 srg
 
Relational Algebra (1).pptx
Relational Algebra (1).pptxRelational Algebra (1).pptx
Relational Algebra (1).pptx
 
Set theory
Set theorySet theory
Set theory
 
Relation and function_xii
Relation and function_xiiRelation and function_xii
Relation and function_xii
 
Mathematics JEE quick revision notes pdf
Mathematics JEE quick revision notes pdfMathematics JEE quick revision notes pdf
Mathematics JEE quick revision notes pdf
 
Final relation1 m_tech(cse)
Final relation1 m_tech(cse)Final relation1 m_tech(cse)
Final relation1 m_tech(cse)
 
Final relation1 m_tech(cse)
Final relation1 m_tech(cse)Final relation1 m_tech(cse)
Final relation1 m_tech(cse)
 
Final relation1 m_tech(cse)
Final relation1 m_tech(cse)Final relation1 m_tech(cse)
Final relation1 m_tech(cse)
 
Mtk3013 chapter 2-3
Mtk3013   chapter 2-3Mtk3013   chapter 2-3
Mtk3013 chapter 2-3
 
dm_13_RelationsAndTheirProperties (1).pdf
dm_13_RelationsAndTheirProperties (1).pdfdm_13_RelationsAndTheirProperties (1).pdf
dm_13_RelationsAndTheirProperties (1).pdf
 
SetTheory.ppt
SetTheory.pptSetTheory.ppt
SetTheory.ppt
 
SetTheory.ppt
SetTheory.pptSetTheory.ppt
SetTheory.ppt
 
1. set theory
1. set theory1. set theory
1. set theory
 
RELATION
RELATIONRELATION
RELATION
 
Relations and Functions 1
Relations and Functions 1Relations and Functions 1
Relations and Functions 1
 
2 homework
2 homework2 homework
2 homework
 
dm_13_RelationsAndTheirProperties (1).pptx
dm_13_RelationsAndTheirProperties (1).pptxdm_13_RelationsAndTheirProperties (1).pptx
dm_13_RelationsAndTheirProperties (1).pptx
 
Relations
RelationsRelations
Relations
 
Set and Set operations, UITM KPPIM DUNGUN
Set and Set operations, UITM KPPIM DUNGUNSet and Set operations, UITM KPPIM DUNGUN
Set and Set operations, UITM KPPIM DUNGUN
 
05 tat math class xi_r&f-1_for website
05 tat math class xi_r&f-1_for website05 tat math class xi_r&f-1_for website
05 tat math class xi_r&f-1_for website
 

Mehr von manikanta361 (6)

Loops and functions in r
Loops and functions in rLoops and functions in r
Loops and functions in r
 
Inroduction to r
Inroduction to rInroduction to r
Inroduction to r
 
Gui programming
Gui programmingGui programming
Gui programming
 
Number theory
Number theoryNumber theory
Number theory
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Mathemetics module
Mathemetics moduleMathemetics module
Mathemetics module
 

Kürzlich hochgeladen

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Kürzlich hochgeladen (20)

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 

Set theory

  • 2. NotationNotation • S={a, b, c} refers to the set whose elements are a, b and c. • a∈S means “a is an element of set S”. • d∉S means “d is not an element of set S”. • {x ∈S | P(x)} is the set of all those x from S such that P(x) is true. E.g., T={x ∈Z | 0<x<10} . • Notes: 1) {a,b,c}, {b,a,c}, {c,b,a,b,b,c} all represent the same set. 2) Sets can themselves be elements of other sets, e.g., S={ {Mary, John}, {Tim, Ann}, …}
  • 3. 3 Relations between setsRelations between sets • Definition: Suppose A and B are sets. Then A is called a subset of B: A ⊆ B iff every element of A is also an element of B. Symbolically, A ⊆B ⇔ ∀x, if x∈A then x ∈B. • A ⊄ B ⇔ ∃x such that x∈A and x∉B. BA A B BA A ⊆ B A ⊄ B A ⊄ B
  • 4. 4 Relations between setsRelations between sets • Definition: Suppose A and B are sets. Then A equals B: A = B iff every element of A is in B and every element of B is in A. Symbolically, A=B ⇔ A⊆B and B⊆A . • Example: Let A = {m∈Z | m=2k+3 for some integer k}; B = the set of all odd integers. Then A=B.
  • 5. Operations on SetsOperations on Sets Definition: Let A and B be subsets of a set U. 1. Union of A and B: A ∪ B = {x∈U | x∈A or x∈B} 2. Intersection of A and B: A ∩ B = {x∈U | x∈A and x∈B} 3. Difference of B minus A: B−A = {x∈U | x∈B and x∉A} 4. Complement of A: Ac = {x∈U | x∉A} Ex.: Let U=R, A={x ∈R | 3<x<5}, B ={x ∈R| 4<x<9}. Then 1) A ∪ B = {x ∈R | 3<x<9}. 2) A ∩ B = {x ∈R | 4<x<5}. 3) B−A = {x ∈R | 5 ≤x<9}, A−B = {x ∈R | 3<x ≤4}. 4) Ac = {x∈R | x ≤3 or x≥5}, Bc = {x∈R | x ≤4 or x≥9}
  • 6. 6 Properties of SetsProperties of Sets Theorem 1 (Some subset relations): 1) A∩B ⊆ A 2) A ⊆ A∪B 3) If A ⊆ B and B ⊆ C, then A ⊆ C .  To prove that A ⊆ B use the “element argument”: 1. suppose that x is a particular but arbitrarily chosen element of A, 2. show that x is an element of B.
  • 7. 7 Proving a Set PropertyProving a Set Property • Theorem 2 (Distributive Law): For any sets A,B and C: A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) . • Proof: We need to show that (I) A ∪ (B ∩ C) ⊆ (A ∪ B) ∩ (A ∪ C) and (II) (A ∪ B) ∩ (A ∪ C) ⊆ A ∪ (B ∩ C) . Let’s show (I). Suppose x ∈ A ∪ (B ∩ C) (1) We want to show that x ∈ (A ∪ B) ∩ (A ∪ C) (2)
  • 8. 8 Proving a Set PropertyProving a Set Property • Proof (cont.): x ∈ A ∪ (B ∩ C) ⇒ x ∈ A or x ∈ B ∩ C . (a) Let x ∈ A. Then x ∈ A∪B and x ∈ A∪C ⇒ x ∈ (A ∪ B) ∩ (A ∪ C) (b) Let x ∈ B ∩ C. Then x∈B and x∈C. Thus, (2) is true, and we have shown (I). (II) is shown similarly (left as exercise). ■ )()( CABAx CAxCx BAxBx ∪∩∪∈⇒    ∪∈⇒∈ ∪∈⇒∈
  • 9. 9 Set PropertiesSet Properties • Commutative Laws: • Associative Laws: • Distributive Laws: ABBAb ABBAa ∪=∪ ∩=∩ )( )( )()()( )()()( CBACBAb CBACBAa ∪∪=∪∪ ∩∩=∩∩ )()()()( )()()()( CABACBAb CABACBAa ∩∪∩=∪∩ ∪∩∪=∩∪
  • 10. 10 Set PropertiesSet Properties • Double Complement Law: • De Morgan’s Laws: • Absorption Laws: AA cc =)( ccc ccc BABAb BABAa ∩=∪ ∪=∩ )()( )()( ABAAb ABAAa =∪∩ =∩∪ )()( )()(
  • 11. 11 Showing that an alleged setShowing that an alleged set property is falseproperty is false • Statement: For all sets A,B and C, A−(B−C) = (A−B)−C . The following counterexample shows that the statement is false. • Counterexample: Let A={1,2,3,4} , B={3,4,5,6} , C={3}. Then B−C = {4,5,6} and A−(B−C) = {1,2,3} . On the other hand, A−B = {1,2} and (A−B)−C = {1,2} . Thus, for this example A−(B−C) ≠ (A−B)−C .
  • 12. 12 Empty SetEmpty Set • The unique set with no elements is called empty set and denoted by ∅. • Set Properties that involve ∅ . For all sets A, 1. ∅ ⊆ A 2. A ∪ ∅ = A 3. A ∩ ∅ = ∅ 4. A ∩ Ac = ∅
  • 13. 13 Disjoint SetsDisjoint Sets  A and B are called disjoint iff A ∩ B = ∅ .  Sets A1, A2, …, An are called mutually disjoint iff for all i,j = 1,2,…, n Ai ∩ Aj = ∅ whenever i ≠ j .  Examples: 1) A={1,2} and B={3,4} are disjoint. 2) The sets of even and odd integers are disjoint. 3) A={1,4}, B={2,5}, C={3} are mutually disjoint. 4) A−B, B−A and A∩B are mutually disjoint.
  • 14. 14 PartitionsPartitions • Definition: A collection of nonempty sets {A1, A2, …, An} is a partition of a set A iff 1. A = A1 ∪ A2 ∪ … ∪ An 2. A1, A2, …, An are mutually disjoint. • Examples: 1) {Z+ , Z- , {0} } is a partition of Z. 2) Let S0={n ∈ Z | n=3k for some integer k} S1={n ∈ Z | n=3k+1 for some integer k} S2={n ∈ Z | n=3k+2 for some integer k} Then {S0, S1, S2} is a partition of Z.
  • 15. 15 Power SetsPower Sets • Definition: Given a set A, the power set of A, denoted P (A) , is the set of all subsets of A. • Example: P ({a,b}) = {∅, {a}, {b}, {a,b}} . • Properties: 1) If A ⊆ B then P (A) ⊆ P (B) . 2) If a set A has n elements then P (A) has 2n elements.
  • 17. 17 Relations •If we want to describe a relationship between elements of two sets A and B, we can use ordered pairs with their first element taken from A and their second element taken from B. •Since this is a relation between two sets, it is called a binary relation. •Definition: Let A and B be sets. A binary relation from A to B is a subset of A×B. •In other words, for a binary relation R we have R ⊆ A×B. We use the notation aRb to denote that (a, b)∈R and aRb to denote that (a, b)∉R.
  • 18. 18 Relations •When (a, b) belongs to R, a is said to be related to b by R. •Example: Let P be a set of people, C be a set of cars, and D be the relation describing which person drives which car(s). •P = {Carl, Suzanne, Peter, Carla}, •C = {Mercedes, BMW, tricycle} •D = {(Carl, Mercedes), (Suzanne, Mercedes), (Suzanne, BMW), (Peter, tricycle)} •This means that Carl drives a Mercedes, Suzanne drives a Mercedes and a BMW, Peter drives a tricycle, and Carla does not drive any of these vehicles.
  • 19. 19 Functions as Relations •You might remember that a function f from a set A to a set B assigns a unique element of B to each element of A. •The graph of f is the set of ordered pairs (a, b) such that b = f(a). •Since the graph of f is a subset of A×B, it is a relation from A to B. •Moreover, for each element a of A, there is exactly one ordered pair in the graph that has a as its first element.
  • 20. 20 Functions as Relations •Conversely, if R is a relation from A to B such that every element in A is the first element of exactly one ordered pair of R, then a function can be defined with R as its graph. •This is done by assigning to an element a∈A the unique element b∈B such that (a, b)∈R.
  • 21. 21 Relations on a Set •Definition: A relation on the set A is a relation from A to A. •In other words, a relation on the set A is a subset of A×A. •Example: Let A = {1, 2, 3, 4}. Which ordered pairs are in the relation R = {(a, b) | a < b} ?
  • 22. 22 Relations on a Set •Solution: R = {(1, 2),(1, 2), (1, 3),(1, 3), (1, 4),(1, 4), (2, 3),(2, 3), (2, 4),(2, 4), (3, 4)}(3, 4)} RR 11 22 33 44 11 22 33 44 11 11 22 33 44 22 33 44 XX XX XX XX XX XX
  • 23. Fall 2002 23 Relations on a Set •How many different relations can we define on a set A with n elements? •A relation on a set A is a subset of A×A. •How many elements are in A×A ? •There are n2 elements in A×A, so how many subsets (= relations on A) does A×A have? •The number of subsets that we can form out of a set with m elements is 2m . Therefore, 2n2 subsets can be formed out of A×A. •Answer: We can define 2n2 different relations on A.
  • 24. 24 Properties of Relations •We will now look at some useful ways to classify relations. •Definition: A relation R on a set A is called reflexive if (a, a)∈R for every element a∈A. •Are the following relations on {1, 2, 3, 4} reflexive? R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)}R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)} No.No. R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)}R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)} Yes.Yes. R = {(1, 1), (2, 2), (3, 3)}R = {(1, 1), (2, 2), (3, 3)} No.No. Definition:Definition: A relation on a set A is calledA relation on a set A is called irreflexiveirreflexive if (a, a)if (a, a)∉∉R for every elementR for every element aa∈∈A.A.
  • 25. 25 Properties of Relations •Definitions: •A relation R on a set A is called symmetric if (b, a)∈R whenever (a, b)∈R for all a, b∈A. •A relation R on a set A is called antisymmetric if a = b whenever (a, b)∈R and (b, a)∈R. •A relation R on a set A is called asymmetric if (a, b)∈R implies that (b, a)∉R for all a, b∈A.
  • 26. 26 Properties of Relations •Are the following relations on {1, 2, 3, 4} symmetric, antisymmetric, or asymmetric? R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)}R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)} symmetricsymmetric R = {(1, 1)}R = {(1, 1)} sym. andsym. and antisym.antisym. R = {(1, 3), (3, 2), (2, 1)}R = {(1, 3), (3, 2), (2, 1)} antisym. andantisym. and asym.asym. R = {(4, 4), (3, 3), (1, 4)}R = {(4, 4), (3, 3), (1, 4)} antisym.antisym.
  • 27. 27 Properties of Relations •Definition: A relation R on a set A is called transitive if whenever (a, b)∈R and (b, c)∈R, then (a, c)∈R for a, b, c∈A. •Are the following relations on {1, 2, 3, 4} transitive? R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)}R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)} Yes.Yes. R = {(1, 3), (3, 2), (2, 1)}R = {(1, 3), (3, 2), (2, 1)} No.No. R = {(2, 4), (4, 3), (2, 3), (4, 1)}R = {(2, 4), (4, 3), (2, 3), (4, 1)} No.No.
  • 28. 28 Counting Relations •Example: How many different reflexive relations can be defined on a set A containing n elements? •Solution: Relations on R are subsets of A×A, which contains n2 elements. •Therefore, different relations on A can be generated by choosing different subsets out of these n2 elements, so there are 2n2 relations. •A reflexive relation, however, must contain the n elements (a, a) for every a∈A. •Consequently, we can only choose among n2 – n = n(n – 1) elements to generate reflexive relations, so there are 2n(n – 1) of them.
  • 29. 29 Combining Relations •Relations are sets, and therefore, we can apply the usual set operations to them. •If we have two relations R1 and R2, and both of them are from a set A to a set B, then we can combine them to R1 ∪ R2, R1 ∩ R2, or R1 – R2. •In each case, the result will be another relation from A to B.
  • 30. Fall 2002 CMSC 203 - Discrete Structures 30 Combining Relations •… and there is another important way to combine relations. •Definition: Let R be a relation from a set A to a set B and S a relation from B to a set C. The composite of R and S is the relation consisting of ordered pairs (a, c), where a∈A, c∈C, and for which there exists an element b∈B such that (a, b)∈R and (b, c)∈S. We denote the composite of R and S by S°R. •In other words, if relation R contains a pair (a, b) and relation S contains a pair (b, c), then S°R contains a pair (a, c).
  • 31. 31 Combining Relations •Example: Let D and S be relations on A = {1, 2, 3, 4}. •D = {(a, b) | b = 5 - a} “b equals (5 – a)” •S = {(a, b) | a < b} “a is smaller than b” •D = {(1, 4), (2, 3), (3, 2), (4, 1)} •S = {(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)} •S°D = {(2, 4),(2, 4), (3, 3),(3, 3), (3, 4),(3, 4), (4, 2),(4, 2), (4, 3),(4, 3), D maps an element a to the element (5 – a), and afterwards S maps (5 – a) to allD maps an element a to the element (5 – a), and afterwards S maps (5 – a) to all elements larger than (5 – a), resulting inelements larger than (5 – a), resulting in SS°°D = {(a,b) | b > 5 – a}D = {(a,b) | b > 5 – a} oror SS°°D = {(a,b) | aD = {(a,b) | a + b > 5}.+ b > 5}. (4, 4)}(4, 4)}
  • 32. 32 Combining Relations •We already know that functions are just special cases of relations (namely those that map each element in the domain onto exactly one element in the codomain). •If we formally convert two functions into relations, that is, write them down as sets of ordered pairs, the composite of these relations will be exactly the same as the composite of the functions (as defined earlier).
  • 33. CMSC 203 - Discrete Structures 33 Combining Relations •Definition: Let R be a relation on the set A. The powers Rn , n = 1, 2, 3, …, are defined inductively by •R1 = R •Rn+1 = Rn °R •In other words: •Rn = R°R° … °R (n times the letter R)
  • 34. Fall 2002 CMSC 203 - Discrete Structures 34 Combining Relations •Theorem: The relation R on a set A is transitive if and only if Rn ⊆ R for all positive integers n. •Remember the definition of transitivity: •Definition: A relation R on a set A is called transitive if whenever (a, b)∈R and (b, c)∈R, then (a, c)∈R for a, b, c∈A. •The composite of R with itself contains exactly these pairs (a, c). •Therefore, for a transitive relation R, R°R does not contain any pairs that are not in R, so R°R ⊆ R. •Since R°R does not introduce any pairs that are not already in R, it must also be true that (R°R)°R ⊆ R, and so on, so that Rn ⊆ R.
  • 35. Fall 2002 CMSC 203 - Discrete Structures 35 n-ary Relations •In order to study an interesting application of relations, namely databases, we first need to generalize the concept of binary relations to n-ary relations. •Definition: Let A1, A2, …, An be sets. An n-ary relation on these sets is a subset of A1×A2×…×An. •The sets A1, A2, …, An are called the domains of the relation, and n is called its degree.
  • 36. Fall 2002 CMSC 203 - Discrete Structures 36 n-ary Relations •Example: •Let R = {(a, b, c) | a = 2b ∧ b = 2c with a, b, c∈N} •What is the degree of R? •The degree of R is 3, so its elements are triples. •What are its domains? •Its domains are all equal to the set of integers. •Is (2, 4, 8) in R? •No. •Is (4, 2, 1) in R? •Yes.
  • 37. Fall 2002 CMSC 203 - Discrete Structures 37 Databases and Relations •Let us take a look at a type of database representation that is based on relations, namely the relational data model. •A database consists of n-tuples called records, which are made up of fields. •These fields are the entries of the n-tuples. •The relational data model represents a database as an n-ary relation, that is, a set of records.
  • 38. Fall 2002 CMSC 203 - Discrete Structures 38 Databases and Relations •Example: Consider a database of students, whose records are represented as 4-tuples with the fields Student Name, ID Number, Major, and GPA: •R = {(Ackermann, 231455, CS, 3.88), (Adams, 888323, Physics, 3.45), (Chou, 102147, CS, 3.79), (Goodfriend, 453876, Math, 3.45), (Rao, 678543, Math, 3.90), (Stevens, 786576, Psych, 2.99)} •Relations that represent databases are also called tables, since they are often displayed as tables.
  • 39. Fall 2002 CMSC 203 - Discrete Structures 39 Databases and Relations •A domain of an n-ary relation is called a primary key if the n-tuples are uniquely determined by their values from this domain. •This means that no two records have the same value from the same primary key. •In our example, which of the fields Student Name, ID Number, Major, and GPA are primary keys? •Student Name and ID Number are primary keys, because no two students have identical values in these fields. •In a real student database, only ID Number would be a primary key.
  • 40. Fall 2002 CMSC 203 - Discrete Structures 40 Databases and Relations •In a database, a primary key should remain one even if new records are added. •Therefore, we should use a primary key of the intension of the database, containing all the n-tuples that can ever be included in our database. •Combinations of domains can also uniquely identify n-tuples in an n-ary relation. •When the values of a set of domains determine an n-tuple in a relation, the Cartesian product of these domains is called a composite key.
  • 41. Fall 2002 CMSC 203 - Discrete Structures 41 Databases and Relations •We can apply a variety of operations on n-ary relations to form new relations. •Definition: The projection Pi1, i2, …, im maps the n-tuple (a1, a2, …, an) to the m-tuple (ai1 , ai2 , …, aim ), where m ≤ n. •In other words, a projection Pi1, i2, …, im keeps the m components ai1 , ai2 , …, aim of an n-tuple and deletes its (n – m) other components. •Example: What is the result when we apply the projection P2,4 to the student record (Stevens, 786576, Psych, 2.99) ? •Solution: It is the pair (786576, 2.99).
  • 42. Fall 2002 CMSC 203 - Discrete Structures 42 Databases and Relations •In some cases, applying a projection to an entire table may not only result in fewer columns, but also in fewer rows. •Why is that? •Some records may only have differed in those fields that were deleted, so they become identical, and there is no need to list identical records more than once.
  • 43. Fall 2002 CMSC 203 - Discrete Structures 43 Databases and Relations •We can use the join operation to combine two tables into one if they share some identical fields. •Definition: Let R be a relation of degree m and S a relation of degree n. The join Jp(R, S), where p ≤ m and p ≤ n, is a relation of degree m + n – p that consists of all (m + n – p)-tuples (a1, a2, …, am-p, c1, c2, …, cp, b1, b2, …, bn-p), where the m-tuple (a1, a2, …, am-p, c1, c2, …, cp) belongs to R and the n-tuple (c1, c2, …, cp, b1, b2, …, bn-p) belongs to S.
  • 44. Fall 2002 CMSC 203 - Discrete Structures 44 Databases and Relations •In other words, to generate Jp(R, S), we have to find all the elements in R whose p last components match the p first components of an element in S. •The new relation contains exactly these matches, which are combined to tuples that contain each matching field only once.
  • 45. Fall 2002 CMSC 203 - Discrete Structures 45 Databases and Relations •Example: What is J1(Y, R), where Y contains the fields Student Name and Year of Birth, •Y = {(1978, Ackermann), (1972, Adams), (1917, Chou), (1984, Goodfriend), (1982, Rao), (1970, Stevens)}, •and R contains the student records as defined before ?
  • 46. Fall 2002 CMSC 203 - Discrete Structures 46 Databases and Relations •Solution: The resulting relation is: • {(1978, Ackermann, 231455, CS, 3.88), (1972, Adams, 888323, Physics, 3.45), (1917, Chou, 102147, CS, 3.79), (1984, Goodfriend, 453876, Math, 3.45), (1982, Rao, 678543, Math, 3.90), (1970, Stevens, 786576, Psych, 2.99)} •Since Y has two fields and R has four, the relation J1(Y, R) has 2 + 4 – 1 = 5 fields.
  • 47. Fall 2002 CMSC 203 - Discrete Structures 47 Representing Relations •We already know different ways of representing relations. We will now take a closer look at two ways of representation: Zero-one matrices and directed graphs. •If R is a relation from A = {a1, a2, …, am} to B = {b1, b2, …, bn}, then R can be represented by the zero- one matrix MR = [mij] with •mij = 1, if (ai, bj)∈R, and •mij = 0, if (ai, bj)∉R. •Note that for creating this matrix we first need to list the elements in A and B in a particular, but arbitrary order.
  • 48. Fall 2002 CMSC 203 - Discrete Structures 48 Representing Relations •Example: How can we represent the relation R = {(2, 1), (3, 1), (3, 2)} as a zero-one matrix? •Solution: The matrix MR is given by           = 11 01 00 RM
  • 49. Fall 2002 CMSC 203 - Discrete Structures 49 Representing Relations •What do we know about the matrices representing a relation on a set (a relation from A to A) ? •They are square matrices. •What do we know about matrices representing reflexive relations? •All the elements on the diagonal of such matrices Mref must be 1s.                     = 1 . . . 1 1 refM
  • 50. Fall 2002 CMSC 203 - Discrete Structures 50 Representing Relations •What do we know about the matrices representing symmetric relations? •These matrices are symmetric, that is, MR = (MR)t .             = 1101 1001 0010 1101 RM symmetric matrix,symmetric matrix, symmetric relation.symmetric relation.             = 0011 0011 0011 0011 RM non-symmetric matrix,non-symmetric matrix, non-symmetric relation.non-symmetric relation.
  • 51. Fall 2002 CMSC 203 - Discrete Structures 51 Representing Relations •The Boolean operations join and meet (you remember?) can be used to determine the matrices representing the union and the intersection of two relations, respectively. •To obtain the join of two zero-one matrices, we apply the Boolean “or” function to all corresponding elements in the matrices. •To obtain the meet of two zero-one matrices, we apply the Boolean “and” function to all corresponding elements in the matrices.
  • 52. Fall 2002 CMSC 203 - Discrete Structures 52 Representing Relations •Example: Let the relations R and S be represented by the matrices           =∨=∪ 011 111 101 SRSR MMM           = 001 110 101 SM What are the matrices representing RWhat are the matrices representing R∪∪S and RS and R∩∩S?S? Solution:Solution: These matrices are given byThese matrices are given by           =∧=∩ 000 000 101 SRSR MMM           = 010 001 101 RM
  • 53. Fall 2002 CMSC 203 - Discrete Structures 53 Representing Relations Using Matrices •Example: How can we represent the relation R = {(2, 1), (3, 1), (3, 2)} as a zero-one matrix? •Solution: The matrix MR is given by           = 11 01 00 RM
  • 54. Fall 2002 CMSC 203 - Discrete Structures 54 Representing Relations Using Matrices •Example: Let the relations R and S be represented by the matrices           =∨=∪ 011 111 101 SRSR MMM           = 001 110 101 SM What are the matrices representing RWhat are the matrices representing R∪∪S and RS and R∩∩S?S? Solution:Solution: These matrices are given byThese matrices are given by           =∧=∩ 000 000 101 SRSR MMM           = 010 001 101 RM
  • 55. Fall 2002 CMSC 203 - Discrete Structures 55 Representing Relations Using Matrices Do you remember theDo you remember the Boolean productBoolean product of two zero-one matrices?of two zero-one matrices? Let A = [aLet A = [aijij] be an m] be an m××k zero-one matrix andk zero-one matrix and B = [bB = [bijij] be a k] be a k××n zero-one matrix.n zero-one matrix. Then theThen the Boolean productBoolean product of A and B, denoted by Aof A and B, denoted by AοοB, is the mB, is the m××n matrix with (i,n matrix with (i, j)th entry [cj)th entry [cijij], where], where ccijij = (a= (ai1i1 ∧∧ bb1j1j)) ∨∨ (a(ai2i2 ∧∧ bb2i2i)) ∨∨ …… ∨∨ (a(aikik ∧∧ bbkjkj).). ccijij = 1 if and only if at least one of the terms= 1 if and only if at least one of the terms (a(ainin ∧∧ bbnjnj) = 1 for some n; otherwise c) = 1 for some n; otherwise cijij = 0.= 0.
  • 56. Fall 2002 CMSC 203 - Discrete Structures 56 Representing Relations Using Matrices Let us now assume that the zero-one matricesLet us now assume that the zero-one matrices MMAA = [a= [aijij], M], MBB = [b= [bijij] and M] and MCC = [c= [cijij] represent relations A, B, and C, respectively.] represent relations A, B, and C, respectively. Remember:Remember: For MFor MCC = M= MAAοοMMBB we have:we have: ccijij = 1 if and only if at least one of the terms= 1 if and only if at least one of the terms (a(ainin ∧∧ bbnjnj) = 1 for some n; otherwise c) = 1 for some n; otherwise cijij = 0.= 0. In terms of theIn terms of the relationsrelations, this means that C contains a pair (x, this means that C contains a pair (xii, z, zjj) if and only if there) if and only if there is an element yis an element ynn such that (xsuch that (xii, y, ynn) is in relation A and) is in relation A and (y(ynn, z, zjj) is in relation B.) is in relation B. Therefore, C = BTherefore, C = B°°A (A (compositecomposite of A and B).of A and B).
  • 57. Fall 2002 CMSC 203 - Discrete Structures 57 Representing Relations Using Matrices This gives us the following rule:This gives us the following rule: MMBB°°AA = M= MAAοοMMBB In other words, the matrix representing theIn other words, the matrix representing the compositecomposite of relations A and B is theof relations A and B is the Boolean productBoolean product of the matrices representing A and B.of the matrices representing A and B. Analogously, we can find matrices representing theAnalogously, we can find matrices representing the powers of relationspowers of relations:: MMRRnn = M= MRR [n][n] (n-th(n-th Boolean powerBoolean power).).
  • 58. Fall 2002 CMSC 203 - Discrete Structures 58 Representing Relations Using Matrices •Example: Find the matrix representing R2 , where the matrix representing R is given by           = 001 110 010 RM Solution:Solution: The matrix for RThe matrix for R22 is given byis given by           == 010 111 110 ]2[ 2 RR MM
  • 59. Fall 2002 CMSC 203 - Discrete Structures 59 Representing Relations Using Digraphs •Definition: A directed graph, or digraph, consists of a set V of vertices (or nodes) together with a set E of ordered pairs of elements of V called edges (or arcs). •The vertex a is called the initial vertex of the edge (a, b), and the vertex b is called the terminal vertex of this edge. •We can use arrows to display graphs.
  • 60. Fall 2002 CMSC 203 - Discrete Structures 60 Representing Relations Using Digraphs •Example: Display the digraph with V = {a, b, c, d}, E = {(a, b), (a, d), (b, b), (b, d), (c, a), (c, b), (d, b)}. aa bb ccdd An edge of the form (b, b) is called aAn edge of the form (b, b) is called a loop.loop.
  • 61. Fall 2002 CMSC 203 - Discrete Structures 61 Representing Relations Using Digraphs •Obviously, we can represent any relation R on a set A by the digraph with A as its vertices and all pairs (a, b)∈R as its edges. •Vice versa, any digraph with vertices V and edges E can be represented by a relation on V containing all the pairs in E. •This one-to-one correspondence between relations and digraphs means that any statement about relations also applies to digraphs, and vice versa.
  • 62. Fall 2002 CMSC 203 - Discrete Structures 62 Equivalence Relations •Equivalence relations are used to relate objects that are similar in some way. •Definition: A relation on a set A is called an equivalence relation if it is reflexive, symmetric, and transitive. •Two elements that are related by an equivalence relation R are called equivalent.
  • 63. Fall 2002 CMSC 203 - Discrete Structures 63 Equivalence Relations •Since R is symmetric, a is equivalent to b whenever b is equivalent to a. •Since R is reflexive, every element is equivalent to itself. •Since R is transitive, if a and b are equivalent and b and c are equivalent, then a and c are equivalent. •Obviously, these three properties are necessary for a reasonable definition of equivalence.
  • 64. Fall 2002 CMSC 203 - Discrete Structures 64 Equivalence Relations •Example: Suppose that R is the relation on the set of strings that consist of English letters such that aRb if and only if l(a) = l(b), where l(x) is the length of the string x. Is R an equivalence relation? •Solution: • R is reflexive, because l(a) = l(a) and therefore aRa for any string a. • R is symmetric, because if l(a) = l(b) then l(b) = l(a), so if aRb then bRa. • R is transitive, because if l(a) = l(b) and l(b) = l(c), then l(a) = l(c), so aRb and bRc implies aRc. •R is an equivalence relation.
  • 65. Fall 2002 CMSC 203 - Discrete Structures 65 Equivalence Classes •Definition: Let R be an equivalence relation on a set A. The set of all elements that are related to an element a of A is called the equivalence class of a. •The equivalence class of a with respect to R is denoted by [a]R. •When only one relation is under consideration, we will delete the subscript R and write [a] for this equivalence class. •If b∈[a]R, b is called a representative of this equivalence class.
  • 66. Fall 2002 CMSC 203 - Discrete Structures 66 Equivalence Classes •Example: In the previous example (strings of identical length), what is the equivalence class of the word mouse, denoted by [mouse] ? •Solution: [mouse] is the set of all English words containing five letters. •For example, ‘horse’ would be a representative of this equivalence class. •
  • 67. Fall 2002 CMSC 203 - Discrete Structures 67 Equivalence Classes •Theorem: Let R be an equivalence relation on a set A. The following statements are equivalent: • aRb • [a] = [b] • [a] ∩ [b] ≠ ∅ •Definition: A partition of a set S is a collection of disjoint nonempty subsets of S that have S as their union. In other words, the collection of subsets Ai, i∈I, forms a partition of S if and only if (i) Ai ≠ ∅ for i∈I • Ai ∩ Aj = ∅, if i ≠ j • ∪i∈I Ai = S
  • 68. Fall 2002 CMSC 203 - Discrete Structures 68 Equivalence Classes •Examples: Let S be the set {u, m, b, r, o, c, k, s}. Do the following collections of sets partition S ? {{m, o, c, k}, {r, u, b, s}}{{m, o, c, k}, {r, u, b, s}} yes.yes. {{c, o, m, b}, {u, s}, {r}}{{c, o, m, b}, {u, s}, {r}} no (k is missing).no (k is missing). {{b, r, o, c, k}, {m, u, s, t}}{{b, r, o, c, k}, {m, u, s, t}} no (t is not in S).no (t is not in S). {{u, m, b, r, o, c, k, s}}{{u, m, b, r, o, c, k, s}} yes.yes. {{b, o, o, k}, {r, u, m}, {c, s}}{{b, o, o, k}, {r, u, m}, {c, s}} yes ({b,o,o,k} = {b,o,k}).yes ({b,o,o,k} = {b,o,k}). {{u, m, b}, {r, o, c, k, s},{{u, m, b}, {r, o, c, k, s}, ∅∅}} no (no (∅∅ not allowed).not allowed).
  • 69. Fall 2002 CMSC 203 - Discrete Structures 69 Equivalence Classes •Theorem: Let R be an equivalence relation on a set S. Then the equivalence classes of R form a partition of S. Conversely, given a partition {Ai | i∈I} of the set S, there is an equivalence relation R that has the sets Ai, i∈I, as its equivalence classes.
  • 70. Fall 2002 CMSC 203 - Discrete Structures 70 Equivalence Classes •Example: Let us assume that Frank, Suzanne and George live in Boston, Stephanie and Max live in Lübeck, and Jennifer lives in Sydney. •Let R be the equivalence relation {(a, b) | a and b live in the same city} on the set P = {Frank, Suzanne, George, Stephanie, Max, Jennifer}. •Then R = {(Frank, Frank), (Frank, Suzanne), (Frank, George), (Suzanne, Frank), (Suzanne, Suzanne), (Suzanne, George), (George, Frank), (George, Suzanne), (George, George), (Stephanie, Stephanie), (Stephanie, Max), (Max, Stephanie), (Max, Max), (Jennifer, Jennifer)}.
  • 71. Fall 2002 CMSC 203 - Discrete Structures 71 Equivalence Classes •Then the equivalence classes of R are: •{{Frank, Suzanne, George}, {Stephanie, Max}, {Jennifer}}. •This is a partition of P. •The equivalence classes of any equivalence relation R defined on a set S constitute a partition of S, because every element in S is assigned to exactly one of the equivalence classes.
  • 72. Fall 2002 CMSC 203 - Discrete Structures 72 Equivalence Classes •Another example: Let R be the relation {(a, b) | a ≡ b (mod 3)} on the set of integers. •Is R an equivalence relation? •Yes, R is reflexive, symmetric, and transitive. •What are the equivalence classes of R ? •{{…, -6, -3, 0, 3, 6, …}, {…, -5, -2, 1, 4, 7, …}, {…, -4, -1, 2, 5, 8, …}}
  • 74. 74 Definition of Functions • Given any sets A, B, a function f from (or “mapping”) A to B (f:A→B) is an assignment of exactly one element f(x)∈B to each element x∈A.
  • 75. 75 Graphical Representations • Functions can be represented graphically in several ways: • • A B a b f f • • • • • • • • • x y Plot Graph Like Venn diagrams A B
  • 76. 76 Definition of Functions (cont’d) • Formally: given f:A→B “x is a function” :≡ (¬∃x,y: x=y ∧ f(x) ≠ f(y)) or “x is a function” :≡ (∀ x,y: ¬(x=y) ∨ ¬(f(x) ≠ f(y))) or “x is a function” :≡ (∀ x,y: ¬(x=y) ∨ (f(x) = f(y))) or “x is a function” :≡ (∀ x,y: (x=y) → (f(x) = f(y))) or “x is a function” :≡ (∀ x,y: (f(x) ≠ f(y)) → (x ≠ y))
  • 77. 77 Some Function Terminology • If f:A→B, and f(a)=b (where a∈A & b∈B), then: – A is the domain of f. – B is the codomain of f. – b is the image of a under f. – a is a pre-image of b under f. • In general, b may have more than one pre-image. – The range R⊆B of f is {b | ∃a f(a)=b }.
  • 78. 78 Function Addition/Multiplication • We can add and multiply functions f,g:R→R: – (f + g):R→R, where (f + g)(x) = f(x) + g(x) – (f × g):R→R, where (f × g)(x) = f(x) × g(x)
  • 79. 79 Function Composition • For functions g:A→B and f:B→C, there is a special operator called compose (“○”). – It composes (i.e., creates) a new function out of f,g by applying f to the result of g. (f○g):A→C, where (f○g)(a) = f(g(a)). – Note g(a)∈B, so f(g(a)) is defined and ∈C. – The range of g must be a subset of f’s domain!! – Note that ○ (like Cartesian ×, but unlike +,∧,∪) is non-commuting. (In general, f○g ≠ g○f.)
  • 81. 81 Images of Sets under Functions • Given f:A→B, and S⊆A, • The image of S under f is simply the set of all images (under f) of the elements of S. f(S) :≡ {f(s) | s∈S} :≡ {b | ∃ s∈S: f(s)=b}. • Note the range of f can be defined as simply the image (under f) of f’s domain!
  • 82. 82 One-to-One Functions • A function is one-to-one (1-1), or injective, or an injection, iff every element of its range has only one pre- image. • Only one element of the domain is mapped to any given one element of the range. – Domain & range have same cardinality. What about codomain?
  • 83. 83 One-to-One Functions (cont’d) • Formally: given f:A→B “x is injective” :≡ (¬∃x,y: x≠y ∧ f(x)=f(y)) or “x is injective” :≡ (∀ x,y: ¬(x≠y) ∨ ¬(f(x)=f(y))) or “x is injective” :≡ (∀ x,y: ¬(x≠y) ∨ (f(x) ≠ f(y))) or “x is injective” :≡ (∀ x,y: (x≠y) → (f(x) ≠ f(y))) or “x is injective” :≡ (∀ x,y: (f(x)=f(y)) → (x =y))
  • 84. 84 One-to-One Illustration • Graph representations of functions that are (or not) one-to-one: • • • • • • • • • One-to-one • • • • • • • • • Not one-to-one • • • • • • • • • Not even a function!
  • 85. 85 Sufficient Conditions for 1- 1ness • Definitions (for functions f over numbers): – f is strictly (or monotonically) increasing iff x>y → f(x)>f(y) for all x,y in domain; – f is strictly (or monotonically) decreasing iff x>y → f(x)<f(y) for all x,y in domain; • If f is either strictly increasing or strictly decreasing, then f is one-to-one. – e.g. f(x)=x3
  • 86. 86 Onto (Surjective) Functions • A function f:A→B is onto or surjective or a surjection iff its range is equal to its codomain (∀b∈B, ∃a∈A: f(a)=b). • An onto function maps the set A onto (over, covering) the entirety of the set B, not just over a piece of it. – e.g., for domain & codomain R, x3 is onto, whereas x2 isn’t. (Why not?)
  • 87. 87 Illustration of Onto • Some functions that are or are not onto their codomains: Onto (but not 1-1) • • • • • • • • • Not Onto (or 1-1) • • • • • • • • • Both 1-1 and onto • • • • • • • • 1-1 but not onto • • • • • • • • •
  • 88. 88 Bijections • A function f is a one-to-one correspondence, or a bijection, or reversible, or invertible, iff it is both one- to-one and onto.
  • 89. 89 Inverse of a Function • For bijections f:A→B, there exists an inverse of f, written f −1 :B→A, which is the unique function such that: Iff =− 1
  • 90. 90 Inverse of a function (cont’d)
  • 91. 91 The Identity Function • For any domain A, the identity function I:A→A (variously written, IA, 1, 1A) is the unique function such that ∀a∈A: I(a)=a. • Some identity functions you’ve seen: ∧ing with T, ∨ing with F, ∪ing with ∅, ∩ing with U. • Note that the identity function is both one- to-one and onto (bijective).
  • 92. 92 • The identity function: Identity Function Illustrations • • • • • • • • • Domain and range x y
  • 93. 93 Graphs of Functions • We can represent a function f:A→B as a set of ordered pairs {(a,f(a)) | a∈A}. • Note that ∀a, there is only one pair (a, f(a)). • For functions over numbers, we can represent an ordered pair (x,y) as a point on a plane. A function is then drawn as a curve (set of points) with only one y for each x.
  • 95. 95 A Couple of Key Functions • In discrete math, we frequently use the following functions over real numbers: x (“floor of x”) is the largest integer ≤ x. x (“ceiling of x”) is the smallest integer ≥ x.
  • 96. 96 Visualizing Floor & Ceiling • Real numbers “fall to their floor” or “rise to their ceiling.” • Note that if x∉Z, −x ≠ − x & −x ≠ − x • Note that if x∈Z, x = x = x. 0 −1 1 2 3 −2 −3 . . . . . . . . . 1.6 1.6=2 −1.4= −2 −1.4 −1.4= −1 1.6=1 −3 −3=−3= −3
  • 97. 97 Plots with floor/ceiling: Example • Plot of graph of function f(x) = x/3: x f(x) Set of points (x, f(x)) +3 −2 +2 −3