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: initializing 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.