Theorem: Zsqrtd.divides_sq_eq_zero
File: Mathlib/NumberTheory/Zsqrtd/Basic.lean

tactic: let ⟨m, n, co, (hx : x = m * g), (hy : y = n * g)⟩ := Nat.exists_coprime gpos
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
h : x * x = d * y * y
g : ℕ := Nat.gcd x y
gpos : g > 0
⊢ False

tactic: rw [hx, hy] at h
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
h : x * x = d * y * y
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
⊢ False

tactic: have : m * m = d * (n * n) := by
  refine mul_left_cancel₀ (mul_pos gpos gpos).ne' ?_
  calc
    g * g * (m * m)
    _ = m * g * (m * g) := by ring
    _ = d * (n * g) * (n * g) := h
    _ = g * g * (d * (n * n)) := by ring
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
⊢ False

tactic: have co2 :=
  let co1 := co.mul_right co
  co1.mul co1
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
this : m * m = d * (n * n)
⊢ False

tactic: exact
  Nonsquare.ns d m
    (Nat.dvd_antisymm (by rw [this]; apply dvd_mul_right) <|
      co2.dvd_of_dvd_mul_right <| by simp [this])
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
this : m * m = d * (n * n)
co2 : Nat.coprime (m * m) (n * n)
⊢ False

tactic: refine mul_left_cancel₀ (mul_pos gpos gpos).ne' ?_
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
⊢ m * m = d * (n * n)

tactic: calc
  g * g * (m * m)
  _ = m * g * (m * g) := by ring
  _ = d * (n * g) * (n * g) := h
  _ = g * g * (d * (n * n)) := by ring
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
⊢ g * g * (m * m) = g * g * (d * (n * n))

tactic: ring
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
⊢ g * g * (m * m) = m * g * (m * g)

tactic: ring
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
⊢ d * (n * g) * (n * g) = g * g * (d * (n * n))

tactic: rw [this]
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
this : m * m = d * (n * n)
co2 : Nat.coprime (m * m) (n * n)
⊢ d ∣ m * m

tactic: apply dvd_mul_right
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
this : m * m = d * (n * n)
co2 : Nat.coprime (m * m) (n * n)
⊢ d ∣ d * (n * n)

tactic: simp [this]
state_before: d : ℕ
dnsq : Nonsquare d
x y : ℕ
g : ℕ := Nat.gcd x y
gpos : g > 0
m n : ℕ
h : m * g * (m * g) = d * (n * g) * (n * g)
co : Nat.coprime m n
hx : x = m * g
hy : y = n * g
this : m * m = d * (n * n)
co2 : Nat.coprime (m * m) (n * n)
⊢ m * m ∣ d * (n * n)