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

tactic: obtain ⟨x, y, (h : a ≤ ⟨x, y⟩)⟩ : ∃ x y : ℕ, Nonneg (⟨x, y⟩ + -a) :=
  match -a with
  | ⟨Int.ofNat x, Int.ofNat y⟩ => ⟨0, 0, by trivial⟩
  | ⟨Int.ofNat x, -[y+1]⟩ => ⟨0, y + 1, by simp [add_def, Int.negSucc_coe, add_assoc]; trivial⟩
  | ⟨-[x+1], Int.ofNat y⟩ => ⟨x + 1, 0, by simp [Int.negSucc_coe, add_assoc]; trivial⟩
  | ⟨-[x+1], -[y+1]⟩ => ⟨x + 1, y + 1, by simp [Int.negSucc_coe, add_assoc]; trivial⟩
state_before: d : ℕ
a : ℤ√↑d
⊢ ∃ n, a ≤ ↑n
state_after: case intro.intro
d : ℕ
a : ℤ√↑d
x y : ℕ
h : a ≤ { re := ↑x, im := ↑y }
⊢ ∃ n, a ≤ ↑n

tactic: refine ⟨x + d * y, h.trans ?_⟩
state_before: case intro.intro
d : ℕ
a : ℤ√↑d
x y : ℕ
h : a ≤ { re := ↑x, im := ↑y }
⊢ ∃ n, a ≤ ↑n
state_after: case intro.intro
d : ℕ
a : ℤ√↑d
x y : ℕ
h : a ≤ { re := ↑x, im := ↑y }
⊢ { re := ↑x, im := ↑y } ≤ ↑(x + d * y)

tactic: change Nonneg ⟨↑x + d * y - ↑x, 0 - ↑y⟩
state_before: case intro.intro
d : ℕ
a : ℤ√↑d
x y : ℕ
h : a ≤ { re := ↑x, im := ↑y }
⊢ { re := ↑x, im := ↑y } ≤ ↑(x + d * y)
state_after: case intro.intro
d : ℕ
a : ℤ√↑d
x y : ℕ
h : a ≤ { re := ↑x, im := ↑y }
⊢ { re := ↑x + ↑d * ↑y - ↑x, im := 0 - ↑y }.Nonneg

tactic: cases' y with y
state_before: case intro.intro
d : ℕ
a : ℤ√↑d
x y : ℕ
h : a ≤ { re := ↑x, im := ↑y }
⊢ { re := ↑x + ↑d * ↑y - ↑x, im := 0 - ↑y }.Nonneg
state_after: case intro.intro.zero
d : ℕ
a : ℤ√↑d
x : ℕ
h : a ≤ { re := ↑x, im := ↑0 }
⊢ { re := ↑x + ↑d * ↑0 - ↑x, im := 0 - ↑0 }.Nonneg

case intro.intro.succ
d : ℕ
a : ℤ√↑d
x y : ℕ
h : a ≤ { re := ↑x, im := ↑(y + 1) }
⊢ { re := ↑x + ↑d * ↑(y + 1) - ↑x, im := 0 - ↑(y + 1) }.Nonneg

tactic: have h : ∀ y, SqLe y d (d * y) 1 := fun y => by
  simpa [SqLe, mul_comm, mul_left_comm] using Nat.mul_le_mul_right (y * y) (Nat.le_mul_self d)
state_before: case intro.intro.succ
d : ℕ
a : ℤ√↑d
x y : ℕ
h : a ≤ { re := ↑x, im := ↑(y + 1) }
⊢ { re := ↑x + ↑d * ↑(y + 1) - ↑x, im := 0 - ↑(y + 1) }.Nonneg
state_after: case intro.intro.succ
d : ℕ
a : ℤ√↑d
x y : ℕ
h✝ : a ≤ { re := ↑x, im := ↑(y + 1) }
h : ∀ (y : ℕ), SqLe y d (d * y) 1
⊢ { re := ↑x + ↑d * ↑(y + 1) - ↑x, im := 0 - ↑(y + 1) }.Nonneg

