48. What comes before red
A traffic light cycles red → green → yellow → red. Prove that if next l is red, then l is yellow.
Two of the three cases are impossible, and Lean has to be told so.
1inductive Light where
2 | red
3 | yellow
4 | green
5
6def next : Light → Light
7 | .red => .green
8 | .green => .yellow
9 | .yellow => .red
10theorem solution (l : Light) (h : next l = Light.red) : l = Light.yellow := by
givenLoading editor…
Type
\to in the editor, or click:Where you start. Everything above ⊢ may be assumed; the line below it is what you must prove.
l:Light
h:next l = Light.red
⊢l = Light.yellow
ReadyLn 1, Col 1Lean 4
Draft saved in this browser