Zulip Chat Archive

Stream: maths

Topic: Mod 2 alternating truth value


Mark Andrew Gerads (Jan 13 2023 at 06:32):

I need this lemma, and do not know how to prove it. I wrote an induction lemma about hyperoperators that depends on this lemma.

lemma mod_two_alternates (k : ) : (k.succ % 2 = 0) = ¬(k % 2 = 0):=

Mark Andrew Gerads (Jan 13 2023 at 06:42):

I don't know how to deal with mods. My best try is this:

lemma mod_two_alternates (k : ) : (k.succ % 2 = 0) = ¬(k % 2 = 0):=
begin
  rw eq_iff_iff,
  split,
  intros h0,
  sorry,
  intros h1,
  sorry,
end

Patrick Johnson (Jan 13 2023 at 06:44):

import data.nat.parity

example {k : } : (k.succ % 2 = 0) = ¬(k % 2 = 0) :=
by simp_rw [nat.even_iff, nat.even_add_one]

Mark Andrew Gerads (Jan 13 2023 at 06:59):

Because you helped, I added you as an author here: https://github.com/leanprover-community/mathlib/pull/18116

Eric Rodriguez (Jan 13 2023 at 11:21):

Usually these types of lemmas are written using iff, instead of equality - why do you need the equality?

Eric Wieser (Jan 13 2023 at 11:22):

Note that in the end the answer was to use even and docs#nat.even_add_one directly

Mark Andrew Gerads (Jan 13 2023 at 11:56):

Eric Rodriguez said:

Usually these types of lemmas are written using iff, instead of equality - why do you need the equality?

I needed it for a lemma hyperoperation_ge_four_zero in https://github.com/leanprover-community/mathlib/pull/18116/files .
The lemma has been rewritten, like @Eric Wieser mentioned.

Eric Wieser (Jan 13 2023 at 11:59):

That answers "why do I need a result with (k.succ % 2 = 0) on the LHS and ¬(k % 2 = 0) on the right", but it doesn't answer the question "why does it need = in the middle instead of iff"

Eric Wieser (Jan 13 2023 at 11:59):

The answer to that second question is "it doesn't", and I think that's Eric's point

Mark Andrew Gerads (Jan 13 2023 at 12:01):

Ah. I have it that way because I was using simp_rw to rewrite it in an ite, and was not aware of the method of rewriting when it is in iff form, but knew it would rewrite as an equality.

Eric Wieser (Jan 13 2023 at 12:07):

simp, simp_rw, and rw, among most other tactics, do not care about the difference


Last updated: Dec 20 2023 at 11:08 UTC