No public endorsements yet.
Loading review…
Sign in with ORCIDConcept map
Definition
A formula of monadic second-order logic over graphs is built from three atoms — two vertices are adjacent, two vertices are equal, a vertex belongs to a set — by negation, conjunction, and quantification over vertices and over sets of vertices. A formula holds in a graph under an assignment of vertices to its free vertex variables and of sets of vertices to its free set variables, by the usual reading of the connectives and the quantifiers. The quantifier rank of a formula is the nesting depth of its quantifiers, counting both kinds.
Lean source view on GitHub
| 1 | import Mathlib.Combinatorics.SimpleGraph.Basic |
| 2 | import Mathlib.Data.Fin.Tuple.Basic |
| 3 | |
| 4 | /-! |
| 5 | --- |
| 6 | title: Monadic second-order logic on graphs |
| 7 | type: definition |
| 8 | --- |
| 9 | A formula of monadic second-order logic over graphs is built from three |
| 10 | atoms — two vertices are adjacent, two vertices are equal, a vertex |
| 11 | belongs to a set — by negation, conjunction, and quantification over |
| 12 | vertices and over sets of vertices. A formula holds in a graph under an |
| 13 | assignment of vertices to its free vertex variables and of sets of |
| 14 | vertices to its free set variables, by the usual reading of the |
| 15 | connectives and the quantifiers. The quantifier rank of a formula is |
| 16 | the nesting depth of its quantifiers, counting both kinds. |
| 17 | |
| 18 | # Formalization notes |
| 19 | |
| 20 | Free variables are counted rather than named: `MSO r s` is the type of |
| 21 | formulas with `r` free vertex variables and `s` free set variables, and |
| 22 | a quantifier turns a formula with one more free variable of its kind |
| 23 | into a formula with one fewer. Satisfaction is therefore a total |
| 24 | function of a formula and two environments, `Fin r → Fin n` and |
| 25 | `Fin s → Set (Fin n)`, one entry per free variable: there is no partial |
| 26 | valuation, no default value for an unassigned variable, and no |
| 27 | well-formedness side condition. A sentence is a formula of `MSO 0 0`, |
| 28 | so being closed is a property of the type rather than a predicate to |
| 29 | check. The price is that variables are de Bruijn positions rather than |
| 30 | names; the alternative, named variables, needs capture-avoiding |
| 31 | substitution *inside the trusted definition*, which is a considerably |
| 32 | worse object to audit than an index. |
| 33 | |
| 34 | Variables are levels, not indices: a quantifier extends the environment |
| 35 | at its *last* position (`Fin.snoc`), so the outermost bound variable of |
| 36 | a formula is `0` and the innermost is the last. Nothing in the |
| 37 | definition shifts an index. |
| 38 | |
| 39 | Only negation, conjunction and existential quantification are |
| 40 | constructors. Disjunction, implication and universal quantification are |
| 41 | the usual abbreviations, written out where they are used: each of them |
| 42 | as a constructor would add a case to the definition of satisfaction and |
| 43 | buy nothing that is not already there. |
| 44 | |
| 45 | The logic is monadic second-order logic in its MSO₁ form — |
| 46 | quantification over vertices and over *sets of vertices*, with |
| 47 | adjacency, equality and membership as the atoms. Sets of edges are not |
| 48 | quantified over. This is not a step on the way to a fuller version that |
| 49 | was left unfinished: MSO₁ and MSO₂, the logic that also quantifies over |
| 50 | edges and sets of edges, are matched to different width measures. MSO₂ |
| 51 | model checking is tractable on classes of bounded treewidth and is *not* |
| 52 | tractable on classes of bounded cliquewidth unless the standard |
| 53 | complexity assumptions fail, so a development that proved the MSO₁ |
| 54 | statement for cliquewidth and then claimed MSO₂ "by the same argument" |
| 55 | would be claiming something false. MSO₂ needs its own encoding — the |
| 56 | incidence graph, or edge-set variables in the type algebra — and is |
| 57 | deferred as one unit, logic and width measure together. |
| 58 | -/ |
| 59 | |
| 60 | namespace Lax11.Mso |
| 61 | |
| 62 | /-- Formulas of monadic second-order logic over the adjacency |
| 63 | signature, with `r` free vertex variables and `s` free set variables. |
| 64 | Vertex variables are `Fin r`, set variables are `Fin s`, and a |
| 65 | quantifier binds the *new last* index. -/ |
| 66 | inductive MSO : ℕ → ℕ → Type |
| 67 | /-- The vertices `i` and `j` are adjacent. -/ |
| 68 | | adj {r s : ℕ} (i j : Fin r) : MSO r s |
| 69 | /-- The vertices `i` and `j` are equal. -/ |
| 70 | | eq {r s : ℕ} (i j : Fin r) : MSO r s |
| 71 | /-- The vertex `i` belongs to the set `X`. -/ |
| 72 | | mem {r s : ℕ} (i : Fin r) (X : Fin s) : MSO r s |
| 73 | /-- Negation. -/ |
| 74 | | not {r s : ℕ} (φ : MSO r s) : MSO r s |
| 75 | /-- Conjunction. -/ |
| 76 | | and {r s : ℕ} (φ ψ : MSO r s) : MSO r s |
| 77 | /-- There is a vertex satisfying `φ`, bound at the last index. -/ |
| 78 | | exV {r s : ℕ} (φ : MSO (r + 1) s) : MSO r s |
| 79 | /-- There is a set of vertices satisfying `φ`, bound at the last |
| 80 | index. -/ |
| 81 | | exS {r s : ℕ} (φ : MSO r (s + 1)) : MSO r s |
| 82 | |
| 83 | /-- The quantifier rank: the nesting depth of quantifiers, counting |
| 84 | both kinds. -/ |
| 85 | def rank : {r s : ℕ} → MSO r s → ℕ |
| 86 | | _, _, .adj _ _ => 0 |
| 87 | | _, _, .eq _ _ => 0 |
| 88 | | _, _, .mem _ _ => 0 |
| 89 | | _, _, .not φ => rank φ |
| 90 | | _, _, .and φ ψ => max (rank φ) (rank ψ) |
| 91 | | _, _, .exV φ => rank φ + 1 |
| 92 | | _, _, .exS φ => rank φ + 1 |
| 93 | |
| 94 | variable {n : ℕ} |
| 95 | |
| 96 | /-- Satisfaction of a formula in the graph `G`, under a vertex |
| 97 | environment `m` and a set environment `A`. -/ |
| 98 | def Sat (G : SimpleGraph (Fin n)) : |
| 99 | {r s : ℕ} → (Fin r → Fin n) → (Fin s → Set (Fin n)) → MSO r s → Prop |
| 100 | | _, _, m, _, .adj i j => G.Adj (m i) (m j) |
| 101 | | _, _, m, _, .eq i j => m i = m j |
| 102 | | _, _, m, A, .mem i X => m i ∈ A X |
| 103 | | _, _, m, A, .not φ => ¬ Sat G m A φ |
| 104 | | _, _, m, A, .and φ ψ => Sat G m A φ ∧ Sat G m A ψ |
| 105 | | _, _, m, A, .exV φ => ∃ v : Fin n, Sat G (Fin.snoc m v) A φ |
| 106 | | _, _, m, A, .exS φ => ∃ S : Set (Fin n), Sat G m (Fin.snoc A S) φ |
| 107 | |
| 108 | end Lax11.Mso |
| 109 |
Formalization notes
Free variables are counted rather than named: is the type of formulas with free vertex variables and free set variables, and a quantifier turns a formula with one more free variable of its kind into a formula with one fewer. Satisfaction is therefore a total function of a formula and two environments, and , one entry per free variable: there is no partial valuation, no default value for an unassigned variable, and no well-formedness side condition. A sentence is a formula of , so being closed is a property of the type rather than a predicate to check. The price is that variables are de Bruijn positions rather than names; the alternative, named variables, needs capture-avoiding substitution inside the trusted definition, which is a considerably worse object to audit than an index.
Variables are levels, not indices: a quantifier extends the environment at its last position (), so the outermost bound variable of a formula is and the innermost is the last. Nothing in the definition shifts an index.
Only negation, conjunction and existential quantification are constructors. Disjunction, implication and universal quantification are the usual abbreviations, written out where they are used: each of them as a constructor would add a case to the definition of satisfaction and buy nothing that is not already there.
The logic is monadic second-order logic in its MSO₁ form — quantification over vertices and over sets of vertices, with adjacency, equality and membership as the atoms. Sets of edges are not quantified over. This is not a step on the way to a fuller version that was left unfinished: MSO₁ and MSO₂, the logic that also quantifies over edges and sets of edges, are matched to different width measures. MSO₂ model checking is tractable on classes of bounded treewidth and is not tractable on classes of bounded cliquewidth unless the standard complexity assumptions fail, so a development that proved the MSO₁ statement for cliquewidth and then claimed MSO₂ "by the same argument" would be claiming something false. MSO₂ needs its own encoding — the incidence graph, or edge-set variables in the type algebra — and is deferred as one unit, logic and width measure together.
Builds on
none
Used by
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