Skip to content

11.3 Discrete math 1 problem set: sets, counting, proofs, induction, relations, bijections

The chapters ahead are arguments as much as code. Graphs, DAGs, and an iterative topological sort must order every node of the autograd graph before backward runs, and the only convincing evidence that it does is an induction over the traversal. Modular arithmetic, hashing, and PCG32 builds a generator whose state wraps modulo 2642^{64} and whose output is a counted rotation of bits. Counting: parameters, FLOPs, KV bytes, and memory plans turns a ModelConfig into counts that decide whether a model fits on a laptop, and Injective, surjective, bijective: the GPT-2 byte map proves a byte table invertible. In AI Engineering, Masks: causal, padding, sliding window, additive builds attention masks from boolean algebra, and Softmax in C: three-pass and online two-pass streams a softmax in one pass under a loop invariant.

Concepts from other sections (4)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

This set gives the vocabulary and the proof habits those sections assume: sets and logic, counting, the standard proof methods, induction, relations, and functions. It needs only high-school algebra and the overview in the chapter opening, and it is best worked before the two sections of this chapter.

The set has 23 problems with exact answers (34 parts) and 18 proofs, whose model proofs are also in course/solutions/solve/S-M05/. Every problem is followed by a collapsed worked answer with the final result or a complete model proof, and the common wrong answers and why they are wrong. Try each problem before opening its answer.

Learning objectives

  • Manipulate sets and quantified statements, including negating nested quantifiers, and read an attention mask as a set.
  • Count with the product, permutation, combination, and stars-and-bars rules, and apply them to parameters, FLOPs, and KV-cache bytes.
  • Write complete direct, contrapositive, contradiction, case, and pigeonhole proofs.
  • Prove statements by induction and prove loops correct with invariants.
  • Classify relations, and prove functions injective, surjective, or bijective.
  1. Tools and a worked proof: Connect set, logic, counting, and induction tools to a worked argument.
  2. Sets, logic, and counting: Work the set, quantified-logic, and counting problems before revealing solutions.
  3. Proofs, induction, and invariants: Choose a proof method and connect induction to loop invariants.
  4. Relations, functions, and validation: Check relation properties and prove function/bijection claims with explicit domains.