Documentation

DescriptiveComplexity.Problems.Machine.Fixpoint

Deterministic machine acceptance is in PTIME #

Stage 2b of the machine bridge: a deterministic run is exactly a least fixed point, so DescriptiveComplexity.DTMAccept is FO(LFP) definable – DescriptiveComplexity.dtmAccept_lfpDefinable – and hence, through the formalized translation DescriptiveComplexity.lfpDefinable_iff_sigmaSOHornDefinable, SO-Horn definable, that is, in PTIME (DescriptiveComplexity.dtmAccept_mem_PTIME).

The fixed point #

Three relation variables, indexed by the time positions of the run exactly as in the Σ₁ membership proof of NTMAccept: Q t q (the state at time t), H t p (the head cell) and T t p a (the tape). The rules are the step relation read as an inductive definition:

All the conditions are first-order over the input vocabulary, so they sit in the guards of the Horn clauses; the body atoms are the three variables read at time t, at most four per rule.

The output sentence is where FO(LFP) earns its keep over bare SO-Horn: it states positively that an accepting state occurs in the fixed point – a thing no goal clause can say – conjoined with the first-order promises (DescriptiveComplexity.TMData.WellFormed, DescriptiveComplexity.TMData.Deterministic) that DTMAccept folds into its yes-instances.

Why determinism is what makes this correct #

The fixed point derives everything any run does. For a deterministic machine the run from the (unique) initial configuration is unique (DescriptiveComplexity.TMData.stepsIn_functional), so the derived atoms describe it and nothing else: soundness (DescriptiveComplexity.DTFix.derives_sound) is an induction on derivations, completeness (DescriptiveComplexity.DTFix.derivedAt_of_run) an induction along the rank of the time position, and together they make the output read exactly “the machine accepts within its budget”.

@[reducible, inline]

The ordered expansion of the machine vocabulary.

