Finite Model Theory and Game Comonads: Part 1
Posted by Emily Riehl
guest post by Elena Dimitriadis, Richie Yeung, Tyler Hanks, and Zhixuan Yang
Finite model theory (Libkin 2004) studies finite models of logics. Its main motivation comes from computer science: a finite relational structure, i.e. a finite set with a finite set of relations on , is essentially a database in the sense of good old SQL tables, and a logic formula with free variables is understood as a query to the database that selects all -tuples of that satisfy the formula .
Finite model theory is naturally related to complexity theory, as we may ask questions like what’s the time complexity to query a finite relational structure with a formula from some logic, and also the converse question—what kind of logic is needed to describe the algorithmic problems in a complexity class. For example, given a finite graph , we may ask if it is possible to write a first-order logic formula using a relation symbol saying there is an edge from to , such that is satisfied precisely by vertices that are connected by a path.
From a logical point of view, what makes finite model theory interesting is that some prominent techniques in model theory fail for finite models. In particular, compactness fails for finite model theory: a theory may not have a finite model even if all its finite sub-theories have finite models—consider e.g. where asserts there are at least distinct elements.
Fortunately there are model-theoretic techniques remaining valid in the finite context. One of them is model-comparison games, which characterise logical equivalence of models, i.e. when two models satisfy exactly the same formulas of a logic.
Such logical equivalences are very useful for showing (in)expressivity of logics. For example, if we are able to show that two models and of a theory satisfy exactly the same formulas from first-order logic, but there is a semantic property (in the meta-theory) which satisfies but does not. Then we know the property necessarily cannot be expressed in first-order logic. This proof technique works for both finite and infinite models. In fact, using this technique one can show that connectivity of finite graphs cannot be expressed as a first-order logic formula with only the relation symbol for edges.
Of course the logic equivalences for different logics need to be characterised by different games: first-order logic is characterised by Ehrenfeucht-Fraïssé games; the -variable fragment of first-order logic is characterised by pebble games; modal logic is characterised by bisimulation games, and so on.
Despite being different, these games are structurally so similar that they almost begged to be unified. Their unification is eventually done by Abramsky and Shah (2018, 2021) in the categorical framework of game comonads. This two-part blog post aims to give a brief introduction to finite model theory and game comonads. This post will cover only a tiny part of this active research programme, but we will aim to exposit in a self-contained way the basics with some intuition that is hidden in the papers.
Basics of First-Order Logic
Let’s begin with a quick recap on classical first-order logic (FOL). A purely relational vocabulary is a set of relation symbols where each relation symbol has an associated arity . In this post we do not consider vocabularies with function symbols or constants since they can be alternatively modelled as relations with axioms asserting their functionality, which slightly makes our life easier.
The formulas of FOL in a (purely relational) vocabulary is inductively generated by the following grammar, where the meta-variable ranges over a countably infinite set of variables:
A set of closed formulas (i.e. formulas with no free variables) is called a theory.
We will only consider the classical semantics of FOL in the category of sets in this post. A -relational structure, or simply a -structure, consists of a set and an -ary relation on the set for each relation symbol of arity .
A homomorphism of -structures from to is a function on the underlying sets such that for each relation symbol in , we have implies for all . Each vocabulary thus yields a category of -structures and homomorphisms.
Let be a FOL formula (in the vocabulary ) with free variables. The semantics of in a -structure is an -ary relation on the set . We will write when some is contained in and also write when is a closed formula and is in . The relation is inductively defined on as follows (we implicity treats as a function from the set of the free variables to the set ):
where is the function mapping to and anything else to .
Logical Equivalences and Ehrenfeucht-Fraïssé Games
As motivated earlier, we are interested in characterising when two models and of a relational vocabulary satisfy exactly the same formulas, more precisely, when for all closed FOL formulas in the vocabulary . When it is the case, and are sometimes called elementarily equivalent.
An Example of Logical Equivalence
Let’s build up our intuition with a concrete example. Let be the vocabulary with just one binary relation symbol , and let be the model with being the usual linear order of natural numbers and similarly be the model with the same order. These two models are clearly different, and indeed they can be differentiated by a first-order logic formula in the vocabulary —the formula saying that there exist different elements is satisfied by but not by .
However, the formula is a pretty big formula—it has 1002 quantifiers and 501501 clauses, so it is possible that small enough formulas cannot differentiate and since they are pretty similar (they are both linear orders). Let’s consider some formulas with just a few quantifiers:
The vocabulary doesn’t have a constant, so there are no closed terms and thus no closed formulas other than and . Thus and agree on all formulas with 0 quantifiers.
Consider formulas of the form where doesn’t have any quantifiers. We argue that iff as follows: supposing holds, this means that there is some such that , then we may choose any , say , making because the formula is inductively built from the variable , relations , , and propositional connectives; both and are true, so we can inductively show that and agree for all . Conversely, if is witnessed by some , we can always pick an arbitrary witnessing .
Moreover, since the semantics of propositional connectives are defined compositionally, we can inductively show that and agree on all closed formulas built out of exactly one and , , , and . Since we are considering classical logic, universal quantification can be reduced to , so and agree on it so we conclude that and agree on all FOL formulas with exactly one quanfier.
This example gets interesting when we consider two nested quantifiers. Supposing where is quanfier-free, if , there exist and such that . Then we can also choose any two elements such that, importantly, (i) iff , and (ii) iff . This ensures since the atomic formulas in are built from , , and , on which with the variable assignment and with agree. Conversely, if witnessed by we can also choose a matching pair making .
Now suppose . Whenever , there is some such that . In this case we can also choose an element that mimics : if is the bottom element in the structure , we let as well; if is the top in , we let be the top in ; otherwise we can choose an arbitrary . We then claim as well, because if there is some making not hold, we can also find an that is to in as is to in : precisely, if , we let ; if , we let be any element in such that , and similarly for the case (such a choice is always possible because earlier and are chosen to be at the same relative position). This choice of entails not true, leading to a contradiction. Therefore .
By a symmetric argument, implies as well. Moreover, by the compositionality of the semantics of propositional connectives, the two paragraphs above imply that and agree on all FOL formulas with quantifiers are nested at most once.
Hopefully working through the example above reveals the intuition behind logical equivalence for FOL: two -structures and agree on a FOL formula whenever a quantifier in picks an element in or , there is always an element in the other structure that “simulates the behaviour” of in the model.
The Ehrenfeucht-Fraïssé Game
The intuition is precisely formulated as Ehrenfeucht-Fraïssé (EF) games. Given two -structures and for any vocabulary and a natural number , the -round EF game for and is a turn-based game between two players, called the spoiler and the duplicator. Roughly speaking, the goal of the spoiler is to point out the difference between and while the goal of the duplicator is to advocate that and are the same. The rules are very simple:
Movement: at each round, the spoiler picks an element from one of the structures and the duplicator must respond with an element from the other structure. For example, if the spoiler picks an element from the structure , then the duplicator must pick an element .
Winning Condition: After rounds, the game state consists of and representing the elements chosen from each structure at each round. The duplicator wins this play if the mapping defines a partial isomorphism between and , i.e., if the substructures of and generated by and are isomorphic. Otherwise, the spoiler has succeeded in showing the structures are different and wins.
If the duplicator can guarantee a win after rounds no matter how the spoiler plays, we say the duplicator has a -round winning strategy.
The quantifier rank of a FOL formula is the depth of nesting of the quantifiers in :
Theorem (Ehrenfeucht-Fraïssé). If the duplicator has a winning strategy for the -round EF game for and , and agree on all closed FOL formulas of quantifier-rank . When the vocabulary is finite, the converse is also true.
Proof sketch: Assuming a winning strategy for the duplicator, and let be any formula of quantifier rank . Without loss of generality, we can assume where are quantifiers and is quantifier-free. We need to show . As we demonstrated in the example above, we consider how is defined inductively: if a quantifier and one of and satisfies the formula, we use the winning strategy for the duplicator to pick a matching element in the other structure; if a quantifier and one of and satisfies the formula, every counter-witness in the other structure leads to a counter-witness in this structure by the winning strategy of the duplicator, thus a contradiction.
The converse direction is also interesting and is not demonstrated in the example in the last section. We only give a rough sketch here and refer interested readers to Libkin (2004, section 3) for details.
Assuming that and agree on all FOL formulas of rank , the duplicator’s strategy is that whenever the spoiler picks an element (or symmetrically ), the duplicator first constructs a FOL formula that “maximally describes the current board on ”. Roughly speaking, is the conjunction of all formulas in the following set A priori, this set may have infinitely many formulas, but since there are only finitely many atomic formulas when is finite, can be reduced to a finite formula using the rules of propositional connectives. With the formula in hand, the duplicator can use the fact that witnessed by . Now using the assumption that and agree on FOL up to rank and the fact that is of rank , has an element witnessing the truth of this formula as well, which is going to be the duplicator’s response.
EF games are very useful for showing inexpressivity results of FOL. Suppose we are interested in a property (in the meta-theory) on a class of -structures. If for every natural number , we can find two models such that
- the duplicator has a winning strategy for the -round EF game on and , but
- only one of and satisfy the property ,
Then by the EF theorem, the property cannot be expressed by a FOL formula, whatever the quantifier it has.
For example, using this technique, we can show that the evenness of finite linear orders is not expressible—there isn’t a FOL formula in the vocabulary such that for every finite linear order , exactly when has an even number of elements. (Hint: we pick and to be the linear order of and elements respectively and play the EF games.)