Counting on a block of heads #
A deterministic machine cannot guess a tuple: it has to walk the tuples one at a time. This file gives it the odometer.
DescriptiveComplexity.HeadProgram.lexNextP replaces the tuple held on a block of
heads by its lexicographic successor, and exits false when there is none –
when the tuple is the greatest. It is the same chain a schoolchild uses to add
one: walk the positions from the last, and at the first position that is not at
its greatest value, step that head and reset the ones after it.
The one thing a machine cannot do directly is ask whether a head is at the
greatest element: that is not a quantifier-free fact of one head. So the block
comes with a marker head parked at the greatest element, and the test is the
atom "these two heads are equal" – the same device the quantifier sweep of
DescriptiveComplexity.HeadEval uses, here shared by every position of the block.
Accordingly the relation DescriptiveComplexity.HeadProgram.lexRel that the gadget runs
is stated in terms of the marker's value, not of maximality: it is an honest
description of what the machine does whatever the marker holds. Where the marker
is known to be at the greatest element, DescriptiveComplexity.HeadProgram.tupSucc_of_lexRel
turns it into DescriptiveComplexity.TupSucc, the coordinatewise description of
covering in Lex (Fin n → A), and the walk becomes a walk along a finite linear
order like any other.
The control graph of an increment #
The control nodes of a lexicographic increment on a block of n heads:
test j has found the positions from j on to be at the marker and is about to
look at position j - 1; bump j steps position j and resets the rest.
- test
{n : ℕ}
(j : Fin (n + 1))
: LexNode n
Positions from
jon are at the marker; about to test positionj - 1. - bump
{n : ℕ}
(j : Fin n)
: LexNode n
Step position
j, and reset the positions after it.
Instances For
Dependency graph
Dependency graph
The position a test node is about to look at, if it has not run out.
Equations
Instances For
Dependency graph
The test node that follows, one position down.
Equations
- DescriptiveComplexity.HeadProgram.testDown j = ⟨↑j - 1, ⋯⟩
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
The wiring of an increment: at the marker, look one position down; away from it, step that position.
Equations
- One or more equations did not get rendered due to their size.
- DescriptiveComplexity.HeadProgram.lexWire (DescriptiveComplexity.HeadProgram.LexNode.bump j) x✝ = Sum.inr true
Instances For
Dependency graph
The moves of an increment: step position j of the block and send the
positions after it to the least element.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The fragments of an increment.
Equations
- One or more equations did not get rendered due to their size.
- DescriptiveComplexity.HeadProgram.lexFam blk mk (DescriptiveComplexity.HeadProgram.LexNode.bump j) = DescriptiveComplexity.HeadProgram.moveP (DescriptiveComplexity.HeadProgram.bumpMoves blk j)
Instances For
Dependency graph
The odometer: replace the tuple on the block by its lexicographic
successor, exiting false when every position is at the marker.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
What an increment runs, stated by the marker's value rather than by maximality: either some position is away from the marker – the last such one is stepped and the positions after it are reset – or all of them are at it and the increment fails.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The relations the fragments of an increment run.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
What the increment runs #
Dependency graph
Dependency graph
Dependency graph
The walk of an increment #
What the increment runs once the positions from jj on are known to be at
the marker: the stepped position is one of those left.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Abbreviation for the walk of an increment.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Soundness of the increment: every exit is the one the relation describes.
Dependency graph
The tuple an increment produces at position p: the stepped and reset
positions taken from the outcome, everything else left where it was.
Equations
Instances For
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Dependency graph
Completeness of the increment: the outcome the relation describes is reached.
Dependency graph
The odometer #
What the odometer runs: the lexicographic successor of the tuple on the block, read through the marker.
Dependency graph
Dependency graph
Reading the increment as a lexicographic step #
Where the marker holds the greatest element, a successful increment is the lexicographic successor.
Dependency graph
Where the marker holds the greatest element, a failed increment says the tuple was the greatest.
Dependency graph
The increment can always be taken where the tuple is not the greatest: the outcome the relation describes exists.
Dependency graph
The increment fails exactly at the greatest tuple, and then leaves everything alone.