tactic: rw [show (x : ℤ) + d * Nat.succ y - x = d * Nat.succ y by simp]
state_before: case intro.intro.succ
d : ℕ
a : ℤ√↑d
x y : ℕ
h✝ : a ≤ { re := ↑x, im := ↑(y + 1) }
h : ∀ (y : ℕ), SqLe y d (d * y) 1
⊢ { re := ↑x + ↑d * ↑(y + 1) - ↑x, im := 0 - ↑(y + 1) }.Nonneg
state_after: case intro.intro.succ
d : ℕ
a : ℤ√↑d
x y : ℕ
h✝ : a ≤ { re := ↑x, im := ↑(y + 1) }
h : ∀ (y : ℕ), SqLe y d (d * y) 1
⊢ { re := ↑d * ↑y.succ, im := 0 - ↑(y + 1) }.Nonneg

tactic: exact h (y + 1)
state_before: case intro.intro.succ
d : ℕ
a : ℤ√↑d
x y : ℕ
h✝ : a ≤ { re := ↑x, im := ↑(y + 1) }
h : ∀ (y : ℕ), SqLe y d (d * y) 1
⊢ { re := ↑d * ↑y.succ, im := 0 - ↑(y + 1) }.Nonneg
state_after: no goals

tactic: trivial
state_before: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ ({ re := ↑0, im := ↑0 } + { re := ofNat x, im := ofNat y }).Nonneg
state_after: no goals

tactic: simp [add_def, Int.negSucc_coe, add_assoc]
state_before: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ ({ re := ↑0, im := ↑(y + 1) } + { re := ofNat x, im := -[y+1] }).Nonneg
state_after: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ { re := ↑x, im := 0 }.Nonneg

tactic: trivial
state_before: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ { re := ↑x, im := 0 }.Nonneg
state_after: no goals

tactic: simp [Int.negSucc_coe, add_assoc]
state_before: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ ({ re := ↑(x + 1), im := ↑0 } + { re := -[x+1], im := ofNat y }).Nonneg
state_after: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ { re := 0, im := ↑y }.Nonneg

tactic: trivial
state_before: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ { re := 0, im := ↑y }.Nonneg
state_after: no goals

tactic: simp [Int.negSucc_coe, add_assoc]
state_before: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ ({ re := ↑(x + 1), im := ↑(y + 1) } + { re := -[x+1], im := -[y+1] }).Nonneg
state_after: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ { re := 0, im := 0 }.Nonneg

tactic: trivial
state_before: d : ℕ
a : ℤ√↑d
x y : ℕ
⊢ { re := 0, im := 0 }.Nonneg
state_after: no goals

tactic: simp
state_before: case intro.intro.zero
d : ℕ
a : ℤ√↑d
x : ℕ
h : a ≤ { re := ↑x, im := ↑0 }
⊢ { re := ↑x + ↑d * ↑0 - ↑x, im := 0 - ↑0 }.Nonneg
state_after: case intro.intro.zero
d : ℕ
a : ℤ√↑d
x : ℕ
h : a ≤ { re := ↑x, im := ↑0 }
⊢ { re := 0, im := 0 }.Nonneg

tactic: trivial
state_before: case intro.intro.zero
d : ℕ
a : ℤ√↑d
x : ℕ
h : a ≤ { re := ↑x, im := ↑0 }
⊢ { re := 0, im := 0 }.Nonneg
state_after: no goals

tactic: simpa [SqLe, mul_comm, mul_left_comm] using Nat.mul_le_mul_right (y * y) (Nat.le_mul_self d)
state_before: d : ℕ
a : ℤ√↑d
x y✝ : ℕ
h : a ≤ { re := ↑x, im := ↑(y✝ + 1) }
y : ℕ
⊢ SqLe y d (d * y) 1
state_after: no goals

tactic: simp
state_before: d : ℕ
a : ℤ√↑d
x y : ℕ
h✝ : a ≤ { re := ↑x, im := ↑(y + 1) }
h : ∀ (y : ℕ), SqLe y d (d * y) 1
⊢ ↑x + ↑d * ↑y.succ - ↑x = ↑d * ↑y.succ
state_after: no goals