Documentation

DescriptiveComplexity.Problems.TwoSat.Ptime

2SAT is in PTIME, by a Horn program for the implication graph #

2SAT is SO-Horn definable (DescriptiveComplexity.twoSat_sigmaSOHornDefinable), hence in DescriptiveComplexity.PTIME. This is what makes the inclusion NL ⊆ PTIME available: the inclusion has no syntactic route, a Krom kernel not being a Horn kernel, so it goes through the complete problem of the Krom fragment.

The program guesses the reachability relation of the implication graph (DescriptiveComplexity.TwoSatImpl), as one binary relation variable per pair of signs, and constrains it by Horn clauses:

An assignment satisfies the program exactly when it contains reachability and has no bad cycle, so correctness is the classical criterion DescriptiveComplexity.TwoSatImpl.satisfiable_of_no_bad_cycle in one direction and DescriptiveComplexity.TwoSatImpl.no_bad_cycle_of_satisfiable in the other.

Note the shape of the argument: the acceptance condition of 2SAT is negative ("no bad cycle"), which a Horn program can state because a goal clause is exactly a negative constraint on the guessed relation.

The block and its atoms #

@[reducible, inline]

The block of the Horn program: one binary relation variable per pair of signs, holding reachability in the implication graph. An abbrev, so that the arity reduces when tuples are written as ![x, y].

Equations
Instances For
    Dependency graph

    The atom Reach s t (v i) (v j).

    Equations
    Instances For
      Dependency graph

      Reachability as read off an assignment of the block.

      Equations
      Instances For
        Dependency graph
        theorem DescriptiveComplexity.TwoSatHorn.reachAtom_holds {A : Type} (ρ : reachBlock.Assignment A) (s t : Bool) (i j : Fin 4) (v : Fin 4A) :
        (reachAtom s t i j).Holds ρ v RVal ρ s t (v i) (v j)
        Dependency graph

        The guards over four variables #

        The membership program of DescriptiveComplexity.Problems.TwoSat.Membership uses three universally quantified variables (c, x, y); this program needs a fourth one for transitivity, so its covering-pair guard is that formula relabelled.

        The injection of the three variables of the covering-pair guard into the four variables of this program.

        Equations
        Instances For
          Dependency graph
          Dependency graph

          The covering-pair guard says exactly that the clause v 0 is covered by the occurrences (v 1, s) and (v 2, u).

          Dependency graph

          The program #

          Reflexivity of reachability.

          Equations
          Instances For
            Dependency graph

            The implication ¬ℓ(x, s) → ℓ(y, u) of a clause covered by (x, s) and (y, u).

            Equations
            Instances For
              Dependency graph

              The implication ¬ℓ(y, u) → ℓ(x, s) of the same clause.

              Equations
              Instances For
                Dependency graph

                Transitivity of reachability.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  Dependency graph

                  The goal clause forbidding a bad cycle: a variable reaching its own negation and back.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    Dependency graph

                    The goal clause rejecting an empty clause.

                    Equations
                    Instances For
                      Dependency graph

                      The goal clause rejecting a violated width promise.

                      Equations
                      Instances For
                        Dependency graph

                        The Horn program defining 2SAT: reachability in the implication graph, constrained to have no bad cycle. The sign combinations are spelled out, so that membership of a clause is decided by simp.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph

                          A yes-instance satisfies the program #

                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph
                          Dependency graph

                          A yes-instance satisfies the program: the reachability relation itself is a satisfying assignment.

                          Dependency graph

                          A satisfying assignment describes a yes-instance #

                          A satisfying assignment contains reachability: it is closed under the reflexivity, edge and transitivity clauses.

                          Dependency graph

                          A satisfying assignment makes the instance a yes-instance.

                          Dependency graph

                          Correctness of the program: it is satisfiable exactly on the yes-instances of 2SAT.

                          Dependency graph

                          2SAT is SO-Horn definable: guess the reachability relation of the implication graph, constrain it by reflexivity, the clause edges and transitivity, and reject the instances where a variable reaches its own negation and back. Since PTIME is defined as SO-Horn definability, this is the statement TwoSAT ∈ PTIME.

                          Dependency graph
                          Dependency graph