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

tactic: rw [binaryRec]
state_before: m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
⊢ binaryRec z f (bit b n) = f b n (binaryRec z f n)
state_after: m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
⊢ (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
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
⊢ (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
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
⊢ ⋯.mpr z = f b n (binaryRec z f n)

case neg
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
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: generalize binaryRec z f (bit b n) = e
state_before: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
⊢ ⋯.mpr z = f b n (binaryRec z f n)
state_after: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
e : C (bit b n)
⊢ ⋯.mpr z = f b n (binaryRec z f n)

tactic: revert e
state_before: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
e : C (bit b n)
⊢ ⋯.mpr z = f b n (binaryRec z f n)
state_after: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)

tactic: have bf := bodd_bit b n
state_before: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)
state_after: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
bf : (bit b n).bodd = b
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)

tactic: have n0 := div2_bit b n
state_before: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
bf : (bit b n).bodd = b
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)
state_after: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
bf : (bit b n).bodd = b
n0 : (bit b n).div2 = n
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)

tactic: rw [h'] at bf n0
state_before: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
bf : (bit b n).bodd = b
n0 : (bit b n).div2 = n
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)
state_after: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
bf : bodd 0 = b
n0 : div2 0 = n
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)

tactic: simp only [bodd_zero, div2_zero] at bf n0
state_before: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
bf : bodd 0 = b
n0 : div2 0 = n
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)
state_after: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
bf : false = b
n0 : 0 = n
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)

tactic: subst bf n0
state_before: case pos
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : bit b n = 0
bf : false = b
n0 : 0 = n
⊢ C (bit b n) → ⋯.mpr z = f b n (binaryRec z f n)
state_after: case pos
m n : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
h' : bit false 0 = 0
⊢ C (bit false 0) → ⋯.mpr z = f false 0 (binaryRec z f 0)

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

tactic: intros
state_before: case pos
m n : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
h' : bit false 0 = 0
⊢ C (bit false 0) → ⋯.mpr z = f false 0 z
state_after: case pos
m n : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
h' : bit false 0 = 0
e✝ : C (bit false 0)
⊢ ⋯.mpr z = f false 0 z

tactic: rw [h, eq_mpr_eq_cast, cast_eq]
state_before: case pos
m n : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
h' : bit false 0 = 0
e✝ : C (bit false 0)
⊢ ⋯.mpr z = f false 0 z
state_after: no goals

tactic: simp only
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
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
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
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 h
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
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
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h✝ : f false 0 z = z
b : Bool
n : ℕ
h' : ¬bit b n = 0
h : C (bit b n) = C (bit (bit b n).bodd (bit b n).div2)
⊢ h.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 h
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h✝ : f false 0 z = z
b : Bool
n : ℕ
h' : ¬bit b n = 0
h : C (bit b n) = C (bit (bit b n).bodd (bit b n).div2)
⊢ h.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
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : ¬bit b n = 0
⊢ ∀ (h : C (bit b n) = C (bit (bit b n).bodd (bit b n).div2)),
    h.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
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : ¬bit b n = 0
⊢ ∀ (h : C (bit b n) = C (bit (bit b n).bodd (bit b n).div2)),
    h.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
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : ¬bit b n = 0
⊢ ∀ (h : C (bit b n) = C (bit b n)), h.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
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : ¬bit b n = 0
⊢ ∀ (h : C (bit b n) = C (bit b n)), h.mpr (f b n (binaryRec z f n)) = f b n (binaryRec z f n)
state_after: case neg
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : ¬bit b n = 0
h✝ : C (bit b n) = C (bit b n)
⊢ h✝.mpr (f b n (binaryRec z f n)) = f b n (binaryRec z f n)

tactic: simp only [eq_mpr_eq_cast, cast_eq]
state_before: case neg
m n✝ : ℕ
C : ℕ → Sort u
z : C 0
f : (b : Bool) → (n : ℕ) → C n → C (bit b n)
h : f false 0 z = z
b : Bool
n : ℕ
h' : ¬bit b n = 0
h✝ : C (bit b n) = C (bit b n)
⊢ h✝.mpr (f b n (binaryRec z f n)) = f b n (binaryRec z f n)
state_after: no goals