Theorem: Nat.eq_of_testBit_eq
File: Mathlib/Data/Nat/Bitwise.lean

tactic: induction' n using Nat.binaryRec with b n hn generalizing m
state_before: n m : ℕ
h : ∀ (i : ℕ), testBit n i = testBit m i
⊢ n = m

tactic: induction' m using Nat.binaryRec with b' m
state_before: case f
n✝ m✝ : ℕ
h✝ : ∀ (i : ℕ), testBit n✝ i = testBit m✝ i
b : Bool
n : ℕ
hn : ∀ {m : ℕ}, (∀ (i : ℕ), testBit n i = testBit m i) → n = m
m : ℕ
h : ∀ (i : ℕ), testBit (bit b n) i = testBit m i
⊢ bit b n = m

tactic: suffices h' : n = m
state_before: case f.f
n✝ m✝¹ : ℕ
h✝¹ : ∀ (i : ℕ), testBit n✝ i = testBit m✝¹ i
b : Bool
n : ℕ
hn : ∀ {m : ℕ}, (∀ (i : ℕ), testBit n i = testBit m i) → n = m
m✝ : ℕ
h✝ : ∀ (i : ℕ), testBit (bit b n) i = testBit m✝ i
b' : Bool
m : ℕ
a✝ : (∀ (i : ℕ), testBit (bit b n) i = testBit m i) → bit b n = m
h : ∀ (i : ℕ), testBit (bit b n) i = testBit (bit b' m) i
⊢ bit b n = bit b' m

tactic: exact hn fun i => by convert h (i + 1) using 1 <;> rw [testBit_succ]
state_before: case h'
n✝ m✝¹ : ℕ
h✝¹ : ∀ (i : ℕ), testBit n✝ i = testBit m✝¹ i
b : Bool
n : ℕ
hn : ∀ {m : ℕ}, (∀ (i : ℕ), testBit n i = testBit m i) → n = m
m✝ : ℕ
h✝ : ∀ (i : ℕ), testBit (bit b n) i = testBit m✝ i
b' : Bool
m : ℕ
a✝ : (∀ (i : ℕ), testBit (bit b n) i = testBit m i) → bit b n = m
h : ∀ (i : ℕ), testBit (bit b n) i = testBit (bit b' m) i
⊢ n = m

tactic: simp only [zero_testBit] at h
state_before: case z
n m✝ : ℕ
h✝ : ∀ (i : ℕ), testBit n i = testBit m✝ i
m : ℕ
h : ∀ (i : ℕ), testBit 0 i = testBit m i
⊢ 0 = m

tactic: exact (zero_of_testBit_eq_false fun i => (h i).symm).symm
state_before: case z
n m✝ : ℕ
h✝ : ∀ (i : ℕ), testBit n i = testBit m✝ i
m : ℕ
h : ∀ (i : ℕ), false = testBit m i
⊢ 0 = m

tactic: simp only [zero_testBit] at h
state_before: case f.z
n✝ m✝ : ℕ
h✝¹ : ∀ (i : ℕ), testBit n✝ i = testBit m✝ i
b : Bool
n : ℕ
hn : ∀ {m : ℕ}, (∀ (i : ℕ), testBit n i = testBit m i) → n = m
m : ℕ
h✝ : ∀ (i : ℕ), testBit (bit b n) i = testBit m i
h : ∀ (i : ℕ), testBit (bit b n) i = testBit 0 i
⊢ bit b n = 0

tactic: exact zero_of_testBit_eq_false h
state_before: case f.z
n✝ m✝ : ℕ
h✝¹ : ∀ (i : ℕ), testBit n✝ i = testBit m✝ i
b : Bool
n : ℕ
hn : ∀ {m : ℕ}, (∀ (i : ℕ), testBit n i = testBit m i) → n = m
m : ℕ
h✝ : ∀ (i : ℕ), testBit (bit b n) i = testBit m i
h : ∀ (i : ℕ), testBit (bit b n) i = false
⊢ bit b n = 0

tactic: rw [h', show b = b' by simpa using h 0]
state_before: case f.f
n✝ m✝¹ : ℕ
h✝¹ : ∀ (i : ℕ), testBit n✝ i = testBit m✝¹ i
b : Bool
n : ℕ
hn : ∀ {m : ℕ}, (∀ (i : ℕ), testBit n i = testBit m i) → n = m
m✝ : ℕ
h✝ : ∀ (i : ℕ), testBit (bit b n) i = testBit m✝ i
b' : Bool
m : ℕ
a✝ : (∀ (i : ℕ), testBit (bit b n) i = testBit m i) → bit b n = m
h : ∀ (i : ℕ), testBit (bit b n) i = testBit (bit b' m) i
h' : n = m
⊢ bit b n = bit b' m

tactic: simpa using h 0
state_before: n✝ m✝¹ : ℕ
h✝¹ : ∀ (i : ℕ), testBit n✝ i = testBit m✝¹ i
b : Bool
n : ℕ
hn : ∀ {m : ℕ}, (∀ (i : ℕ), testBit n i = testBit m i) → n = m
m✝ : ℕ
h✝ : ∀ (i : ℕ), testBit (bit b n) i = testBit m✝ i
b' : Bool
m : ℕ
a✝ : (∀ (i : ℕ), testBit (bit b n) i = testBit m i) → bit b n = m
h : ∀ (i : ℕ), testBit (bit b n) i = testBit (bit b' m) i
h' : n = m
⊢ b = b'

tactic: convert h (i + 1) using 1 <;> rw [testBit_succ]
state_before: n✝ m✝¹ : ℕ
h✝¹ : ∀ (i : ℕ), testBit n✝ i = testBit m✝¹ i
b : Bool
n : ℕ
hn : ∀ {m : ℕ}, (∀ (i : ℕ), testBit n i = testBit m i) → n = m
m✝ : ℕ
h✝ : ∀ (i : ℕ), testBit (bit b n) i = testBit m✝ i
b' : Bool
m : ℕ
a✝ : (∀ (i : ℕ), testBit (bit b n) i = testBit m i) → bit b n = m
h : ∀ (i : ℕ), testBit (bit b n) i = testBit (bit b' m) i
i : ℕ
⊢ testBit n i = testBit m i