Documentation

DescriptiveComplexity.Problems.Pcp.Hardness.ConfigWord

Configurations as words: the rewriting system of a machine #

The middle layer of the RE-hardness of DescriptiveComplexity.PCP: a machine on the unbounded tape of DescriptiveComplexity.MachinesUnbounded accepts exactly when the string-rewriting system read off its transition table derives the halting word from the start word (DescriptiveComplexity.HaltPcp.acceptsU_iff_derives). Composed with DescriptiveComplexity.Pcp.History.hasMatch_iff one file up, this makes the domino system of the machine decide its acceptance; the sibling Interp file draws that domino system as a first-order interpretation.

The words #

A configuration is written as a word over DescriptiveComplexity.HaltPcp.TapeLetter: a left endmarker, the symbols of a finite window of consecutive tape cells with the state letter wedged in front of the head's cell, and a right endmarker (DescriptiveComplexity.HaltPcp.Represents). The window must contain the head and every non-blank cell, and may contain any amount of blank padding beyond them – a configuration has many words, which is what lets the rules extend the window on demand.

The format is kept strict: the state letter always has a symbol letter to its right (the cell the head is on). Each rule of DescriptiveComplexity.HaltPcp.MRule preserves strictness on its own – the boundary variants of the two moves extend the window by one blank cell in the same rewriting step – so every word of a derivation between the boot and the halting letter is a configuration word, and the backward reading of a derivation is a plain case analysis on the rule applied.

The rules #

No letter of a configuration word is a boot or halting letter, so the boot rule fires only on the start word and the erasers only after an accepting state was seen: the phases of a derivation cannot mix.

The alphabet #

The alphabet configurations are written in: the two endmarkers of the window, the boot letter standing in the state slot of the start word, the halting letter, and a symbol letter and a state letter per element of the machine.

  • lft {A : Type} : TapeLetter A

    The left endmarker of the window.

  • rgt {A : Type} : TapeLetter A

    The right endmarker of the window.

  • boot {A : Type} : TapeLetter A

    The boot letter, in the state slot of the start word.

  • halt {A : Type} : TapeLetter A

    The halting letter, the one-letter word a derivation must reach.

  • sym {A : Type} : ATapeLetter A

    The contents of a tape cell.

  • state {A : Type} : ATapeLetter A

    The current state, wedged before the head's cell.

