Theorem: PythagoreanTriple.coprime_classification'
File: Mathlib/NumberTheory/PythagoreanTriples.lean

tactic: obtain ⟨m, n, ht1, ht2, ht3, ht4⟩ :=
  PythagoreanTriple.coprime_classification.mp (And.intro h h_coprime)
state_before: x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
⊢ ∃ m n,
    x = m ^ 2 - n ^ 2 ∧
      y = 2 * m * n ∧ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: cases' le_or_lt 0 m with hm hm
state_before: case intro.intro.intro.intro.intro
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht1 : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n ∨ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
⊢ ∃ m n,
    x = m ^ 2 - n ^ 2 ∧
      y = 2 * m * n ∧ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: use m, n
state_before: case intro.intro.intro.intro.intro.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht1 : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n ∨ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
⊢ ∃ m n,
    x = m ^ 2 - n ^ 2 ∧
      y = 2 * m * n ∧ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: cases' ht1 with h_odd h_even
state_before: case intro.intro.intro.intro.intro.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht1 : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n ∨ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
⊢ x = m ^ 2 - n ^ 2 ∧
    y = 2 * m * n ∧ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: exfalso
state_before: case intro.intro.intro.intro.intro.inl.inr
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_even : x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
⊢ x = m ^ 2 - n ^ 2 ∧
    y = 2 * m * n ∧ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: rcases h_even with ⟨rfl, -⟩
state_before: case intro.intro.intro.intro.intro.inl.inr.h
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_even : x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
⊢ False

tactic: rw [mul_assoc, Int.mul_emod_right] at h_parity
state_before: case intro.intro.intro.intro.intro.inl.inr.h.intro
x y✝ z✝ : ℤ
h✝ : PythagoreanTriple x y✝ z✝
y z : ℤ
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h : PythagoreanTriple (2 * m * n) y z
h_coprime : Int.gcd (2 * m * n) y = 1
h_parity : 2 * m * n % 2 = 1
⊢ False

tactic: exact zero_ne_one h_parity
state_before: case intro.intro.intro.intro.intro.inl.inr.h.intro
x y✝ z✝ : ℤ
h✝ : PythagoreanTriple x y✝ z✝
y z : ℤ
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h : PythagoreanTriple (2 * m * n) y z
h_coprime : Int.gcd (2 * m * n) y = 1
h_parity : 0 = 1
⊢ False

tactic: apply And.intro h_odd.1
state_before: case intro.intro.intro.intro.intro.inl.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ x = m ^ 2 - n ^ 2 ∧
    y = 2 * m * n ∧ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: apply And.intro h_odd.2
state_before: case intro.intro.intro.intro.intro.inl.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ y = 2 * m * n ∧ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: cases' ht2 with h_pos h_neg
state_before: case intro.intro.intro.intro.intro.inl.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: apply And.intro h_pos (And.intro ht3 (And.intro ht4 hm))
state_before: case intro.intro.intro.intro.intro.inl.inl.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: exfalso
state_before: case intro.intro.intro.intro.intro.inl.inl.inr
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_neg : z = -(m ^ 2 + n ^ 2)
⊢ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: revert h_pos
state_before: case intro.intro.intro.intro.intro.inl.inl.inr.h
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_neg : z = -(m ^ 2 + n ^ 2)
⊢ False

tactic: rw [h_neg]
state_before: case intro.intro.intro.intro.intro.inl.inl.inr.h
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_neg : z = -(m ^ 2 + n ^ 2)
⊢ 0 < z → False

tactic: exact imp_false.mpr (not_lt.mpr (neg_nonpos.mpr (add_nonneg (sq_nonneg m) (sq_nonneg n))))
state_before: case intro.intro.intro.intro.intro.inl.inl.inr.h
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : 0 ≤ m
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_neg : z = -(m ^ 2 + n ^ 2)
⊢ 0 < -(m ^ 2 + n ^ 2) → False

tactic: use -m, -n
state_before: case intro.intro.intro.intro.intro.inr
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht1 : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n ∨ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
⊢ ∃ m n,
    x = m ^ 2 - n ^ 2 ∧
      y = 2 * m * n ∧ z = m ^ 2 + n ^ 2 ∧ Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ m

tactic: cases' ht1 with h_odd h_even
state_before: case intro.intro.intro.intro.intro.inr
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht1 : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n ∨ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
⊢ x = (-m) ^ 2 - (-n) ^ 2 ∧
    y = 2 * -m * -n ∧
      z = (-m) ^ 2 + (-n) ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: exfalso
state_before: case intro.intro.intro.intro.intro.inr.inr
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_even : x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
⊢ x = (-m) ^ 2 - (-n) ^ 2 ∧
    y = 2 * -m * -n ∧
      z = (-m) ^ 2 + (-n) ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: rcases h_even with ⟨rfl, -⟩
