l3lab/ntp-mathlib huggingface dataset:
/-- The ith bit is the ith element of `n.bits`. -/
theorem testBit_eq_inth (n i : ℕ) : n.testBit i = n.bits.getI i := by
  induction' i with i ih generalizing n
  · simp only [testBit, zero_eq, shiftRight_zero, and_one_is_mod, mod_two_of_bodd,
      bodd_eq_bits_head, List.getI_zero_eq_headI]
    cases List.headI (bits n) <;> rfl
  conv_lhs => rw [← bit_decomp n]
  rw [testBit_succ, ih n.div2, div2_bits_eq_tail]
  

Proof state:
case succ
i : ℕ
ih : ∀ (n : ℕ), testBit n i = List.getI (bits n) i
n : ℕ
⊢ List.getI (List.tail (bits n)) i = List.getI (bits n) (succ i)

Next tactic:
cases n.bits
/-- The ith bit is the ith element of `n.bits`. -/
theorem testBit_eq_inth (n i : ℕ) : n.testBit i = n.bits.getI i := by
  induction' i with i ih generalizing n
  · simp only [testBit, zero_eq, shiftRight_zero, and_one_is_mod, mod_two_of_bodd,
      bodd_eq_bits_head, List.getI_zero_eq_headI]
    cases List.headI (bits n) <;> rfl
  conv_lhs => rw [← bit_decomp n]
  rw [testBit_succ, ih n.div2, div2_bits_eq_tail]
  cases n.bits <;> 

Proof state:
case succ.nil
i : ℕ
ih : ∀ (n : ℕ), testBit n i = List.getI (bits n) i
n : ℕ
⊢ List.getI (List.tail []) i = List.getI [] (succ i)

Next tactic:
simp
/-- The ith bit is the ith element of `n.bits`. -/
theorem testBit_eq_inth (n i : ℕ) : n.testBit i = n.bits.getI i := by
  induction' i with i ih generalizing n
  · simp only [testBit, zero_eq, shiftRight_zero, and_one_is_mod, mod_two_of_bodd,
      bodd_eq_bits_head, List.getI_zero_eq_headI]
    cases List.headI (bits n) <;> rfl
  conv_lhs => rw [← bit_decomp n]
  rw [testBit_succ, ih n.div2, div2_bits_eq_tail]
  cases n.bits <;> 

Proof state:
case succ.cons
i : ℕ
ih : ∀ (n : ℕ), testBit n i = List.getI (bits n) i
n : ℕ
head✝ : Bool
tail✝ : List Bool
⊢ List.getI (List.tail (head✝ :: tail✝)) i = List.getI (head✝ :: tail✝) (succ i)

Next tactic:
simp
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  

Proof state:
n : ℕ
h : n ≠ 0
⊢ ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false

Next tactic:
induction' n using Nat.binaryRec with b n hn
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · 

Proof state:
case z
h : 0 ≠ 0
⊢ ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false

Next tactic:
exact False.elim (h rfl)
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  

Proof state:
case f
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
⊢ ∃ i, testBit (bit b n) i = true ∧ ∀ (j : ℕ), i < j → testBit (bit b n) j = false

Next tactic:
by_cases h' : n = 0
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · 

Proof state:
case pos
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : n = 0
⊢ ∃ i, testBit (bit b n) i = true ∧ ∀ (j : ℕ), i < j → testBit (bit b n) j = false

Next tactic:
subst h'
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    

Proof state:
case pos
b : Bool
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
h : bit b 0 ≠ 0
⊢ ∃ i, testBit (bit b 0) i = true ∧ ∀ (j : ℕ), i < j → testBit (bit b 0) j = false

Next tactic:
rw [show b = true by
        revert h
        cases b <;> simp]
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        

Proof state:
b : Bool
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
h : bit b 0 ≠ 0
⊢ b = true

Next tactic:
revert h
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        

Proof state:
b : Bool
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
⊢ bit b 0 ≠ 0 → b = true