Instances For
    Dependency graph

    Being a state letter, as a Boolean – the alphabet has no decidable equality to offer, but the constructor is decidable on its own.

    Equations
    Instances For
      Dependency graph
      theorem DescriptiveComplexity.HaltPcp.TapeLetter.absurd_of_ne {A : Type} {P : Prop} {a b : TapeLetter A} (h : a = b) (hne : a b := by simp) :
      P

      A letter of the words below is never a boot or halting letter; this is the shape the case analyses need.

      Dependency graph

      The rules #

      The rewriting system of a machine: the two moves with their boundary variants, the boot rule, and the halting rule with its erasers. The transition performing a move is existentially quantified in the side condition, since its attributes are relations rather than functions; the letters of the rule are the attribute values themselves.

      Instances For
        Dependency graph
        theorem DescriptiveComplexity.HaltPcp.mRule_ne {A : Type} {M : TMData A} {l r : List (TapeLetter A)} (h : MRule M l r) :

        No side of a rule is empty – the promise the domino construction requires.

        Dependency graph

        The order of the cells #

        The cells ℤ × A are ordered lexicographically – pages first, the machine's order on the offsets inside a page – and one DescriptiveComplexity.TMData.SuccCell step increases that order strictly. This is what makes a window a duplicate-free list and puts a cell entering it outside of it.

        The strict lexicographic order on cells.

        Equations
        Instances For
          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.CellLt.trans {A : Type} {M : TMData A} (hlin : IsLinOrd M.Le) {x y z : × A} (hxy : CellLt M x y) (hyz : CellLt M y z) :
          CellLt M x z
          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.CellLt.ne {A : Type} {M : TMData A} {x y : × A} (h : CellLt M x y) :
          x y
          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.cellLt_of_succCell {A : Type} {M : TMData A} {x y : × A} (h : M.SuccCell x y) :
          CellLt M x y
          Dependency graph

          A chain of successive cells is duplicate-free and increasing.

          Dependency graph

          Every cell has a next one and a previous one #

          On a well-formed machine with at least one position, the strip of pages is unbounded in both directions: the mirror-image lemmas of DescriptiveComplexity.exists_predPos supply the missing successor facts.

          theorem DescriptiveComplexity.HaltPcp.succPos_reverse {A : Type} {Le : AAProp} {Posn : AProp} {p q : A} :
          SuccPos (fun (a b : A) => Le b a) Posn p q SuccPos Le Posn q p

          SuccPos mirrors along the reversed order.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.exists_succPos {A : Type} [Finite A] {Le : AAProp} {Posn : AProp} (hlin : IsLinOrd Le) {p : A} (hp : Posn p) (hmax : ¬MaxPos Le Posn p) :
          ∃ (q : A), SuccPos Le Posn p q

          Every position that is not the highest has one immediately above it.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.exists_succCell {A : Type} {M : TMData A} [Finite A] (hwf : M.WellFormed) {x : × A} (hx : M.Posn x.2) :
          ∃ (y : × A), M.SuccCell x y

          Every cell over a position has a next cell.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.exists_predCell {A : Type} {M : TMData A} [Finite A] (hwf : M.WellFormed) {x : × A} (hx : M.Posn x.2) :
          ∃ (y : × A), M.SuccCell y x

          Every cell over a position has a previous cell.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.minPos_unique {A : Type} {Le : AAProp} {Posn : AProp} (hlin : IsLinOrd Le) {p q : A} (hp : MinPos Le Posn p) (hq : MinPos Le Posn q) :
          p = q

          Lowest positions are unique.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.maxPos_unique {A : Type} {Le : AAProp} {Posn : AProp} (hlin : IsLinOrd Le) {p q : A} (hp : MaxPos Le Posn p) (hq : MaxPos Le Posn q) :
          p = q

          Highest positions are unique.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.succPos_right_unique {A : Type} {Le : AAProp} {Posn : AProp} (hlin : IsLinOrd Le) {p q q' : A} (h : SuccPos Le Posn p q) (h' : SuccPos Le Posn p q') :
          q = q'

          The element immediately above a given one is unique.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.succPos_not_maxPos {A : Type} {Le : AAProp} {Posn : AProp} (hlin : IsLinOrd Le) {p q : A} (h : SuccPos Le Posn p q) :
          ¬MaxPos Le Posn p

          A position with a successor is not the highest.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.succPos_not_minPos {A : Type} {Le : AAProp} {Posn : AProp} (hlin : IsLinOrd Le) {p q : A} (h : SuccPos Le Posn p q) :
          ¬MinPos Le Posn q

          A position with a predecessor is not the lowest.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.succCell_right_unique {A : Type} {M : TMData A} (hwf : M.WellFormed) {x y y' : × A} (h : M.SuccCell x y) (h' : M.SuccCell x y') :
          y = y'

          The cell after a given one is unique.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.succCell_left_unique {A : Type} {M : TMData A} (hwf : M.WellFormed) {x x' y : × A} (h : M.SuccCell x y) (h' : M.SuccCell x' y) :
          x = x'

          The cell before a given one is unique.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.posn_of_succCell {A : Type} {M : TMData A} {x y : × A} (h : M.SuccCell x y) :
          M.Posn y.2

          The successor cell keeps to the positions.

          Dependency graph
          theorem DescriptiveComplexity.HaltPcp.posn_of_succCell_left {A : Type} {M : TMData A} {x y : × A} (h : M.SuccCell x y) :
          M.Posn x.2

          The previous cell keeps to the positions, too.

          Dependency graph

          Configuration words #

          A configuration is written as a window of consecutive cells: the symbols they hold, with the state letter wedged before the head's cell and an endmarker at each end. The window contains the head and every non-blank cell over a position; it may contain blank padding beyond them, so a configuration has many words.

          The symbol letters of a list of cells.

          Equations
          Instances For
            Dependency graph
            Dependency graph
            @[simp]
            theorem DescriptiveComplexity.HaltPcp.cellSyms_cons {A : Type} (c : ConfigU A) (x : × A) (l : List ( × A)) :
            Dependency graph
            @[simp]
            theorem DescriptiveComplexity.HaltPcp.cellSyms_append {A : Type} (c : ConfigU A) (l l' : List ( × A)) :
            cellSyms c (l ++ l') = cellSyms c l ++ cellSyms c l'
            Dependency graph
            theorem DescriptiveComplexity.HaltPcp.cellSyms_congr {A : Type} {c c' : ConfigU A} {l : List ( × A)} (h : xl, c'.tape x = c.tape x) :

            Two configurations agreeing on a window write it the same way.

            Dependency graph

            w is a word of the configuration c: the symbols of a window of consecutive cells between the two endmarkers, the state letter wedged before the head's cell. The window consists of cells over positions, contains the head, and every cell over a position outside it is blank.

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

              Letters of a configuration word #

              A configuration word carries no boot and no halting letter, and exactly one state letter; these two facts drive the case analysis on a rewriting step.

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

              A word without state letters is exactly a word of vanishing state count.

              Dependency graph
              theorem DescriptiveComplexity.HaltPcp.state_align {A : Type} {u₁ u₂ v₁ v₂ : List (TapeLetter A)} {q₁ q₂ : A} :
              u₁ ++ TapeLetter.state q₁ :: v₁ = u₂ ++ TapeLetter.state q₂ :: v₂(∀ xu₁, x.isState = false)(∀ xu₂, x.isState = false)u₁ = u₂ q₁ = q₂ v₁ = v₂

              Alignment at the state letter: two decompositions of one word around a state letter, neither prefix carrying one, agree.

              Dependency graph

              The prefix of a configuration word carries no state letter.

              Dependency graph

              No boot letter and no halting letter occurs in a configuration word.

              Dependency graph
              theorem DescriptiveComplexity.HaltPcp.window_lt {A : Type} {M : TMData A} {ls rs : List ( × A)} {h : × A} (hlin : IsLinOrd M.Le) (hchain : List.IsChain M.SuccCell (ls ++ h :: rs)) :
              (∀ zls, CellLt M z h) zrs, CellLt M h z

              The two halves of a window sit strictly below and strictly above the head.

              Dependency graph

              A configuration word has exactly one state letter.

              Dependency graph

              Reading a rewriting step off a configuration word #

              The inversion at the heart of the backward direction: a rewriting step on a configuration word either simulates one machine step or fires the halting rule on the current – hence accepting – state. Each move rule carries exactly one state letter on its left-hand side, and a configuration word carries exactly one, so the rule can only apply at the head.

              theorem DescriptiveComplexity.HaltPcp.step_inversion {A : Type} {M : TMData A} [Finite A] (hwf : M.WellFormed) {w w₁ : List (TapeLetter A)} {c : ConfigU A} (hrep : Represents M w c) (hstep : Pcp.History.Step (MRule M) w w₁) :
              (∃ (c' : ConfigU A), M.StepU c c' Represents M w₁ c') M.Acc c.state
              Dependency graph

              Writing a machine step as a rewriting step #

              The forward direction: one machine step is one rewriting step – the boundary variants of the moves extend the window in the same stroke, so no separate padding step is ever needed.

              theorem DescriptiveComplexity.HaltPcp.exists_step_of_stepU {A : Type} {M : TMData A} [Finite A] (hwf : M.WellFormed) {w : List (TapeLetter A)} {c c' : ConfigU A} (hrep : Represents M w c) (h : M.StepU c c') :
              ∃ (w' : List (TapeLetter A)), Pcp.History.Step (MRule M) w w' Represents M w' c'
              Dependency graph

              Whole runs, and the halting phase #

              theorem DescriptiveComplexity.HaltPcp.derives_of_run {A : Type} {M : TMData A} [Finite A] (hwf : M.WellFormed) {n : } {c c' : ConfigU A} :
              M.StepsInU n c c'∀ {w : List (TapeLetter A)}, Represents M w c∃ (w' : List (TapeLetter A)), Pcp.History.Derives (MRule M) w w' Represents M w' c'

              A run of the machine is a derivation between words of its endpoints.

              Dependency graph

              The halting letter melts a block of symbols to its left away.

              Dependency graph

              The halting letter melts a block of symbols to its right away.

              Dependency graph

              From an accepting configuration the derivation closes: the state letter becomes the halting letter, which then swallows the whole word.

              Dependency graph

              The start word #

              The start word writes the input page between the endmarkers, with the boot letter in the state slot; the boot rule turns it into a word of an initial configuration. The page is read along an enumeration of the positions in the machine's order.

              ps enumerates the positions, in the machine's order.

              Equations
              Instances For
                Dependency graph

                The start word of an input page: endmarkers, the boot letter, and the symbols of the page.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  Dependency graph
                  theorem DescriptiveComplexity.HaltPcp.IsPosEnum.ne_nil {A : Type} {M : TMData A} (hwf : M.WellFormed) {ps : List A} (hps : IsPosEnum M ps) :
                  ps []

                  A machine with a position has a nonempty enumeration.

                  Dependency graph
                  theorem DescriptiveComplexity.HaltPcp.IsPosEnum.isChain {A : Type} {M : TMData A} (hlin : IsLinOrd M.Le) {ps : List A} (hps : IsPosEnum M ps) :

                  Consecutive entries of an enumeration are consecutive positions.

                  Dependency graph
                  theorem DescriptiveComplexity.HaltPcp.IsPosEnum.head_minPos {A : Type} {M : TMData A} (hlin : IsLinOrd M.Le) {p : A} {pr : List A} (hps : IsPosEnum M (p :: pr)) :
                  MinPos M.Le M.Posn p

                  The first entry of an enumeration is the lowest position.

                  Dependency graph
                  theorem DescriptiveComplexity.HaltPcp.exists_isInitU {A : Type} {M : TMData A} [Finite A] (hwf : M.WellFormed) {q₀ : A} (hq : M.Start q₀) :
                  ∃ (c₀ : ConfigU A), M.IsInitU c₀ c₀.state = q₀

                  A well-formed machine with a start state has an initial configuration on the unbounded tape, its input page filled by choice and the rest blank.

                  Dependency graph
                  theorem DescriptiveComplexity.HaltPcp.represents_of_isInitU {A : Type} {M : TMData A} [Finite A] (hwf : M.WellFormed) {ps inp : List A} (hps : IsPosEnum M ps) (hinp : List.Forall₂ M.InitTape ps inp) {c₀ : ConfigU A} (hinit : M.IsInitU c₀) :

                  The word of an initial configuration: the input page between the endmarkers, the state in front of its first cell.

                  Dependency graph

                  No letter of a start word is a state or halting letter, and its only boot letter is the one in the state slot.

                  Dependency graph

                  The equivalence #

                  theorem DescriptiveComplexity.HaltPcp.acceptsU_of_derives {A : Type} {M : TMData A} [Finite A] (hwf : M.WellFormed) {w : List (TapeLetter A)} (hder : Pcp.History.Derives (MRule M) w [TapeLetter.halt]) (c : ConfigU A) :
                  Represents M w c∃ (c' : ConfigU A) (n : ), M.StepsInU n c c' M.Acc c'.state

                  The backward reading: a derivation from a configuration word to the halting word yields an accepting run from that configuration.

                  Dependency graph

                  Acceptance is derivability: the machine accepts exactly when the rewriting system derives the halting word from the start word.

                  Dependency graph

                  Acceptance is having a match: the domino system of the machine's rewriting rules has a match exactly when the machine accepts.

                  Dependency graph