Loading...
Set notation describes collections and the relationships between them. Keep membership, inclusion and ordering separate before using these ideas to define languages or function types.
What you'll be able to do
A set is an unordered collection with no repeated elements. Membership, written ∈, asks whether one object belongs to the set. A subset relation asks whether every element of one set belongs to another. A proper subset additionally requires at least one extra element in the larger set.
The empty set has no elements and has cardinality zero. It is a subset of every set, but it is not automatically an element of every set. A set comprehension specifies members using a condition; in this specification, natural numbers include zero.
Union contains members in either set; intersection contains members in both. Difference A minus B contains those in A but not B and need not equal B minus A. Cardinality counts distinct members, so repeats in a written input list do not increase a set’s size.
A finite set has a finite number of members. A countably infinite set can be enumerated using natural numbers; the integers are an example even though negative values are included. The real numbers are uncountable. “Infinite” alone does not determine whether such an enumeration exists.
The Cartesian product A×B contains ordered pairs (a,b) with a in A and b in B. For finite sets its cardinality is |A|×|B|. Pair order matters even though a set itself is unordered.
A function f:A→B associates every allowed input in domain A with exactly one output in co-domain B. Not every member of B must occur as an output; the actual outputs form the range or image. This distinction supports precise descriptions of both computational transformations and functional-programming types.
| A={1,2,3}, B={3,4} | Result |
|---|---|
| A union B | {1,2,3,4} |
| A intersection B | {3} |
| A minus B | {1,2} |
| B minus A | {4} |
Attempt the task before opening its worked response. Record each change of state, explain the rule used, and check the result against the original requirements. Code examples labelled Python 3 use that language’s conventions; pseudocode states its own assumptions.
Common mistakes to avoid
Key takeaways
Test yourself
Answer a few questions, then review anything you missed.
Start with the quiz above to check the key ideas. You can also choose another topic from the practice library.