Some TuringComplete Extensions of FirstOrder Logic
Abstract
We introduce a natural Turingcomplete extension of firstorder logic . The extension adds two novel features to . The first one of these is the capacity to add new points to models and new tuples to relations. The second one is the possibility of recursive looping when a formula is evaluated using a semantic game. We first define a gametheoretic semantics for the logic and then prove that the expressive power of the logic corresponds in a canonical way to the recognition capacity of Turing machines. Finally, we show how to incorporate generalized quantifiers into the logic and argue for a highly natural connection between oracles and generalized quantifiers.
Adriano Peron and Carla Piazza (Eds.): Proceedings of the Fifth International Symposium on Games, Automata, Logics and Formal Verification (GandALF 2014) EPTCS 161, 2014, pp. Some TuringComplete Extensions of FirstOrder Logic–LABEL:LastPage, doi:10.4204/EPTCS.161.4 © A. Kuusisto This work is licensed under the Creative Commons Attribution License.
Some TuringComplete Extensions of FirstOrder Logic
Antti Kuusisto^{†}^{†}thanks: This work was carried out during a tenure of the ERCIM “Alain Bensoussan” Fellowship Programme. The reported research has received funding from the European Union Seventh Framework Programme (FP7/20072013) under grant agreement number 246016; the author has been employed as Marie Curie Fellow during the research period. \IfArrayPackageLoaded  