state_before: case intro.intro.intro.intro.intro.inr.inr.h
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_even : x = 2 * m * n ∧ y = m ^ 2 - n ^ 2
⊢ False

tactic: rw [mul_assoc, Int.mul_emod_right] at h_parity
state_before: case intro.intro.intro.intro.intro.inr.inr.h.intro
x y✝ z✝ : ℤ
h✝ : PythagoreanTriple x y✝ z✝
y z : ℤ
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h : PythagoreanTriple (2 * m * n) y z
h_coprime : Int.gcd (2 * m * n) y = 1
h_parity : 2 * m * n % 2 = 1
⊢ False

tactic: exact zero_ne_one h_parity
state_before: case intro.intro.intro.intro.intro.inr.inr.h.intro
x y✝ z✝ : ℤ
h✝ : PythagoreanTriple x y✝ z✝
y z : ℤ
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h : PythagoreanTriple (2 * m * n) y z
h_coprime : Int.gcd (2 * m * n) y = 1
h_parity : 0 = 1
⊢ False

tactic: rw [neg_sq m]
state_before: case intro.intro.intro.intro.intro.inr.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ x = (-m) ^ 2 - (-n) ^ 2 ∧
    y = 2 * -m * -n ∧
      z = (-m) ^ 2 + (-n) ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: rw [neg_sq n]
state_before: case intro.intro.intro.intro.intro.inr.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ x = m ^ 2 - (-n) ^ 2 ∧
    y = 2 * -m * -n ∧
      z = m ^ 2 + (-n) ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: apply And.intro h_odd.1
state_before: case intro.intro.intro.intro.intro.inr.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ x = m ^ 2 - n ^ 2 ∧
    y = 2 * -m * -n ∧
      z = m ^ 2 + n ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: constructor
state_before: case intro.intro.intro.intro.intro.inr.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ y = 2 * -m * -n ∧
    z = m ^ 2 + n ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: cases' ht2 with h_pos h_neg
state_before: case intro.intro.intro.intro.intro.inr.inl.right
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ z = m ^ 2 + n ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: rw [h_odd.2]
state_before: case intro.intro.intro.intro.intro.inr.inl.left
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ y = 2 * -m * -n

tactic: ring
state_before: case intro.intro.intro.intro.intro.inr.inl.left
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht2 : z = m ^ 2 + n ^ 2 ∨ z = -(m ^ 2 + n ^ 2)
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
⊢ 2 * m * n = 2 * -m * -n

tactic: apply And.intro h_pos
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ z = m ^ 2 + n ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: constructor
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inl
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: delta Int.gcd
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inl.left
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ Int.gcd (-m) (-n) = 1

tactic: rw [Int.natAbs_neg, Int.natAbs_neg]
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inl.left
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ Nat.gcd (Int.natAbs (-m)) (Int.natAbs (-n)) = 1

tactic: exact ht3
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inl.left
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ Nat.gcd (Int.natAbs m) (Int.natAbs n) = 1

tactic: rw [Int.neg_emod_two, Int.neg_emod_two]
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inl.right
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: apply And.intro ht4
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inl.right
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0) ∧ 0 ≤ -m

tactic: linarith
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inl.right
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos✝ : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_pos : z = m ^ 2 + n ^ 2
⊢ 0 ≤ -m

tactic: exfalso
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inr
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_neg : z = -(m ^ 2 + n ^ 2)
⊢ z = m ^ 2 + n ^ 2 ∧ Int.gcd (-m) (-n) = 1 ∧ (-m % 2 = 0 ∧ -n % 2 = 1 ∨ -m % 2 = 1 ∧ -n % 2 = 0) ∧ 0 ≤ -m

tactic: revert h_pos
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inr.h
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
h_pos : 0 < z
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_neg : z = -(m ^ 2 + n ^ 2)
⊢ False

tactic: rw [h_neg]
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inr.h
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_neg : z = -(m ^ 2 + n ^ 2)
⊢ 0 < z → False

tactic: exact imp_false.mpr (not_lt.mpr (neg_nonpos.mpr (add_nonneg (sq_nonneg m) (sq_nonneg n))))
state_before: case intro.intro.intro.intro.intro.inr.inl.right.inr.h
x✝ y✝ z✝ : ℤ
h✝ : PythagoreanTriple x✝ y✝ z✝
x y z : ℤ
h : PythagoreanTriple x y z
h_coprime : Int.gcd x y = 1
h_parity : x % 2 = 1
m n : ℤ
ht3 : Int.gcd m n = 1
ht4 : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hm : m < 0
h_odd : x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n
h_neg : z = -(m ^ 2 + n ^ 2)
⊢ 0 < -(m ^ 2 + n ^ 2) → False