The machine of a quantified Boolean formula #
The program half of QSAT ≤ᶠᵒ[≤] DTMAcceptSpace: the states, symbols and
transitions of the machine built inside a QSAT instance, on the tape laid out
in DescriptiveComplexity.Problems.Machine.QsatTape.
The program #
Iterative evaluation of a quantified Boolean formula. The recursion stack is
not a stack: each variable's own cell carries its current value b together
with a bit f recording that both values have already been tried, which is
all the standard algorithm needs.
Desc ⊢ → at each cell write (0,0), moving right → ⊣, then evaluate
Eval f d c sweep in direction d accumulating f := f ∨ QLit c x b;
at the marker: ¬f → the matrix is false;
f and c has a successor → next clause, turn round;
f and c is the last → the matrix is true
ToEnd b walk right to ⊣, turn round, and return the value b
Proc b at the innermost unfinished variable x:
the level is decided (∃ and b, or ∀ and ¬b, or f already set)
→ move left, keep returning b
otherwise → write (1,1), move right, Desc
at ⊢: b → accept; ¬b → no transition, the run dies
The machine is deterministic, which is the whole point: DTMAcceptSpace
folds DescriptiveComplexity.TMData.Deterministic into its yes-instances, and a
deterministic run is also what makes the converse half of correctness free
(Relation.ReflTransGen.total_of_right_unique).
Malformed instances #
DescriptiveComplexity.QsatHolds requires DescriptiveComplexity.QsatWf, so an
instance whose prefix order is not a strict linear order on the marked
variables must map to a machine that cannot accept. That is arranged by a
guard on the accepting predicate
(DescriptiveComplexity.QsatTM.QAcc) rather than by the tape order, which
would not catch every violation.
Semantics first #
As in DescriptiveComplexity.Problems.Machine.Hardness, everything here is a plain
predicate on tagged tuples: the machine is assembled as a
DescriptiveComplexity.TMData and reasoned about directly, and only later
transcribed into defining formulas. A transition table type-checks whatever it
says, so it has to be validated by proofs – which is what the second half of
this file is.
The instance, read #
Being a clause of the matrix.
Equations
Instances For
Dependency graph
The variable x occurs positively in the clause c.
Equations
Instances For
Dependency graph
The variable x occurs negatively in the clause c.
Equations
Instances For
Dependency graph
The literal test: the cell of x, holding the truth value b,
satisfies the clause c. This is the first-order test on the source structure
that the evaluation sweep performs.
Equations
- DescriptiveComplexity.QsatTM.QLit c x b = (DescriptiveComplexity.QsatTM.QPosIn c x ∧ b = true ∨ DescriptiveComplexity.QsatTM.QNegIn c x ∧ b = false)
Instances For
Dependency graph
c is the lowest clause in the ambient order.
Equations
- DescriptiveComplexity.QsatTM.QMinCl c = (DescriptiveComplexity.QsatTM.QCl c ∧ ∀ (e : A), DescriptiveComplexity.QsatTM.QCl e → c ≤ e)
Instances For
Dependency graph
c is the highest clause in the ambient order.
Equations
- DescriptiveComplexity.QsatTM.QMaxCl c = (DescriptiveComplexity.QsatTM.QCl c ∧ ∀ (e : A), DescriptiveComplexity.QsatTM.QCl e → e ≤ c)
Instances For
Dependency graph
c' is the clause immediately above c.
Equations
- DescriptiveComplexity.QsatTM.QNextCl c c' = (DescriptiveComplexity.QsatTM.QCl c ∧ DescriptiveComplexity.QsatTM.QCl c' ∧ c < c' ∧ ∀ (e : A), DescriptiveComplexity.QsatTM.QCl e → c < e → c' ≤ e)
Instances For
Dependency graph
The level is already decided: a returning value v settles the
quantifier at x on its own – an existential level reached by a winning
branch, a universal one by a losing branch.
Equations
Instances For
Dependency graph
The elements of the machine #
The least element of the instance, to which every constant of the machine is pinned.
Equations
Instances For
Dependency graph
Dependency graph
Dependency graph
A constant of the machine: a tag on the pair of least elements.
Equations
- DescriptiveComplexity.QsatTM.qCst t = (t, fun (x : Fin 2) => DescriptiveComplexity.QsatTM.qBot)
Instances For
Dependency graph
A tag carrying one element, pinned in the second coordinate.
Equations
Instances For
Dependency graph
Symbols #
The left-marker symbol.
Equations
Instances For
Dependency graph
The right-marker symbol.
Equations
Instances For
Dependency graph
The symbol of the cell of x: value b, flag f.
Equations
Instances For
Dependency graph
The marker a sweep in direction d ends at.
Equations
Instances For
Dependency graph
Positions #
The left-marker cell.
Equations
Instances For
Dependency graph
The cell of the variable x.
Equations
Instances For
Dependency graph
The right-marker cell.
Equations
Instances For
Dependency graph
States #
Descending: initialising the cells to the right.
Equations
Instances For
Dependency graph
Evaluating the clause c, flag f, sweeping in direction d.
Equations
Instances For
Dependency graph
Carrying the value b to the right marker.
Equations
Instances For
Dependency graph
Returning the value b through the prefix.
Equations
Instances For
Dependency graph
The accepting state.
Equations
Instances For
Dependency graph
The transition table #
The second coordinate of a tuple is the least element: the padding of the tags that carry a single element.
Equations
- DescriptiveComplexity.QsatTM.IsMin1 p = ∀ (a : A), p.2 1 ≤ a
Instances For
Dependency graph
Which tagged tuples are transitions. The payload is pinned exactly as far as the transition needs it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The state a transition applies in.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The symbol a transition reads.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The state a transition moves to. The only place the instance is consulted
is the evaluation sweep, where the new flag depends on
DescriptiveComplexity.QsatTM.QLit.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The symbol a transition writes: the descent resets a cell, the switch sets the second value with the flag up, and everything else leaves the tape as it found it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Which transitions move the head right: the descent and the carry always do, a sweep goes in its own direction, a turn reverses, and the return walks leftwards.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Accepting states, guarded by well-formedness of the instance: a malformed instance is a no-instance of QSAT, and its machine has no accepting state at all.
Equations
Instances For
Dependency graph
Dependency graph
The machine of a quantified Boolean formula.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The table is a table #
Before any run is considered: each transition has exactly one destination and symbol written, and the state together with the symbol read pins the transition. A mistake in the table shows up here first, which is why these come before the correctness proof.
Two elements agree when their tag and both coordinates do.
Dependency graph
Dependency graph
A transition writes exactly one symbol.
Dependency graph
A transition moves to exactly one state. The only case with a choice is
the evaluation sweep, whose two branches are separated by the flag and by
DescriptiveComplexity.QsatTM.QLit.
Dependency graph
The end of the descent is not ambiguous: the matrix either has a clause or has none.
Dependency graph
A turn is not ambiguous: the clause just evaluated either has a successor or is the last one.
Dependency graph
The return step is not ambiguous: a level either is decided – by the quantifier or by its flag – or is not.
Dependency graph
The tag of a transition, seen from the state and the symbol #
The tag of the state a transition applies in, as a function of its own tag. Junk tags are sent to themselves; they are never transitions.
Equations
- DescriptiveComplexity.QsatTM.qStateTag DescriptiveComplexity.QsatTM.QTag.tDescStart = DescriptiveComplexity.QsatTM.QTag.qDesc
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tDescCell b f) = DescriptiveComplexity.QsatTM.QTag.qDesc
- DescriptiveComplexity.QsatTM.qStateTag DescriptiveComplexity.QsatTM.QTag.tDescEndTrue = DescriptiveComplexity.QsatTM.QTag.qDesc
- DescriptiveComplexity.QsatTM.qStateTag DescriptiveComplexity.QsatTM.QTag.tDescEndEval = DescriptiveComplexity.QsatTM.QTag.qDesc
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tEval b f fl d) = DescriptiveComplexity.QsatTM.QTag.qEval fl d
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tTurnNext d) = DescriptiveComplexity.QsatTM.QTag.qEval true d
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tTurnLast d) = DescriptiveComplexity.QsatTM.QTag.qEval true d
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tTurnFalse d) = DescriptiveComplexity.QsatTM.QTag.qEval false d
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tToEndCell v b f) = DescriptiveComplexity.QsatTM.QTag.qToEnd v
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tToEndStart v) = DescriptiveComplexity.QsatTM.QTag.qToEnd v
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tToEndTurn v) = DescriptiveComplexity.QsatTM.QTag.qToEnd v
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tProcSkip v b f) = DescriptiveComplexity.QsatTM.QTag.qProc v
- DescriptiveComplexity.QsatTM.qStateTag (DescriptiveComplexity.QsatTM.QTag.tProcSwitch v b f) = DescriptiveComplexity.QsatTM.QTag.qProc v
- DescriptiveComplexity.QsatTM.qStateTag DescriptiveComplexity.QsatTM.QTag.tProcAcc = DescriptiveComplexity.QsatTM.QTag.qProc true
- DescriptiveComplexity.QsatTM.qStateTag x✝ = x✝
Instances For
Dependency graph
The tag of the symbol a transition reads, as a function of its own tag.
Equations
- DescriptiveComplexity.QsatTM.qReadTag DescriptiveComplexity.QsatTM.QTag.tDescStart = DescriptiveComplexity.QsatTM.QTag.sStart
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tDescCell b f) = DescriptiveComplexity.QsatTM.QTag.sVal b f
- DescriptiveComplexity.QsatTM.qReadTag DescriptiveComplexity.QsatTM.QTag.tDescEndTrue = DescriptiveComplexity.QsatTM.QTag.sEnd
- DescriptiveComplexity.QsatTM.qReadTag DescriptiveComplexity.QsatTM.QTag.tDescEndEval = DescriptiveComplexity.QsatTM.QTag.sEnd
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tEval b f fl d) = DescriptiveComplexity.QsatTM.QTag.sVal b f
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tTurnNext d) = if d = true then DescriptiveComplexity.QsatTM.QTag.sEnd else DescriptiveComplexity.QsatTM.QTag.sStart
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tTurnLast d) = if d = true then DescriptiveComplexity.QsatTM.QTag.sEnd else DescriptiveComplexity.QsatTM.QTag.sStart
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tTurnFalse d) = if d = true then DescriptiveComplexity.QsatTM.QTag.sEnd else DescriptiveComplexity.QsatTM.QTag.sStart
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tToEndCell v b f) = DescriptiveComplexity.QsatTM.QTag.sVal b f
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tToEndStart v) = DescriptiveComplexity.QsatTM.QTag.sStart
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tToEndTurn v) = DescriptiveComplexity.QsatTM.QTag.sEnd
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tProcSkip v b f) = DescriptiveComplexity.QsatTM.QTag.sVal b f
- DescriptiveComplexity.QsatTM.qReadTag (DescriptiveComplexity.QsatTM.QTag.tProcSwitch v b f) = DescriptiveComplexity.QsatTM.QTag.sVal b f
- DescriptiveComplexity.QsatTM.qReadTag DescriptiveComplexity.QsatTM.QTag.tProcAcc = DescriptiveComplexity.QsatTM.QTag.sStart
- DescriptiveComplexity.QsatTM.qReadTag x✝ = x✝
Instances For
Dependency graph
The state pins the transition's tag.
Dependency graph
The symbol read pins the transition's tag.
Dependency graph
Being the tag of a transition.
Equations
- DescriptiveComplexity.QsatTM.qIsTrTag DescriptiveComplexity.QsatTM.QTag.tDescStart = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tDescCell b f) = true
- DescriptiveComplexity.QsatTM.qIsTrTag DescriptiveComplexity.QsatTM.QTag.tDescEndTrue = true
- DescriptiveComplexity.QsatTM.qIsTrTag DescriptiveComplexity.QsatTM.QTag.tDescEndEval = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tEval b f fl d) = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tTurnNext d) = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tTurnLast d) = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tTurnFalse d) = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tToEndCell v b f) = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tToEndStart v) = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tToEndTurn v) = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tProcSkip v b f) = true
- DescriptiveComplexity.QsatTM.qIsTrTag (DescriptiveComplexity.QsatTM.QTag.tProcSwitch v b f) = true
- DescriptiveComplexity.QsatTM.qIsTrTag DescriptiveComplexity.QsatTM.QTag.tProcAcc = true
- DescriptiveComplexity.QsatTM.qIsTrTag x✝ = false
Instances For
Dependency graph
The tag ending the descent with no clause to evaluate.
Equations
Instances For
Dependency graph
The tag ending the descent with a clause to evaluate.
Equations
Instances For
Dependency graph
The tag turning to the next clause.
Equations
Instances For
Dependency graph
The tag finishing the last clause.
Equations
Instances For
Dependency graph
The tag passing a decided level on.
Equations
Instances For
Dependency graph
The tag switching a level to its second value.
Equations
Instances For
Dependency graph
The state and the symbol determine the transition's tag, up to the three known branch points: the end of the descent, a turn, and the return step. A finite check over the tags – no case analysis by hand.
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Only transitions have transition tags.
Dependency graph
Reading off DescriptiveComplexity.QsatTM.QSrc at a turn-to-next tag.
Dependency graph
Reading off DescriptiveComplexity.QsatTM.QSrc at a turn-to-last tag.
Dependency graph
Reading off DescriptiveComplexity.QsatTM.QSrc at a skip tag.
Dependency graph
Reading off DescriptiveComplexity.QsatTM.QSrc at a switch tag.
Dependency graph
Reading off DescriptiveComplexity.QsatTM.QRead at a skip tag.
Dependency graph
Reading off DescriptiveComplexity.QsatTM.QRead at a switch tag.
Dependency graph
Equal tags force equal payloads: the state and the symbol pin one
coordinate, the promises in DescriptiveComplexity.QsatTM.QTr pin the other.
Dependency graph
At most one transition applies in a given state on a given symbol: the
state and the symbol read pin the tag (DescriptiveComplexity.QsatTM.qTag_cases),
the tag pins the payload (DescriptiveComplexity.QsatTM.qTr_payload), and the three
branch points are exclusive.
Dependency graph
There is exactly one start state.
Dependency graph
The machine is deterministic.