Theorem: PosNum.cast_sub'
File: Mathlib/Data/Num/Lemmas.lean

Proof steps:
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a : PosNum
⊢ ↑(a.sub' 1) = ↑a - ↑1
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a : PosNum
⊢ ↑(↑a - 1) = ↑a - ↑1
tactic: rw [sub'_one, Num.cast_toZNum, ← Num.cast_to_nat, pred'_to_nat, ← Nat.sub_one]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a : PosNum
⊢ ↑(↑a - 1) = ↑a - ↑1
state_after: no goals
tactic: simp [PosNum.cast_pos]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
b : PosNum
⊢ ↑(sub' 1 b) = ↑1 - ↑b
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
b : PosNum
⊢ ↑(↑b - 1) = ↑b - ↑1
tactic: rw [one_sub', Num.cast_toZNumNeg, ← neg_sub, neg_inj, ← Num.cast_to_nat, pred'_to_nat,
        ← Nat.sub_one]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
b : PosNum
⊢ ↑(↑b - 1) = ↑b - ↑1
state_after: no goals
tactic: simp [PosNum.cast_pos]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑(a.bit0.sub' b.bit0) = ↑a.bit0 - ↑b.bit0
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑a - ↑b + (↑a - ↑b) = ↑a.bit0 - ↑b.bit0
tactic: rw [sub', ZNum.cast_bit0, cast_sub' a b]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑a - ↑b + (↑a - ↑b) = ↑a.bit0 - ↑b.bit0
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
this : ↑(↑a + -↑b + (↑a + -↑b)) = ↑a + ↑a + (-↑b + -↑b)
⊢ ↑a - ↑b + (↑a - ↑b) = ↑a.bit0 - ↑b.bit0
tactic: have : ((a + -b + (a + -b) : ℤ) : α) = a + a + (-b + -b) := by simp [add_left_comm]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
this : ↑(↑a + -↑b + (↑a + -↑b)) = ↑a + ↑a + (-↑b + -↑b)
⊢ ↑a - ↑b + (↑a - ↑b) = ↑a.bit0 - ↑b.bit0
state_after: no goals
tactic: simpa [sub_eq_add_neg] using this
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑(a.bit0.sub' b.bit1) = ↑a.bit0 - ↑b.bit1
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑a - ↑b + (↑a - ↑b) - 1 = ↑a.bit0 - ↑b.bit1
tactic: rw [sub', ZNum.cast_bitm1, cast_sub' a b]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑a - ↑b + (↑a - ↑b) - 1 = ↑a.bit0 - ↑b.bit1
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
this : ↑(-↑b + (↑a + (-↑b + -1))) = ↑(↑a + -1 + (-↑b + -↑b))
⊢ ↑a - ↑b + (↑a - ↑b) - 1 = ↑a.bit0 - ↑b.bit1
tactic: have : ((-b + (a + (-b + -1)) : ℤ) : α) = (a + -1 + (-b + -b) : ℤ) := by
      simp [add_comm, add_left_comm]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
this : ↑(-↑b + (↑a + (-↑b + -1))) = ↑(↑a + -1 + (-↑b + -↑b))
⊢ ↑a - ↑b + (↑a - ↑b) - 1 = ↑a.bit0 - ↑b.bit1
state_after: no goals
tactic: simpa [sub_eq_add_neg] using this
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑(a.bit1.sub' b.bit0) = ↑a.bit1 - ↑b.bit0
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑a - ↑b + (↑a - ↑b) + 1 = ↑a.bit1 - ↑b.bit0
tactic: rw [sub', ZNum.cast_bit1, cast_sub' a b]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑a - ↑b + (↑a - ↑b) + 1 = ↑a.bit1 - ↑b.bit0
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
this : ↑(-↑b + (↑a + (-↑b + 1))) = ↑(↑a + 1 + (-↑b + -↑b))
⊢ ↑a - ↑b + (↑a - ↑b) + 1 = ↑a.bit1 - ↑b.bit0
tactic: have : ((-b + (a + (-b + 1)) : ℤ) : α) = (a + 1 + (-b + -b) : ℤ) := by
      simp [add_comm, add_left_comm]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
this : ↑(-↑b + (↑a + (-↑b + 1))) = ↑(↑a + 1 + (-↑b + -↑b))
⊢ ↑a - ↑b + (↑a - ↑b) + 1 = ↑a.bit1 - ↑b.bit0
state_after: no goals
tactic: simpa [sub_eq_add_neg] using this
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑(a.bit1.sub' b.bit1) = ↑a.bit1 - ↑b.bit1
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑a - ↑b + (↑a - ↑b) = ↑a.bit1 - ↑b.bit1
tactic: rw [sub', ZNum.cast_bit0, cast_sub' a b]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
⊢ ↑a - ↑b + (↑a - ↑b) = ↑a.bit1 - ↑b.bit1
state_after: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
this : ↑(-↑b + (↑a + -↑b)) = ↑a + (-↑b + -↑b)
⊢ ↑a - ↑b + (↑a - ↑b) = ↑a.bit1 - ↑b.bit1
tactic: have : ((-b + (a + -b) : ℤ) : α) = a + (-b + -b) := by simp [add_left_comm]
state_before: α : Type u_1
inst✝ : AddGroupWithOne α
a b : PosNum
this : ↑(-↑b + (↑a + -↑b)) = ↑a + (-↑b + -↑b)
⊢ ↑a - ↑b + (↑a - ↑b) = ↑a.bit1 - ↑b.bit1
state_after: no goals
tactic: simpa [sub_eq_add_neg] using this