l3lab/ntp-mathlib huggingface dataset:
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  

Proof state:
d n : PosNum
⊢ ↑(divMod d n).2 + ↑d * ↑(divMod d n).1 = ↑n ∧ ↑(divMod d n).2 < ↑d

Next tactic:
induction' n with n IH n IH
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · 

Proof state:
case one
d : PosNum
⊢ ↑(divMod d one).2 + ↑d * ↑(divMod d one).1 = ↑one ∧ ↑(divMod d one).2 < ↑d

Next tactic:
exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by 

Proof state:
d : PosNum
⊢ ↑1 + ↑d * _root_.bit0 ↑0 = ↑one

Next tactic:
simp
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · 

Proof state:
case bit1
d n : PosNum
IH : ↑(divMod d n).2 + ↑d * ↑(divMod d n).1 = ↑n ∧ ↑(divMod d n).2 < ↑d
⊢ ↑(divMod d (bit1 n)).2 + ↑d * ↑(divMod d (bit1 n)).1 = ↑(bit1 n) ∧ ↑(divMod d (bit1 n)).2 < ↑d

Next tactic:
unfold divMod
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    

Proof state:
case bit1
d n : PosNum
IH : ↑(divMod d n).2 + ↑d * ↑(divMod d n).1 = ↑n ∧ ↑(divMod d n).2 < ↑d
⊢ ↑(match divMod d n with
            | (q, r₁) => divModAux d q (Num.bit1 r₁)).2 +
        ↑d *
          ↑(match divMod d n with
              | (q, r₁) => divModAux d q (Num.bit1 r₁)).1 =
      ↑(bit1 n) ∧
    ↑(match divMod d n with
          | (q, r₁) => divModAux d q (Num.bit1 r₁)).2 <
      ↑d

Next tactic:
revert IH
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; 

Proof state:
case bit1
d n : PosNum
⊢ ↑(divMod d n).2 + ↑d * ↑(divMod d n).1 = ↑n ∧ ↑(divMod d n).2 < ↑d →
    ↑(match divMod d n with
              | (q, r₁) => divModAux d q (Num.bit1 r₁)).2 +
          ↑d *
            ↑(match divMod d n with
                | (q, r₁) => divModAux d q (Num.bit1 r₁)).1 =
        ↑(bit1 n) ∧
      ↑(match divMod d n with
            | (q, r₁) => divModAux d q (Num.bit1 r₁)).2 <
        ↑d

Next tactic:
cases' divMod d n with q r
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; 

Proof state:
case bit1.mk
d n : PosNum
q r : Num
⊢ ↑(q, r).2 + ↑d * ↑(q, r).1 = ↑n ∧ ↑(q, r).2 < ↑d →
    ↑(match (q, r) with
              | (q, r₁) => divModAux d q (Num.bit1 r₁)).2 +
          ↑d *
            ↑(match (q, r) with
                | (q, r₁) => divModAux d q (Num.bit1 r₁)).1 =
        ↑(bit1 n) ∧
      ↑(match (q, r) with
            | (q, r₁) => divModAux d q (Num.bit1 r₁)).2 <
        ↑d

Next tactic:
intro IH
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    

Proof state:
case bit1.mk
d n : PosNum
q r : Num
IH : ↑(q, r).2 + ↑d * ↑(q, r).1 = ↑n ∧ ↑(q, r).2 < ↑d
⊢ ↑(match (q, r) with
            | (q, r₁) => divModAux d q (Num.bit1 r₁)).2 +
        ↑d *
          ↑(match (q, r) with
              | (q, r₁) => divModAux d q (Num.bit1 r₁)).1 =
      ↑(bit1 n) ∧
    ↑(match (q, r) with
          | (q, r₁) => divModAux d q (Num.bit1 r₁)).2 <
      ↑d

Next tactic:
simp only [divMod] at IH ⊢
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    

Proof state:
case bit1.mk
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ ↑(divModAux d q (Num.bit1 r)).2 + ↑d * ↑(divModAux d q (Num.bit1 r)).1 = ↑(bit1 n) ∧
    ↑(divModAux d q (Num.bit1 r)).2 < ↑d

Next tactic:
apply divMod_to_nat_aux
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> 

Proof state:
case bit1.mk.h₁
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ ↑(Num.bit1 r) + ↑d * _root_.bit0 ↑q = ↑(bit1 n)