Equations
Instances For
    Dependency graph

    Guards over the machine vocabulary #

    @[reducible, inline]

    The position symbol over the ordered expansion.

    Equations
    Instances For
      Dependency graph
      @[reducible, inline]

      The transition symbol over the ordered expansion.

      Equations
      Instances For
        Dependency graph
        @[reducible, inline]

        The start-state symbol over the ordered expansion.

        Equations
        Instances For
          Dependency graph
          @[reducible, inline]

          The accepting-state symbol over the ordered expansion.

          Equations
          Instances For
            Dependency graph
            @[reducible, inline]

            The blank symbol over the ordered expansion.

            Equations
            Instances For
              Dependency graph
              @[reducible, inline]

              The move-right symbol over the ordered expansion.

              Equations
              Instances For
                Dependency graph
                @[reducible, inline]

                The machine's own order symbol over the ordered expansion.

                Equations
                Instances For
                  Dependency graph
                  @[reducible, inline]

                  The transition-source symbol over the ordered expansion.

                  Equations
                  Instances For
                    Dependency graph
                    @[reducible, inline]

                    The transition-read symbol over the ordered expansion.

                    Equations
                    Instances For
                      Dependency graph
                      @[reducible, inline]

                      The transition-destination symbol over the ordered expansion.

                      Equations
                      Instances For
                        Dependency graph
                        @[reducible, inline]

                        The transition-write symbol over the ordered expansion.

                        Equations
                        Instances For
                          Dependency graph
                          @[reducible, inline]

                          The input symbol over the ordered expansion.

                          Equations
                          Instances For
                            Dependency graph
                            Dependency graph
                            noncomputable def DescriptiveComplexity.DTFix.trG {α : Type} (x : α) :

                            x is a transition, as a guard.

                            Equations
                            Instances For
                              Dependency graph
                              Dependency graph
                              noncomputable def DescriptiveComplexity.DTFix.accG {α : Type} (x : α) :

                              x is an accepting state, as a guard.

                              Equations
                              Instances For
                                Dependency graph
                                Dependency graph
                                noncomputable def DescriptiveComplexity.DTFix.rightG {α : Type} (x : α) :

                                The transition x moves the head right, as a guard.

                                Equations
                                Instances For
                                  Dependency graph
                                  noncomputable def DescriptiveComplexity.DTFix.leG {α : Type} (x y : α) :

                                  x ≤ y in the machine's own order, as a guard.

                                  Equations
                                  Instances For
                                    Dependency graph
                                    noncomputable def DescriptiveComplexity.DTFix.srcG {α : Type} (x y : α) :

                                    The transition x applies in the state y, as a guard.

                                    Equations
                                    Instances For
                                      Dependency graph
                                      noncomputable def DescriptiveComplexity.DTFix.readG {α : Type} (x y : α) :

                                      The transition x reads the symbol y, as a guard.

                                      Equations
                                      Instances For
                                        Dependency graph
                                        noncomputable def DescriptiveComplexity.DTFix.dstG {α : Type} (x y : α) :

                                        The transition x moves to the state y, as a guard.

                                        Equations
                                        Instances For
                                          Dependency graph
                                          noncomputable def DescriptiveComplexity.DTFix.writeG {α : Type} (x y : α) :

                                          The transition x writes the symbol y, as a guard.

                                          Equations
                                          Instances For
                                            Dependency graph
                                            noncomputable def DescriptiveComplexity.DTFix.inpG {α : Type} (x y : α) :

                                            The cell x initially holds the symbol y, as a guard.

                                            Equations
                                            Instances For
                                              Dependency graph
                                              noncomputable def DescriptiveComplexity.DTFix.eqG {α : Type} (x y : α) :

                                              x = y, as a guard.

                                              Equations
                                              Instances For
                                                Dependency graph
                                                Dependency graph
                                                noncomputable def DescriptiveComplexity.DTFix.minPosG {α : Type} (x : α) :

                                                x is the lowest position, as a guard.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  Dependency graph
                                                  noncomputable def DescriptiveComplexity.DTFix.succPosG {α : Type} (x y : α) :

                                                  y is the position immediately above x, as a guard.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For
                                                    Dependency graph
                                                    noncomputable def DescriptiveComplexity.DTFix.initTapeG {α : Type} (x y : α) :

                                                    The cell x initially holds the symbol y: the input where defined, the blank elsewhere.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      Dependency graph
                                                      noncomputable def DescriptiveComplexity.DTFix.existsDstG {α : Type} (x : α) :

                                                      The transition x has a destination, as a guard.

                                                      Equations
                                                      Instances For
                                                        Dependency graph
                                                        noncomputable def DescriptiveComplexity.DTFix.existsWriteG {α : Type} (x : α) :

                                                        The transition x has a written symbol, as a guard.

                                                        Equations
                                                        Instances For
                                                          Dependency graph
                                                          noncomputable def DescriptiveComplexity.DTFix.canMoveG {α : Type} (x h : α) :

                                                          The transition x, with the head at h, can move: there is a neighbour in its direction. Without this in every step rule the fixed point would run past a halt.

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

                                                            Realization of the guards #

                                                            @[simp]
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_trG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x : α) :
                                                            (trG x).Realize v TMTr (v x)
                                                            Dependency graph
                                                            Dependency graph
                                                            @[simp]
                                                            Dependency graph
                                                            Dependency graph
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_leG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (leG x y).Realize v TMLe (v x) (v y)
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_srcG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (srcG x y).Realize v TMSrc (v x) (v y)
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_readG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (readG x y).Realize v TMRead (v x) (v y)
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_dstG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (dstG x y).Realize v TMDst (v x) (v y)
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_writeG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (writeG x y).Realize v TMWrite (v x) (v y)
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_inpG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (inpG x y).Realize v TMInp (v x) (v y)
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_eqG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (eqG x y).Realize v v x = v y
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_neG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (neG x y).Realize v v x v y
                                                            Dependency graph
                                                            Dependency graph
                                                            @[simp]
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_initTapeG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x y : α) :
                                                            (initTapeG x y).Realize v (tmData A).InitTape (v x) (v y)
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_existsDstG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x : α) :
                                                            (existsDstG x).Realize v ∃ (q : A), TMDst (v x) q
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_existsWriteG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x : α) :
                                                            (existsWriteG x).Realize v ∃ (a : A), TMWrite (v x) a
                                                            Dependency graph
                                                            @[simp]
                                                            theorem DescriptiveComplexity.DTFix.realize_canMoveG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {α : Type} {v : αA} (x h : α) :
                                                            (canMoveG x h).Realize v (TMRight (v x) ∃ (p : A), SuccPos TMLe TMPosn (v h) p) ¬TMRight (v x) ∃ (p : A), SuccPos TMLe TMPosn p (v h)
                                                            Dependency graph

                                                            The promises, as sentences #

                                                            Dependency graph

                                                            Transitivity of the machine's order.

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

                                                              Antisymmetry of the machine's order.

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

                                                                Totality of the machine's order.

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

                                                                  The input is functional.

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

                                                                    The blank symbol is unique.

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

                                                                      The start state is unique.

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

                                                                        At most one transition applies in a given state on a given symbol.

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

                                                                          The destination of a transition is unique.

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

                                                                            The written symbol of a transition is unique.

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

                                                                              Well-formedness, as a sentence.

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

                                                                                Determinism, as a sentence.

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

                                                                                  The block and the rules #

                                                                                  The relation variables of the fixed point: the state Q t q, the head H t p and the tape T t p a of the run, indexed by the time positions.

                                                                                  Equations
                                                                                  Instances For
                                                                                    Dependency graph

                                                                                    The atom Q (xᵢ, xⱼ).

                                                                                    Equations
                                                                                    Instances For
                                                                                      Dependency graph

                                                                                      The atom H (xᵢ, xⱼ).

                                                                                      Equations
                                                                                      Instances For
                                                                                        Dependency graph

                                                                                        The atom T (xᵢ, xⱼ, xₗ).

                                                                                        Equations
                                                                                        Instances For
                                                                                          Dependency graph

                                                                                          Initial state: at the lowest position, a start state.

                                                                                          Equations
                                                                                          Instances For
                                                                                            Dependency graph

                                                                                            Initial head: at the lowest position, on the lowest position – times and cells being the same sort.

                                                                                            Equations
                                                                                            Instances For
                                                                                              Dependency graph

                                                                                              Initial tape: the input, with the blank elsewhere.

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

                                                                                                The shared core of the step rules: consecutive times, an applicable transition that can fire – a destination and a written symbol exist.

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

                                                                                                  The shared body of the step rules: the state, the head, and the symbol under the head, at the current time.

                                                                                                  Equations
                                                                                                  Instances For
                                                                                                    Dependency graph

                                                                                                    Step, the state: the transition's destination.

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

                                                                                                      Step, the head, moving right.

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

                                                                                                        Step, the head, moving left.

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

                                                                                                          Step, the written cell.

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

                                                                                                            Step, the frame: every other cell is unchanged.

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

                                                                                                              The rules of the fixed point: the step relation of the machine, read as an inductive definition along the time positions.

                                                                                                              Equations
                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                              Instances For
                                                                                                                Dependency graph
                                                                                                                theorem DescriptiveComplexity.DTFix.realize_dtCoreG {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {v : Fin 9A} :
                                                                                                                dtCoreG.Realize v SuccPos TMLe TMPosn (v 0) (v 1) TMTr (v 2) TMSrc (v 2) (v 3) TMRead (v 2) (v 4) (∃ (q : A), TMDst (v 2) q) ∃ (a : A), TMWrite (v 2) a
                                                                                                                Dependency graph

                                                                                                                The output sentence #

                                                                                                                The acceptance atom of the output, over two variables.

                                                                                                                Equations
                                                                                                                Instances For
                                                                                                                  Dependency graph

                                                                                                                  The positive part of the output: some time carries an accepting state in the fixed point – the statement no goal clause of a Horn program can make.

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

                                                                                                                    The output sentence: the promises, and acceptance at the fixed point.

                                                                                                                    Equations
                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                    Instances For
                                                                                                                      Dependency graph
                                                                                                                      theorem DescriptiveComplexity.DTFix.dtAccAt_holds {A : Type} (ρ : dtBlock.Assignment A) (w : Fin 2A) :
                                                                                                                      dtAccAt.Holds ρ w ρ (some true) ![w 0, w 1]

                                                                                                                      Reading the acceptance atom off an assignment.

                                                                                                                      Dependency graph
                                                                                                                      Dependency graph
                                                                                                                      Dependency graph

                                                                                                                      Correctness #

                                                                                                                      Soundness – everything derived is true of the (unique) run – is one induction on derivations; completeness – everything true of the run is derived – one induction along the rank of the time position. Determinism enters exactly where the plan said it would: a derived state atom carries some run to its time, the head and tape atoms hold of every run to theirs, and uniqueness of the run (DescriptiveComplexity.TMData.stepsIn_functional) is what lets the two readings meet in the step cases.

                                                                                                                      Dependency graph
                                                                                                                      Dependency graph
                                                                                                                      Dependency graph
                                                                                                                      theorem DescriptiveComplexity.DTFix.dq_iff {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {v : Fin 9A} {i j : Fin 9} :
                                                                                                                      Derives dtRules (qAt i j).idx, fun (l : Fin (dtBlock.arity (qAt i j).idx)) => v ((qAt i j).args l) DQ (v i) (v j)
                                                                                                                      Dependency graph
                                                                                                                      theorem DescriptiveComplexity.DTFix.dh_iff {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {v : Fin 9A} {i j : Fin 9} :
                                                                                                                      Derives dtRules (hAt i j).idx, fun (l : Fin (dtBlock.arity (hAt i j).idx)) => v ((hAt i j).args l) DH (v i) (v j)
                                                                                                                      Dependency graph
                                                                                                                      theorem DescriptiveComplexity.DTFix.dt_iff {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] {v : Fin 9A} {i j l : Fin 9} :
                                                                                                                      Derives dtRules (tAt i j l).idx, fun (m : Fin (dtBlock.arity (tAt i j l).idx)) => v ((tAt i j l).args m) DT (v i) (v j) (v l)
                                                                                                                      Dependency graph

                                                                                                                      A position of rank 0 is the lowest.

                                                                                                                      Dependency graph

                                                                                                                      Every rank below the position count is realized by a position: this is where the run's -indexed clock is matched to the time positions.

                                                                                                                      Dependency graph

                                                                                                                      The meaning of a state atom: some run reaches its time in that state.

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

                                                                                                                        The meaning of a head atom: every run to its time has the head there.

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

                                                                                                                          The meaning of a tape atom: every run to its time reads that symbol.

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

                                                                                                                            What a derived atom says about the run: a state atom carries some run to its time, a head or tape atom holds of every run to its time. The asymmetry is deliberate – the head and tape rules alone cannot certify a run exists, and the state rules can.

                                                                                                                            Equations
                                                                                                                            Instances For
                                                                                                                              Dependency graph

                                                                                                                              Soundness: every derived atom is true of the run. Induction on derivations, one case per rule; in the step cases the step the rule took is compared with the run's own step through determinism.

                                                                                                                              Dependency graph
                                                                                                                              theorem DescriptiveComplexity.DTFix.derivedAt_of_run {A : Type} [FirstOrder.Language.turing.Structure A] [LinearOrder A] [Finite A] (hwf : (tmData A).WellFormed) {c₀ : Config A} (hinit : (tmData A).IsInit c₀) (k : ) (t : A) :
                                                                                                                              TMPosn tbitRank TMLe TMPosn t = k∀ (d : Config A), (tmData A).StepsIn k c₀ dDQ t d.state DH t d.head ∀ (p : A), DT t p (d.tape p)

                                                                                                                              Completeness: the run is derived, rank by rank. Determinism plays no role in this direction – the rules fire on whatever run is given.

                                                                                                                              Dependency graph

                                                                                                                              The machine accepts exactly when the fixed point contains an accepting state: the two inductions above, glued by the surjectivity of the rank below the position count.

                                                                                                                              Dependency graph

                                                                                                                              Deterministic machine acceptance is FO(LFP) definable: the run is the least fixed point of the step rules, and the output states the promises and that an accepting state occurs.

                                                                                                                              Dependency graph

                                                                                                                              Deterministic machine acceptance is in PTIME, through the formalized translation of FO(LFP) into the Horn fragment.

                                                                                                                              Dependency graph