-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/LRAT/Internal/Formula/RatAddResult.lean
theorem clear_insertRat {n : Nat} (f : DefaultFormula n)
    (hf : f.ratUnits = #[] ∧ f.assignments.size = n) (units : CNF.Clause (PosFin n)) :
    clearRatUnits (f.insertRatUnits units).1 = f

Proof state:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
⊢ { clauses := (f.insertRatUnits units).1.clauses, rupUnits := (f.insertRatUnits units).1.rupUnits, ratUnits := #[],
      assignments :=
        Array.foldl clearUnit (f.insertRatUnits units).1.assignments (f.insertRatUnits units).1.ratUnits } =
    f

Tactic:
ext : 1

Result:
case clauses
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
⊢ { clauses := (f.insertRatUnits units).1.clauses, rupUnits := (f.insertRatUnits units).1.rupUnits, ratUnits := #[],
        assignments :=
          Array.foldl clearUnit (f.insertRatUnits units).1.assignments (f.insertRatUnits units).1.ratUnits }.clauses =
    f.clauses

case rupUnits
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
⊢ { clauses := (f.insertRatUnits units).1.clauses, rupUnits := (f.insertRatUnits units).1.rupUnits, ratUnits := #[],
        assignments :=
          Array.foldl clearUnit (f.insertRatUnits units).1.assignments (f.insertRatUnits units).1.ratUnits }.rupUnits =
    f.rupUnits

case ratUnits
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
⊢ { clauses := (f.insertRatUnits units).1.clauses, rupUnits := (f.insertRatUnits units).1.rupUnits, ratUnits := #[],
        assignments :=
          Array.foldl clearUnit (f.insertRatUnits units).1.assignments (f.insertRatUnits units).1.ratUnits }.ratUnits =
    f.ratUnits

case assignments
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
⊢ { clauses := (f.insertRatUnits units).1.clauses, rupUnits := (f.insertRatUnits units).1.rupUnits, ratUnits := #[],
        assignments :=
          Array.foldl clearUnit (f.insertRatUnits units).1.assignments
            (f.insertRatUnits units).1.ratUnits }.assignments =
    f.assignments

Proof state:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
motive : Nat → Array Assignment → Prop := f.ClearInsertInductionMotive ⋯ (f.insertRatUnits units).fst.ratUnits
h_base : motive 0 (f.insertRatUnits units).fst.assignments
h_inductive :
  ∀ (idx : Fin (f.insertRatUnits units).fst.ratUnits.size) (assignments : Array Assignment),
    motive (↑idx) assignments → motive (↑idx + 1) (clearUnit assignments (f.insertRatUnits units).fst.ratUnits[idx])
h_size : (Array.foldl clearUnit (f.insertRatUnits units).fst.assignments (f.insertRatUnits units).fst.ratUnits).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.insertRatUnits units).fst.assignments (f.insertRatUnits units).fst.ratUnits)[↑i];
    let fassignments_i := f.assignments[↑i];
    (assignments_i = fassignments_i ∧
        ∀ (j : Fin (f.insertRatUnits units).fst.ratUnits.size),
          ↑j ≥ (f.insertRatUnits units).fst.ratUnits.size → (f.insertRatUnits units).fst.ratUnits[j].fst.val ≠ ↑i) ∨
      (∃ j b i_gt_zero,
          ↑j ≥ (f.insertRatUnits units).fst.ratUnits.size ∧
            (f.insertRatUnits units).fst.ratUnits[j] = (⟨↑i, ⋯⟩, b) ∧
              assignments_i = addAssignment b fassignments_i ∧
                ¬hasAssignment b fassignments_i = true ∧
                  ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                    ↑k ≥ (f.insertRatUnits units).fst.ratUnits.size →
                      k ≠ j → (f.insertRatUnits units).fst.ratUnits[k].fst.val ≠ ↑i) ∨
        ∃ j1 j2 i_gt_zero,
          ↑j1 ≥ (f.insertRatUnits units).fst.ratUnits.size ∧
            ↑j2 ≥ (f.insertRatUnits units).fst.ratUnits.size ∧
              (f.insertRatUnits units).fst.ratUnits[j1] = (⟨↑i, ⋯⟩, true) ∧
                (f.insertRatUnits units).fst.ratUnits[j2] = (⟨↑i, ⋯⟩, false) ∧
                  assignments_i = both ∧
                    fassignments_i = unassigned ∧
                      ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                        ↑k ≥ (f.insertRatUnits units).fst.ratUnits.size →
                          k ≠ j1 → k ≠ j2 → (f.insertRatUnits units).fst.ratUnits[k].fst.val ≠ ↑i
i : Nat
hi1 : i < (Array.foldl clearUnit (f.insertRatUnits units).1.assignments (f.insertRatUnits units).1.ratUnits).size
hi2 : i < f.assignments.size
⊢ i < n

Tactic:
omega

Result:
no goals