Theorem: Zsqrtd.Nonneg.add
File: Mathlib/NumberTheory/Zsqrtd/Basic.lean

tactic: rcases nonneg_cases ha with ⟨x, y, rfl | rfl | rfl⟩ <;>
  rcases nonneg_cases hb with ⟨z, w, rfl | rfl | rfl⟩
state_before: d : ℕ
a b : ℤ√↑d
ha : Nonneg a
hb : Nonneg b
⊢ Nonneg (a + b)

tactic: trivial
state_before: case intro.intro.inl.intro.intro.inl
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
⊢ Nonneg ({ re := ↑x, im := ↑y } + { re := ↑z, im := ↑w })

tactic: refine' nonnegg_cases_right fun i h => sqLe_of_le _ _ (nonnegg_pos_neg.1 hb)
state_before: case intro.intro.inl.intro.intro.inr.inl
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
⊢ Nonneg ({ re := ↑x, im := ↑y } + { re := ↑z, im := -↑w })

tactic: dsimp only at h
state_before: case intro.intro.inl.intro.intro.inr.inl.refine'_1
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
i : ℕ
h : { re := ↑x, im := ↑y }.im + { re := ↑z, im := -↑w }.im = -↑i
⊢ i ≤ w

tactic: exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro y (by simp [add_comm, *])))
state_before: case intro.intro.inl.intro.intro.inr.inl.refine'_1
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
i : ℕ
h : ↑y + -↑w = -↑i
⊢ i ≤ w

tactic: simp [add_comm, *]
state_before: d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
i : ℕ
h : ↑y + -↑w = -↑i
⊢ -↑w + ↑y = -↑i

tactic: apply Nat.le_add_left
state_before: case intro.intro.inl.intro.intro.inr.inl.refine'_2
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
i : ℕ
h : { re := ↑x, im := ↑y }.im + { re := ↑z, im := -↑w }.im = -↑i
⊢ z ≤ x + z

tactic: refine' nonnegg_cases_left fun i h => sqLe_of_le _ _ (nonnegg_neg_pos.1 hb)
state_before: case intro.intro.inl.intro.intro.inr.inr
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
⊢ Nonneg ({ re := ↑x, im := ↑y } + { re := -↑z, im := ↑w })

tactic: dsimp only at h
state_before: case intro.intro.inl.intro.intro.inr.inr.refine'_1
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
i : ℕ
h : { re := ↑x, im := ↑y }.re + { re := -↑z, im := ↑w }.re = -↑i
⊢ i ≤ z

tactic: exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro x (by simp [add_comm, *])))
state_before: case intro.intro.inl.intro.intro.inr.inr.refine'_1
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
i : ℕ
h : ↑x + -↑z = -↑i
⊢ i ≤ z

tactic: simp [add_comm, *]
state_before: d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
i : ℕ
h : ↑x + -↑z = -↑i
⊢ -↑z + ↑x = -↑i

tactic: apply Nat.le_add_left
state_before: case intro.intro.inl.intro.intro.inr.inr.refine'_2
d x y : ℕ
ha : Nonneg { re := ↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
i : ℕ
h : { re := ↑x, im := ↑y }.re + { re := -↑z, im := ↑w }.re = -↑i
⊢ w ≤ y + w

tactic: refine' nonnegg_cases_right fun i h => sqLe_of_le _ _ (nonnegg_pos_neg.1 ha)
state_before: case intro.intro.inr.inl.intro.intro.inl
d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
⊢ Nonneg ({ re := ↑x, im := -↑y } + { re := ↑z, im := ↑w })

tactic: dsimp only at h
state_before: case intro.intro.inr.inl.intro.intro.inl.refine'_1
d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
i : ℕ
h : { re := ↑x, im := -↑y }.im + { re := ↑z, im := ↑w }.im = -↑i
⊢ i ≤ y

tactic: exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro w (by simp [*])))
state_before: case intro.intro.inr.inl.intro.intro.inl.refine'_1
d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
i : ℕ
h : -↑y + ↑w = -↑i
⊢ i ≤ y

tactic: simp [*]
state_before: d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
i : ℕ
h : -↑y + ↑w = -↑i
⊢ -↑y + ↑w = -↑i

tactic: apply Nat.le_add_right
state_before: case intro.intro.inr.inl.intro.intro.inl.refine'_2
d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
i : ℕ
h : { re := ↑x, im := -↑y }.im + { re := ↑z, im := ↑w }.im = -↑i
⊢ x ≤ x + z

