Theorem: Nat.digits_two_eq_bits
File: Mathlib/Data/Nat/Digits.lean

tactic: induction' n using Nat.binaryRecFromOne with b n h ih
state_before: n✝ n : ℕ
⊢ digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
state_after: case z₀
n : ℕ
⊢ digits 2 0 = List.map (fun b => bif b then 1 else 0) (bits 0)

case z₁
n : ℕ
⊢ digits 2 1 = List.map (fun b => bif b then 1 else 0) (bits 1)

case f
n✝ : ℕ
b : Bool
n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ digits 2 (bit b n) = List.map (fun b => bif b then 1 else 0) (bit b n).bits

tactic: rw [bits_append_bit _ _ fun hn => absurd hn h]
state_before: case f
n✝ : ℕ
b : Bool
n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ digits 2 (bit b n) = List.map (fun b => bif b then 1 else 0) (bit b n).bits
state_after: case f
n✝ : ℕ
b : Bool
n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ digits 2 (bit b n) = List.map (fun b => bif b then 1 else 0) (b :: n.bits)

tactic: cases b
state_before: case f
n✝ : ℕ
b : Bool
n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ digits 2 (bit b n) = List.map (fun b => bif b then 1 else 0) (b :: n.bits)
state_after: case f.false
n✝ n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ digits 2 (bit false n) = List.map (fun b => bif b then 1 else 0) (false :: n.bits)

case f.true
n✝ n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ digits 2 (bit true n) = List.map (fun b => bif b then 1 else 0) (true :: n.bits)

tactic: simp
state_before: case z₀
n : ℕ
⊢ digits 2 0 = List.map (fun b => bif b then 1 else 0) (bits 0)
state_after: no goals

tactic: rfl
state_before: case z₁
n : ℕ
⊢ digits 2 1 = List.map (fun b => bif b then 1 else 0) (bits 1)
state_after: no goals

tactic: rw [digits_def' one_lt_two]
state_before: case f.false
n✝ n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ digits 2 (bit false n) = List.map (fun b => bif b then 1 else 0) (false :: n.bits)
state_after: case f.false
n✝ n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ bit false n % 2 :: digits 2 (bit false n / 2) = List.map (fun b => bif b then 1 else 0) (false :: n.bits)

case f.false
n✝ n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ 0 < bit false n

tactic: simpa [Nat.bit, Nat.bit0_val n]
state_before: case f.false
n✝ n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ bit false n % 2 :: digits 2 (bit false n / 2) = List.map (fun b => bif b then 1 else 0) (false :: n.bits)
state_after: no goals

tactic: simpa [pos_iff_ne_zero, Nat.bit0_eq_zero]
state_before: case f.false
n✝ n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ 0 < bit false n
state_after: no goals

tactic: simpa [Nat.bit, Nat.bit1_val n, add_comm, digits_add 2 one_lt_two 1 n, Nat.add_mul_div_left]
state_before: case f.true
n✝ n : ℕ
h : n ≠ 0
ih : digits 2 n = List.map (fun b => bif b then 1 else 0) n.bits
⊢ digits 2 (bit true n) = List.map (fun b => bif b then 1 else 0) (true :: n.bits)
state_after: no goals