Documentation

CslibFrontier.Computability.Complexity.Classes.LogSpace.FirstOrder.Formula

Shared first-order counter-program control #

Compile Mathlib first-order formulas using one counter per bound variable. Equality compares compiled term expressions; relation atoms execute a single supplied branch/read instruction. Implication and universal quantification use the existing fixed-control model-checking recursion. The atomic-handler correctness hypothesis is discharged by each concrete model checker.

This factors the control proof of the original order-free model checker without changing its code lengths, quantifier order or empty-universe behavior.

Main definitions #

Main results #

References #

The number of bound variables in scope at the deepest point of a formula: the nesting depth of its quantifiers, plus the number of bound variables in scope at the formula itself.

Instances For

    The register depth of a formula is the number of bound variables in scope plus its quantifier rank.

    Compile terms to arithmetic expressions and relations to one branch/read instruction. The handlers do not change registers. Their semantics are proved by AtomicCompiler.Correct.

    Instances For
      structure Cslib.Logic.Vocabulary.ModelChecker.AtomicCompiler.Correct {L : FirstOrder.Language} {α : Type u_1} (C : AtomicCompiler L α) {n : ℕ} [L.Structure (Fin n)] (w : List Bool) (fv : α → ℕ) (base : ℕ) (val : α → Fin n) :

      The atomic handlers realize terms and relations in a concrete input structure, without changing the assignment registers. This is an internal compiler specification, not a hypothesis of the concrete query-language membership theorems.

      Instances For

        The number of instructions compiled from a formula (Cslib.Logic.Vocabulary.ModelChecker.formulaCodeWith).

        Instances For

          The code evaluating a formula with free variables α and k bound variables, placed at the label b: with the cardinality in register 0, the values expected by the atomic handlers, and the bound variable i in register base + i, it goes to T if the formula holds and to F otherwise. A quantifier over the bound variable k loops over the values of register base + k below the cardinality; equality compares two compiled expressions, and a relation uses its supplied branch instruction.

          Instances For
            theorem Cslib.Logic.Vocabulary.ModelChecker.length_formulaCodeWith {L : FirstOrder.Language} {α : Type u_1} (C : AtomicCompiler L α) (base : ℕ) {k : ℕ} (φ : L.BoundedFormula α k) (b T F : ℕ) :
            (formulaCodeWith C base φ b T F).length = codeLength φ
            theorem Cslib.Logic.Vocabulary.ModelChecker.reaches_formulaCodeWith {L : FirstOrder.Language} {P : Turing.CounterProgram} {w : List Bool} {n B : ℕ} [L.Structure (Fin n)] (hnB : n ≤ B) {α : Type u_1} (fv : α → ℕ) (base : ℕ) (hbase : 0 < base) (hfv : ∀ (x : α), fv x < base) (val : α → Fin n) (C : AtomicCompiler L α) (hC : C.Correct w fv base val) {k : ℕ} (φ : L.BoundedFormula α k) (b T F : ℕ) (regs : List ℕ) (xs : Fin k → Fin n) :
            P.CodeAt b (formulaCodeWith C base φ b T F) → base + FO.boundDepth φ ≤ regs.length → regs.getD 0 0 = n → (∀ r ∈ regs, r ≤ B) → (∀ (x : α), regs.getD (fv x) 0 = ↑(val x)) → (∀ (i : Fin k), regs.getD (base + ↑i) 0 = ↑(xs i)) → ∃ (res : Bool) (regs' : List ℕ), (res = true ↔ φ.Realize val xs) ∧ P.Reaches w (P.Running B) (b, regs) (if res = true then T else F, regs') ∧ Turing.CounterProgram.Kept B (base + k) regs regs'

            Compiled first-order control evaluates the formula and preserves the registers below the current bound-variable scope. Only the atomic handlers depend on the input vocabulary/model.