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 nn a nonzero natural number, the statement "2n2^n is odd" is equivalent to "77 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' runs tac on the main goal and tac' on each produced goal, concatenating all goals produced by tac'.

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