l3lab/ntp-mathlib huggingface dataset:
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> 

Proof state:
case zero.bit0
α : Type u_1
m : PosNum
⊢ PosNum.testBit (PosNum.bit0 m) Nat.zero = Nat.testBit (↑(PosNum.bit0 m)) Nat.zero

Next tactic:
dsimp only [PosNum.testBit, Nat.zero_eq]
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> 

Proof state:
case succ.one
α : Type u_1
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.testBit (↑m) n
⊢ PosNum.testBit one (Nat.succ n) = Nat.testBit (↑one) (Nat.succ n)

Next tactic:
dsimp only [PosNum.testBit, Nat.zero_eq]
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> 

Proof state:
case succ.bit1
α : Type u_1
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.testBit (↑m) n
m : PosNum
⊢ PosNum.testBit (PosNum.bit1 m) (Nat.succ n) = Nat.testBit (↑(PosNum.bit1 m)) (Nat.succ n)

Next tactic:
dsimp only [PosNum.testBit, Nat.zero_eq]
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> 

Proof state:
case succ.bit0
α : Type u_1
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.testBit (↑m) n
m : PosNum
⊢ PosNum.testBit (PosNum.bit0 m) (Nat.succ n) = Nat.testBit (↑(PosNum.bit0 m)) (Nat.succ n)

Next tactic:
dsimp only [PosNum.testBit, Nat.zero_eq]
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> dsimp only [PosNum.testBit, Nat.zero_eq]
    · 

Proof state:
case zero.one
α : Type u_1
⊢ true = Nat.testBit (↑one) 0

Next tactic:
rfl
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> dsimp only [PosNum.testBit, Nat.zero_eq]
    · rfl
    · 

Proof state:
case zero.bit1
α : Type u_1
m : PosNum
⊢ true = Nat.testBit (↑(PosNum.bit1 m)) 0

Next tactic:
rw [PosNum.cast_bit1, ← Nat.bit_true, Nat.testBit_zero]
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> dsimp only [PosNum.testBit, Nat.zero_eq]
    · rfl
    · rw [PosNum.cast_bit1, ← Nat.bit_true, Nat.testBit_zero]
    · 

Proof state:
case zero.bit0
α : Type u_1
m : PosNum
⊢ false = Nat.testBit (↑(PosNum.bit0 m)) 0

Next tactic:
rw [PosNum.cast_bit0, ← Nat.bit_false, Nat.testBit_zero]
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> dsimp only [PosNum.testBit, Nat.zero_eq]
    · rfl
    · rw [PosNum.cast_bit1, ← Nat.bit_true, Nat.testBit_zero]
    · rw [PosNum.cast_bit0, ← Nat.bit_false, Nat.testBit_zero]
    · 

Proof state:
case succ.one
α : Type u_1
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.testBit (↑m) n
⊢ false = Nat.testBit (↑one) (Nat.succ n)

