MTH 225 Lecture-Module #08:
Sets



now covering Sections 2.1–2.2 of our textbook
(the material can be covered in different orders...)

sets are theoretical bases for statements about collections/groups
e.g. databases, linked lists, subclasses in Java/C++/etc., ...

is a collection or group of  which can be any objects

may be depicted pictorially as (sub)regions e.g. as follows:

where (as with predicates) should have specification of  U
from which elements may be drawn
here  U  is  {a,b,c,d,e,f,g,h,...,z}
and set B  contains  a,b,c,d,e
and set V  contains  a,e,i,o,u
and set E  contains  x,y,z}

in writing, instead of saying "contains", specify a set's list of elements with braces  
e.g.  B  is  {a,b,c,d,e}
e.g.  V  is  {a,e,i,o,u}
e.g. (with another universe)  {Color.RED, Color,GREEN, Color.BLUE}
e.g. (with another universe)  {1, 2, 3, 4}

another way a set may be specified is via the following notation:
    expression : conditions_on_variables_in_expression }
    "set of all values of expression for which condition is satisfied"
reading ":" here as "such that"
e.g.:
    { x : x is a positive integer less than 5 }
    same as 
another e.g.:
    {x : x is a positive prime integer}
    which is  {2, 3, 5, 7, 11, 13, 17, 19, ...}
    (hard to write out complete, eh? ;-)

another e.g.:
    { x + y : x is an odd prime and y is an odd prime }
            :=  {}
   

some people use "|" instead of ":" in these set specifications
e.g.  { x | x is a positive integer less than 5 }
e.g.  {x | x is a positive prime integer}



order, multiplicity of elements not counted
e.g.  {red,green,blue}  considered equivalent to  {green,blue,red}
and the following two sets are considered equivalent to each other:




generally denote sets using uppercase letters (or such):
S,  A,  B,  S1,  S2, ...
e.g.  B  could be  {1,2,3,4}

empty set "{ }" may be specially written as "∅"

a set-specification can yield  
e.g.:  {x : x < 5 and x > 12}
e.g.?:  {x : x is a pizza-topping and x is an ice-cream flavor}  ?
e.g.:  {x : false}


to indicate something is an element of a set,
use "∈"
syntax: "element ∈ set"
e.g.:  green ∈ {red,green,blue}

negation of "" normally expressed by drawing slash through it: ""
    like with "=", "≠"
e.g.:  yellow ∉ {red,green,blue}
e.g.:  green ∉ ∅
e.g.:  5 ∉ ∅
Axiom:  ∀x∀S[x ∉ S  ↔  ¬(x ∈ S)]
Axiom:  ∀x[x ∉ ∅]


we use the following symbols to denote the main sets of numbers:
"N" := natural numbers  {0,1,2,3,...}  a.k.a. nonnegative integers
"Z" := all integers  {...,-2,-1,0,1,2,...}  positive,negative,zero
"R := real numbers
    e.g.  √3 ∈ R
    e.g.  √(-1) ∉ R
"Q" := rational numbers
    { a/b : a ∈ Z  and  b ∈ Z  and  b ≠ 0 }
    Quotients

no a priori restriction on elements of set
e.g. could have  {red, green, -5, √3}
a set can even contain other sets
e.g.  { N, -2, R, yellow, {red,green} }
-2 ∈ { N, -2, R, yellow, {red,green} }
{red,green} ∈ { N, -2, R, yellow, {red,green} }
?  green ?∈? { N, -2, R, yellow, {red,green} } ?
    votes: yes: 
                    no: 
  abstentions: 

thus you can see: membership checked simply by checking equality to each element:
  -2 =?= N
  -2 =?= -2
      .
      .
      .

  green =?= N
  green =?= -2
  green =?= R
  green =?= yellow
  green =?= {red,green}
it's common to use the term  for a set whose elements are sets
e.g.  { {a,b}, {a}, {b}, ∅ }  is a collection of sets
e.g.  { {a,b,c,d}, {e,f,g}, {h,i,j,k}, {l,m,n,o,p},
                {q,r,s}, {t,u,v}, {w,x,y,z} }
        is a collection of sets comprising all the letters
        in our alphabet
