Review: pick the right tool
Mixed proofs about lights and fees, with no step checklist.
Lesson 8 of 80/8 done0 of 8 lessons completed in this course. Open the list of lessons.
No new material: each exercise mixes the tools of this course, and none has a checklist. Before each one, ask which tool fits the goal: unfold to look inside a definition, simp to simplify, omega for arithmetic, cases to split a value of an inductive type, contradiction for impossible branches.
The traffic light from Lean foundations is given above the editor: next moves red to green, green to yellow and yellow to red, and canGo is true only for green.
Worked example
inductive Light where
| red
| yellow
| green
def next : Light → Light
| .red => .green
| .green => .yellow
| .yellow => .red
def canGo : Light → Bool
| .green => true
| _ => falseexample (l : Light) (h : l = Light.red) : canGo (next l) = true := by
rw [h]
rfl
At the start of the proof on line 1. Everything above ⊢ may be used; the line below it is what must be proved.
With h the light is known, so after rewriting everything computes.
Match the tool to the goal: unfold to look inside, simp to simplify, omega for arithmetic, cases to split, contradiction for the impossible.
Prove that after three steps a light is back where it started.
\to in the editor, or click:Where you start. Everything above ⊢ may be assumed; the line below it is what you must prove.
Knowledge check
Answer from memory. Each answer is checked as you pick it.