The previous task started with an “or” hypothesis. Here we'll look start with anl “and” hypothesis.
Task
For integers
show that
The symbol
Maths
Once we realise a hypothesis of the form
In this sense, conjunctive hypotheses are not particularly interesting, but we do need to learn how to handle them.
Let's write a proof, making clear each step.
From the single conjunctive hypothesis
We start with
Code
The following Lean program proves
-- 08 - Conjunctive "and" Hypothesis
import Mathlib.Tactic
example {x y : ℤ} (h : x = 5 ∧ y = x + 3) : y = 8 := by
obtain ⟨ ha , hb ⟩ := h
calc
y = x + 3 := by rw [hb]
_ = (5) + 3 := by rw [ha]
_ = 8 := by norm_num
As usual, the proof header declares the variable types, establishes the hypothesis, and defines the overall proof goal. The hypothesis is a conjunction, and uses the symbol ∧ to denote “logical and”.
The next step is to replace the conjunctive hypothesis with two smaller hypotheses. The instruction obtain ⟨ ha, hb ⟩ := h does this. It splits the conjunctive hypothesis h into ha and hb, and then removes h.
Notice the comma and angle brackets ⟨⟩ used to split a conjunction, unlike the vertical bar | and no brackets used to split a disjunction.
The rest of the proof uses the familiar calc structure to show y = 8.
Infoview
Placing the cursor before the obtain instruction shows there is only one hypothesis g.
x y : ℤ
h : x = 5 ∧ y = x + 3
⊢ y = 8
Placing the cursor on the next line after obtain, confirms h has been replaced by ha and hb.
x y : ℤ
ha : x = 5
hb : y = x + 3
⊢ y = 8
Notice the hypothesis h has been entirely removed.
Easy Exercise
Write a Lean program to show that
where