-- 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₂.inl.intro
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 :
  (Array.foldl clearUnit (f.insertRupUnits units).fst.assignments (f.insertRupUnits units).fst.rupUnits)[↑⟨i, i_lt_n⟩] =
    f.assignments[↑⟨i, i_lt_n⟩]
right✝ :
  ∀ (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⟩
⊢ (Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits)[i] =
    f.assignments[i]

Tactic:
exact h

Result:
no goals

Proof state:
case assignments
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
⊢ { clauses := (f.insertRupUnits units).1.clauses, rupUnits := #[], ratUnits := (f.insertRupUnits units).1.ratUnits,
        assignments :=
          Array.foldl clearUnit (f.insertRupUnits units).1.assignments
            (f.insertRupUnits units).1.rupUnits }.assignments =
    f.assignments

Tactic:
simp only

Result:
case assignments
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
⊢ Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits = f.assignments

Proof state:
case clauses
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
⊢ { clauses := (f.insertRupUnits units).1.clauses, rupUnits := #[], ratUnits := (f.insertRupUnits units).1.ratUnits,
        assignments :=
          Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits }.clauses =
    f.clauses

Tactic:
simp only [insertRupUnits]

Result:
no goals

Proof state:
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
⊢ (f.insertRupUnits units).fst.clearRupUnits = f

Tactic:
simp only [clearRupUnits]

Result:
n : Nat
f : DefaultFormula n
f_readyForRupAdd : f.ReadyForRupAdd
units : CNF.Clause (PosFin n)
⊢ { clauses := (f.insertRupUnits units).1.clauses, rupUnits := #[], ratUnits := (f.insertRupUnits units).1.ratUnits,
      assignments :=
        Array.foldl clearUnit (f.insertRupUnits units).1.assignments (f.insertRupUnits units).1.rupUnits } =
    f