Documentation

DescriptiveComplexity.Problems.ThreeColorability.CountGadget

A count-preserving 3-coloring gadget graph of a CNF formula #

The gadget graph of DescriptiveComplexity.Problems.ThreeColorability.SatGadget decides satisfiability but does not count models: its OR gate leaves its output free when exactly one input is true. This file builds the graph the counting reduction draws, whose proper 3-colorings are the models of the formula, each 6 · 8 ^ g times, g the number of non-first occurrences (DescriptiveComplexity.SatToColCount.card_proper).

The vertices are a palette T, F, B; a pair of complementary Boolean vertices per variable of the formula and per gate, i.e., per non-first occurrence of a clause, adjacent to each other and to B, so colored T and F in some order; a spoiler per empty clause, adjacent to the palette; and nine triangle vertices per gate. A triangle whose three vertices are attached to three Boolean or palette vertices has exactly two colorings when these are not all equal and none otherwise (DescriptiveComplexity.SatToColCount.tri_card), and the gate z = p ∨ ℓ, p the value of the prefix of the clause before the occurrence and ℓ its literal, is exactly NAE(z, ¬p, ¬ℓ) ∧ NAE(¬p, z, F) ∧ NAE(¬ℓ, z, F) (DescriptiveComplexity.SatToColCount.gate_iff): three triangles per gate, each with two colorings. The value of the last prefix of each clause is forced true by an edge to F.

The palette.

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

    Two Boolean facts #

    The color of a truth value: 0 for true, 1 for false.

    Equations
    Instances For
      Dependency graph

      Three colors are not all equal.

      Equations
      Instances For
        Dependency graph
        Dependency graph
        theorem DescriptiveComplexity.SatToColCount.gate_iff (z p l : Bool) :
        NAE3 (bc z) (bc !p) (bc !l) ∧ NAE3 (bc !p) (bc z) 1 ∧ NAE3 (bc !l) (bc z) 1 ↔ z = (p || l)

        The gate: z = p ∨ ℓ iff the three not-all-equal conditions hold.

        Dependency graph
        theorem DescriptiveComplexity.SatToColCount.tri_card (a b c : Fin 3) :
        a ≠ 2 → b ≠ 2 → c ≠ 2 → Fintype.card { t : Fin 3 → Fin 3 // (t 0 ≠ t 1 ∧ t 0 ≠ t 2 ∧ t 1 ≠ t 2) ∧ t 0 ≠ a ∧ t 1 ≠ b ∧ t 2 ≠ c } = if NAE3 a b c then 2 else 0

        A triangle attached to three vertices of colors other than B has two colorings when the three colors are not all equal, none otherwise.

        Dependency graph

        The graph #

        @[reducible, inline]

        The variables of the formula.

        Equations
        Instances For
          Dependency graph
          @[reducible, inline]

          The gates: the non-first occurrences.

          Equations
          Instances For
            Dependency graph
            Dependency graph
            Dependency graph
            @[reducible, inline]

            The vertices: the core, and nine triangle vertices per gate.

            Equations
            Instances For
              Dependency graph
              Dependency graph

              The prefix vertex of an occurrence: the vertex whose color is the disjunction of the literals of the clause up to it. The literal itself for the first occurrence, the output of the gate otherwise.

              Equations
              Instances For
                Dependency graph
                Dependency graph
                theorem DescriptiveComplexity.SatToColCount.pred_spec {A : Type} [FirstOrder.Language.sat.Structure A] [LinearOrder A] [Finite A] (g : Gate A) :
                SatOcc.SuccOcc (↑g).1 (pred g).1 (pred g).2 (↑g).2.1 (↑g).2.2
                Dependency graph
                Dependency graph
                Dependency graph

                The negated literal of a gate.

                Equations
                Instances For
                  Dependency graph

                  The attachment of the triangles of a gate: NAE(z, ¬p, ¬ℓ), NAE(¬p, z, F) and NAE(¬ℓ, z, F).

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

                    Normalizing the palette #

                    @[reducible, inline]

                    A palette vertex.

                    Equations
                    Instances For
                      Dependency graph
                      @[reducible, inline]

                      A Boolean vertex.

                      Equations
                      Instances For
                        Dependency graph
                        Dependency graph

                        The triangles #

                        Dependency graph

                        The palette is colored 0, 1, 2, on the core.

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

                          The core colorings are the models #

                          Every triangle sees three colors not all equal.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            Dependency graph
                            Dependency graph
                            Dependency graph
                            Dependency graph
                            theorem DescriptiveComplexity.SatToColCount.bv_flip {A : Type} [FirstOrder.Language.sat.Structure A] [LinearOrder A] {κ : Core A → Fin 3} (hκ : CoreProper κ) (hn : NormC κ) (b : Bv A) (s : Bool) :
                            κ (bvV (b, !s)) = 0 ↔ κ (bvV (b, s)) ≠ 0
                            Dependency graph
                            theorem DescriptiveComplexity.SatToColCount.lit_iff {A : Type} [FirstOrder.Language.sat.Structure A] [LinearOrder A] {κ : Core A → Fin 3} (hκ : CoreProper κ) (hn : NormC κ) (x : Var A) (s : Bool) :
                            κ (bvV (Sum.inl x, s)) = 0 ↔ SatOcc.LitTrue (modelOf κ) (↑x) s
                            Dependency graph

                            A core coloring gives a model.

                            Dependency graph

                            From a model to a core coloring #

                            The value of a carrier under an assignment: the variable, or the prefix disjunction of the gate.

                            Equations
                            Instances For
                              Dependency graph
                              Dependency graph
                              Dependency graph
                              Dependency graph
                              Dependency graph
                              theorem DescriptiveComplexity.SatToColCount.prefixOr_max {A : Type} [FirstOrder.Language.sat.Structure A] [LinearOrder A] {ν : A → Prop} (hν : SatModel A ν) {c x : A} {s : Bool} (hmax : SatOcc.MaxOcc c x s) :
                              Dependency graph
                              Dependency graph
                              Dependency graph
                              Dependency graph

                              The core colorings are the models.

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

                                The count #

                                The number of proper 3-colorings of the gadget graph: 6 · 8 ^ g times the number of models, g the number of non-first occurrences.

                                Dependency graph