Documentation

DescriptiveComplexity.Exponential.GameRun

A configuration of the control, and the steps out of it #

The bridge between the machine of DescriptiveComplexity.Exponential.GameMachine and the two simulations: what it means for the machine to sit at a phase of the control, that a step of the control graph is a step of the machine, and that nothing else is.

The configuration #

DescriptiveComplexity.CtrlCfg bundles the four facts every phase of the control keeps:

Being a conjunction of equations rather than a structure keeps it usable with rw at the transparency the tagged-tuple types force.

The two readings #

DescriptiveComplexity.ctrlCfg_step builds a step from an edge of DescriptiveComplexity.MachPh.CtrlStep, and DescriptiveComplexity.ctrlCfg_cases reads every step back as such an edge – the _det-style lemma the universal phases need, since a universal configuration wins only when every successor does. Both are stated at an arbitrary phase that is not a walk; the walks have their own runs.

Winning along a walk #

DescriptiveComplexity.altWin_of_guardedChain is what turns a run into a win: a chain of steps all of whose sources are existential is won as soon as its last configuration is. The runs of GameMachine produce exactly such a chain – the guard being the state has not changed – which is why they carry it. Its universal counterpart is DescriptiveComplexity.altWin_of_walk, which runs a walk backwards: a family of configurations closed under the steps that carry the walk on, every exit of which wins.

One move, and then the prefix #

DescriptiveComplexity.altWin_of_steps is the shape every phase of the control has, whichever player owns it: a witness among the successors, always, and goodness of every successor, only when the phase is universal – both read off one Good predicate, into which the phase's own content goes.

Its first customers are here: the alternating prefix of a question, played one variable at a time (DescriptiveComplexity.altWin_pre, with DescriptiveComplexity.qval naming the restriction of the machine's tuple to the question's variables), and the challenge round that settles the matrix – altWin_claim into altWin_check into altWin_seek and altWin_conc. All of it is parametric in concOk and isTarget; the program that supplies them is DescriptiveComplexity.Exponential.GameAsk.

Winning along a chain of existential steps #

theorem DescriptiveComplexity.altWin_of_guardedChain {U : Type} {N : ATMData U} {start : Bool} {Guard : Config UProp} (hnu : ∀ (e : Config U), Guard e¬N.IsUniv start e.state) {c d : Config U} (h : Relation.ReflTransGen (fun (x y : Config U) => N.Step x y Guard x) c d) (hd : N.AltWin start d) :
N.AltWin start c

A chain of existential steps wins if its last configuration does. The guard is what the walks of DescriptiveComplexity.Exponential.GameMachine carry: a predicate true of every configuration a step is taken from.

