SlideShare a Scribd company logo
Sets
      S t


A                      B




          C


    Lecture 1: Sep 5
This Lecture

We will first introduce some basic set theory before we do counting.



                        ā€¢ Basic Definitions

                        ā€¢ Operations on Sets

                        ā€¢ Set Identities

                        ā€¢ Russellā€™s Paradox
Defining Sets
                               g

Definition: A set is an unordered collection of objects.


The objects in a set are called the elements or members
of the set S, and we say S contains its elements.



We can define a set by directly listing all its elements.

    e.g. S = {2, 3, 5, 7, 11, 13, 17, 19},
        S = {CSC1130, CSC2110, ERG2020, MAT2510}


After
Aft we d fi a set, th set is a single mathematical object,
       define   t the t i       i l     th   ti l bj t
and it can be an element of another set.

    e.g. S = {{1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}}
Defining Sets by Properties
                g       y    p

It is inconvenient, and sometimes impossible,
                  ,                 p       ,
to define a set by listing all its elements.

Alternatively, we can define b a set b d
Alt    ti l           d fi by      t by describing
                                             ibi
the properties that its elements should satisfy.


We use the notation    {x āˆˆ A | P( x)}
to define the set as the set of elements x,
                                elements,
in A such that x satisfies property P.

  e.g.
Examples of Sets
                             p

Well known sets: ā€¢    the set of all real numbers,
                                                 ,
                  ā€¢   the set of all complex numbers,
                  ā€¢   the set of all integers,
                  ā€¢   the set of all positive integers
                  ā€¢   empty set,           , the set with no elements.

Other examples:

The set of all polynomials with degree at most three: {1, x, x2, x3, 2x+3x2,ā€¦}.

The set of all n-bit strings: {000ā€¦0, 000ā€¦1, ā€¦, 111ā€¦1}

The set of all triangles without an obtuse angle: {       ,       ,ā€¦ }

The set of all graphs with four nodes: {         ,        ,      ,       ,ā€¦}
                                                                           }
Membership
                                              p

                  Order, number of occurence are not important.

                            e.g. {a,b,c} = {c,b,a} = {a,a,b,c,b}


       The most basic question in set theory is whether an element is in a set.


                x is an element of A                         x is not an element of A
                x is in A                                    x is not in A

e.g.     Recall that Z is the set of all integers. So 7āˆˆ Ī– and 2/3 āˆ‰ Ī– .

         Let b h
         L P be the set of all prime numbers. Then
                         f ll i         b     Th                     and
                                                                       d

         Let Q be the set of all rational numbers. Then                 and

                                                                       (will prove later)
Size of a Set

In this course we mostly focus on finite sets.


Definition: The size of a set S, denoted by |S|,
is defined as the number of elements contained in S.


e.g.
e g if S = {2, 3 5, 7, 11, 13, 17, 19}, then |S|=8.
           {2 3, 5 7 11 13 17 19}            |S|=8
    if S = {CSC1130, CSC2110, ERG2020, MAT2510}, then |S|=4.
    if S = {{1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}}, then |S|=6.


Later we will study how to determine the size of the following sets:
    ā€¢    the set of poker hands which are ā€œfull houseā€.
    ā€¢    the set of n-bit strings without three consecutive ones.
    ā€¢    the set of valid ways to add n pairs of parentheses
Subset

      Definition: Given two sets A and B, we say A is a subset of B,
      denoted by            , if every element of A is also an element of B.



                                      A        B
                                                                     not a subset


ā€¢ If A={4, 8, 12, 16} and B={2, 4, 6, 8, 10, 12, 14, 16}, then       but

ā€¢         because every element in A is an element of A.

ā€¢        for any A because the empty set has no elements.
               y                 p y

ā€¢ If A is the set of prime numbers and B is the set of odd numbers, then

       Fact: If           , then |A| <= |B|.
Proper Subset, Equality
                        p            q     y

Definition: Given two sets A and B, we say A is a proper subset of B,
denoted by            , if every element of A is an element of B,
But there is an element in B that is not contained in A.



             B           Fact: If         , then |A| < |B|.
     A




Definition: Given two sets A and B, we say A = B if           and       .


A                B
                         Fact: If A = B, then |A| = |B|.
Exercises

1.           ?

2. {3}     {5,7,3}?

3.
3 āˆ…        every set?
                    ?

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

5. {a} = {{a}}?

