Uniform word-RAM model checking for intrinsic MSO sentences

Lax842588.MSOLinearTime · concepts/Lax842588/MSOLinearTime.lean · lax-842588

proven

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition and theorem

    One fixed word-RAM program decides monadic second-order satisfaction when the ranked alphabet, the intrinsically scoped Lax-52 sentence, and the ranked tree are all supplied at runtime. Their sole machine input is the distinguished constructor-certified Lax560851 arena. The actual Lax808846 instruction bound includes all sentence-to-automaton compilation and tree-automaton evaluation.

    The resource coefficients are computable functions only of the constructor size of the alphabet and sentence and of the largest symbol rank. This leaves the unavoidable nonelementary dependence on the sentence abstract while stating the uniform runtime in terms of mathematical sizes rather than a serialization. For a fixed alphabet and sentence, a separate companion program receives only the tree and runs linearly in its number of nodes.

    The reusable Lax560851 predicate packages the single program, every sufficient word width, and the payload/address/capacity premises. No constructor tags, arena offsets, compiled automata, or intermediate syntax belong to this concept.

    Concept map
    17 concepts
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A
    Evidence

    Each proof establishes this claim relative to its assumptions.

    Lean source view on GitHub

    1import Mathlib.Computability.Partrec
    2import Lax560851.RamComplexity
    3import Lax842588.StructuralRepresentations
    4import Lax842588.TreeModelCheckingEncoding
    5
    6/-!
    7---
    8title: Uniform word-RAM model checking for intrinsic MSO sentences
    9type: definition and theorem
    10---
    11
    12One fixed word-RAM program decides monadic second-order satisfaction when the
    13ranked alphabet, the intrinsically scoped Lax-52 sentence, and the ranked tree
    14are all supplied at runtime. Their sole machine input is the distinguished
    15constructor-certified Lax560851 arena. The actual Lax808846 instruction bound
    16includes all sentence-to-automaton compilation and tree-automaton evaluation.
    17
    18The resource coefficients are computable functions only of the constructor
    19size of the alphabet and sentence and of the largest symbol rank. This leaves
    20the unavoidable nonelementary dependence on the sentence abstract while
    21stating the uniform runtime in terms of mathematical sizes rather than a
    22serialization. For a fixed alphabet and sentence, a separate companion
    23program receives only the tree and runs linearly in its number of nodes.
    24
    25The reusable Lax560851 predicate packages the single program, every sufficient
    26word width, and the payload/address/capacity premises. No constructor tags,
    27arena offsets, compiled automata, or intermediate syntax belong to this
    28concept.
    29-/
    30
    31namespace Lax842588.MSOLinearTime
    32
    33open Lax146103.MSOSyntax
    34open Lax842588.RankedTree
    35open Lax842588.TreeStructure
    36open Lax842588.ValueTranslations
    37open Lax842588.StructuralRepresentations
    38open Lax842588.TreeModelCheckingEncoding
    39open Lax560851.StructuralPresentation
    40open Lax560851.StructuralPresentation.Presentation
    41open Lax560851.StructuralCombinators
    42open Lax560851.WordArena
    43open Lax560851.RamComplexity
    44
    45/-- Constructor size of an intrinsic MSO sentence, including its term and
    46relation fields but excluding any physical arena layout. -/
    47def sentenceSize (alphabet : RankedAlphabetCode)
    48 (phi : Sentence (treeSignature alphabet.toRankedAlphabet)) : Nat :=
    49 (formulaStructure alphabet phi).nodes
    50
    51/-- Mathematical parameter size controlling the formula-dependent part of
    52the uniform algorithm. Symbol arity is explicit because one natural payload
    53can prescribe an arbitrarily large finite family. -/
    54def parameterSize (alphabet : RankedAlphabetCode)
    55 (phi : Sentence (treeSignature alphabet.toRankedAlphabet)) : Nat :=
    56 (derivedPresentation : Presentation RankedAlphabetCode).structuralSize alphabet +
    57 sentenceSize alphabet phi + maximumRank alphabet
    58
    59/-- A complete dependent model-checking input, bundled as one ordinary type
    60for use with the reusable Lax560851 RAM-complexity predicate. -/
    61structure ModelCheckingInstance where
    62 alphabet : RankedAlphabetCode
    63 sentence : Sentence (treeSignature alphabet.toRankedAlphabet)
    64 tree : Tree alphabet.toRankedAlphabet
    65
    66/-- Complete constructor-derived content of one uniform model-checking
    67instance. The dependent typing of the sentence and tree is enforced before
    68this representation is formed. -/
    69def msoTreeRaw (alphabet : RankedAlphabetCode)
    70 (phi : Sentence (treeSignature alphabet.toRankedAlphabet))
    71 (t : Tree alphabet.toRankedAlphabet) : Raw :=
    72 Raw.constructor "msoModelChecking"
    73 [(derivedPresentation : Presentation RankedAlphabetCode).toRaw alphabet,
    74 formulaStructure alphabet phi,
    75 treeStructure alphabet t]
    76
    77/-- Exact structural content of a bundled uniform model-checking input. -/
    78def modelCheckingInstanceRaw (input : ModelCheckingInstance) : Raw :=
    79 msoTreeRaw input.alphabet input.sentence input.tree
    80
    81/-- Presentation used by the reusable RAM predicate. Its encoder is exactly
    82`msoTreeRaw`, so bundling introduces no tags, advice, or alternate layout. -/
    83noncomputable def modelCheckingPresentation :
    84 Presentation ModelCheckingInstance :=
    85 presentationOf modelCheckingInstanceRaw
    86
    87/-- Structural size of the complete uniform runtime input. -/
    88def inputStructuralSize (alphabet : RankedAlphabetCode)
    89 (phi : Sentence (treeSignature alphabet.toRankedAlphabet))
    90 (t : Tree alphabet.toRankedAlphabet) : Nat :=
    91 (msoTreeRaw alphabet phi t).nodes
    92
    93/-- Largest primitive natural payload in the complete uniform input. -/
    94def inputPayloadMax (alphabet : RankedAlphabetCode)
    95 (phi : Sentence (treeSignature alphabet.toRankedAlphabet))
    96 (t : Tree alphabet.toRankedAlphabet) : Nat :=
    97 (msoTreeRaw alphabet phi t).maxNat
    98
    99/-- Primitive payloads in the complete uniform input fit in a `w`-bit word. -/
    100def InputPayloadsFitInWord (alphabet : RankedAlphabetCode)
    101 (phi : Sentence (treeSignature alphabet.toRankedAlphabet))
    102 (t : Tree alphabet.toRankedAlphabet) (w : Nat) : Prop :=
    103 (msoTreeRaw alphabet phi t).PayloadsFitInWord w
    104
    105/-- Distinguished Lax808846 input containing the alphabet, intrinsic sentence,
    106and tree. -/
    107def modelCheckingInput (alphabet : RankedAlphabetCode)
    108 (phi : Sentence (treeSignature alphabet.toRankedAlphabet))
    109 (t : Tree alphabet.toRankedAlphabet) : List Nat :=
    110 (encodeRaw (msoTreeRaw alphabet phi t)).toInput
    111
    112/-- The actual instruction allowance for the uniform model checker. The
    113computable coefficient absorbs sentence compilation and the automaton
    114workload; the remaining dependence is linear in tree nodes. -/
    115def uniformTimeBound (coefficient : Nat → Nat)
    116 (alphabet : RankedAlphabetCode)
    117 (phi : Sentence (treeSignature alphabet.toRankedAlphabet))
    118 (t : Tree alphabet.toRankedAlphabet) : Nat :=
    119 coefficient (parameterSize alphabet phi) * (treeSize t + 1)
    120
    121/-- Public word-resource allowance for the uniform implementation. -/
    122def uniformWordBound (coefficient : Nat → Nat)
    123 (alphabet : RankedAlphabetCode)
    124 (phi : Sentence (treeSignature alphabet.toRankedAlphabet))
    125 (t : Tree alphabet.toRankedAlphabet) : Nat :=
    126 coefficient (parameterSize alphabet phi) *
    127 (inputStructuralSize alphabet phi t + inputPayloadMax alphabet phi t + 1)
    128
    129open Classical in
    130/-- A single program handles every alphabet, intrinsic sentence, tree, and
    131sufficient word width. Formula compilation is part of this measured run. -/
    132axiom exists_uniform_msoModelChecking :
    133 ∃ timeCoefficient wordCoefficient : Nat → Nat,
    134 Computable timeCoefficient ∧ Computable wordCoefficient ∧
    135 RamComputableWithinUsing modelCheckingPresentation natOutput
    136 (fun input => if input.treesentenceLanguage input.sentence then 1 else 0)
    137 (fun input => uniformTimeBound timeCoefficient input.alphabet
    138 input.sentence input.tree)
    139 (fun input => uniformWordBound wordCoefficient input.alphabet
    140 input.sentence input.tree)
    141
    142/-- Structural size of a tree-only fixed-parameter input. -/
    143def treeStructuralSize (alphabet : RankedAlphabetCode)
    144 (t : Tree alphabet.toRankedAlphabet) : Nat :=
    145 (treeStructure alphabet t).nodes
    146
    147/-- Largest primitive payload in a tree-only fixed-parameter input. -/
    148def treePayloadMax (alphabet : RankedAlphabetCode)
    149 (t : Tree alphabet.toRankedAlphabet) : Nat :=
    150 (treeStructure alphabet t).maxNat
    151
    152/-- Primitive tree payloads fit in a `w`-bit word. -/
    153def TreePayloadsFitInWord (alphabet : RankedAlphabetCode)
    154 (t : Tree alphabet.toRankedAlphabet) (w : Nat) : Prop :=
    155 (treeStructure alphabet t).PayloadsFitInWord w
    156
    157/-- Distinguished tree-only input for a program specialized to a fixed
    158alphabet and sentence. -/
    159def treeInput (alphabet : RankedAlphabetCode)
    160 (t : Tree alphabet.toRankedAlphabet) : List Nat :=
    161 (encodeRaw (treeStructure alphabet t)).toInput
    162
    163end Lax842588.MSOLinearTime
    164
    Show Proof

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…