Documentation

DescriptiveComplexity.Problems.Machine.Counting

Counting the accepting runs of a machine #

The counting version of DescriptiveComplexity.NTMAccept, on the same vocabulary: the number of accepting runs of the machine an instance describes – the quantity #P was introduced to measure (Valiant 1979).

A run is counted through its layout along the positions, as in DescriptiveComplexity.TMData.IsWalk, with two more requirements that make the layout of a run unique (DescriptiveComplexity.TMData.IsHaltWalk):

DescriptiveComplexity.SharpNTMAccept is the bundled counting problem; its support is machine acceptance (DescriptiveComplexity.sharpNtmAccept_support_iff), and it belongs to #P (DescriptiveComplexity.sharpNtmAccept_mem_sharpP): the tableau of Fagin's argument is functionally determined by the run, so its guesses are the runs, bijectively (DescriptiveComplexity.haltWalkEquiv). With the counting Cook–Levin theorem this gives its textbook form, DescriptiveComplexity.sharpNtmAccept_reduces_to_sharpSat: counting the accepting runs of a machine reduces parsimoniously to counting the models of a CNF formula.

The converse reduction is in DescriptiveComplexity.Problems.Machine.CountingHardness, which makes this problem parsimoniously #P-complete and #P the class of the problems reducing to it.

def DescriptiveComplexity.TMData.IsHaltWalk {A : Type} (M : TMData A) (conf : A → Config A) :

A halting walk: a walk that repeats an accepting configuration once it has reached one, and carries the initial configuration at the times that are not positions. A run from an initial configuration to the first accepting one, within the budget, has exactly one such layout.

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

    Halting walks of agreeing machines #

    theorem DescriptiveComplexity.Config.map_symm_map {A B : Type} (u : B ≃ A) (c : Config B) :
    map u.symm (map u c) = c
    Dependency graph

    The relational form of a halting walk #

    def DescriptiveComplexity.TMData.RelSame {A : Type} (Q H : A → A → Prop) (T : A → A → A → Prop) (t t' : A) :

    The three relations describe the same configuration at t' as at t.

    Equations
    Instances For
      Dependency graph
      structure DescriptiveComplexity.TMData.RelHaltWalk {A : Type} (M : TMData A) (Q H : A → A → Prop) (T : A → A → A → Prop) :

      A halting walk, guessed as three relations.

      • walk : M.RelWalk Q H T

        The relations are a walk.

      • halt (t t' : A) : SuccPos M.Le M.Posn t t' → (∀ (q : A), Q t q → M.Acc q) → RelSame Q H T t t'

        An accepting configuration is repeated.

      • off (t t₀ : A) : ¬M.Posn t → MinPos M.Le M.Posn t₀ → RelSame Q H T t₀ t

        Times that are not positions carry the initial configuration.

      Instances For
        Dependency graph
        theorem DescriptiveComplexity.TMData.RelHaltWalk.isHaltWalk {A : Type} {M : TMData A} {Q H : A → A → Prop} {T : A → A → A → Prop} (h : M.RelHaltWalk Q H T) :

        A relational halting walk is a halting walk, through the configurations it describes.

        Dependency graph
        theorem DescriptiveComplexity.TMData.IsHaltWalk.relHaltWalk {A : Type} {M : TMData A} {conf : A → Config A} (h : M.IsHaltWalk conf) :
        M.RelHaltWalk (fun (t q : A) => q = (conf t).state) (fun (t p : A) => p = (conf t).head) fun (t p a : A) => a = (conf t).tape p

        A halting walk is a relational halting walk, through the graphs of its configurations.

        Dependency graph

        The kernel #

        noncomputable def DescriptiveComplexity.tqAccAtF {α : Type} (t : α) :

        The state at t is accepting, as a formula.

        Equations
        Instances For
          Dependency graph
          noncomputable def DescriptiveComplexity.tqSameF {α : Type} (t t' : α) :

          The configuration at t' is the one at t, as a formula.

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

            An accepting configuration is repeated.

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

              Times that are not positions carry the initial configuration.

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

                The kernel of the counting problem: the kernel of machine acceptance, and the two clauses that make the tableau of a run unique.

                Equations
                Instances For
                  Dependency graph

                  Runs are the witnesses of the kernel #

                  The guess of the block describing a family of configurations: the graphs of its state, head and tape.

                  Equations
                  Instances For
                    Dependency graph

                    The number of halting walks is the number of witnesses of the kernel.

                    Dependency graph

                    The counting problem #

                    Counting accepting runs: the number of runs of the machine described by the instance that reach an accepting state within as many steps as there are positions, each counted up to the first accepting configuration it reaches, through its layout along the positions (DescriptiveComplexity.TMData.IsHaltWalk). As for DescriptiveComplexity.NTMAccept, the well-formedness promises are folded in: an ill-formed instance has no run.

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

                      The support of counting accepting runs is machine acceptance.

                      Dependency graph

                      Counting accepting runs is in #P: the runs are the witnesses of an existential second-order sentence, the tableau of a run being determined by it.

                      Dependency graph

                      The textbook counting Cook–Levin theorem: counting the accepting runs of a machine reduces, parsimoniously, to counting the models of a CNF formula. As on the decision side, no tableau-to-CNF encoding appears: the Σ₁ definition of a run feeds the generic parsimonious Tseitin reduction.

                      Dependency graph