tr1413 set_theory
Post on 17-Jan-2015
666 Views
Preview:
DESCRIPTION
TRANSCRIPT
TR1413: Discrete TR1413: Discrete Mathematics For Computer Mathematics For Computer
ScienceScience
Lecture 22: Set TheoryLecture 22: Set Theory
IntroductionIntroduction• Z formal specification notation is
based on set. • Everything in Z is actually a set.• So it is important for us to
understand the concept of sets and set theory.
SetsSets
• 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}
– Description• Example: B = {x | x = 2k + 1, 0 < k < 3}
Empty setEmpty set
• The empty set or { } has no elements.
Also called null set or void set.
Universal setUniversal 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}
CardinalityCardinality
• Cardinality of a set A (in symbols |A| or #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)
SubsetsSubsets
• X is a subset of Y if every element of X is also contained in Y
(in symbols X Y)
• Observation: is a subset of every set. So for any set X, X
• Observation: A set is always a subset to itself, i.e . X X
SubsetsSubsets
• X is a proper subset of Y (in symbol X Y) if X Y but X Y.
EqualityEquality
Equality: X = Y if X Y and Y X
Power setPower set
• The power set of X is the set of all subsets of X, in symbols P(X),– i.e. P(X)= {A | A X}– Example: if X = {1, 2, 3},
then P(X) = {, {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}}
UnionUnion
• Given two sets X and Y. The union of X and Y is defined as the set
X Y = { w | w X w Y}
IntersectionIntersection
• Given two sets X and Y. The intersection of X and Y is defined as the set
X Y = { w | w X w Y}• Two sets X and Y are disjoint if X Y =
DifferenceDifference
• The difference of two sets
X – Y = { w | w X and w Y}
The difference is also called the relative complement of Y in X
ComplementComplement
The complement of a set A contained in a universal set U is the set Ac = U – A In symbols Ac = U - A
Cartesian ProductCartesian Product
• Given two sets X and B, its Cartesian product X x Y is the set of all ordered pairs (x,y) where x X and y Y
• In symbols X x Y = {(x, y) | x X and y Y}
Binary RelationBinary Relation
• A binary relation R from a set X to a set Y is a subset of the Cartesian product X x Y– Example: X = {1, 2, 3} and Y = {a, b}– R = {(1,a), (1,b), (2,b), (3,a)} is a relation between X
and Y
Domain and rangeDomain and range
Given a relation R from X to Y,• The domain of R is the set
– Dom(R) = { x X | (x, y) R for some y Y}
• The range of R is the set– Rng(R) = { y Y | (x, y) R for some x X}
Domain and rangeDomain and range
Given a relation R from X to Y,• Example:
– if X = {1, 2, 3} and Y = {a, b}
– R = {(1,a), (1,b), (2,b)}
– Then: • Dom(R)= {1, 2}
• Rng(R) = (a, b}
Inverse of a relationInverse of a relation
• Given a relation R from X to Y, its inverse R-1 is the relation from Y to X defined by
R-1 = { (y,x) | (x,y) R }
Relation CompositionRelation Composition• Let R1 be a relation from X to Y and R2 be a
relation from Y to Z. The composition of R1 and R2, denoted as R1 ◦ R2 is the relation from X to Z defined by
R1 ◦ R2 = {(x,z) | (x,y) R∊ 1 and (y,z) R∊ 2 for some y Y}∊
Relation CompositionRelation Composition
• Example:– R1 = {(1,2),(1,6),(2,4),(3,4),(3,6),(3,8)}
– R2 = {(2,u),(4,s),(4,t),(6,t),(8,u)}
– R1 ◦ R2 = {(1,u),(1,t),(2,s),(2,t),(3,s),(3,t),(3,u)}
Domain RestrictionDomain Restriction• We can restrict a given relation to a
certain domain.• For example
R = {(1,2),(1,6),(2,4),(3,4),(3,6),(3,8)}
{1,2} \dres R = {(1,2),(1,6),(2,4)}
{1,2} \ndres R = {(3,4),(3,6),(3,8)}
Range RestrictionRange Restriction• We can restrict a given relation to a
certain range.• For example
R = {(1,2),(1,6),(2,4),(3,4),(3,6),(3,8)}
R \rres {2,4} = {(1,2),(2,4),(3,4)}
R \nrres {2,4} = {(1,6),(3,6),(3,8)}
FunctionsFunctions
• A special kind of relation.• A function f from X to Y (in symbols f : X Y)
is a relation from X to Y such that 1. dom(f) = X
2. if two pairs (x,y) and (x,y’) f, then y = y’
• If dom(f) ⊂ X, f is called a partial function otherwise it is called a total function.
FunctionsFunctions
– Domain of f = X
– Range of f =
{ y | y = f(x) for some x X}
– A function f : X Y assigns to each x in dom(f) = X a unique element y in rng(f) Y.
– Therefore, no two pairs in f have the same first coordinate.
FunctionsFunctions
• Example: Dom(f) = X = {a, b, c, d},
Rng(f) = {1, 3, 5}
f(a) = f(b) = 3,
f(c) = 5, f(d) = 1.
One-to-one functionsOne-to-one functions
• A function f : X Y is one-to-one (injective)
for each y Y there exists at most one x X with f(x) = y.
One-to-one functionsOne-to-one functions
• Alternative definition: f : X Y is one-to-one for each pair of distinct elements x1, x2 X there exist two distinct elements y1, y2 Y such that f(x1) = y1 and f(x2) = y2.
Onto functionsOnto functions
• A function f : X Y is onto (surjective)
for each y Y there exists at least one x X with f(x) = y, i.e. rng(f) = Y.
Bijective functionsBijective functions
• A function f : X Y is bijective
f is one-to-one and onto
Types of FunctionsTypes of Functions• Partial Function• Total Function• Injective (one-to-one)
– Partial injective– Total injective
• Surjective (onto)– Partial surjective– Total surjective
• Bijective– Partial bijective– Total bijective
Inverse functionInverse function
• Given a function y = f(x), the inverse f -1 is the set {(y, x) | y = f(x)}.
• The inverse f -1 of f is not necessarily a function.
• However, if f is a bijective function, it can be shown that f -1 is a function.
Composition of functionsComposition of functions
• Given two functions g : X Y and f : Y Z, the composition f ◦ g is defined as follows:
f ◦ g (x) = f(g(x)) for every x X.
Composition of functionsComposition of functions
Composition of functions is associative:
f ◦ (g ◦h) = (f ◦ g) ◦ h, But, in general, it is not commutative:
f ◦ g g ◦ f.
OverrideOverride• We can replace elements in a function
with new elements.• Example:
f = {(1,a),(2,a),(3,b),(4,c)}
f \override {(2,b),(3,a),(5,a)}
={(1,a),(2,b),(3,a),(4,c),(5,a)}
top related