Compiling FO(TC) formulas to nondeterministic counter code #
A formula over the canonical ordered language with transitive-closure operators is compiled, at
a polarity s, to nondeterministic counter code that reaches a target label when the formula has
truth value s and otherwise rejects. First-order subformulas reuse the deterministic ordered
checker, shifted above the choice register. Conjunction and universal quantification at polarity
true (dually disjunction and existential quantification at false) run sequentially;
existential quantification and disjunction at polarity true guess. A closure at polarity true
becomes the bounded path loop tcCode around the compiled code of its body. A closure at polarity
false becomes the inductive-counting block countCode, whose tests countTestCode run the body
code at polarity true (walks and edges) and at polarity false (non-edges).
The correctness contract Correct states soundness and completeness of the compiled code of a
formula at each polarity, with every register at most B.
Main definitions #
Cslib.Logic.FO.Ordered.TCModelChecker.compile: the polarity-indexed compiler.Cslib.Logic.FO.Ordered.TCModelChecker.tcCode: the bounded closure loop.Cslib.Logic.FO.Ordered.TCModelChecker.countTestCode,Cslib.Logic.FO.Ordered.TCModelChecker.countCode: one test and the counting block of inductive counting.Cslib.Logic.FO.Ordered.TCModelChecker.Env,Cslib.Logic.FO.Ordered.TCModelChecker.Correct: the hypotheses and statement of compiler correctness.
The register-machine kernel shared with the FO(DTC) compiler (term expressions, the loop test,
digit decoding and loading the source tuple) is in
Cslib.Logic.FO.Ordered.ClosureKernel; the effect of a block on the registers is
Turing.CounterProgram.Kept.
Main results #
Cslib.Logic.FO.Ordered.TCModelChecker.correct_ofFO,correct_neg,correct_conj,correct_ex: correctness for the first-order constructors.
References #
The scratch registers used by the compiled code of a formula, above its free variables.
Instances For
Straight-line assignments of e i to register r + i above the choice, for i < k.
Instances For
assignChain is the shifted block of assignments.
|x - y| for registers x and y: positive exactly when they differ.
Instances For
The closure loop around compiled body code body, placed at b. The source tuple is
copied to registers base + i, the guessed successor is decoded into registers base + k + i,
register base + 2 * k holds the guess and base + 2 * k + 1 the step counter. The loop reaches
T once the current tuple is dst and rejects at R after M steps.
Instances For
The code of a tuple: ∑ i, z i * n ^ i, inverse to digitE.
Instances For
One test of inductive counting, placed at b, with registers I, C, Y, X, S, H at
base + 0, 1, 3, 4, 5, 6, the decoded pair at base + 7, and the walk at base + 7 + 2 * k.
Given the size C of round I, it scans every x < n ^ k, guesses whether x is in round I,
certifies selected x by a walk of at most I steps from src (walk body wb), and guesses and
certifies whether x reaches y (the value of Y) in at most one step (edge codes et, ef).
It goes to T with H = 1 exactly when y is in round I + 1, after checking that C
elements were selected; otherwise it rejects at R.
Instances For
The inductive-counting block for a negated closure, placed at b: rounds I < n ^ k - 1
compute the size D of round I + 1 from the size C of round I by one test per candidate
y (first test code t₁), and a final test (code t₂) of the target code at round n ^ k - 1
goes to T exactly when the target is not reached.
Instances For
The number of instructions compiled from a formula at a polarity.
Instances For
The code for a formula at a polarity s, placed at b: registers above the choice; the free
variable x in register fv x, scratch registers from base. It goes to T when the formula has
truth value s and otherwise rejects at R.
Instances For
Straight-line assignments, when each expression ignores the registers assigned.
A proposition with the truth value s.
Instances For
The hypotheses of the compiler correctness proof.
- atomic {β : Type} (fv : β → ℕ) (base : ℕ) (val : β → Fin a.1) : (ModelChecker.atomicCompiler v fv base).Correct (encStructure a) fv base val
- post (s : Turing.CounterProgram.Config) : s.1 = R → Post s
Instances For
The compiled code of φ is correct at every polarity.