tactic: have : Nonneg ⟨_, _⟩ :=
  nonnegg_pos_neg.2 (sqLe_add (nonnegg_pos_neg.1 ha) (nonnegg_pos_neg.1 hb))
state_before: case intro.intro.inr.inl.intro.intro.inr.inl
d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
⊢ Nonneg ({ re := ↑x, im := -↑y } + { re := ↑z, im := -↑w })

tactic: rw [Nat.cast_add, Nat.cast_add, neg_add] at this
state_before: case intro.intro.inr.inl.intro.intro.inr.inl
d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
this : Nonneg { re := ↑(x + z), im := -↑(y + w) }
⊢ Nonneg ({ re := ↑x, im := -↑y } + { re := ↑z, im := -↑w })

tactic: rwa [add_def]
state_before: case intro.intro.inr.inl.intro.intro.inr.inl
d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
this : Nonneg { re := ↑x + ↑z, im := -↑y + -↑w }
⊢ Nonneg ({ re := ↑x, im := -↑y } + { re := ↑z, im := -↑w })

tactic: exact nonneg_add_lem ha hb
state_before: case intro.intro.inr.inl.intro.intro.inr.inr
d x y : ℕ
ha : Nonneg { re := ↑x, im := -↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
⊢ Nonneg ({ re := ↑x, im := -↑y } + { re := -↑z, im := ↑w })

tactic: refine' nonnegg_cases_left fun i h => sqLe_of_le _ _ (nonnegg_neg_pos.1 ha)
state_before: case intro.intro.inr.inr.intro.intro.inl
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
⊢ Nonneg ({ re := -↑x, im := ↑y } + { re := ↑z, im := ↑w })

tactic: dsimp only at h
state_before: case intro.intro.inr.inr.intro.intro.inl.refine'_1
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
i : ℕ
h : { re := -↑x, im := ↑y }.re + { re := ↑z, im := ↑w }.re = -↑i
⊢ i ≤ x

tactic: exact Int.ofNat_le.1 (le_of_neg_le_neg (Int.le.intro _ h))
state_before: case intro.intro.inr.inr.intro.intro.inl.refine'_1
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
i : ℕ
h : -↑x + ↑z = -↑i
⊢ i ≤ x

tactic: apply Nat.le_add_right
state_before: case intro.intro.inr.inr.intro.intro.inl.refine'_2
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := ↑w }
i : ℕ
h : { re := -↑x, im := ↑y }.re + { re := ↑z, im := ↑w }.re = -↑i
⊢ y ≤ y + w

tactic: dsimp
state_before: case intro.intro.inr.inr.intro.intro.inr.inl
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
⊢ Nonneg ({ re := -↑x, im := ↑y } + { re := ↑z, im := -↑w })

tactic: rw [add_comm, add_comm (y : ℤ)]
state_before: case intro.intro.inr.inr.intro.intro.inr.inl
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
⊢ Nonneg { re := -↑x + ↑z, im := ↑y + -↑w }

tactic: exact nonneg_add_lem hb ha
state_before: case intro.intro.inr.inr.intro.intro.inr.inl
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := ↑z, im := -↑w }
⊢ Nonneg { re := ↑z + -↑x, im := -↑w + ↑y }

tactic: have : Nonneg ⟨_, _⟩ :=
  nonnegg_neg_pos.2 (sqLe_add (nonnegg_neg_pos.1 ha) (nonnegg_neg_pos.1 hb))
state_before: case intro.intro.inr.inr.intro.intro.inr.inr
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
⊢ Nonneg ({ re := -↑x, im := ↑y } + { re := -↑z, im := ↑w })

tactic: rw [Nat.cast_add, Nat.cast_add, neg_add] at this
state_before: case intro.intro.inr.inr.intro.intro.inr.inr
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
this : Nonneg { re := -↑(x + z), im := ↑(y + w) }
⊢ Nonneg ({ re := -↑x, im := ↑y } + { re := -↑z, im := ↑w })

tactic: rwa [add_def]
state_before: case intro.intro.inr.inr.intro.intro.inr.inr
d x y : ℕ
ha : Nonneg { re := -↑x, im := ↑y }
z w : ℕ
hb : Nonneg { re := -↑z, im := ↑w }
this : Nonneg { re := -↑x + -↑z, im := ↑y + ↑w }
⊢ Nonneg ({ re := -↑x, im := ↑y } + { re := -↑z, im := ↑w })