-- 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])
h1 :
  Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty →
    ∀ (p : PosFin n → Bool), (∀ (i : Fin c_arr.size), ↑i < c_arr.size → ¬(p ⊨ c_arr[i])) ∨ ¬(p ⊨ assignment)
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
l : Literal (PosFin n)
hl : Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l
p : PosFin n → Bool
hp : p ⊨ assignment
i : PosFin n
pc1 : (i, false) ∈ c_arr.toList
pc2 : decide (p i = false) = true
idx : Fin c_arr.toList.length
hidx : c_arr.toList.get idx = (i, false)
⊢ ∃ idx, c_arr[idx] = (i, false)

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])
h1 :
  Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty →
    ∀ (p : PosFin n → Bool), (∀ (i : Fin c_arr.size), ↑i < c_arr.size → ¬(p ⊨ c_arr[i])) ∨ ¬(p ⊨ assignment)
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
l : Literal (PosFin n)
hl : Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l
p : PosFin n → Bool
hp : p ⊨ assignment
i : PosFin n
pc1 : (i, false) ∈ c_arr.toList
pc2 : decide (p i = false) = true
idx : Fin c_arr.toList.length
hidx : c_arr.toList[↑idx] = (i, false)
⊢ ∃ idx, c_arr[idx] = (i, 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
a✝ : PosFin n
b✝ : Bool
⊢ (reducedToEmpty = reducedToUnit (a✝, b✝)) = False

Tactic:
simp

Result:
no goals

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
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])
⊢ (Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty →
      Incompatible (PosFin n) c assignment) ∧
    ∀ (l : Literal (PosFin n)),
      Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l →
        ∀ (p : PosFin n → Bool), p ⊨ assignment → p ⊨ c → p ⊨ l

Tactic:
rcases Array.foldl_induction motive h_base h_inductive with ⟨h1, h2⟩

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])
h1 :
  Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty →
    ∀ (p : PosFin n → Bool), (∀ (i : Fin c_arr.size), ↑i < c_arr.size → ¬(p ⊨ c_arr[i])) ∨ ¬(p ⊨ assignment)
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
⊢ (Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty →
      Incompatible (PosFin n) c assignment) ∧
    ∀ (l : Literal (PosFin n)),
      Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l →
        ∀ (p : PosFin n → Bool), p ⊨ assignment → p ⊨ c → p ⊨ l

Proof state:
case intro.right.intro.inl.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])
h1 :
  Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty →
    ∀ (p : PosFin n → Bool), (∀ (i : Fin c_arr.size), ↑i < c_arr.size → ¬(p ⊨ c_arr[i])) ∨ ¬(p ⊨ assignment)
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
l : Literal (PosFin n)
hl : Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l
p : PosFin n → Bool
hp : p ⊨ assignment
i : PosFin n
pc1 : (i, false) ∈ c_arr.toList
pc2 : decide (p i = false) = true
⊢ ∃ i, ↑i < c_arr.size ∧ (p ⊨ c_arr[i])

Tactic:
have idx_exists : ∃ idx : Fin c_arr.size, c_arr[idx] = (i, false) := by
  rcases List.get_of_mem pc1 with ⟨idx, hidx⟩
  simp only [List.get_eq_getElem] at hidx
  exact Exists.intro idx hidx

Result:
case intro.right.intro.inl.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])
h1 :
  Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToEmpty →
    ∀ (p : PosFin n → Bool), (∀ (i : Fin c_arr.size), ↑i < c_arr.size → ¬(p ⊨ c_arr[i])) ∨ ¬(p ⊨ assignment)
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
l : Literal (PosFin n)
hl : Array.foldl (reduce_fold_fn assignment) reducedToEmpty c_arr = reducedToUnit l
p : PosFin n → Bool
hp : p ⊨ assignment
i : PosFin n
pc1 : (i, false) ∈ c_arr.toList
pc2 : decide (p i = false) = true
idx_exists : ∃ idx, c_arr[idx] = (i, false)
⊢ ∃ i, ↑i < c_arr.size ∧ (p ⊨ c_arr[i])