We've seen that a hypothesis can be a disjunction or a conjunction.
Here we look at a slightly more interesting scenario, a proof goal that is a disjunction.
Task
For integer
Maths
Our initial reaction might be concern at seeing
Remember that
Given the hypothesis
Let's write a step by step proof.
Once we state that it is sufficient to prove
Choice
If the proof objective were
We can choose which one of the two statements we want to prove. We don't need to prove both, because proving one is sufficient for a disjunction.
Code
The following Lean program proves
-- 09 - Disjunctive "or" Goal
import Mathlib.Tactic
example {x : ℤ} (h : x = -1) : x^2 = 1 ∨ x^3 = 1 := by
left
calc
x^2 = (-1)^2 := by rw [h]
_ = 1 := by norm_num
As usual, the proof header declares the variable types, establishes the hypothesis, and defines the overall proof objective. The objective here is a disjunction, and uses the symbol
We state our intention to prove only the “left” part of the disjunction. The instruction left does precisely this.
The Infoview will confirm that left replaces the goal x^2 = 1 ∨ x^3 = 1 with x^2 = 1.
The rest of the proof uses the familiar calc structure to show x^2 = 1. This matches the new proof goal, and because it is sufficient, the original goal x^2 = 1 ∨ x^3 = 1 is also proven.
Infoview
Placing the cursor before the left instruction shows the original proof goal.
x : ℤ
h : x = -1
⊢ x ^ 2 = 1 ∨ x ^ 3 = 1
Placing the cursor on the next line after left confirms the proof goal has been replaced by a smaller, but sufficient, goal.
x : ℤ
h : x = -1
⊢ x ^ 2 = 1
This manipulation of the proof goal might appear to be a hack, something to be discouraged. In fact, it is quite common, and considered quite normal.
Easy Exercise
A longer disjunction could be
For integer