Documentation

DescriptiveComplexity.MachinesAlt

Alternating Turing machines over a universe, without a vocabulary #

The semantics half of the machine bridge for the polynomial hierarchy: what it means for an alternating Turing machine, presented as relations on a universe, to accept. As in DescriptiveComplexity.Machines no vocabulary appears, so the reductions – which build machines rather than read them – can reason about acceptance without unfolding any RelMap.

The model #

DescriptiveComplexity.ATMData is DescriptiveComplexity.TMData together with one further family of marks, Blk j q: the state q belongs to the j-th quantifier block. Two conventions fix the game the marks describe.

With one block the model is the nondeterministic one: AltAcc start n c unfolds to “some run of at most n steps from c reaches an accepting state”, so DescriptiveComplexity.ATMData.AltAccepts at k = 1 is DescriptiveComplexity.TMData.Accepts.

The alternation bound #

Nothing above bounds the number of alternations; the bound is DescriptiveComplexity.ATMData.BlocksWellFormed, folded into the yes-instances of the decision problem exactly as linearity of the order is: every state carries exactly one of the k marks, a transition raises the block index by 0 or 1, and a start state is in block 0. All three are first-order for a fixed k – the second because it is a condition on a single transition, which is what makes “at most k - 1 alternations” checkable by the kernel of a Σₖ definition rather than by an inspection of runs. The last two together make a run pass through the blocks in succession, starting at the first, which is what lets it be read as k rounds of a game with the right player in each.

Transport #

DescriptiveComplexity.ATMData.AltAgree records that two alternating machines over different universes correspond along an equivalence, and the lemmas below transport acceptance along it – all the isomorphism-invariance proof of the decision problem needs.

An alternating Turing machine presented as relations on a universe: a machine in the sense of DescriptiveComplexity.TMData, together with marks splitting its states into quantifier blocks.

