Theorem: Num.gcd_to_nat_aux
File: Mathlib/Data/Num/Lemmas.lean

tactic: simp [gcdAux]
state_before: n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : natSize (pos a * b) ≤ Nat.succ n
⊢ ↑(gcdAux (Nat.succ n) (pos a) b) = Nat.gcd ↑(pos a) ↑b

tactic: rw [Nat.gcd_rec, gcd_to_nat_aux, mod_to_nat]
state_before: n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : natSize (pos a * b) ≤ Nat.succ n
⊢ ↑(gcdAux n (b % pos a) (pos a)) = Nat.gcd ↑a ↑b

tactic: rw [natSize_to_nat, mul_to_nat, Nat.size_le] at h⊢
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : natSize (pos a * b) ≤ Nat.succ n
⊢ natSize (b % pos a * pos a) ≤ n

tactic: rw [mod_to_nat, mul_comm]
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * ↑b < 2 ^ Nat.succ n
⊢ ↑(b % pos a) * ↑(pos a) < 2 ^ n

tactic: rw [pow_succ', ← Nat.mod_add_div b (pos a)] at h
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * ↑b < 2 ^ Nat.succ n
⊢ ↑(pos a) * (↑b % ↑(pos a)) < 2 ^ n

tactic: refine' lt_of_mul_lt_mul_right (lt_of_le_of_lt _ h) (Nat.zero_le 2)
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a))) < 2 ^ n * 2
⊢ ↑(pos a) * (↑b % ↑(pos a)) < 2 ^ n

tactic: rw [mul_two, mul_add]
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a))) < 2 ^ n * 2
⊢ ↑(pos a) * (↑b % ↑(pos a)) * 2 ≤ ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a)))

tactic: refine'
  add_le_add_left
    (Nat.mul_le_mul_left _ (le_trans (le_of_lt (Nat.mod_lt _ (PosNum.cast_pos _))) _)) _
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a))) < 2 ^ n * 2
⊢ ↑(pos a) * (↑b % ↑(pos a)) + ↑(pos a) * (↑b % ↑(pos a)) ≤
    ↑(pos a) * (↑b % ↑(pos a)) + ↑(pos a) * (↑(pos a) * (↑b / ↑(pos a)))

tactic: suffices : 1 ≤ _
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a))) < 2 ^ n * 2
⊢ ↑a ≤ ↑(pos a) * (↑b / ↑(pos a))

tactic: simpa using Nat.mul_le_mul_left (pos a) this
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a))) < 2 ^ n * 2
this : 1 ≤ ?m.1170277
⊢ ↑a ≤ ↑(pos a) * (↑b / ↑(pos a))

case this
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a))) < 2 ^ n * 2
⊢ 1 ≤ ?m.1170277

tactic: rw [Nat.le_div_iff_mul_le a.cast_pos, one_mul]
state_before: case this
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a))) < 2 ^ n * 2
⊢ 1 ≤ ↑b / ↑a

tactic: exact le_to_nat.2 ab
state_before: case this
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : ↑(pos a) * (↑b % ↑(pos a) + ↑(pos a) * (↑b / ↑(pos a))) < 2 ^ n * 2
⊢ ↑a ≤ ↑b

tactic: rfl
state_before: n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : natSize (pos a * b) ≤ Nat.succ n
⊢ Nat.gcd (↑b % ↑(pos a)) ↑(pos a) = Nat.gcd (↑b % ↑a) ↑a

tactic: rw [← le_to_nat, mod_to_nat]
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : natSize (pos a * b) ≤ Nat.succ n
⊢ b % pos a ≤ pos a

tactic: exact le_of_lt (Nat.mod_lt _ (PosNum.cast_pos _))
state_before: case a
n : ℕ
a : PosNum
b : Num
ab : pos a ≤ b
h : natSize (pos a * b) ≤ Nat.succ n
⊢ ↑b % ↑(pos a) ≤ ↑(pos a)