# MSOL over Strings

## Syntax and Semantics of Weak Monadic Second-Order Logic over Strings

Explanation of the name:

• second-order logic: we can quantify not only over elements but also over sets and relations
• monadic: we cannot quantify over any relations, just unary relations, that is, sets
• over strings: the domain of interpretation are not general graphs, but only strings, so the only built-in relation is a relation that gives us the next position in a string
• weak: we consider only finite strings

Alternative name is “monadic second-order logic of one successor”.

Minimalistic syntax for monadic second-order logic is: As the domain of interpretation we take the set of natural numbers . We interpret variables as finite subsets of this set, and as the subset relation. The relation is the successor relation on integers lifted to singleton sets.

More precisely, if then we have the following semantics: ## What can we express in MSOL over strings

Set operations. The ideas is that quantification over sets with gives us the full Boolean algebra of sets.

• Two sets are equal: • Strict subset: • Set is empty: • Set is full: • Set is singleton (has exactly 1 element): • Set membership, treating elements as singletons: • Intersection: • Union: • Set difference: (or just use element-wise definitions with singletons)

• If is a fixed constant, properties , , Transitive closure of a relation. If is a formula on singletons, we define reflexive transitive closure as follows. Define shorthand Then is defined by Using transitive closure and successors:

• Constant zero: • Addition by constant: • Ordering on positions in the string: • Reachability in -increments, that is, : • Congruence modulo : Representing integers. Note that although we interpret elements as sets of integers, we cannot even talk about addition of two arbitrary integers , only addition with a constant. Also, although we can say we cannot say in how many steps we reach from . However, if we view sets of integers digits of a binary representation of another integer, then we can express much more. If is a finite set, let represent the number whose digits are , that is: Then we can define addition by saying that there exists a set of carry bits such that the rules for binary addition hold: where This way we can represent entire Presburger arithmetic in MSOL over strings. Moreover, we have more expressive power because means that the one bits of are included in the bits of , that is, the bitwise or of and is equal to . In fact, if we add the relation of bit inclusion into Presburger arithmetic, we obtain precisely the expressive power of MSOL when sets are treated as binary representations of integers (Indeed, taking the minimal syntax of MSOL from the beginning, the bit inclusion gives us the subset, whereas the successor relation is expressible using .)