6.
6 If A      B and B     C then A
                        C,            C?

7. If A     B and B     C, then A     C?
This Lecture




ā€¢ Basic Definitions

ā€¢ Operations on Sets

ā€¢ Set Identities

ā€¢ Russellā€™s Paradox
Basic Operations on Sets
                               p

             Let A, B be two subsets of a universal set U
             (depending on the context U could be R, Z, or other sets).
                                                  R Z            sets)


intersection:

     Defintion: Two sets are said to be disjoint if
                their intersection is an empty set
                                               set.


     e.g. Let A be the set of odd numbers, and B be the set of even numbers.
         Then A and B are disjoint.


    union:


     Fact:
Basic Operations on Sets
                            p


d fference
difference:


     Fact
     Fact:



complement:


     e.g. Let U = Z and A b the set of odd numbers.
          L           d be h         f dd     b
        Then     is the set of even numbers.


     Fact: If          , then
Examples
                                   p


A = {1, 3, 6, 8, 10}
    { ,           0}   B = {2, 4, 6, 7, 10}
                           { , ,         0}

A   B = {6, 10}, A     B = {1, 2, 3, 4, 6, 7, 8, 10}   A-B = {1, 3, 8}



Let U = { x   Z | 1 <= x <= 100}.

A={x       U | x is divisible by 3}, B = { x     U | x is divisible by 5}

A   B={x      U | x is divisible by 15}

A   B={x      U | x is divisible by 3 or is divisible by 5 (or both)}

Aā€“B={x         U | x is divisible by 3 but is not divisible by 5 }


Exercise: compute |A| |B| |A B| |A
E    i         t |A|, |B|,   B|,               B| |A ā€“ B|
                                               B|,     B|.
Partitions of Sets

         Two sets are disjoint if their intersection is empty.


A collection of nonempty sets {A1, A2, ā€¦, An} is a partition of a set A
if and only if



          A1, A2, ā€¦, An are mutually disjoint (or pairwise disjoint).


e.g. Let A be the set of integers.
    Let A1 be the set of negative integers.
    Let A2 be the set of positive integers.
    Then {A1, A2} is not a partition of A, because A ā‰ A1 A2
       as 0 is contained in A but not contained in A1 A2
Partitions of Sets


e.g. Let A be the set of integers d v s ble by 6.
                          ntegers divisible
    A1 be the set of integers divisible by 2.
    A2 be the set of integers divisible by 3.
    Then {A1, A2} is not a partition of A, because A1 and A2 are not disjoint,
       and also A A1 A2 (so both conditions are not satisfied).


e.g. Let A be the set of integers.
     A1 = {x   A | x = 3k+1 for some integer k}
     A2 = {x A | x = 3k+2 for some integer k}
     A3 = {x A | x = 3k for some integer k}
          {             f        i
     Then {A1, A2, A3} is a partition of A
Power Sets

        p
        power set:          pow ( A) ::= {S | S āŠ† A}
        In words, the power set pow(A) of a set A
        contains all the subsets of A as members.
                  ll h     b      f         b

        p ({ , }) {āˆ…, {a}, {b}, {a,b}}
        pow({a,b}) = { , { }, { }, { , }}


        pow({a,b,c}) = {āˆ…, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}}


        pow({a,b,c,d}) = {āˆ…, {a}, {b}, {c}, {d},
                            {a,b}, {a,c}, {b,c}, {a,d}, {b,d}, {c,d},
                            {a,b,c}, {a,b,d}, {a,c,d}, {b,c,d}, {a,b,c,d}}


Fact (to be explained later): If A has n elements, then pow(A) has 2n elements.
Cartesian Products

Definition: Given two sets A and B, the Cartesian product A x B is the
set of all ordered pairs (a,b), where a is in A and b is in B. Formally,




Ordered pairs means the ordering is important, e g (1 2) ā‰  (2,1)
                                    important e.g. (1,2) (2 1)

e.g. Let A be the set of letters, i.e. {a,b,c,ā€¦,x,y,z}.
    Let B be the set of digits, i.e. {0,1,ā€¦,9}.

    AxA is just the set of strings with two letters.

    BxB is just the set of strings with two digits.

    AxB is the set of strings where the first character is a letter
                           g
      and the second character is a digit.
Cartesian Products

      The definition can be generalized to any number of sets, e.g.




Using the above examples, AxAxA is the set of strings with three letters.

Our ID card number has one letter and then six digits,
                                                 g
