Skip to content
The Lumenary

Each worksheet prints cleanly on A4 or Letter. Answer keys are on a separate page.

The Lumenary · Grades 9–12

First steps in Lean

Name: ______________________

Date: ______________________

You will learn to

  • Write and check short Lean proofs of propositional tautologies and simple equalities using rfl, intro, exact, constructor, cases, rw and simp
  • Explain the idea "propositions are types, proofs are terms", for example why a proof of p→qp \to q is a function
  • Prove a statement about natural numbers by induction in Lean, and explain why n+0=nn + 0 = n holds by definition while 0+n=n0 + n = n needs induction
  • Read a Mathlib theorem statement, and distinguish applying a library theorem from proving a result independently
  • Explain what a machine check guarantees (and what it does not), including sorry, axioms, and mis-stated theorems
  1. 1.

    Let n : ℕ be a variable. Which of these goals can be closed by rfl alone? (Choose all that apply.)

    • A.n + 0 = n
    • B.2 + 3 = 5
    • C.0 + n = n
    • D.n + 1 = 1 + n
  2. 2.

    A classmate's Lean file compiles with the warning "declaration uses sorry". What can you conclude?

    • A.The theorem is not proved: sorry is a placeholder Lean accepts on trust, and #print axioms would list sorryAx.
    • B.The theorem is proved, because the file compiles.
    • C.The theorem is false.
    • D.Lean found a proof automatically and is warning that it is long.
  3. 3.

    In Lean, what is the value of (7 : ℕ) - 10?

  4. 4.

    In Lean, what is the value of (17 : ℕ) / 5?

  5. 5.

    You are proving theorem t (p q : Prop) : p → (q → p) := by and you type intro hp. What does the goal state look like now?

    • A.Hypotheses p q : Prop and hp : p; goal ⊢ q → p
    • B.Hypotheses p q : Prop and hp : p → q; goal ⊢ p
    • C.Hypotheses p q : Prop; goal ⊢ p
    • D.No goals: the proof is complete.
  6. 6.

    Which term is a proof of p ∧ q → q ∧ p?

    • A.fun ⟨hp, hq⟩ => ⟨hq, hp⟩
    • B.fun ⟨hp, hq⟩ => ⟨hp, hq⟩
    • C.fun h => h
    • D.⟨hq, hp⟩
  7. 7.

    The theorem no_nat_sqrt_two : ¬ ∃ q : ℕ, q * q = 2 is proved in Lean without sorry. Does it show that 2\sqrt 2 is irrational?

    • A.No. It only says no natural number squares to 22; irrationality is about fractions, which this statement never mentions.
    • B.Yes, because Lean checked it.
    • C.Yes, because every rational number is a natural number.
    • D.No, because the proof must be wrong.
  8. 8.

    Mathlib contains theorem Nat.exists_infinite_primes (n : ℕ) : ∃ p, n ≤ p ∧ Nat.Prime p. Which reading is correct?

    • A.For every natural number nn there is a prime pp with p≥np \ge n.
    • B.There is a prime pp that is at least as big as every natural number nn.
    • C.Every natural number p≥np \ge n is prime.
    • D.There are exactly nn primes.
  9. 9.

    In the induction proof of 0 + n = n, the inductive step has hypothesis ih : 0 + k = k and goal ⊢ 0 + (k + 1) = k + 1. Which tactic line closes the goal?

    • A.rw [Nat.add_succ, ih]
    • B.rw [ih]
    • C.rfl
    • D.exact ih
  10. 10.

    Truth tables decide propositional tautologies by brute force. Write is_tautology(formula, n), where formula is a Python function of n Booleans, returning True exactly when it is true for all 2n2^n assignments. (In Python, p <= q on Booleans means p→qp \to q.)

    Computational — Practice

Code: Apache-2.0 · Content: CC BY-SA 4.0