-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/LRAT/Internal/Formula/RupAddSound.lean
theorem reduce_postcondition {n : Nat} (c : DefaultClause n) (assignment : Array Assignment) :
    (reduce c assignment = reducedToEmpty → Incompatible (PosFin n) c assignment) ∧
    (∀ l : Literal (PosFin n), reduce c assignment = reducedToUnit l → ∀ (p : (PosFin n) → Bool), p ⊨ assignment → p ⊨ c → p ⊨ l)

Proof state:
case intro
n : Nat
c : DefaultClause n
assignment : Array Assignment
c_arr : Array (Literal (PosFin n)) := List.toArray c.clause
c_clause_rw : c.clause = c_arr.toList
motive : Nat → ReduceResult (PosFin n) → Prop := ReducePostconditionInductionMotive c_arr assignment
h_base : motive 0 reducedToEmpty
h_inductive :
  ∀ (idx : Fin c_arr.size) (res : ReduceResult (PosFin n)),
    motive (↑idx) res → motive (↑idx + 1) (reduce_fold_fn assignment res c_arr[idx])
h2 :
  ∀ (l : Literal (PosFin n)),
    Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l →
      ∀ (p : PosFin n → Bool), p ⊨ assignment → (∃ i, ↑i < c_arr.size ∧ (p ⊨ c_arr[i])) → p ⊨ l
h : Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty
p : PosFin n → Bool
h1 : ∀ (i : Fin c_arr.size), ↑i < c_arr.size → ¬(p ⊨ c_arr[i])
i : PosFin n
pc1 : (i, true) ∈ c_arr.toList
pc2 : decide (p i = true) = true
idx : Fin c_arr.toList.length
hidx : c_arr.toList.get idx = (i, true)
⊢ ∃ idx, c_arr[idx] = (i, true)

Tactic:
simp only [List.get_eq_getElem] at hidx

Result:
case intro
n : Nat
c : DefaultClause n
assignment : Array Assignment
c_arr : Array (Literal (PosFin n)) := List.toArray c.clause
c_clause_rw : c.clause = c_arr.toList
motive : Nat → ReduceResult (PosFin n) → Prop := ReducePostconditionInductionMotive c_arr assignment
h_base : motive 0 reducedToEmpty
h_inductive :
  ∀ (idx : Fin c_arr.size) (res : ReduceResult (PosFin n)),
    motive (↑idx) res → motive (↑idx + 1) (reduce_fold_fn assignment res c_arr[idx])
h2 :
  ∀ (l : Literal (PosFin n)),
    Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l →
      ∀ (p : PosFin n → Bool), p ⊨ assignment → (∃ i, ↑i < c_arr.size ∧ (p ⊨ c_arr[i])) → p ⊨ l
h : Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty
p : PosFin n → Bool
h1 : ∀ (i : Fin c_arr.size), ↑i < c_arr.size → ¬(p ⊨ c_arr[i])
i : PosFin n
pc1 : (i, true) ∈ c_arr.toList
pc2 : decide (p i = true) = true
idx : Fin c_arr.toList.length
hidx : c_arr.toList[↑idx] = (i, true)
⊢ ∃ idx, c_arr[idx] = (i, true)

Proof state:
case intro.left.inl.h.intro.inr.intro.intro
n : Nat
c : DefaultClause n
assignment : Array Assignment
c_arr : Array (Literal (PosFin n)) := List.toArray c.clause
c_clause_rw : c.clause = c_arr.toList
motive : Nat → ReduceResult (PosFin n) → Prop := ReducePostconditionInductionMotive c_arr assignment
h_base : motive 0 reducedToEmpty
h_inductive :
  ∀ (idx : Fin c_arr.size) (res : ReduceResult (PosFin n)),
    motive (↑idx) res → motive (↑idx + 1) (reduce_fold_fn assignment res c_arr[idx])
