When does a grouping rule make sense?
Three documents have keyword sets: document a has “python,” b has “python” and “ai,” and c has “ai.” A grouping tool calls two documents equivalent when they share a keyword. Then a is equivalent to b, and b to c, but a is not equivalent to c. Grouping each document with an existing representative produces different results when the input order changes. The problem is mathematical before it is an implementation bug: the proposed relationship does not have the properties required of equivalence.
Sets describe collections; relations describe which pairs belong together; functions describe a special kind of relation with exactly one output per input. This module connects those ideas to record identifiers, grouping rules, and dependency orders. You will learn to name the property a rule needs and produce a concrete witness when it fails. An attractive diagram or an intuitive word such as “similar” is insufficient.
Retrieval check: translate “every pair satisfies a property,” negate “every object has a match,” and distinguish a function’s image from its codomain. Review quantifiers and functions as needed. The finite catalogues used below are teaching models; general definitions apply to larger and infinite sets too.
Membership subsets and collection operations
A set is a collection determined by its members. In the elementary sets used here, order and repetition do not matter: . A list can preserve repetitions and order, so replacing a list with a set may change the problem. If a dataset contains the same observation twice, a set of its distinct values no longer records that multiplicity. The mathematical representation must match the quantity you intend to study.
Write for membership and for nonmembership. The statement means ; it permits equality. A proper subset, written here , additionally requires . Membership compares an object with a collection of objects, while inclusion compares two sets by their members. When the members are themselves sets, both questions are possible and should be asked separately.
The empty set has no members. It is a subset of every set: no element violates the inclusion implication. It is not automatically an element of every set. For , is true and is false. For , both statements are true. This distinction often prevents errors when using collections of possible subsets.
Union contains members of either set; intersection contains members of both; difference contains members of outside . A complement is always relative to a declared universe : , assuming . Without , the word “everything else” is incomplete. A catalogue complement means other catalogue items, not every conceivable object.
Let , , and . Then , , , and . Reversing difference gives . If the universe changes to , only the listed complement changes, gaining four.
The power set is the set of every subset of . For it contains , the three singleton sets, the three two-element sets, and itself: eight members. Each original element either belongs or does not belong to a chosen subset. A finite -element set therefore has subsets; Module 05 develops the counting rule systematically. Note that the power set contains sets as elements, rather than merely repeating the members of .
The Cartesian product contains ordered pairs with and . Order matters here because the first coordinate has a designated role. For request set and reviewer set , is the collection of candidate request–reviewer assignments. The reversed product describes reviewer–request pairs with different coordinate roles. If either factor is empty, there are no pairs and the product is empty.
Python uses set() for the empty set, because {} creates a dictionary. Set elements must be hashable; a mathematical set of sets can be represented using frozenset elements, while a mutable Python set cannot itself be a set member. These representation rules are programming constraints, not changes to membership mathematics. Printed set order is not guaranteed, so the labs sort elements when presenting reproducible outputs.
For , decide whether , , and hold. Why is the power set not just A with different punctuation?
Show answer
All three hold. The power set’s elements are subsets such as and , while A’s elements are the original objects a and b. Their element types and sizes differ.
Set identities proved through membership
Two sets are equal exactly when they have the same members. To prove , show that an arbitrary object belongs to if and only if it belongs to . Alternatively, prove both inclusions and . Checking the number of members alone is insufficient: different sets can have equal cardinality. Checking one chosen member is insufficient unless the entire domain is that one member.
Membership definitions connect set operations to the logic from Module 02. means , while means their inclusive disjunction. If , membership in means . A set identity can therefore follow from a logical equivalence applied to each arbitrary candidate member, without relying on the sets being small enough to list.
For an arbitrary ,
The middle step is distributivity of Boolean connectives, verified by its complete truth table or a two-case argument on membership in A. Since x was arbitrary, both sides have exactly the same members. Thus the sets are equal, including when any of them is empty.
For complements relative to a common universe, De Morgan’s laws give and . The common universe is a hypothesis. Comparing a complement over a training catalogue with a complement over all records would change the candidate members and could invalidate the equality. Carrying the universe explicitly is particularly useful in database filtering and data-split descriptions.
Difference satisfies within that universe. It is generally not commutative. Symmetric difference does commute, because it selects members appearing in exactly one set. A report of changed identifiers may need symmetric difference, whereas a report of identifiers removed from A needs only . Similar names do not guarantee interchangeable operations.
A diagram can communicate an identity by shading regions, but the diagram alone does not explain every assumption. In a two-set membership table there are four regions: neither, A only, B only, and both. A set expression selects some of these regions. Comparing its selections across all regions provides a finite logical proof for the membership expression; drawing a few sample points merely illustrates it. State which kind of evidence you are giving.
The four membership possibilities determine union, intersection, and difference. Region labels describe truth of membership, rather than the number of data points in a region.
When proving inclusion, a useful writing pattern is “take any ; by the definitions and assumptions, it follows that .” The argument should not start by assuming unless you are proving the reverse direction or an equivalence with reversible steps. An inclusion proof may use extra hypotheses, for example and to conclude . Those hypotheses should remain visible.
The labs inspect all subsets of one three-element universe. Their results are a useful check on the implementation and on your prediction. They do not by themselves prove identities for every conceivable set. The arbitrary-member argument above covers the general statement, including infinite sets. A successful computation and a general proof can support each other while answering different questions.
Prove by membership, rather than by saying the result “looks obvious.” Then explain why equal finite sizes alone cannot prove equality.
Show answer
Membership in the intersection requires membership in the empty set, which no object has. Thus the intersection has no members. Sets and have equal size but different members, so size alone is insufficient.
Binary relations and their properties
A binary relation from to is a subset . It selects which candidate ordered pairs hold. Write as shorthand for . A relation on has , allowing properties that compare objects of the same kind. A Boolean table can represent a finite relation: rows are first coordinates, columns are second coordinates, and a true cell records membership in R.
Four properties recur. Reflexive means . Symmetric means . Antisymmetric means . Transitive means . Each is a quantified conditional or membership requirement, so its failure has a specific witness shape.
A missing diagonal pair witnesses failed reflexivity. A pair present in one direction but absent in the reverse witnesses failed symmetry. Two distinct objects related in both directions witness failed antisymmetry. A chain and with missing witnesses failed transitivity. A property is not disproved by any unusual-looking pair; its exact quantified rule must be violated.
Antisymmetry does not mean “never symmetric.” It permits both directions for the same object, and it does not require any direction between distinct objects. Equality is both symmetric and antisymmetric: whenever two objects are related they are equal, so a distinct mutual pair never occurs. A relation may also have neither property. The names should be learned through their formulas rather than through a loose interpretation of the prefix “anti.”
On let mean . It is reflexive and symmetric. It is not antisymmetric because and with . It is not transitive because and hold while fails. The relation table contains concrete witnesses for both failures.
The keyword rule from the opening is another transitivity failure: a shares with b, b shares with c, and a shares nothing with c. Symmetry alone cannot fix it. Reflexivity also needs care: a document with no keywords would share no keyword even with itself, so the rule is not reflexive on a domain including such a document. A domain restricted to documents with nonempty keyword sets removes that particular failure but leaves the transitivity problem.
The chain a–b–c has its two adjacent keyword matches but lacks a–c. It supplies the three objects needed to refute transitivity.
Relations can be empty or universal. On a nonempty D, the empty relation is not reflexive, but is symmetric, antisymmetric, and transitive: the relevant antecedents never hold. The universal relation is reflexive, symmetric, and transitive; it is antisymmetric only when D has at most one member. On an empty D, all four properties hold vacuously. These edge cases are direct applications of quantified logic.
Properties should be tested against the declared domain, even when some domain objects never occur in a stored pair. If a table omits an object, checking reflexivity only for objects already present can miss its missing diagonal. The lab receives the domain separately from the pair set. For a general theorem, show why every relevant pair or triple obeys the rule; for a finite table, complete enumeration can establish the properties of that particular relation.
On , the relation has no diagonal pairs. Is it symmetric, antisymmetric, and transitive? Explain why a missing reverse pair does not violate antisymmetry.
Show answer
It is not symmetric, since but not . It is antisymmetric because no distinct pair is related in both directions, and transitive because implies . Antisymmetry forbids mutual distinct pairs; it does not require reverse pairs.
Equivalence classes partitions and quotient sets
An equivalence relation is reflexive, symmetric, and transitive. It formalises a chosen meaning of “the same for this purpose.” Literal equality is one example, but two distinct records may be equivalent under a declared key. The equivalence statement concerns that key or representation; it does not automatically prove that the underlying people, events, or physical objects are identical.
For an equivalence relation on D, the equivalence class of x is . Reflexivity gives , so classes are nonempty. If , symmetry and transitivity imply . Thus any member may serve as a representative of the class without changing which objects it contains. Representatives label a class; they do not create a different class each time.
Define when is even. Reflexivity follows from , symmetry from negating an even difference, and transitivity from adding two even differences. There are two classes: even integers and odd integers. , while . Different representatives can denote the same class, and no integer belongs to both classes.
Why can two classes not partially overlap? Suppose . Then and , so symmetry gives and transitivity gives . For any , symmetry gives and transitivity with gives , so . The reverse inclusion follows the same way. Hence overlapping classes are equal. This is the key mathematical protection missing from the keyword grouping rule.
The distinct equivalence classes therefore form a partition of D: nonempty blocks, pairwise disjoint, whose union is D. Every object is in its own class by reflexivity, so the blocks cover the domain. Conversely, a partition defines equivalence by “belongs to the same block.” That relation is reflexive, symmetric, and transitive because block membership is unique. The two descriptions express the same structure from different directions.
On the finite domain {0,1,2,3,4,5}, parity produces two disjoint blocks. The quotient contains those two blocks, rather than choosing just the numbers zero and one as its members.
The quotient set is the set of distinct equivalence classes. Its elements are classes, not individual representatives, though a program may store a convenient representative label. A computation on representatives is meaningful on the quotient only if changing representative within a class cannot change the result’s class or value as intended. Later modular arithmetic will use this condition to justify operations on residues.
Equality of a deterministic key produces an equivalence relation: when . Equality supplies all three axioms. For example, stripping surrounding spaces and case-folding a name groups labels according to an explicit normalisation rule. That rule may merge two different people with the same name or collapse a distinction needed by the application. Mathematical equivalence of labels and suitability of the chosen key are separate questions.
If a similarity rule lacks transitivity, avoid calling its output equivalence classes. You could choose another clustering objective, or use connectivity through chains, but the latter changes the rule: a and c may become connected through b even though they share no keyword. The chosen repair should be declared and evaluated for its purpose. A programmer should not silently take a transitive closure and still describe the result as direct similarity.
Why does grouping records by exact equality of a fixed key avoid partially overlapping classes? Does it guarantee the key uniquely identifies a person?
Show answer
Key equality is an equivalence; if two groups share a record, their keys are equal and the groups coincide. It says nothing about whether different people share that key. Identity suitability requires extra modelling or information.
Partial orders total orders and Hasse diagrams
A partial order on D is reflexive, antisymmetric, and transitive. Write for it. Unlike equivalence, it describes an ordering relationship rather than interchangeable membership. Comparable means or . A total order is a partial order in which every pair is comparable. “Partial” permits incomparable pairs; it does not mean the three axioms hold only sometimes.
Set inclusion is a partial order on a power set. Every set includes itself; mutual inclusion gives equality; inclusion chains compose. On , singleton sets and are incomparable: neither includes the other. An implementation that assigns both a numerical position in a sorted list has chosen an additional ordering, not discovered an inclusion relation between them.
The four objects are . The empty set is below every object and the full set is above every object. The two singleton sets lie between them and are incomparable. This is a partial order but not a total order. Its least element is and greatest element .
A Hasse diagram for a finite partial order omits self-loops and edges already implied by transitivity. It draws a cover edge from x upward to y when and no domain object lies strictly between them. Upward paths represent the other comparisons. Omitting an edge does not make its comparison false if an upward path still exists. Conversely, objects without an upward path in either direction are incomparable in the diagram.
The inclusion order on the power set of {a,b} is a diamond. Upward edges are covers; reflexivity and the empty-to-full comparison are understood rather than drawn.
A least element is below every domain element. A minimal element has no distinct element below it. A least element is necessarily minimal, but a minimal element need not be least when some objects are incomparable. There can be multiple minimal elements, while a least element is unique if it exists: two least elements would be related both ways, so antisymmetry would make them equal. Greatest and maximal are the corresponding reversed notions.
Consider the domain containing only , ordered by inclusion. Both singletons are minimal; neither is least because each fails to be below the other. The full set is greatest. This example shows why a rule demanding “the smallest eligible item” needs a tie or incomparability policy. A partial order may not supply a unique choice without extra information.
Strict order notation removes equality: means and . For a partial order this strict relation is irreflexive and transitive. It is not itself reflexive, so do not classify as a non-strict partial order using the three earlier axioms. Conversely, a suitable strict order can be converted to a non-strict one by adding equality. State which convention is being used before checking its properties.
Dependencies often lead to partial orders through reachability: an object precedes another if it is the same object or has a directed path to it. To get antisymmetry for distinct objects, directed cycles must be excluded. Module 07 will develop graphs and topological ordering. For now, distinguish a direct dependency pair from its transitive reachability relation. A direct-edge list need not itself be transitive even when the overall dependency structure has a meaningful order.
Equivalence and order can coexist in an application but answer different questions. Grouping equal labels may give equivalence classes; ordering those groups by a prerequisite relation is another structure. Equality itself is both an equivalence and a partial order, though it is total only on domains of at most one element. This is another reason to read the axioms instead of assuming the categories can never overlap.
Remove the empty set from the diamond domain. Which objects are minimal, which are least, and why is sorting the remaining objects not enough to change those answers?
Show answer
Both singletons are minimal, and there is no least object. A sorting implementation can choose which singleton comes first, but that additional order does not make it a subset of the other singleton.
Functions as relations and reversible mappings
A function can be represented by its graph , a subset of . It is a special relation because for every input in A there is exactly one output in B. A relation may have no output or several outputs for a given input, so not every relation is a function. Declaring A and B remains essential even when a graph is listed.
A function is injective when implies for all inputs. Distinct inputs must have distinct outputs; every attained output identifies at most one input. It is surjective onto B when every has some with . That property depends on the declared codomain. A function is bijective when both conditions hold, so every codomain member has exactly one preimage.
Let and . With , the function is injective but not surjective: nine has no preimage. With and the same input–output rule, it is bijective. Replacing the codomain with the image changes the specified function’s target and resolves surjectivity; it does not invent a preimage for nine.
The inverse relation reverses every pair of . It defines a function on B exactly when f is bijective: surjectivity supplies an output for every inverse input, and injectivity ensures uniqueness. An injective function can instead have an inverse defined only on its image. If f is not injective, the reversed relation has multiple outputs for some input, so selecting one would require an extra rule rather than being the unique inverse.
For the real square function, , so it is not injective. Restricting the domain to nonnegative reals makes it injective and surjective onto the nonnegative reals, with inverse square root. This restriction is a mathematical choice. A feature mapping that drops an attribute can likewise lose distinctions between records. A later algorithm cannot reconstruct those distinctions uniquely from the feature value alone without extra information or assumptions.
An identifier key intended to identify every stored record uniquely should be injective on the record domain. It need not be surjective onto every possible identifier string: unused identifiers are normal. A label mapping may intentionally be many-to-one, because multiple records belong to the same class. Treating a label as a unique identifier would confuse these two purposes. The required property follows from the specification rather than from the word “mapping.”
Cardinality comparisons can be expressed by mappings. For finite sets, an injection A to B shows A has at most as many members as B; a bijection shows equal size. Equal finite sizes do not make every mapping bijective: a function may collide on two inputs and omit an output. You still need to inspect the actual rule. For infinite sets, a proper subset may have a bijection with the original set, so finite intuitions about “strictly fewer” do not transfer automatically.
A brief countability preview illustrates this. The map is a bijection from the natural numbers, including zero, to the even natural numbers, despite the latter being a proper subset. The integers can be listed as , and the rational numbers can be listed by organising integer numerators and positive denominators and skipping duplicates. These sets are countably infinite. The real numbers are uncountable; a full diagonal argument is deferred as further proof practice, not required for the labs here.
The lesson’s practical exit skill is to inspect a declared mapping, state what information it preserves, and determine whether a reversal is unique and total on the intended domain. Relations, equivalence classes, and orders give other ways to represent structure when a single reversible mapping is not appropriate. Choose the object matching the question before choosing an algorithm to process it.
A mapping sends record identifiers to binary class labels and maps several records to each label. Is it injective? If both labels occur, is it surjective onto {0,1}? Can a label uniquely recover a record?
Show answer
It is not injective because distinct records share a label. If both labels occur, it is surjective onto that codomain. A label cannot uniquely recover a record; surjectivity does not remove collisions.
Common misconceptions
| Symptom | Cause | Repair |
|---|---|---|
| A repeated observation disappears | A list was replaced with a set | Preserve multiplicity when the problem requires it |
| Complement includes unexpected records | No common universe was stated | Declare U before taking any complement |
| Antisymmetry is rejected because self-pairs exist | “Anti” was interpreted as no reverse pairs | Test mutual pairs only for distinct objects |
| Similar documents form unstable groups | Symmetry was mistaken for equivalence | Exhibit the failed triple and choose an explicit grouping objective |
| A later representative produces a different class | The rule lacks equivalence properties | Use a genuine equivalence or label the alternative clustering method |
| A minimal object is called least | Incomparable objects were ignored | Test comparison against every domain object |
| An inverse is assumed from a formula alone | Domain, codomain, or collisions were omitted | Check both uniqueness and coverage of inverse inputs |
Lab setup
Use Python 3.11 or later and the Python primer if needed. No packages are required. &, |, and - on sets mean intersection, union, and difference; they are not scalar arithmetic in these expressions. Explain predicted results, observed structure, and a fault or variation for each lab. Allocate ten explanation points per lab: 3 for prediction, 4 for interpretation, 3 for diagnosis.
Lab 1 Enumerate set identities
Forty minutes: list the eight subsets of {0,1,2}, predict the number of ordered triples of subsets, and run the script. It compares distributivity and a complement identity on every triple in this one universe. Explain why there are 512 triples, why the output sorts elements, and why the general proof still needs an arbitrary-member argument. Replace the right-hand intersection in De Morgan’s law with union; preserve a failing A,B pair and repair it.
Download lab1_set_identities.py
"""Exhaustive checks over one small universe, not a general set-theoretic proof."""
from itertools import combinations, product
def subsets(items):
return [set(part) for k in range(len(items) + 1) for part in combinations(items, k)]
def main():
universe = {0, 1, 2}
choices = subsets(sorted(universe))
print("Power set:", [sorted(s) for s in choices])
checks = 0
for a, b, c in product(choices, repeat=3):
assert a & (b | c) == (a & b) | (a & c)
assert universe - (a | b) == (universe - a) & (universe - b)
checks += 1
print("Distributivity and De Morgan agree for", checks, "triples in this universe.")
a, b = {0, 1}, {1, 2}
print("A union B:", sorted(a | b), "intersection:", sorted(a & b))
print("A minus B:", sorted(a - b), "B minus A:", sorted(b - a))
print("{} is a dict; set() is an empty set.")
print("General identities still require a proof for arbitrary membership.")
if __name__ == "__main__":
main()
Power set: [[], [0], [1], [2], [0, 1], [0, 2], [1, 2], [0, 1, 2]]
Distributivity and De Morgan agree for 512 triples in this universe.
A union B: [0, 1, 2] intersection: [1]
A minus B: [0] B minus A: [2]
{} is a dict; set() is an empty set.
General identities still require a proof for arbitrary membership.
Lab 2 Classify finite relations
Forty minutes: predict all four properties for equal parity, distance at most one, , and . Run the classifier and read each returned witness against the exact definition. Modify the domain to (0,1,2,3) and predict a new witness before execution. The identity relation’s final check demonstrates that symmetry and antisymmetry can coexist. The explorer above lets you create missing diagonal, reverse-pair, and transitivity failures directly.
"""Return one explicit witness for each failed property on a finite domain."""
from itertools import product
def failures(domain, relation):
pairs = list(product(domain, repeat=2))
triples = product(domain, repeat=3)
return {
"reflexive": next(((x, x) for x in domain if (x, x) not in relation), None),
"symmetric": next(((x, y) for x, y in pairs if (x, y) in relation and (y, x) not in relation), None),
"antisymmetric": next(((x, y) for x, y in pairs if x != y and (x, y) in relation and (y, x) in relation), None),
"transitive": next(((x, y, z) for x, y, z in triples if (x, y) in relation and (y, z) in relation and (x, z) not in relation), None),
}
def main():
domain = (0, 1, 2)
rules = {
"same parity": lambda x, y: x % 2 == y % 2,
"distance at most one": lambda x, y: abs(x - y) <= 1,
"less than or equal": lambda x, y: x <= y,
"strictly less": lambda x, y: x < y,
}
for name, rule in rules.items():
relation = {(x, y) for x, y in product(domain, repeat=2) if rule(x, y)}
result = failures(domain, relation)
print(name)
for property_name, witness in result.items():
print(" ", property_name + ":", "holds" if witness is None else f"fails at {witness}")
identity = {(x, x) for x in domain}
assert all(witness is None for witness in failures(domain, identity).values())
print("Identity is both symmetric and antisymmetric.")
if __name__ == "__main__":
main()
same parity
reflexive: holds
symmetric: holds
antisymmetric: fails at (0, 2)
transitive: holds
distance at most one
reflexive: holds
symmetric: holds
antisymmetric: fails at (0, 1)
transitive: fails at (0, 1, 2)
less than or equal
reflexive: holds
symmetric: fails at (0, 1)
antisymmetric: holds
transitive: holds
strictly less
reflexive: fails at (0, 0)
symmetric: fails at (0, 1)
antisymmetric: holds
transitive: holds
Identity is both symmetric and antisymmetric.
Lab 3 Diagnose a grouping rule
Forty minutes: predict the normalised-name groups and the two greedy keyword groupings. Run and explain the different results. Equality of a fixed key forms equivalence classes, while direct shared-keyword similarity does not. Do not describe normalised names as verified personal identity. As a variation, add a fifth record with name “Ada” but representing another person; explain why the code remains mathematically correct for its key and unsuitable for identifying people.
"""Equality of a declared key is an equivalence; shared keywords need not be."""
def main():
records = (("r1", "Ada"), ("r2", " ADA "), ("r3", "Lin"), ("r4", "LIN"))
groups = {}
for identifier, name in records:
key = name.strip().casefold()
groups.setdefault(key, []).append(identifier)
print("Groups by stripped, case-folded name:", groups)
print("This key defines equality of labels, not proof of personal identity.")
keywords = {"a": {"python"}, "b": {"python", "ai"}, "c": {"ai"}}
def related(x, y):
return bool(keywords[x] & keywords[y])
print("a~b:", related("a", "b"), "b~c:", related("b", "c"), "a~c:", related("a", "c"))
assert related("a", "b") and related("b", "c") and not related("a", "c")
def greedy(order):
result = []
for item in order:
for group in result:
if related(item, group[0]):
group.append(item)
break
else:
result.append([item])
return result
print("Representative grouping, order a,b,c:", greedy(("a", "b", "c")))
print("Representative grouping, order b,a,c:", greedy(("b", "a", "c")))
print("Repair: use an explicit equivalence key or declare a different clustering objective.")
if __name__ == "__main__":
main()
Groups by stripped, case-folded name: {'ada': ['r1', 'r2'], 'lin': ['r3', 'r4']}
This key defines equality of labels, not proof of personal identity.
a~b: True b~c: True a~c: False
Representative grouping, order a,b,c: [['a', 'b'], ['c']]
Representative grouping, order b,a,c: [['b', 'a', 'c']]
Repair: use an explicit equivalence key or declare a different clustering objective.
Exercises with complete solutions
Exercises 1–12 have a 110-minute budget and five points each. The optional pair adds 25 minutes. For a failed property, give inputs satisfying the premise and violating the conclusion. For a proof, state the domain and use an arbitrary member or complete logical argument.
For , , , compute union, intersection, both differences, and .
Show solution
The results are , , , , and . Difference direction changes the selected members; the complement uses the specified U.
For decide , , , and . List .
Show solution
The first three are true and the fourth false. The power set is . Membership and inclusion ask different questions.
List and compare with the reversed product. What if the second factor is empty?
Show solution
The pairs are . Reversed pairs put letters first and numbers second. An empty factor yields no pair, so the product is empty.
State the four relation properties as quantified rules and identify the shape of one counterexample for each.
Show solution
Reflexivity requires every ; a missing one refutes it. Symmetry requires a reverse for each present pair; a missing reverse refutes it. Antisymmetry forbids distinct mutual pairs. Transitivity requires whenever are present; a missing closing pair in a triple refutes it.
With complements relative to U, prove by arbitrary membership.
Show solution
For arbitrary , iff , iff and , iff . Outside U neither complement side has members. Hence the sets agree everywhere.
Prove equal parity is an equivalence on integers using differences, not a finite table.
Show solution
is even. If , then is even. If and , then is even. These prove reflexivity, symmetry, and transitivity for arbitrary integers.
Show any two overlapping classes of an equivalence relation are equal. Name where symmetry and transitivity enter.
Show solution
For shared z, and symmetry give . For , symmetry gives , and transitivity gives , so . Reversing x,y proves the opposite inclusion. Thus overlap forces equality.
Draw the Hasse diagram of inclusion on . Identify the incomparable pair, least element, and greatest element.
Show solution
Draw empty at the bottom, the two singletons in the middle, and the full set at the top, with four upward cover edges. The singletons are incomparable. Empty is least and full greatest. The empty-to-full relation follows by a path and needs no direct edge.
Let satisfy . Classify injectivity and surjectivity and describe its inverse relation.
Show solution
It is not injective because zero and two collide. It is surjective because both outputs occur. The inverse relation contains and is not a function: input zero has two outputs.
Group {0,1,2,3,4,5} by equal parity. Write the quotient set and distinguish it from one possible set of representative labels.
Show solution
The quotient is . Labels such as {0,1} may represent its two classes in a program, but the quotient’s mathematical elements are the blocks themselves.
A report says a relation cannot be antisymmetric because it contains . Refute the reasoning and give a genuine failed-antisymmetry witness.
Show solution
The implication permits mutual pairs when their objects are equal, so is harmless. A relation containing and fails antisymmetry because zero and one are distinct. Equality is both symmetric and antisymmetric.
Use the keyword example to explain order-dependent representative grouping. Is making all chain-connected documents one block a faithful implementation of direct keyword sharing?
Show solution
Starting with a groups a,b, then excludes c because c does not match representative a. Starting with b can group all three. The rule is not transitive. Chain connectivity would group all three consistently, but then a,c are grouped without a direct shared keyword. It is a different declared relation, not preservation of the original direct-match rule.
Optional: prove is a bijection from onto the even natural numbers and explain why it is not surjective onto all of .
Show solution
If , cancellation gives , so it is injective. Every even natural is for a natural k, giving a preimage. An odd natural such as one has no preimage, so enlarging the codomain to all naturals breaks surjectivity.
Optional: prove a least element of a partial order, if present, is unique. Then give an order with two minimal elements and no least element.
Show solution
If a and b are both least, and , so antisymmetry gives . Inclusion on has two incomparable minimal singletons and no least member. Existence and uniqueness are different issues.
Self check quiz
Complete nine automatically checked choices and one written explanation. Review the definitions when feedback identifies a confusion; a familiar name does not replace its quantified rule.
Show answer
Use keyword sets a={python}, b={python,ai}, c={ai}. Then aRb and bRc, but not aRc, violating transitivity. Equivalence needs reflexivity, symmetry, and transitivity; symmetry alone is insufficient. Award the written point for the explicit three-object witness and correct axiom, not just a statement that grouping “looks inconsistent.”
Guided reading
Required, 15 minutes: in the textbook linked by MIT Mathematics for Computer Science, read the elementary set and binary-relation definitions. Rewrite one membership identity using logical connectives and compare the use of subset notation.
Required, 20 minutes: read its equivalence-relation and partial-order discussions. Write their axiom lists side by side and explain which axiom changes the purpose. Draw the four-object inclusion diagram yourself. Advanced countability is optional here.
Optional: use the official Python set documentation to compare mutable sets with frozenset and to distinguish empty-set construction from an empty dictionary. All diagrams and teaching examples here are original.
Review and readiness for proofs
Membership gives set operations; arbitrary-member arguments establish identities. Relations select pairs, and quantified axioms determine which structures they represent. Equivalence gives partitions into interchangeable blocks. Partial orders give comparisons that may leave some objects incomparable. Functions add unique outputs; bijections permit unique reversal on the whole codomain.
Exit task: prove one complement identity, classify a three-object relation with concrete failure witnesses, draw a Hasse diagram with an incomparable pair, and determine whether a listed function has a total inverse. Use exercises 60, lab explanations 30, and quiz 10 including the reviewed written point. Explain any failed prerequisite after correction.
Module 04 develops direct proofs, contradiction, induction, and program invariants. Its starting skill is to take an arbitrary object, use the relevant definitions, and state a conclusion whose scope matches the argument. Keep the membership and parity proofs as examples of that pattern.
Notation and bilingual terms
| Term or notation | Meaning | 中文 |
|---|---|---|
| , | Membership, inclusion allowing equality | 属于、包含于 |
| , , | Union, intersection, difference | 并、交、差 |
| Complement in a fixed universe | 补集 | |
| , | Power set, Cartesian product | 幂集、笛卡尔积 |
| Reflexive / symmetric | All self-pairs / all reverse pairs | 自反 / 对称 |
| Antisymmetric / transitive | No distinct mutual pairs / chains close | 反对称 / 传递 |
| , | Equivalence class, quotient set | 等价类、商集 |
| Partition | Disjoint nonempty blocks covering a domain | 划分 |
| Partial / total order | Order axioms / additionally all pairs comparable | 偏序 / 全序 |
| Least / minimal | Below all / no distinct predecessor | 最小 / 极小 |
| Injective / surjective / bijective | No collisions / codomain covered / both | 单射 / 满射 / 双射 |