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,rwandsimp - Explain the idea "propositions are types, proofs are terms", for example why a proof of is a function
- Prove a statement about natural numbers by induction in Lean, and explain why holds by definition while 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.
Let
n : ℕbe a variable. Which of these goals can be closed byrflalone? (Choose all that apply.)- A.
n + 0 = n - B.
2 + 3 = 5 - C.
0 + n = n - D.
n + 1 = 1 + n
- A.
- 2.
A classmate's Lean file compiles with the warning "declaration uses
sorry". What can you conclude?- A.The theorem is not proved:
sorryis a placeholder Lean accepts on trust, and#print axiomswould listsorryAx. - 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.
- A.The theorem is not proved:
- 3.
In Lean, what is the value of
(7 : ℕ) - 10? - 4.
In Lean, what is the value of
(17 : ℕ) / 5? - 5.
You are proving
theorem t (p q : Prop) : p → (q → p) := byand you typeintro hp. What does the goal state look like now?- A.Hypotheses
p q : Propandhp : p; goal⊢ q → p - B.Hypotheses
p q : Propandhp : p → q; goal⊢ p - C.Hypotheses
p q : Prop; goal⊢ p - D.No goals: the proof is complete.
- A.Hypotheses
- 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⟩
- A.
- 7.
The theorem
no_nat_sqrt_two : ¬ ∃ q : ℕ, q * q = 2is proved in Lean withoutsorry. Does it show that is irrational?- A.No. It only says no natural number squares to ; 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.
Mathlib contains
theorem Nat.exists_infinite_primes (n : ℕ) : ∃ p, n ≤ p ∧ Nat.Prime p. Which reading is correct?- A.For every natural number there is a prime with .
- B.There is a prime that is at least as big as every natural number .
- C.Every natural number is prime.
- D.There are exactly primes.
- 9.
In the induction proof of
0 + n = n, the inductive step has hypothesisih : 0 + k = kand 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
- A.
- 10.
Truth tables decide propositional tautologies by brute force. Write
is_tautology(formula, n), whereformulais a Python function ofnBooleans, returningTrueexactly when it is true for all assignments. (In Python,p <= qon Booleans means .)Computational — Practice