Zulip Chat Archive
Stream: new members
Topic: Proving false is equivalent to false
Barinder S Banwait (Apr 24 2024 at 13:57):
I'm at a point in a proof where my goal is to prove that, for a nonzero natural number, the statement " is odd" is equivalent to " is even'". Each statement is obviously false so the two are indeed equivalent, but I'm having trouble formalizing this in Lean:
example (n : ℕ) (h : n ≠ 0) : Odd ((2 : ℤ) ^ n) ↔ Even (7 : ℤ) := by
sorry
(Type casting to ℤ arises from a previous part of the proof.)
Can anyone help get me unstuck?
Markus Himmel (Apr 24 2024 at 14:07):
Which part are you stuck on? Showing that the statements are individually false or concluding the claim from that? Once you have that the statements are individually false, simp
is usually really good at finishing off the goal. Here's a proof:
import Mathlib
theorem not_even_seven : ¬Even (7 : ℤ) := by decide
theorem not_odd_two_pow (n : ℕ) : n ≠ 0 → ¬Odd ((2 : ℤ) ^ n) := by
cases n <;> simp [pow_succ]
example (n : ℕ) (h : n ≠ 0) : Odd ((2 : ℤ) ^ n) ↔ Even (7 : ℤ) := by
simp [not_even_seven, not_odd_two_pow _ h]
Yaël Dillies (Apr 24 2024 at 14:12):
or use docs#iff_of_false
Barinder S Banwait (Apr 24 2024 at 14:18):
Markus Himmel said:
Which part are you stuck on? Showing that the statements are individually false or concluding the claim from that? Once you have that the statements are individually false,
simp
is usually really good at finishing off the goal. Here's a proof:import Mathlib theorem not_even_seven : ¬Even (7 : ℤ) := by decide theorem not_odd_two_pow (n : ℕ) : n ≠ 0 → ¬Odd ((2 : ℤ) ^ n) := by cases n <;> simp [pow_succ] example (n : ℕ) (h : n ≠ 0) : Odd ((2 : ℤ) ^ n) ↔ Even (7 : ℤ) := by simp [not_even_seven, not_odd_two_pow _ h]
Thanks for your response Markus; I was trying to split the ↔
and attempt to prove each direction, but I couldn't get that to work. I've not seen <;>
before, is that like repeat
?
Barinder S Banwait (Apr 24 2024 at 14:21):
but from Yaël's response, it seems I was looking for apply iff_of_false
:sweat_smile:
Markus Himmel (Apr 24 2024 at 14:22):
You can hover over the <;>
in VS Code to get a description. It says
tac <;> tac'
runstac
on the main goal andtac'
on each produced goal, concatenating all goals produced bytac'
.
Barinder S Banwait (Apr 24 2024 at 14:22):
Here's the solution inspired by both Markus and Yaël:
example (n : ℕ) (h : n ≠ 0) : Odd ((2 : ℤ) ^ n) ↔ Even (7 : ℤ) := by
apply iff_of_false
· exact not_odd_two_pow n h
· decide
Last updated: May 02 2025 at 03:31 UTC