0% found this document useful (0 votes)
19 views28 pages

Buchi Logical Characterization Regular Languages

The document summarizes Büchi's 1960 logical characterization of regular languages using monadic second-order logic (MSO). Some key points: - Büchi showed that a language is regular if and only if it can be described by an MSO sentence over the alphabet. - MSO allows quantification over positions in a string and subsets of positions. - An example MSO sentence is given that defines the language of strings of odd length over the alphabet {a,b}. - The construction of an MSO sentence from a deterministic finite automaton that defines the same language is outlined.

Uploaded by

pnddle1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views28 pages

Buchi Logical Characterization Regular Languages

The document summarizes Büchi's 1960 logical characterization of regular languages using monadic second-order logic (MSO). Some key points: - Büchi showed that a language is regular if and only if it can be described by an MSO sentence over the alphabet. - MSO allows quantification over positions in a string and subsets of positions. - An example MSO sentence is given that defines the language of strings of odd length over the alphabet {a,b}. - The construction of an MSO sentence from a deterministic finite automaton that defines the same language is outlined.

Uploaded by

pnddle1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Büchi’s Logical Characterisation of Regular

Languages

Meenakshi D’Souza

IIIT-Bangalore.

Term II 2023-’24.
Background

Büchi’s motivation: Decision procedure for deciding truth of


first-order logic statements about natural numbers and their
ordering. Eg.
∀x∃y (x < y ).
Used finite-state automata to give a decision procedure.
By-product: a logical characterisation of regular languages.

Theorem (Büchi 1960)


L is regular iff L can be described in Monadic-Second Order Logic.
First-Order logic of (N, <).

Interpreted over N = {0, 1, 2, 3, . . .}.


What you can say:

x < y , ∃xϕ, ∀xϕ, ¬, ∧, ∨.

Examples:
1 ∀x∃y (x < y ).
First-Order logic of (N, <).

Interpreted over N = {0, 1, 2, 3, . . .}.


What you can say:

x < y , ∃xϕ, ∀xϕ, ¬, ∧, ∨.

Examples:
1 ∀x∃y (x < y ).
2 ∀x∃y (y < x).
First-Order logic of (N, <).

Interpreted over N = {0, 1, 2, 3, . . .}.


What you can say:

x < y , ∃xϕ, ∀xϕ, ¬, ∧, ∨.

Examples:
1 ∀x∃y (x < y ).
2 ∀x∃y (y < x).
3 ∃x(∀y (y ≤ x)).
First-Order logic of (N, <).

Interpreted over N = {0, 1, 2, 3, . . .}.


What you can say:

x < y , ∃xϕ, ∀xϕ, ¬, ∧, ∨.

Examples:
1 ∀x∃y (x < y ).
2 ∀x∃y (y < x).
3 ∃x(∀y (y ≤ x)).
4 ∃x(∀y (x ≤ y )).
First-Order logic of (N, <).

Interpreted over N = {0, 1, 2, 3, . . .}.


What you can say:

x < y , ∃xϕ, ∀xϕ, ¬, ∧, ∨.

Examples:
1 ∀x∃y (x < y ).
2 ∀x∃y (y < x).
3 ∃x(∀y (y ≤ x)).
4 ∃x(∀y (x ≤ y )).
5 ∀x∀y ((x < y ) =⇒ ∃z(x < z < y )).
First-Order logic of (N, <).

Interpreted over N = {0, 1, 2, 3, . . .}.


What you can say:

x < y , ∃xϕ, ∀xϕ, ¬, ∧, ∨.

Examples:
1 ∀x∃y (x < y ).
2 ∀x∃y (y < x).
3 ∃x(∀y (y ≤ x)).
4 ∃x(∀y (x ≤ y )).
5 ∀x∀y ((x < y ) =⇒ ∃z(x < z < y )).
Sentences 1 and 4 are true over the given domain (N, <)
while others are not.
First-Order logic of (N, <).

Interpreted over N = {0, 1, 2, 3, . . .}.


What you can say:

