-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/LRAT/Internal/Formula/RupAddResult.lean
theorem confirmRupHint_preserves_invariant_helper {n : Nat} (f : DefaultFormula n)
    (f_assignments_size : f.assignments.size = n)
    (acc : Array Assignment × CNF.Clause (PosFin n) × Bool × Bool) (hsize : acc.1.size = n)
    (l : Literal (PosFin n)) (ih : DerivedLitsInvariant f f_assignments_size acc.1 hsize acc.2.1)
    (h : ¬hasAssignment l.snd acc.fst[l.fst.val]! = true) :
    have hsize' : (Array.modify acc.1 l.1.1 (addAssignment l.snd)).size = n

Proof state:
case right.right.right.left
n : Nat
f : DefaultFormula n
f_assignments_size : f.assignments.size = n
acc : Array Assignment × CNF.Clause (PosFin n) × Bool × Bool
hsize : acc.fst.size = n
l : Literal (PosFin n)
ih : f.DerivedLitsInvariant f_assignments_size acc.fst hsize acc.snd.fst
hsize'✝ : (acc.fst.modify l.fst.val (addAssignment l.snd)).size = n :=
  Eq.mpr (id (congrArg (fun _a => _a = n) (Array.size_modify acc.fst l.fst.val (addAssignment l.snd)))) hsize
i : Fin n
i_in_bounds : ↑i < acc.fst.size
l_in_bounds : l.fst.val < acc.fst.size
j : Fin (List.length acc.snd.fst)
j_eq_i : (List.get acc.snd.fst j).fst.val = ↑i
h1 : acc.fst[↑i] = addAssignment (List.get acc.snd.fst j).snd f.assignments[↑i]
h3 : ∀ (k : Fin (List.length acc.snd.fst)), k ≠ j → (List.get acc.snd.fst k).fst.val ≠ ↑i
l' : Literal (PosFin n) := List.get acc.snd.fst j
zero_in_bounds : 0 < (l :: acc.snd.fst).length
j_succ_in_bounds : ↑j + 1 < (l :: acc.snd.fst).length
l_eq_i : l.fst.val = ↑i
l_ne_l' : true ≠ l'.snd
l_eq_true : l.snd = true
l'_eq_false : (List.get acc.snd.fst j).snd = false
h2 : ¬(if false = true then hasPosAssignment else hasNegAssignment) f.assignments[↑i] = true
h : ¬f.assignments[↑i].hasPosAssignment = true
⊢ f.assignments[↑i] = unassigned

Tactic:
exact unassigned_of_has_neither _ h h2

Result:
no goals

Proof state:
case intro
n : Nat
f : DefaultFormula n
f_assignments_size : f.assignments.size = n
acc : Array Assignment × CNF.Clause (PosFin n) × Bool × Bool
hsize : acc.fst.size = n
l : Literal (PosFin n)
ih : f.DerivedLitsInvariant f_assignments_size acc.fst hsize acc.snd.fst
h : ¬hasAssignment l.snd acc.fst[l.fst.val]! = true
hsize'✝ : (acc.fst.modify l.fst.val (addAssignment l.snd)).size = n :=
  Eq.mpr (id (congrArg (fun _a => _a = n) (Array.size_modify acc.fst l.fst.val (addAssignment l.snd)))) hsize
i : Fin n
i_in_bounds : ↑i < acc.fst.size
l_in_bounds : l.fst.val < acc.fst.size
h1 : acc.fst[↑i] = f.assignments[↑i]
h2 : ∀ (l : Literal (PosFin n)), l ∈ acc.snd.fst → l.fst.val ≠ ↑i
l_eq_i : l.fst.val = ↑i
zero_lt_length_list : 0 < (l :: acc.snd.fst).length
k : Fin (l :: acc.snd.fst).length
k_ne_zero : k ≠ ⟨0, zero_lt_length_list⟩
k_val_ne_zero : ↑k ≠ 0
k' : Nat
k_eq_k'_succ : ↑k = k' + 1
k'_succ_in_bounds : k' + 1 < (l :: acc.snd.fst).length
⊢ ∃ k' k'_succ_in_bounds, k = ⟨k' + 1, k'_succ_in_bounds⟩

Tactic:
apply Exists.intro k' ∘ Exists.intro k'_succ_in_bounds

Result:
case intro
n : Nat
f : DefaultFormula n
f_assignments_size : f.assignments.size = n
acc : Array Assignment × CNF.Clause (PosFin n) × Bool × Bool
hsize : acc.fst.size = n
l : Literal (PosFin n)
ih : f.DerivedLitsInvariant f_assignments_size acc.fst hsize acc.snd.fst
h : ¬hasAssignment l.snd acc.fst[l.fst.val]! = true
hsize'✝ : (acc.fst.modify l.fst.val (addAssignment l.snd)).size = n :=
  Eq.mpr (id (congrArg (fun _a => _a = n) (Array.size_modify acc.fst l.fst.val (addAssignment l.snd)))) hsize
i : Fin n
i_in_bounds : ↑i < acc.fst.size
l_in_bounds : l.fst.val < acc.fst.size
h1 : acc.fst[↑i] = f.assignments[↑i]
h2 : ∀ (l : Literal (PosFin n)), l ∈ acc.snd.fst → l.fst.val ≠ ↑i
l_eq_i : l.fst.val = ↑i
zero_lt_length_list : 0 < (l :: acc.snd.fst).length
k : Fin (l :: acc.snd.fst).length
k_ne_zero : k ≠ ⟨0, zero_lt_length_list⟩
k_val_ne_zero : ↑k ≠ 0
k' : Nat
k_eq_k'_succ : ↑k = k' + 1
k'_succ_in_bounds : k' + 1 < (l :: acc.snd.fst).length
⊢ k = ⟨k' + 1, k'_succ_in_bounds⟩

