Theorem: Nat.sqrt.iter_sq_le
File: Mathlib/Data/Nat/Defs.lean

tactic: unfold sqrt.iter
state_before: a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
⊢ iter n guess * iter n guess ≤ n
state_after: a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
⊢ ((let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) *
      let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) ≤
    n

tactic: let next := (guess + n / guess) / 2
state_before: a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
⊢ ((let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) *
      let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) ≤
    n
state_after: a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
⊢ ((let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) *
      let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) ≤
    n

tactic: simpa only [dif_pos h] using sqrt.iter_sq_le n next
state_before: a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : next < guess
⊢ ((let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) *
      let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) ≤
    n
state_after: no goals

tactic: simp only [dif_neg h]
state_before: a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ ((let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) *
      let next := (guess + n / guess) / 2;
      if _h : next < guess then iter n next else guess) ≤
    n
state_after: a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ guess * guess ≤ n

tactic: apply Nat.mul_le_of_le_div
state_before: a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ guess * guess ≤ n
state_after: case h
a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ guess ≤ n / guess

tactic: apply Nat.le_of_add_le_add_left (a := guess)
state_before: case h
a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ guess ≤ n / guess
state_after: case h
a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ guess + guess ≤ guess + n / guess

tactic: rw [← Nat.mul_two, ← le_div_iff_mul_le]
state_before: case h
a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ guess + guess ≤ guess + n / guess
state_after: case h
a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ guess ≤ (guess + n / guess) / 2

case h
a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ 0 < 2

tactic: exact Nat.le_of_not_lt h
state_before: case h
a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ guess ≤ (guess + n / guess) / 2
state_after: no goals

tactic: exact Nat.zero_lt_two
state_before: case h
a b c d m n✝ k : ℕ
p q : ℕ → Prop
n guess : ℕ
next : ℕ := (guess + n / guess) / 2
h : ¬next < guess
⊢ 0 < 2
state_after: no goals