Documentation

DescriptiveComplexity.Problems.Machine.AltGuess

A round of the game, played by either player #

What a sweep amounts to, whichever player owns its block. Its moves are exactly the truth assignments of the block: for an existential block the machine picks one, for a universal block it must survive all of them, and DescriptiveComplexity.inSweepR_step / DescriptiveComplexity.inSweepL_step say that every play is the run of some assignment.

The universal half needs two things beyond the read-off. The sweep is never stuck (DescriptiveComplexity.exists_step_of_inSweepR, DescriptiveComplexity.exists_step_of_inSweepL) – at a cell it may keep or set the value, at the markers it turns or hands over – and it terminates, the head moving up until the turn and down afterwards. Both are needed because a universal configuration accepts only when it has a successor and all of them accept, so an induction on the budget alone would never reach its base case.

The one place the handover can genuinely be stuck is the left marker of the last sweep, where the machine passes to the check phase: a disjunctive matrix with no term at all has nothing to check and nothing to accept. That is DescriptiveComplexity.CanHandOver, and it is exactly the case where the formula is false.

The block of a sweeping state #

theorem DescriptiveComplexity.AltQbf.isUniv_stG {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf start : Bool} {i : Fin k} {d : Bool} :
(altMachine k A cnf).IsUniv start (stG i.castSucc d) blockPol start i = false

A sweeping state is universal exactly when its block is.

Dependency graph

The sweep is never stuck #

theorem DescriptiveComplexity.AltQbf.posn_le_posCell_cases {k : } {A : Type} [LinearOrder A] [Finite A] [Nonempty A] {p : AltV k A} (hp : AltPosn p) (hle : tagTupleLe p (posCell qtopA)) :
p = posStart p = posCell (p.2 0)

A position at or below the last cell is the left marker or a cell.

Dependency graph
theorem DescriptiveComplexity.AltQbf.posn_between_cases {k : } {A : Type} [LinearOrder A] [Finite A] [Nonempty A] {p : AltV k A} (hp : AltPosn p) (hlo : tagTupleLe (posCell qbotA) p) (hhi : tagTupleLe p posEnd) :
p = posCell (p.2 0) p = posEnd

A position between the first cell and the right marker is a cell or the right marker.

Dependency graph

A cell has a position above it: the right marker.

Dependency graph

A cell has a position below it: the left marker.

