-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/LRAT/Internal/Formula/Lemmas.lean
theorem insert_iff {n : Nat} (f : DefaultFormula n) (c1 : DefaultClause n) (c2 : DefaultClause n) :
    c2 ∈ toList (insert f c1) ↔ c2 = c1 ∨ c2 ∈ toList f

Proof state:
case mp.h.inl.h.h_3.inl
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_ne_c1 : ¬c2 = c1
x✝ : Option (Literal (PosFin n))
l✝ : PosFin n
heq✝ : c1.isUnit = some (l✝, false)
h : some c2 ∈ f.clauses.toList
⊢ some c2 ∈ f.clauses.toList

Tactic:
exact h

Result:
no goals

Proof state:
case mpr.inl
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_ne_c1 : ¬c2 = c1
h : c2 = c1
⊢ some c2 ∈ (f.insert c1).clauses.toList ∨
    (∃ a,
        (a, false) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, false) = c2 ∨
          (a, true) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, true) = c2) ∨
      ∃ a,
        (a, false) ∈ (f.insert c1).ratUnits.toList ∧ unit (a, false) = c2 ∨
          (a, true) ∈ (f.insert c1).ratUnits.toList ∧ unit (a, true) = c2

Tactic:
exact False.elim <| c2_ne_c1 h

Result:
no goals

Proof state:
case mpr.inr.inl.h.h_3
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_ne_c1 : ¬c2 = c1
h : some c2 ∈ f.clauses.toList
x✝ : Option (Literal (PosFin n))
l✝ : PosFin n
heq✝ : c1.isUnit = some (l✝, false)
⊢ some c2 ∈ f.clauses.toList ∨ c2 = c1

Tactic:
exact Or.inl h

Result:
no goals

Proof state:
case mpr
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_eq_c1 : c2 = c1
⊢ (c2 = c1 ∨
      some c2 ∈ f.clauses.toList ∨
        (∃ a,
            (a, false) ∈ f.rupUnits.toList ∧ unit (a, false) = c2 ∨
              (a, true) ∈ f.rupUnits.toList ∧ unit (a, true) = c2) ∨
          ∃ a,
            (a, false) ∈ f.ratUnits.toList ∧ unit (a, false) = c2 ∨
              (a, true) ∈ f.ratUnits.toList ∧ unit (a, true) = c2) →
    some c2 ∈ (f.insert c1).clauses.toList ∨
      (∃ a,
          (a, false) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, false) = c2 ∨
            (a, true) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, true) = c2) ∨
        ∃ a,
          (a, false) ∈ (f.insert c1).ratUnits.toList ∧ unit (a, false) = c2 ∨
            (a, true) ∈ (f.insert c1).ratUnits.toList ∧ unit (a, true) = c2

Tactic:
intro _

Result:
case mpr
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_eq_c1 : c2 = c1
a✝ :
  c2 = c1 ∨
    some c2 ∈ f.clauses.toList ∨
      (∃ a,
          (a, false) ∈ f.rupUnits.toList ∧ unit (a, false) = c2 ∨ (a, true) ∈ f.rupUnits.toList ∧ unit (a, true) = c2) ∨
        ∃ a, (a, false) ∈ f.ratUnits.toList ∧ unit (a, false) = c2 ∨ (a, true) ∈ f.ratUnits.toList ∧ unit (a, true) = c2
⊢ some c2 ∈ (f.insert c1).clauses.toList ∨
    (∃ a,
        (a, false) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, false) = c2 ∨
          (a, true) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, true) = c2) ∨
      ∃ a,
        (a, false) ∈ (f.insert c1).ratUnits.toList ∧ unit (a, false) = c2 ∨
          (a, true) ∈ (f.insert c1).ratUnits.toList ∧ unit (a, true) = c2

Proof state:
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
⊢ c2 ∈ (f.insert c1).toList ↔ c2 = c1 ∨ c2 ∈ f.toList

Tactic:
simp only [toList, List.append_assoc, List.mem_append, List.mem_filterMap, id_eq, exists_eq_right,
  List.mem_map, Prod.exists, Bool.exists_bool]

Result:
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
⊢ (some c2 ∈ (f.insert c1).clauses.toList ∨
      (∃ a,
          (a, false) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, false) = c2 ∨
            (a, true) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, true) = c2) ∨
        ∃ a,
          (a, false) ∈ (f.insert c1).ratUnits.toList ∧ unit (a, false) = c2 ∨
            (a, true) ∈ (f.insert c1).ratUnits.toList ∧ unit (a, true) = c2) ↔
    c2 = c1 ∨
      some c2 ∈ f.clauses.toList ∨
        (∃ a,
            (a, false) ∈ f.rupUnits.toList ∧ unit (a, false) = c2 ∨
              (a, true) ∈ f.rupUnits.toList ∧ unit (a, true) = c2) ∨
          ∃ a,
            (a, false) ∈ f.ratUnits.toList ∧ unit (a, false) = c2 ∨ (a, true) ∈ f.ratUnits.toList ∧ unit (a, true) = c2

Proof state:
case mp.h.inr.inl
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_ne_c1 : ¬c2 = c1
h :
  ∃ a,
    (a, false) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, false) = c2 ∨
      (a, true) ∈ (f.insert c1).rupUnits.toList ∧ unit (a, true) = c2
⊢ some c2 ∈ f.clauses.toList ∨
    (∃ a, (a, false) ∈ f.rupUnits.toList ∧ unit (a, false) = c2 ∨ (a, true) ∈ f.rupUnits.toList ∧ unit (a, true) = c2) ∨
      ∃ a, (a, false) ∈ f.ratUnits.toList ∧ unit (a, false) = c2 ∨ (a, true) ∈ f.ratUnits.toList ∧ unit (a, true) = c2

Tactic:
rw [rupUnits_insert] at h

Result:
case mp.h.inr.inl
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_ne_c1 : ¬c2 = c1
h : ∃ a, (a, false) ∈ f.rupUnits.toList ∧ unit (a, false) = c2 ∨ (a, true) ∈ f.rupUnits.toList ∧ unit (a, true) = c2
⊢ some c2 ∈ f.clauses.toList ∨
    (∃ a, (a, false) ∈ f.rupUnits.toList ∧ unit (a, false) = c2 ∨ (a, true) ∈ f.rupUnits.toList ∧ unit (a, true) = c2) ∨
      ∃ a, (a, false) ∈ f.ratUnits.toList ∧ unit (a, false) = c2 ∨ (a, true) ∈ f.ratUnits.toList ∧ unit (a, true) = c2

Proof state:
case mp.h.inl.h.h_3
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_ne_c1 : ¬c2 = c1
x✝ : Option (Literal (PosFin n))
l✝ : PosFin n
heq✝ : c1.isUnit = some (l✝, false)
h : some c2 ∈ f.clauses.toList ∨ c2 = c1
⊢ some c2 ∈ f.clauses.toList

Tactic:
rcases h with h | h

Result:
case mp.h.inl.h.h_3.inl
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_ne_c1 : ¬c2 = c1
x✝ : Option (Literal (PosFin n))
l✝ : PosFin n
heq✝ : c1.isUnit = some (l✝, false)
h : some c2 ∈ f.clauses.toList
⊢ some c2 ∈ f.clauses.toList

case mp.h.inl.h.h_3.inr
n : Nat
f : DefaultFormula n
c1 c2 : DefaultClause n
c2_ne_c1 : ¬c2 = c1
x✝ : Option (Literal (PosFin n))
l✝ : PosFin n
heq✝ : c1.isUnit = some (l✝, false)
h : c2 = c1
⊢ some c2 ∈ f.clauses.toList