Instances For
    Dependency graph

    The polarity of the j-th quantifier block of a prefix starting with polarity start: true for an existential block, false for a universal one. The polarities alternate, so the parity of j decides.

    Equations
    Instances For
      Dependency graph
      @[simp]
      theorem DescriptiveComplexity.blockPol_zero (start : Bool) :
      blockPol start 0 = start
      Dependency graph
      theorem DescriptiveComplexity.blockPol_succ (start : Bool) (j : ) :
      blockPol start (j + 1) = !blockPol start j

      The polarities of consecutive blocks are opposite.

      Dependency graph
      def DescriptiveComplexity.guardQ (pol : Bool) {α : Type} (C P : αProp) :

      Quantification with a polarity, guarded. Existentially, the guard is conjoined; universally it is assumed – and, in the same breath, required to be satisfiable by something. That extra clause is the “a stuck universal state rejects” convention of the module docstring, at the level of quantifiers: a universal player with no legal move loses rather than winning vacuously.

      Equations
      Instances For
        Dependency graph
        theorem DescriptiveComplexity.guardQ_true {α : Type} (C P : αProp) :
        guardQ true C P ∃ (a : α), C a P a
        Dependency graph
        theorem DescriptiveComplexity.guardQ_false {α : Type} (C P : αProp) :
        guardQ false C P (∃ (a : α), C a) ∀ (a : α), C aP a
        Dependency graph
        theorem DescriptiveComplexity.guardQ_congr (pol : Bool) {α : Type} {C C' P P' : αProp} (hC : ∀ (a : α), C a C' a) (hP : ∀ (a : α), C a → (P a P' a)) :
        guardQ pol C P guardQ pol C' P'

        Guarded quantification only depends on its two predicates up to pointwise equivalence.

        Dependency graph

        The players #

        def DescriptiveComplexity.ATMData.BlkLt {A : Type} (M : ATMData A) (i : ) (q : A) :

        The state q belongs to a block below i.

        Equations
        Instances For
          Dependency graph
          def DescriptiveComplexity.ATMData.IsUniv {A : Type} (M : ATMData A) (start : Bool) (q : A) :

          The state q is universal: it carries the mark of a block whose polarity is universal, so the moves out of it belong to the universal player.

          Equations
          Instances For
            Dependency graph

            No step is available from the configuration c: the machine stops there. Whether that is an acceptance depends only on the state, never on the block – see the module docstring.

            Equations
            Instances For
              Dependency graph

              Alternating acceptance #

              def DescriptiveComplexity.ATMData.AltAcc {A : Type} (M : ATMData A) (start : Bool) :
              Config AProp

              Alternating acceptance within a budget. M.AltAcc start n c says the configuration c accepts with n steps to spare: an accepting state accepts outright, an existential configuration accepts when some successor does, and a universal one when it has a successor and every successor accepts.

              The budget recurses, so the definition is a Lean-level recursion rather than a fixed point, and DescriptiveComplexity.ATMData.AltAccepts cashes it in at the number of positions – the same unary bound as DescriptiveComplexity.TMData.Accepts.

              Equations
              • One or more equations did not get rendered due to their size.
              • M.AltAcc start 0 x✝ = M.Acc x✝.state
              Instances For
                Dependency graph

                Alternating acceptance: an initial configuration accepts within as many steps as there are positions – chosen by the player of block 0, which is what DescriptiveComplexity.guardQ at the polarity start says.

                The residual freedom in the initial configuration (a machine may have several start states, and its input may leave cells to the blank) belongs to the same player as the first move, since it is the first move; at start = true this is the ∃ c₀ of DescriptiveComplexity.TMData.Accepts, which the problem therefore specializes to when every state lies in an existential block.

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

                  The block structure is well formed, in the style of DescriptiveComplexity.TMData.WellFormed: every state carries exactly one of the k block marks, and every transition either stays in its block or moves to the next one. The second clause is what bounds the number of alternations by k - 1, and it is a condition on a single transition, hence first-order.

                  The blocks are entered in order – a transition may not skip one, and the run starts in block 0 – so that the phases of a run are the blocks in succession. Skipping would be harmless for the number of alternations but not for the reading of the run as k rounds of a game: the round of a player would no longer be the block whose moves it makes, and a run starting above block 0 would hand the choice of its initial configuration to the wrong player. Padding a machine that skips is a matter of inserting one state per skipped block.

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

                    Elementary properties #

                    theorem DescriptiveComplexity.ATMData.stuck_iff_not_exists_step {A : Type} {M : ATMData A} {c : Config A} :
                    M.Stuck c ¬∃ (c' : Config A), M.Step c c'

                    Being stuck is the negation of having a successor.

                    Dependency graph
                    theorem DescriptiveComplexity.ATMData.altAcc_succ {A : Type} {M : ATMData A} {start : Bool} (n : ) {c : Config A} :
                    M.AltAcc start n cM.AltAcc start (n + 1) c

                    Spare budget is never harmful: one more step to spare cannot turn an accepting configuration into a rejecting one.

                    Dependency graph
                    theorem DescriptiveComplexity.ATMData.altAcc_mono {A : Type} {M : ATMData A} {start : Bool} {m n : } :
                    n m∀ {c : Config A}, M.AltAcc start n cM.AltAcc start m c

                    Acceptance is monotone in the budget.

                    Dependency graph
                    theorem DescriptiveComplexity.ATMData.altAcc_of_acc {A : Type} {M : ATMData A} {start : Bool} {n : } {c : Config A} (h : M.Acc c.state) :
                    M.AltAcc start n c

                    An accepting state accepts, whatever the budget.

                    Dependency graph
                    theorem DescriptiveComplexity.ATMData.altAcc_succ_iff {A : Type} {M : ATMData A} {start : Bool} {n : } {c : Config A} :
                    M.AltAcc start (n + 1) c M.Acc c.state (M.IsUniv start c.state (∃ (c' : Config A), M.Step c c') ∀ (c' : Config A), M.Step c c'M.AltAcc start n c') ¬M.IsUniv start c.state ∃ (c' : Config A), M.Step c c' M.AltAcc start n c'

                    Unfolding one step, in the form the proofs use: with a positive budget an accepting configuration either is accepting outright, or hands the choice to the player owning its state.

                    Dependency graph
                    theorem DescriptiveComplexity.ATMData.altAcc_iff_stepsIn {A : Type} {M : ATMData A} {start : Bool} (hex : ∀ (q : A), ¬M.IsUniv start q) (n : ) (c : Config A) :
                    M.AltAcc start n c mn, ∃ (d : Config A), M.StepsIn m c d M.Acc d.state

                    With no universal state the model is the nondeterministic one: the recursion unfolds to “some run of at most n steps reaches an accepting state”. This is what makes the one-block problem the machine problem of DescriptiveComplexity.Machines again, and it is why the alternating model is a conservative extension rather than a new one.

                    Dependency graph
                    theorem DescriptiveComplexity.ATMData.altAccepts_true_iff_accepts {A : Type} {M : ATMData A} [Finite A] (hex : ∀ (q : A), ¬M.IsUniv true q) (hne : ∃ (p : A), M.Posn p) :

                    The one-block model accepts exactly when the underlying machine does. Stated at an existential outermost polarity, where the initial configuration is chosen existentially, as DescriptiveComplexity.TMData.Accepts chooses it.

                    Dependency graph

                    Transport along an equivalence of universes #

                    structure DescriptiveComplexity.ATMData.AltAgree {A B : Type} (u : B A) (N : ATMData B) (M : ATMData A) :

                    Two alternating machines over different universes agree along an equivalence when their underlying machines do and their block marks correspond.

                    Instances For
                      Dependency graph
                      theorem DescriptiveComplexity.ATMData.AltAgree.isUniv {A : Type} {M : ATMData A} {B : Type} {u : B A} {N : ATMData B} (h : AltAgree u N M) (start : Bool) (b : B) :
                      N.IsUniv start b M.IsUniv start (u b)

                      Universality of a state transports along an equivalence.

                      Dependency graph
                      theorem DescriptiveComplexity.ATMData.AltAgree.stuck {A : Type} {M : ATMData A} {B : Type} {u : B A} {N : ATMData B} (h : AltAgree u N M) (c : Config B) :

                      Being stuck transports along an equivalence.

                      Dependency graph
                      theorem DescriptiveComplexity.ATMData.AltAgree.altAcc {A : Type} {M : ATMData A} {B : Type} {u : B A} {N : ATMData B} (h : AltAgree u N M) (start : Bool) (n : ) (c : Config B) :
                      N.AltAcc start n c M.AltAcc start n (Config.map u c)

                      Alternating acceptance within a budget transports along an equivalence.

                      Dependency graph
                      theorem DescriptiveComplexity.ATMData.AltAgree.altAccepts {A : Type} {M : ATMData A} {B : Type} {u : B A} {N : ATMData B} (h : AltAgree u N M) (start : Bool) :
                      N.AltAccepts start M.AltAccepts start

                      Alternating acceptance transports along an equivalence.

                      Dependency graph

                      Well-formedness of the block structure transports along an equivalence.

                      Dependency graph