-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/LRAT/Internal/Formula/RatAddResult.lean
theorem clear_insertRat_base_case {n : Nat} (f : DefaultFormula n)
    (hf : f.ratUnits = #[] ∧ f.assignments.size = n) (units : CNF.Clause (PosFin n)) :
    let insertRat_res := insertRatUnits f units
    ClearInsertInductionMotive f hf.2 insertRat_res.1.ratUnits 0 insertRat_res.1.assignments

Proof state:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
⊢ let insertRat_res := f.insertRatUnits units;
  f.ClearInsertInductionMotive ⋯ insertRat_res.fst.ratUnits 0 insertRat_res.fst.assignments

Tactic:
have insertRatUnits_assignments_size := size_assignments_insertRatUnits f units

Result:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
insertRatUnits_assignments_size : (f.insertRatUnits units).fst.assignments.size = f.assignments.size
⊢ let insertRat_res := f.insertRatUnits units;
  f.ClearInsertInductionMotive ⋯ insertRat_res.fst.ratUnits 0 insertRat_res.fst.assignments

Proof state:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
insertRatUnits_assignments_size : (f.insertRatUnits units).fst.assignments.size = n
⊢ let insertRat_res := f.insertRatUnits units;
  f.ClearInsertInductionMotive ⋯ insertRat_res.fst.ratUnits 0 insertRat_res.fst.assignments

Tactic:
apply Exists.intro insertRatUnits_assignments_size

Result:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
insertRatUnits_assignments_size : (f.insertRatUnits units).fst.assignments.size = n
⊢ ∀ (i : Fin n),
    let_fun i_lt_assignments_size := ⋯;
    let_fun i_lt_f_assignments_size := ⋯;
    let assignments_i := (f.insertRatUnits units).fst.assignments[↑i];
    let fassignments_i := f.assignments[↑i];
    (assignments_i = fassignments_i ∧
        ∀ (j : Fin (f.insertRatUnits units).fst.ratUnits.size),
          ↑j ≥ 0 → (f.insertRatUnits units).fst.ratUnits[j].fst.val ≠ ↑i) ∨
      (∃ j b i_gt_zero,
          ↑j ≥ 0 ∧
            (f.insertRatUnits units).fst.ratUnits[j] = (⟨↑i, ⋯⟩, b) ∧
              assignments_i = addAssignment b fassignments_i ∧
                ¬hasAssignment b fassignments_i = true ∧
                  ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                    ↑k ≥ 0 → k ≠ j → (f.insertRatUnits units).fst.ratUnits[k].fst.val ≠ ↑i) ∨
        ∃ j1 j2 i_gt_zero,
          ↑j1 ≥ 0 ∧
            ↑j2 ≥ 0 ∧
              (f.insertRatUnits units).fst.ratUnits[j1] = (⟨↑i, ⋯⟩, true) ∧
                (f.insertRatUnits units).fst.ratUnits[j2] = (⟨↑i, ⋯⟩, false) ∧
                  assignments_i = both ∧
                    fassignments_i = unassigned ∧
                      ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                        ↑k ≥ 0 → k ≠ j1 → k ≠ j2 → (f.insertRatUnits units).fst.ratUnits[k].fst.val ≠ ↑i

Proof state:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
insertRatUnits_assignments_size : (f.insertRatUnits units).fst.assignments.size = f.assignments.size
⊢ let insertRat_res := f.insertRatUnits units;
  f.ClearInsertInductionMotive ⋯ insertRat_res.fst.ratUnits 0 insertRat_res.fst.assignments

Tactic:
rw [hf.2] at insertRatUnits_assignments_size

Result:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
insertRatUnits_assignments_size : (f.insertRatUnits units).fst.assignments.size = n
⊢ let insertRat_res := f.insertRatUnits units;
  f.ClearInsertInductionMotive ⋯ insertRat_res.fst.ratUnits 0 insertRat_res.fst.assignments

Proof state:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
insertRatUnits_assignments_size : (f.insertRatUnits units).fst.assignments.size = n
i : Fin n
⊢ let_fun i_lt_assignments_size := ⋯;
  let_fun i_lt_f_assignments_size := ⋯;
  let assignments_i := (f.insertRatUnits units).fst.assignments[↑i];
  let fassignments_i := f.assignments[↑i];
  (assignments_i = fassignments_i ∧
      ∀ (j : Fin (f.insertRatUnits units).fst.ratUnits.size),
        ↑j ≥ 0 → (f.insertRatUnits units).fst.ratUnits[j].fst.val ≠ ↑i) ∨
    (∃ j b i_gt_zero,
        ↑j ≥ 0 ∧
          (f.insertRatUnits units).fst.ratUnits[j] = (⟨↑i, ⋯⟩, b) ∧
            assignments_i = addAssignment b fassignments_i ∧
              ¬hasAssignment b fassignments_i = true ∧
                ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                  ↑k ≥ 0 → k ≠ j → (f.insertRatUnits units).fst.ratUnits[k].fst.val ≠ ↑i) ∨
      ∃ j1 j2 i_gt_zero,
        ↑j1 ≥ 0 ∧
          ↑j2 ≥ 0 ∧
            (f.insertRatUnits units).fst.ratUnits[j1] = (⟨↑i, ⋯⟩, true) ∧
              (f.insertRatUnits units).fst.ratUnits[j2] = (⟨↑i, ⋯⟩, false) ∧
                assignments_i = both ∧
                  fassignments_i = unassigned ∧
                    ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                      ↑k ≥ 0 → k ≠ j1 → k ≠ j2 → (f.insertRatUnits units).fst.ratUnits[k].fst.val ≠ ↑i

Tactic:
simp only [Nat.zero_le, Fin.getElem_fin, ne_eq, forall_const, true_and]

Result:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
insertRatUnits_assignments_size : (f.insertRatUnits units).fst.assignments.size = n
i : Fin n
⊢ ((f.insertRatUnits units).fst.assignments[↑i] = f.assignments[↑i] ∧
      ∀ (j : Fin (f.insertRatUnits units).fst.ratUnits.size), ¬(f.insertRatUnits units).fst.ratUnits[↑j].fst.val = ↑i) ∨
    (∃ j b h,
        (f.insertRatUnits units).fst.ratUnits[↑j] = (⟨↑i, ⋯⟩, b) ∧
          (f.insertRatUnits units).fst.assignments[↑i] = addAssignment b f.assignments[↑i] ∧
            ¬hasAssignment b f.assignments[↑i] = true ∧
              ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                ¬k = j → ¬(f.insertRatUnits units).fst.ratUnits[↑k].fst.val = ↑i) ∨
      ∃ j1 j2 h,
        (f.insertRatUnits units).fst.ratUnits[↑j1] = (⟨↑i, ⋯⟩, true) ∧
          (f.insertRatUnits units).fst.ratUnits[↑j2] = (⟨↑i, ⋯⟩, false) ∧
            (f.insertRatUnits units).fst.assignments[↑i] = both ∧
              f.assignments[↑i] = unassigned ∧
                ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                  ¬k = j1 → ¬k = j2 → ¬(f.insertRatUnits units).fst.ratUnits[↑k].fst.val = ↑i

Proof state:
n : Nat
f : DefaultFormula n
hf : f.ratUnits = #[] ∧ f.assignments.size = n
units : CNF.Clause (PosFin n)
insertRatUnits_assignments_size : (f.insertRatUnits units).fst.assignments.size = n
i : Fin n
⊢ ((f.insertRatUnits units).fst.assignments[↑i] = f.assignments[↑i] ∧
      ∀ (j : Fin (f.insertRatUnits units).fst.ratUnits.size), ¬(f.insertRatUnits units).fst.ratUnits[↑j].fst.val = ↑i) ∨
    (∃ j b h,
        (f.insertRatUnits units).fst.ratUnits[↑j] = (⟨↑i, ⋯⟩, b) ∧
          (f.insertRatUnits units).fst.assignments[↑i] = addAssignment b f.assignments[↑i] ∧
            ¬hasAssignment b f.assignments[↑i] = true ∧
              ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                ¬k = j → ¬(f.insertRatUnits units).fst.ratUnits[↑k].fst.val = ↑i) ∨
      ∃ j1 j2 h,
        (f.insertRatUnits units).fst.ratUnits[↑j1] = (⟨↑i, ⋯⟩, true) ∧
          (f.insertRatUnits units).fst.ratUnits[↑j2] = (⟨↑i, ⋯⟩, false) ∧
            (f.insertRatUnits units).fst.assignments[↑i] = both ∧
              f.assignments[↑i] = unassigned ∧
                ∀ (k : Fin (f.insertRatUnits units).fst.ratUnits.size),
                  ¬k = j1 → ¬k = j2 → ¬(f.insertRatUnits units).fst.ratUnits[↑k].fst.val = ↑i

Tactic:
exact insertRatUnits_postcondition f hf units i

Result:
no goals