Next tactic:
rw [PosNum.cast_one', ← bit1_zero, ← Nat.bit_true, Nat.testBit_succ, Nat.zero_testBit]
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> dsimp only [PosNum.testBit, Nat.zero_eq]
    · rfl
    · rw [PosNum.cast_bit1, ← Nat.bit_true, Nat.testBit_zero]
    · rw [PosNum.cast_bit0, ← Nat.bit_false, Nat.testBit_zero]
    · rw [PosNum.cast_one', ← bit1_zero, ← Nat.bit_true, Nat.testBit_succ, Nat.zero_testBit]
    · 

Proof state:
case succ.bit1
α : Type u_1
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.testBit (↑m) n
m : PosNum
⊢ PosNum.testBit m n = Nat.testBit (↑(PosNum.bit1 m)) (Nat.succ n)

Next tactic:
rw [PosNum.cast_bit1, ← Nat.bit_true, Nat.testBit_succ, IH]
@[simp]
theorem castNum_testBit (m n) : testBit m n = Nat.testBit m n := by
  -- Porting note: `unfold` → `dsimp only`
  cases m <;> dsimp only [testBit]
  case zero =>
    rw [show (Num.zero : Nat) = 0 from rfl, Nat.zero_testBit]
  case pos m =>
    rw [cast_pos]
    induction' n with n IH generalizing m <;> cases' m with m m
        <;> dsimp only [PosNum.testBit, Nat.zero_eq]
    · rfl
    · rw [PosNum.cast_bit1, ← Nat.bit_true, Nat.testBit_zero]
    · rw [PosNum.cast_bit0, ← Nat.bit_false, Nat.testBit_zero]
    · rw [PosNum.cast_one', ← bit1_zero, ← Nat.bit_true, Nat.testBit_succ, Nat.zero_testBit]
    · rw [PosNum.cast_bit1, ← Nat.bit_true, Nat.testBit_succ, IH]
    · 

Proof state:
case succ.bit0
α : Type u_1
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.testBit (↑m) n
m : PosNum
⊢ PosNum.testBit m n = Nat.testBit (↑(PosNum.bit0 m)) (Nat.succ n)

Next tactic:
rw [PosNum.cast_bit0, ← Nat.bit_false, Nat.testBit_succ, IH]
theorem zneg_zneg (n : ZNum) : - -n = n := by 

Proof state:
α : Type u_1
n : ZNum
⊢ - -n = n

Next tactic:
cases n
theorem zneg_zneg (n : ZNum) : - -n = n := by cases n <;> 

Proof state:
case zero
α : Type u_1
⊢ - -zero = zero

Next tactic:
rfl
theorem zneg_zneg (n : ZNum) : - -n = n := by cases n <;> 

Proof state:
case pos
α : Type u_1
a✝ : PosNum
⊢ - -pos a✝ = pos a✝

Next tactic:
rfl
theorem zneg_zneg (n : ZNum) : - -n = n := by cases n <;> 

Proof state:
case neg
α : Type u_1
a✝ : PosNum
⊢ - -neg a✝ = neg a✝

Next tactic:
rfl
theorem zneg_bit1 (n : ZNum) : -n.bit1 = (-n).bitm1 := by 

Proof state:
α : Type u_1
n : ZNum
⊢ -ZNum.bit1 n = ZNum.bitm1 (-n)

Next tactic:
cases n
theorem zneg_bit1 (n : ZNum) : -n.bit1 = (-n).bitm1 := by cases n <;> 

Proof state:
case zero
α : Type u_1
⊢ -ZNum.bit1 zero = ZNum.bitm1 (-zero)

Next tactic:
rfl
theorem zneg_bit1 (n : ZNum) : -n.bit1 = (-n).bitm1 := by cases n <;> 

Proof state:
case pos
α : Type u_1
a✝ : PosNum
⊢ -ZNum.bit1 (pos a✝) = ZNum.bitm1 (-pos a✝)

Next tactic:
rfl
theorem zneg_bit1 (n : ZNum) : -n.bit1 = (-n).bitm1 := by cases n <;> 

Proof state:
case neg
α : Type u_1
a✝ : PosNum
⊢ -ZNum.bit1 (neg a✝) = ZNum.bitm1 (-neg a✝)

Next tactic:
rfl
theorem zneg_bitm1 (n : ZNum) : -n.bitm1 = (-n).bit1 := by 

Proof state:
α : Type u_1
n : ZNum
⊢ -ZNum.bitm1 n = ZNum.bit1 (-n)

Next tactic:
cases n
theorem zneg_bitm1 (n : ZNum) : -n.bitm1 = (-n).bit1 := by cases n <;> 

Proof state:
case zero
α : Type u_1
⊢ -ZNum.bitm1 zero = ZNum.bit1 (-zero)

Next tactic:
rfl
theorem zneg_bitm1 (n : ZNum) : -n.bitm1 = (-n).bit1 := by cases n <;> 

Proof state:
case pos
α : Type u_1
a✝ : PosNum
⊢ -ZNum.bitm1 (pos a✝) = ZNum.bit1 (-pos a✝)

Next tactic:
rfl
theorem zneg_bitm1 (n : ZNum) : -n.bitm1 = (-n).bit1 := by cases n <;> 

Proof state:
case neg
α : Type u_1
a✝ : PosNum
⊢ -ZNum.bitm1 (neg a✝) = ZNum.bit1 (-neg a✝)

Next tactic:
rfl
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  

Proof state:
α : Type u_1
n : ZNum
⊢ -succ n = pred (-n)

Next tactic:
cases n
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> 

Proof state:
case zero
α : Type u_1
⊢ -succ zero = pred (-zero)

Next tactic:
try { rfl }
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> try 

Proof state:
case zero
α : Type u_1
⊢ -succ zero = pred (-zero)

Next tactic:
{ rfl }
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> try { 

Proof state:
case zero
α : Type u_1
⊢ -succ zero = pred (-zero)

Next tactic:
rfl
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> 

Proof state:
case pos
α : Type u_1
a✝ : PosNum
⊢ -succ (pos a✝) = pred (-pos a✝)

Next tactic:
try { rfl }
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> try 

Proof state:
case pos
α : Type u_1
a✝ : PosNum
⊢ -succ (pos a✝) = pred (-pos a✝)

Next tactic:
{ rfl }
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> try { 

Proof state:
case pos
α : Type u_1
a✝ : PosNum
⊢ -succ (pos a✝) = pred (-pos a✝)

Next tactic:
rfl
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> 

Proof state:
case neg
α : Type u_1
a✝ : PosNum
⊢ -succ (neg a✝) = pred (-neg a✝)

Next tactic:
try { rfl }
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> try 

Proof state:
case neg
α : Type u_1
a✝ : PosNum
⊢ -succ (neg a✝) = pred (-neg a✝)

Next tactic:
{ rfl }
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> try { 

Proof state:
case neg
α : Type u_1
a✝ : PosNum
⊢ -succ (neg a✝) = pred (-neg a✝)

Next tactic:
rfl
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> try { rfl }; 

Proof state:
case neg
α : Type u_1
a✝ : PosNum
⊢ -succ (neg a✝) = pred (-neg a✝)

Next tactic:
rw [succ, Num.zneg_toZNumNeg]
theorem zneg_succ (n : ZNum) : -n.succ = (-n).pred := by
  cases n <;> try { rfl }; rw [succ, Num.zneg_toZNumNeg]; 

Proof state:
case neg
α : Type u_1
a✝ : PosNum
⊢ Num.toZNum (pred' a✝) = pred (-neg a✝)

Next tactic:
rfl
theorem zneg_pred (n : ZNum) : -n.pred = (-n).succ := by
  

Proof state:
α : Type u_1
n : ZNum
⊢ -pred n = succ (-n)

Next tactic:
rw [← zneg_zneg (succ (-n)), zneg_succ, zneg_zneg]
@[simp]
theorem abs_to_nat : ∀ n, (abs n : ℕ) = Int.natAbs n
  | 0 => rfl
  | pos p => congr_arg Int.natAbs p.to_nat_to_int
  | neg p => show Int.natAbs ((p : ℕ) : ℤ) = Int.natAbs (-p) by 

Proof state:
α : Type u_1
p : PosNum
⊢ natAbs ↑↑p = natAbs (-↑p)

Next tactic:
rw [p.to_nat_to_int, Int.natAbs_neg]
@[simp, norm_cast]
theorem cast_to_int [AddGroupWithOne α] : ∀ n : ZNum, ((n : ℤ) : α) = n
  | 0 => by 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
⊢ ↑↑0 = ↑0

Next tactic:
rw [cast_zero, cast_zero, Int.cast_zero]
@[simp, norm_cast]
theorem cast_to_int [AddGroupWithOne α] : ∀ n : ZNum, ((n : ℤ) : α) = n
  | 0 => by rw [cast_zero, cast_zero, Int.cast_zero]
  | pos p => by 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ ↑↑(pos p) = ↑(pos p)

Next tactic:
rw [cast_pos, cast_pos, PosNum.cast_to_int]
@[simp, norm_cast]
theorem cast_to_int [AddGroupWithOne α] : ∀ n : ZNum, ((n : ℤ) : α) = n
  | 0 => by rw [cast_zero, cast_zero, Int.cast_zero]
  | pos p => by rw [cast_pos, cast_pos, PosNum.cast_to_int]
  | neg p => by 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ ↑↑(neg p) = ↑(neg p)

Next tactic:
rw [cast_neg, cast_neg, Int.cast_neg, PosNum.cast_to_int]
theorem bit1_of_bit1 : ∀ n : ZNum, bit1 n = n.bit1
  | 0 => rfl
  | pos a => congr_arg pos a.bit1_of_bit1
  | neg a => show PosNum.sub' 1 (_root_.bit0 a) = _ by 

Proof state:
α : Type u_1
a : PosNum
⊢ sub' 1 (_root_.bit0 a) = ZNum.bit1 (neg a)

Next tactic:
rw [PosNum.one_sub', a.bit0_of_bit0]
theorem bit1_of_bit1 : ∀ n : ZNum, bit1 n = n.bit1
  | 0 => rfl
  | pos a => congr_arg pos a.bit1_of_bit1
  | neg a => show PosNum.sub' 1 (_root_.bit0 a) = _ by rw [PosNum.one_sub', a.bit0_of_bit0]; 

Proof state:
α : Type u_1
a : PosNum
⊢ Num.toZNumNeg (pred' (PosNum.bit0 a)) = ZNum.bit1 (neg a)

Next tactic:
rfl
@[simp, norm_cast]
theorem cast_bit0 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit0 : α) = bit0 (n : α)
  | 0 => (add_zero _).symm
  | pos p => by 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ ↑(ZNum.bit0 (pos p)) = _root_.bit0 ↑(pos p)

Next tactic:
rw [ZNum.bit0, cast_pos, cast_pos]
@[simp, norm_cast]
theorem cast_bit0 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit0 : α) = bit0 (n : α)
  | 0 => (add_zero _).symm
  | pos p => by rw [ZNum.bit0, cast_pos, cast_pos]; 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ ↑(PosNum.bit0 p) = _root_.bit0 ↑p

Next tactic:
rfl
@[simp, norm_cast]
theorem cast_bit0 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit0 : α) = bit0 (n : α)
  | 0 => (add_zero _).symm
  | pos p => by rw [ZNum.bit0, cast_pos, cast_pos]; rfl
  | neg p => by
    

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ ↑(ZNum.bit0 (neg p)) = _root_.bit0 ↑(neg p)

Next tactic:
rw [ZNum.bit0, cast_neg, cast_neg, PosNum.cast_bit0, _root_.bit0, _root_.bit0, neg_add_rev]
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
⊢ ↑(ZNum.bit1 0) = _root_.bit1 ↑0

Next tactic:
simp [ZNum.bit1, _root_.bit1, _root_.bit0]
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ ↑(ZNum.bit1 (pos p)) = _root_.bit1 ↑(pos p)

Next tactic:
rw [ZNum.bit1, cast_pos, cast_pos]
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ ↑(PosNum.bit1 p) = _root_.bit1 ↑p

Next tactic:
rfl
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ ↑(ZNum.bit1 (neg p)) = _root_.bit1 ↑(neg p)

Next tactic:
rw [ZNum.bit1, cast_neg, cast_neg]
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
⊢ -↑(Num.casesOn (pred' p) 1 PosNum.bit1) = _root_.bit1 (-↑p)

Next tactic:
cases' e : pred' p with a
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      

Proof state:
case zero
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
e : pred' p = Num.zero
⊢ -↑(Num.casesOn Num.zero 1 PosNum.bit1) = _root_.bit1 (-↑p)

Next tactic:
have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      

Proof state:
case pos
α : Type u_1
inst✝ : AddGroupWithOne α
p a : PosNum
e : pred' p = Num.pos a
⊢ -↑(Num.casesOn (Num.pos a) 1 PosNum.bit1) = _root_.bit1 (-↑p)

Next tactic:
have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · 

Proof state:
case zero
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
e : pred' p = Num.zero
ep : p = Num.succ' Num.zero
⊢ -↑(Num.casesOn Num.zero 1 PosNum.bit1) = _root_.bit1 (-↑p)

Next tactic:
conv at ep => change p = 1
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · conv at ep => 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
e : pred' p = Num.zero
ep : p = Num.succ' Num.zero
| p = Num.succ' Num.zero

Next tactic:
change p = 1
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · conv at ep => change p = 1
      

Proof state:
case zero
α : Type u_1
inst✝ : AddGroupWithOne α
p : PosNum
e : pred' p = Num.zero
ep : p = 1
⊢ -↑(Num.casesOn Num.zero 1 PosNum.bit1) = _root_.bit1 (-↑p)

Next tactic:
subst p
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · conv at ep => change p = 1
      subst p
      

Proof state:
case zero
α : Type u_1
inst✝ : AddGroupWithOne α
e : pred' 1 = Num.zero
⊢ -↑(Num.casesOn Num.zero 1 PosNum.bit1) = _root_.bit1 (-↑1)

Next tactic:
simp [_root_.bit1, _root_.bit0]
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · conv at ep => change p = 1
      subst p
      simp [_root_.bit1, _root_.bit0]
    -- Porting note: `rw [Num.succ']` yields a `match` pattern.
    · 

Proof state:
case pos
α : Type u_1
inst✝ : AddGroupWithOne α
p a : PosNum
e : pred' p = Num.pos a
ep : p = Num.succ' (Num.pos a)
⊢ -↑(Num.casesOn (Num.pos a) 1 PosNum.bit1) = _root_.bit1 (-↑p)

Next tactic:
dsimp only [Num.succ'] at ep
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · conv at ep => change p = 1
      subst p
      simp [_root_.bit1, _root_.bit0]
    -- Porting note: `rw [Num.succ']` yields a `match` pattern.
    · dsimp only [Num.succ'] at ep
      

Proof state:
case pos
α : Type u_1
inst✝ : AddGroupWithOne α
p a : PosNum
e : pred' p = Num.pos a
ep : p = PosNum.succ a
⊢ -↑(Num.casesOn (Num.pos a) 1 PosNum.bit1) = _root_.bit1 (-↑p)

Next tactic:
subst p
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · conv at ep => change p = 1
      subst p
      simp [_root_.bit1, _root_.bit0]
    -- Porting note: `rw [Num.succ']` yields a `match` pattern.
    · dsimp only [Num.succ'] at ep
      subst p
      

Proof state:
case pos
α : Type u_1
inst✝ : AddGroupWithOne α
a : PosNum
e : pred' (PosNum.succ a) = Num.pos a
⊢ -↑(Num.casesOn (Num.pos a) 1 PosNum.bit1) = _root_.bit1 (-↑(PosNum.succ a))

Next tactic:
have : (↑(-↑a : ℤ) : α) = -1 + ↑(-↑a + 1 : ℤ) := by simp [add_comm (- ↑a : ℤ) 1]
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · conv at ep => change p = 1
      subst p
      simp [_root_.bit1, _root_.bit0]
    -- Porting note: `rw [Num.succ']` yields a `match` pattern.
    · dsimp only [Num.succ'] at ep
      subst p
      have : (↑(-↑a : ℤ) : α) = -1 + ↑(-↑a + 1 : ℤ) := by 

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
a : PosNum
e : pred' (PosNum.succ a) = Num.pos a
⊢ ↑(-↑a) = -1 + ↑(-↑a + 1)

Next tactic:
simp [add_comm (- ↑a : ℤ) 1]
@[simp, norm_cast]
theorem cast_bit1 [AddGroupWithOne α] : ∀ n : ZNum, (n.bit1 : α) = bit1 (n : α)
  | 0 => by simp [ZNum.bit1, _root_.bit1, _root_.bit0]
  | pos p => by rw [ZNum.bit1, cast_pos, cast_pos]; rfl
  | neg p => by
    rw [ZNum.bit1, cast_neg, cast_neg]
    cases' e : pred' p with a <;>
      have ep : p = _ := (succ'_pred' p).symm.trans (congr_arg Num.succ' e)
    · conv at ep => change p = 1
      subst p
      simp [_root_.bit1, _root_.bit0]
    -- Porting note: `rw [Num.succ']` yields a `match` pattern.
    · dsimp only [Num.succ'] at ep
      subst p
      have : (↑(-↑a : ℤ) : α) = -1 + ↑(-↑a + 1 : ℤ) := by simp [add_comm (- ↑a : ℤ) 1]
      

Proof state:
case pos
α : Type u_1
inst✝ : AddGroupWithOne α
a : PosNum
e : pred' (PosNum.succ a) = Num.pos a
this : ↑(-↑a) = -1 + ↑(-↑a + 1)
⊢ -↑(Num.casesOn (Num.pos a) 1 PosNum.bit1) = _root_.bit1 (-↑(PosNum.succ a))

Next tactic:
simpa [_root_.bit1, _root_.bit0] using this
@[simp]
theorem cast_bitm1 [AddGroupWithOne α] (n : ZNum) : (n.bitm1 : α) = bit0 (n : α) - 1 := by
  

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
n : ZNum
⊢ ↑(ZNum.bitm1 n) = _root_.bit0 ↑n - 1

Next tactic:
conv =>
    lhs
    rw [← zneg_zneg n]
@[simp]
theorem cast_bitm1 [AddGroupWithOne α] (n : ZNum) : (n.bitm1 : α) = bit0 (n : α) - 1 := by
  conv =>
    

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
n : ZNum
| ↑(ZNum.bitm1 n) = _root_.bit0 ↑n - 1

Next tactic:
lhs
    rw [← zneg_zneg n]
@[simp]
theorem cast_bitm1 [AddGroupWithOne α] (n : ZNum) : (n.bitm1 : α) = bit0 (n : α) - 1 := by
  conv =>
    

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
n : ZNum
| ↑(ZNum.bitm1 n) = _root_.bit0 ↑n - 1

Next tactic:
lhs
@[simp]
theorem cast_bitm1 [AddGroupWithOne α] (n : ZNum) : (n.bitm1 : α) = bit0 (n : α) - 1 := by
  conv =>
    lhs
    

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
n : ZNum
| ↑(ZNum.bitm1 n)

Next tactic:
rw [← zneg_zneg n]
@[simp]
theorem cast_bitm1 [AddGroupWithOne α] (n : ZNum) : (n.bitm1 : α) = bit0 (n : α) - 1 := by
  conv =>
    lhs
    rw [← zneg_zneg n]
  

Proof state:
α : Type u_1
inst✝ : AddGroupWithOne α
n : ZNum
⊢ ↑(ZNum.bitm1 (- -n)) = _root_.bit0 ↑n - 1

Next tactic:
rw [← zneg_bit1, cast_zneg, cast_bit1]