x < y , ∃xϕ, ∀xϕ, ¬, ∧, ∨.

Examples:
1 ∀x∃y (x < y ).
2 ∀x∃y (y < x).
3 ∃x(∀y (y ≤ x)).
4 ∃x(∀y (x ≤ y )).
5 ∀x∀y ((x < y ) =⇒ ∃z(x < z < y )).
Sentences 1 and 4 are true over the given domain (N, <)
while others are not.
Question: Is there an algorithm to decide if a given FO(N, <)
sentence is true or not?
First-Order Logic

A First-Order Logic usually has a signature comprising the


constants, and function/relation symbols. Eg. (0, <, +).
Terms are expressions built out of the constants and variables
and function symbols. Eg. 0, x + y , (x + y ) + 0. They are
interpreted as elements of the domain of interpretation.
Atomic formulas are obtained using the relation symbols on
terms of the logic. Eg. x < y , x = 0 + y , x + y < 0.
Formulas are obtained from atomic formulas using boolean
operators, and existential quantification (∃x) and universal
quantification (∀x). Eg. ¬(x < y ), (x < 0) ∧ (x = y ),
∃x(∀y (x < y ) ∧ (z < x)).
First-Order Logic

Given a “structure” (i.e. a domain, a concrete interpretation


for each constant and function/relation symbol) and an
assignment for variables to values in the domain) to interpret
the formulas in, each formula is either true or false.
A formula is called a sentence if it has no free (unquantified)
variables.
Second-Order Logic

In Second-Order logic, one allows quantification over relations


over the domain (not just elements of the domain). Eg:

∃R (2) (R (2) (x, y ) =⇒ x < y ).

In Monadic second-order logic, one allows quantification over


monadic relations (i.e. relations of arity one, or equivalently,
subsets of the domain). Eg: only 1 element

∃X (x ∈ X =⇒ 0 < x).
Monadic Second-Order logic over alphabet A: MSO(A)
Section 1.1 & 1.2 of wolfgang book

Interpreted over a string w ∈ A∗ .


w = a a b a b a b a b
0 1 2 3 4 5 6 7 8

Domain is set of positions in w : {0, 1, 2, . . . , |w | − 1}.


“<” is interpretated as usual < over numbers.
What we can say in the logic:
Qa (x): “Position x is labelled a”.
x < y : “Position x is strictly less than position y ”.
∃xϕ: “There exists a position x ...”
∀xϕ: “For all positions x ...”
∃X ϕ: “There exists a set of positions X ...”
∀X ϕ: “For all sets of positions X ...”
x ∈ X : “Position x belongs to the set of positions X ”.
Example MSO({a, b}) formulas

Consider the alphabet {a, b}.