so the set of ID card numbers is the set AxBxBxBxBxBxB.


 Fact: If |A| = n and |B| = m, then |AxB| = mn.


 Fact: If |A| = n and |B| = m and |C| = l, then |AxBxC| = mnl.


 Fact:
 F t |A1xA2xā€¦xAk| = |A1| |A2|
         A    A        |x|A |xā€¦x|Ak|
                                |A |.
Exercises

1. Let A be the set of prime numbers, and let B be the set of even numbers.
    What is
    Wh t i A B and |A B|?
                 d



2. Is |A   B| > |A| > |A   B| always true?


3. Let A be the set of all n-bit binary strings, Ai be the set of all n-bit
    binary strings with i ones. Is (A1, A2, ā€¦, Ai, ā€¦, An) a partition of A?


4. Why the name Cartesian product?


5. Let A = {x,y}. What is pow(A)xpow(A) and |pow(A)xpow(A)|?
This Lecture




ā€¢ Basic Definitions

ā€¢ Operations on Sets

ā€¢ Set Identities

ā€¢ Russellā€™s Paradox
Set Identities

Some basic properties of sets, which are true for all sets.
Set Identities

    Distributive Law:                              (1)

                                                   (2)




A                       B      A               B




          C                              C

          (1)                            (2)
Set Identities

    Distributive Law:

                   We can also verify this law more carefully

                                     L.H.S
                                     LHS


    S1        S2
                         S3
A                              B
              S4
         S5         S6
                                     R.H.S.
                                     RHS
              S7



              C

    There are formal proofs in the textbook, but we donā€™t do that.
Set Identities

De Morganā€™s Law:
Set Identities

De Morganā€™s Law:
Disproof
                   p




A           B       A              B




    C                      C

    L.H.S                  R.H.S
Disproof
                           p




      1     2   3                             1     2   3
A                      B             A                      B
          4 5 6                                   4 5 6

            7                                       7


           C                                       C

We can easily construct a counterexample to the equality,
by putting a number in each region in the figure.
Let A = {1,2,4,5}, B = {2,3,5,6}, C = {4,5,6,7}.
Then we see that L.H.S = {1,2,3,4} and R.H.S = {1,2}.
Algebraic Proof
                       g

 Sometimes when we know some rules, we can use them to prove
 new rules without drawing figures.


e.g. we can prove                             without drawing figures.




                                by using DeMorganā€™s rule on A and B
                                 y     g      g
Algebraic Proof
  g




        by DeMorganā€™s law on A U C and B U C
         y      g

        by DeMorganā€™s law on the first half


        by DeMorganā€™s law on the second half


        by distributive law
Exercises
This Lecture




ā€¢ Basic Definitions

ā€¢ Operations on Sets

ā€¢ Set Identities

ā€¢ Russellā€™s Paradox
Russellā€™s Paradox (Optional)
                                         p

                     Let W ::= {S āˆˆ Sets | S āˆ‰ S }
In words, W is the set that contains all the sets that donā€™t contain themselves.


                                  Is W in W?

        If W is in W, then W contains itself.
        But W contains only those sets that donā€™t contain themselves.
        So W is not in W.

        If W is not in W, then W does not contain itself.
        But W contains those sets that donā€™t contain themselves.
        So W is in W.

        Whatā€™s wrong???
Barberā€™s Paradox (Optional)
                                 p


        There is a male barber who shaves all those men,
         here s

        and only those men, who do not shave themselves.


                  Does the barber shave himself?

Suppose the barber shaves himself.
But the barber only shaves those men who donā€™t shave themselves.
Since the barber shaves himself, he does not shave himself.

Suppose the barber does not shave himself.
But the barber shaves those men who donā€™t shave themselves.
Since the barber does not shave himself, he shaves himself.

Whatā€™s wrong???
Solution to Russellā€™s Paradox (Optional)
                                  p

A man either shaves himself or not shaves himself.
A barber neither shaves himself nor not shaves himself
                                               himself.
Perhaps such a barber does not exist?
Actually thatā€™s the way out of this paradox.
         that s                     paradox


Going back to the barberā€™s paradox,
    g                      p      ,
we conclude that W cannot be a set,
because every set is either contains itself or not,
            y
but either case cannot happen for W.


This paradox tells us that not everything we define is a set.
Later on mathematicians define sets more carefully,
e.g. using sets that we already know.
Halting Problem (Optional)
                        g           p

