Draft — mutable and not usable as a dependency; its citation marks the draft state.

Lax11.Courcelle

Courcelle's theorem on a word RAM

concepts/Lax11/Courcelle.lean · lax-11

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.

    Concept map

    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Evidence

    Each proof establishes this claim relative to its assumptions.

    Theorem

    Every property of graphs expressible in monadic second-order logic can be decided in linear time on graphs of bounded cliquewidth, given a k-expression for the graph. Fix a sentence and a width bound k; then there are one word RAM program and one constant c such that, at every word length, given any graph in compressed sparse row form followed by a k-expression that evaluates to it, as a word x each of whose entries v satisfies c(|x|+v+1) ≤ 2w2 ^ w, the program halts within c(|x|+1) steps and writes 11 if the sentence holds in the graph and 00 if it does not.

    This is the Courcelle–Makowsky–Rotics form of Courcelle's theorem: the width measure is cliquewidth and the logic is monadic second-order logic with quantification over vertices and vertex sets, which is the pairing the two notions are matched to.

    Lean source view on GitHub

    1import Lax67.RamComputes
    2import Lax11.Mso
    3import Lax11.InstanceEncoding
    4
    5/-!
    6---
    7title: Courcelle's theorem on a word RAM
    8type: theorem
    9---
    10Every property of graphs expressible in monadic second-order logic can
    11be decided in linear time on graphs of bounded cliquewidth, given a
    12*k*-expression for the graph. Fix a sentence and a width bound *k*; then
    13there are one word RAM program and one constant *c* such that, at every
    14word length, given any graph in compressed sparse row form followed by a
    15*k*-expression that evaluates to it, as a word *x* each of whose entries
    16*v* satisfies *c*(|x|+*v*+1) ≤ `2 ^ w`, the program halts within
    17*c*(|x|+1) steps and writes `1` if the sentence holds in the graph and
    18`0` if it does not.
    19
    20This is the Courcelle–Makowsky–Rotics form of Courcelle's theorem: the
    21width measure is cliquewidth and the logic is monadic second-order
    22logic with quantification over vertices and vertex sets, which is the
    23pairing the two notions are matched to.
    24
    25# Formalization notes
    26
    27The expression is *input*, not something the program computes. Deciding
    28cliquewidth, or approximating it, is a different theorem with a
    29different proof, and folding it in here would silently claim it; the
    30statement is the honest one, "given a graph together with a
    31*k*-expression for it". This is the same choice a treewidth-based
    32statement makes when it takes a tree decomposition as input.
    33
    34The order of the quantifiers is the content of the theorem: the
    35sentence and the width bound come first, then the program and the
    36constant, then the graph and the word length. So one program serves all
    37graphs of cliquewidth at most *k* at every word length, with one
    38constant, but both may depend — and in every known proof do depend, in a
    39way that grows faster than any tower of exponentials in the sentence —
    40on the sentence and the width. Nothing here estimates the constant. This
    41is the opposite ordering from the vertex cover statement of this
    42submission, and it has to be: there the parameter is an entry of the
    43input word, so one program can read it and serve every parameter, while
    44here the sentence is not part of the input at all and a program that has
    45never seen it cannot decide it. Quantifying the program before the word
    46length says the same thing about `w` as everywhere else in this
    47submission — one program that works at every word length that admits its
    48input, rather than a family of programs, one of which could hide an
    49arbitrary amount of information in its literals.
    50
    51One constant does both jobs, and the condition it appears in says two
    52things at once. The first is that the running time fits: taking *v* to
    53be any entry of the word — an instance word is never empty — the
    54condition gives *c*(|x|+1) ≤ `2 ^ w`, so `2 ^ w` is at least the number
    55of steps the claim allows, and with it every quantity the program forms
    56out of the length of the word, the number of nodes of the expression and
    57the addresses of the arrays included. The four tables of the dynamic
    58program are also covered, since their sizes depend on the sentence and
    59the width bound alone and are therefore absorbed into *c*, which is
    60chosen after both.
    61
    62The second is that the entries themselves fit, and this is why the
    63condition quantifies over them. A machine at word length `w` sees its
    64input reduced modulo `2 ^ w`, so an entry that is not a word is not the
    65entry it was handed. Most entries of an instance are small: vertex
    66numbers, offsets and node numbers are below the length of the word, and
    67an operation code is below the number of operations at width *k*, which
    68`c` covers. But not all of them are, because the format has slots the
    69encoding deliberately leaves free — the parent entry of the root,
    70through which nothing points, and the vertex name at a node whose
    71operation creates no vertex. Those may hold any number whatever, and
    72saying of every entry that it fits is what makes the claim about them
    73honest instead of silently assuming they are small. It is the same
    74bookkeeping the vertex cover statement of this submission does with
    75`c * (|x| + k + 1)`, where the one entry not bounded by the length is
    76the parameter.
    77
    78The fitting condition is a condition on the admissible inputs and not a
    79hypothesis of the claim, because as a hypothesis it would be empty. A
    80graph with an edge has encodings of every length, since a block may list
    81a neighbour repeatedly, so no word length accommodates all encodings of
    82a fixed graph at once and "if every instance for `G` and `k` fits into a
    83word" would never be satisfied. Restricting the inputs instead says what
    84is meant: at every word length, every instance that fits is decided
    85within the bound.
    86
    87Only encodings of `G` are admitted as inputs; the program may behave
    88arbitrarily on words that encode nothing, and on words too long for its
    89word length.
    90-/
    91
    92namespace Lax11.Courcelle
    93
    94open Lax67.Ram Lax67.RamComputes Lax11.Mso Lax11.InstanceEncoding
    95
    96open Classical in
    97/-- **Courcelle's theorem** (Courcelle–Makowsky–Rotics form): model
    98checking monadic second-order logic is linear time on a word random
    99access machine, for graphs presented together with a `k`-expression. For
    100every sentence and every width bound there are one program and one
    101constant such that, at every word length `w`, on every graph given in
    102compressed sparse row form followed by a `k`-expression for it as a word
    103`x` each of whose entries `v` satisfies `c * (x.length + v + 1) ≤ 2 ^ w`,
    104the program halts within a constant multiple of the length of the input,
    105having written `1` if the sentence holds in the graph and `0`
    106otherwise. -/
    107axiom exists_linearTime_program_modelChecking :
    108 ∀ (φ : MSO 0 0) (k : ℕ),
    109 ∃ (p : Program) (c : ℕ), ∀ (n : ℕ) (G : SimpleGraph (Fin n)) (w : ℕ),
    110 ComputesInTime w p
    111 {x | EncodesModelCheckingInstance x n G k ∧
    112 ∀ v ∈ x, c * (x.length + v + 1) ≤ 2 ^ w}
    113 (fun _ => if Sat G Fin.elim0 Fin.elim0 φ then [1] else [0])
    114 (fun x => c * (x.length + 1))
    115
    116end Lax11.Courcelle
    117
    Show Proof

    Formalization notes

    The expression is input, not something the program computes. Deciding cliquewidth, or approximating it, is a different theorem with a different proof, and folding it in here would silently claim it; the statement is the honest one, "given a graph together with a k-expression for it". This is the same choice a treewidth-based statement makes when it takes a tree decomposition as input.

    The order of the quantifiers is the content of the theorem: the sentence and the width bound come first, then the program and the constant, then the graph and the word length. So one program serves all graphs of cliquewidth at most k at every word length, with one constant, but both may depend — and in every known proof do depend, in a way that grows faster than any tower of exponentials in the sentence — on the sentence and the width. Nothing here estimates the constant. This is the opposite ordering from the vertex cover statement of this submission, and it has to be: there the parameter is an entry of the input word, so one program can read it and serve every parameter, while here the sentence is not part of the input at all and a program that has never seen it cannot decide it. Quantifying the program before the word length says the same thing about ww as everywhere else in this submission — one program that works at every word length that admits its input, rather than a family of programs, one of which could hide an arbitrary amount of information in its literals.

    One constant does both jobs, and the condition it appears in says two things at once. The first is that the running time fits: taking v to be any entry of the word — an instance word is never empty — the condition gives c(|x|+1) ≤ 2w2 ^ w, so 2w2 ^ w is at least the number of steps the claim allows, and with it every quantity the program forms out of the length of the word, the number of nodes of the expression and the addresses of the arrays included. The four tables of the dynamic program are also covered, since their sizes depend on the sentence and the width bound alone and are therefore absorbed into c, which is chosen after both.

    The second is that the entries themselves fit, and this is why the condition quantifies over them. A machine at word length ww sees its input reduced modulo 2w2 ^ w, so an entry that is not a word is not the entry it was handed. Most entries of an instance are small: vertex numbers, offsets and node numbers are below the length of the word, and an operation code is below the number of operations at width k, which cc covers. But not all of them are, because the format has slots the encoding deliberately leaves free — the parent entry of the root, through which nothing points, and the vertex name at a node whose operation creates no vertex. Those may hold any number whatever, and saying of every entry that it fits is what makes the claim about them honest instead of silently assuming they are small. It is the same bookkeeping the vertex cover statement of this submission does with c(x+k+1)c * (|x| + k + 1), where the one entry not bounded by the length is the parameter.

    The fitting condition is a condition on the admissible inputs and not a hypothesis of the claim, because as a hypothesis it would be empty. A graph with an edge has encodings of every length, since a block may list a neighbour repeatedly, so no word length accommodates all encodings of a fixed graph at once and "if every instance for GG and kk fits into a word" would never be satisfied. Restricting the inputs instead says what is meant: at every word length, every instance that fits is decided within the bound.

    Only encodings of GG are admitted as inputs; the program may behave arbitrarily on words that encode nothing, and on words too long for its word length.

    Used by

    none

    From Mathlib

    none

    Community review

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.

    0 comments

    Loading discussion…