Next tactic:
cases b
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> 

Proof state:
case false
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
⊢ bit false 0 ≠ 0 → false = true

Next tactic:
simp
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> 

Proof state:
case true
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
⊢ bit true 0 ≠ 0 → true = true

Next tactic:
simp
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    

Proof state:
case pos
b : Bool
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
h : bit b 0 ≠ 0
⊢ ∃ i, testBit (bit true 0) i = true ∧ ∀ (j : ℕ), i < j → testBit (bit true 0) j = false

Next tactic:
refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by 

Proof state:
b : Bool
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
h : bit b 0 ≠ 0
⊢ testBit (bit true 0) 0 = true

Next tactic:
rw [testBit_zero]
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    

Proof state:
case pos
b : Bool
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
h : bit b 0 ≠ 0
j : ℕ
hj : 0 < j
⊢ testBit (bit true 0) j = false

Next tactic:
obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    

Proof state:
case pos.intro
b : Bool
hn : 0 ≠ 0 → ∃ i, testBit 0 i = true ∧ ∀ (j : ℕ), i < j → testBit 0 j = false
h : bit b 0 ≠ 0
j' : ℕ
hj : 0 < succ j'
⊢ testBit (bit true 0) (succ j') = false

Next tactic:
rw [testBit_succ, zero_testBit]
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    rw [testBit_succ, zero_testBit]
  · 

Proof state:
case neg
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : ¬n = 0
⊢ ∃ i, testBit (bit b n) i = true ∧ ∀ (j : ℕ), i < j → testBit (bit b n) j = false

Next tactic:
obtain ⟨k, ⟨hk, hk'⟩⟩ := hn h'
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    rw [testBit_succ, zero_testBit]
  · obtain ⟨k, ⟨hk, hk'⟩⟩ := hn h'
    

Proof state:
case neg.intro.intro
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : ¬n = 0
k : ℕ
hk : testBit n k = true
hk' : ∀ (j : ℕ), k < j → testBit n j = false
⊢ ∃ i, testBit (bit b n) i = true ∧ ∀ (j : ℕ), i < j → testBit (bit b n) j = false

Next tactic:
refine' ⟨k + 1, ⟨by rw [testBit_succ, hk], fun j hj => _⟩⟩
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    rw [testBit_succ, zero_testBit]
  · obtain ⟨k, ⟨hk, hk'⟩⟩ := hn h'
    refine' ⟨k + 1, ⟨by 

Proof state:
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : ¬n = 0
k : ℕ
hk : testBit n k = true
hk' : ∀ (j : ℕ), k < j → testBit n j = false
⊢ testBit (bit b n) (k + 1) = true

Next tactic:
rw [testBit_succ, hk]
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    rw [testBit_succ, zero_testBit]
  · obtain ⟨k, ⟨hk, hk'⟩⟩ := hn h'
    refine' ⟨k + 1, ⟨by rw [testBit_succ, hk], fun j hj => _⟩⟩
    

Proof state:
case neg.intro.intro
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : ¬n = 0
k : ℕ
hk : testBit n k = true
hk' : ∀ (j : ℕ), k < j → testBit n j = false
j : ℕ
hj : k + 1 < j
⊢ testBit (bit b n) j = false

Next tactic:
obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (show j ≠ 0 by intro x; subst x; simp at hj)
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    rw [testBit_succ, zero_testBit]
  · obtain ⟨k, ⟨hk, hk'⟩⟩ := hn h'
    refine' ⟨k + 1, ⟨by rw [testBit_succ, hk], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (show j ≠ 0 by 

Proof state:
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : ¬n = 0
k : ℕ
hk : testBit n k = true
hk' : ∀ (j : ℕ), k < j → testBit n j = false
j : ℕ
hj : k + 1 < j
⊢ j ≠ 0

Next tactic:
intro x
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    rw [testBit_succ, zero_testBit]
  · obtain ⟨k, ⟨hk, hk'⟩⟩ := hn h'
    refine' ⟨k + 1, ⟨by rw [testBit_succ, hk], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (show j ≠ 0 by intro x; 

Proof state:
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : ¬n = 0
k : ℕ
hk : testBit n k = true
hk' : ∀ (j : ℕ), k < j → testBit n j = false
j : ℕ
hj : k + 1 < j
x : j = 0
⊢ False

Next tactic:
subst x
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    rw [testBit_succ, zero_testBit]
  · obtain ⟨k, ⟨hk, hk'⟩⟩ := hn h'
    refine' ⟨k + 1, ⟨by rw [testBit_succ, hk], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (show j ≠ 0 by intro x; subst x; 

Proof state:
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : ¬n = 0
k : ℕ
hk : testBit n k = true
hk' : ∀ (j : ℕ), k < j → testBit n j = false
hj : k + 1 < 0
⊢ False

Next tactic:
simp at hj
theorem exists_most_significant_bit {n : ℕ} (h : n ≠ 0) :
    ∃ i, testBit n i = true ∧ ∀ j, i < j → testBit n j = false := by
  induction' n using Nat.binaryRec with b n hn
  · exact False.elim (h rfl)
  by_cases h' : n = 0
  · subst h'
    rw [show b = true by
        revert h
        cases b <;> simp]
    refine' ⟨0, ⟨by rw [testBit_zero], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (ne_of_gt hj)
    rw [testBit_succ, zero_testBit]
  · obtain ⟨k, ⟨hk, hk'⟩⟩ := hn h'
    refine' ⟨k + 1, ⟨by rw [testBit_succ, hk], fun j hj => _⟩⟩
    obtain ⟨j', rfl⟩ := exists_eq_succ_of_ne_zero (show j ≠ 0 by intro x; subst x; simp at hj)
    

Proof state:
case neg.intro.intro.intro
b : Bool
n : ℕ
hn : n ≠ 0 → ∃ i, testBit n i = true ∧ ∀ (j : ℕ), i < j → testBit n j = false
h : bit b n ≠ 0
h' : ¬n = 0
k : ℕ
hk : testBit n k = true
hk' : ∀ (j : ℕ), k < j → testBit n j = false
j' : ℕ
hj : k + 1 < succ j'
⊢ testBit (bit b n) (succ j') = false

Next tactic:
exact (testBit_succ _ _ _).trans (hk' _ (lt_of_succ_lt_succ hj))
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  

Proof state:
n m i : ℕ
hn : testBit n i = false
hm : testBit m i = true
hnm : ∀ (j : ℕ), i < j → testBit n j = testBit m j
⊢ n < m

Next tactic:
induction' n using Nat.binaryRec with b n hn' generalizing i m
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · 

Proof state:
case z
m i : ℕ
hn : testBit 0 i = false
hm : testBit m i = true
hnm : ∀ (j : ℕ), i < j → testBit 0 j = testBit m j
⊢ 0 < m

Next tactic:
contrapose! hm
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    

Proof state:
case z
m i : ℕ
hn : testBit 0 i = false
hnm : ∀ (j : ℕ), i < j → testBit 0 j = testBit m j
hm : m ≤ 0
⊢ testBit m i ≠ true

Next tactic:
rw [le_zero_iff] at hm
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    

Proof state:
case z
m i : ℕ
hn : testBit 0 i = false
hnm : ∀ (j : ℕ), i < j → testBit 0 j = testBit m j
hm : m = 0
⊢ testBit m i ≠ true

Next tactic:
simp [hm]
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    simp [hm]
  

Proof state:
case f
b : Bool
n : ℕ
hn' :
  ∀ {m : ℕ} (i : ℕ), testBit n i = false → testBit m i = true → (∀ (j : ℕ), i < j → testBit n j = testBit m j) → n < m
m i : ℕ
hn : testBit (bit b n) i = false
hm : testBit m i = true
hnm : ∀ (j : ℕ), i < j → testBit (bit b n) j = testBit m j
⊢ bit b n < m

Next tactic:
induction' m using Nat.binaryRec with b' m hm' generalizing i
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    simp [hm]
  induction' m using Nat.binaryRec with b' m hm' generalizing i
  · 

Proof state:
case f.z
b : Bool
n : ℕ
hn' :
  ∀ {m : ℕ} (i : ℕ), testBit n i = false → testBit m i = true → (∀ (j : ℕ), i < j → testBit n j = testBit m j) → n < m
i : ℕ
hn : testBit (bit b n) i = false
hm : testBit 0 i = true
hnm : ∀ (j : ℕ), i < j → testBit (bit b n) j = testBit 0 j
⊢ bit b n < 0

Next tactic:
exact False.elim (Bool.false_ne_true ((zero_testBit i).symm.trans hm))
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    simp [hm]
  induction' m using Nat.binaryRec with b' m hm' generalizing i
  · exact False.elim (Bool.false_ne_true ((zero_testBit i).symm.trans hm))
  

Proof state:
case f.f
b : Bool
n : ℕ
hn' :
  ∀ {m : ℕ} (i : ℕ), testBit n i = false → testBit m i = true → (∀ (j : ℕ), i < j → testBit n j = testBit m j) → n < m
b' : Bool
m : ℕ
hm' :
  ∀ (i : ℕ),
    testBit (bit b n) i = false →
      testBit m i = true → (∀ (j : ℕ), i < j → testBit (bit b n) j = testBit m j) → bit b n < m
i : ℕ
hn : testBit (bit b n) i = false
hm : testBit (bit b' m) i = true
hnm : ∀ (j : ℕ), i < j → testBit (bit b n) j = testBit (bit b' m) j
⊢ bit b n < bit b' m

Next tactic:
by_cases hi : i = 0
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    simp [hm]
  induction' m using Nat.binaryRec with b' m hm' generalizing i
  · exact False.elim (Bool.false_ne_true ((zero_testBit i).symm.trans hm))
  by_cases hi : i = 0
  · 

Proof state:
case pos
b : Bool
n : ℕ
hn' :
  ∀ {m : ℕ} (i : ℕ), testBit n i = false → testBit m i = true → (∀ (j : ℕ), i < j → testBit n j = testBit m j) → n < m
b' : Bool
m : ℕ
hm' :
  ∀ (i : ℕ),
    testBit (bit b n) i = false →
      testBit m i = true → (∀ (j : ℕ), i < j → testBit (bit b n) j = testBit m j) → bit b n < m
i : ℕ
hn : testBit (bit b n) i = false
hm : testBit (bit b' m) i = true
hnm : ∀ (j : ℕ), i < j → testBit (bit b n) j = testBit (bit b' m) j
hi : i = 0
⊢ bit b n < bit b' m

Next tactic:
subst hi
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    simp [hm]
  induction' m using Nat.binaryRec with b' m hm' generalizing i
  · exact False.elim (Bool.false_ne_true ((zero_testBit i).symm.trans hm))
  by_cases hi : i = 0
  · subst hi
    

Proof state:
case pos
b : Bool
n : ℕ
hn' :
  ∀ {m : ℕ} (i : ℕ), testBit n i = false → testBit m i = true → (∀ (j : ℕ), i < j → testBit n j = testBit m j) → n < m
b' : Bool
m : ℕ
hm' :
  ∀ (i : ℕ),
    testBit (bit b n) i = false →
      testBit m i = true → (∀ (j : ℕ), i < j → testBit (bit b n) j = testBit m j) → bit b n < m
hn : testBit (bit b n) 0 = false
hm : testBit (bit b' m) 0 = true
hnm : ∀ (j : ℕ), 0 < j → testBit (bit b n) j = testBit (bit b' m) j
⊢ bit b n < bit b' m

Next tactic:
simp only [testBit_zero] at hn hm
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    simp [hm]
  induction' m using Nat.binaryRec with b' m hm' generalizing i
  · exact False.elim (Bool.false_ne_true ((zero_testBit i).symm.trans hm))
  by_cases hi : i = 0
  · subst hi
    simp only [testBit_zero] at hn hm
    

Proof state:
case pos
b : Bool
n : ℕ
hn' :
  ∀ {m : ℕ} (i : ℕ), testBit n i = false → testBit m i = true → (∀ (j : ℕ), i < j → testBit n j = testBit m j) → n < m
b' : Bool
m : ℕ
hm' :
  ∀ (i : ℕ),
    testBit (bit b n) i = false →
      testBit m i = true → (∀ (j : ℕ), i < j → testBit (bit b n) j = testBit m j) → bit b n < m
hnm : ∀ (j : ℕ), 0 < j → testBit (bit b n) j = testBit (bit b' m) j
hn : b = false
hm : b' = true
⊢ bit b n < bit b' m

Next tactic:
have : n = m :=
      eq_of_testBit_eq fun i => by convert hnm (i + 1) (Nat.zero_lt_succ _) using 1
      <;> rw [testBit_succ]
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    simp [hm]
  induction' m using Nat.binaryRec with b' m hm' generalizing i
  · exact False.elim (Bool.false_ne_true ((zero_testBit i).symm.trans hm))
  by_cases hi : i = 0
  · subst hi
    simp only [testBit_zero] at hn hm
    have : n = m :=
      eq_of_testBit_eq fun i => by 

Proof state:
b : Bool
n : ℕ
hn' :
  ∀ {m : ℕ} (i : ℕ), testBit n i = false → testBit m i = true → (∀ (j : ℕ), i < j → testBit n j = testBit m j) → n < m
b' : Bool
m : ℕ
hm' :
  ∀ (i : ℕ),
    testBit (bit b n) i = false →
      testBit m i = true → (∀ (j : ℕ), i < j → testBit (bit b n) j = testBit m j) → bit b n < m
hnm : ∀ (j : ℕ), 0 < j → testBit (bit b n) j = testBit (bit b' m) j
hn : b = false
hm : b' = true
i : ℕ
⊢ testBit n i = testBit m i

Next tactic:
convert hnm (i + 1) (Nat.zero_lt_succ _) using 1
theorem lt_of_testBit {n m : ℕ} (i : ℕ) (hn : testBit n i = false) (hm : testBit m i = true)
    (hnm : ∀ j, i < j → testBit n j = testBit m j) : n < m := by
  induction' n using Nat.binaryRec with b n hn' generalizing i m
  · contrapose! hm
    rw [le_zero_iff] at hm
    simp [hm]
  induction' m using Nat.binaryRec with b' m hm' generalizing i
  · exact False.elim (Bool.false_ne_true ((zero_testBit i).symm.trans hm))
  by_cases hi : i = 0
  · subst hi
    simp only [testBit_zero] at hn hm
    have : n = m :=
      eq_of_testBit_eq fun i => by convert hnm (i + 1) (Nat.zero_lt_succ _) using 1
      <;> 

Proof state:
case h.e'_2
b : Bool
n : ℕ
hn' :
  ∀ {m : ℕ} (i : ℕ), testBit n i = false → testBit m i = true → (∀ (j : ℕ), i < j → testBit n j = testBit m j) → n < m
b' : Bool
m : ℕ
hm' :
  ∀ (i : ℕ),
    testBit (bit b n) i = false →
      testBit m i = true → (∀ (j : ℕ), i < j → testBit (bit b n) j = testBit m j) → bit b n < m
hnm : ∀ (j : ℕ), 0 < j → testBit (bit b n) j = testBit (bit b' m) j
hn : b = false
hm : b' = true
i : ℕ
⊢ testBit n i = testBit (bit b n) (i + 1)

Next tactic:
rw [testBit_succ]