Now we mention one of the most famous problems in computer science.


The halting problem: Can we write a program which detects infinite loop?


   We want a program H that given any program P and input I:
   H(P,I) returns ā€œhaltā€ if P will terminate given input I;
   H(P,I) returns ā€œloop foreverā€ if P will not terminate given input I.
   And H itself must terminate in finite time.


The halting problem: Does such a program H exist?             NO!

    The reasoning used in solving the halting problem is very similar
    to that of Russellā€™s paradox, if youā€™re interested please see
    Chapter 5.4 of the textbook.
Summary
                                   y


Recall what we have covered so far
                               far.


ā€¢ Basic Definitions (defining sets, membership, subsets, size)
                    (       g     ,          p,        ,     )

ā€¢ Operations on Sets (intersection, union, difference, complement,
                      partition,
                      partition power set, Cartesian product)
                                      set

ā€¢ Set Identities (distributive law, DeMorganā€™s law,
                 checking set identities ā€“ proof & di
                  h ki      t id titi          f disproof, algebraic)
                                                        f l b i )


We wonā€™t ask difficult questions about sets
   won t                               sets,
but later on sets will be in our language in this course,
so make sure that you remember the basic definitions and n
   m     u        y u m m                  fn     n n notation.
                                                             n.

More Related Content

What's hot

Sets venn diagrams
Sets venn diagramsSets venn diagrams
Sets venn diagrams
zahoormirza194
Ā 
Complement of a set
Complement of a setComplement of a set
Complement of a set
Sarah Bumanglag
Ā 
Linear Algebra and Matrix
Linear Algebra and MatrixLinear Algebra and Matrix
Linear Algebra and Matrix
itutor
Ā 
POWERPOINT (SETS & FUNCTIONS).pdf
POWERPOINT (SETS & FUNCTIONS).pdfPOWERPOINT (SETS & FUNCTIONS).pdf
POWERPOINT (SETS & FUNCTIONS).pdf
MaryAnnBatac1
Ā 

What's hot (20)

Cardinality of a set
Cardinality of a setCardinality of a set
Cardinality of a set
Ā 
Sets (Mathematics class XI)
Sets (Mathematics class XI)Sets (Mathematics class XI)
Sets (Mathematics class XI)
Ā 
Introduction to Set Theory
Introduction to Set TheoryIntroduction to Set Theory
Introduction to Set Theory
Ā 
Set theory
Set theory Set theory
Set theory
Ā 
Ppt sets and set operations
Ppt sets and set operationsPpt sets and set operations
Ppt sets and set operations
Ā 
Cantor Set
Cantor SetCantor Set
Cantor Set
Ā 
Set concepts
Set conceptsSet concepts
Set concepts
Ā 
Abstract algebra - Algebraic closed field, unit - 2 , M.Sc. l semester Maths
Abstract algebra -  Algebraic closed field, unit - 2 , M.Sc. l semester Maths Abstract algebra -  Algebraic closed field, unit - 2 , M.Sc. l semester Maths
Abstract algebra - Algebraic closed field, unit - 2 , M.Sc. l semester Maths
Ā 
Sets
SetsSets
Sets
Ā 
Sets venn diagrams
Sets venn diagramsSets venn diagrams
Sets venn diagrams
Ā 
Complement of a set
Complement of a setComplement of a set
Complement of a set
Ā 
Linear Algebra and Matrix
Linear Algebra and MatrixLinear Algebra and Matrix
Linear Algebra and Matrix
Ā 
Sets
SetsSets
Sets
Ā 
Types Of Set
Types Of SetTypes Of Set
Types Of Set
Ā 
Set Theory Presentation
Set Theory PresentationSet Theory Presentation
Set Theory Presentation
Ā 
Group theory notes
Group theory notesGroup theory notes
Group theory notes
Ā 
POWERPOINT (SETS & FUNCTIONS).pdf
POWERPOINT (SETS & FUNCTIONS).pdfPOWERPOINT (SETS & FUNCTIONS).pdf
POWERPOINT (SETS & FUNCTIONS).pdf
Ā 
Introduction to set theory
Introduction to set theoryIntroduction to set theory
Introduction to set theory
Ā 
Relations
RelationsRelations
Relations
Ā 
Ring
RingRing
Ring
Ā 

Similar to Set

