The largest variable index, by slot #
CNF.maxVar folds over clauses and then over literals. An algorithm instead
loops over a flat slot index and takes the largest value it sees. The two are
the same number, and this module says why: each bounds the family of variable
indices and each is attained by it.
Main results #
Complexity.var_le_maxVar— every literal's index is at mostmaxVarComplexity.exists_slot_eq_maxVar— and some literal attains itComplexity.maxOver_slotVar— the loop computesmaxVar
theorem
Complexity.exists_lit_eq_maxVar
(c : SAT.Clause)
:
0 < List.length c → ∃ (p : ℕ) (hp : p < List.length c), c[p].var = c.maxVar
Some literal of a nonempty clause attains its largest index.
theorem
Complexity.exists_clause_eq_maxVar
(φ : SAT.CNF)
:
0 < List.length φ → ∃ (j : ℕ) (hj : j < List.length φ), φ[j].maxVar = φ.maxVar
Some clause of a nonempty formula attains its largest index.