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

tactic: have hz : z ≠ 0
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
⊢ IsPrimitiveClassified h

tactic: apply ne_of_gt hzpos
state_before: case hz
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
⊢ z ≠ 0

x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
⊢ IsPrimitiveClassified h

tactic: have h2 : y = m ^ 2 - n ^ 2 ∧ z = m ^ 2 + n ^ 2 := by
  apply Rat.div_int_inj hzpos hm2n2 (h.coprime_of_coprime hc) H
  rw [hw2]
  norm_cast
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
⊢ IsPrimitiveClassified h

tactic: use m, n
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
h2 : y = m ^ 2 - n ^ 2 ∧ z = m ^ 2 + n ^ 2
⊢ IsPrimitiveClassified h

tactic: apply And.intro _ (And.intro co pp)
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
h2 : y = m ^ 2 - n ^ 2 ∧ z = m ^ 2 + n ^ 2
⊢ (x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n ∨ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2) ∧
    Int.gcd m n = 1 ∧ (m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0)

tactic: right
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
h2 : y = m ^ 2 - n ^ 2 ∧ z = m ^ 2 + n ^ 2
⊢ x = m ^ 2 - n ^ 2 ∧ y = 2 * m * n ∨ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2

tactic: refine' ⟨_, h2.left⟩
state_before: case h
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
h2 : y = m ^ 2 - n ^ 2 ∧ z = m ^ 2 + n ^ 2
⊢ x = 2 * m * n ∧ y = m ^ 2 - n ^ 2

tactic: rw [← Rat.coe_int_inj _ _, ← div_left_inj' ((mt (Rat.coe_int_inj z 0).mp) hz), hv2, h2.right]
state_before: case h
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
h2 : y = m ^ 2 - n ^ 2 ∧ z = m ^ 2 + n ^ 2
⊢ x = 2 * m * n

tactic: norm_cast
state_before: case h
x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
h2 : y = m ^ 2 - n ^ 2 ∧ z = m ^ 2 + n ^ 2
⊢ 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2) = ↑(2 * m * n) / ↑(m ^ 2 + n ^ 2)

tactic: apply Rat.div_int_inj hzpos hm2n2 (h.coprime_of_coprime hc) H
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
⊢ y = m ^ 2 - n ^ 2 ∧ z = m ^ 2 + n ^ 2

tactic: rw [hw2]
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
⊢ ↑y / ↑z = ↑(m ^ 2 - n ^ 2) / ↑(m ^ 2 + n ^ 2)

tactic: norm_cast
state_before: x y z : ℤ
h : PythagoreanTriple x y z
hc : Int.gcd x y = 1
hzpos : 0 < z
m n : ℤ
hm2n2 : 0 < m ^ 2 + n ^ 2
hv2 : ↑x / ↑z = 2 * ↑m * ↑n / (↑m ^ 2 + ↑n ^ 2)
hw2 : ↑y / ↑z = (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2)
H : Int.gcd (m ^ 2 - n ^ 2) (m ^ 2 + n ^ 2) = 1
co : Int.gcd m n = 1
pp : m % 2 = 0 ∧ n % 2 = 1 ∨ m % 2 = 1 ∧ n % 2 = 0
hz : z ≠ 0
⊢ (↑m ^ 2 - ↑n ^ 2) / (↑m ^ 2 + ↑n ^ 2) = ↑(m ^ 2 - n ^ 2) / ↑(m ^ 2 + n ^ 2)