Theorem: Nat.binaryRec_eq'
File: Mathlib/Data/Nat/Bits.lean

tactic: rw [binaryRec]
state_before: m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
⊢ binaryRec z f (bit b n) = f b n (binaryRec z f n)
state_after: m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
⊢ (if n0 : bit b n = 0 then ⋯.mpr z
    else
      let n' := (bit b n).div2;
      let_fun _x := ⋯;
      ⋯.mpr (f (bit b n).bodd n' (binaryRec z f n'))) =
    f b n (binaryRec z f n)

tactic: split_ifs with h'
state_before: m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
⊢ (if n0 : bit b n = 0 then ⋯.mpr z
    else
      let n' := (bit b n).div2;
      let_fun _x := ⋯;
      ⋯.mpr (f (bit b n).bodd n' (binaryRec z f n'))) =
    f b n (binaryRec z f n)
state_after: case pos
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : bit b n = 0
⊢ ⋯.mpr z = f b n (binaryRec z f n)

case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
⊢ (let n' := (bit b n).div2;
    let_fun _x := ⋯;
    ⋯.mpr (f (bit b n).bodd n' (binaryRec z f n'))) =
    f b n (binaryRec z f n)

tactic: rcases bit_eq_zero_iff.mp h' with ⟨rfl, rfl⟩
state_before: case pos
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : bit b n = 0
⊢ ⋯.mpr z = f b n (binaryRec z f n)
state_after: case pos.intro
m n : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z ∨ (0 = 0 → false = true)
h' : bit false 0 = 0
⊢ ⋯.mpr z = f false 0 (binaryRec z f 0)

tactic: rw [binaryRec_zero]
state_before: case pos.intro
m n : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z ∨ (0 = 0 → false = true)
h' : bit false 0 = 0
⊢ ⋯.mpr z = f false 0 (binaryRec z f 0)
state_after: case pos.intro
m n : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z ∨ (0 = 0 → false = true)
h' : bit false 0 = 0
⊢ ⋯.mpr z = f false 0 z

tactic: simp only [imp_false, or_false_iff, eq_self_iff_true, not_true] at h
state_before: case pos.intro
m n : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z ∨ (0 = 0 → false = true)
h' : bit false 0 = 0
⊢ ⋯.mpr z = f false 0 z
state_after: case pos.intro
m n : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h' : bit false 0 = 0
h : f false 0 z = z
⊢ ⋯.mpr z = f false 0 z

tactic: exact h.symm
state_before: case pos.intro
m n : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h' : bit false 0 = 0
h : f false 0 z = z
⊢ ⋯.mpr z = f false 0 z
state_after: no goals

tactic: dsimp only []
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
⊢ (let n' := (bit b n).div2;
    let_fun _x := ⋯;
    ⋯.mpr (f (bit b n).bodd n' (binaryRec z f n'))) =
    f b n (binaryRec z f n)
state_after: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
⊢ ⋯.mpr (f (bit b n).bodd (bit b n).div2 (binaryRec z f (bit b n).div2)) = f b n (binaryRec z f n)

tactic: generalize_proofs e
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
⊢ ⋯.mpr (f (bit b n).bodd (bit b n).div2 (binaryRec z f (bit b n).div2)) = f b n (binaryRec z f n)
state_after: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
e : C (bit b n) = C (bit (bit b n).bodd (bit b n).div2)
⊢ e.mpr (f (bit b n).bodd (bit b n).div2 (binaryRec z f (bit b n).div2)) = f b n (binaryRec z f n)

tactic: revert e
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
e : C (bit b n) = C (bit (bit b n).bodd (bit b n).div2)
⊢ e.mpr (f (bit b n).bodd (bit b n).div2 (binaryRec z f (bit b n).div2)) = f b n (binaryRec z f n)
state_after: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
⊢ ∀ (e : C (bit b n) = C (bit (bit b n).bodd (bit b n).div2)),
    e.mpr (f (bit b n).bodd (bit b n).div2 (binaryRec z f (bit b n).div2)) = f b n (binaryRec z f n)

tactic: rw [bodd_bit, div2_bit]
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
⊢ ∀ (e : C (bit b n) = C (bit (bit b n).bodd (bit b n).div2)),
    e.mpr (f (bit b n).bodd (bit b n).div2 (binaryRec z f (bit b n).div2)) = f b n (binaryRec z f n)
state_after: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
⊢ ∀ (e : C (bit b n) = C (bit b n)), e.mpr (f b n (binaryRec z f n)) = f b n (binaryRec z f n)

tactic: intros
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
⊢ ∀ (e : C (bit b n) = C (bit b n)), e.mpr (f b n (binaryRec z f n)) = f b n (binaryRec z f n)
state_after: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
e✝ : C (bit b n) = C (bit b n)
⊢ e✝.mpr (f b n (binaryRec z f n)) = f b n (binaryRec z f n)

tactic: rfl
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u_1
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
b : Bool
n : ℕ
h : f false 0 z = z ∨ (n = 0 → b = true)
h' : ¬bit b n = 0
e✝ : C (bit b n) = C (bit b n)
⊢ e✝.mpr (f b n (binaryRec z f n)) = f b n (binaryRec z f n)
state_after: no goals