Documentation

DescriptiveComplexity.Problems.Sat.Tseitin

The Tseitin encoding of a first-order kernel: semantic layer #

Machinery for the hardness half of the Cook–Levin theorem (Cook 1971; Levin 1973; DescriptiveComplexity.sat_hard_of_sigmaSODefinable, in DescriptiveComplexity.Problems.Sat.Hardness): the generic, machine-free reduction of any existential-second-order definable problem to SAT (via a Tseitin (Tseitin 1968) encoding), in the style of Dahlhaus (Dahlhaus 1983). Given the first-order kernel φ (a sentence over the input vocabulary expanded by one second-order block), the produced CNF instance has

This file contains the semantic part of the construction, independent of the FO formulas defining the CNF instance inside the input structure:

The corresponding first-order formulas and their realization lemmas are in DescriptiveComplexity.Problems.Sat.TseitinFormulas.

Subformula positions #

The type of subformula positions (“nodes”) of f with context length m: positions at which the subformula has m free de Bruijn variables. The family is indexed by the context length so that all node-dependent data (valuations, clauses) can be typed uniformly, without a dependent context function.

Equations
Instances For
    Dependency graph
    Dependency graph

    Whether a position is the root, as a Boolean (usable inside formula definitions, where positions of a variable formula cannot be pattern-matched).

    Equations
    Instances For
      Dependency graph

      A position is the root iff isRootB says so; in that case its context length is the formula's own index. Stated as an equality of dependent pairs.

      Dependency graph
      theorem DescriptiveComplexity.Tseitin.sigma_map_eq_iff {β β' : Type} (F : (m : ) → β mβ' m) (hF : ∀ (m : ), Function.Injective (F m)) {m₁ m₂ : } (a : β m₁) (b : β m₂) :
      m₁, F m₁ a = m₂, F m₂ b m₁, a = m₂, b

      Equality of dependent pairs through a fiberwise injective map.

      Dependency graph
      Dependency graph

      A formula's own index is a context length, hence bounded by maxCtx.

      Dependency graph

      Context lengths of actual positions are bounded by maxCtx.

      Dependency graph

      There are finitely many positions in a formula.

      Dependency graph

      Terms of the expanded language #

      Dependency graph

      Reembedding termToL into the expanded language gives the term back.

      Dependency graph

      Realization of termToL in the base structure agrees with realization of the term in any expansion.

      Dependency graph

      Gates: correctness of a valuation of the position variables #

      @[instance_reducible]

      The expansion of an L-structure by a block assignment.

      Equations
      Instances For
        Dependency graph
        def DescriptiveComplexity.Tseitin.RealizeWith {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {n : } (f : (L.sum B.lang).BoundedFormula Empty n) (w : Fin nA) :

        Realization of a kernel formula in the expansion of an L-structure by a block assignment.

        Equations
        Instances For
          Dependency graph
          def DescriptiveComplexity.Tseitin.eqGuard {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] {m : } (t₁ t₂ : (L.sum B.lang).Term (Empty Fin m)) (w : Fin mA) :

          The truth value of an equality atom of the kernel under a context tuple.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            Dependency graph
            def DescriptiveComplexity.Tseitin.relGuard {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] {m l : } (r : L.Relations l) (ts : Fin l(L.sum B.lang).Term (Empty Fin m)) (w : Fin mA) :

            The truth value of an input-relation atom of the kernel under a context tuple.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              Dependency graph
              def DescriptiveComplexity.Tseitin.blockAtom {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {m l : } (r : B.lang.Relations l) (ts : Fin l(L.sum B.lang).Term (Empty Fin m)) (w : Fin mA) :

              The truth value of a block-variable atom of the kernel under an assignment and a context tuple.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                Dependency graph
                def DescriptiveComplexity.Tseitin.atomHolds {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {m l : } (R : (L.sum B.lang).Relations l) (ts : Fin l(L.sum B.lang).Term (Empty Fin m)) (w : Fin mA) :

                The truth value of an arbitrary atom of the kernel.

                Equations
                Instances For
                  Dependency graph
                  @[reducible, inline]

                  A valuation of the position variables of a formula: a truth value for every position and context tuple.

                  Equations
                  Instances For
                    Dependency graph

                    All Tseitin gates of a formula hold under a valuation of its position variables: at every position, the valuation relates to the valuations at the children (or to the atom's truth value) as dictated by the connective. A valuation satisfying all gates computes actual truth values (DescriptiveComplexity.Tseitin.gates_realize).

                    Equations
                    Instances For
                      Dependency graph

                      The canonical valuation: each position variable receives the truth value of its subformula.

                      Equations
                      Instances For
                        Dependency graph
                        theorem DescriptiveComplexity.Tseitin.canonVal_rootAt {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {n : } (f : (L.sum B.lang).BoundedFormula Empty n) (w : Fin nA) :
                        canonVal μ f n (rootAt f) w RealizeWith μ f w

                        The canonical valuation at the root is the truth value of the whole formula.

                        Dependency graph

                        Unfolding RealizeWith #

                        Dependency graph
                        theorem DescriptiveComplexity.Tseitin.realizeWith_equal {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {n : } (t₁ t₂ : (L.sum B.lang).Term (Empty Fin n)) (w : Fin nA) :
                        Dependency graph
                        theorem DescriptiveComplexity.Tseitin.realizeWith_rel {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {n l : } (R : (L.sum B.lang).Relations l) (ts : Fin l(L.sum B.lang).Term (Empty Fin n)) (w : Fin nA) :
                        Dependency graph
                        theorem DescriptiveComplexity.Tseitin.realizeWith_imp {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {n : } (f₁ f₂ : (L.sum B.lang).BoundedFormula Empty n) (w : Fin nA) :
                        RealizeWith μ (f₁.imp f₂) w RealizeWith μ f₁ wRealizeWith μ f₂ w
                        Dependency graph
                        theorem DescriptiveComplexity.Tseitin.realizeWith_all {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {n : } (f : (L.sum B.lang).BoundedFormula Empty (n + 1)) (w : Fin nA) :
                        RealizeWith μ f.all w ∀ (a : A), RealizeWith μ f (Fin.snoc w a)
                        Dependency graph

                        Gates compute truth values #

                        theorem DescriptiveComplexity.Tseitin.gates_realize {L : FirstOrder.Language} {B : SOBlock} {A : Type} [L.Structure A] (μ : B.Assignment A) {n : } (f : (L.sum B.lang).BoundedFormula Empty n) (ν : NodeVal A f) :
                        Gates μ f ν∀ (w : Fin nA), ν n (rootAt f) w RealizeWith μ f w

                        Any valuation satisfying all gates assigns to the root the truth value of the formula.

                        Dependency graph

                        The canonical valuation satisfies all gates.

                        Dependency graph

                        The clauses of the encoding and their literals #

                        def DescriptiveComplexity.Tseitin.atomLit {L : FirstOrder.Language} {B : SOBlock} {A : Type} {D : } [L.Structure A] [LE A] {m l : } (ts : Fin l(L.sum B.lang).Term (Empty Fin m)) (w : Fin mA) (x : Fin DA) :

                        The literal tuple of a block-variable atom: canonical, with the atom's term values as prefix.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          Dependency graph
                          def DescriptiveComplexity.Tseitin.IsClauseSem {L : FirstOrder.Language} {B : SOBlock} {A : Type} {D : } [L.Structure A] [LE A] {n : } (f : (L.sum B.lang).BoundedFormula Empty n) :
                          maxCtx f D{m : } → NodeAt f mFin 3(Fin DA)Prop

                          The clauses of the Tseitin encoding, as a predicate on positions, clause kinds (Fin 3) and canonical D-tuples:

                          • falsum node at context w: kind 0, the unit clause ¬v(p, w);
                          • equal/input-relation node: kind 0, the unit clause v(p, w), present when the atom holds under w; kind 1, the unit clause ¬v(p, w), present otherwise;
                          • block-variable node: kind 0, ¬v(p, w) ∨ R(ā); kind 1, v(p, w) ∨ ¬R(ā);
                          • imp node with children a, b: kind 0, ¬v(p, w) ∨ ¬a(w) ∨ b(w); kind 1, v(p, w) ∨ a(w); kind 2, v(p, w) ∨ ¬b(w);
                          • all node with child c: kind 0 (indexed by extended tuples w ⌢ a), ¬v(p, w) ∨ c(w ⌢ a); kind 1, the wide clause v(p, w) ∨ ⋁_a ¬c(w ⌢ a).
                          Equations
                          Instances For
                            Dependency graph
                            def DescriptiveComplexity.Tseitin.LitSem {L : FirstOrder.Language} {B : SOBlock} {A : Type} {D : } [L.Structure A] [LE A] (s : Bool) {n : } (f : (L.sum B.lang).BoundedFormula Empty n) :
                            maxCtx f D{m : } → NodeAt f mFin 3(Fin DA)B.ι (m' : ) × NodeAt f m'(Fin DA)Prop

                            The literals of the clauses of the Tseitin encoding: LitSem s f h p k u v x states that the propositional variable indexed by v (a block variable index or a position) at tuple x occurs with sign s in the clause (p, k, u). The clause-existence guards of DescriptiveComplexity.Tseitin.IsClauseSem are not repeated here.

                            Equations
                            Instances For
                              Dependency graph

                              Clause satisfaction is gate satisfaction #

                              def DescriptiveComplexity.Tseitin.SatCond {L : FirstOrder.Language} {B : SOBlock} {A : Type} {D : } [L.Structure A] [LinearOrder A] {n : } (f : (L.sum B.lang).BoundedFormula Empty n) (hctx : maxCtx f D) (tv : B.ι (m : ) × NodeAt f m(Fin DA)Prop) :

                              Every clause of the encoding contains a literal made true by the valuation tv of the propositional variables.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                Dependency graph
                                def DescriptiveComplexity.Tseitin.padAssign {L : FirstOrder.Language} {B : SOBlock} {A : Type} {D : } (a₀ : A) {n : } {f : (L.sum B.lang).BoundedFormula Empty n} (tv : B.ι (m : ) × NodeAt f m(Fin DA)Prop) :

                                The block assignment read off a valuation of the propositional variables, on padded tuples.

                                Equations
                                Instances For
                                  Dependency graph
                                  def DescriptiveComplexity.Tseitin.padVal {L : FirstOrder.Language} {B : SOBlock} {A : Type} {D : } (a₀ : A) {n : } {f : (L.sum B.lang).BoundedFormula Empty n} (tv : B.ι (m : ) × NodeAt f m(Fin DA)Prop) :

                                  The position valuation read off a valuation of the propositional variables, on padded tuples.

                                  Equations
                                  Instances For
                                    Dependency graph
                                    theorem DescriptiveComplexity.Tseitin.satCond_iff_gates {L : FirstOrder.Language} {B : SOBlock} {A : Type} {D : } [L.Structure A] [LinearOrder A] {a₀ : A} (h₀ : IsBot a₀) (harity : ∀ (i : B.ι), B.arity i D) {n : } (f : (L.sum B.lang).BoundedFormula Empty n) (hctx : maxCtx f D) (tv : B.ι (m : ) × NodeAt f m(Fin DA)Prop) :
                                    SatCond f hctx tv Gates (padAssign a₀ tv) f (padVal a₀ tv)

                                    Clause satisfaction is gate satisfaction: a valuation of the propositional variables makes every clause of the Tseitin encoding true iff the valuation it induces on positions (through canonical padding) satisfies every gate, with the block variables read off the atom variables.

                                    Dependency graph