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

tactic: cases m <;> dsimp only [testBit, Nat.testBit]
state_before: α : Type ?u.633818
m : Num
n : ℕ
⊢ testBit m n = Nat.testBit (↑m) n

tactic: case zero =>
  change false = Nat.bodd (Nat.shiftr 0 n)
  rw [Nat.zero_shiftr]
  rfl
state_before: case zero
α : Type ?u.633818
n : ℕ
⊢ false = Nat.bodd (Nat.shiftr (↑zero) n)

case pos
α : Type ?u.633818
n : ℕ
a✝ : PosNum
⊢ PosNum.testBit a✝ n = Nat.bodd (Nat.shiftr (↑(pos a✝)) n)

tactic: change false = Nat.bodd (Nat.shiftr 0 n)
state_before: α : Type ?u.633818
n : ℕ
⊢ false = Nat.bodd (Nat.shiftr (↑zero) n)

tactic: rw [Nat.zero_shiftr]
state_before: α : Type ?u.633818
n : ℕ
⊢ false = Nat.bodd (Nat.shiftr 0 n)

tactic: rfl
state_before: α : Type ?u.633818
n : ℕ
⊢ false = Nat.bodd 0

tactic: induction' n with n IH generalizing m <;> cases' m with m m <;> dsimp only [PosNum.testBit]
state_before: α : Type ?u.633818
n : ℕ
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)

tactic: rfl
state_before: case zero.one
α : Type ?u.633818
m : PosNum
⊢ true = Nat.bodd (Nat.shiftr (↑(pos one)) Nat.zero)

tactic: exact (Nat.bodd_bit _ _).symm
state_before: case zero.bit1
α : Type ?u.633818
m✝ m : PosNum
⊢ true = Nat.bodd (Nat.shiftr (↑(pos (PosNum.bit1 m))) Nat.zero)

tactic: exact (Nat.bodd_bit _ _).symm
state_before: case zero.bit0
α : Type ?u.633818
m✝ m : PosNum
⊢ false = Nat.bodd (Nat.shiftr (↑(pos (PosNum.bit0 m))) Nat.zero)

tactic: change false = Nat.bodd (Nat.shiftr 1 (n + 1))
state_before: case succ.one
α : Type ?u.633818
m : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
⊢ false = Nat.bodd (Nat.shiftr (↑(pos one)) (Nat.succ n))

tactic: rw [add_comm, Nat.shiftr_add]
state_before: case succ.one
α : Type ?u.633818
m : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
⊢ false = Nat.bodd (Nat.shiftr 1 (n + 1))

tactic: change false = Nat.bodd (Nat.shiftr 0 n)
state_before: case succ.one
α : Type ?u.633818
m : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
⊢ false = Nat.bodd (Nat.shiftr (Nat.shiftr 1 1) n)

tactic: rw [Nat.zero_shiftr]
state_before: case succ.one
α : Type ?u.633818
m : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
⊢ false = Nat.bodd (Nat.shiftr 0 n)

tactic: rfl
state_before: case succ.one
α : Type ?u.633818
m : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
⊢ false = Nat.bodd 0

tactic: change PosNum.testBit m n = Nat.bodd (Nat.shiftr (Nat.bit true m) (n + 1))
state_before: case succ.bit1
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos (PosNum.bit1 m))) (Nat.succ n))

tactic: rw [add_comm, Nat.shiftr_add]
state_before: case succ.bit1
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (Nat.bit true ↑m) (n + 1))

tactic: dsimp only [Nat.shiftr]
state_before: case succ.bit1
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (Nat.shiftr (Nat.bit true ↑m) 1) n)

tactic: rw [Nat.div2_bit]
state_before: case succ.bit1
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (Nat.div2 (Nat.bit true ↑m)) n)

tactic: apply IH
state_before: case succ.bit1
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑m) n)

tactic: change PosNum.testBit m n = Nat.bodd (Nat.shiftr (Nat.bit false m) (n + 1))
state_before: case succ.bit0
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos (PosNum.bit0 m))) (Nat.succ n))

tactic: rw [add_comm, Nat.shiftr_add]
state_before: case succ.bit0
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (Nat.bit false ↑m) (n + 1))

tactic: dsimp only [Nat.shiftr]
state_before: case succ.bit0
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (Nat.shiftr (Nat.bit false ↑m) 1) n)

tactic: rw [Nat.div2_bit]
state_before: case succ.bit0
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (Nat.div2 (Nat.bit false ↑m)) n)

tactic: apply IH
state_before: case succ.bit0
α : Type ?u.633818
m✝ : PosNum
n : ℕ
IH : ∀ (m : PosNum), PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑(pos m)) n)
m : PosNum
⊢ PosNum.testBit m n = Nat.bodd (Nat.shiftr (↑m) n)