Sets, Logic and Proofs
Sets collect the objects, logic tests claims about them, and proofs chain tested claims into conclusions you can trust without rechecking.
Why Does This Exist?
Every ML argument stands on three legs, and most confusion comes from mixing them up. "The training set" is a set question: which objects are in? "If accuracy drops then roll back" is a logic question: which claims follow? "This optimizer converges" is a proof question: why should anyone believe it? Teams that cannot separate the three debug the wrong layer: rewriting pipelines when the logic was faulty, or doubting correct code when the dataset was misdefined.
This page maps the territory: what each leg does, how they connect, and where each gets its full treatment. Set operations live with Venn diagrams, connectives live with propositional logic, and the methods live in proof techniques. Counting what your sets contain is combinatorics, and updating beliefs about them is Bayes theorem.
The one idea you need first
A claim is a sentence that is either true or false, never both and never neither. "7 is odd" qualifies. "Wow, big number" does not, because there is nothing to check. Sets collect the objects claims talk about, logic combines claims into bigger ones, and proofs assemble true claims into new true claims. Everything below is machinery for handling claims responsibly.
Think of It Like This
A kitchen, a recipe, and a tasting panel
You run a kitchen. The pantry is your set: exactly what is on the shelves, no more. The recipe is your logic: if the oven is hot and the timer rings, the bread is done. The tasting panel is your proof: independent judges confirm this loaf is good, so tomorrow's diners need not re-taste every slice.
Skip the inventory and the recipe names missing items. Skip the recipe and tasting is random. Skip the tasting and every meal is a gamble. ML fails the same three ways: undefined data, faulty conditionals, and unproven convergence claims served with confidence.
Where it stops: a kitchen feeds people tonight, while a proof must convince a stranger next year. Taste changes with judges, but a checked proof stays checked.
How It Actually Works
The pipeline runs in three stages, each answering its own question.
- Sets answer "what is in?" A set like selects by a membership rule. Union, intersection, and complement combine selections. Order does not matter, duplicates collapse, and everything is exact.
- Logic answers "what follows?" From "every member of is black" and " is in ", logic derives " is black" mechanically. Connectives (and, or, not, implies) build compound claims whose truth is computed from the parts.
- Proofs answer "why certain?" A proof chains logic steps from agreed starting points to the conclusion, so any checker reaches the same verdict. The standard methods are direct argument, contradiction, and induction.
In plain words: sets draw the boundaries, logic moves truth across them, and proofs record the journey so it never needs repeating. A dataset definition, a training conditional, and a convergence theorem are the same three stages wearing work clothes.
Worked example
Twelve shelter cats: 7 black, 5 tabby. Define as the black ones.
- Sets: , complement , union with the tabbies . Selection is exact: .
- Logic: test "every cat in is black" by checking each of the 7. All pass. Then test "every cat here is black": the 8th check lands on a tabby and fails, so the universal claim is false. One counterexample kills it.
- Proof: "some cat here is not black" follows by exhibiting that tabby. A single verified example proves an existence claim conclusively. No rechecking needed.
Seven in, two claims tested, one certified: the whole pipeline on twelve cats.
Code
The point is the check, not the syntax. Membership decides the set, then logic tests the claim over exactly that set.
cats: list[str] = ["black"] * 7 + ["tabby"] * 5
B: set[int] = {i for i, c in enumerate(cats) if c == "black"}
print(len(B), len(cats) - len(B), len(cats)) # -> 7 5 12print(all(cats[i] == "black" for i in B)) # -> Trueprint(all(c == "black" for c in cats)) # -> FalseThe first line builds the set by rule. The second confirms all 7 members pass. The third shows the universal claim over all 12 fails, exactly as the hand count says.
Watch Out For
Proving a claim about a misdefined set
A flawless proof over the wrong collection convinces everyone of nothing useful. "The model never errs on the test set" can check out while the test set silently overlaps training. The logic is valid, the proof steps hold, and the conclusion misleads because membership was wrong.
Define and audit the set first, in writing, before reasoning about it. If a result surprises you, re-examine membership before re-examining logic.
Treating an unproven hope as a proven lemma
"It usually converges" slides into "it converges" inside long arguments, and everything downstream inherits the gap. Training lore is full of steps that hold on one dataset and nowhere else.
Label each claim as you go: assumed, tested once, or proven. Never let an assumed claim support a conclusion without flagging the dependency.
The Quick Version
- Sets collect: membership rules define exactly which objects count, with no duplicates and no ambiguity.
- Logic derives: connectives move truth from premises to conclusions mechanically.
- Proofs certify: chained steps let any checker reach the same verdict without repeating the work.
- 7 of 12 cats selected, a universal claim felled by one tabby, and existence proven by example.
- Audit the set before trusting any reasoning about it.
- Track whether each claim is assumed, tested, or proven, and never upgrade it silently.