Documentation

CslibFrontier.Computability.Complexity.Classes.Alternation.SavitchEndpoints

The endpoints of Savitch's midpoint game #

A play of Savitch's midpoint game (Cslib.Reachability.midpointGame) on words of width w and i levels ends with a pair of endpoints, whose edge test decides the play. The pair depends on two levels only: the left endpoint is the midpoint chosen at the last level whose half is true, or the initial left endpoint if there is none, and the right endpoint is the midpoint chosen at the last level whose half is false, or the initial right endpoint if there is none (Cslib.Reachability.midpointGame_eq_reach_lastMidpoint).

The midpoint of the last level with a given half is extracted from any moves z in time linear in the number of moves, O((2 * w + 2) * i + w + |z|), by a native multi-tape machine (Cslib.Reachability.computableInO_lastMidpoint). The moves are padded or cut to the length of the game by a zip transducer (Cslib.Reachability.padZip); then the level marks are written in one streaming pass (Cslib.Reachability.levelMarks), the moves are reversed, and a finite-state zip transducer reads the marks and the reversed moves in lockstep (Cslib.Reachability.endpointZip), copying the first level, from the end, with the wanted half. The moves are read a constant number of times, not once per level: re-reading the remaining moves at every level would take order w * i ^ 2 steps. The word this endpoint machine computes is Cslib.Reachability.endpointWord.

This is a step toward NSPACE(s) ⊆ ATIME(s ^ 2) Chandra, Kozen and Stockmeyer, which Cslib.Complexity.NSPACE_subset_ATIME_sq_of_timeConstructible assembles for a time-constructible s (#4086) with the codes of the initial and accepting views and the edge test Cslib.Reachability.reach ntm.codeEdge _ 0 of the final endpoints.

Main definitions #

Main results #

References #

The endpoints of the midpoint game #

The midpoint chosen at the last of the first i levels of the midpoint game on words of width w whose half is d, if there is one. A level takes 2 * w + 2 moves: its midpoint is Cslib.Reachability.midpointMoves w of the moves from its start, and its half is its last move.

theorem Cslib.Reachability.lastMidpoint_eq_none_iff {w i : ℕ} {z : List Bool} {d : Bool} :
lastMidpoint w i z d = none ↔ ∀ j < i, z.getD ((2 * w + 2) * j + (2 * w + 1)) false ≠ d

No level with half d. lastMidpoint w i z d is none exactly when no level j < i of the moves z has half d; the half of level j is the move (2 * w + 2) * j + (2 * w + 1).

theorem Cslib.Reachability.lastMidpoint_eq_some_iff {w i : ℕ} {z : List Bool} {d : Bool} {m : List Bool} :
lastMidpoint w i z d = some m ↔ ∃ j < i, z.getD ((2 * w + 2) * j + (2 * w + 1)) false = d ∧ midpointMoves w (List.drop ((2 * w + 2) * j) z) = m ∧ ∀ (j' : ℕ), j < j' → j' < i → z.getD ((2 * w + 2) * j' + (2 * w + 1)) false ≠ d

The midpoint of the last level with half d. lastMidpoint w i z d is some m exactly when some level j < i of the moves z has half d, no later level j' < i has half d, and m is the midpoint of level j, that is Cslib.Reachability.midpointMoves w of the moves from its start (2 * w + 2) * j.

theorem Cslib.Reachability.iterate_midpointStep {w : ℕ} (i : ℕ) (u v z : List Bool) :
(midpointStep w)^[i] (u, v, z) = ((lastMidpoint w i z true).getD u, (lastMidpoint w i z false).getD v, List.drop ((2 * w + 2) * i) z)

The endpoints after i levels. After i levels of the midpoint game from u and v, the left endpoint is the midpoint of the last level whose half is true, or u, and the right endpoint is the midpoint of the last level whose half is false, or v.

theorem Cslib.Reachability.midpointGame_eq_reach_lastMidpoint {edge : List Bool → List Bool → Bool} {w : ℕ} (i : ℕ) (u v z : List Bool) :
midpointGame edge w i u v z = reach edge w 0 ((lastMidpoint w i z true).getD u) ((lastMidpoint w i z false).getD v)

The midpoint game depends on two levels. The existential player wins a play of the midpoint game at level i between u and v exactly when the edge test accepts the midpoint of the last level whose half is true (or u) and the midpoint of the last level whose half is false (or v).

The endpoint machine #

The level marks of i levels of 2 * w + 2 moves, read from the last move backwards: for each level, true at its half, then false at its other 2 * w + 1 moves.

The states of the endpoint scan, which reads the levels from the last one backwards.

  • seek : EndpointState

    No level with the wanted half yet.

  • skip : EndpointState

    At the move of the existential player after the half of the level found.

  • univ : EndpointState

    Copying the level found, at a move of the universal player.

  • mid : EndpointState

    Copying the level found, at a bit of its midpoint.

  • done : EndpointState

    Past the level found.

Instances For

    The endpoint scan for the half d: a zip transducer reading the level marks and the reversed moves in lockstep. It emits the bits of the midpoint of the first level read, that is the last level of the game, whose half is d, last bit first, and then true; it emits nothing if no level has half d.

    The word computed by the endpoint machine for the half d, on the width w, the number i of levels and the moves z: the endpoint scan of the level marks and the reversed moves, reversed. On moves of the length of the game it encodes Cslib.Reachability.lastMidpoint w i z d.

    The pad scan: one move per mark, false past the end of the moves, nothing past the marks.

    The pad scan reads the moves at the positions of the marks, false past their end.

    theorem Cslib.Reachability.lastMidpoint_congr {w i : ℕ} {z z' : List Bool} {d : Bool} (h : ∀ p < (2 * w + 2) * i, z.getD p false = z'.getD p false) :
    lastMidpoint w i z d = lastMidpoint w i z' d

    lastMidpoint w i z d reads only the first (2 * w + 2) * i moves of z.

    The midpoint of the last level with a given half, in linear time. On any moves z, the midpoint of the last of the first i levels whose half is d, as an option, is computed on a multi-tape machine within time and space O((2 * w + 2) * i + w + |z|): the moves are padded or cut to the length of the game by the pad scan, and then the endpoint machine runs.