Read this lesson as text
Sets and Set Notation
Math for CS · Axiom Academy
The language of collections: membership, common sets, and cardinality A set is an unordered collection of distinct objects, called elements or members . We write sets using curly braces: Sets are usually denoted by capital letters ( A, B, S, T ) and elements by lowercase letters ( a, b, x, y ). We use the symbol ("is an element of") to indicate membership: In programming terms, x A is like checking x in A (Python) or A.contains(x) (Java). Several important sets appear throughout mathematics and computer science: These sets nest inside each other: . When a set is too large to list, we describe it with a rule : \ x x > 0\ = \ 1, 2, 3, \ — positive integers \ x^2 x \ 1,2,3,4\ \ = \ 1, 4, 9, 16\ — perfect squares The empty set is a subset of every set: A for any set A . Be careful: \ \ . The first has 0 elements; the second has 1 element (which happens to be the empty set itself). Example: If A = \ 1,3\ and B = \ 1,2,3,4\ , then A B . Set equality: A = B if and only if A B and B A . This "double containment" proof strategy is fundamental. |\ 1, \ 2, 3\ \ | = 2 — the set has two elements: the number 1 and the set \ 2,3\ A set is an unordered collection of distinct elements The empty set has no elements and is a subset of every set Cardinality |A| counts the elements in A
This is the written version of the interactive lesson above. See the full Math for CS course.