Dependency graph
theorem DescriptiveComplexity.AltQbf.exists_step_of_inSweepR {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf : Bool} {i : Fin k} {νs : Fin kAProp} {c : Config (AltV k A)} (hinv : InSweepR i νs c) :
∃ (c' : Config (AltV k A)), (altMachine k A cnf).Step c c'

The rightward pass always has a move: at a cell it keeps the value it reads, and at the right marker it turns.

Dependency graph

The last sweep can hand over: either there is a clause to check, or there is none and the matrix is conjunctive, so the machine accepts outright. This fails only for a disjunctive matrix with no term, which is the false formula.

Equations
Instances For
    Dependency graph
    theorem DescriptiveComplexity.AltQbf.exists_step_of_inSweepL {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf : Bool} {i : Fin k} {νs : Fin kAProp} {c : Config (AltV k A)} (hinv : InSweepL i νs c) (hover : i + 1 = kCanHandOver k A cnf) :
    ∃ (c' : Config (AltV k A)), (altMachine k A cnf).Step c c'

    The leftward pass always has a move, given that the handover is available: at a cell it steps back, at the left marker it passes the tape on.

    Dependency graph

    A universal round survives every play #

    Two inductions, one per pass, on the only quantity that changes monotonically: the rank of the head, which rises during the rightward pass and falls during the leftward one. The budget is threaded through as a bound rather than as a step count, since a universal player is answered by all plays at once and there is no single run to count.

    The number of positions on the tape: the yardstick a sweep is measured against.

    Equations
    Instances For
      Dependency graph
      theorem DescriptiveComplexity.AltQbf.altAcc_of_inSweepL {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf start : Bool} {i : Fin k} {νs : Fin kAProp} {n' : } (huniv : blockPol start i = false) (hover : i + 1 = kCanHandOver k A cnf) (hexit : ∀ (ν' : AProp) (c : Config (AltV k A)), (∀ (x : A), ν' xQbfBlk i x)AfterSweep cnf i (Function.update νs i ν') c(altMachine k A cnf).AltAcc start n' c) (r n : ) (c : Config (AltV k A)) :
      InSweepL i νs cbitRank tagTupleLe AltPosn c.head rr + 1 + n' n(altMachine k A cnf).AltAcc start n c

      The leftward pass of a universal round accepts, given that whatever it hands over accepts.

      Dependency graph
      theorem DescriptiveComplexity.AltQbf.altAcc_of_inSweepR {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf start : Bool} {i : Fin k} {νs : Fin kAProp} {n' : } (huniv : blockPol start i = false) (hover : i + 1 = kCanHandOver k A cnf) (hexit : ∀ (ν' : AProp) (c : Config (AltV k A)), (∀ (x : A), ν' xQbfBlk i x)AfterSweep cnf i (Function.update νs i ν') c(altMachine k A cnf).AltAcc start n' c) (r n : ) (c : Config (AltV k A)) :

      The rightward pass of a universal round accepts. The measure is what the head has left to climb; at the turn the leftward pass takes over, with what it has left to descend. The two together are the length of the sweep, so a universal round costs no more than the run it must survive.

      Dependency graph

      Following a run of universal configurations #

      A universal configuration accepts only if every successor does, so acceptance descends along any run that stays universal – in particular along the intended run of a given assignment, which is how a universal round is read for one play at a time. These mirror DescriptiveComplexity.TMData.stepsIn_of_segment and its downward twin, and could be hoisted beside them.

      def DescriptiveComplexity.AltQbf.StepForced {k : } {A : Type} (M : ATMData (AltV k A)) (start : Bool) (c c' : Config (AltV k A)) :

      Acceptance descends across a step when the step is not a choice: either the state is universal, and then every successor accepts, or it is the only step available, and then the successor the machine picks is that one.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        Dependency graph
        theorem DescriptiveComplexity.AltQbf.altAcc_down_step {k : } {A : Type} {M : ATMData (AltV k A)} {start : Bool} {n : } {c c' : Config (AltV k A)} (hf : StepForced M start c c') (hstep : M.Step c c') (hacc : M.AltAcc start n c) :
        1 n M.AltAcc start (n - 1) c'

        One step down.

        Dependency graph
        theorem DescriptiveComplexity.AltQbf.altAcc_along_segment {k : } {A : Type} [Finite A] {M : ATMData (AltV k A)} {start : Bool} (hlin : IsLinOrd M.Le) {conf : AltV k AConfig (AltV k A)} {p₀ p₁ : AltV k A} (hp₀ : M.Posn p₀) (hstep : ∀ (p q : AltV k A), SuccPos M.Le M.Posn p qM.Le p₀ pM.Le q p₁M.Step (conf p) (conf q)) (hf : ∀ (p q : AltV k A), SuccPos M.Le M.Posn p qM.Le p₀ pM.Le q p₁StepForced M start (conf p) (conf q)) (n : ) (p : AltV k A) :
        M.Posn pM.Le p₀ pM.Le p p₁M.AltAcc start n (conf p₀)bitRank M.Le M.Posn p - bitRank M.Le M.Posn p₀ n M.AltAcc start (n - (bitRank M.Le M.Posn p - bitRank M.Le M.Posn p₀)) (conf p)

        Down a rising segment.

        Dependency graph
        theorem DescriptiveComplexity.AltQbf.altAcc_along_segment_down {k : } {A : Type} [Finite A] {M : ATMData (AltV k A)} {start : Bool} (hlin : IsLinOrd M.Le) {conf : AltV k AConfig (AltV k A)} {p₀ p₁ : AltV k A} (hp₁ : M.Posn p₁) (hstep : ∀ (p q : AltV k A), SuccPos M.Le M.Posn p qM.Le p₀ pM.Le q p₁M.Step (conf q) (conf p)) (hf : ∀ (p q : AltV k A), SuccPos M.Le M.Posn p qM.Le p₀ pM.Le q p₁StepForced M start (conf q) (conf p)) (n : ) (p : AltV k A) :
        M.Posn pM.Le p₀ pM.Le p p₁M.AltAcc start n (conf p₁)bitRank M.Le M.Posn p₁ - bitRank M.Le M.Posn p n M.AltAcc start (n - (bitRank M.Le M.Posn p₁ - bitRank M.Le M.Posn p)) (conf p)

        Down a falling segment.

        Dependency graph

        A universal round, followed for one assignment at a time #

        theorem DescriptiveComplexity.AltQbf.not_acc_stG {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf : Bool} {i : Fin (k + 1)} {d : Bool} :
        ¬(altMachine k A cnf).Acc (stG i d)

        A sweeping state is not accepting.

        Dependency graph
        noncomputable def DescriptiveComplexity.AltQbf.passLen (k : ) (A : Type) [LinearOrder A] [Finite A] [Nonempty A] :

        The steps a sweep takes before handing over: up to the right marker, round, and back to the left one.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          Dependency graph
          Dependency graph
          theorem DescriptiveComplexity.AltQbf.altAcc_passes_down {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf start : Bool} {i : Fin k} {νs : Fin kAProp} (huniv : blockPol start i = false) {n : } (hacc : (altMachine k A cnf).AltAcc start n (confSweep νs i.castSucc (posCell qbotA))) :
          passLen k A n (altMachine k A cnf).AltAcc start (n - passLen k A) (confBack νs i.castSucc posStart)

          A universal round, followed along the run of one assignment. Both passes are runs of universal configurations, so acceptance descends along them: whatever the round's assignment, the configuration it leaves at the left marker accepts too.

          Dependency graph

          Following a run of existential configurations #

          The mirror of the descent: an existential configuration accepts as soon as one successor does, so acceptance climbs back up any run whose configurations all belong to the machine. This is how an existential round plays the assignment it has chosen.

          theorem DescriptiveComplexity.AltQbf.altAcc_up_step {k : } {A : Type} {M : ATMData (AltV k A)} {start : Bool} {n : } {c c' : Config (AltV k A)} (hnu : ¬M.IsUniv start c.state) (hstep : M.Step c c') (hacc : M.AltAcc start n c') :
          M.AltAcc start (n + 1) c

          One step up.

          Dependency graph
          theorem DescriptiveComplexity.AltQbf.altAcc_along_segment_up {k : } {A : Type} [Finite A] {M : ATMData (AltV k A)} {start : Bool} (hlin : IsLinOrd M.Le) {conf : AltV k AConfig (AltV k A)} {p₀ p₁ : AltV k A} (hp₀ : M.Posn p₀) (hstep : ∀ (p q : AltV k A), SuccPos M.Le M.Posn p qM.Le p₀ pM.Le q p₁M.Step (conf p) (conf q)) (hnu : ∀ (p : AltV k A), ¬M.IsUniv start (conf p).state) (n : ) (p : AltV k A) :
          M.Posn pM.Le p₀ pM.Le p p₁M.AltAcc start n (conf p)M.AltAcc start (n + (bitRank M.Le M.Posn p - bitRank M.Le M.Posn p₀)) (conf p₀)

          Up a rising segment.

          Dependency graph
          theorem DescriptiveComplexity.AltQbf.altAcc_along_segment_up_down {k : } {A : Type} [Finite A] {M : ATMData (AltV k A)} {start : Bool} (hlin : IsLinOrd M.Le) {conf : AltV k AConfig (AltV k A)} {p₀ p₁ : AltV k A} (hp₁ : M.Posn p₁) (hstep : ∀ (p q : AltV k A), SuccPos M.Le M.Posn p qM.Le p₀ pM.Le q p₁M.Step (conf q) (conf p)) (hnu : ∀ (p : AltV k A), ¬M.IsUniv start (conf p).state) (n : ) (p : AltV k A) :
          M.Posn pM.Le p₀ pM.Le p p₁M.AltAcc start n (conf p)M.AltAcc start (n + (bitRank M.Le M.Posn p₁ - bitRank M.Le M.Posn p)) (conf p₁)

          Up a falling segment.

          Dependency graph
          theorem DescriptiveComplexity.AltQbf.altAcc_passes_up {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf start : Bool} {i : Fin k} {νs : Fin kAProp} (hex : blockPol start i = true) {n : } (hacc : (altMachine k A cnf).AltAcc start n (confBack νs i.castSucc posStart)) :
          (altMachine k A cnf).AltAcc start (n + passLen k A) (confSweep νs i.castSucc (posCell qbotA))

          An existential round, played along the run of the assignment it picks. The mirror of DescriptiveComplexity.altAcc_passes_down: acceptance at the left marker, where the round hands over, climbs back to its entry.

          Dependency graph

          An existential round, and reading any round off an accepting run #

          def DescriptiveComplexity.AltQbf.InSweep {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] (i : Fin k) (νs : Fin kAProp) (c : Config (AltV k A)) :

          Being somewhere in the sweep of round i, on either pass.

          Equations
          Instances For
            Dependency graph
            theorem DescriptiveComplexity.AltQbf.inSweep_step {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf : Bool} {i : Fin k} {νs : Fin kAProp} {c c' : Config (AltV k A)} (hinv : InSweep i νs c) (hstep : (altMachine k A cnf).Step c c') :
            InSweep i νs c' ∃ (ν' : AProp), (∀ (x : A), ν' xQbfBlk i x) AfterSweep cnf i (Function.update νs i ν') c'

            A sweep either continues or hands over, whatever the machine does.

            Dependency graph
            theorem DescriptiveComplexity.AltQbf.state_of_inSweep {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {i : Fin k} {νs : Fin kAProp} {c : Config (AltV k A)} (hinv : InSweep i νs c) :

            The state of a sweeping configuration.

            Dependency graph
            theorem DescriptiveComplexity.AltQbf.not_acc_of_inSweep {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf : Bool} {i : Fin k} {νs : Fin kAProp} {c : Config (AltV k A)} (hinv : InSweep i νs c) :
            ¬(altMachine k A cnf).Acc c.state

            A sweeping configuration is not accepting.

            Dependency graph
            theorem DescriptiveComplexity.AltQbf.not_isUniv_of_inSweep {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf start : Bool} {i : Fin k} {νs : Fin kAProp} {c : Config (AltV k A)} (hex : blockPol start i = true) (hinv : InSweep i νs c) :
            ¬(altMachine k A cnf).IsUniv start c.state

            The moves of an existential round belong to the machine.

            Dependency graph
            theorem DescriptiveComplexity.AltQbf.exit_of_altAcc {k : } {A : Type} [(FirstOrder.Language.qbf k).Structure A] [LinearOrder A] [Finite A] [Nonempty A] {cnf start : Bool} {i : Fin k} {νs : Fin kAProp} (n : ) (c : Config (AltV k A)) :
            InSweep i νs c(altMachine k A cnf).AltAcc start n c∃ (ν' : AProp) (d : Config (AltV k A)), m < n, (∀ (x : A), ν' xQbfBlk i x) AfterSweep cnf i (Function.update νs i ν') d (altMachine k A cnf).AltAcc start m d

            Any accepting run of a round hands over an assignment. Whichever player owns the block, an accepting configuration has an accepting successor – the one it picks, or any of the ones it must survive – and following those successors reaches the handover, since a sweeping state never accepts.

            Dependency graph