What language do the sentences below define?
1 ∃x(¬∃y (y < x) ∧ Qa (x)).
2 ∃y (¬∃x(y < x) ∧ Qb (y )).
3 ∃x∃y ∃z(succ(x, y ) ∧ succ(y , z) ∧ last(z) ∧ (Qb (x)).
Example MSO({a, b}) formulas
Sentence 1: "There exists an x such that it is not
the case that there exists a y less than x and Qa
holds for x."
Sentence 2: "There exists a y such that it is not the
Consider the alphabet {a, b}. case that there exists an x less than y and Qb holds
for y."
What language do the sentences below define?
Sentence 3: "There exist x, y, and z such that y is
1 ∃x(¬∃y (y < x) ∧ Qa (x)). the successor of x, z is the successor of y, z is the
last element, and Qb holds for x."
2 ∃y (¬∃x(y < x) ∧ Qb (y )).
3 ∃x∃y ∃z(succ(x, y ) ∧ succ(y , z) ∧ last(z) ∧ (Qb (x)).

Give sentences that describe the following languages:


1 Every a is immediately followed by a b.
2 Strings of odd length.
MSO sentence for strings of odd length

Language L ⊆ {a, b}∗ of strings of odd length.


a a b a b a b a b
Xe 1 0 1 0 1 0 1 0 1
Xo 0 1 0 1 0 1 0 1 0

∃Xe ∃Xo (∃x(x ∈ Xe ) ∧ (∀x((x ∈ Xe =⇒ ¬x ∈ Xo ) ∧


(x ∈ Xo =⇒ ¬x ∈ Xe ) ∧
(x ∈ Xe ∨ x ∈ Xo ) ∧
(zero(x) =⇒ x ∈ Xe ) ∧
(∀y ((x ∈ Xe ∧ succ(x, y )) =⇒ y ∈ Xo )) ∧
(∀y ((x ∈ Xo ∧ succ(x, y )) =⇒ y ∈ Xe )) ∧
(last(x) =⇒ x ∈ Xe )))).
Formal Semantics of MSO

An interpretation for the logic will be a pair (w , I) where


w ∈ A∗ and I is an assignment of “individual” variables to a
position in w , and “set” variables to a set of positions in w .

I : Var → pos(w ) ∪ 2pos(w ) .

I[i/x] denotes the assignment which maps x to i and agrees


with I on all other individual and set variables.
Similarly for I[S/X ].
Formal Semantics of MSO

The satisfaction relation w , I |= ϕ is given by:

w , I |= Qa (x) iff w (I(x)) = a


w , I |= x < y iff I(x) < I(y )
w , I |= x ∈ X iff I(x) ∈ I(X )
w , I |= ¬ϕ iff w , I 6|= ϕ
w , I |= ϕ ∨ ϕ0 iff w , I |= ϕ or w , I |= ϕ0
w , I |= ∃xϕ iff exists i ∈ pos(w ) s.t. w , I[i/x] |= ϕ
w , I |= ∃X ϕ iff exists S ⊆ pos(w )s.t w , I[S/X ] |= ϕ
MSO sentences

A sentence is a formula with no free variables.


For example ∃X (y ∈ X =⇒ 0 < y ) is not a sentence since y
occurs free.
∃X (0 ∈ X =⇒ ∃y (0 < y ∧ y ∈ X )) is a sentence.
If ϕ is a sentence, then we don’t need an interpretation for
variables to say if ϕ is true or false of a given word w :

w |= ϕ.

For a sentence ϕ, we can define the language of words that


satisfy ϕ:
L(ϕ) = {w ∈ A∗ | w |= ϕ}.
Languages definable by MSO

We say that a language L ⊆ A∗ is definable in MSO(A) if


there is a sentence ϕ in MSO(A) such that L(ϕ) = L.

Theorem (Büchi 1960 (also Elgot ’61 and Traktenbrot 62))


L ⊆ A∗ is regular iff L is definable in MSO(A).
From automata to MSO sentence

Let L ⊆ A∗ be regular. Let A = (Q, s, δ, F ) be a DFA for L.


To show L is definable in MSO(A).
Idea: Construct a sentence ϕA describing an accepting run of
A on a given word.
That is: ϕA is true over a given word w precisely when A has
an accepting run on w .
Let Q = {q1 , . . . , qn }, with q1 = s.
Define ϕA as
V W
∃X1 · · · ∃Xn (∀x( ( i6=j (x ∈ Xi =⇒ ¬x ∈ Xj ) ∧ i x ∈ Xi ) ∧
(zero(x)
V =⇒ x ∈ X1 ) ∧
( a∈A, i,j∈{1,...n}, δ(qi ,a)=qj ((x ∈ Xi ∧ Qa (x) ∧ ¬last(x)) =⇒
W ∃y (succ(x, y ) ∧ y ∈ Xj ))) ∧
(last(x) =⇒ a∈A, δ(qi ,a)∈F (Qa (x) ∧ x ∈ Xi )))).
Example
Consider language L ⊆ {a, b}∗ of strings of even length.
a, b

DFA A for L:
e o
a, b

a a b a b a b a b
Xe 1 0 1 0 1 0 1 0 1
Xo 0 1 0 1 0 1 0 1 0

ϕA :
∃Xe ∃Xo (∀x( (x ∈ Xe =⇒ ¬x ∈ Xo ) ∧ (x ∈ Xo =⇒ ¬x ∈ Xe ) ∧
(x ∈ Xe ∨ x ∈ Xo ) ∧
(zero(x) =⇒ x ∈ Xe ) ∧
((x ∈ Xe ∧ Qa (x) ∧ ¬last(x)) =⇒ ∃y (succ(x, y ) ∧ y ∈ Xo )) ∧
((x ∈ Xe ∧ Qb (x) ∧ ¬last(x)) =⇒ ∃y (succ(x, y ) ∧ y ∈ Xo )) ∧
((x ∈ Xo ∧ Qa (x) ∧ ¬last(x)) =⇒ ∃y (succ(x, y ) ∧ y ∈ Xe )) ∧
((x ∈ Xo ∧ Qb (x) ∧ ¬last(x)) =⇒ ∃y (succ(x, y ) ∧ y ∈ Xe )) ∧
(last(x) =⇒ ((Qa (x) ∧ x ∈ Xo ) ∨ (Qb (x) ∧ x ∈ Xo ))))).
From MSO sentence to automaton

Idea: Inductively describe the language of extended models of


a given MSO formula ϕ by an automaton Aϕ .
Extended models wrt set of first-order and second-order
variables T = {x1 , . . . , xm , X1 , . . . , Xn }: (w , I)
Can be represented as a word over A × {0, 1}m+n .
a a b a b a b a b
x1 0 1 0 0 0 0 0 0 0
x2 0 0 0 0 1 0 0 0 0
X1 1 0 1 0 1 0 1 0 1
X2 0 1 0 1 0 1 0 1 0

For example above extended word satisfies the formula

Qa (x1 ) ∧ (x2 ∈ X1 ).
Inductive construction of ATϕ .

If ϕ is a formula whose free variables are in T , then we have


the notion of whether w 0 |= ϕ based on whether the (w , I)
encoded by w 0 satisfies ϕ or not.
Let the set of valid extended words wrt T be valid T (A).
We can define an automaton AT
val which accepts this set.
Claim: with every formula ϕ in MSO(A), and any finite set of
variables T containing at least the free variables of ϕ, we can
construct an automaton AT ϕ which accepts the language
T
L (ϕ).
Proof: by induction on structure of ϕ.

Qa (x), x < y , x ∈ Y , ¬ϕ, ϕ ∨ ψ, ∃xϕ, ∃X ϕ.


Example formula

∃x

∃x(Qa (x) ∧ ¬∃y (x < y )) Qa (x) ¬

∃y

x <y
Back to First-Order logic of (N, <).

Interpreted over N = {0, 1, 2, 3, . . .}.


What you can say:

x < y , ∃xϕ, ∀xϕ, ¬, ∧, ∨.

Examples:
1 ∀x∃y (x < y ).
2 ∀x∃y (y < x).
3 ∃x(∀y (y ≤ x)).
4 ∀x∀y ((x < y ) =⇒ ∃z(x < z < y )).
Question: Is there an algorithm to decide if a given FO(N, <)
sentence is true or not?
Büchi’s decision procedure for MSO(N, <)
Büchi considered finite automata over infinite strings (so
called ω-automata).
An infinite word is accepted if there is a run of the automaton
on it that visits a final state inifinitely often.
Büchi showed that ω-automata have similar properties to
classical automata: are closed under boolean operations,
projection, and can be effectively checked for emptiness.
MSO characterisation works similarly for ω-automata as well.
Given a sentence ϕ in MSO(N, <) we can now view it as an
MSO({a}) sentence.
Construct an ω-automaton Aϕ that accepts precisely the
words that satisfy ϕ.
Check if L(Aϕ ) is non-empty.
If non-empty say “Yes, ϕ is true”, else say “No, it is not true.”
Summary

Another characterisation of the class of regular languages, this


time via logic:
Theorem (Büchi 1960)
L ⊆ A∗ is regular iff L is definable in MSO(A).

An application of automata theory to solve a decision


procedure in logic:
Theorem (Büchi 1960)
The Monadic Second-Order (MSO) logic of (N, <) is decidable.

You might also like