antti.j.kuusisto@uta.fi 
1 Introduction
We introduce a natural Turingcomplete extension of firstorder logic . This extension essentially adds two features to basic . The first one of these is the capacity to add new points to models and new tuples to relations. The second one is the possibility of looping when a formula is evaluated using a semantic game.
Logics with different kinds of recursive looping capacities have been widely studied in the context of finite model theory [17]. Typically such logics are fragments of secondorder predicate logic. A crucial weakness in the expressivity of th order predicate logic is that only a finite amount of information can be encoded by a finite number of quantified relations over a finite domain. Intuitively, there is no infinitely expandable memory available. Thus th order logic is not Turingcomplete. To overcome this limitation, we add to firstorder logic operators that enable the addition of new elements to the domains of models and new tuples to relations. Coupling this feature with the possibility of recursive looping leads to a very natural Turingcomplete extension of firstorder logic.
In addition to operators that enable the extension of domains and relations, we also consider an operator that enables the deletion of tuples of relations. It would be natural to also include to our framework an operator that enables the deletion of domain points. This indeed could (and perhaps should) be done, but for purely technical reasons, we ignore this possibility.
We provide a gametheoretic semantics for the novel logic. A nice feature of the logic — let us simply call it , or logic — is that it simulates halting as well as diverging computations of Turing machines in a very natural way. This behavioural correspondence between Turing machines and the logic stems from the appropriate use of gametheoretic concepts. Let us have a closer look at this matter.
Let be a model and a formula of firstorder logic. Let be an assignment function that interprets the free variables of in the domain of . The semantic game is played between the two players and in the usual way (see, e.g., [12, 19]). If the verifying player has a winning strategy in the game , we write and say that is true in . If, on the other hand, the falsifying player has a winning strategy, we write and say that is false in . Since is a firstorder formula, we have iff it is not the case that .
If is a formula of IF logic [13] or dependence logic [22] , for example, the situation changes. It is then possible that neither player has a winning strategy in the semantic game. This results in a third truth value (indeterminate). Turing machines of course exhibit analogous behaviour: on an input word , a Turing machine can halt in an accepting state, halt in a rejecting state, or diverge.
The logic incorporates each of these three options in its semantics in a canonical way. For each Turing machine , there exists a sentence of such that accepts the encoding of a finite model iff , and furthermore, rejects the encoding of iff . Therefore diverges on the encoding of iff neither the verifying nor the falsifying player has a winning strategy in the game invoving , and . For the converse, for each formula of the logic , there exists a Turing machine such that a similar full symmetry exists between semantic games involving and computations involving . By Turingcompleteness of a logic we mean exactly this kind of a behavioral equivalence between Turing machines and formulae.
The moves in the semantic games for are exactly as in firstorder logic in positions involving the firstorder operators , , . In positions of the type , a fresh point is inserted into the domain of the model investigated, and the variable is interpreted to refer to the fresh point. There are similar operators for the insertion (deletion) of tuples into (from) relations. The recursive looping is facilitated by operators such as the ones in the formula , where the player ending up in a position involving the novel atomic formula can jump back into a position involving . Semantic games are played for at most omega rounds ^{1}^{1}1Omega of course refers to the smallest infinite ordinal. and can be won only by moving to a position involving a firstorder atomic formula. Winning and losing in positions involving firstorder atoms is determined exactly as in firstorder logic.
Operators that bear a resemblance to the ones used in the logic have of course been considered in logical contexts before. Lauri Hella has suggested (personal communication) extending firstorder logic with recursive looping constructors that resemble those investigated in this article. His idea involves studying fixed point logics using a gametheoretic semantics with somewhat different kinds of winning conditions than the ones we shall formulate below. The framework does not involve modifying the domains of structures. The insertion (deletion) of tuples to (from) relations is an important ingredient in dynamic complexity (see, e.g., [9, 20]), although motivated and used there in a way that is quite different from the approach in this article. Logics that involve jumping into different model domains include for example the sort logic of Väänänen ([21],[23]), a logic which can in a sense be regarded as the strongest possible model theoretic logic. Other systems with similar constructors or motivations to those considered in this article include for example BGS logic [3], WHILE languages [2] and abstract state machines [11, 4]. See also the articles [6] and [15].
The reason we believe that the logic is particularly interesting lies in its simplicity and exact behavioural correspondence with Turing machines on one hand, and in the fact that it provides a canonical unified perspective on logic and computation on the other hand. The logic canonically extends ordinary firstorder logic to a Turingcomplete framework, and thereby serves not only as a novel logic, but also as a novel model of computation. It is also worth noting that the fresh operators of nicely capture two classes of constructors that are omnipresent in the practise of mathematics: scenarios where fresh points are added to investigated constructions (or fresh lines are drawn, etc.) play a central role in geometry, and recursive looping operators are found everywhere in mathematical practise, often indicated with the help of the famous three dots (…).
The structure of the paper is as follows. In Section 2 we define some preliminary notions and give a formal account of the syntax . In Section 3 we develop the semantics of . In Section 4 we establish the Turingcompleteness of in restriction to the class of word models. In Section 5 we use the results of Section 4 in order to establish Turingcompleteness of in the class of all finite models. In Section 6 we show how to extend with generalized quantifiers. We also briefly discuss the conceptiual link between oracles and generalized quantifiers.
2 Preliminaries
Let denote the set of positive integers. Let be the set of variable symbols used in firstorder logic. We mainly use metavariables etc., in order to refer to the variables in . Let . We let be a countably infinite set of ary relation variables. We let .
Let denote a complete relational vocabulary, i.e., is the union , where is a countably infinite set of ary relation symbols. Let . Define the language to be the smallest set such that the following conditions are satisfied.

If are variable symbols and a ary relation symbol, then .

If are variable symbols and a ary relation variable, then .

If are variable symbols, then .

If is (a symbol representing) a natural number, then .

If , then .

If , then .

If is a variable symbol and , then .

If is a variable symbol and , then .

If are variable symbols, a ary relation symbol and , then .

If are variable symbols, a ary relation variable symbol and , then .

If are variable symbols, a ary relation symbol and , then .

If are variable symbols, a ary relation variable symbol and , then .

If and , then .
While we could develop a sensible semantics for the language , we shall only consider a sublanguage that avoids certain undesirable situations in semantic games. Let be a formula. Assume that contains an atomic subformula and another subformula . Assume that is not a subformula of . Then we say that has a nonstandard jump. Note that we define that every instance of the syntactically same subformula of is a distinct subformula: for example, the formula is considered to have three subformulae, these being the left and right instances of and the formula itself. Thus for example the formula has a nonstandard jump. We define to be the largest subset of that does not contain formulae with nonstandard jumps.
The reason we wish to avoid nonstandard jumps is simple and will become entirely clear when we define the semantics of in Section 3 . Let us consider an example that demonstrates the undesirable situation. Consider the formula of . As will become clear in Section 3 , it is possible to end up in the related semantic game in a position involving the atomic formula without first visiting a position involving the formula . This is undesirable, since a related variable assignment function will then not necessarily give any value to the variable . For this reason we limit attention to the fragment containing only formulae without nonstandard jumps.
Before defining the semantics of the language , we make a number of auxiliary definitions. Let , , etc., be models. We let , , etc., denote the domains of the models in the usual way. A function that interprets a finite subset of in the domain of a model is called an assignment. Naturally, if is a ary relation variable, then , and if , then . We let denote the valuation with the domain defined such that and if . We analogously define , where is a ary relation variable and . We will also construct valuations of, say, the type . The interpretation of these constructions is clear.
We define the set of free variables of a formula as follows.

