. next idx_ne_j =>
  refine Or.inr <| Or.inl <| ⟨j,b,i_gt_zero,?_⟩
  constructor
  . rw [← Nat.succ_eq_add_one]
    apply Nat.succ_le_of_lt ∘ Nat.lt_of_le_of_ne j_ge_idx
    intro idx_eq_j
    exact idx_ne_j (Fin.eq_of_val_eq idx_eq_j)
  . constructor
    . exact ih1
    . constructor
      . simp only [clearUnit, Array.get_eq_getElem]
        specialize ih4 idx (Nat.le_refl idx.1) idx_ne_j
        have idx_unit_in_bounds : units[idx.1].1.1 < assignments.size := by
          rw [hsize]
          exact units[idx.1].1.2.2
        have i_in_bounds : i.1 < assignments.size := by rw [hsize]; exact i.2
        rw [Array.get_modify_unchanged idx_unit_in_bounds i_in_bounds _ ih4]
        exact ih2
      . constructor
        . exact ih3
        . intro k k_ge_idx_add_one k_ne_j
          exact ih4 k (Nat.le_of_succ_le k_ge_idx_add_one) k_ne_j
case neg
n : Nat
f : DefaultFormula n
f_assignments_size : f.assignments.size = n
units : Array (Literal (PosFin n))
units_nodup : ∀ (i j : Fin units.size), i ≠ j → units[i] ≠ units[j]
idx : Fin units.size
assignments : Array Assignment
hsize : assignments.size = n
hsize' : (clearUnit assignments units[idx]).size = n
i : Fin n
j : Fin units.size
j_ge_idx : ↑j ≥ ↑idx
b : Bool
i_gt_zero : ↑i > 0
ih1 : units[↑j] = (⟨↑i, ⋯⟩, b)
ih2 : assignments[↑i] = addAssignment b f.assignments[↑i]
ih3 : ¬hasAssignment b f.assignments[↑i] = true
ih4 : ∀ (k : Fin units.size), ↑k ≥ ↑idx → ¬k = j → ¬units[↑k].fst.val = ↑i
h✝ : ¬idx = j
⊢ let_fun i_lt_assignments_size := ⋯;
  let_fun i_lt_f_assignments_size := ⋯;
  let assignments_i := (clearUnit assignments units[idx])[↑i];
  let fassignments_i := f.assignments[↑i];
  (assignments_i = fassignments_i ∧ ∀ (j : Fin units.size), ↑j ≥ ↑idx + 1 → units[j].fst.val ≠ ↑i) ∨
    (∃ j b i_gt_zero,
        ↑j ≥ ↑idx + 1 ∧
          units[j] = (⟨↑i, ⋯⟩, b) ∧
            assignments_i = addAssignment b fassignments_i ∧
              ¬hasAssignment b fassignments_i = true ∧
                ∀ (k : Fin units.size), ↑k ≥ ↑idx + 1 → k ≠ j → units[k].fst.val ≠ ↑i) ∨
      ∃ j1 j2 i_gt_zero,
        ↑j1 ≥ ↑idx + 1 ∧
          ↑j2 ≥ ↑idx + 1 ∧
            units[j1] = (⟨↑i, ⋯⟩, true) ∧
              units[j2] = (⟨↑i, ⋯⟩, false) ∧
                assignments_i = both ∧
                  fassignments_i = unassigned ∧
                    ∀ (k : Fin units.size), ↑k ≥ ↑idx + 1 → k ≠ j1 → k ≠ j2 → units[k].fst.val ≠ ↑i
no goals