-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/LRAT/Internal/Formula/Lemmas.lean
theorem deleteOne_preserves_strongAssignmentsInvariant {n : Nat} (f : DefaultFormula n) (id : Nat) :
    StrongAssignmentsInvariant f → StrongAssignmentsInvariant (deleteOne f id)

Proof state:
n : Nat
f : DefaultFormula n
id : Nat
hsize : f.assignments.size = n
hf : ∀ (i : PosFin n) (b : Bool), hasAssignment b f.assignments[i.val] = true → unit (i, b) ∈ f.toList
hsize' : (f.deleteOne id).assignments.size = n
i : PosFin n
b : Bool
i_in_bounds : i.val < f.assignments.size
c : DefaultClause n
heq : f.clauses[id]! = some c
l : Literal (PosFin n)
hl : c = { clause := [l], nodupkey := ⋯, nodup := ⋯ }
l_eq_i : l.fst.val = i.val
hb : hasAssignment b (removeAssignment l.snd f.assignments[i.val]) = true
⊢ l.snd ≠ b

Tactic:
intro l_eq_b

Result:
n : Nat
f : DefaultFormula n
id : Nat
hsize : f.assignments.size = n
hf : ∀ (i : PosFin n) (b : Bool), hasAssignment b f.assignments[i.val] = true → unit (i, b) ∈ f.toList
hsize' : (f.deleteOne id).assignments.size = n
i : PosFin n
b : Bool
i_in_bounds : i.val < f.assignments.size
c : DefaultClause n
heq : f.clauses[id]! = some c
l : Literal (PosFin n)
hl : c = { clause := [l], nodupkey := ⋯, nodup := ⋯ }
l_eq_i : l.fst.val = i.val
hb : hasAssignment b (removeAssignment l.snd f.assignments[i.val]) = true
l_eq_b : l.snd = b
⊢ False

Proof state:
case inl.h.isTrue.intro.intro
n : Nat
f : DefaultFormula n
id : Nat
hsize : f.assignments.size = n
hsize' : (f.deleteOne id).assignments.size = n
i : PosFin n
b : Bool
i_in_bounds : i.val < f.assignments.size
c : DefaultClause n
heq : f.clauses[id]! = some c
l : Literal (PosFin n)
hl : c = { clause := [l], nodupkey := ⋯, nodup := ⋯ }
l_eq_i : l.fst.val = i.val
l_ne_b : l.snd = !b
hb✝ : hasAssignment b (removeAssignment (!b) f.assignments[i.val]) = true
hb : hasAssignment b f.assignments[i.val] = true
hf : some (unit (i, b)) ∈ f.clauses.toList
h✝ : id < f.clauses.size
idx : Nat
hbound : idx < f.clauses.toList.length
hidx : f.clauses.toList[idx] = some (unit (i, b))
⊢ ∃ n_1, (f.clauses.toList.set id none).get n_1 = f.clauses.toList[idx]

Tactic:
have idx_in_bounds : idx < List.length (List.set f.clauses.toList id none) := by
  simp only [List.length_set]
  exact hbound

Result:
case inl.h.isTrue.intro.intro
n : Nat
f : DefaultFormula n
id : Nat
hsize : f.assignments.size = n
hsize' : (f.deleteOne id).assignments.size = n
i : PosFin n
b : Bool
i_in_bounds : i.val < f.assignments.size
c : DefaultClause n
heq : f.clauses[id]! = some c
l : Literal (PosFin n)
hl : c = { clause := [l], nodupkey := ⋯, nodup := ⋯ }
l_eq_i : l.fst.val = i.val
l_ne_b : l.snd = !b
hb✝ : hasAssignment b (removeAssignment (!b) f.assignments[i.val]) = true
hb : hasAssignment b f.assignments[i.val] = true
hf : some (unit (i, b)) ∈ f.clauses.toList
h✝ : id < f.clauses.size
idx : Nat
hbound : idx < f.clauses.toList.length
hidx : f.clauses.toList[idx] = some (unit (i, b))
idx_in_bounds : idx < (f.clauses.toList.set id none).length
⊢ ∃ n_1, (f.clauses.toList.set id none).get n_1 = f.clauses.toList[idx]

Proof state:
n : Nat
f : DefaultFormula n
id : Nat
hsize : f.assignments.size = n
hsize' : (f.deleteOne id).assignments.size = n
i : PosFin n
b : Bool
i_in_bounds : i.val < f.assignments.size
c : DefaultClause n
heq✝ : f.clauses[id]! = some c
l : Literal (PosFin n)
hl : c = { clause := [l], nodupkey := ⋯, nodup := ⋯ }
l_eq_i : l.fst.val = i.val
l_ne_b : l.snd = !b
hb✝ : hasAssignment b (removeAssignment (!b) f.assignments[i.val]) = true
hb : hasAssignment b f.assignments[i.val] = true
hf : some (unit (i, b)) ∈ f.clauses.toList
h✝ : id < f.clauses.size
idx : Nat
hbound : idx < f.clauses.toList.length
hidx : f.clauses.toList[idx] = some (unit (i, b))
idx_in_bounds : idx < (f.clauses.toList.set id none).length
id_eq_idx : id = idx
idx_in_bounds2 : idx < f.clauses.size
heq : some (unit (i, b)) = some { clause := [l], nodupkey := ⋯, nodup := ⋯ }
⊢ False