If , then .

If , then .

.

.

.

.

.

.

.

.

.

.

.
A formula of is a sentence if .
3 A Semantics for
In this section we define a gametheoretic semantics for the language . The semantics extends the wellknown gametheoretic semantics of firstorder logic (see, e.g., [19]). The semantic games are played by two players and .
Let be a formula of . Let be a model, and let be an assignment that interprets the free variables of in . Let be simply a symbol. The quadruple defines a semantic game . The set of positions in the game is the smallest set such that the following conditions hold.

.

If , then , where .

If , then and .

If and , then .

If and is a fresh element ^{2}^{2}2To avoid introducing a proper class of new positions here, we assume . Since , the element is a fresh element. Only a single new position is generated. , then ; we define to be the model where is simply a fresh isolated point, i.e., the domain of is , and for each .

If and , then , where is obtained from by defining , and . For each relation symbol , we have . The models and have the same domain.

Assume and . If , call . Otherwise let . Then , where .

If and , then , where is obtained from by defining , and . For each relation symbol , we have . The models and have the same domain.

Assume and . If , call . If , define . Then , where .

If , then .
The game is played as follows.

Every play of the game begins from the position .

If a position is reached in a play of the game, the play continues from the position , where .

If a position is reached, then the play continues as follows. If (respectively, ), then the player (respectively, ) picks a formula , and the play continues from the position .

If a position is reached, then the play continues as follows. If (respectively, ), then the player (respectively, ) picks an element , and the play continues from the position .

If a position is reached, then the play continues from the position , where is the model , where is simply a fresh isolated point^{3}^{3}3Recall that we let in order to avoid proper classes of new positions. , i.e., the domain of is , and for each .

Assume a position has been reached. The play of the game continues as follows. If (respectively, ), then the player (respectively, ) chooses a tuple . The play of the game continues from the position , where is obtained from by redefining , and . Other relations and the domain remain unaltered.

Assume a position has been reached. The play of the game continues as follows. If (respectively, ), then the player (respectively, ) chooses a tuple . The play of the game continues from the position , where ; here if , and otherwise .

Assume a position has been reached. The play of the game continues as follows. If (respectively, ), then the player (respectively, ) chooses a tuple . The play of the game continues from the position , where is obtained from by redefining , and . Other relations and the domain remain unaltered.

Assume a position has been reached. The play of the game continues as follows. If (respectively, ), then the player (respectively, ) chooses a tuple . If , call . Otherwise define . The play of the game continues from the position , where .

If a position is reached, then the play of the game continues from the position .

If a position is reached, then the play of the game continues as follows. If (respectively, ) and there exists a subformula of the original formula , then the player (respectively, ) chooses some subformula of , and the play continues from the position . If no subformula exists, the play of the game ends.

If is an atomic formula , or , and a position is reached, then the play of the game ends.
A play of the game is played up to omega rounds. If a play of the game continues for omega rounds, then neither of the two players wins the play. If a play of the game ends after a finite number of rounds, then one of the players wins the play. The winner is determined as follows.

If the play ends in a position , which may happen in the pathological case where there are no subformulae of of the type , then wins if and wins if .

If the play ends in a position , where is an atomic formula , or , then the winner of the play is determined as follows.

Assume . Then wins if . If , then wins. Here is the semantic turnstile of ordinary firstorder logic.

Assume . Then wins if . If , then wins.

