Upcoming SlideShare
×

# Tr1413 set_theory

691 views
603 views

Published on

Published in: Technology
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
691
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
9
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Tr1413 set_theory

1. 1. TR1413: DiscreteMathematics For Computer Science Lecture 22: Set Theory
2. 2. Introduction• 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.
3. 3. Sets• Set = a collection of distinct unordered objects• Members of a set are called elements• How to determine a set – Listing: • Example: A = {1,3,5,7} – Description • Example: B = {x | x = 2k + 1, 0 < k < 3}
4. 4. Empty set• The empty set ∅ or { } has no elements. Also called null set or void set.
5. 5. Universal 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}
6. 6. Cardinality• 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)
7. 7. Subsets• 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
8. 8. Subsets• X is a proper subset of Y (in symbol X ⊂ Y) if X ⊆ Y but X ≠ Y.
9. 9. Equality Equality: X = Y if X ⊆ Y and Y ⊆ X
10. 10. Power 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}}
11. 11. Union• Given two sets X and Y. The union of X and Y is defined as the set X ∪ Y = { w | w ∈ X ∨ w ∈ Y}
12. 12. Intersection• 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 = ∅
13. 13. Difference• 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
14. 14. Complement The complement of a set A contained in a universal set U is the set Ac = U – A In symbols Ac = U - A
15. 15. Cartesian 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}
16. 16. Binary 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
17. 17. Domain and rangeGiven 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}
18. 18. Domain and rangeGiven 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}
19. 19. Inverse 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 }
20. 20. Relation 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)∊ R1 and (y,z) ∊ R2 for some y ∊ Y}
21. 21. Relation 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)}
22. 22. Domain 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)}
23. 23. Range 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)}
24. 24. Functions• 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 o dom(f) = X o 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.
25. 25. Functions– 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.
26. 26. Functions• Example: Dom(f) = X = {a, b, c, d}, Rng(f) = {1, 3, 5} f(a) = f(b) = 3, f(c) = 5, f(d) = 1.
27. 27. One-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.
28. 28. One-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.
29. 29. Onto 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.
30. 30. Bijective functions• A function f : X→ Y is bijective ⇔ f is one-to-one and onto
31. 31. Types 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
32. 32. Inverse 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.
33. 33. Composition 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.
34. 34. Composition of functions Composition of functions is associative: f ◦ (g ◦h) = (f ◦ g) ◦ h, But, in general, it is not commutative: f ◦ g ≠ g ◦ f.
35. 35. Override• 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)}