Documentation

Complexitylib.SAT.ThreeCNF

3-CNF formulas #

The 3-CNF refinement of the existing CNF type: a CNF is in 3-CNF when every clause has exactly three literals. Following the roadmap (track N3), 3-CNF is introduced here as a predicate on the existing CNF = List Clause, so that all of the CNF semantics (CNF.eval, CNF.Satisfiable, CNF.maxVar, renaming) apply unchanged and a 3-CNF is literally a CNF.

Main definitions and results #

The substantive N3 milestone — a size-controlled clause-padding transformation turning an arbitrary CNF into an equisatisfiable 3-CNF — builds on this predicate and is tracked separately.

A CNF is in 3-CNF when every clause is a disjunction of exactly three literals. This is a predicate on the existing CNF type, so a 3-CNF formula is literally a CNF and inherits all of its semantics.

Equations
Instances For
    @[simp]

    The empty CNF is trivially in 3-CNF.

    @[simp]

    c :: φ is 3-CNF iff c has three literals and φ is 3-CNF.

    theorem Complexity.SAT.CNF.Is3CNF.mapVar {φ : CNF} (h : φ.Is3CNF) (f : ) :

    Variable renaming preserves the 3-CNF shape: Clause.mapVar maps literals one-for-one, so it does not change clause lengths.

    Padding short clauses to width three #

    A clause with one or two literals is padded to exactly three literals by repeating its last literal. This changes neither the clause's models nor its satisfiability (repeating a literal in a disjunction is idempotent), and turns a CNF whose clauses all have width 1 … 3 into an equivalent 3-CNF. Splitting wide clauses (width > 3) needs fresh Tseitin variables and is tracked separately.

    Pad a clause of one or two literals to width three by repeating a literal; clauses of any other width are left unchanged.

    Equations
    Instances For

      Padding preserves the clause's value under every assignment (repeating a literal in a disjunction is idempotent).

      A clause of width 1 … 3 is padded to width exactly three.

      Pad every clause of a CNF to width three.

      Equations
      Instances For
        theorem Complexity.SAT.CNF.padTo3_eval (α : Assignment) (φ : CNF) :
        eval α φ.padTo3 = eval α φ

        Padding preserves the CNF's value under every assignment — hence satisfiability.

        Padding preserves satisfiability.

        theorem Complexity.SAT.CNF.is3CNF_padTo3 {φ : CNF} (h : cφ, 1 List.length c List.length c 3) :

        If every clause of φ has width 1 … 3, then CNF.padTo3 φ is a genuine 3-CNF equivalent to φ.