Next tactic:
simp
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> 

Proof state:
case bit1.mk.h₂
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ ↑(Num.bit1 r) < 2 * ↑d

Next tactic:
simp
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · 

Proof state:
case bit1.mk.h₁
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ _root_.bit1 ↑r + ↑d * _root_.bit0 ↑q = _root_.bit1 ↑n

Next tactic:
rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · 

Proof state:
case bit1.mk.h₂
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ _root_.bit1 ↑r < 2 * ↑d

Next tactic:
rw [← bit0_eq_two_mul]
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      

Proof state:
case bit1.mk.h₂
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ _root_.bit1 ↑r < _root_.bit0 ↑d

Next tactic:
exact Nat.bit1_lt_bit0 IH.2
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · 

Proof state:
case bit0
d n : PosNum
IH : ↑(divMod d n).2 + ↑d * ↑(divMod d n).1 = ↑n ∧ ↑(divMod d n).2 < ↑d
⊢ ↑(divMod d (bit0 n)).2 + ↑d * ↑(divMod d (bit0 n)).1 = ↑(bit0 n) ∧ ↑(divMod d (bit0 n)).2 < ↑d

Next tactic:
unfold divMod
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    

Proof state:
case bit0
d n : PosNum
IH : ↑(divMod d n).2 + ↑d * ↑(divMod d n).1 = ↑n ∧ ↑(divMod d n).2 < ↑d
⊢ ↑(match divMod d n with
            | (q, r₁) => divModAux d q (Num.bit0 r₁)).2 +
        ↑d *
          ↑(match divMod d n with
              | (q, r₁) => divModAux d q (Num.bit0 r₁)).1 =
      ↑(bit0 n) ∧
    ↑(match divMod d n with
          | (q, r₁) => divModAux d q (Num.bit0 r₁)).2 <
      ↑d

Next tactic:
revert IH
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; 

Proof state:
case bit0
d n : PosNum
⊢ ↑(divMod d n).2 + ↑d * ↑(divMod d n).1 = ↑n ∧ ↑(divMod d n).2 < ↑d →
    ↑(match divMod d n with
              | (q, r₁) => divModAux d q (Num.bit0 r₁)).2 +
          ↑d *
            ↑(match divMod d n with
                | (q, r₁) => divModAux d q (Num.bit0 r₁)).1 =
        ↑(bit0 n) ∧
      ↑(match divMod d n with
            | (q, r₁) => divModAux d q (Num.bit0 r₁)).2 <
        ↑d

Next tactic:
cases' divMod d n with q r
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; 

Proof state:
case bit0.mk
d n : PosNum
q r : Num
⊢ ↑(q, r).2 + ↑d * ↑(q, r).1 = ↑n ∧ ↑(q, r).2 < ↑d →
    ↑(match (q, r) with
              | (q, r₁) => divModAux d q (Num.bit0 r₁)).2 +
          ↑d *
            ↑(match (q, r) with
                | (q, r₁) => divModAux d q (Num.bit0 r₁)).1 =
        ↑(bit0 n) ∧
      ↑(match (q, r) with
            | (q, r₁) => divModAux d q (Num.bit0 r₁)).2 <
        ↑d

Next tactic:
intro IH
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    

Proof state:
case bit0.mk
d n : PosNum
q r : Num
IH : ↑(q, r).2 + ↑d * ↑(q, r).1 = ↑n ∧ ↑(q, r).2 < ↑d
⊢ ↑(match (q, r) with
            | (q, r₁) => divModAux d q (Num.bit0 r₁)).2 +
        ↑d *
          ↑(match (q, r) with
              | (q, r₁) => divModAux d q (Num.bit0 r₁)).1 =
      ↑(bit0 n) ∧
    ↑(match (q, r) with
          | (q, r₁) => divModAux d q (Num.bit0 r₁)).2 <
      ↑d

Next tactic:
simp only [divMod] at IH ⊢
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    

Proof state:
case bit0.mk
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ ↑(divModAux d q (Num.bit0 r)).2 + ↑d * ↑(divModAux d q (Num.bit0 r)).1 = ↑(bit0 n) ∧
    ↑(divModAux d q (Num.bit0 r)).2 < ↑d

Next tactic:
apply divMod_to_nat_aux
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> 

