Theorem: ZMod.neg_eq_self_iff
File: Mathlib/Data/ZMod/Basic.lean

tactic: rw [neg_eq_iff_add_eq_zero, ← two_mul]
state_before: n : ℕ
a : ZMod n
⊢ -a = a ↔ a = 0 ∨ 2 * val a = n

tactic: cases n
state_before: n : ℕ
a : ZMod n
⊢ 2 * a = 0 ↔ a = 0 ∨ 2 * val a = n

tactic: conv_lhs =>
  rw [← a.nat_cast_zmod_val, ← Nat.cast_two, ← Nat.cast_mul, nat_cast_zmod_eq_zero_iff_dvd]
state_before: case succ
n✝ : ℕ
a : ZMod (Nat.succ n✝)
⊢ 2 * a = 0 ↔ a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: constructor
state_before: case succ
n✝ : ℕ
a : ZMod (Nat.succ n✝)
⊢ Nat.succ n✝ ∣ 2 * val a ↔ a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: erw [@mul_eq_zero ℤ, @mul_eq_zero ℕ, val_eq_zero]
state_before: case zero
a : ZMod Nat.zero
⊢ 2 * a = 0 ↔ a = 0 ∨ 2 * val a = Nat.zero

tactic: exact
  ⟨fun h => h.elim (by simp) Or.inl, fun h =>
    Or.inr (h.elim id fun h => h.elim (by simp) id)⟩
state_before: case zero
a : ZMod Nat.zero
⊢ 2 = 0 ∨ a = 0 ↔ a = 0 ∨ 2 = 0 ∨ a = 0

tactic: simp
state_before: a : ZMod Nat.zero
h : 2 = 0 ∨ a = 0
⊢ 2 = 0 → a = 0 ∨ 2 = 0 ∨ a = 0

tactic: simp
state_before: a : ZMod Nat.zero
h✝ : a = 0 ∨ 2 = 0 ∨ a = 0
h : 2 = 0 ∨ a = 0
⊢ 2 = 0 → a = 0

tactic: rintro ⟨m, he⟩
state_before: case succ.mp
n✝ : ℕ
a : ZMod (Nat.succ n✝)
⊢ Nat.succ n✝ ∣ 2 * val a → a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: cases' m with m
state_before: case succ.mp.intro
n✝ : ℕ
a : ZMod (Nat.succ n✝)
m : ℕ
he : 2 * val a = Nat.succ n✝ * m
⊢ a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: cases m
state_before: case succ.mp.intro.succ
n✝ : ℕ
a : ZMod (Nat.succ n✝)
m : ℕ
he : 2 * val a = Nat.succ n✝ * Nat.succ m
⊢ a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: refine' (a.val_lt.not_le <| Nat.le_of_mul_le_mul_left _ zero_lt_two).elim
state_before: case succ.mp.intro.succ.succ
n✝¹ : ℕ
a : ZMod (Nat.succ n✝¹)
n✝ : ℕ
he : 2 * val a = Nat.succ n✝¹ * Nat.succ (Nat.succ n✝)
⊢ a = 0 ∨ 2 * val a = Nat.succ n✝¹

tactic: rw [he, mul_comm]
state_before: case succ.mp.intro.succ.succ
n✝¹ : ℕ
a : ZMod (Nat.succ n✝¹)
n✝ : ℕ
he : 2 * val a = Nat.succ n✝¹ * Nat.succ (Nat.succ n✝)
⊢ 2 * Nat.succ n✝¹ ≤ 2 * val a

tactic: apply Nat.mul_le_mul_left
state_before: case succ.mp.intro.succ.succ
n✝¹ : ℕ
a : ZMod (Nat.succ n✝¹)
n✝ : ℕ
he : 2 * val a = Nat.succ n✝¹ * Nat.succ (Nat.succ n✝)
⊢ Nat.succ n✝¹ * 2 ≤ Nat.succ n✝¹ * Nat.succ (Nat.succ n✝)

tactic: erw [Nat.succ_le_succ_iff, Nat.succ_le_succ_iff]
state_before: case succ.mp.intro.succ.succ.h
n✝¹ : ℕ
a : ZMod (Nat.succ n✝¹)
n✝ : ℕ
he : 2 * val a = Nat.succ n✝¹ * Nat.succ (Nat.succ n✝)
⊢ 2 ≤ Nat.succ (Nat.succ n✝)

tactic: simp
state_before: case succ.mp.intro.succ.succ.h
n✝¹ : ℕ
a : ZMod (Nat.succ n✝¹)
n✝ : ℕ
he : 2 * val a = Nat.succ n✝¹ * Nat.succ (Nat.succ n✝)
⊢ 0 ≤ n✝

tactic: erw [MulZeroClass.mul_zero, mul_eq_zero] at he
state_before: case succ.mp.intro.zero
n✝ : ℕ
a : ZMod (Nat.succ n✝)
he : 2 * val a = Nat.succ n✝ * Nat.zero
⊢ a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: rcases he with (⟨⟨⟩⟩ | he)
state_before: case succ.mp.intro.zero
n✝ : ℕ
a : ZMod (Nat.succ n✝)
he : 2 = 0 ∨ val a = 0
⊢ a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: exact Or.inl (a.val_eq_zero.1 he)
state_before: case succ.mp.intro.zero.inr
n✝ : ℕ
a : ZMod (Nat.succ n✝)
he : val a = 0
⊢ a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: right
state_before: case succ.mp.intro.succ.zero
n✝ : ℕ
a : ZMod (Nat.succ n✝)
he : 2 * val a = Nat.succ n✝ * Nat.succ Nat.zero
⊢ a = 0 ∨ 2 * val a = Nat.succ n✝

tactic: rwa [show Nat.succ Nat.zero = 1 from rfl, mul_one] at he
state_before: case succ.mp.intro.succ.zero.h
n✝ : ℕ
a : ZMod (Nat.succ n✝)
he : 2 * val a = Nat.succ n✝ * Nat.succ Nat.zero
⊢ 2 * val a = Nat.succ n✝

tactic: rintro (rfl | h)
state_before: case succ.mpr
n✝ : ℕ
a : ZMod (Nat.succ n✝)
⊢ a = 0 ∨ 2 * val a = Nat.succ n✝ → Nat.succ n✝ ∣ 2 * val a

tactic: rw [val_zero, MulZeroClass.mul_zero]
state_before: case succ.mpr.inl
n✝ : ℕ
⊢ Nat.succ n✝ ∣ 2 * val 0

tactic: apply dvd_zero
state_before: case succ.mpr.inl
n✝ : ℕ
⊢ Nat.succ n✝ ∣ 0

tactic: rw [h]
state_before: case succ.mpr.inr
n✝ : ℕ
a : ZMod (Nat.succ n✝)
h : 2 * val a = Nat.succ n✝
⊢ Nat.succ n✝ ∣ 2 * val a