Sets and Functions By Saleh ElShehabey
Sets and Functions By Saleh ElShehabeySets and Functions By Saleh ElShehabey
Sets and Functions By Saleh ElShehabey
ravingeek
Ā 

Similar to Set (20)

sets.pptx
sets.pptxsets.pptx
sets.pptx
Ā 
2.1 Sets
2.1 Sets2.1 Sets
2.1 Sets
Ā 
Sets functions-sequences-exercises
Sets functions-sequences-exercisesSets functions-sequences-exercises
Sets functions-sequences-exercises
Ā 
Mathematics JEE quick revision notes pdf
Mathematics JEE quick revision notes pdfMathematics JEE quick revision notes pdf
Mathematics JEE quick revision notes pdf
Ā 
4898850.ppt
4898850.ppt4898850.ppt
4898850.ppt
Ā 
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
Ā 
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptxMoazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
Moazzzim Sir (25.07.23)CSE 1201, Week#3, Lecture#7.pptx
Ā 
Discrete mathematics OR Structure
Discrete mathematics OR Structure Discrete mathematics OR Structure
Discrete mathematics OR Structure
Ā 
Sets and Functions By Saleh ElShehabey
Sets and Functions By Saleh ElShehabeySets and Functions By Saleh ElShehabey
Sets and Functions By Saleh ElShehabey
Ā 
Set concepts
Set conceptsSet concepts
Set concepts
Ā 
discrete maths notes.ppt
discrete maths notes.pptdiscrete maths notes.ppt
discrete maths notes.ppt
Ā 
sets and their introduction and their exercises.pptx
sets and their introduction and their exercises.pptxsets and their introduction and their exercises.pptx
sets and their introduction and their exercises.pptx
Ā 
BCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and functionBCA_Semester-I_Mathematics-I_Set theory and function
BCA_Semester-I_Mathematics-I_Set theory and function
Ā 
Set concepts
Set conceptsSet concepts
Set concepts
Ā 
Set theory
Set theorySet theory
Set theory
Ā 
7-Sets-1.ppt
7-Sets-1.ppt7-Sets-1.ppt
7-Sets-1.ppt
Ā 
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
Ā 
Digital text sets pdf
Digital text sets  pdfDigital text sets  pdf
Digital text sets pdf
Ā 
Set theory
Set theorySet theory
Set theory
Ā 
CS205_2
CS205_2CS205_2
CS205_2
Ā 

More from H K (20)

Assignment4
Assignment4Assignment4
Assignment4
Ā 
Assignment3
Assignment3Assignment3
Assignment3
Ā 
Induction
InductionInduction
Induction
Ā 
Solution3
Solution3Solution3
Solution3
Ā 
Solution2
Solution2Solution2
Solution2
Ā 
Mid-
Mid-Mid-
Mid-
Ā 
Assignment4
Assignment4Assignment4
Assignment4
Ā 
Assignment4
Assignment4Assignment4
Assignment4
Ā 
Dm assignment3
Dm assignment3Dm assignment3
Dm assignment3
Ā 
Proof
ProofProof
Proof
Ā 
Resolution
ResolutionResolution
Resolution
Ā 
Assignment description
Assignment descriptionAssignment description
Assignment description
Ā 
Dm assignment2
Dm assignment2Dm assignment2
Dm assignment2
Ā 
Dm assignment1
Dm assignment1Dm assignment1
Dm assignment1
Ā 
Logic
LogicLogic
Logic
Ā 
Introduction
IntroductionIntroduction
Introduction
Ā 
Assignment 2 sol
Assignment 2 solAssignment 2 sol
Assignment 2 sol
Ā 
Assignment sw solution
Assignment sw solutionAssignment sw solution
Assignment sw solution
Ā 
Violinphoenix
ViolinphoenixViolinphoenix
Violinphoenix
Ā 
Ie project
Ie projectIe project
Ie project
Ā 

Recently uploaded

Recently uploaded (20)

Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
Ā 
Exploring UiPath Orchestrator API: updates and limits in 2024 šŸš€
Exploring UiPath Orchestrator API: updates and limits in 2024 šŸš€Exploring UiPath Orchestrator API: updates and limits in 2024 šŸš€
Exploring UiPath Orchestrator API: updates and limits in 2024 šŸš€
Ā 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Ā 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
Ā 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
Ā 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Ā 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Ā 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Ā 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
Ā 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Ā 
Salesforce Adoption ā€“ Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption ā€“ Metrics, Methods, and Motivation, Antone KomSalesforce Adoption ā€“ Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption ā€“ Metrics, Methods, and Motivation, Antone Kom
Ā 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
Ā 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Ā 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
Ā 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Ā 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Ā 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Ā 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
Ā 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
Ā 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Ā 

