-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/LRAT/Internal/Formula/RupAddResult.lean
theorem clear_insertRup {n : Nat} (f : DefaultFormula n) (f_readyForRupAdd : ReadyForRupAdd f)
    (units : CNF.Clause (PosFin n)) :
    clearRupUnits (f.insertRupUnits units).1 = f

Proof state:
case assignments.intro.h₂
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
motive : Nat → Array Assignment → Prop := f.ClearInsertInductionMotive ⋯ (f.insertRupUnits units).fst.rupUnits
h_base : motive 0 (f.insertRupUnits units).fst.assignments
h_inductive :
  ∀ (idx : Fin (f.insertRupUnits units).fst.rupUnits.size) (assignments : Array Assignment),
    motive (↑idx) assignments → motive (↑idx + 1) (clearUnit assignments (f.insertRupUnits units).fst.rupUnits[idx])
h_size : (Array.foldl clearUnit (f.insertRupUnits units).fst.assignments (f.insertRupUnits units).fst.rupUnits).size = n
h :
  ∀ (i : Fin n),
    let_fun i_lt_assignments_size := ⋯;
    let_fun i_lt_f_assignments_size := ⋯;
    let assignments_i :=
      (Array.foldl clearUnit (f.insertRupUnits units).fst.assignments (f.insertRupUnits units).fst.rupUnits)[↑i];
    let fassignments_i := f.assignments[↑i];
    (assignments_i = fassignments_i ∧
        ∀ (j : Fin (f.insertRupUnits units).fst.rupUnits.size),
          ↑j ≥ (f.insertRupUnits units).fst.rupUnits.size → (f.insertRupUnits units).fst.rupUnits[j].fst.val ≠ ↑i) ∨
      (∃ j b i_gt_zero,
          ↑j ≥ (f.insertRupUnits units).fst.rupUnits.size ∧
            (f.insertRupUnits units).fst.rupUnits[j] = (⟨↑i, ⋯⟩, b) ∧
              assignments_i = addAssignment b fassignments_i ∧
                ¬hasAssignment b fassignments_i = true ∧
                  ∀ (k : Fin (f.insertRupUnits units).fst.rupUnits.size),
                    ↑k ≥ (f.insertRupUnits units).fst.rupUnits.size →
                      k ≠ j → (f.insertRupUnits units).fst.rupUnits[k].fst.val ≠ ↑i) ∨
        ∃ j1 j2 i_gt_zero,
          ↑j1 ≥ (f.insertRupUnits units).fst.rupUnits.size ∧
            ↑j2 ≥ (f.insertRupUnits units).fst.rupUnits.size ∧
              (f.insertRupUnits units).fst.rupUnits[j1] = (⟨↑i, ⋯⟩, true) ∧
                (f.insertRupUnits units).fst.rupUnits[j2] = (⟨↑i, ⋯⟩, false) ∧
                  assignments_i = both ∧
                    fassignments_i = unassigned ∧
                      ∀ (k : Fin (f.insertRupUnits units).fst.rupUnits.size),
                        ↑k ≥ (f.insertRupUnits units).fst.rupUnits.size →
                          k ≠ j1 → k ≠ j2 → (f.insertRupUnits units).fst.rupUnits[k].fst.val ≠ ↑i
i : Nat
hi1 : i < (Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits).size
hi2 : i < f.assignments.size
i_lt_n : i < n
⊢ (Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits)[i] =
    f.assignments[i]

Tactic:
specialize h ⟨i, i_lt_n⟩

Result:
case assignments.intro.h₂
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
motive : Nat → Array Assignment → Prop := f.ClearInsertInductionMotive ⋯ (f.insertRupUnits units).fst.rupUnits
h_base : motive 0 (f.insertRupUnits units).fst.assignments
h_inductive :
  ∀ (idx : Fin (f.insertRupUnits units).fst.rupUnits.size) (assignments : Array Assignment),
    motive (↑idx) assignments → motive (↑idx + 1) (clearUnit assignments (f.insertRupUnits units).fst.rupUnits[idx])
h_size : (Array.foldl clearUnit (f.insertRupUnits units).fst.assignments (f.insertRupUnits units).fst.rupUnits).size = n
i : Nat
hi1 : i < (Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits).size
hi2 : i < f.assignments.size
i_lt_n : i < n
h :
  let_fun i_lt_assignments_size := ⋯;
  let_fun i_lt_f_assignments_size := ⋯;
  let assignments_i :=
    (Array.foldl clearUnit (f.insertRupUnits units).fst.assignments
        (f.insertRupUnits units).fst.rupUnits)[↑⟨i, i_lt_n⟩];
  let fassignments_i := f.assignments[↑⟨i, i_lt_n⟩];
  (assignments_i = fassignments_i ∧
      ∀ (j : Fin (f.insertRupUnits units).fst.rupUnits.size),
        ↑j ≥ (f.insertRupUnits units).fst.rupUnits.size →
          (f.insertRupUnits units).fst.rupUnits[j].fst.val ≠ ↑⟨i, i_lt_n⟩) ∨
    (∃ j b i_gt_zero,
        ↑j ≥ (f.insertRupUnits units).fst.rupUnits.size ∧
          (f.insertRupUnits units).fst.rupUnits[j] = (⟨↑⟨i, i_lt_n⟩, ⋯⟩, b) ∧
            assignments_i = addAssignment b fassignments_i ∧
              ¬hasAssignment b fassignments_i = true ∧
                ∀ (k : Fin (f.insertRupUnits units).fst.rupUnits.size),
                  ↑k ≥ (f.insertRupUnits units).fst.rupUnits.size →
                    k ≠ j → (f.insertRupUnits units).fst.rupUnits[k].fst.val ≠ ↑⟨i, i_lt_n⟩) ∨
      ∃ j1 j2 i_gt_zero,
        ↑j1 ≥ (f.insertRupUnits units).fst.rupUnits.size ∧
          ↑j2 ≥ (f.insertRupUnits units).fst.rupUnits.size ∧
            (f.insertRupUnits units).fst.rupUnits[j1] = (⟨↑⟨i, i_lt_n⟩, ⋯⟩, true) ∧
              (f.insertRupUnits units).fst.rupUnits[j2] = (⟨↑⟨i, i_lt_n⟩, ⋯⟩, false) ∧
                assignments_i = both ∧
                  fassignments_i = unassigned ∧
                    ∀ (k : Fin (f.insertRupUnits units).fst.rupUnits.size),
                      ↑k ≥ (f.insertRupUnits units).fst.rupUnits.size →
                        k ≠ j1 → k ≠ j2 → (f.insertRupUnits units).fst.rupUnits[k].fst.val ≠ ↑⟨i, i_lt_n⟩
⊢ (Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits)[i] =
    f.assignments[i]

Proof state:
case assignments
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
motive : Nat → Array Assignment → Prop := f.ClearInsertInductionMotive ⋯ (f.insertRupUnits units).fst.rupUnits
⊢ Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits = f.assignments

Tactic:
have h_base : motive 0 (insertRupUnits f units).1.assignments := clear_insertRup_base_case f f_readyForRupAdd units

Result:
case assignments
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
motive : Nat → Array Assignment → Prop := f.ClearInsertInductionMotive ⋯ (f.insertRupUnits units).fst.rupUnits
h_base : motive 0 (f.insertRupUnits units).fst.assignments
⊢ Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits = f.assignments