e.g. {N, Z, Q, R } is the collection of those main sets of numbers
e.g. { {1}, {1,2}, {1,3}, {1,2,4}, {1,5}, {1,2,3,6}, ... } is the collection of sets of positive integers' divisors

incidentally don't assume that    may be elided when it's a member of another set
e.g.  { {a,b}, {a}, {b}, ∅ }  not the same as  { {a,b}, {a}, {b} }
for an analogy, consider that  Strings are groups of characters somewhat like sets
e.g.:  "helo",  "world"
and    is like  ""  which is a valid  String
    can apply methods  .length(),  .substring(),  .toCharArray(),
    .compareTo(), etc. to  ""
    (may not get much from those method-calls for  "",
    but it is valid to do them)
then the collection {"helo", "world", ""}  contains how many  Strings? 
whereas by contrast the collection {"helo", "world"}  contains 



further operations on sets

well a set is like a  String  or array containing material
what can do with array besides accessing element?

  • array.length
    for a set, the notation for such determination of size is "|set|"
    called "cardinality"
    e.g.  |{red,green,blue}|  is 
    e.g.  |∅|  is 
    e.g.  |N|  is ∞
        rem.  {0,1,2,3,...}
    e.g.  |R|  is ∞
        (
        technically  |R|  different "∞" from  |N|
        explanation of that is beyond the scope of this course
        but it's presented at the end of our textbook's Section 2.4
        and if you want I could discuss with any of you outside of class
        e.g. during office-hours
        )
    e.g.  |{N}|  is 
        outer set has  inside
        { {0,1,2,3,...} }
    e.g.  |{∅}|  is 
        outer set has  inside
        { {} }
    watch braces as in code

  • "=": two sets equal iff contain same elements
    e.g.:
        {1,2,3,4}  =  {x : x is a positive integer less than 5}
        {red,green,blue}  =  {red,blue,green}
        {red,green,yellow}  ≠  {red,green,blue}
    Axiom:  ∀S1∀S2[S1 = S2  ↔  (∀x)(x ∈ S1  ↔  x ∈ S2)]

    is  {{red,green},yellow} ?=?/?≠? {red,green,yellow} ?


  • "⊂": containment
    syntax: "set1 ⊂ set2"
    semantics (i.e. meaning):  all the elements of set1 are also contained in set2
    we say "set1 is a subset of set2"
    and "set2 is a superset of set1"
    e.g.:  {green,blue} ⊂ {red,green,blue}
    e.g.:  {blue,green} ⊂ {red,green,blue}
    e.g.:  ¬({green,yellow} ⊂ {red,green,blue})
    e.g.?  {green} ?⊂? {red,green,blue} ? 
    e.g.?  green ?⊂? {red,green,blue} ?
    e.g.?  ∅ ?⊂? {red,green,blue} ?
        consider  {green,blue} ⊂ {red,green,blue}
        consider  {green} ⊂ {red,green,blue}
        consider  ∅ ⊂ {red,green,blue}
    e.g.?  {red} ?⊂? {red,{green,yellow}} ? 
    e.g.?  {green,yellow} ?⊂? {red,{green,yellow}} ? 
    e.g.:  {{green,yellow}} ⊂ {red,{green,yellow}}  is true
    e.g.:?  {red,green,blue} ?⊂? {red,green,blue} ? 

    we actually do say  {red,green,blue}  is a subset of itself,
    but just like with "<" and "≤",
    if it matters to you to disallow equality or allow it,
    with subset relationship use "⊂" or "⊆" respectively:
    e.g.:?  {red,green,blue} ?⊆? {red,green,blue} ? 
    e.g.:?  {red,green,blue} ?⊂? {red,green,blue} ? 
    e.g.:?  {green,blue} ?⊆? {red,green,blue} ? 
    e.g.?  ∅ ⊆ ∅ ? 
    e.g.?  ∅ ⊂ ∅ ? 
    in text, may add adjective "proper" for subset that is different from 'original' (⊂)
    e.g.: "{red,blue}  is a proper subset of  {red,green,blue}."
    e.g.: "{red,green,blue}  is not a proper subset of  {red,green,blue}."
    in fact all subsets of a set S are proper except S itself
    e.g. all the subsets — proper and itself — of  {a,b}  are as follows:
       
    thus,  { X : X ⊆ {a,b} }  i.e. { X : X is a subset of {a,b} }   is   { ∅, {a}, {b}, {a,b} }

    Axiom:  ∀S1∀S2[S1 ⊆ S2  ↔  ∀x(if  x ∈ S1  then  x ∈ S2)]
    Axiom:  ∀S1∀S2[S1 ⊂ S2  ↔  (S1 ⊆ S2  ∧  S1 ≠ S2)]

    if not subset, write something like "⊈" (a.k.a. "" )
    e.g.  {1,4}  {1,2,3}


    of a set S is the collection of all the subsets of S
    denoted  (S)
    e.g.  ({a,b}) = { ∅, {a}, {b}, {a,b} }
    e.g.  ({a}) = { ∅, {a} }
    e.g.  (∅) = { ∅ }
    note  (∅) ≠ ∅
    e.g.  ({a,b,c}) = { ∅, {a}, {b}, {a,b}, {a,c}, {b,c}, {a,c,b}, {c} }
    e.g.
    ({a,b,c,d}) = {
      ∅,  {a},   {b},   {a,b},   {a,c},   {b,c},   {a,c,b},   {c},
      {d}, {a,d}, {b,d}, {a,b,d}, {a,c,d}, {b,c,d}, {a,c,b,d}, {c,d}
      }


    observe:
    |S|  |(S)|
    -----------
     0     
     1     
     2     
     3     
     4     
     n     
    


    rem. order,multiplicity of elements not significant for sets
    e.g.  {red,blue,green,red} = {red,green,blue}
    but order,multiplicity do matter for other data-structures
    such as (x,y)-coordinates
    e.g.:  (20,50) ?==? (50,20) ? 
    e.g.:  (20,20) ?==? (20) ? 
    (but  {20,20} = {20})

    Definition:
    (as in "quadruplet", "quintuplet", …) is a list of elements for which order does matter
    written with parentheses
        "(elt1elt2elt3, ..., eltn)"
    (naturally) a tuple with n elements called an "n-tuple"
    have more specific names for n-tuples with specific (low) values of n
    e.g. , ...

    two tuples are equal iff they have equal length
    and elements at corresponding positions are equal
    e.g.:  (red,green,blue) == (red,green,blue)
    e.g.:  (red,blue,green) ≠ (red,green,blue)
    e.g.:  (20,20) ≠ (20)
    e.g.:  (20,50) ≠ (50,20)

    the following operation on sets involves tuples:

    Definition:
    If S1, S2, S3, ..., Sn are sets, then their ,
    denoted "S1 × S2 × ··· × Sn", is as follows:
        { every combination (a1,a2,...,an) : each ai ∈ Si }
    e.g.  {163} × {Dulimarta,Ferguson} × {easy,moderate,hard}

    e.g.  {t,f} × {t,f} := 
    e.g.  {t,f} × ∅ := { (t,), (f,) } ?
                                                        or maybe  { (t), (f) } ?
    consider
        {t,f} × {r,g,b}  :=
           

        {t,f} × {r,g}  :=
           

        {t,f} × {r}  :=
           

        {t,f} × {}  :=
           
    i.e.:
        {t,f} × ∅  :=
           



    again, may use  diagram
    to depict sets as regions of universe  U  of elements
    e.g. suppose  U  is  {a,b,c,d,e,f,g,h,...,z}
    and  B  is  {a,b,c,d,e}
    and  V  is  {a,e,i,o,u}
    and  E  is  {x,y,z}



    Definition:
    the  of sets  S1  and  S2, denoted "S1 ∪ S2",
    is the set
    containing all of  S1's elements plus all of  S2's elements listed together
    Axiom:   ∀S1∀S2∀x[x ∈ S1 ∪ S2  ↔  (x ∈ S1  or  x ∈ S2)]
    e.g.:  B ∪ V := 
    note  B ∪ V ≠ {{a,b,c,d,e},{a,e,i,o,u}}
    e.g.:  {a} ∪ {b,c} := {a,b,c}
    e.g.:   ∅ ∪ {a,b,c} := {a,b,c}

    another operation on pairs of sets is as follows:
    Definition: The  of sets S1 and S2, denoted "S1 ∩ S2",
        (a mnemonic for this symbol "∩" is "n" for "intersection")
    is the set comprising all the objects shared in common by S1 and S2
    Axiom:   ∀S1∀S2∀x[x ∈ S1 ∩ S2  iff  (x ∈ S1  and  x ∈ S2)]
    e.g.:  B ∩ V  is 
    another e.g.:   ∩   :=  ∅

    incidentally,   ∩ ∅ := ∅
    and   ∩ ∅ := ∅
    Theorem:   (∀S)[S ∩ ∅ := ∅]



    some further properties of "" and "" are as follows:

    Theorem:  (∀S1)(∀S2)(∀S3)[S1 ∩ (S2 ∪ S3)  =  (S1 ∩ S2) ∪ (S1 ∩ S3)]
        // distributivity of    over  
    let  W := V ∪ {y} := 
    e.g. check
        W ∩ (B ∪ E) =?= (W ∩ B) ∪ (W ∩ E) ?
        W ∩  =?=  ∪  ?
         =?=  ?  

    Theorem:  (∀S1)(∀S2)(∀S3)[S1 ∪ (S2 ∩ S3)  =  (S1 ∪ S2) ∩ (S1 ∪ S3)]
        // distributivity of    over  
    e.g. check
        B ∪ (W ∩ E) =?= (B ∪ W) ∩ (B ∪ E) ?
        B ∪  =?=  ∩  ?
         =?=  ?  

    Please use this sample material as models for your work for Exercise H.



    Definition:
    a pair of sets is called  if their intersection is empty.
    Axiom:   ∀S1∀S2[disjoint(S1,S2)  ↔  S1 ∩ S2 := ∅]
    a collection of sets {S1,S2,...,Sn} is called  if each pair Si,Sj of sets that are distinct (i.e. with i ≠ j) from the collection is disjoint
    e.g.  { {a,b,c,d}, {e,f,g}, {h,i,j,k}, {l,m,n,o,p},
            {q,r,s}, {t,u,v}, {w,x,y,z} }

    e.g.?  {B, V, E}  ? 
    e.g.?  {{r,g,b}, V, E}  ? 
    e.g.?  { {1}, {1,2}, {1,3}, {1,2,4}, {1,5}, {1,2,3,6}, ... }  ? 


    to  a set means to separate it into a collection of its subsets
    which are supposed to be 
    e.g.  { {1,2,3}, {4,5}, {6} }  is a partition of {1,2,3,4,5,6}
    e.g.  { {1,2,3,6}, {4,5} }  is a partition of {1,2,3,4,5,6}
    e.g.  { {1,2,4}, {3,5}, {4,6} }  doesn't qualify as a partition of {1,2,3,4,5,6}
    e.g.  { {1,2,4}, {3,6} }  doesn't qualify as a partition of {1,2,3,4,5,6}
    e.g. integers may be partitioned into negatives, zero, positives:
        { {...,-3,-2,-1}, {0}, {1,2,3,...} }
    e.g. U may be partitioned into  { B, M, E } 
            if M is 
    suppose set C comprises the consonants:
           
    e.g. ? then does  {C, V}  partition U ?
    partitioning really does happen in CS
    e.g. in compilers such as Javac/BlueJ/gcc
    at one stage in building parser (lexer),
    minimize a multi-state system by partitioning overall 'states'
    into sets of states



    further notation used for union, intersection of many sets
    e.g. suppose
    S1 = B = {a,b,c,d,e},
    S2 = V = {a,e,i,o,u},
    S3 = E = {x,y,z},
    S4 = {h,i,j,k},
    S5 = {v,w,x,y,z},
    S6 = something,
    S7 = something else,
    and so on up to S20,
    then instead of writing S1 ∪ S2 ∪ S3 ∪ S4 ∪ S5 ∪ S6 ∪ S7 ∪ S8 ∪ S9 ∪ S10 ∪ S11 ∪ S12 ∪ S13 ∪ S14 ∪ S15 ∪ S16 ∪ S17 ∪ S18 ∪ S19 ∪ S20,
    use notation as follows:
      Si   // stands for "S1 ∪ S2 ∪ S3 ∪ . . . ∪ S20"
    1≤i≤20
    
    and similarly for intersection:
      Si   // stands for "S1 ∩ S2 ∩ S3 ∩ . . . ∩ S20"
    1≤i≤20
    
    e.g. if S1 := {a,b,c,d}, S2 := {b,c,d,e}, and S3 := {c,d,e,f}, then:
     Si  := 
    1≤i≤3
    
    and:
     Si  := 
    1≤i≤3
    
    the expression under the "" or the ""
    is somewhat arbitrary
    e.g. for this example using numbers instead of letters,
        if Si is the set of positive divisors of i,
        S1:={1}, S2:={1,2}, S3:={1,3},
        S4:={1,2,4}, S5:={1,5}, S6:={1,2,3,6},
        and so on,
    then:
    Si  := 
     1≤i
    
    and:
    Si  := 
     1≤i
    
    in fact sometimes we write just the following:
    Si
    
    and:
    Si
    
    (maybe with an "i" under there)




    Definition:
    , denoted "S1 - S2" or maybe "S1 \ S2",
    yields all of  S1's elements that are not in  S2
    e.g.  B - V  :=  {b,c,d}
    Axiom:   ∀S1∀S2∀x[x ∈ S1 - S2  iff  (x ∈ S1  and  x ∉ S2)]

    incidentally, if  S1 ⊆ S2, how does  S1 - S2  look?
    e.g.  T = {a,i}
              T - V := 

    Definition:
    A set  S's , denoted "~S" or "Sc" or "S"
        or maybe "S'" or "S"
    comprises everything not in S
    e.g.  ~V  is 
    a.k.a. "Vc" or "V" or maybe "V'" or "V′"
    Axiom:   ∀S∀x[x ∈ ~S  iff  x ∉ S]

    incidentally,  ~V  doesn't include  red  or  3
    because limit consideration to U universe of discourse:


    another e.g.  ~B := 
    a.k.a. "Bc" or "B" or maybe "B'" or "B′"

    incidentally  ~(S1 ∪ S2) == ~S1 ∩ ~S2
    e.g. considering the above two examples,
        ~B ∩ ~V := 
    and the elements not listed there are  {a,b,c,d,e,i,o,u}  which equals  B ∪ V
    thus  ~B ∩ ~V := ~(B ∪ V)

    set-properties such as that listed page  of our textbook
    can be proven from axioms
    e.g.  ∀S1∀S2[~(S1 ∪ S2) == ~S1 ∩ ~S2]

    another e.g.  (∀S)[~~S == S]
    e.g.  ~V  is everything not a vowel i.e. all the consonants,
    so  ~(~V)  is everything not a consonant i.e. all the vowels again, 




    to clarify things, just producing Venn diagram(s) is often useful
    e.g. Rosen 2.2.27a:  A ∩ (B - C)  (on board)
    e.g. Rosen 2.2.27c:  (A ∩ ~B) ∪ (A ∩ ~C)  (on board)



    sample proof:
    Proposition:  (∀S)[S ∪ ∅ = S]


    More concisely — without the explicative details:
    Proposition (same as above):  (∀S)[S ∪ ∅ = S]

    You can model your proofs based on this concise one.


    another sample proof:
    Proposition:  (∀S1)(∀S2)(S1 ∩ [S1 ∪ S2] = S1)

    You can model your proofs based on this one also.
    (see also our textbook's Exercise 2.2.13 and its solution in the back of the book.)


    (Copyright © 2009 by Hugh McGuire   — for thoughts about this, see   http://www.cis.gvsu.edu/~mcguire/teaching/copyright_thoughts.html .)