Proof state:
case inr.inr.intro.intro.intro.intro.intro.intro.intro.intro
n : Nat
f : DefaultFormula n
f_assignments_size : f.assignments.size = n
acc : Array Assignment × CNF.Clause (PosFin n) × Bool × Bool
hsize : acc.fst.size = n
l : Literal (PosFin n)
ih : f.DerivedLitsInvariant f_assignments_size acc.fst hsize acc.snd.fst
h : ¬hasAssignment l.snd acc.fst[l.fst.val]! = true
hsize'✝ : (acc.fst.modify l.fst.val (addAssignment l.snd)).size = n :=
  Eq.mpr (id (congrArg (fun _a => _a = n) (Array.size_modify acc.fst l.fst.val (addAssignment l.snd)))) hsize
i : Fin n
i_in_bounds : ↑i < acc.fst.size
l_in_bounds : l.fst.val < acc.fst.size
j1 j2 : Fin (List.length acc.snd.fst)
j1_eq_i : (List.get acc.snd.fst j1).fst.val = ↑i
j2_eq_i : (List.get acc.snd.fst j2).fst.val = ↑i
j1_eq_true : (List.get acc.snd.fst j1).snd = true
j2_eq_false : (List.get acc.snd.fst j2).snd = false
h1 : acc.fst[↑i] = both
h2 : f.assignments[↑i] = unassigned
h3 : ∀ (k : Fin (List.length acc.snd.fst)), k ≠ j1 → k ≠ j2 → (List.get acc.snd.fst k).fst.val ≠ ↑i
j1_succ_in_bounds : ↑j1 + 1 < (l :: acc.snd.fst).length
j2_succ_in_bounds : ↑j2 + 1 < (l :: acc.snd.fst).length
j1_succ : Fin (l :: acc.snd.fst).length := ⟨↑j1 + 1, j1_succ_in_bounds⟩
j2_succ : Fin (l :: acc.snd.fst).length := ⟨↑j2 + 1, j2_succ_in_bounds⟩
⊢ ((l :: acc.snd.fst).get j1_succ).fst.val = ↑i ∧
    ((l :: acc.snd.fst).get j2_succ).fst.val = ↑i ∧
      ((l :: acc.snd.fst).get j1_succ).snd = true ∧
        ((l :: acc.snd.fst).get j2_succ).snd = false ∧
          (acc.fst.modify l.fst.val (addAssignment l.snd))[↑i] = both ∧
            f.assignments[↑i] = unassigned ∧
              ∀ (k : Fin (l :: acc.snd.fst).length), k ≠ j1_succ → k ≠ j2_succ → ((l :: acc.snd.fst).get k).fst.val ≠ ↑i

Tactic:
simp only [List.get, Nat.add_eq, Nat.add_zero, List.length_cons, ne_eq]

Result:
case inr.inr.intro.intro.intro.intro.intro.intro.intro.intro
n : Nat
f : DefaultFormula n
f_assignments_size : f.assignments.size = n
acc : Array Assignment × CNF.Clause (PosFin n) × Bool × Bool
hsize : acc.fst.size = n
l : Literal (PosFin n)
ih : f.DerivedLitsInvariant f_assignments_size acc.fst hsize acc.snd.fst
h : ¬hasAssignment l.snd acc.fst[l.fst.val]! = true
hsize'✝ : (acc.fst.modify l.fst.val (addAssignment l.snd)).size = n :=
  Eq.mpr (id (congrArg (fun _a => _a = n) (Array.size_modify acc.fst l.fst.val (addAssignment l.snd)))) hsize
i : Fin n
i_in_bounds : ↑i < acc.fst.size
l_in_bounds : l.fst.val < acc.fst.size
j1 j2 : Fin (List.length acc.snd.fst)
j1_eq_i : (List.get acc.snd.fst j1).fst.val = ↑i
j2_eq_i : (List.get acc.snd.fst j2).fst.val = ↑i
j1_eq_true : (List.get acc.snd.fst j1).snd = true
j2_eq_false : (List.get acc.snd.fst j2).snd = false
h1 : acc.fst[↑i] = both
h2 : f.assignments[↑i] = unassigned
h3 : ∀ (k : Fin (List.length acc.snd.fst)), k ≠ j1 → k ≠ j2 → (List.get acc.snd.fst k).fst.val ≠ ↑i
j1_succ_in_bounds : ↑j1 + 1 < (l :: acc.snd.fst).length
j2_succ_in_bounds : ↑j2 + 1 < (l :: acc.snd.fst).length
j1_succ : Fin (l :: acc.snd.fst).length := ⟨↑j1 + 1, j1_succ_in_bounds⟩
j2_succ : Fin (l :: acc.snd.fst).length := ⟨↑j2 + 1, j2_succ_in_bounds⟩
⊢ ((l :: acc.snd.fst).get j1_succ).fst.val = ↑i ∧
    ((l :: acc.snd.fst).get j2_succ).fst.val = ↑i ∧
      ((l :: acc.snd.fst).get j1_succ).snd = true ∧
        ((l :: acc.snd.fst).get j2_succ).snd = false ∧
          (acc.fst.modify l.fst.val (addAssignment l.snd))[↑i] = both ∧
            f.assignments[↑i] = unassigned ∧
              ∀ (k : Fin (List.length acc.snd.fst + 1)),
                ¬k = j1_succ → ¬k = j2_succ → ¬((l :: acc.snd.fst).get k).fst.val = ↑i