1 / 35

Sets and relations Reading: Chapter 5 (72-93) from the text book

Sets and relations Reading: Chapter 5 (72-93) from the text book. Sets. We’ll look briefly at the main ideas of sets Our intention is to introduce terminology & notation that will be useful later The term set means a collection of items The items are called the elements of the set

prema
Download Presentation

Sets and relations Reading: Chapter 5 (72-93) from the text book

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sets and relationsReading: Chapter 5 (72-93) from the text book

  2. Sets • We’ll look briefly at the main ideas of sets • Our intention is to introduce terminology & notation that will be useful later • The term setmeans a collection of items • The items are called the elementsof the set • A set can be described in 2 ways – 1. in enumerated form (i.e. as a list) 2. in predicate form (i.e. using a property that defines the elements of the set)

  3. Examples of Enumerated Sets • the set of summer months is {June, July, August} note the use of braces(‘curly brackets’) for sets • the set of positive even numbers less than 10 is {2, 4, 6, 8} • the set of positive even numbers less than 100 is {2, 4, 6, 8, …, 98} – an ellipsis (3 dots) is used if there is a clear pattern • the set of positive even numbers is {2, 4, 6, 8, …}

  4. Examples of Sets in predicate form • The set of positive even numbers less than 100 can be written in predicate form as {x: x is even and 0 < x < 100} • This definition is read as ‘the set of all x such that x is even and 0 < x < 100’ • Sets are usually denoted by capital letters e.g.A = {2, 4, 6, 8},B = {x: x is a pos. even no.} • The symbols ∈ and ∉ mean ‘is an element of’ and ‘is not an element of’, respectively • e.g.6 ∈ A, 120 ∈ B, 7 ∉ A

  5. Symbols for Special Sets • Special symbols are used for certain sets of nos: N= set of natural numbers = {1, 2, 3, 4, …} J= set of integers = {…, –3, –2, –1, 0, 1, 2, 3,…} Q= set of rationalnos = {x: x = m/n for some integersm andn withn ≠ 0} R= set of all real nos ∅ = the null set or empty set. It has no elements, & may be written as { } or even as {x: x = x + 1} (any predicate that is always false can be used)

  6. The Universal Set • The universal set, denoted by U, contains all elements that could be under discussion in a particular situation • U changes according to circumstances • e.g. If we’re dealing with months of the year, U = {January, February, March, …, December} If we’re dealing with numbers, U might be R(the set of all real nos)

  7. Subsets, Set Operations andVenn Diagrams • If A& B are sets so that every element of Bis an element of A, Bis a subsetof A(written B ⊆ A) • e.g.A = {1,2,3,4}, B = {1,3,4}, C = {4,5,6}. Then B ⊆ A, but C is not a subset of A. • In a picture:

  8. Venn Diagrams • A picture such as in the previous slide is called a Venn diagram • Venn diagrams were introduced by John Venn, who used them in his book Symbolic Logic (1881) to illustrate principles of logic • Venn diagrams are easy to use for 2 or 3 sets. • For more than 3 sets, the diagrams become quite complicated and are not so easy to use.

  9. Properties of Sets • Recall: If every element of Bis an element of A, Bis a subsetof A, written as B ⊆ A • Thus, for any set A, it is true that A ⊆ A • Also, for any set A, it is true that ∅ ⊆ A i.e.we can’t find an element of ∅ which isn’t in A • Two sets Aand Bare equalif A ⊆ B and B ⊆ A Thus 2 sets are equal if they have the same elts • So the orderof listing elts is immaterial e.g. {1, 2, 3} = {2, 1, 3} – & there’s no reason to list an elt more than once – e.g.{1, 2, 1} = {1, 2}

  10. Set Operations • The intersectionof 2 sets A and B is A ∩ B = {x: x ∈ A and x ∈ B} • 2 sets A and B are disjointif A ∩ B = ∅ (i.e. if the sets have no elements in common) • The unionof 2 sets A and B is A ∪ B = {x: x ∈ A or x ∈ B} where ‘or’ means the inclusive‘or’ • The complementof a set A consists of all the elements of the universal set that are not in A. i.e. = {x : x ∈U and x ∉ A}

  11. Set Operations • The differenceof 2 sets A and B is A – B = {x: x ∈ A and x ∉ B} A – B is shaded in red • Note that A − B = A ∩ • This can be shown using the defns of set operations, or by using Venn diagrams

  12. Example Suppose E = {a, b, c, d, e, f, g, h, i, j}, A = {a, b, c, d, e, f, g}, B = {b, d, f, i, j}, C = {a, c, f, j}. Find: (i) A ∪ C (ii) A ∩ B (iii) A∩ C (iv) (B ∩ A) ∪ C (v) A ∪(C ∩ B)

  13. Laws of Sets

  14. Verifying and Using the Laws of Sets • All the laws of sets can be verified • Another way of verifying the laws is to use Venn diagrams • Example: Use Venn diagrams to illustrate the 2nd de Morgan’s law for sets • The laws of sets can be used to simplify a given set (just as we will use the laws of Algebra to simplify a given algebraic expression) • Example: Use laws of sets to simplify

  15. The Power Set • Suppose A = {a, b}. The subsets of A are ∅, {a}, {b} & {a, b} • The set of these subsets is called the powersetof A, denoted by P (A) i.e. P(A) = {∅, {a}, {b}, {a, b}} • Note that P(A) is a set whose elements are themselves sets – i.e. it is a set of sets • Also note that A has 2 elements, & P(A) has 4 elements • Exercise: If A = {a, b, c}, write down P(A)

  16. Cardinality of the Power Set • The cardinalityof a finite set Ais the no. of elements in the set, written as | A | • Example: If A = {a, b, c}, then | A | = 3 • Observe that A has 3 elements, & P(A) has 8 elements • This leads to the general observation: If A has n elements, then P(A) has 2nelements i.e. if | A | = n, then |P(A) | = 2n • Then a set with nelements has 2nsubsets

  17. Ordered Pairs • When dealing with sets, the ordering of elements in the set is immaterial – e.g.{2, 1, 4} = {1, 4, 2} • Sometimes, though, orderdoes matter e.g.: (i) a list of place-getters in a race, or a list of football teams in order of leader position; (ii) an ordered string of characters such as a tax file no., password, credit card PIN or car reg. no. • An ordered pair is a pair of elements in a particular order, written as (a, b)

  18. Ordered n-tuples • Thus the ordered pair (3, 5) is differentto (5, 3) • Note the use of parentheses(‘round brackets’), and not braces (‘curly brackets’) as for sets • If we have nelements, an ordered n-tuple is a list of the n elements in a particular order – it is written as (x1, x2, x3,…, xn) • Since order is important, the only way for (x1, x2, x3,…, xn) = (y1, y2, y3,…, yn) is if the 1st elements are the same (i.e. x1 = y1), the 2nd elements are the same (i.e. x2 = y2), and so on • So (1, 4, 5) ≠ (1, 5, 4) (but {1, 4, 5} = {1, 5, 4})

  19. The Cartesian Product of 2 Sets • The Cartesian product of 2 sets Aand Bis A × B = {(x, y): x ∈ A and y ∈ B} i.e. It is the set of all ordered pairs, where the first element is from A& the second element is from B • e.g. If A is the set of digits 0-9, & B is the set of letters a-z, then (3, t) is in A × B, but (m, 7) is not in A × B – although it is in B × A • e.g. If A = {1, 2, 3} & B = {p, q}, then A × B = {(x, y): x ∈ A and y ∈ B} = {(1, p), (1, q), (2, p), (2, q), (3, p), (3, q)}

  20. The Cartesian Product of n Sets • The Cartesian product of n sets A1, A2,…, Anis A1 × A2 ×… × An= {(x1, x2, x3,…, xn): x1 ∈ A1, x2 ∈ A2, …, xn∈ An} • i.e. It is the set of all ordered n-tuples, where the 1st elt is from A1, the 2nd elt is from A2,etc • e.g. A car reg. no. such as KCT454 can be regarded as an ordered 6-tuple (K, C, T, 4, 5,4). • If L is the set of all letters, & D is the set of all decimal digits, then the set of all possible car registration nos is L × L × L × D × D × D

  21. Cartesian Product of a Set with Itself • The set A × A ×… × A (n times) is written as An • e.g. If Ris the set of real nos, then R2 is the set of all ordered pairs (x, y),where x& y are real nos – geometrically, R2 is the 2-dimensional plane • Similarly, think of R3 as all points in 3-dim space

  22. Cartesian Product of a Set with Itself • e.g.{0, 1}2 = {(0, 0), (0, 1), (1, 0), (1, 1)} • e.g. The elements of {0, 1}nare ordered n-tuples in which each element is 0 or 1 – so a typical element of {0, 1}6is (0, 1, 1, 1, 0, 1) • Think of {0, 1}nas the set of all strings of nbits • Note that L × L × L × D × D × D = L3 × D3

  23. Computer Repn of Sets • To enable computers to handle sets, assume the elements of the universal set U are listed in a definite order. • Then, if |U| = n and Ais a set, Ais represented by a string of nbits b1b2b3…bn. • Here biis 1 if the ith elt of U is in A, and biis 0 if the ith elt of U is not in A.

  24. Computer Repn of Sets • Example: Suppose U = {a, b, c, d, e, f, g}.Find: (a) the representation of {d, f, a, g} as a bit string (b) the set represented by the bit string 0111011 • For sets defined w.r.t. the sameuniversal set, the operations of intersection, union & complement can be carried out directly on the bit strings, without having to convert to the original sets.

  25. Computer Repn of Sets • The bit string of A ∩ B has a 1 if the bit strings of A & B both have a 1, & otherwise has a 0 • This process is termed a bitwiseand operation • The bit string of A ∪ B has a 0 if the bit strings of A & B both have a 0, & otherwise has a 1 (this is a bitwise oroperation)

  26. Set Operations Using Bit Strings • The bit string for the complement of Ais obtained from that of Aby simply replacing 0 with 1, and 1 with 0 (a bitwise notoperation) • Example: Suppose the bit strings of A& B are A: 0110110101, B: 1111001001 Find the bit strings of A ∩ B, A ∪ B &

  27. Relations • A binary relation occurs when we say something about a property of an object relativeto another object of the same type • Example: The statement ‘Ali is taller than Yasir’ illustrates a relation • The word ‘binary’ refers to the fact that twoobjects are compared – in future, we’ll omit this word and refer to just a ‘relation’

  28. Examples which Illustrate Relations • Examples of statements from everyday life which illustrate relations: ‘Ali is the husband of Alia’ ‘Nadir is the sister of Nuha’ ‘Australia has a smaller population than China’ ‘Discrete Maths is a prerequisite for Encryption and Network Security’

  29. More Examples which Illustrate Relations • Examples of statements from mathematics which illustrate relations: ‘12 is greater than 4’ ‘{a} is a subset of {a, b, c}’ ‘20 is divisible by 4’ ‘Line L1 is parallel to line L2’

  30. Comments on the Examples • In each of the examples, a statement is made about a pair of objects of the same type. • The orderof the objects is often important – e.g. it is true that ‘Australia has a smaller population than China’, but it is not true that ‘China has a smaller population than Australia’ • Thus relations involve 2 objects of the same type (i.e. from the same set), where orderis important

  31. Definitions of a Relation • Informal Defn:A relationcan be thought of as a statement about ordered pairs (x, y) that are in A × A, where Ais some set. • This is the basic idea of a relation, although the formal definition looks a little different. • Formal Defn:A (binary) relation on a set Ais a subsetRof A × A. We say that x& yare related iff (x, y) ∈ R.

  32. Example • Consider the relation ‘is greater than’ on the set A = {3, 5, 6, 8}. • For any (x, y) ∈ A × A, either xis greater than y, and then x is related to y or xis not greater than y, and then x is notrelated to y. • The set of the ordered pairs (x, y) ∈ A × A, for which x is related to y is given by: R = {(5, 3), (6, 3), (8, 3), (6, 3), (6, 5), (8, 6)}

  33. Notation for a Relation • In the previous example, we can state that x& yare related by writing (x, y) ∈ R. • In practice, this is often written as xRy(read this as ‘x is related to y’). • For the previous example, we can write ‘x > y’ instead of xRy to mean that xis related to y

  34. Graphical Repn of a Relation • Example:The reln ‘>’ on the set A = {3, 5, 6, 8} can be depicted using a graph. The elements of Aare represented by dots, & if xis related to y, an arrow is drawn from x to y. The result is called a directed graph.

  35. Matrix Repn of a Relation • A relation can also be represented by a matrix (plural ‘matrices’) called the relation matrix. • The entry in row x& column yis T if xis related to y, and is F otherwise. • e.g. For ‘>’ on {3, 5, 6, 8}, the relation matrix is given by

More Related