Finite Model Theory Tutorial
On the Expressive Power of Logics
Phokion G. Kolaitis
Computer Science Department
University of California, Santa Cruz
Finite Model Theory
The study of logics on classes of nite structures
Examples of Logics
{ First-order logic
{ Second-order logic (and its fragments)
{ Logics with xed-point operators
{ Innitary logics
{ Logics with generalized quantiers.
Examples of Classes of Finite Structures
{ The class of all nite graphs
{ The class of all nite ordered graphs
{ The class of all nite planar graphs
{ The class of all nite strings
{ The class of all nite trees.
2
Reasons for Developing Finite Model Theory
Connections and applications to CS
Interactions with several areas of CS, including
{ database theory
{ computational complexity
{ computer-aided verication.
Study nite model theory in its own right
{ Traditional focus of mathematical logic has
been on xed innite structures or on classes
of nite and innite structures.
{ New phenomena emerge, when one focuses
on classes of nite structures.
3
Areas of Research in Finite Model Theory
Expressive Power of Logics
{ this tutorial
Logic and Computational Complexity
{ tutorial by Erich Gradel
Logic and Asymptotic Probabilities
{ tutorial by Joel Spencer
4
Basic Concepts
Denitions:
Vocabulary : a set = fR10 ; : : : ; Rm0 g of rela-
tion symbols of specied arities.
-structure A = (A; R1; : : : ; Rm):
a non-empty set A and relations on A such that
arity(Ri ) = arity(Ri0 ), 1 i m.
Finite -structure A: universe A is nite
Examples:
Graph: G = (V; E ), where E is binary.
Ordered Graph: G = (V; E; ), where E is
binary and is a linear order on V .
String: S = (f1; 2; : : : ; ng; P ), where P is unary
m 2 P () the m-th bit of the string is 1:
{ string 10001 encoded as (f1; 2; 3; 4; 5g; f1; 5g)
5
Queries
Denitions:
Class C of -structures: a collection of -structures
closed under isomorphisms.
k-ary Query Q on C :
a mapping Q with domain C and such that
{ Q(A) is a k-ary relation on A, for A 2 C ;
{ Q is preserved under isomorphisms , i.e.,
if h : A ! B is an isomorphism, then
Q(B) = h(Q(A)):
Boolean Query Q on C :
a mapping Q : C ! f0; 1g preserved under
isomorphisms. Thus, Q can be identied with
the subclass C 0 of C , where
C 0 = fA 2 C : Q(A) = 1g:
6
Examples of Queries
Transitive Closure TC :
Binary query on graphs G = (V; E ) such that
TC (G) = f(a; b) 2 V 2 : there is a path from a to bg:
Articulation Point AP :
Unary query on graphs G = (V; E ) such that
AP (G) = fa 2 V : a is an articulation point of Gg:
Connectivity CN :
Boolean query on graphs G = (V; E ) such that
CN (G) =
8
<1
:0
if G is connected
otherwise.
Acyclicity , k-Colorability , Hamiltonicity , ...
7
Denability of Queries
Let L be a logic and C a class of -structures
A k-ary query Q on C is L-denable if there is
an L-formula '(x1 ; : : : ; xk ) with x1 ; : : : ; xk as
free variables and such that for every A 2 C
Q(A) = f(a1 ; : : : ; ak ) 2 Ak : A j= '(a1 ; : : : ; ak )g:
A Boolean query Q on C is L-denable if there
is an L-sentence such that for every A 2 C
Q(A) = 1 () A j= :
L(C ) denotes the collection of all L-denable
queries on C .
8
First-Order Logic
Syntax of rst-order logic on graphs:
rst-order variables: x, y, z, . . .
atomic formulas: E (x; y), x = y
formulas: atomic formulas + connectives +
rst-order quantiers 9x, 8x, 9y, 8y, . . . that
range over the nodes of the graph.
Examples of rst-order denable queries:
\node x has at least two distinct neighbors"
(9y)(9z )(:(y = z ) ^ E (x; y) ^ E (x; z ))
\each node has at least two distinct neighbors"
(8x)(9y)(9z )(:(y = z ) ^ E (x; y) ^ E (x; z ))
\there is a path of length 3 from x to y"
(9z1 )(9z2 )(E (x; z1 ) ^ E (z1 ; z2 ) ^ E (z2 ; y))
9
Second-Order Logic and its Fragments
Second-Order Logic SO:
First-order logic + second-order quantiers
9S , 8S , 9T , 8T , ... ranging over relations of
specied arities on the universe of structures.
Existential Second-Order Logic ESO:
(9S1) (9Sm )'(x; S1; : : : ; Sm );
where '(x; S1; : : : ; Sm ) is rst-order.
Universal Second-Order Logic USO:
(8S1) (8Sm )'(x; S1; : : : ; Sm );
where '(x; S1; : : : ; Sm ) is rst-order.
Monadic Second-Order Logic MSO:
All second-order quantiers involve unary
relation variables, i.e., they range over
subsets of the universe of structures.
Monadic Existential Second-Order Logic
Monadic Universal Second-Order Logic
10
Second-Order Denable Queries
Monadic Existential Second Order Logic
Disconnectivity of graphs G = (V; E ):
(9S )((9x)S (x) ^ (9y):S (y)^
(8z )(8w)(S (z )^:S (w) ! :E (z; w))):
2-Colorability of graphs G = (V; E ):
(9B )(9R)((\B and R partition V ")^
(8x)(8y)(E (x; y) ! (B (x)^R(y))_(B (y)^R(x)))):
k-Colorability , k 3, of graphs G = (V; E ):
Monadic Universal Second-Order Logic
Well-Foundedness of linear orders A = (A; ):
(8S )((9x)S (x) ! (9y)(S (y)^(8z )(S (z ) ! y z ))):
11
Second-Order Denable Queries
Existential Second-Order Logic
Hamiltonicity of graphs G = (V; E ):
(9S )((\S is a linear order on V ")^
(8x)(8y)(\y = x + 1" ! E (x; y)));
where S is a binary relation symbol.
Universal Second-Order Logic
Circumscription (McCarthy { 1980)
Let '(S ) be a rst-order formula in which S is
a k-ary relation symbol.
The circumscription of '(S ) is the universal
second-order formula below asserting that S is
a minimal relation satisfying '(S )
'(S ) ^ (8T )(T S ! :'(T )):
12
Limitations of First-Order Logic
Fact: Let G be the class of nite graphs. None of
the following queries is rst-order denable on G :
Transitive Closure
Articulation Point
Connectivity
Acyclicity
Planarity
Eulerian
k-Colorability , for each xed k 2
Hamiltonicity
your favorite algorithmically interesting property
of graphs
13
Lower Bounds for Denability - Methods
Question: How does one establish that a query
Q is not denable in a certain logic L?
In particular, how does one prove lower bounds for
denability in rst-order logic?
Answer: Three methods for establishing lower
bounds for denability in rst-order logic:
Compactness Theorem
Ultraproducts
Ehrenfeucht-Frasse Games (E-F Games)
Fact: E-F Games is the main method used to
establish lower bound for denability in rst-order
logic on classes of nite structures.
Furthermore, it is a exible and extendible method:
variants of E-F games can be used to obtain lower
bounds for denability in stronger logics.
14
Ehrenfeucht-Frasse Game with r-Moves
{ Spoiler and Duplicator play on two -structures
A and B.
{ Each run of the game has r moves. In each move,
Spoiler picks an element from A or from B .
Duplicator picks an element from B or from A.
A typical run could look as follows:
a1 2 A b2 2 B b3 2 B : : :
#
#
#
:::
Duplicator b1 2 B a2 2 A a3 2 A : : :
Spoiler
ar 2 A
#
br 2 B
Duplicator wins the run if the mapping
a1 7! b1 ; a2 7! b2 ; : : : ; ar 7! br
is an isomorphism between the -structures
induced by fa1 ; : : : ; ar g and fb1 ; : : : ; br g.
Spoiler wins the run otherwise.
15
Ehrenfeucht-Frasse Game with r-moves
Denition: Let A and B be two -structures.
The Duplicator wins the r-move E-F game on
A and B if the Duplicator can win every run
of the game, i.e., if (s)he has a winning strategy
for the Ehrenfeucht-Frasse game.
The Spoiler wins the game, otherwise.
Notation:
A r B denotes that the Duplicator wins the
r-move Ehrenfeucht-Frasse game on A and B.
Fact:
r is an equivalence relation on the class S of all
-structures.
16
Example
v
v
v
v
v
v
v
v
v
v
v
A
B
Duplic. wins the 2-move E-F game on A, B.
A 2 B
Spoiler wins the 3-move E-F game on A, B.
A 63 B
17
Uses of Ehrenfeucht-Frasse Games
Question:
What are Ehrenfeucht-Frasse games good for?
Answer:
Ehrenfeucht-Frasse games capture the combinatorial content of rst-order quantication.
Ehrenfeucht-Frasse games can be used to char-
acterize denability in rst-order logic on an
arbitrary class of -structures.
18
Quantier Rank
Denition: Let ' be a rst-order formula over .
The quantier rank of ' is the depth of quantier
nesting in '.
Example:
' is (8x)(8y)(9z); where is quantier-free.
qr(') = 3:
' is (9x)E (x; x) _ (9y)(8z):E (y; z)
qr(') = 2:
Denition: Let r be a positive integer, and let
A and B be two -structures.
A r B if A and B satisfy the same rst-order
sentences of quantier rank r.
Fact: r is an equivalence relation on the class S
of all -structures.
19
E-F Games and First-Order Logic
Theorem: Frasse (1954), Ehrenfeucht (1961)
For every r, A, and B, the following are equivalent:
A and B satisfy the same rst-order sentences
of quantier rank r.
Duplicator wins the r-move E-F game on A
and B.
Moreover, the following statements are true:
r has nitely many equivalence classes.
Each r -equivalence class is FO-denable.
Remark: This theorem provides a purely combi-
natorial characterization of rst-order logic, since
it asserts that
A r B () A r B, where
r is dened in terms of logic only;
r is dened in terms of games only.
20
Theorem: If A r B, then A r B.
Proof: By example for r = 3. Assume that there
is a quantier-free formula (x; y; z ) such that
A j= (8x)(8y)(9z)(x; y; z), but
B j= (9x)(9y)(8z):(x; y; z).
Then, the Spoiler can win the following run:
Spoiler
b1 2 B b2 2 B a3 2 A
#
#
#
Duplicator a1 2 A a2 2 A b3 2 B
where b1 , b2 , a3 have been chosen so that
B j= (8z):(b1; b2; z)
A j= (a1; a2; a3);
this is possible, because A j= (9z )(a1; a2 ; z ).
Thus, A j= (a1 ; a2 ; a3 ) and B j= :(b1; b2 ; b3).
As a result,
a1 7! b1 ; a2 7! b2 ; a3 7! b3
is not an isomorphism and, hence, A 63 B:
21
Example { Revisited
v
v
v
v
v
v
v
v
v
v
v
A
B
Spoiler wins the 3-move E-F game on A, B.
The theorem predicts that A 63 B. Indeed,
A j= ' and B j= :';
where ' is the rst-order sentence
(8x)(8y)(9z )(x 6= y ! E (x; z ) ^ E (y; z )):
22
E-F Games and First-Order Denability
Corollary: Let Q be a Boolean query on C .
The following statements are equivalent:
Q is rst-order denable on C .
There is an r such that for every A, B in C if
A j= Q and B 6j= Q, then the Spoiler wins the
r-move E-F game on A, B.
A Methodology for First-Order Denability
Let Q be a Boolean query on C .
Soundness: To show that Q is not rst-order denable on C , suces to show that for every r there
are structures Ar and Br in C such that
Ar j= Q and Br 6j= Q.
Duplicat. wins the r-move E-F game on A, B.
Completeness: This method is also complete ,
i.e., if Q is not rst-order denable on C , then this
can be shown using E-F games.
23
Applications
Even Cardinality Query:
w
w
w
w
w
w
w
q
q
q
q
q
q
w
w
w
Km
Kn
Fact: If m r and n r, then K m r K n .
Corollary: Even Cardinality is not rst-order
denable on nite graphs.
24
Applications
Eulerian Graphs:
c1
XXX cn
c
P
P
J
XXXXPXPPP
XXXPXPXP JJ
XPXPXPXPJ
w
w
2
r
r
r
w
a
w
b
w
An
Fact:
If n r, then An+1 r An.
An is Eulerian () n is even.
Corollary: Eulerian is not rst-order denable
on nite graphs.
25
Methodology for First-Order Denability:
To show that a Boolean query Q is not rst-order
denable on C , suces to show that for every r
there are structures Ar and Br in C such that
Ar j= Q and Br 6j= Q.
Duplicat. wins the r-move E-F game on A, B.
Implementation Diculties:
I. How does one nd such Ar and Br , r 1?
No general technique for this task exists.
II. After candidates Ar and Br have been found,
how does one show that Ar r Br ?
In general, it is quite dicult to describe rigorously
the winning strategy of the Duplicator. However,
In a few cases, it is possible to give explicit
descriptions of the r -equivalence classes.
In particular, we can do so for Linear Orders.
It is possible to build a \library" of winning
strategies.
26
Example
w
w
w
w
w
w
w
w
w
w
w
w
w
L7
L6
L7 63 L6
Spoiler wins the 3-move E-F game on L7 and L6
27
Example
w
w
w
w
w
w
w
w
w
w
w
w
w
w
w
L8
L8 3 L7
L7
Duplicat. wins the 3-move E-F game on L8 and L7
28
Analysis of r on Linear Orders
Theorem: The following are equivalent:
Lm r Ln
(m = n) or (m 2r 1 and n 2r 1)
Proof: By induction on min(m; n), using
Lemma: The following are equivalent:
Lm r+1 Ln
for every a 2 Lm there is b 2 Ln such that
>b
<a
<b
L>a
m r Ln and Lm r Ln ; and
for every b 2 Ln there is a 2 Lm such that
>b
<a
<b
L>a
m r Ln and Lm r Ln .
Corollary: Even Cardinality is not rst-order
denable logic on nite linear orders.
Proof: Lm r Lm+1, where m 2r 1.
29
Towards a Library of Winning Strategies
Goal: To identify general sucient conditions for
the Duplicator to win E-F games.
Some History:
Gaifman (1982):
First-order logic can express local properties
only.
Fagin, Stockmeyer, Vardi (1993):
Building on earlier work by Hanf (1965), they
developed \o-the-shelf" winning strategies for
the Duplicator in the E-F game.
Schwentick (1994), Arora and Fagin (1997):
Additonal \o-the-shelf" winning strategies.
30
Neighborhoods and Types
A = (A; R1; : : : ; Rm) a -structure, a 2 A, d 1.
The connection graph (A; EA) of A is dened by
EA = f(b; c) : there exist Ri and (t1 ; : : : ; ts ) 2 Ri
such that b and c are among t1 ; : : : ; ts g:
N (a; d) = Neighborhood of a of radius d.
It consists of a and all points in A of distance less
than d from a in the connection graph EA .
The d-type of a is the isomorphism type of the
graph N (a; d) with a as a distinguished node.
a and b have the same d-type if N (a; d) = N (b; d)
via an isomorphism h such that h(a) = b.
31
Examples
Linear Order Ln , a 2 Ln , d 2
N (a; d) = Ln
Clique Kn , a 2 Kn , d 2
N (a; d) = Kn
Complement of Clique K n , a 2 Kn , d 2
N (a; d) = fag
Cycle Cn , a 2 Cn , d such that 2d n
N (a; d) = path of length 2d 1
with a as midpoint
32
Winning Strategies for the Duplicator
Denition: A and B two -structures, d 1.
A and B are d-equivalent if for each d-type they
have the same # of neighborhoods of that type.
Theorem: Fagin, Stockmeyer, Vardi (1993):
For every r 1 there is a d 1 such that if A and
B are d-equivalent, then A r B.
In fact, every d 3r has this property.
Hint of Proof: Duplicator can win the r-move
E-F game by maintaining the following stronger
condition in every round a1 ; b1; : : : ; ar ; br :
[
ij
N (ai ; 3r j ) =
[
ij
N (bi ; 3r j )
via an isomorphism such that ai 7! bi , i j r.
33
A Simpler Methodology
Corollary:
To show that a Boolean query Q is not rst-order
denable on C , suces to show that for every r
there are structures Ar and Br in such that
Ar j= Q and Br 6j= Q
Ar is d-equivalent to Br for some d 3r .
Remarks:
This method is sound , but it is not complete.
It can not be used for rst-order denability
on linear orders, since for every d 2
Lm is d-equivalent to Ln () m = n.
This method, however, simplies the combina-
torial arguments. Moreover, it provides a clue
for nding candidate structures Ar and Br .
34
Theorem: Connectivity is not rst-order denable on nite graphs.
Proof: By picture, where d is any number 3r .
!a a....
... .!! a
.
v
PPP
cc
#
#
#
c
B
..
q
#
q
v
PPP##
v
v
.....
..
aaa!!!
!a
!
aa.......
!
.
.. ..
v
v
q
v
v
q
v
q
v
.....
..
.. ...
aaa!!!
B
v
v
Ar
r
Each d-type is a path of length 2d 1
Ar is d-equivalent to Br
35
q
2d
q
q
v
q
q
... ...
v
q
4d
q
B
cc
c
q
v
q
2d
q
v
v
v
q
v
v
...
v
v
q
q
Theorem: 2-Colorability is not rst-order denable on nite graphs.
Proof: By picture, where d = 3r (an odd number).
!a
!
aa.....
!
.
..
v
PPP
#
cc
#
#
c
..
B
q
B
cc
c
#
q
v
PPP##
v
v
.....
..
v
v
v
q
v
v
q
v
q
v
.....
..
.. ...
aaa!!!
B
v
v
Ar
r
Each d-type is a path of length 2d 1
Ar is d-equivalent to Br
36
q
3d
q
q
v
q
q
.. ...
aaa!!!
!a
!
aa.......
!
.
.
... .
q
6d
q
q
v
q
3d
q
v
v
v
q
v
v
...
v
v
q
q
Theorem: Acyclicity is not rst-order denable
on nite graphs.
Proof: Again by picture, where d 3r .
v
v
v
a
!
!
! aa@
@
v
v
v
r
r
4d
2d
r
r
r
r
@@a
aa!!!
v
v
v
v
B
A
r
r
Ar is d-equivalent to Br
37
v
v
v
r
2d
r
r
r
v
r
r
Homework Assignment #1
Show that the following graph properties
are not rst-order expressible:
k-Colorability, for each xed k 3
Planarity
Rigidity (no non-trivial automorphims)
Connectivity on linearly ordered graphs
Hint:
Use pictures for the rst three properties; use the
analysis of r on linear orders for the last one.
38
Solution to Homework Assignment #1
Fact: Connectivity is not rst-order expressible
on lineary ordered graphs.
Proof: Turn each linear order Ln into a graph Gn
by dening an edge relation En as follows:
En (a; b) () (b = \a + 2") _ (a = n ^ b = 1)
Then,
Gn is connected () n is even:
Note that En is rst-order denable from < and
recall that Even Cardinality is not rst-order on
linear orders.
39
© Copyright 2026 Paperzz