Proof state:
case bit0.mk.h₁
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ ↑(Num.bit0 r) + ↑d * _root_.bit0 ↑q = ↑(bit0 n)

Next tactic:
simp
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> 

Proof state:
case bit0.mk.h₂
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ ↑(Num.bit0 r) < 2 * ↑d

Next tactic:
simp
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · 

Proof state:
case bit0.mk.h₁
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ _root_.bit0 ↑r + ↑d * _root_.bit0 ↑q = _root_.bit0 ↑n

Next tactic:
rw [bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ← bit0_eq_two_mul, mul_left_comm, ←
        bit0_eq_two_mul]
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ← bit0_eq_two_mul, mul_left_comm, ←
        bit0_eq_two_mul]
    · 

Proof state:
case bit0.mk.h₂
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ _root_.bit0 ↑r < 2 * ↑d

Next tactic:
rw [← bit0_eq_two_mul]
theorem divMod_to_nat (d n : PosNum) :
    (n / d : ℕ) = (divMod d n).1 ∧ (n % d : ℕ) = (divMod d n).2 := by
  rw [Nat.div_mod_unique (PosNum.cast_pos _)]
  induction' n with n IH n IH
  · exact
      divMod_to_nat_aux (by simp) (Nat.mul_le_mul_left 2 (PosNum.cast_pos d : (0 : ℕ) < d))
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [_root_.bit1, _root_.bit1, add_right_comm, bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ←
        bit0_eq_two_mul, mul_left_comm, ← bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      exact Nat.bit1_lt_bit0 IH.2
  · unfold divMod
    -- Porting note: `cases'` didn't rewrite at `this`, so `revert` & `intro` are required.
    revert IH; cases' divMod d n with q r; intro IH
    simp only [divMod] at IH ⊢
    apply divMod_to_nat_aux <;> simp
    · rw [bit0_eq_two_mul (n : ℕ), ← IH.1, mul_add, ← bit0_eq_two_mul, mul_left_comm, ←
        bit0_eq_two_mul]
    · rw [← bit0_eq_two_mul]
      

Proof state:
case bit0.mk.h₂
d n : PosNum
q r : Num
IH : ↑r + ↑d * ↑q = ↑n ∧ ↑r < ↑d
⊢ _root_.bit0 ↑r < _root_.bit0 ↑d

Next tactic:
exact Nat.bit0_lt IH.2
@[simp]
protected theorem div_zero (n : Num) : n / 0 = 0 :=
  show n.div 0 = 0 by
    

Proof state:
n : Num
⊢ div n 0 = 0

Next tactic:
cases n
@[simp]
protected theorem div_zero (n : Num) : n / 0 = 0 :=
  show n.div 0 = 0 by
    cases n
    · 

Proof state:
case zero
⊢ div zero 0 = 0

Next tactic:
rfl
@[simp]
protected theorem div_zero (n : Num) : n / 0 = 0 :=
  show n.div 0 = 0 by
    cases n
    · rfl
    · 

Proof state:
case pos
a✝ : PosNum
⊢ div (pos a✝) 0 = 0

Next tactic:
simp [Num.div]
@[simp, norm_cast]
theorem div_to_nat : ∀ n d, ((n / d : Num) : ℕ) = n / d
  | 0, 0 => by 

Proof state:
⊢ ↑(0 / 0) = ↑0 / ↑0

Next tactic:
simp
@[simp]
protected theorem mod_zero (n : Num) : n % 0 = n :=
  show n.mod 0 = n by
    

Proof state:
n : Num
⊢ mod n 0 = n

Next tactic:
cases n
@[simp]
protected theorem mod_zero (n : Num) : n % 0 = n :=
  show n.mod 0 = n by
    cases n
    · 

Proof state:
case zero
⊢ mod zero 0 = zero

Next tactic:
rfl
@[simp]
protected theorem mod_zero (n : Num) : n % 0 = n :=
  show n.mod 0 = n by
    cases n
    · rfl
    · 

Proof state:
case pos
a✝ : PosNum
⊢ mod (pos a✝) 0 = pos a✝

Next tactic:
simp [Num.mod]
@[simp, norm_cast]
theorem mod_to_nat : ∀ n d, ((n % d : Num) : ℕ) = n % d
  | 0, 0 => by 

Proof state:
⊢ ↑(0 % 0) = ↑0 % ↑0

Next tactic:
simp