h2 :
  ∀ (l : Literal (PosFin n)),
    Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l →
      ∀ (p : PosFin n → Bool), p ⊨ assignment → (∃ i, ↑i < c_arr.size ∧ (p ⊨ c_arr[i])) → p ⊨ l
h : Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty
p : PosFin n → Bool
h1 : ∀ (i : Fin c_arr.size), ↑i < c_arr.size → ¬(p ⊨ c_arr[i])
i : PosFin n
pc1 : (i, true) ∈ c_arr.toList
pc2 : decide (p i = true) = true
idx : Fin c_arr.size
hidx : c_arr[idx] = (i, true)
⊢ False

Tactic:
specialize h1 idx idx.2

Result:
case intro.left.inl.h.intro.inr.intro.intro
n : Nat
c : DefaultClause n
assignment : Array Assignment
c_arr : Array (Literal (PosFin n)) := List.toArray c.clause
c_clause_rw : c.clause = c_arr.toList
motive : Nat → ReduceResult (PosFin n) → Prop := ReducePostconditionInductionMotive c_arr assignment
h_base : motive 0 reducedToEmpty
h_inductive :
  ∀ (idx : Fin c_arr.size) (res : ReduceResult (PosFin n)),
    motive (↑idx) res → motive (↑idx + 1) (reduce_fold_fn assignment res c_arr[idx])
h2 :
  ∀ (l : Literal (PosFin n)),
    Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l →
      ∀ (p : PosFin n → Bool), p ⊨ assignment → (∃ i, ↑i < c_arr.size ∧ (p ⊨ c_arr[i])) → p ⊨ l
h : Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty
p : PosFin n → Bool
i : PosFin n
pc1 : (i, true) ∈ c_arr.toList
pc2 : decide (p i = true) = true
idx : Fin c_arr.size
hidx : c_arr[idx] = (i, true)
h1 : ¬(p ⊨ c_arr[idx])
⊢ False

Proof state:
n : Nat
c : DefaultClause n
assignment : Array Assignment
c_arr : Array (Literal (PosFin n)) := List.toArray c.clause
c_clause_rw : c.clause = c_arr.toList
motive : Nat → ReduceResult (PosFin n) → Prop := ReducePostconditionInductionMotive c_arr assignment
⊢ motive 0 reducedToEmpty

Tactic:
have : ∀ (a : PosFin n) (b : Bool), (reducedToEmpty = reducedToUnit (a, b)) = False := by intros; simp

Result:
n : Nat
c : DefaultClause n
assignment : Array Assignment
c_arr : Array (Literal (PosFin n)) := List.toArray c.clause
c_clause_rw : c.clause = c_arr.toList
motive : Nat → ReduceResult (PosFin n) → Prop := ReducePostconditionInductionMotive c_arr assignment
this : ∀ (a : PosFin n) (b : Bool), (reducedToEmpty = reducedToUnit (a, b)) = False
⊢ motive 0 reducedToEmpty

Proof state:
n : Nat
c : DefaultClause n
assignment : Array Assignment
c_arr : Array (Literal (PosFin n)) := List.toArray c.clause
⊢ (c.reduce assignment = reducedToEmpty → Incompatible (PosFin n) c assignment) ∧
    ∀ (l : Literal (PosFin n)),
      c.reduce assignment = reducedToUnit l → ∀ (p : PosFin n → Bool), p ⊨ assignment → p ⊨ c → p ⊨ l

Tactic:
have c_clause_rw : c.clause = c_arr.toList := by simp [c_arr]

Result:
n : Nat
c : DefaultClause n
assignment : Array Assignment
c_arr : Array (Literal (PosFin n)) := List.toArray c.clause
c_clause_rw : c.clause = c_arr.toList
⊢ (c.reduce assignment = reducedToEmpty → Incompatible (PosFin n) c assignment) ∧
    ∀ (l : Literal (PosFin n)),
      c.reduce assignment = reducedToUnit l → ∀ (p : PosFin n → Bool), p ⊨ assignment → p ⊨ c → p ⊨ l