A strategy of in the game is simply a function that determines a unique choice for the player in every position of the game that requires to make a choice. A strategy of is defined analogously. A strategy of () in the game is a winning strategy if every play of the game where () makes her moves according to the strategy, ends after a finite number of rounds in a position where () wins.
We write iff the player has a winning strategy in the game . We write iff has a winning strategy in the game . By duality of the rules of the game, it is easy to see that has a winning strategy in iff has a winning strategy in . Similarly, has a winning strategy in iff has a winning strategy in .
Let be a sentence of . We write iff , where denotes the empty valuation. Similarly, we write iff .
4 TuringCompleteness
Let be a finite nonempty set of unary relation symbols. let be a binary relation symbol. A word model over the vocabulary is defined as follows.

The domain of is a nonempty finite set.

The binary predicate is a successor relation over , i.e., a binary relation corresponding to a linear order, but with maximum outdegree and indegree equal to one.

Let denote the smallest element with respect to . We have for each . (This is because we do not want to consider models with the empty domain; the empty word will correspond to the word model with exactly one element.) For each element , there exists exactly one predicate such that .
Word models canonically encode finite words. For example the word over the alphabet is encoded by the word model over the vocabulary defined as follows.

.

is the canonical successor relation on .

and .
If is a finite word, we let denote its encoding by a word model in the way defined above. If is a set of finite words, then . If is a finite nonempty alphabet, we let denote the vocabulary .
We define computation of Turing machines in the standard way that involves a possible tape alphabet in addition to an input alphabet. These two alphabets are disjoint. Let be a finite nonempty alphabet. Then is the set of all inputs to a Turing machine whose input alphabet is . During computation, may employ an additional finite set of tape symbols. That set is the tape alphabet of . There is a nice loose analogy between tape alphabet symbols of Turing machines and relation variable symbols in used in formulas of .
Theorem 4.1.
Let be a finite nonempty alphabet. Let be a deterministic Turing machine with the input alphabet . Then there exists a sentence such that the following conditions hold.

Let be the set of words such that halts in an accepting state with the input . Then for all , iff .

Let be the set of words such that halts in a rejecting state with the input . Then for all , iff .
Proof.
We shall define a sentence such that the semantic games involving simulate the action of .
Let be the set of states of . For each , reserve a variable symbol . Furthermore, let be a variable symbol. Intuitively, the equality will hold in the semantic game exactly when is in the state during a run with the input .
Simulating the action of the head of the Turing machine is a bit more complicated, since when defining the new position of the head with a subformula of , information concerning the old position must be somehow accessible. ^{4}^{4}4Note that we assume, w.l.o.g., that has a single head. Fix two variables and . These variables will encode the position of the head. Define three further variables , , and . The tape of will be encoded by the (dynamically extendible) successor relation , which is a part of the model (or models, to be exact) constructed during the semantic game. The variables and will denote elements of the successor relation. Intuitively, will mean that indicates the current position of the head of , while will mean that indicates the position of the head of . The value of will always be easily definable based on the value of , and vice versa, the value of will be definable based on the value of .
If employs tape alphabet symbols , these can be encoded by unary relation variables . Intuitively, if is an element of the domain of the model under investigation, then will mean that the point of the tape of corresponding to contains the symbol . Similarly, for an input alphabet symbol , will mean that the point of the tape of corresponding to contains the symbol .
The sentence will contain subformulae which are essentially (but not exactly, as we shall see) of the type
where is simply the atomic formula , which indicates that the semantic game ought to be continued from some subformula of . The sentence will also contain subformulae which are essentially of the type
and
where in the first case the final state is an accepting state, and in the second case a rejecting state. Here () is the formula ().
Let be input alphabet symbols of . Consider a transition instruction of of the type , which states that if the state is and the symbol scanned is , then write to the current cell, change state to , and move right. Let us call this instruction . The instruction defines a formula . Assume is not a final state. Let us see how is constructed.
Define the formula . Define the formula to be the conjunction of the following formulae.

,

.
Define to be the formula
where is a formula that forces to be interpreted as the successor of with respect to . It is possible that no successor of exists in the current model. In that case a successor can be constructed by appropriately using the operators and . To cover this case, define to be the formula
where forces the fresh point to be the successor of with respect to , and forces to be the successor of . Let be a formula that states that has a successor with respect to in the current model. Define to be the conjunction .
The formula simulates the instruction when the current position of the head of is encoded by . The formula determines a new position for based on the current position of . A similar formula can be defined analogously to deal with the situation where the current position of the head is encoded by .
Define to be the conjunction of the formulae