Tactic:
simp only [unit, Option.some.injEq, DefaultClause.mk.injEq, List.cons.injEq, and_true] at heq

Result:
n : Nat
f : DefaultFormula n
id : Nat
hsize : f.assignments.size = n
hsize' : (f.deleteOne id).assignments.size = n
i : PosFin n
b : Bool
i_in_bounds : i.val < f.assignments.size
c : DefaultClause n
heq✝ : f.clauses[id]! = some c
l : Literal (PosFin n)
hl : c = { clause := [l], nodupkey := ⋯, nodup := ⋯ }
l_eq_i : l.fst.val = i.val
l_ne_b : l.snd = !b
hb✝ : hasAssignment b (removeAssignment (!b) f.assignments[i.val]) = true
hb : hasAssignment b f.assignments[i.val] = true
hf : some (unit (i, b)) ∈ f.clauses.toList
h✝ : id < f.clauses.size
idx : Nat
hbound : idx < f.clauses.toList.length
hidx : f.clauses.toList[idx] = some (unit (i, b))
idx_in_bounds : idx < (f.clauses.toList.set id none).length
id_eq_idx : id = idx
idx_in_bounds2 : idx < f.clauses.size
heq : (i, b) = l
⊢ False

Proof state:
n : Nat
f : DefaultFormula n
id : Nat
hsize : f.assignments.size = n
hf : ∀ (i : PosFin n) (b : Bool), hasAssignment b f.assignments[i.val] = true → unit (i, b) ∈ f.toList
hsize' : (f.deleteOne id).assignments.size = n
i : PosFin n
b : Bool
hb : hasAssignment b (f.deleteOne id).assignments[i.val] = true
i_in_bounds : i.val < f.assignments.size
c : DefaultClause n
heq : f.clauses[id]! = some c
hl :
  ∀ (x : PosFin n),
    ¬c = { clause := [(x, false)], nodupkey := ⋯, nodup := ⋯ } ∧
      ¬c = { clause := [(x, true)], nodupkey := ⋯, nodup := ⋯ }
x✝² : Option (DefaultClause n)
val✝ : DefaultClause n
x✝¹ :
  ∀ (l : Literal (PosFin n)) (nodupkey : ∀ (l_1 : PosFin n), ¬(l_1, true) ∈ [l] ∨ ¬(l_1, false) ∈ [l])
    (nodup : [l].Nodup), val✝ = { clause := [l], nodupkey := nodupkey, nodup := nodup } → False
heq✝ : some c = some val✝
x✝ : Option (DefaultClause n)
l : Literal (PosFin n)
nodupkey✝ : ∀ (l_1 : PosFin n), ¬(l_1, true) ∈ [l] ∨ ¬(l_1, false) ∈ [l]
nodup✝ : [l].Nodup
heq2 : f.clauses[id]! = some { clause := [l], nodupkey := nodupkey✝, nodup := nodup✝ }
⊢ { clauses := f.clauses.set! id none, rupUnits := f.rupUnits, ratUnits := f.ratUnits,
      assignments := f.assignments.modify l.fst.val (removeAssignment l.snd) } =
    { clauses := f.clauses.set! id none, rupUnits := f.rupUnits, ratUnits := f.ratUnits, assignments := f.assignments }

Tactic:
simp only [heq, Option.some.injEq] at heq2

Result:
n : Nat
f : DefaultFormula n
id : Nat
hsize : f.assignments.size = n
hf : ∀ (i : PosFin n) (b : Bool), hasAssignment b f.assignments[i.val] = true → unit (i, b) ∈ f.toList
hsize' : (f.deleteOne id).assignments.size = n
i : PosFin n
b : Bool
hb : hasAssignment b (f.deleteOne id).assignments[i.val] = true
i_in_bounds : i.val < f.assignments.size
c : DefaultClause n
heq : f.clauses[id]! = some c
hl :
  ∀ (x : PosFin n),
    ¬c = { clause := [(x, false)], nodupkey := ⋯, nodup := ⋯ } ∧
      ¬c = { clause := [(x, true)], nodupkey := ⋯, nodup := ⋯ }
x✝² : Option (DefaultClause n)
val✝ : DefaultClause n
x✝¹ :
  ∀ (l : Literal (PosFin n)) (nodupkey : ∀ (l_1 : PosFin n), ¬(l_1, true) ∈ [l] ∨ ¬(l_1, false) ∈ [l])
    (nodup : [l].Nodup), val✝ = { clause := [l], nodupkey := nodupkey, nodup := nodup } → False
heq✝ : some c = some val✝
x✝ : Option (DefaultClause n)
l : Literal (PosFin n)
nodupkey✝ : ∀ (l_1 : PosFin n), ¬(l_1, true) ∈ [l] ∨ ¬(l_1, false) ∈ [l]
nodup✝ : [l].Nodup
heq2 : c = { clause := [l], nodupkey := nodupkey✝, nodup := nodup✝ }
⊢ { clauses := f.clauses.set! id none, rupUnits := f.rupUnits, ratUnits := f.ratUnits,
      assignments := f.assignments.modify l.fst.val (removeAssignment l.snd) } =
    { clauses := f.clauses.set! id none, rupUnits := f.rupUnits, ratUnits := f.ratUnits, assignments := f.assignments }