Finite Model Theory and Game Comonads: Part 2
Posted by Emily Riehl
guest post by Elena Dimitriadis, Richie Yeung, Tyler Hanks, and Zhixuan Yang
In the Part 1 of this post, we saw how logical equivalences of first-order logic (FOL) can be characterised by a combinatory game, but there are still a few unsatisfactory aspects of the formulation of EF games in Part 1:
The game was formulated in a slightly informal way, delegating the precise meaning of “turns”, “moves”, “wins” to our common sense.
There are variants of the EF game that characterise logical equivalences for other logics, but these closely related games are defined ad hoc rather than as instances of one mathematical framework.
We have confined ourselves entirely to the classical semantics of FOL in the category of sets, rather than general categorical semantics.
So you, a patron of the n-Category Café, must be thinking that category theory is perfect for addressing these problems! This is exactly what we are gonna talk about today—the framework of game comonads that was introduced by Abramsky, Dawar and Wang (2017) and Abramsky and Shah (2018).
(We will not address the third point above in this post though, but hopefully the reader will agree that what we talk about below is a useful first step towards model comparison games for general categorical logic.)
One-Way EF Games
Let’s warm up by recalling EF games and considering a simplified version of them.
Recall that a -round EF game is parameterized by two -relational structures and for some relational vocabulary . The rule is that in every round , the spoiler picks either an element from or an element from , and then the duplicator responds with an element from the other structure. The duplicator wins if after -rounds, these elements form a partial isomorphism.
In the game the spoiler has the freedom in each round to pick the structure or , so EF games are also sometimes called back-and-forth games. We can also consider the one-way variant of EF games from to , where the spoiler can only pick elements from (so the duplicator responds with elements from ). Additionally, we weaken the winning condition for the duplicator to be forming a partial homomorphism from to (rather than a partial isomorphism).
It is not difficult to modify the Ehrenfeucht-Fraïssé theorem that we saw last time to show that such one-way EF games characterise the fragment of FOL that only uses , , , , . This fragment of FOL is known as existential-positive fragment of first-order logic or coherent logic.
Theorem (Existential Ehrenfeucht-Fraïssé). If the duplicator has a winning strategy for the -round one-way EF game from to , then implies for all closed formulas of quantifier rank in the existential-positive fragment.
A consequence of the one-way EF games is that now a winning strategy for the duplicator can be thought of as a function from the half-board of -elements in each round to the duplicator’s response , instead of a function from the whole board to their response . The reason is that the -elements were all picked by the duplicator themselves before, so the duplicator knows what they are, and they don’t have to be in the input to the duplicator’s winning strategy.
Write for the set of non-empty -sequences of length at most . Clearly, not every function is a valid winning strategy for the duplicator for the one-way EF game, since the duplicator has to make sure their responses maintain a partial homomorphism to the spoiler’s choices .
More precisely, for all half-boards , if some of its elements are related by a relation of arity , i.e. holds for , the duplicator’s strategy must make
The EF Game Comonad
Now we are ready to formulate EF games in a more categorical way using comonads. Recall that the Kleisli presentation a comonad on a category is given by
a map ,
for all , a counit , and
a co-extension operation that takes every morphism to a morphism
such that the following equations hold for all and :
Given any natural number , the mapping from sets to sets of non-empty -sequences of length at most can be equipped with a comonad structure on :
for all sets ;
extracts the last element of the sequence (which corresponds to the newest choice by the spoiler in the one-way EF game);
for all , the co-extension is which intuitively means that the duplicator can recall their own historical moves on the half-board on given the spoiler’s half-board on .
A co-Kleisli map for this comonad is then a function from half-boards of -elements to responses in , so encodes precisely a (not necessarily winning) strategy for the duplicator.
The way to formulate winning strategies is to lift the comonad on to a comonad on the category of -relational structures.
Definition (EF Comonad). The comonad on is defined as follows:
The object mapping sends every -structure to the -structure whose underlying set is just , i.e. non-empty -sequences of length at most ; for every relation symbol of arity , its interpretation relates sequences satisfying the following two conditions:
- for all , the sequence is a prefix of or is a prefix of , and
- .
The counit and the co-extension are the same as those of the comonad . It can be checked that they are valid morphisms in the category .
Co-Kleisli morphisms are exactly winning strategies for the duplicator in the one-way EF game frome to (modulo one subtle problem that we will talk about later). Let’s gain some intuition by looking at a small example.
Let us have two -structures, and , with underlying sets and respectively, and let us play a 3-round one-way EF game. We will try to associate the objects of the comonad as we go: * The spoiler chooses . In response, the duplicator chooses :
The spoiler chooses . In response, the duplicator chooses :
The spoiler chooses . In response, the duplicator chooses :
For intuition on how the EF comonad acts on relations, let us look at the binary relation case. The general case has the same intuition, but with more terms.
Condition (1) of the above definition imposes that one sequence be a prefix of the other. In game terms, this amounts to that and can be stages of the same game play: either evolves to or evolves to .
Condition (2) says that two sequences and are related iff their last elements are related. Since under Condition (1), and are two stages of the same play, so and being related mean precisely that two elements in a game are related.
Let us go back to our earlier example with our -structures and , and suppose there is binary relation symbol in whose interpretation in and are the alphabetical order . Then, we can say that , because on one hand both sequences start in the same way (this game has started with the spoiler playing and then ), and on the other hand in the alphabetical order.
Now the intuition behind the comonad might be clearer: in the -relational structure , some sequences are related means precisely that there is a game play for which are the spoiler’s half-boards on in certain rounds, and the spoiler’s choices are related by some relation in . Therefore, a -structure homomorphism is a winning strategy for the duplicator.
There is one problem though: we have lifted all relations on to , but there is a special built-in relation in FOL—the equality . The one-way EF game asks that after every round, the chosen -elements and the chosen -elements form a partial isomorphism, so if the spoiler chooses the same element in two rounds, the duplicator must respond with the same elements as well. Otherwise it won’t be a partial isomorphism. However, this requirement is not captured by co-Kleisli morphisms , since e.g. and are different elements of , do not need to map them to the same response.
This motivates us to consider what is called I-morphisms, which are coKleisli morphisms such that whenever is a prefix of and . (There is an alternative definition of I-morphisms using relative comonads, but the direct definition suffices for our purposes in this post.)
Theorem. There is an winning strategy for the duplicator in the -round one-way EF game from to if and only if there is an I-morphism .
Since -round one-way EF games characterise logical refinement of existential-positive FOL, a direct corollary is that two -structure and agree on all closed existential-positive FOL formula of rank if and only if there are two I-morphisms and .
Back-and-Forth Games
If we ask to have two coKleisli morphisms but nothing else of them, we get the existential-positive fragment, but recall our original goal was to characterise FOL and EF games. What if we ask for the morphisms to have a relationship between them? What if, as we usually do, we ask them to be inverses of each other?
It turns out to characterise the logical equivalence of FOL augmented with counting quantifiers and , whose semantics is that there exist at most , and respectively at least , elements making true.
Proposition. Two finite -structures and agree on all closed formulas on FOL with counting quantifiers if and only if there is a pair of -morphisms and that are mutual inverses (in the co-Kleisli category of ).
So if we don’t ask anything from the homomorphisms we get too little; but if we ask for them to be an isomorphism we go overboard and get too much. Can we find a middle ground?
Yes, the key intuition for this is that the duplicator can play the back-and-forth game like a one-way game when the spoiler keeps choosing elements from one structure, but the duplicator must have a plan B in mind in case the spoiler switches to choosing elements from the other structure in the next round.
This motivates what is called a locally invertible pair. Given two -structure and and a natural number as usual, a locally invertible pair consists of a set of co-Kleisli I-morphisms and a set of co-Kleisli I-morphisms such that
- for all and , there is some with , and
- for all and , there is some with .
Theorem. The duplicator has a winning strategy for the -round EF game on and if and only if there is a non-empty locally invertible pair .
Proof. Assuming a non-empty locally invertible pair , the duplicator has the following strategy such that the chosen elements and after round satisfy the condition 1. In round , if the spoiler chooses an element , the duplicator can pick an arbitrary and respond with . The condition is witnessed by and given by the definition of locally invertible pairs. If the spoiler chooses an element , the argument is the same.
- In round , if the spoiler chooses an element , the duplicator responds with . The condition is then witnessed by and .
After -rounds, is true and it implies that and are a partial isomorphism because and are coKleisli morphisms and .
For the other direction, assuming the duplicator has a winning strategy, let be the set of all possible game states in each round following the winning strategy. The locally invertible pair is
First we argue that for all , (i) and (ii) . To show (i) (and symmetrically for (ii)) we construct as follows: for every , let be the length of the longest common prefix of and . We consider the game play where in the first -rounds the spoiler and the duplicator play in the way as , and afterwards, the spoiler always chooses elements according to and the duplicator follows the winning strategy. The last -element picked in this game play is the value of the function at .
Now we can see defined as above is a locally invertible pair, for every and , is in , and thus by (i) there exists with . The symmetric condition for similarly holds.
Wrap-up
In Part 1 of the post, we have seen how logical equivalences for first-order logic can be characterised by combinatorial games, and how this can be used for showing inexpressivity results of first-order logic. In Part 2 of this post, we have seen how such games can be formulated in a concise way using comonads.
As an active research subject, what we didn’t say about game comonads in this blog post is a lot:
Many other logics have model comparison games and have received a comonadic treatment, including modal logics (Abramsky and Shah 2021), the -variable fragment of FOL (Abramsky, Dawar and Wang 2017), guarded logics (Abramsky and Marsden 2021), monadic second-order logic (Jakl, Marsden and Shah 2022), finite-variable logics with generalised quantifiers (Conghaile and Dawar 2021).
Coalgebras of game comonads usually reveal interesting information about the combinatorial structure of finite structures. For example, -coalgebras are in bijection with forest covers of height for the Gaifman graph of .
Back-and-forth games can be defined in an axiomatic way (Abramsky and Reggio 2021).
Moreover, we have only considered the classical semantics of FOL in sets, so a natural question is how finite model theory interacts with the various notions of finiteness in constructive mathematics and the general categorical semantics of FOL in hyperdoctrines.