Set Theory

set definition

  • unordered collection of distinct objects
    • eg.
  • set builder notation:
  • data types in CS is built upon the concept of a set
  •   my_set = {1,2,"hi"}
      # set from iterable object
      my_set = set([1,2, "hi"])
  •   Set<Integer> mySet = newHashSet<>();

Equal Set

  • every element in 1st set is in 2nd set, and vice versa
  • Remark 1: empty set / null set is special set with no element
  • Remark 2: set with 1 element: singleton set

Subset:

  • A is a subset of B, and B is a superset of A > every element of A is also element of B
  • (A is subset of set B: ) = (B is superset of set A: )
  • Theorem 4: For every set S, (i) , (ii)
  • Remark 1: A is proper subset of B if (i) A is a subset of B (ii)
  • Remark 2: and

Power Set:

  • power set of S is set of all subsets of set S,

Cardinality:

  • If have exactly n distinct elements in set S, n is nonnegative integer S is a finite set, n is cardinality (number of elements) of S (denoted as )

Ordered n-tuples

  • represent ordered collection - with tuple
    • as this is ordered,
    • > for all

Cartesian Product

  • A x B, is set of all ordered pairs (a, b), where and
    • : and
  • pairs every element of the first set with every element of the second set
  • eg:

Set operations

  • Common set operations
    • Union: : elements in S or T
      • : or
    • Intersection: : intersection of S and T only
    • Differences: : in S but not T
    • Complements:
      • is the universe containing sets S and T
  • Theorem 15
    • For all sets S and T,
    • Prove Set Equality: show that and
    • see the prove here

Strings

  • Given a set and a natural number ,
  • is the set of length ‘strings’. Can be defined as product of copies of (i.e., ).”
    • : set of all n-bit strings. set is all possible combination of 0 and 1 in string of length 3
    • There are possible strings (8 when n = 3 above)
  • is the set of finite length ‘strings’, where contains empty string.”
    • : set of all finite-length bit strings. = any length, even 0. set is all possible combinations of 0 and 1 for all possible lengths, including "", “0”, and so on
  • is the set

Russell’s Paradox

  • , that is R is the set of all sets that don’t contain themselves as an element
  • see more here