Zulip Chat Archive
Stream: new members
Topic: Proof by Contradiction
Mohammed (Sep 14 2024 at 17:46):
I am new to Lean, so I am very inexperienced with all the specific tactics we could use to prove things.
Currently I am trying to prove this:
I plan to use contradiction, since I think that's the quickest route, but I can't seem to figure it out.
This is part of a larger proof (bijection), but I have already solved for the opposite direction.
Daniel Weber (Sep 14 2024 at 17:52):
Do you have a #mwe?
Julian Berman (Sep 14 2024 at 17:52):
Can you perhaps write out the statement you're trying to prove in Lean, rather than LaTeX? Besides making it a bit easier for others to help, it also can help make precise things like "what type is x in what you want to prove"?
Ruben Van de Velde (Sep 14 2024 at 17:52):
rintro rfl; norm_num
should do it
Daniel Weber (Sep 14 2024 at 17:52):
Why do you want to do a proof by contradiction? Is something wrong with
example (x : Int) : x = 4 → x * (x * x) - x * x * 5 - (x + x) = -24 := by
intro a
rw [a]
rfl
Mohammed (Sep 14 2024 at 17:55):
@Daniel Weber Since it's part of a larger proof, I think I can write something out but I'm not sure if it'll be entirely accurate.
example (x : ℝ) (h1 : x * (x * x) - x * x * 5 - (x + x) = -24): x = 4 := by sorry
This should be a replication of where I am at in the proof.
(The previous steps separated the iff into both directions.)
Daniel Weber (Sep 14 2024 at 17:57):
Ah, that's the opposite of the direction you've written in LaTeX
Mohammed (Sep 14 2024 at 17:58):
Oh my apologies, I didn't realize.
Daniel Weber (Sep 14 2024 at 17:59):
In any case, that's not true - x
could also be 3
, for instance
Mohammed (Sep 14 2024 at 17:59):
Yes it could be -2, 3 or 4.
Edward van de Meent (Sep 14 2024 at 17:59):
or even -2
Daniel Weber (Sep 14 2024 at 18:01):
theorem factor (x : ℝ) : x * (x * x) - x * x * 5 - (x + x) = (x + 2) * (x - 3) * (x - 4) - 24 := by ring
example (x : ℝ) (h1 : x * (x * x) - x * x * 5 - (x + x) = -24) : x = -2 ∨ x = 3 ∨ x = 4 := by
simpa [factor, sub_eq_zero, add_eq_zero_iff_eq_neg, or_assoc] using h1
Mohammed (Sep 14 2024 at 18:06):
Thank you, I will try it out.
Mohammed (Sep 14 2024 at 18:07):
Is it normal to come up with a theorem for a specific proof? I usually always try to keep my proofs within the example/indentation level for superficial reasons.
Daniel Weber (Sep 14 2024 at 18:11):
You can also do
import Mathlib
example (x : ℝ) (h1 : x * (x * x) - x * x * 5 - (x + x) = -24) : x = -2 ∨ x = 3 ∨ x = 4 := by
have factor : x * (x * x) - x * x * 5 - (x + x) = (x + 2) * (x - 3) * (x - 4) - 24 := by ring
simpa [factor, sub_eq_zero, add_eq_zero_iff_eq_neg, or_assoc] using h1
if you prefer
Mohammed (Sep 14 2024 at 18:16):
Thanks, I haven't used have
before so I will use this as an example.
Although these solutions worked, I would like to know how they are applied in Lean? I have tried to go through the line but it is not very human readable.
Ruben Van de Velde (Sep 14 2024 at 18:22):
The point is that you "manually" factor the expression, and then simpa
uses mul_eq_zero
to go from (x - a)(x - b) = 0 to x - a = 0 \or x - b = 0 and then sub_eq_zero to get to x = a \or x = b
Mohammed (Sep 14 2024 at 18:25):
Okay I see now, thank you Ruben.
Mohammed (Sep 14 2024 at 18:29):
I cannot mark this as completed, I must complete the rest of my proofs after a short break.
Thank you to everyone who assisted me.
Last updated: May 02 2025 at 03:31 UTC