Theorem: PythagoreanTriple.even_odd_of_coprime
File: Mathlib/NumberTheory/PythagoreanTriples.lean

tactic: cases' Int.emod_two_eq_zero_or_one x with hx hx <;>
  cases' Int.emod_two_eq_zero_or_one y with hy hy
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
⊢ x % 2 = 0 ∧ y % 2 = 1 ∨ x % 2 = 1 ∧ y % 2 = 0

tactic: exfalso
state_before: case inl.inl
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 0
⊢ x % 2 = 0 ∧ y % 2 = 1 ∨ x % 2 = 1 ∧ y % 2 = 0

tactic: apply Nat.not_coprime_of_dvd_of_dvd (by decide : 1 < 2) _ _ hc
state_before: case inl.inl.h
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 0
⊢ False

tactic: decide
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 0
⊢ 1 < 2

tactic: apply Int.coe_nat_dvd_left.1
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 0
⊢ 2 ∣ Int.natAbs x

tactic: apply Int.dvd_of_emod_eq_zero hx
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 0
⊢ ↑2 ∣ x

tactic: apply Int.coe_nat_dvd_left.1
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 0
⊢ 2 ∣ Int.natAbs y

tactic: apply Int.dvd_of_emod_eq_zero hy
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 0
⊢ ↑2 ∣ y

tactic: left
state_before: case inl.inr
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 1
⊢ x % 2 = 0 ∧ y % 2 = 1 ∨ x % 2 = 1 ∧ y % 2 = 0

tactic: exact ⟨hx, hy⟩
state_before: case inl.inr.h
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 0
hy : y % 2 = 1
⊢ x % 2 = 0 ∧ y % 2 = 1

tactic: right
state_before: case inr.inl
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 1
hy : y % 2 = 0
⊢ x % 2 = 0 ∧ y % 2 = 1 ∨ x % 2 = 1 ∧ y % 2 = 0

tactic: exact ⟨hx, hy⟩
state_before: case inr.inl.h
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 1
hy : y % 2 = 0
⊢ x % 2 = 1 ∧ y % 2 = 0

tactic: exfalso
state_before: case inr.inr
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 1
hy : y % 2 = 1
⊢ x % 2 = 0 ∧ y % 2 = 1 ∨ x % 2 = 1 ∧ y % 2 = 0

tactic: obtain ⟨x0, y0, rfl, rfl⟩ : ∃ x0 y0, x = x0 * 2 + 1 ∧ y = y0 * 2 + 1 := by
  cases' exists_eq_mul_left_of_dvd (Int.dvd_sub_of_emod_eq hx) with x0 hx2
  cases' exists_eq_mul_left_of_dvd (Int.dvd_sub_of_emod_eq hy) with y0 hy2
  rw [sub_eq_iff_eq_add] at hx2 hy2
  exact ⟨x0, y0, hx2, hy2⟩
state_before: case inr.inr.h
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 1
hy : y % 2 = 1
⊢ False

tactic: apply Int.sq_ne_two_mod_four z
state_before: case inr.inr.h.intro.intro.intro
z x0 y0 : ℤ
hx : (x0 * 2 + 1) % 2 = 1
hy : (y0 * 2 + 1) % 2 = 1
h : PythagoreanTriple (x0 * 2 + 1) (y0 * 2 + 1) z
hc : Int.gcd (x0 * 2 + 1) (y0 * 2 + 1) = 1
⊢ False

tactic: rw [show z * z = 4 * (x0 * x0 + x0 + y0 * y0 + y0) + 2 by
    rw [← h.eq]
    ring]
state_before: case inr.inr.h.intro.intro.intro
z x0 y0 : ℤ
hx : (x0 * 2 + 1) % 2 = 1
hy : (y0 * 2 + 1) % 2 = 1
h : PythagoreanTriple (x0 * 2 + 1) (y0 * 2 + 1) z
hc : Int.gcd (x0 * 2 + 1) (y0 * 2 + 1) = 1
⊢ z * z % 4 = 2

tactic: field_simp [Int.add_emod]
state_before: case inr.inr.h.intro.intro.intro
z x0 y0 : ℤ
hx : (x0 * 2 + 1) % 2 = 1
hy : (y0 * 2 + 1) % 2 = 1
h : PythagoreanTriple (x0 * 2 + 1) (y0 * 2 + 1) z
hc : Int.gcd (x0 * 2 + 1) (y0 * 2 + 1) = 1
⊢ (4 * (x0 * x0 + x0 + y0 * y0 + y0) + 2) % 4 = 2

tactic: cases' exists_eq_mul_left_of_dvd (Int.dvd_sub_of_emod_eq hx) with x0 hx2
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 1
hy : y % 2 = 1
⊢ ∃ x0 y0, x = x0 * 2 + 1 ∧ y = y0 * 2 + 1

tactic: cases' exists_eq_mul_left_of_dvd (Int.dvd_sub_of_emod_eq hy) with y0 hy2
state_before: case intro
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 1
hy : y % 2 = 1
x0 : ℤ
hx2 : x - 1 = x0 * 2
⊢ ∃ x0 y0, x = x0 * 2 + 1 ∧ y = y0 * 2 + 1

tactic: rw [sub_eq_iff_eq_add] at hx2 hy2
state_before: case intro.intro
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 1
hy : y % 2 = 1
x0 : ℤ
hx2 : x - 1 = x0 * 2
y0 : ℤ
hy2 : y - 1 = y0 * 2
⊢ ∃ x0 y0, x = x0 * 2 + 1 ∧ y = y0 * 2 + 1

tactic: exact ⟨x0, y0, hx2, hy2⟩
state_before: case intro.intro
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hx : x % 2 = 1
hy : y % 2 = 1
x0 : ℤ
hx2 : x = x0 * 2 + 1
y0 : ℤ
hy2 : y = y0 * 2 + 1
⊢ ∃ x0 y0, x = x0 * 2 + 1 ∧ y = y0 * 2 + 1

tactic: rw [← h.eq]
state_before: z x0 y0 : ℤ
hx : (x0 * 2 + 1) % 2 = 1
hy : (y0 * 2 + 1) % 2 = 1
h : PythagoreanTriple (x0 * 2 + 1) (y0 * 2 + 1) z
hc : Int.gcd (x0 * 2 + 1) (y0 * 2 + 1) = 1
⊢ z * z = 4 * (x0 * x0 + x0 + y0 * y0 + y0) + 2

tactic: ring
state_before: z x0 y0 : ℤ
hx : (x0 * 2 + 1) % 2 = 1
hy : (y0 * 2 + 1) % 2 = 1
h : PythagoreanTriple (x0 * 2 + 1) (y0 * 2 + 1) z
hc : Int.gcd (x0 * 2 + 1) (y0 * 2 + 1) = 1
⊢ (x0 * 2 + 1) * (x0 * 2 + 1) + (y0 * 2 + 1) * (y0 * 2 + 1) = 4 * (x0 * x0 + x0 + y0 * y0 + y0) + 2