Monadic second-order logic over words #
Monadic second-order logic (MSO) over finite words with alphabet α
Libkin, Section 7.4, Thomas, Section 3. A word w of length ℓ is the
structure with universe the positions Fin ℓ, their natural order <, and for each letter a the
unary predicate P_a = {i | w i = a}. Formulas have first-order variables ranging over positions
and monadic second-order (set) variables ranging over sets of positions, with atoms P_a(x),
x < y and x ∈ X, the connectives ⊥ and →, and existential quantifiers over both sorts.
Variables are de Bruijn-style: Formula α m n has m free first-order and n free set
variables, indexed by Fin m and Fin n. As for Mathlib's FirstOrder.Language.BoundedFormula,
a quantifier binds the last index (Fin.last), so an assignment is extended with Fin.snoc. A
sentence is a formula without free variables, and defines the language of the words whose
structure satisfies it. The empty word is the empty structure, in which every existential
quantifier is false and every universal quantifier is true; some sources restrict to nonempty words
instead.
Unlike the existential second-order sentences of Cslib.Logic.ESO (one block of existential
relation quantifiers over a first-order matrix), MSO allows arbitrary nesting and alternation of
set quantifiers, restricted to unary relations.
Main definitions #
Cslib.Logic.WordMSO.Formula,Cslib.Logic.WordMSO.Formula.Realize: formulas and their satisfaction in a word structure under assignments of the free variables.Cslib.Logic.WordMSO.Formula.not,top,and,or,all,allSet,eq,iInf,iSup: derived connectives, quantifiers, equality, and finite conjunctions and disjunctions.Cslib.Logic.WordMSO.Formula.first,last,succ: the first and last positions and the successor relation, defined from<.Cslib.Logic.WordMSO.Formula.IsFO: the first-order fragment, without set quantifiers.Cslib.Logic.WordMSO.Sentence,Cslib.Logic.WordMSO.Sentence.language: sentences and the language they define.Cslib.Logic.WordMSO.Definable,Cslib.Logic.WordMSO.FODefinable: MSO- and FO-definability of a language.
Main results #
Cslib.Logic.WordMSO.Formula.realize_and,realize_all,realize_eq,realize_iInf, ...: semantics of the derived connectives.Cslib.Logic.WordMSO.Formula.realize_first,realize_last,realize_succ: semantics of the defined position predicates.Cslib.Logic.WordMSO.Formula.isFO_and,isFO_all,not_isFO_exSet, ...: the first-order fragment is closed under the derived first-order connectives and excludes set quantifiers.Cslib.Logic.WordMSO.FODefinable.definable: first-order definable languages are MSO-definable.
References #
Formulas of monadic second-order logic over words with alphabet α, with m free
first-order (position) variables and n free monadic second-order (set) variables. Quantifiers
bind the last variable of their sort.
- letter {α : Type u} {m n : ℕ} (a : α) (x : Fin m) : Formula α m n
P_a(x): positionxcarries the lettera. - lt {α : Type u} {m n : ℕ} (x y : Fin m) : Formula α m n
x < yin the order of positions. - mem {α : Type u} {m n : ℕ} (x : Fin m) (X : Fin n) : Formula α m n
x ∈ X: positionxbelongs to the setX. - falsum {α : Type u} {m n : ℕ} : Formula α m n
Falsity.
- imp {α : Type u} {m n : ℕ} (φ ψ : Formula α m n) : Formula α m n
Implication.
- ex {α : Type u} {m n : ℕ} (φ : Formula α (m + 1) n) : Formula α m n
Existential quantification over positions, binding first-order variable
Fin.last m. - exSet {α : Type u} {m n : ℕ} (φ : Formula α m (n + 1)) : Formula α m n
Existential quantification over sets of positions, binding set variable
Fin.last n.
An MSO sentence over the alphabet α: a formula without free variables.
The language defined by a sentence: the words whose word structure satisfies it.
A language is MSO-definable when it is the language of some MSO sentence.
A language is first-order definable (in FO[<] with letter predicates) when it is the
language of some sentence without set quantifiers.
First-order definable languages are MSO-definable.