Set

  • 1. Sets S t A B C Lecture 1: Sep 5
  • 2. This Lecture We will first introduce some basic set theory before we do counting. ā€¢ Basic Definitions ā€¢ Operations on Sets ā€¢ Set Identities ā€¢ Russellā€™s Paradox
  • 3. Defining Sets g Definition: A set is an unordered collection of objects. The objects in a set are called the elements or members of the set S, and we say S contains its elements. We can define a set by directly listing all its elements. e.g. S = {2, 3, 5, 7, 11, 13, 17, 19}, S = {CSC1130, CSC2110, ERG2020, MAT2510} After Aft we d fi a set, th set is a single mathematical object, define t the t i i l th ti l bj t and it can be an element of another set. e.g. S = {{1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}}
  • 4. Defining Sets by Properties g y p It is inconvenient, and sometimes impossible, , p , to define a set by listing all its elements. Alternatively, we can define b a set b d Alt ti l d fi by t by describing ibi the properties that its elements should satisfy. We use the notation {x āˆˆ A | P( x)} to define the set as the set of elements x, elements, in A such that x satisfies property P. e.g.
  • 5. Examples of Sets p Well known sets: ā€¢ the set of all real numbers, , ā€¢ the set of all complex numbers, ā€¢ the set of all integers, ā€¢ the set of all positive integers ā€¢ empty set, , the set with no elements. Other examples: The set of all polynomials with degree at most three: {1, x, x2, x3, 2x+3x2,ā€¦}. The set of all n-bit strings: {000ā€¦0, 000ā€¦1, ā€¦, 111ā€¦1} The set of all triangles without an obtuse angle: { , ,ā€¦ } The set of all graphs with four nodes: { , , , ,ā€¦} }
  • 6. Membership p Order, number of occurence are not important. e.g. {a,b,c} = {c,b,a} = {a,a,b,c,b} The most basic question in set theory is whether an element is in a set. x is an element of A x is not an element of A x is in A x is not in A e.g. Recall that Z is the set of all integers. So 7āˆˆ Ī– and 2/3 āˆ‰ Ī– . Let b h L P be the set of all prime numbers. Then f ll i b Th and d Let Q be the set of all rational numbers. Then and (will prove later)
  • 7. Size of a Set In this course we mostly focus on finite sets. Definition: The size of a set S, denoted by |S|, is defined as the number of elements contained in S. e.g. e g if S = {2, 3 5, 7, 11, 13, 17, 19}, then |S|=8. {2 3, 5 7 11 13 17 19} |S|=8 if S = {CSC1130, CSC2110, ERG2020, MAT2510}, then |S|=4. if S = {{1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4}}, then |S|=6. Later we will study how to determine the size of the following sets: ā€¢ the set of poker hands which are ā€œfull houseā€. ā€¢ the set of n-bit strings without three consecutive ones. ā€¢ the set of valid ways to add n pairs of parentheses
  • 8. Subset Definition: Given two sets A and B, we say A is a subset of B, denoted by , if every element of A is also an element of B. A B not a subset ā€¢ If A={4, 8, 12, 16} and B={2, 4, 6, 8, 10, 12, 14, 16}, then but ā€¢ because every element in A is an element of A. ā€¢ for any A because the empty set has no elements. y p y ā€¢ If A is the set of prime numbers and B is the set of odd numbers, then Fact: If , then |A| <= |B|.
  • 9. Proper Subset, Equality p q y Definition: Given two sets A and B, we say A is a proper subset of B, denoted by , if every element of A is an element of B, But there is an element in B that is not contained in A. B Fact: If , then |A| < |B|. A Definition: Given two sets A and B, we say A = B if and . A B Fact: If A = B, then |A| = |B|.
  • 10. Exercises 1. ? 2. {3} {5,7,3}? 3. 3 āˆ… every set? ? 4. {1,2} {{1,2}, {2,3}, {3,1}}? 5. {a} = {{a}}? 6. 6 If A B and B C then A C, C? 7. If A B and B C, then A C?
  • 11. This Lecture ā€¢ Basic Definitions ā€¢ Operations on Sets ā€¢ Set Identities ā€¢ Russellā€™s Paradox
  • 12. Basic Operations on Sets p Let A, B be two subsets of a universal set U (depending on the context U could be R, Z, or other sets). R Z sets) intersection: Defintion: Two sets are said to be disjoint if their intersection is an empty set set. e.g. Let A be the set of odd numbers, and B be the set of even numbers. Then A and B are disjoint. union: Fact:
  • 13. Basic Operations on Sets p d fference difference: Fact Fact: complement: e.g. Let U = Z and A b the set of odd numbers. L d be h f dd b Then is the set of even numbers. Fact: If , then
  • 14. Examples p A = {1, 3, 6, 8, 10} { , 0} B = {2, 4, 6, 7, 10} { , , 0} A B = {6, 10}, A B = {1, 2, 3, 4, 6, 7, 8, 10} A-B = {1, 3, 8} Let U = { x Z | 1 <= x <= 100}. A={x U | x is divisible by 3}, B = { x U | x is divisible by 5} A B={x U | x is divisible by 15} A B={x U | x is divisible by 3 or is divisible by 5 (or both)} Aā€“B={x U | x is divisible by 3 but is not divisible by 5 } Exercise: compute |A| |B| |A B| |A E i t |A|, |B|, B|, B| |A ā€“ B| B|, B|.
  • 15. Partitions of Sets Two sets are disjoint if their intersection is empty. A collection of nonempty sets {A1, A2, ā€¦, An} is a partition of a set A if and only if A1, A2, ā€¦, An are mutually disjoint (or pairwise disjoint). e.g. Let A be the set of integers. Let A1 be the set of negative integers. Let A2 be the set of positive integers. Then {A1, A2} is not a partition of A, because A ā‰ A1 A2 as 0 is contained in A but not contained in A1 A2
  • 16. Partitions of Sets e.g. Let A be the set of integers d v s ble by 6. ntegers divisible A1 be the set of integers divisible by 2. A2 be the set of integers divisible by 3. Then {A1, A2} is not a partition of A, because A1 and A2 are not disjoint, and also A A1 A2 (so both conditions are not satisfied). e.g. Let A be the set of integers. A1 = {x A | x = 3k+1 for some integer k} A2 = {x A | x = 3k+2 for some integer k} A3 = {x A | x = 3k for some integer k} { f i Then {A1, A2, A3} is a partition of A
  • 17. Power Sets p power set: pow ( A) ::= {S | S āŠ† A} In words, the power set pow(A) of a set A contains all the subsets of A as members. ll h b f b p ({ , }) {āˆ…, {a}, {b}, {a,b}} pow({a,b}) = { , { }, { }, { , }} pow({a,b,c}) = {āˆ…, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}} pow({a,b,c,d}) = {āˆ…, {a}, {b}, {c}, {d}, {a,b}, {a,c}, {b,c}, {a,d}, {b,d}, {c,d}, {a,b,c}, {a,b,d}, {a,c,d}, {b,c,d}, {a,b,c,d}} Fact (to be explained later): If A has n elements, then pow(A) has 2n elements.
  • 18. Cartesian Products Definition: Given two sets A and B, the Cartesian product A x B is the set of all ordered pairs (a,b), where a is in A and b is in B. Formally, Ordered pairs means the ordering is important, e g (1 2) ā‰  (2,1) important e.g. (1,2) (2 1) e.g. Let A be the set of letters, i.e. {a,b,c,ā€¦,x,y,z}. Let B be the set of digits, i.e. {0,1,ā€¦,9}. AxA is just the set of strings with two letters. BxB is just the set of strings with two digits. AxB is the set of strings where the first character is a letter g and the second character is a digit.
  • 19. Cartesian Products The definition can be generalized to any number of sets, e.g. Using the above examples, AxAxA is the set of strings with three letters. Our ID card number has one letter and then six digits, g so the set of ID card numbers is the set AxBxBxBxBxBxB. Fact: If |A| = n and |B| = m, then |AxB| = mn. Fact: If |A| = n and |B| = m and |C| = l, then |AxBxC| = mnl. Fact: F t |A1xA2xā€¦xAk| = |A1| |A2| A A |x|A |xā€¦x|Ak| |A |.
  • 20. Exercises 1. Let A be the set of prime numbers, and let B be the set of even numbers. What is Wh t i A B and |A B|? d 2. Is |A B| > |A| > |A B| always true? 3. Let A be the set of all n-bit binary strings, Ai be the set of all n-bit binary strings with i ones. Is (A1, A2, ā€¦, Ai, ā€¦, An) a partition of A? 4. Why the name Cartesian product? 5. Let A = {x,y}. What is pow(A)xpow(A) and |pow(A)xpow(A)|?
  • 21. This Lecture ā€¢ Basic Definitions ā€¢ Operations on Sets ā€¢ Set Identities ā€¢ Russellā€™s Paradox
  • 22. Set Identities Some basic properties of sets, which are true for all sets.
  • 23. Set Identities Distributive Law: (1) (2) A B A B C C (1) (2)
  • 24. Set Identities Distributive Law: We can also verify this law more carefully L.H.S LHS S1 S2 S3 A B S4 S5 S6 R.H.S. RHS S7 C There are formal proofs in the textbook, but we donā€™t do that.
  • 27. Disproof p A B A B C C L.H.S R.H.S
  • 28. Disproof p 1 2 3 1 2 3 A B A B 4 5 6 4 5 6 7 7 C C We can easily construct a counterexample to the equality, by putting a number in each region in the figure. Let A = {1,2,4,5}, B = {2,3,5,6}, C = {4,5,6,7}. Then we see that L.H.S = {1,2,3,4} and R.H.S = {1,2}.
  • 29. Algebraic Proof g Sometimes when we know some rules, we can use them to prove new rules without drawing figures. e.g. we can prove without drawing figures. by using DeMorganā€™s rule on A and B y g g
  • 30. Algebraic Proof g by DeMorganā€™s law on A U C and B U C y g by DeMorganā€™s law on the first half by DeMorganā€™s law on the second half by distributive law
  • 32. This Lecture ā€¢ Basic Definitions ā€¢ Operations on Sets ā€¢ Set Identities ā€¢ Russellā€™s Paradox
  • 33. Russellā€™s Paradox (Optional) p Let W ::= {S āˆˆ Sets | S āˆ‰ S } In words, W is the set that contains all the sets that donā€™t contain themselves. Is W in W? If W is in W, then W contains itself. But W contains only those sets that donā€™t contain themselves. So W is not in W. If W is not in W, then W does not contain itself. But W contains those sets that donā€™t contain themselves. So W is in W. Whatā€™s wrong???
  • 34. Barberā€™s Paradox (Optional) p There is a male barber who shaves all those men, here s and only those men, who do not shave themselves. Does the barber shave himself? Suppose the barber shaves himself. But the barber only shaves those men who donā€™t shave themselves. Since the barber shaves himself, he does not shave himself. Suppose the barber does not shave himself. But the barber shaves those men who donā€™t shave themselves. Since the barber does not shave himself, he shaves himself. Whatā€™s wrong???
  • 35. Solution to Russellā€™s Paradox (Optional) p A man either shaves himself or not shaves himself. A barber neither shaves himself nor not shaves himself himself. Perhaps such a barber does not exist? Actually thatā€™s the way out of this paradox. that s paradox Going back to the barberā€™s paradox, g p , we conclude that W cannot be a set, because every set is either contains itself or not, y but either case cannot happen for W. This paradox tells us that not everything we define is a set. Later on mathematicians define sets more carefully, e.g. using sets that we already know.
  • 36. Halting Problem (Optional) g p Now we mention one of the most famous problems in computer science. The halting problem: Can we write a program which detects infinite loop? We want a program H that given any program P and input I: H(P,I) returns ā€œhaltā€ if P will terminate given input I; H(P,I) returns ā€œloop foreverā€ if P will not terminate given input I. And H itself must terminate in finite time. The halting problem: Does such a program H exist? NO! The reasoning used in solving the halting problem is very similar to that of Russellā€™s paradox, if youā€™re interested please see Chapter 5.4 of the textbook.
  • 37. Summary y Recall what we have covered so far far. ā€¢ Basic Definitions (defining sets, membership, subsets, size) ( g , p, , ) ā€¢ Operations on Sets (intersection, union, difference, complement, partition, partition power set, Cartesian product) set ā€¢ Set Identities (distributive law, DeMorganā€™s law, checking set identities ā€“ proof & di h ki t id titi f disproof, algebraic) f l b i ) We wonā€™t ask difficult questions about sets won t sets, but later on sets will be in our language in this course, so make sure that you remember the basic definitions and n m u y u m m fn n n notation. n.