Theorem: Pell.IsFundamental.mul_inv_x_lt_x
File: Mathlib/NumberTheory/Pell.lean

Proof steps:
state_before: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ (a * a₁⁻¹).x < a.x
state_after: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.x * a₁.x < d * (a.y * a₁.y) + a.x
tactic: simp only [x_mul, x_inv, y_inv, mul_neg, add_neg_lt_iff_le_add']
state_before: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.x * a₁.x < d * (a.y * a₁.y) + a.x
state_after: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a₁.y * (a.x * a₁.x) < a₁.y * (d * (a.y * a₁.y) + a.x)
tactic: refine (mul_lt_mul_left h.2.1).mp ?_
state_before: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a₁.y * (a.x * a₁.x) < a₁.y * (d * (a.y * a₁.y) + a.x)
state_after: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.x * a₁.y * a₁.x < a₁.y * (d * (a.y * a₁.y) + a.x)
tactic: rw [(by ring : a₁.y * (a.x * a₁.x) = a.x * a₁.y * a₁.x)]
state_before: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.x * a₁.y * a₁.x < a₁.y * (d * (a.y * a₁.y) + a.x)
state_after: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.y * a₁.x * a₁.x < a₁.y * (d * (a.y * a₁.y) + a.x)
tactic: refine
    ((mul_le_mul_right <| zero_lt_one.trans h.1).mpr <| x_mul_y_le_y_mul_x h hax hay).trans_lt ?_
state_before: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.y * a₁.x * a₁.x < a₁.y * (d * (a.y * a₁.y) + a.x)
state_after: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.y * (1 + d * a₁.y ^ 2) - a₁.y * (d * (a.y * a₁.y) + a.x) < 0
tactic: rw [mul_assoc, ← sq, a₁.prop_x, ← sub_neg]
state_before: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.y * (1 + d * a₁.y ^ 2) - a₁.y * (d * (a.y * a₁.y) + a.x) < 0
state_after: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.y - a.x * a₁.y < 0
tactic: suffices a.y - a.x * a₁.y < 0 by convert this using 1; ring
state_before: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.y - a.x * a₁.y < 0
state_after: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.y ^ 2 < (1 + d * a.y ^ 2) * a₁.y ^ 2
tactic: rw [sub_neg, ← abs_of_pos hay, ← abs_of_pos h.2.1, ← abs_of_pos <| zero_lt_one.trans hax, ←
    abs_mul, ← sq_lt_sq, mul_pow, a.prop_x]
state_before: d : ℤ
a₁ : Solution₁ d
h : IsFundamental a₁
a : Solution₁ d
hax : 1 < a.x
hay : 0 < a.y
⊢ a.y ^ 2 < (1 + d * a.y ^ 2) * a₁.y ^ 2
state_after: no goals
tactic: calc
    a.y ^ 2 = 1 * a.y ^ 2 := (one_mul _).symm
    _ ≤ d * a.y ^ 2 := (mul_le_mul_right <| sq_pos_of_pos hay).mpr h.d_pos
    _ < d * a.y ^ 2 + 1 := lt_add_one _
    _ = (1 + d * a.y ^ 2) * 1 := by rw [add_comm, mul_one]
    _ ≤ (1 + d * a.y ^ 2) * a₁.y ^ 2 :=
      (mul_le_mul_left (by have := h.d_pos; positivity)).mpr (sq_pos_of_pos h.2.1)