Dependency graph
theorem DescriptiveComplexity.altWin_of_walk {U : Type} {N : ATMData U} {start : Bool} [Finite U] (hlin : IsLinOrd N.Le) {F : Config UProp} (hpos : ∀ (c : Config U), F cN.Posn c.head) (huniv : ∀ (c : Config U), F cN.IsUniv start c.state) (hex : ∀ (c : Config U), F c∃ (c' : Config U), N.Step c c') (hstep : ∀ (c c' : Config U), F cN.Step c c'F c' SuccPos N.Le N.Posn c.head c'.head N.AltWin start c') (c : Config U) :
F cN.AltWin start c

A universal walk wins if every way out of it wins. The family F is closed under the steps that carry the walk on – each moving the head one position – and a step that leaves it already wins; so the walk is won, by induction on how far the head still has to go.

This is what a universal sweep needs, and it is the one place the simulation runs a walk backwards: AltWin.all quantifies over every step, so the walk cannot be summarized by its run.

Dependency graph

A configuration of the control #

def DescriptiveComplexity.CtrlCfg {B : SOBlock} {V M : } {A : Type} [LinearOrder A] (a₀ : A) (hdim : blockArityBound B gameDim B V) (vars : GameQuestion) (ρ σ : B.Assignment A) (p : MachPh V M) (vv : Fin (gameDim B V)A) (c : Config (GamePt B V M A)) :

The machine sits at a phase of the control: the phase at a canonical valuation, the head on the sentinel its parity names, and the tape holding the two assignments – at the positions, the only place it is ever read.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    Dependency graph
    theorem DescriptiveComplexity.CtrlCfg.read {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars : GameQuestion} {a₀ : A} {hdim : blockArityBound B gameDim B V} {ρ σ : B.Assignment A} (h₀ : IsBot a₀) {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :

    The head of a control configuration is a position, and it reads the left mark.

    Dependency graph
    theorem DescriptiveComplexity.CtrlCfg.posn {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (h₀ : IsBot a₀) (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
    (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).Posn c.head
    Dependency graph
    theorem DescriptiveComplexity.ctrlCfg_of_arity_zero {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars : GameQuestion} {a₀ : A} {hdim : blockArityBound B gameDim B V} {ρ σ : B.Assignment A} {p : MachPh V M} (harity : MachPh.arity vars p = 0) {w : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (h : CtrlCfg a₀ hdim vars ρ σ p (truncTuple a₀ (MachPh.arity vars p) w) c) :
    CtrlCfg a₀ hdim vars ρ σ p (fun (x : Fin (gameDim B V)) => a₀) c

    A phase that declares no coordinate is entered at the constant valuation – which is every phase of the game proper, and the entry of every question's prefix.

    Dependency graph
    theorem DescriptiveComplexity.ctrlCfg_step {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} (h₀ : IsBot a₀) {p p' : MachPh V M} {w vv : Fin (gameDim B V)A} (hcs : MachPh.CtrlStep vars natoms p p') (hconc : p.kind = PhKind.concconcOk p w) (hag : Agree (MachPh.arity vars p) w vv) {c : Config (GamePt B V M A)} (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
    ∃ (c' : Config (GamePt B V M A)), (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).Step c c' CtrlCfg a₀ hdim vars ρ σ p' (truncTuple a₀ (MachPh.arity vars p') w) c'

    An edge of the control graph is a step of the machine. The tape is untouched, the head bounces to the other sentinel, and the destination keeps the transition's tuple up to the arity it declares – so the choice of the transition is the choice of the coordinate a prefix phase writes.

    Dependency graph
    theorem DescriptiveComplexity.ctrlCfg_cases {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} (h₀ : IsBot a₀) {p : MachPh V M} {vv : Fin (gameDim B V)A} {c c' : Config (GamePt B V M A)} (hsw : p.kind PhKind.sweep) (hrw : p.kind PhKind.rewind) (hsk : p.kind PhKind.seek) (h : CtrlCfg a₀ hdim vars ρ σ p vv c) (hstep : (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).Step c c') :
    ∃ (p' : MachPh V M) (w : Fin (gameDim B V)A), MachPh.CtrlStep vars natoms p p' (p.kind = PhKind.concconcOk p w) Agree (MachPh.arity vars p) w vv CtrlCfg a₀ hdim vars ρ σ p' (truncTuple a₀ (MachPh.arity vars p') w) c'

    And nothing else is: every step out of a control configuration is such an edge. This is what a universal phase needs, since it wins only when all its successors do; the destination's valuation is forced because the domain pins whatever the phase does not declare.

    Dependency graph

    The two ends of a branch #

    theorem DescriptiveComplexity.isUniv_ctrlCfg {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
    (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).IsUniv true c.state MachPh.IsUniv pol p = true

    A state of the control belongs to the universal player exactly when its phase does – read at a configuration rather than at a point.

    Dependency graph
    theorem DescriptiveComplexity.acc_ctrlCfg {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (hk : p.kind = PhKind.acc) (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
    (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).Acc c.state

    The accepting phase accepts.

    Dependency graph
    theorem DescriptiveComplexity.altWin_conc {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} (h₀ : IsBot a₀) {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (hk : p.kind = PhKind.conc) (hok : concOk p vv) (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
    (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c

    A concluding phase whose residual formula holds wins. This is the one place a question is settled by the source structure rather than by the tape: concOk is a guard the interpretation writes, and a branch that fails it has no transition at all – so it loses, the phase being existential.

    Dependency graph

    One move of the control, whichever player owns it #

    theorem DescriptiveComplexity.altWin_of_steps {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} (h₀ : IsBot a₀) {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (hsw : p.kind PhKind.sweep) (hrw : p.kind PhKind.rewind) (hsk : p.kind PhKind.seek) (hnc : p.kind PhKind.conc) {Good : MachPh V M(Fin (gameDim B V)A)Prop} (hwit : ∃ (p' : MachPh V M) (w : Fin (gameDim B V)A), MachPh.CtrlStep vars natoms p p' Agree (MachPh.arity vars p) w vv Good p' w) (hall : MachPh.IsUniv pol p = true∀ (p' : MachPh V M) (w : Fin (gameDim B V)A), MachPh.CtrlStep vars natoms p p'Agree (MachPh.arity vars p) w vvGood p' w) (hwin : ∀ (p' : MachPh V M) (w : Fin (gameDim B V)A), MachPh.CtrlStep vars natoms p p'Agree (MachPh.arity vars p) w vvGood p' w∀ (c' : Config (GamePt B V M A)), CtrlCfg a₀ hdim vars ρ σ p' (truncTuple a₀ (MachPh.arity vars p') w) c'(gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c') (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
    (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c

    A phase wins when the moves its owner may make win. The existential player needs one good successor, the universal player needs every successor to be good – so the two halves of the hypothesis are a witness, always, and goodness of all successors, only when the phase is universal. Both are read off the same Good predicate, which is where the phase's own content goes.

    This is the shape every phase of the control has, the prefix included: a transition is a pair (destination phase, tuple), the tuple being the value a prefix move writes.

    Dependency graph

    The prefix, played one variable at a time #

    noncomputable def DescriptiveComplexity.qval {B : SOBlock} {V : } {A : Type} {vars : GameQuestion} (hV : ∀ (q : GameQuestion), vars q V) (q : GameQuestion) (vv : Fin (gameDim B V)A) :
    Fin (vars q)A

    The question's own valuation, read off the machine's tuple: the prefix of DescriptiveComplexity.QuestionData quantifies over Fin (vars q) → A, while the machine carries the whole tuple with junk above – which DescriptiveComplexity.altQuantFrom_congr_val licenses.

    Equations
    Instances For
      Dependency graph
      theorem DescriptiveComplexity.qval_update {B : SOBlock} {V : } {A : Type} {vars : GameQuestion} (hV : ∀ (q : GameQuestion), vars q V) (q : GameQuestion) {j : } (hjD : j < gameDim B V) (hjm : j < vars q) (vv : Fin (gameDim B V)A) (a : A) :
      qval hV q (Function.update vv j, hjD a) = Function.update (qval hV q vv) j, hjm a
      Dependency graph
      theorem DescriptiveComplexity.altWin_pre_last {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} (h₀ : IsBot a₀) (hV : ∀ (q : GameQuestion), vars q V) {q : GameQuestion} {P : (Fin (vars q)A)Prop} {r par : Bool} {jj : Fin (V + 1)} (hjj : jj = vars q) (hclaim : ∀ (par' : Bool) (vv' : Fin (gameDim B V)A) (c' : Config (GamePt B V M A)), P (qval hV q vv')CtrlCfg a₀ hdim vars ρ σ (MachPh.claimPh q r par') vv' c'(gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c') {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (hpre : altQuantFrom (pol q) P (vars q) (qval hV q vv)) (h : CtrlCfg a₀ hdim vars ρ σ (MachPh.prePh q r jj par) vv c) :
      (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c

      The prefix hands over to the claim once every variable has been written. The phase still has an owner, but only one successor, so the two readings of DescriptiveComplexity.altWin_of_steps coincide.

      Dependency graph
      theorem DescriptiveComplexity.altWin_pre {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} (h₀ : IsBot a₀) (hV : ∀ (q : GameQuestion), vars q V) {q : GameQuestion} {P : (Fin (vars q)A)Prop} {r : Bool} (hclaim : ∀ (par' : Bool) (vv' : Fin (gameDim B V)A) (c' : Config (GamePt B V M A)), P (qval hV q vv')CtrlCfg a₀ hdim vars ρ σ (MachPh.claimPh q r par') vv' c'(gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c') (fuel j : ) :
      vars q - j fuelj vars q∀ (par : Bool) (jj : Fin (V + 1)), jj = j∀ (vv : Fin (gameDim B V)A) (c : Config (GamePt B V M A)), altQuantFrom (pol q) P j (qval hV q vv)CtrlCfg a₀ hdim vars ρ σ (MachPh.prePh q r jj par) vv c(gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c

      The alternating prefix of a question is played as moves. The phase index is the number of variables already written, the player its polarity names chooses the next one – which is the choice of the transition, since the transition's tuple is the value written – and the phase declares one more coordinate than the one before, so DescriptiveComplexity.truncTuple_succ turns the step into a single Function.update on either side of qval.

      Dependency graph

      Settling a question: the challenge round #

      theorem DescriptiveComplexity.altWin_seek {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} [Finite A] (h₀ : IsBot a₀) {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (hk : p.kind = PhKind.seek) (harity : MachPh.arity vars p V) (hhit : ∃ (q : GamePt B V M A), machPosn q machDom (ctrlArity vars) q SeekHit a₀ isTarget p vv (tapeOfAssign a₀ hdim ρ σ) q) (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
      (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c

      A seek whose cell exists wins. The run either meets it – and the next state accepts – or reaches the right sentinel having found none, which the hypothesis forbids. Every configuration of the run is the same existential phase, which is what the run's guarded chain carries.

      Dependency graph
      theorem DescriptiveComplexity.altWin_check {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} [Finite A] (h₀ : IsBot a₀) {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (hk : p.kind = PhKind.check) (hV : ∀ (q : GameQuestion), vars q V) (hseek : ∀ (k : Fin (M + 1)), k < natoms p.q∃ (q : GamePt B V M A), machPosn q machDom (ctrlArity vars) q SeekHit a₀ isTarget (MachPh.seekPh p.q p.r p.claims k !p.par) vv (tapeOfAssign a₀ hdim ρ σ) q) (hconc : concOk (MachPh.concPh p.q p.r p.claims !p.par) vv) (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
      (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c

      The challenge round wins. check is universal: the existential player has already claimed the whole vector of truth values, and every successor is either a challenge – settled by a seek, which finds its cell exactly when the claim was right – or the concluding transition, guarded by the residual formula. So the round is won precisely when the claims are correct and the residue holds, which is DescriptiveComplexity.QuestionData.MatrixHolds.

      Dependency graph
      theorem DescriptiveComplexity.altWin_claim {B : SOBlock} {V M : } {A : Type} [LinearOrder A] {vars natoms : GameQuestion} {pol : GameQuestionBool} {a₀ : A} {hdim : blockArityBound B gameDim B V} {concOk : MachPh V M(Fin (gameDim B V)A)Prop} {isTarget : MachPh V MSymTag B(Fin (gameDim B V)A)Prop} {ρ σ : B.Assignment A} [Finite A] (h₀ : IsBot a₀) {p : MachPh V M} {vv : Fin (gameDim B V)A} {c : Config (GamePt B V M A)} (hk : p.kind = PhKind.claim) (hV : ∀ (q : GameQuestion), vars q V) (b : Fin MBool) (hseek : ∀ (k : Fin (M + 1)), k < natoms p.q∃ (q : GamePt B V M A), machPosn q machDom (ctrlArity vars) q SeekHit a₀ isTarget (MachPh.seekPh p.q p.r b k p.par) vv (tapeOfAssign a₀ hdim ρ σ) q) (hconc : concOk (MachPh.concPh p.q p.r b p.par) vv) (h : CtrlCfg a₀ hdim vars ρ σ p vv c) :
      (gameMachine vars pol a₀ hdim (gameRule vars natoms concOk isTarget)).AltWin true c

      Claiming the truth values wins, when a correct vector concludes. The claim is one existential move – finitely many vectors, so finitely many transitions – and it is the whole of the matrix the machine ever computes: what follows is a challenge round, DescriptiveComplexity.altWin_check.

      Dependency graph