Theorem: Nat.bitwise'_bit
File: Mathlib/Init/Data/Nat/Bitwise.lean

tactic: unfold bitwise'
state_before: f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
⊢ bitwise' f (bit a m) (bit b n) = bit (f a b) (bitwise' f m n)

tactic: rw [binaryRec_eq, binaryRec_eq]
state_before: f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
⊢ binaryRec (fun n => bif f false true then n else 0)
      (fun a m Ia => binaryRec (bif f true false then bit a m else 0) fun b n x => bit (f a b) (Ia n)) (bit a m)
      (bit b n) =
    bit (f a b)
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif f true false then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m n)

tactic: induction' ftf : f true false
state_before: case h
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
⊢ bit (f a false)
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif f true false then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0) =
    bif f true false then bit a m else 0

tactic: rw [show f a false = false by cases a <;> assumption]
state_before: case h.false
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = false
⊢ bit (f a false)
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif false then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0) =
    bif false then bit a m else 0

case h.true
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = true
⊢ bit (f a false)
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif true then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0) =
    bif true then bit a m else 0

tactic: apply @congr_arg _ _ _ 0 (bit false)
state_before: case h.false
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = false
⊢ bit false
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif false then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0) =
    bif false then bit a m else 0

case h.true
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = true
⊢ bit (f a false)
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif true then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0) =
    bif true then bit a m else 0

tactic: swap
state_before: case h.false
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = false
⊢ binaryRec (fun n => bif f false true then n else 0)
      (fun a m Ia => binaryRec (bif false then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0 =
    0

case h.true
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = true
⊢ bit (f a false)
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif true then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0) =
    bif true then bit a m else 0

tactic: rw [show f a false = a by cases a <;> assumption]
state_before: case h.true
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = true
⊢ bit (f a false)
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif true then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0) =
    bif true then bit a m else 0

case h.false
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = false
⊢ binaryRec (fun n => bif f false true then n else 0)
      (fun a m Ia => binaryRec (bif false then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0 =
    0

tactic: apply congr_arg (bit a)
state_before: case h.true
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = true
⊢ bit a
      (binaryRec (fun n => bif f false true then n else 0)
        (fun a m Ia => binaryRec (bif true then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0) =
    bif true then bit a m else 0

case h.false
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = false
⊢ binaryRec (fun n => bif f false true then n else 0)
      (fun a m Ia => binaryRec (bif false then bit a m else 0) fun b n x => bit (f a b) (Ia n)) m 0 =
    0

tactic: cases a <;> assumption
state_before: f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = false
⊢ f a false = false

tactic: cases a <;> assumption
state_before: f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = true
⊢ f a false = a

tactic: rfl
state_before: case h.false
f : Bool → Bool → Bool
h : f false false = false
a✝ : Bool
m✝ : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = false
a : Bool
m : ℕ
⊢ (bif false then bit a m else 0) = 0

tactic: rw [← bitwise'_bit_aux h, ftf]
state_before: case h.false.h
f : Bool → Bool → Bool
h : f false false = false
a✝ : Bool
m✝ : ℕ
b : Bool
n : ℕ
x✝ : Bool
ftf✝ : f true false = x✝
ftf : f true false = false
a : Bool
m : ℕ
⊢ (binaryRec (bif false then bit false 0 else 0) fun b n x => bit (f false b) (bif f false true then n else 0)) =
    fun n => bif f false true then n else 0

tactic: exact bitwise'_bit_aux h
state_before: case h
f : Bool → Bool → Bool
h : f false false = false
a : Bool
m : ℕ
b : Bool
n : ℕ
⊢ (binaryRec (bif f true false then bit false 0 else 0) fun b n x => bit (f false b) (bif f false true then n else 0)) =
    fun n => bif f false true then n else 0