Documentation

CslibFrontier.Computability.Complexity.Classes.Alternation.Game

Alternating polynomial time as a game of moves #

An alternating machine running within t steps plays a game of t moves, each chosen by the player that the state labels. Through the strict table (Turing.MultiTapeATM.strict, in CslibFrontier.Computability.Machines.Turing.MultiTape.Alternating.Game), which spends two coins on each step of the machine, acceptance within t moves when every branch halts within t steps is the game of 2 * t single-bit moves, alternately chosen by an existential and a universal player, in which the existential player wins when the strict table, replayed from the moves, emits [true] (Turing.MultiTapeATM.acceptsWithin_iff_alternation). The moves are the blocks of length 1 of the alternating quantifiers Cslib.Complexity.Alternation of the polynomial hierarchy.

Since replaying the strict table of a fixed finite machine is polynomial-time (Turing.MultiTapeATM.computableInPolyTime_gameVerifier), every problem in AP has a polynomial-time game verifier (Cslib.Complexity.IsGameVerifier): a polynomial-time V and a polynomial p such that a ∈ A exactly when the existential player wins the game of 2 * p (enc a).length moves with V (a, ·) as the winning condition (Cslib.Complexity.exists_isGameVerifier_of_mem_AP). Conversely, the guess-then-verify machine plays the game of a polynomial-time game verifier (Cslib.Complexity.IsGameVerifier.mem_AP, in CslibFrontier.Computability.Complexity.Classes.Alternation.GuessVerify).

Main definitions #

Main results #

References #

Single-bit moves #

theorem Cslib.Complexity.alternation_const {q : Bool} {ns : List ℕ} {p : Prop} :
(Alternation q ns fun (x : List Bool) => p) ↔ p

Alternating quantifiers over a predicate that ignores the strings are vacuous.

theorem Cslib.Complexity.Alternation.mono_of_length {q : Bool} {ns : List ℕ} {P Q : List Bool → Prop} (h : ∀ (w : List Bool), w.length = ns.sum → P w → Q w) :
Alternation q ns P → Alternation q ns Q

Alternating quantifiers only apply the predicate to strings of the total length of the blocks.

theorem Cslib.Complexity.alternation_congr_of_length {q : Bool} {ns : List ℕ} {P Q : List Bool → Prop} (h : ∀ (w : List Bool), w.length = ns.sum → (P w ↔ Q w)) :

Alternating quantifiers over two predicates that agree on the strings of the total length of the blocks agree.

The total length of the single-bit moves.

theorem Cslib.Complexity.alternation_true_one_cons {ns : List ℕ} {P : List Bool → Prop} :
Alternation true (1 :: ns) P ↔ ∃ (b : Bool), Alternation false ns fun (v : List Bool) => P (b :: v)

An existential move of one bit.

theorem Cslib.Complexity.alternation_false_one_cons {ns : List ℕ} {P : List Bool → Prop} :
Alternation false (1 :: ns) P ↔ ∀ (b : Bool), Alternation true ns fun (v : List Bool) => P (b :: v)

A universal move of one bit.

theorem Cslib.Complexity.alternation_replicate_succ {P : List Bool → Prop} {n : ℕ} :
Alternation true (List.replicate (2 * (n + 1)) 1) P ↔ ∃ (x : Bool), ∀ (y : Bool), Alternation true (List.replicate (2 * n) 1) fun (v : List Bool) => P (x :: y :: v)

One round of the game: an existential move, then a universal move.

theorem Turing.MultiTapeATM.acceptsWithin_iff_alternation {k : ℕ} {State : Type} (atm : MultiTapeATM k Bool State) {input : List Bool} {n : ℕ} {c : Cfg k Bool State input} (hn : ∀ (coins : List Bool), coins.length = n → (atm.toPTM.stepCoins coins c).state = none) :

Acceptance as a game of moves. If every list of n moves from c reaches a halted configuration, c accepts within n moves exactly when the existential player wins the game of 2 * n alternate single-bit moves, the existential first, in which the strict table replayed from the moves ends with output [true].

theorem Turing.MultiTapeATM.accepts_iff_alternation {k : ℕ} {State : Type} (atm : MultiTapeATM k Bool State) {input : List Bool} {t : ℕ} (ht : atm.toPTM.toNTM.RunsInTime input t) :

A machine under a time bound plays a game of moves on its input: if every computation path of at least t steps ends halted, the machine accepts exactly when the existential player wins the game of 2 * t alternate moves in which the strict table, replayed from the moves on the input, emits [true].

Game verifiers #

def Cslib.Complexity.IsGameVerifier {α : Type} (enc : α ↪ List Bool) (p : Polynomial ℕ) (V : α × List Bool → Bool) (A : Set α) :

V verifies A through a game of p (enc a).length rounds of two single-bit moves, the first chosen by an existential player and the second by a universal player: a ∈ A exactly when the existential player wins, that is, can choose its moves so that V (a, w) = true for the moves w whatever the universal player chooses.

theorem Turing.MultiTapeATM.DecidesInTime.isGameVerifier {k : ℕ} {State α : Type} {enc : α ↪ List Bool} {atm : MultiTapeATM k Bool State} {A : Set α} {c d : ℕ} (h : atm.DecidesInTime enc A fun (a : α) => c * ((enc a).length + 1) ^ d) :

A machine deciding a problem gives a game verifier: if atm decides A within c * ((enc a).length + 1) ^ d steps, then its game verifier verifies A through games of c * ((enc a).length + 1) ^ d rounds.

Every problem in AP has a polynomial-time game verifier.