The Lumenary · Early undergraduate
Formalising mathematics in Lean and Mathlib
Name: ______________________
Date: ______________________
You will learn to
- Formalise definitions and proofs about sets, functions and quantifiers in Lean, such as the facts that a composite of injections is injective and that images preserve unions
- Use structures, type classes and Mathlib's algebraic hierarchy to state and prove results about every monoid or group at once
- Search Mathlib for existing results, and explain the trade-off between citing a library lemma and proving a result from scratch
- Recognise the conventions and hidden hypotheses that formalisation exposes, such as and truncated subtraction on
- Explain what a machine check guarantees — and what it does not — using the kernel,
#print axioms, and the need for definitions to match standard usage
- 1.
With
f : α → βandg : β → γ, which Lean statement says that a composite of injective functions is injective?- A.
Injective g → Injective f → Injective (g ∘ f) - B.
Injective (g ∘ f) → Injective g - C.
∃ f g, Injective (g ∘ f) - D.
Injective g ∧ Injective f
- A.
- 2.
To prove that is injective, we assume and must show . Which fact do we use first?
- A.Injectivity of , to get
- B.Injectivity of , to get directly
- C.Surjectivity of
- D.Associativity of composition
- 3.
Which function gives sets with ?
- A. for all
- B.
- C.
- D.
- 4.
Which of these statements about natural numbers are true? (Choose all that apply.)
- A.
- B.
- C.
- D.
- 5.
In Lean, with natural numbers, what is the value of
(5 : ℕ) - 8 + 8? - 6.
In Mathlib,
(7 : ℝ) / 0 = 0is a theorem (div_zero). What follows?- A.Nothing false: laws such as
a / b * b = arequire the hypothesisb ≠ 0, so the convention cannot be used to cancel a zero. - B.
7 = 0, by multiplying both sides by0. - C.Lean's logic is inconsistent.
- D.Real analysis defines division by zero.
- A.Nothing false: laws such as
- 7.
#print axioms limit_uniquereports[propext, Classical.choice, Quot.sound]. What does this tell you?- A.The proof is complete (no
sorry) and uses only Lean's three standard axioms, including choice. - B.The proof is incomplete, because it depends on axioms.
- C.The proof is constructive.
- D.
limit_uniquewas itself assumed as an axiom.
- A.The proof is complete (no
- 8.
In the proof that a group in which every satisfies is commutative, we write . Which group law justifies the middle equality?
- A.The inverse of a product is the product of the inverses in reverse order (Mathlib's
mul_inv_rev). - B.Commutativity of multiplication.
- C. for all .
- D.Uniqueness of the identity element.
- A.The inverse of a product is the product of the inverses in reverse order (Mathlib's
- 9.
Write
find_counterexample(a, b)that searches all functions from to (as tuples of values) and all pairs of subsets of the domain, and returns the first(f, S, T)with (withS,Tas Python sets), orNoneif there is none. Useitertools.Computational — Practice