,

.
Define to be the formula Formulae , where tells to move to a final state, are defined similarly, but do not have the atom . Instead, accepting states have the atom and rejecting states the atom . We shall not explicitly discuss for example instructions where the head is to move left, since all possible instructions can be easily specified by formulae analogous to the ones above.
Recall that is the set of states of . Let enumerate the elements of . Define
Let be the set of instructions of . The sentence is the formula
where states that the following conditions hold.

is equal to , where is the beginning state of .

is equal to .

is interpreted as the point corresponding to the beginning position of the head of .
It is not difficult to see that corresponds to in the desired way. ∎
We then prove that every sentence of spefifying a property of word models can be simulated by a Turing machine. For this purpose, we use König’s Lemma.
Lemma 4.2 (König).
Let be a finitely branching tree with infinitely many nodes. Then contains an infinite branch.
In the following, accepting means halting in an accepting state, and rejecting means halting in a rejecting (i.e., nonaccepting) state.
Theorem 4.3.
Let be a finite nonempty alphabet. Let be a sentence of . Then there exists a deterministic Turing machine such that the following conditions hold.

Let be the set of words such that . Then for all , accepts iff .

Let be the set of words such that . Then for all , rejects iff .
Proof.
Fix some positive integer . Given an input word , the Turing machine first enumerates all plays of with rounds or less. If wins such a play, checks whether there is a winning strategy for that always leads to a win in or fewer rounds, meaning that no play where follows the strategy lasts for rounds or more, and wins all plays where she follows her strategy. Similarly, if wins a play with or fewer rounds, checks whether there is a winning strategy for that always leads to a win in at most rounds. If there is such a strategy for (), then halts in an accepting (rejecting) state.
If no winning strategy is found, the machine checks all plays with rounds. Again, if wins such a play, checks whether there is a winning strategy for that always leads to a win in at most rounds, and similarly for . Again, if a winning strategy for () is found, then halts in an accepting (rejecting) state.
If no winning strategy is found, the machine scans all plays of the length , and so on. This process of scanning increasingly long plays is carried on potentially infinitely long.
Now assume, for the sake of contradiction, that () has a winning strategy with arbitrarily long plays resulting from following the strategy. Then the game tree restricted to paths where () follows the strategy has infinitely many nodes. Let denote the restriction of the game tree to paths where the strategy is followed. Since each game position can have only finitely many successor positions, and since is infinite, we conclude by König’s lemma that has an infinite branch. Thus the strategy of () cannot be a winning strategy. This is a contradiction. Hence each winning strategy has a finite bound such that each play where the strategy is followed, goes on for at most rounds.
Thus has the desired properties. The crucial issue here is that there exist a finite number of possible moves at every position of the game. This finiteness is due to the underlying models always being finite and properties of the operators of the logic . ∎
Note that our translations of Turing machines to formulae of and formulae of to Turing machines are both effective.
5 Arbitrary Structures
Above we limited attention to word models. This is not necessary, as Theorems 4.1 and 4.3 can easily be generalized to the context of arbitrary finite structures. In this section we show how this generalization can be done.
When investigating computations on structure classes (rather than strings), Turing machines of course operate on encodings of structures. We will use the encoding scheme of [17]. Let be a finite relational vocabulary and a finite structure. In order to encode the structure by a binary string, we first need to define a linear ordering of the domain of . Let denote such an ordering.
Let be a ary relation symbol. The encoding of is the bit string defined as follows. Consider an enumeration of all tuples over in the lexicographic order defined with respect to . In the lexicographic order, is smaller than iff there exists such that and for all . There are tuples in . The string is the string of the length such that the bit of is if and only if the th tuple in the lexicographic order is in the relation .
The encoding is defined as follows. We first order the relations in . Let be the number of relations in , and let enumerate the symbols in according to the order. We define
Notice that the encoding of depends on the order and the ordering of the relation symbols in .
Let be the class of exactly all finite models. Let , and be subclasses of such that the following conditions hold.

Each of the three classes , and is closed under isomorphism.

The classes are disjoint, i.e., the intersection of any two of the three classes is empty.

.
We say that is a Turing classification of finite models if there exists a Turing machine