lecture set i _ sets

Upload: bryan-asaba

Post on 08-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Lecture Set I _ Sets

    1/27

    Copyright Andrew Katumba,2011

    CMP 2201 Lecture Set I:Sets

    Andrew Katumba

  • 8/7/2019 Lecture Set I _ Sets

    2/27

    L4 2

    AgendaSets Curly brace notation { }

    Cardinality | |

    Element containment Subset containment

    Empty set{ } =

    Power set P(S ) = 2S

    N-tuples ( ) and Cartesian productv

  • 8/7/2019 Lecture Set I _ Sets

    3/27

    L4 3

    Section 1.4: Sets

    DEF: A setis a collection of elements.

    This is another example where mathematics

    must start at the level of intuition. Sets arethe basic data structure out of which mostmathematical theories are built. For manyyears mathematicians hoped that sets could

    be defined directly from logic, thus giving afull-proof foundation to Mathematics, whencompared to other sciences. Effort failed!

  • 8/7/2019 Lecture Set I _ Sets

    4/27

    L4 4

    SetsCurly braces { and } are used to denote

    sets.

    Java note: In Java curly braces denote arrays,

    a data-structure with inherent ordering.Mathematical sets are unordered so differentfrom Java arrays. Java arrays require that allelements be of the same type. Mathematical

    sets don

    t require this, however. EG: { 11, 12, 13 }

    { , , }

    { , , , 11, Leo }

  • 8/7/2019 Lecture Set I _ Sets

    5/27

    L4 5

    Sets

    A set is defined only by the elementswhich it contains. Thus repeating an

    element, or changing the ordering ofelements in the description of the set,does not change the set itself:

    { 11, 11, 11, 12, 13 } = { 11, 12, 13 } { , , } = { , , }

  • 8/7/2019 Lecture Set I _ Sets

    6/27

    L4 6

    Standard Numerical SetsThe natural numbers:N= { 0, 1, 2, 3, 4, }

    The integers:

    Z = { -3, -2, -1, 0, 1, 2, 3, }The positive integers:Z+ = {1, 2, 3, 4, 5, }

    The real numbers: R --contains any decimal

    number of arbitrary precisionThe rational numbers: Q --these are decimalnumbers whose decimal expansion repeats

    Q: Give examples of numbers in Rbut notQ.

  • 8/7/2019 Lecture Set I _ Sets

    7/27

    L4 7

    Standard Numerical Sets

    A: num erirrati nalanr,,,2 e

  • 8/7/2019 Lecture Set I _ Sets

    8/27

    L4 8

    -NotationThe Greek letter (epsilon) is used to denote

    that an object is an element of a set. Whencrossed out denotes that the object isnot an element.

    EG: 3 S reads:

    3 is an element of the setS.

    Q: Which of the following are true:

    1. 3 R2. -3 N

    3. -3 R

    4. 0 Z+

    5. x xR x2

    =-5

  • 8/7/2019 Lecture Set I _ Sets

    9/27

    L4 9

    -Notation

    A: 1, 3 and 4

    1. 3 R. True: 3 is a real number.

    2. -3 N. False: natural numbers dontcontain negatives.

    3. -3 R. True: -3 is a real number.

    4. 0 Z+. True: 0 isnt positive.

    5. x xR x2=-5 . False: square of areal number is non-neg., so cant be -5.

  • 8/7/2019 Lecture Set I _ Sets

    10/27

    L4 10

    -NotationDEF: A setS is said to be a subsetof the set T

    iff every element ofS is also an element ofT. This situation is denoted by

    S TA synonym ofsubset is contained by.

    Definitions are often just a means ofestablishing a logical equivalence which aids

    in notation. The definition above says that:S T x (xS ) p (xT)

    We already had all the necessary concepts, butthe notation saves work.

  • 8/7/2019 Lecture Set I _ Sets

    11/27

    L4 11

    -NotationWhen is used instead of, proper

    containment is meant. A subsetSofTissaid to be a propersubsetifS is not equal

    to T. Notationally:

    S T ST x (x S xT)

    Q: What algebraic symbol is reminiscent of?

  • 8/7/2019 Lecture Set I _ Sets

    12/27

    L4 12

    -Notation

    A: is to , as < is to e.

  • 8/7/2019 Lecture Set I _ Sets

    13/27

    L4 13

    The Empty Set

    The empty set is the set containing noelements. This set is also called the

    null set and is denoted by: {}

  • 8/7/2019 Lecture Set I _ Sets

    14/27

    L4 14

    SubsetExamples

    Q: Which of the following are true:

    1. N R

    2. Z N

    3. -3 R

    4. {1,2} Z+

    5.

    6.

  • 8/7/2019 Lecture Set I _ Sets

    15/27

    L4 15

    SubsetExamples

    A: 1, 4 and 51. N R. All natural numbers are real.

    2. Z N. Negative numbers aren

    t natural.3. -3 R. Nonsensical. -3 is not a subset but an

    element! (This could have made sense if weviewed -3 as a setwhich in principle is thecase in this case the proposition is false).

    4. {1,2} Z+

    . This actually makes sense. The set{1,2} is an object in its own right, so could bean element of some set; however, {1,2} is nota number, therefore is not an element ofZ.

    5. . Any set contains itself.

    6. . No set can contain itself properly.

  • 8/7/2019 Lecture Set I _ Sets

    16/27

    L4 16

    Cardinality

    The cardinalityof a set is the number ofdistinct elements in the set. |S|

    denotes the cardinality ofS.Q: Compute each cardinality.

    1. |{1, -13, 4, -13, 1}|

    2. |{3, {1,2,3,4}, }|

    3. |{}|

    4. |{{}, {{}}, {{{}}} }|

  • 8/7/2019 Lecture Set I _ Sets

    17/27

    L4 17

    Cardinality

    Hint: After eliminating the redundancies justlook at the number of top level commas andadd 1 (except for the empty set).

    A:1. |{1, -13, 4, -13, 1}| = |{1, -13, 4}| = 3

    2. |{3, {1,2,3,4}, }| = 3. To see this, setS={1,2,3,4}. Compute the cardinality of{3,S, }

    3. |{}| = || = 0

    4. |{{}, {{}}, {{{}}} }|= |{, {}, {{}}| = 3

  • 8/7/2019 Lecture Set I _ Sets

    18/27

    L4 18

    Cardinality

    DEF: The setS is said to be finite if itscardinality is a nonnegative integer.Otherwise, S is said to be infinite.

    EG: N, Z, Z+, R, Q are each infinite.

    Note: Well see later that not all infinities are

    the same. In fact, R will end up having abigger infinity-type than N, but surprisingly,Nhas same infinity-type as Z, Z+, and Q.

  • 8/7/2019 Lecture Set I _ Sets

    19/27

    L4 19

    Power Set

    DEF: The powersetof S is the set of allsubsets of S.

    Denote the power set by P (S ) or by 2s .

    The latter weird notation comes from thefollowing.

    Lemma: | 2s | = 2|s|

  • 8/7/2019 Lecture Set I _ Sets

    20/27

    L4 20

    Power SetExampleTo understand the previous fact consider

    S = {1,2,3}

    Enumerate all the subsets of S :

    0-element sets: {} 1

    1-element sets: {1}, {2}, {3} +3

    2-element sets: {1,2}, {1,3}, {2,3} +3

    3-element sets: {1,2,3} +1Therefore: | 2s | = 8 = 23 = 2|s|

  • 8/7/2019 Lecture Set I _ Sets

    21/27

    L4 21

    Ordered n-tuplesNotationally, n-tuples look like sets except that

    curly braces are replaced by parentheses: ( 11, 12 ) a 2-tuple aka orderedpair

    ( , , )

    a 3-tuple ( , , , 11, Leo ) a 5-tuple

    Java: n -tuples are similar to Java arrays {},

    except that type-mixing isnt allowed in Java.

  • 8/7/2019 Lecture Set I _ Sets

    22/27

    L4 22

    Ordered n-tuples

    As opposed to sets, repetition andordering do matter with n-tuples.

    (11, 11, 11, 12, 13){

    ( 11, 12, 13 ) ( , , ) { ( , , )

  • 8/7/2019 Lecture Set I _ Sets

    23/27

    L4 23

    Cartesian ProductThe most famous example of 2-tuples are

    points in the Cartesian plane R2. Hereordered pairs (x,y) of elements ofR describethe coordinates of each point. We can thinkof the first coordinate as the value on the x-axis and the second coordinate as the valueon the y-axis.

    DEF: The Cartesianproductof two sets Aand B

    denoted by A vB

    is the set of all

    ordered pairs (a, b) where aAand bB .

    Q: Describe R2 as the Cartesian product of twosets.

  • 8/7/2019 Lecture Set I _ Sets

    24/27

    L4 24

    Cartesian ProductA: R2 = RvR. I.e., the Cartesian plane is

    formed by taking the Cartesian productof the x-axis with the y-axis.

    One can generalize the Cartesian productto several sets simultaneously.

    Q: IfA= {1,2}, B = {3,4}, C = {5,6,7}

    what is AvBvC ?

  • 8/7/2019 Lecture Set I _ Sets

    25/27

    L4 25

    Cartesian Product A: A ={1,2}, B = {3,4}, C = {5,6,7}

    A vBvC =

    { (1,3,5), (1,3,6), (1,3,7),

    (1,4,5), (1,4,6), (1,4,7),(2,3,5), (2,3,6), (2,3,7),

    (2,4,5), (2,4,6), (2,4,7) }

    Lemma: The cardinality of the Cartesianproduct is the product of the cardinalities:

    | A1 vA2 v v An| = |A1||A2| |An|

    Q: What does vSequal?

  • 8/7/2019 Lecture Set I _ Sets

    26/27

    Lecture Set I 26

    Cartesian Product

    A: From the lemma:

    |vS | = |||S | = 0|S | = 0

    There is only one set with no elements

    the empty set therefore, vSmust bethe empty set.

    One can also check this directly from thedefinition of the Cartesian product.

  • 8/7/2019 Lecture Set I _ Sets

    27/27

    27

    Exercise

    Prove the following:

    IfA B and B C then A C .