Zulip Chat Archive
Stream: new members
Topic: duplicate goals - what is best practice?
rzeta0 (Aug 30 2024 at 21:58):
Consider proving
In school we learned that twice, a repeated root.
This seems to have popped up in my learning to write Lean proofs as a duplicate goal.
Question: how do I tell Lean that I don't need to prove the same goal twice?
A better question: what is best practice when dealing with duplicate goals?
import Mathlib.Tactic
example {x : ℝ} (h: x*x = 0) : x = 0 := by
have h1 := eq_zero_or_eq_zero_of_mul_eq_zero h
obtain ha | hb := h1 -- <-- ha and hb are the same x=0
· rw [ha] -- the same as below
· rw [hb] -- the same as above
(Also I'm new to the focussed dot, did I use it correctly above? )
Ruben Van de Velde (Aug 30 2024 at 22:04):
For example:
import Mathlib.Tactic
example {x : ℝ} (h: x*x = 0) : x = 0 := by
have h1 := eq_zero_or_eq_zero_of_mul_eq_zero h
obtain ha | ha := h1 -- <-- in both cases, ha is x=0
<;> -- <-- run the next thing on both subgoals
· rw [ha] -- <-- this works in either case
Ruben Van de Velde (Aug 30 2024 at 22:05):
Another way could be
import Mathlib.Tactic
example {x : ℝ} (h: x*x = 0) : x = 0 := by
have h1 := eq_zero_or_eq_zero_of_mul_eq_zero h
rw [or_self] at h1
exact h1
Last updated: May 02 2025 at 03:31 UTC