Feasible Computation through Model Theory - CiteSeerX

19 downloads 0 Views 636KB Size Report
I would like to thank the other members of the committee: Peter Buneman, ... Walker, Dan Hardt, Bob Frank, Ramesh Subrahmanyam and Breck Baldwin for their.
Feasible Computation through Model Theory Anuj Dawar

A Dissertation

in Computer and Information Science

Presented to the Faculties of the University of Pennsylvania in Partial Ful llment of the Requirements for the Degree of Doctor of Philosophy 1993

Scott Weinstein Supervisor of Dissertation

Mitchell P. Marcus Graduate Group Chairperson

c Copyright 1993 by Anuj Dawar

For my parents, Sarla and Baldev Raj

iii

Acknowledgments This dissertation that appears under my name is, like any endeavour, a social product, embodying the contributions and in uences of many people. I cannot hope to enumerate them all in this short space. I do hope to mention those that are the most salient in my mind. Of course, I bear all responsibility for any errors that remain in this work. First and foremost, I must thank my advisor, Scott Weinstein. When we embarked on this work together, three years ago, I believe that neither one of us knew where it would lead us. It has been an exciting, and sometimes exhilarating time, in which I have learned a lot. It could not have been so without Scott's constant encouragement, guidance and valuable insights. He has taught me most of what I know about logic. His in uence shows through, I am sure, on every page of this dissertation. I have also had the extremely valuable experience of working with Steven Lindell. A large part of the work reported in this dissertation is done jointly with Scott and Steven. I am grateful to Steven, who has contributed to this work in large measure. I had the opportunity to discuss every aspect of the work in this dissertation in great detail with him. I would also like to thank him for serving on my committee and for reading the dissertation very closely. I would like to thank the other members of the committee: Peter Buneman, Val Tannen, S. Rajasekharan and Neil Immerman, for their encouragement and support and their valuable comments. A large part of Chapter 5 represents joint work with Lauri Hella. I would like to express my appreciation for the valuable discussions we have had through our correspondence and for the contributions he has made to the results reported here. I would like to thank Aravind Joshi for the invaluable support he has provided during iv

my stay at Penn. He has been extremely generous in his support, even though our research interests have diverged. Parts of this dissertation have circulated in the form of draft papers and preprints. The comments that I received on these have helped shape the nal version of the dissertation. I would particularly like to thank Yuri Gurevich, Moshe Vardi, Phokion Kolaitis, Jouko Vaananen, Suzanne Zeitman and two anonymous referees for Information and Computation. Penn has provided me with a stimulating and pleasant working environment, both intellectually and physically. I would like to thank all the members of the Logic and Computation Group, who have been a wonderful group to work with. I would also like to thank all those aliated with the Institute for Research in Cognitive Science. In particular, I am grateful to Michael Niv, Barbara Di Eugenio, Jamie Henderson, Young-Suk Lee, Lyn Walker, Dan Hardt, Bob Frank, Ramesh Subrahmanyam and Breck Baldwin for their friendship and companionship. Last, but not least, I am deeply indebted to my parents, Sarla and Baldev Raj. The values they inculcated in me have brought me this far, and their vision has always been a source of inspiration and support. This thesis is dedicated to them.

v

Abstract The computational complexity of a problem is usually de ned in terms of the resources required on some machine model of computation. An alternative view looks at the complexity of describing the problem (seen as a collection of relational structures) in a logic, measuring logical resources such as the number of variables, quanti ers, operators, etc. A close correspondence has been observed between these two, with many natural logics corresponding exactly to independently de ned complexity classes. For the complexity classes that are generally identi ed with feasible computation, such characterizations require the presence of a linear order on the domain of every structure, in which case the class PTIME is characterized by an extension of rst-order logic by means of an inductive operator. No logical characterization of feasible computation is known for unordered structures. We approach this question from two directions. On the one hand, we seek to accurately characterize the expressive power of inductive logics over classes of structures where no linear order is present. On the other hand, we study extensions of inductive logic by means of generalized quanti ers to determine if such extensions might exactly express the PTIME properties. For the two investigations, we develop a common set of tools and techniques, based on notions from model theory. Basic notions, such as those of elementary equivalence and element type are adapted to the context of nite relational structures, in particular, by restricting the number of distinct variables that can appear in any formula. We use these tools to show that there is no extension of the inductive logic be means of a nite number of generalized quanti ers that exactly expresses the PTIME properties of nite relational structures. We also show that, if there is any descriptive characterization of the PTIME properties, indeed if the PTIME properties are recursively indexable, then there is a characterization by means of an extension of rst-order logic by a uniform, in nite vi

sequence of generalized quanti ers. This is established through a general result linking the recursive indexability of a complexity class with the existence of complete problems via weak logical reductions.

vii

Contents iii Acknowledgments

iv

Abstract

vi

1 Introduction and Background

1

1.1 1.2 1.3 1.4

De nitions and Notation : Descriptive Complexity : Inductive Logics : : : : : Unordered Structures : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: 3 : 5 : 7 : 10

2 In nitary Logic and Element Types 2.1 2.2 2.3 2.4

14

In nitary Logic : : : : : : : : : : : : : : : : : : Pebble Games : : : : : : : : : : : : : : : : : : : Characterizing Structures up to Lk -equivalence Element Types : : : : : : : : : : : : : : : : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

3 Inductive Logics on Unordered Structures 3.1 3.2 3.3 3.4

Inductively Ordering the Types : : Rigid Structures : : : : : : : : : : Reduction to an Ordered Structure Complete Binary Trees : : : : : : :

: : : :

viii

: : : :

: : : :

: : : :

15 16 22 27

30 : : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

31 35 40 44

4 Inductive Logics on Arbitrary Classes 4.1 4.2 4.3 4.4

McColm's Conjectures : : : : : : : : : : : Compactness and the Second Conjecture : Preservation and the First Conjecture : : The Ordered Conjecture : : : : : : : : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

5 Generalized Quanti ers and Logical Reducibilities 5.1 5.2 5.3 5.4

Generalized Quanti ers : : : : Quanti ers and Element Types Finitely Many Quanti ers : : : Quanti ers and Reducibilities :

: : : :

: : : :

: : : :

6 Conclusions and Future Work 6.1 6.2 6.3 6.4

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

: : : :

Lk Canonical Structures : : : : : : : : : : : : : : : : How Many Types? : : : : : : : : : : : : : : : : : : : When is an Order De nable? : : : : : : : : : : : : : McColm's Conjectures and Generalized Quanti ers :

Bibliography

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

: : : : : : : : : : : :

51

52 53 58 65

69

71 73 80 83

92

93 96 98 99

101

ix

Chapter 1

Introduction and Background The study of computational complexity attempts to characterize the resources required to solve decision problems in certain given models of computation. The models of computation usually considered are machine models, such as deterministic, non-deterministic or randomized Turing machines, parallel machines and random-access machines. The resources that are accounted for are time, space, hardware, etc. The decision problems are typically characterized as sets of strings over some alphabet that are to be recognized. Descriptive complexity takes a di erent approach in several ways. On the one hand, decision problems are viewed as sets of ( rst-order) structures, instead of sets of strings. This is a generalization in the sense that strings over an alphabet can be viewed as a special kind of structure. It is also a natural generalization, since we are very often interested in decision problems involving arbitrary structures, for instance the set of all graphs with Hamiltonian cycles or other graph properties, which, in the traditional view of complexity, is encoded as a set of strings. On the other hand, descriptive complexity aims at characterizing the resources needed to describe a problem, rather than to compute it. The complexity measures are not tied to a machine model of computation, but to a language such as the predicate calculus. The resources that are measured are logical resources, such as the number of variables, quanti ers, operators, etc. What makes this approach to complexity particularly interesting is that it has a close correspondence with computational complexity. This has been used to provide a natural characterization of many complexity classes that is independent of any particular machine 1

model of computation. This line of investigation began with Fagin who showed that the properties of relational structures expressed by existential second-order sentences are exactly those that are in the class NP [Fagin, 1974]. Immerman [Immerman, 1986] and Vardi [Vardi, 1982] showed that the polynomial-time computable properties of structures in which there is a built-in order are captured exactly by the extension of rst-order logic with a least- xed-point operation. Since then, several further logical characterizations of computational complexity classes have been studied (see, for instance, [Immerman, 1989]). The early work of Chandra and Harel [Chandra and Harel, 1982] and Vardi [Vardi, 1982] linked this to the development of query languages for relational databases. A relational database can be viewed as a nite relational structure and query languages for such databases have generally been based on the predicate calculus and inductive extensions of rst-order logic (see, for instance, [Abiteboul and Vianu, 1991a]). This has also spurred interest in the study of the model theory of nite structures, and the development of tools and techniques speci cally for this study. All the results that relate logics to complexity classes below NP have relied on the presence of an ordering on the elements of the structures being described. In particular, the least- xed-point extension of rst-order logic proves too weak to express all the polynomial time recognizable properties of nite structures that are not necessarily ordered. Indeed, there is no known logical characterization of the collection of classes of nite structures that are recognizable in polynomial time. It is an open question whether this collection has a recursively enumerable index set. Since it is known that relational structures over an arbitrary signature can be encoded as graphs (by an encoding that is rst-order de nable, see, for instance, [Lindell, 1987] or [Gurevich, 1988]), this question is equivalent to asking if there is a recursive enumeration of the polynomial time recognizable properties of graphs. This is a question of great interest, because on the one hand the PTIME computable properties are generally identi ed as those that can be feasibly computed, and on the other hand the order-independent properties are those that are generic in that they do not depend on the order in which the data are presented, but only on their logical properties. As was mentioned above, one of the aims of descriptive complexity is to generalize the notion of complexity from sets of strings to classes of nite relational structures. The characterization of complexity classes on linearly ordered structures can be seen as a somewhat 2

weaker generalization, since strings are a special kind of ordered structure. We can view the failure (so far) to logically characterize the feasible complexity classes (such as PTIME) in two ways. One could take the view that this shows that the notion of polynomial-time Turing computability is closely tied to computation over strings, and it is not the appropriate de nition of feasible computation in the context of arbitrary relational structures. For instance, Leivant suggests that the class of queries de nable in least- xed-point logic should be seen as the natural generalization of the notion of PTIME computation to such structures [Leivant, 1990]. Alternatively, one could take the view that we need to de ne extensions of least- xed-point logic that will exactly express the PTIME computable classes of relational structures. If one takes the former view, we need to understand more fully the expressive power, in computational terms, of least- xed-point logic over structures without an ordering. It is important to characterize the classes of structures where this logic expresses all PTIME properties, those where it collapses to rst-order logic and the various cases in between. On the other hand, under the latter view, it is essential to explore the expressive power of extensions of least- xed-point logic by means of various other operations. This thesis is a contribution in both of these directions. We develop a set of tools based on an in nitary logic with a bounded number of variables (denoted L!1! ) in Chapter 2. Many of the notions of classical model theory, particularly the notion of type, prove useful in the study of nite structures when we place bounds on the number of variables that occur in a formula. These tools are then used to study the expressive power of least xed-point logic and related inductive logics over arbitrary (not necessarily ordered) nite structures (in Chapters 3 and 4) and also to study the expressive power of extensions of least- xed-point logic by means of generalized quanti ers (in the sense of Lindstrom) (in Chapter 5).

1.1 De nitions and Notation A signature (also sometimes called a language or a vocabulary)  is a nite sequence of relation and constant symbols hR1; : : :; Rm; c1; : : :; cni. Associated with each relation symbol, Ri is an arity ai. We will only be considering languages without function symbols. Where 3

this makes a di erence to the results, we will mention it explicitly. A structure over the the signature  , A = hA; RA1 ; : : :; RAm; cA1 ; : : :; cAn i consists of a set A, the universe of the structure, relations RAi  Aai interpreting the relation symbols in  and distinguished elements cA1 ; : : :; cAn of A interpreting the constant symbols. Unless otherwise mentioned, all structures we will be dealing with are assumed to have a nite universe. For convenience, we will assume that the universe A is an initial segment of the natural numbers (note that this does not imply that any of the properties of the natural numbers, such as their linear ordering, are available in the logical vocabulary). We will also write jA j for the universe of the structure A , and card(jA j) for its cardinality. The collection of rst-order formulas over a language  is de ned in the usual way as the smallest collection containing the atomic formulas, ti = tj and Ri (t1 ; : : :; tai ) where Ri is a relation symbol in  and each tj is either a constant symbol or a variable from a given countable collection fx; y; : : :g, and closed under the operations of negation (:), conjunction (^), disjunction (_) and universal and existential quanti cation (8 and 9, respectively). The notion of a structure A satisfying a sentence (i.e., a formula without free variables), written A j= , is de ned in the usual way (see, for instance, [Enderton, 1972]). We will sometimes write (x1; : : :; xm ) to denote a formula  with free variables among x1 ; : : :; xm, and A j= [a1 : : :am ] to indicate that A satis es  with the assignment of the elements a1; : : :; am 2 A to the variables x1; : : :; xm. A model A satis es a set of sentences , written A j= , if and only if, it satis es every sentence in , and we say that  is satis able just in case it is satis ed by some model. The collection of ( nite) structures that satisfy a given sentence  is denoted Mod(). An (m-ary) query q (also sometimes called a global relation) is a map from structures (over some xed signature  ) to (m-ary) relations on the structures, that is closed under isomorphism. That is, if ha1 : : :am i 2 q (A ), and f is an isomorphism from A to B , then hf (a1) : : :f (am)i 2 q(B ). A Boolean query is a collection of structures K closed under isomorphism. We will write FO, LFP, etc. both to denote logics (i.e., sets of formulas) and the classes of queries that are expressible in the respective logics. It will be clear from the context which usage is intended. 4

1.2 Descriptive Complexity As we mentioned above, one of the aims of descriptive complexity is to extend the notion of complexity to classes of nite relational structures. We can speak of the computational complexity of a collection of structures K (over a signature  ) in the following sense. We rst choose some xed reasonable encoding of structures of signature  into strings over some alphabet. For concreteness, suppose  = hR1 : : :Rm i, where the arity of Ri is ai , and let A be a structure over this signature with card(jA j) = n. By choosing a linear ordering on the universe of A , we can encode the structure as a string r1# : : : #rm , where ri is a string over the alphabet f0; 1g of length nai that encodes the relation RAi . There is a 1 in ri at each position corresponding to an ai-tuple of elements from the universe of A that is in the relation RAi , where the tuples are enumerated in the lexicographic order generated by the ordering of jA j. Observe that this yields up to n! possible encodings of the structure A , one for each choice of the linear ordering of its universe. We then identify the complexity of recognizing K with the complexity of the decision problem for S , the set of strings that are encodings of structures in K . The complexity measure is usually given as a function of the size of the structure. Since the strings encoding structures are at most polynomially larger than the structures (to be precise, their size is bounded by O(na ), where a is the maximum of the arities of the relation symbols in  ), this does not cause a problem.1 Another notion of complexity is that of the complexity of describing a collection of structures K . For instance, if there is a sentence  of rst-order logic such that K = Mod(), then K is expressible in rst-order logic. Hence, we can look at the class of decision problems on structures of a given signature  expressible in rst-order logic as a complexity class, which we denote FO. Similarly, we can de ne descriptive complexity classes based on other logics. This raises the question of what the correspondence is between complexity classes de ned in the usual way in terms of resource bounded computing devices and the classes de ned by the expressive power of various logics. It is fairly easy to show that the class FO is contained in DSPACE[log(n)]. To see this, let  be any rst-order sentence and let k be an upper bound on the number of free 1 In the special case where  = fg, the structures can be encoded by strings of size log(n). We will mention this explicitly when we encounter it.

5

variables in any sub-formula of . Let A be any structure of size n. A procedure to check whether A j= , can proceed recursively through the sub-formulas of . At any given stage, it needs to check at most nk assignments to the free variables of the sub-formula. These can be encoded using k log(n) bits, which is the only space required. On the other hand, as we shall see (see Chapter 2), there are some easily computable properties in DSPACE[log(n)] that are not in FO. The earliest result relating computational complexity to the expressive power of logic was that of Fagin [Fagin, 1974] who showed that the class NP contains exactly those properties that are expressible in existential second-order logic. We give, below, an exposition of this result. Second-order logic is the extension of rst-order logic with second-order quanti ers. That is, we have countably many additional relational variables Pi with associated arities ai and, for instance, the formula 9Pi (where  is a rst-order sentence, possibly containing the predicate symbol Pi ) is true in a structure A just in case there is an interpretation of Pi as a relation on the universe of A , such that  holds in A expanded with this additional relation. It is easy to see that any second-order formula can be transformed into an equivalent one in prenex form, with all the second-order quanti ers in front (possibly increasing the arity of the quanti ed relations) . A formula of second-order logic is existential if it is in prenex normal form and all its second-order quanti ers are existential. Existential second-order sentences are also called 11 sentences, and by extension, a class of structures is called 11 if it is expressible by a 11 sentence. As an example, we can express the property of a graph being 3-colourable with a 11 sentence in the language of graphs  = fE g. The sentence is 9P1 9P2 9P3  where the Pi are unary relations (colours) and  is a rst-order sentence in the language fE; P1; P2; P3g asserting that each element has a unique colour and no two elements that are connected by an edge have the same colour.

Theorem 1.1 ([Fagin, 1974]) 11 = NP Proof:

To see that any property de ned by a 11 sentence 9R1 : : : 9Rm  (where  is rst-order), is in NP, note that a relation RA of arity k has cardinality at most nk , where n is the 6

size of the structure A . Thus, a non-deterministic machine, on input A can guess the interpretations of the relations R1; : : :; Rm on A and each of these is an object whose size is polynomial in the size of the input. Given these interpretations, the task of verifying that the rst-order formula  holds in the expanded structure can be done in DSPACE[log(n)], as noted above. In the other direction, let N be a non-deterministic machine that accepts inputs A of size n over the signature  in time nk . We will assume that the input to the machine is in the form of a binary string encoding the structure. We can write a rst order sentence  over the signature  [fO; T; S g (O and T being relation symbols of arity 2k and S of arity 3k) to encode the machine N . The relation O is to be interpreted as a total ordering on tuples of length k from the universe of the input structure. Using this ordering, these tuples can then be used to represent the integers 0; : : :; nk ? 1. T is used to encode the contents of the tape and S the state of the machine. T (n1 ; n2) is true just in case the content of tape cell n2 at time n1 is a 1. S (n1; n2; n3 ) is true just in case at time n1 , the machine is in state n2 with the head reading cell n3 . The sentence  says that these represent an accepting computation of the machine N . That is to say, it asserts the following: 1. O is a total ordering, 2. T (0; 0); : : :; T (0; nk ? 1) represents an encoding of the input structure, 3. given S (x; y; z ) and T (x; 0); : : :; T (x; nk ? 1), there is a move in the transition function of N yielding S (x + 1; y 0; z 0) and T (x + 1; 0); : : :; T (x + 1; nk ? 1), and 4. S (nk ? 1; y; z ) is an accepting state. Then, the 11 sentence 9O9T 9S is true in exactly those structures accepted by N . As a corollary to this theorem, we have the result that full second-order logic expresses exactly the queries in the polynomial hierarchy [Stockmeyer, 1977], with the levels of the hierarchy corresponding exactly to the number of second-order quanti er alternations.

1.3 Inductive Logics One reason for the weakness of rst-order logic in expressing computation is that there is no means to express a construct such as recursion or iteration. This suggests another way 7

of extending rst-order logic by adding some kind of induction operation. For instance, consider the class of graphs that are connected. It is possible to show that this is a class that is not expressible in rst-order logic by an application of the Ehrenfeucht-Frasse game (see, for instance, [Gurevich, 1984]). On the other hand, it is clear that connectedness of a graph can be expressed by the sentence 8x8yR(x; y ) where R is the re exive and transitive closure of the edge relation. While this relation cannot be de ned in rst-order logic, it seems it can be de ned by an induction, because it is the smallest relation satisfying the equivalence:

R(x; y)  x = y _ 9z(E (x; z) ^ R(z; y))

(1.1)

To formally de ne such an induction operation, let (R; x1; : : :; xk ) be a rst-order formula over the signature  [ fRg with free variables x1 ; : : :; xk , where k is the arity of R. For any structure A over the signature ,  de nes a mapping, A on relations of arity k in the following sense | given a relation RA  jA jk , let hA ; RA i be the expansion of A interpreting R as RA . Then, A (RA ) = fha1; : : :ak ijhA ; RA i j= [a1; : : :; ak ]g The map  is called monotone if for any relations R and S such that R  S , (R)  (S ). A map that is monotone has a least xed point, i.e., a smallest relation R such that (R) = R. Moreover, this least xed point can be obtained by the following iterative construction: Let 0A = ; and mA +1 = A (mA ). Then for some m (depending on the structure A ), mA +1 = mA = the least xed point of A . The least such m is called the closure ordinal of  on the structure A and denoted jjjjA . If n is the size of A , then there are nk k-tuples in A and since A is monotone, jjjjA  nk . A sucient syntactic condition for the formula  to de ne a monotone map on all structures is that  be positive in R, that is to say that all occurrences of R in  be within the scope of an even number of negations. We can now de ne the logic LFP over signature  as the smallest set of formulas satisfying:

 if  is a rst-order formula over , then  2 LFP(),  if  is formed from formulas in LFP() by conjunction, disjunction, negation and rst-order quanti cation, then  2 LFP( ), and 8

 if  2 LFP( [fRg),  is positive in R and x1; : : :; xk are distinct variables, where k is the arity of R, then lfp(R; x1 : : :xk )(t1 : : :tk ) 2 LFP( ) for any terms t1 ; : : :; tk . The way to read the last clause above is that the operator lfp binds the second order variable R and the rst-order variables x1 ; : : :xk in  to form a new predicate. This predicate is to be interpreted as the k-ary relation that is the least xed point of the monotone operator de ned by . This predicate is then evaluated at the elements denoted by the terms t1 ; : : :; tk . As an example, let (R; x; y ) be x = y _ 9z (E (x; z ) ^ R(z; y )), the right side of (1.1) above. Then, lfp(R; x; y )(x; y ) is a formula in two free variables that expresses the re exive and transitive closure of the edge relation on any graph. The following normal form result was established in [Immerman, 1986] for formulas of LFP.

Theorem 1.2 In any vocabulary containing constant symbols, every formula in LFP is equivalent to a formula lfp(R; x)(t), where  is rst-order. For more examples of the use of the lfp operator, see Section 3.4. Alternatively, we can de ne the language IFP which has an operation ifp (in ationary xed point) in place of lfp. In ifp(R; x1 : : :xk )(t1 : : :tk ),  is not required to be positive in R. The relational expression ifp(R; x1 : : :xk ) denotes the least xed point of the operator 0 given by 0 (RA ) = fha1; : : :ak ijha1; : : :ak i 2 RA or hA ; RA i j= [a1; : : :; ak ]g = (RA ) [ RA . This language is equivalent in expressive power to LFP:

Theorem 1.3 ([Gurevich and Shelah, 1986]) A query is expressible in IFP if and only if it is expressible in LFP.

Immerman [Immerman, 1986] and Vardi [Vardi, 1982] independently showed that when we include a total ordering on the domain as part of the logical vocabulary, the language LFP expresses exactly the class of polynomial time computable queries.

Theorem 1.4 ([Immerman, 1986],[Vardi, 1982]) LFP with ordering = P. We saw above how a formula with one free predicate variable de ned an operator on relations. This, of course, is true even when the formula is not positive in the predicate 9

variable and the operator, in turn, may or may not be monotone. Moreover, the iterative stages of the operator can still be de ned, though they are not guaranteed to converge to a xed point in the case of non-monotone operators. Let (R; x) be a formula that de nes a (possibly non-monotone) operator . De ne the partial xed point of  to be m for the least m such that m+1 = m , if such an m exists, and empty otherwise. Because there are only 2nk sets of k-tuples over a structure of size n, if such an m exists, then m  2nk . We can then de ne another extension of rst-order logic called PFP with a syntax similar to that of LFP except that the lfp operation is replaced by pfp, which can operate on arbitrary formulas, not just positive ones. The relational expression pfp(R; x) denotes the partial xed point of . It has been shown in [Abiteboul and Vianu, 1991a] that the language PFP is equivalent to the query language while { an extension of rst-order logic with an iterative operation. Putting this together with a result of Vardi [Vardi, 1982], we get the following:

Theorem 1.5 ([Vardi, 1982],[Abiteboul and Vianu, 1991a]) PFP with ordering = PSPACE.

1.4 Unordered Structures As manrioned above, the logic LFP expresses exactly the PTIME properties of structures with a built-in ordering. However, there are collections of structures, which do not have such an ordering, that are recognizable in polynomial time but are not expressible in this logic (see Section 2.2). This raises the question whether there is a logic that expresses exactly the PTIME properties of all structures. That is, is there a natural logic L such that for every sentence  of L, the class of nite structures Mod() is recognizable in polynomial time and conversely, for every class of structures K such that the collection of strings that are encodings of structures in K is recognizable in polynomial time, there is a sentence  in L such that K = Mod()? This question as stated above is not precisely formulated, because we have not de ned what we mean by a natural logic. However, it can be seen as part of the broader question: are the PTIME properties of all structures recursively enumerable? For concreteness, consider graphs, i.e., structures over the signature fE g, where E is a binary relation 10

symbol. As mentioned above, a graph on n nodes can be encoded as a bit string of length n2. However, the same graph can be encoded in many di erent ways (up to n!) and some machines will accept some encodings of a given graph but not others. We say a Turing machine accepts a graph property if it does not break isomorphism classes of graphs, that is to say it either accepts or rejects all encodings of any given graph. Or, putting it di erently, the collection of graphs accepted by the machine is closed under isomorphisms. Every Turing machine can be converted into a polynomial time machine by attaching a clock to it that terminates any computation if it exceeds some xed polynomial time bound. This gives us an enumeration, Mi (i 2 ! ) of polynomial time machines that includes machines that accept any polynomial time recognizable class of binary strings. The problem that we posed can now be framed as follows: can we enumerate a sub-sequence of this list that only includes machines that accept graph properties and includes at least one machine for each graph property accepted by some machine on the original list. We chose the language of graphs for a reason. Structures over any given signature  can be encoded as graphs while preserving isomorphism. Moreover this can be done in polynomial time. In fact, the translation of arbitrary structures into graphs is rst-order de nable. That is to say, for a given signature,  , there are rst order formulas 8 and E in the language  that de ne a graph G(A ) for any structure A . The formula 8 de nes the set of vertices and E de nes the edge relation and G(A )  = G(B ) if and only if A  =B (see, for instance, [Lindell, 1987]). Thus, the problem of the recursive enumerability of the PTIME properties of arbitrary structures reduces to that for graphs. We can look at the same problem in another way. The binary string encoding of graphs described above can be seen as encoding an ordered graph, with the ordering given by the natural ordering on the integers. In this way, each ordered graph gives a unique binary string and hence no Turing machine breaks isomorphism classes. Hence, we know that we can enumerate all the PTIME properties of ordered graphs. We also obtain such an enumeration simply by enumerating all the sentences of LFP over the signature fE; k, are not distinguished by any sentence of 1

Lk .

2

Proof:

The proof is by induction on n: Basis: T0;m1 and T0;m2 , both contain a single vertex, and they are isomorphic. Induction Step: The tree Tn+1;m1 consists of m1 copies of Tn;m1 , call them A1 ; : : :; Am1 , with the root of each Ai being a child of the root of Tn+1;m1 . Similarly, Tn+1;m2 contains m2 copies, B1 ; : : :; Bm2 , of Tn;m2 . By induction hypothesis, Player II has a winning strategy in the pebble game played with k pairs of pebbles, (a1; b1); : : :; (ak ; bk ) on the structures Tn;m1 and Tn;m2 . We now exhibit a winning strategy for Player II in this game on the structures Tn+1;m1 and Tn+1;m2 . If Player I places a pebble at the root of one of the trees, Player II responds by playing at the root of the other tree. If Player I places a pebble in one of the Ai , which already has a pebble, aj , Player II responds by playing the corresponding pebble in the Bi that contains bj , maintaining the partial isomorphism between Ai and Bi using the winning strategy for Tn;m1 and Tn;m2 . If Player I places a pebble in an Ai that does not already contain a pebble, Player II responds by playing in any Bi that does not contain a pebble. Such a Bi must exist, because m2 > k and there are only k pairs of pebbles. Again, Player II ensures that the partial isomorphism between Ai and Bi is maintained. The situation when Player I plays in one of the Bi is symmetric. It is easy to see that Player II can play the game inde nitely and the mapping ai ! bi is always a partial isomorphism between Tn+1;m1 and Tn+1;m2 . The following de nition allows us to use classes of complete trees with varying branching degree to encode functions over the natural numbers. This is then used in Theorem 4.20 0

0

0

0

0

63

to construct, by diagonalization, a class that does not have the k-preservation property for any k  2.

De nition 4.19 For any function f : ! ! !, let Tf = fTn;f (n)jn 2 !g. Theorem 4.20 There is a class of structures C such that for every natural number k  2, C does not have the k-preservation property.

Proof:

We assume a standard encoding of pairs of natural numbers as natural numbers. We write hm; ni to denote the natural number encoding the pair m; n. Also, let 0; : : :; n; : : : be a xed enumeration of rst-order sentences in the vocabulary hE i, such that for all k 2 ! , h0;ki; : : :; hi;ki; : : : is an enumeration of all the sentences of Lk . Now, de ne the function f : ! ! ! as follows:

8 >< k + 1 if Thi;ki;k+1 j= hi;ki f (hi; ki) = > : k + 2 otherwise

Note that, by Lemma 4.18, Thi;ki;k+1 j= hi;ki , if and only if, Thi;ki;k+2 j= hi;ki. Thus, by the above de nition of f , Thi;ki;f (hi;ki) j= hi;ki if and only if, f (hi; ki) = k + 1. We now show that the class of trees Tf does not have the k-preservation property for any k. Observe that every rst-order sentence is equivalent over Tf to a sentence of L21! . To see this, let S = fhjTh;f (h) j= g. Then, is equivalent, over Tf , to:

_

h2S

h

where the h are given by Lemma 4.17. We now need to show that for every k 2 ! , there is a rst-order sentence k that is not equivalent, over Tf , to any sentence of Lk . Let k be the sentence (with k +3 variables) that says that there is a point with k + 2 distinct children. Assume, towards a contradiction, that k is equivalent to some sentence of Lk , say hi;ki . But, by the de nition of f , k and hi;ki di er on Thi;ki;f (hi;ki). While Theorem 4.20 demonstrates that Theorem 4.15 does not resolve McColm's rst conjecture, it does not, however, provide a counterexample to the conjecture either. Indeed, McColm [McColm, 1990] showed that LFP does not collapse to FO on any class of trees 64

with unbounded height. It follows that it does not do so on the class, C , constructed in the proof of Theorem 4.20.

4.4 The Ordered Conjecture Theorem 4.15 also raises the question, for which classes C and k is it the case that C has the k-preservation property. In particular, does the class of all nite structures F have the k-preservation property for any k? We shall show in this section that this question is linked to a restricted version of McColm's rst conjecture, which was formulated by Kolaitis and Vardi [Kolaitis and Vardi, 1992a] that deals with ordered structures. In the case of the class of all structures ( nite or in nite), this question is resolved as a direct consequence of a result proved by Immerman and Kozen [Immerman and Kozen, 1989], using the compactness theorem. This is stated in the theorem below.

Theorem 4.21 ([Immerman and Kozen, 1989]) The class S of all structures ( nite or in nite) has the k-preservation property, for all k.

It is an open question whether this preservation theorem holds in the case of nite structures for any k. Open Question Is there any k such that the class, F , of all nite structures has the k-preservation property? This question is closely connected to a restricted version of McColm's rst conjecture that was formulated by Kolaitis and Vardi in [Kolaitis and Vardi, 1992a]. This restricted conjecture states, essentially, that McColm's rst conjecture is true of all classes of ordered structures. Since any class C of ordered structures which contains arbitrarily large nite structures is pro cient, and the LFP queries correspond exactly to the polynomial time queries on ordered structures, this conjecture can be stated in the following terms:

Conjecture 4.22 ([Kolaitis and Vardi, 1992a]) Over any class of ordered structures

that contains arbitrarily large nite structures, there is a polynomial time computable query that is not rst-order de nable.

In investigating this conjecture, and its connection with the k-preservation property, we will use the property of ordered structures stated in the following lemma. 65

Lemma 4.23 Let  be a signature containing the relation symbol , and let A be a -

structure that interprets  as a linear ordering on its universe. Let m be the maximum arity of any relation symbol in  . Then, for any l  m, if a1 ; : : :; al are elements from A , there is a formula  of Lk (k = max(m; 3)) such that, for any structure B and elements b1; : : :; bl, B j= [b1 : : :bl], if and only if, there is an isomorphism f : A  = B with f (ai) = bi (1  i  l).

Proof:

Recall from the argument given in Section 3.2 that, for any structure A with a linear order  and any element a 2 jA j, there is a formula a(x) of L2 such that a is the only element of A such that A j= [a]. But then, for any m-tuple of elements, there is a formula of Lm that identi es that tuple uniquely. Using these formulas, we can write a sentence A of Lm that determines the structure A up to isomorphism, among structures that interpret  as a linear order. Let  be the sentence (of L3) that asserts that  is a linear order. V Then, A ^  ^ 1il ai is a formula with the required properties. It follows from Lemma 4.23 that if C is a class of ordered structures over some signature , where all relation symbols in  have arity at most m, then every query, of arity at most m, on C is de nable in Lm1! (assuming m is at least 3). Furthermore, if  is any rst-order formula (with at most k free variables, for any k  m) in such a signature  and  is the rst-order sentence that asserts that the relation interpreting  is a linear order, then it follows easily from Lemma 4.23 that  ^  is equivalent over the class of all nite structures to a formula of Lk1! . This enables us to prove the following theorem.

Theorem 4.24 Let  be a signature containing the relation symbol , and let C be a class of  -structures such that every structure A in C interprets  as a linear ordering on its universe. Let m be the maximum arity of any relation symbol in  . Then, for any k  m; 3 such that the class of all nite  -structures, F has the k-preservation property, C has the k-preservation property.

Proof:

Let  be any rst-order formula with free variables among x1 ; : : :; xk , and let  be the rst-order sentence that asserts that the relation interpreting  is a linear order. Since m  k, by the observations above,  ^  is equivalent over F to a formula of Lk1! . But 66

then, by the k-preservation property of F , there is a formula of Lk that is equivalent to  ^  over F . Since  is true in all structures in C , it follows that on C , de nes the same query as . In the proof of Theorem 4.24, we do not actually require the full force of the kpreservation property of F . We now de ne a weaker notion of preservation that will allow us to prove a stronger version of Theorem 4.24.

De nition 4.25 A collection of structures C has the weak k-preservation property, if and only if, there is a k0  k such that every query which is both rst-order de nable over C and Lk1! de nable over C , is Lk de nable over C . 0

We can now state the stronger version of Theorem 4.24.

Theorem 4.26 Let  be a signature containing the relation symbol , and let C be a class of  -structures such that every structure A in C interprets  as a linear ordering on its universe. Let m be the maximum arity of any relation symbol in  . Then, for any k  m; 3 such that the class of all nite  -structures, F has the weak k-preservation property, there is a k0 such that C has the k0 -preservation property.

Proof:

Let  be any rst-order formula and let  be as before. As before,  ^  is equivalent over F to a formula of Lk1! , and by the weak k-preservation property it is equivalent to a formula of Lk . Theorem 4.26 provides a possible approach to the resolution of Conjecture 4.22. This is clearly seen from the following corollary. 0

Corollary 4.27 If there are in nitely many k such that the class of all nite structures F has the weak k-preservation property, then Conjecture 4.22 holds.

Another possibility raised by Theorem 4.26 is to attempt to prove versions of Conjecture 4.22 for particular signatures. Thus, in the case of ordered graphs, the following corollary holds.

Corollary 4.28 If there is any k  3 such that the class of all nite structures F has the

weak k-preservation property, then any class C of ordered graphs that contains arbitrarily large graphs admits a query that is de nable in LFP but not de nable in FO.

67

Ordered graphs can be thought of as linear orders with an additional binary relation. This is the simplest case of ordered structures for which it is an open question whether there is a k such that every collection of structures from this class has the k-preservation property. In the case of linear orderings with additional unary relations, Poizat [Poizat, 1982] proved a result which can be re-stated in the terms we have de ned as follows.

Theorem 4.29 ([Poizat, 1982]) In the signature  = h; U1; : : :; Uni, where U1; : : :; Un

are unary relation symbols, if C is a the class of structures such that for all A 2 C ,  is interpreted as a linear order, C has the 3-preservation property.

68

Chapter 5

Generalized Quanti ers and Logical Reducibilities We have seen (in Section 2.2) that LFP is too weak a logic to express all PTIME properties of nite structures. It remains an open question whether there is any extension of this logic that expresses exactly the PTIME properties. As we pointed out in Section 1.4, it is not even known if the PTIME properties are recursively indexable. Since all known examples of properties that are computable in polynomial time but not expressible in LFP involved the failure of this logic to express cardinalities, it was conjectured that an extension of LFP by means of counting quanti ers would suce to express all PTIME properties. Cai, Furer and Immerman [Cai et al., 1989] showed that this is not the case. In this chapter we study extensions of LFP by means of generalized quanti ers in order to determine if some such extension might exactly capture the PTIME computable properties. The approach to increasing the expressive power of LFP that we consider is to add to the language generalized quanti ers, in the sense of Lindstrom [Lindstrom, 1966]. Associated with each quanti er is its arity n. Recently, Hella [Hella, 1992], generalizing a result of [Cai et al., 1989] has shown that for any set Q of generalized quanti ers whose arities are bounded by n, there is a polynomial time recognizable class of nite structures Cn that is not expressible in LFP(Q) { the extension of LFP with all the quanti ers in the set Q. One important consequence of this result is that there is no nite set of generalized quanti ers that can be added to LFP to yield a logic that captures PTIME. The class Cn constructed 69

by Hella is in a signature that contains a relation of arity n + 1. If we con ne ourselves to structures over a xed signature, such as the language of graphs, the result vanishes. Indeed, there is a collection Q of binary quanti ers such that LFP(Q) expresses all the polynomial time properties of graphs. It then follows, by an encoding de ned in [Hella, 1989], that there is a single ternary quanti er, Q, such that the extension of LFP with the single quanti er Q expresses all the polynomial time properties of graphs. However, this quanti er is not necessarily itself PTIME computable, and therefore LFP(Q) may be able to express queries that are not in PTIME. This leaves open the question of whether, for a xed signature  , there is a nite set of generalized quanti ers Q such that LFP(Q) expresses exactly the PTIME computable queries over  . In one of the results in this chapter, we provide a negative answer to this last question. Towards this end, in Section 5.2, we generalize the notion of element types and related techniques to languages where we have generalized quanti ers. In doing so, we establish generalizations of some of the results in Chapters 2 and 4. We use this to show that, for any nite collection Q of generalized quanti ers, there are only nitely many properties of complete graphs (or, more generally, of complete structures over any signature  ) that are expressible in Lk1! (Q) for any given k. Lauri Hella [Hella, 1993] has used this to show that, if each quanti er in the set Q is itself computable in polynomial time, then there is a polynomial time recognizable set of nite structures over  that is not expressible in L!1! (Q). We give a proof of this result in Section 5.3. In Section 5.4 we de ne certain kinds of in nite sets of generalized quanti ers of unbounded arity, with a strong uniformity condition. These uniform sequences of generalized quanti ers correspond to a natural notion of logical reducibility. We establish that there is such a uniform sequence Q such that LFP (or FO) enriched with the quanti ers in Q expresses exactly the properties of structures that are computable in polynomial time (or logarithmic space), if and only if, there is a property that is complete for PTIME (respectively, LOGSPACE) with respect to rst order de nable reductions. Moreover, this occurs, if and only if, the properties in PTIME (respectively, LOGSPACE) are recursively indexable. We show, thus, that if there is any recursively enumerable set of generalized quanti ers which can be added to LFP (or FO) to capture exactly PTIME, there is a uniform sequence with this property. 70

In this chapter, we refer to an abstract logic L, whereby we mean any extension of rst order logic that satis es reasonable closure properties. It suces, for instance, if L is a regular logic in the sense of [Ebbinghaus, 1985].

5.1 Generalized Quanti ers Let C be any collection of structures over the signature  = hR1 : : :Rmi (where Ri has arity ni) that is closed under isomorphism, i.e., if A  = B then A 2 C , if and only if, B 2 C . We associate with C the generalized quanti er QC . For a logic L, de ne the extension L(QC ) by closing the set of formulas of L under the following formula formation rule: if 1 : : :m are formulas of L(QC ) and x1 : : : xm are tuples of variables with the length of xi being ni, then QC x1 : : : xm (1 : : :m ) is a formula of L(QC ) with all occurrences in i of the variables among xi bound. The semantics of the quanti er is given by the following rule: A j= QC x1 : : : xm (1 : : :m ), if and only if, hA; A1 : : :Am i 2 C , where A is the universe of A and Ai = fa j A j= i [a]g.

Example 5.1 1. The existential quanti er (9) can be de ned as the generalized quanti er associated with the class of structures C over the signature with one unary relation symbol R given by C = fhA; RA i j RA is not emptyg. 2. The universal quanti er (8) is the generalized quanti er associated with the class C = fhA; Aig. 3. The Hartig (or equicardinality) quanti er is given by the class C = fhA; S1; S2i j S1 ; S2  A and card(S1) = card(S2)g. 4. The Rescher (or majority) quanti er is given by the class C = fhA; S1; S2i j S1; S2  A and card(S1)  card(S2)g. 5. The successor quanti er is associated with the class C = fhA; S1; S2i j S1; S2  A and card(S1) = card(S2) + 1g. 6. The unary counting quanti ers are those associated with the classes Ci = fhA; S i j S  A and jS j  ig, for each i 2 !.

71

For a set of generalized quanti ers Q, we write L(Q) for the extension of the logic L by all the quanti ers in Q. Thus, for instance, FO(Q) denotes the extension of rst-order logic by the generalized quanti ers in the set Q, and Lk (Q) is the fragment of FO(Q) in which there are at most k distinct variables in each formula. The following result is a direct consequence of a result in [Cai et al., 1989] which showed that it does not suce to add counting to LFP in order to express all PTIME properties.

Theorem 5.2 ([Cai et al., 1989]) There is a polynomial time graph property that is not expressible in L!1! (C), where C is the set of all unary counting quanti ers. The notion of quanti er rank given in De nition 2.2 can be easily generalized to logics such as FO(Q) and L!1! (Q) for sets of generalized quanti ers Q. We need to add another clause to that de nition which says: 5. if  = Qx1 : : : xm (1 : : :m ) then qr() = max1im (qr(i )) + 1. For a quanti er Q associated with a class of structures over the signature hR1 : : :Rm i, de ne the arity of Q to be max(n1 ; : : :; nm ), where ni is the arity of Ri . Hella [Hella, 1992] has established the following result, which generalizes Theorem 5.2.

Theorem 5.3 ([Hella, 1992]) Given any set Q of generalized quanti ers of bounded ar-

ity, there is a signature  and a polynomial time recognizable class of structures C of signature  that is not de nable in LFP(Q).

It follows immediately that the addition of a nite number of generalized quanti ers to LFP will not allow us to express all classes of structures recognizable in polynomial time:

Corollary 5.4 ([Hella, 1992]) If Q is a nite set of generalized quanti ers, there is a signature  and a polynomial time recognizable class of structures C of signature  that is not de nable in LFP(Q).

Note that in Theorem 5.3, the signature  depends on Q. In particular,  must contain a relation symbol of arity greater than the bound on the arities of the quanti ers in Q. If we only consider classes of structures over a xed signature, Theorem 5.3 fails. Consider, for instance, graphs, i.e., structures over the signature with one binary relation. If we add 72

to LFP (or, indeed, to FO) a quanti er for each polynomial time property of graphs, each of these properties is then trivially de nable. Moreover, all the quanti ers have arity 2. Observe also, that all queries that are de nable in the logic thus obtained are computable in polynomial-time. However, this logic does not give us a recursive indexing of PTIME in the sense of De nition 1.6, unless the collection of quanti ers Q is e ectively enumerable, i.e., unless we already have a recursive indexing of the PTIME properties of graphs. Hella showed in [Hella, 1989] that, for any countable collection of generalized quanti ers Q with the property that there is a bound n on the arity of the quanti ers in Q, there is a single quanti er Q of arity n + 1 such that every property expressible in FO(Q) is expressible in FO(Q). Thus, in particular, there is a ternary generalized quanti er which, when added to FO, yields a logic that expresses all polynomial time graph properties. More generally, by the same argument, for every xed signature  , there is a single generalized quanti er P such that FO(P ) expresses all the polynomial time properties of structures of signature  . Thus, Corollary 5.4 fails as well, when we x the signature. However, in general, the encoding of a countable set of quanti ers of bounded arity into a single quanti er yields a logic that is strictly more powerful than the original one. Thus, it is possible that the logic FO(P ) obtained by encoding quanti ers for all the polynomial time properties of structures of signature  into a single quanti er expresses properties that are themselves not polynomial time computable. In Section 5.3, we show that, indeed, this must be the case. We show that for every signature  , there is no nite set of quanti ers Q such that FO(Q) (or LFP(Q)) expresses exactly the polynomial time properties of graphs. In what follows, we will generally not distinguish between a generalized quanti er and the class of structures with which it is associated, where this will not result in any confusion.

5.2 Quanti ers and Element Types We begin with a result that generalizes Theorem 2.12 and Corollary 2.18. Recall that these results established, respectively, that every nite structure is characterized up to equivalence in Lk by a single sentence of Lk and that every Lk -type realized in any nite structure is isolated by a formula of Lk . We now show that similar results hold for extensions of Lk 73

by nitely many generalized quanti ers. For this purpose, we introduce the notion of an Lk (Q)-type for a set of generalized quanti ers Q.

De nition 5.5 For any collection of generalized quanti ers Q, and for any sequence s = ha1 : : :ali of elements in a structure A , with l  k, de ne the Lk (Q)-type of s, denoted TypeQk (A ; s), to be the set of formulas,  2 Lk (Q) with free variables among x1 ; : : :; xl, such that A j= [a1 : : :al ].

We write hA ; ai Qk hB ; bi to denote TypeQk (A ; a) = TypeQk (B ; b). Consider a xed nite structure A and let n be the cardinality of its universe. There are nk distinct k-tuples of elements of A and, for any xed Q, the relation Qk is an equivalence relation on these tuples. By de nition, for any two distinct equivalence classes under this relation, there is a formula of Lk (Q) that distinguishes them. By taking Boolean combinations of these formulas, it is easily seen that we can obtain a collection of formulas Q k 1; : : :; m, one for each equivalence class that k de nes on jA j such that: 1. for each tuple s 2 jA jk there is exactly one i such that A j= i[s]; and 2. for any tuples s; s0 2 jA jk , and any i, A j= i [s] and A j= i[s0 ], if and only if, hA ; si Qk hA ; s0i. If the set of generalized quanti ers Q is nite, then, for a xed q , there are, up to logical equivalence, only nitely many formulas of Lk (Q) of quanti er rank q or less. Let q be the maximum quanti er rank of any of the formulas i and let 1 ; : : :; r be a maximal collection of inequivalent formulas of quanti er rank q + 1 or less. For each j 2 f1; : : :; rg, de ne G(j ) = fi j A j= i ! j g, that is, G(j ) de nes the set of Qk equivalence classes in A whose Lk (Q)-type includes j . Now, de ne the sentence A as follows:

A =

^ 1im

9x1 : : : 9xk i ^

(5.1)

i^

(5.2)

8x1 : : : 8xk

^

1j r

_

1im

8x1 : : : 8xk (j $ j );

(5.3) 74

where the j are de ned as:

8 _ >< if G(j ) is non-empty; i

j = > i2G(j) : 9x:(x = x) otherwise.

Observe that A j= A . In particular A makes (5.3) true precisely because, within A , the formulas i determine the Lk (Q)-type of a tuple completely. We can now show that, if Q is a nite set of quanti ers, then the Lk (Q)-types that are realized in nite structures are isolated.

Theorem 5.6 For any nite set of generalized quanti ers Q, and for any nite structure A and any tuple ha1 : : :al i of elements in A , with l  k, there is a formula  2 Lk (Q) with

free variables among x1; : : :; xl, such that, for any structure B and elements b1 ; : : :; bl in B , B j= [b1 : : :bl ], if and only if, hA ; a1 : : :al i Qk hB ; b1 : : :bl i.

Proof:

Let 1; : : :; m be formulas for the structure A as constructed above. Let I  f1; : : :; mg be the set of all i such that there are points al+1 ; : : :; ak such that A j= i [a1 : : :ak ]. Now, de ne the formula  as follows:

(x1 ; : : :; xl) = A ^ 8xl+1 : : : 8xk

_

i2I

i:

(5.4)

Since A j= A , it is clear that A j= [a1 : : :al ]. But then, if hA ; a1 : : :al i Qk hB ; b1 : : :bli, it must be that B j= [b1 : : :bl]. This establishes the result in one direction. In the other direction, suppose B j= [b1 : : :bl]. Let  be any formula of Lk (Q). It is clear, by the de nition of the i that, in the structure A ,  is equivalent to a formula of W the form j 2J j for some set J . We show by induction on the quanti er rank of  that B j=  $ Wj 2J j . As before, let q be the maximum quanti er rank of any of the formulas i. W Basis: If qr()  q + 1, then, since B j= A , by (5.3), B j=  $ j 2J j . Induction Step: Suppose  is of the form Qx1 ; : : :; xp(1 ; : : :; p ) for some Q 2 Q (we can consider the existential and universal quanti ers to be just special cases). Then, by the induction hypothesis, each of the i is equivalent, over both A and B , to a formula of 75

W

the form j 2Ji j . But, each of the latter formulas has quanti er rank at most q . Thus, replacing the i be these equivalent formulas, we obtain a formula that is equivalent to  and has quanti er rank at most q + 1. Therefore, we are back in the basis case. Note that, in the case where the free variables of  are among x1 ; : : :; xl, for some l < k, W then it is also the case that B j=  $ 8xl+1 : : : 8xk j 2J j . In particular, suppose that  2 TypeQk (A ; a1 : : :al ), then it must be the case that I  J , where I is the set used in (5.4). Thus, it must be the case that B j=  ! , and therefore  2 TypeQk (B ; b1 : : :bl). Conversely, for any  2 TypeQk (B ; b1 : : :bl), it must be that I  J , since B j= [b1 : : :bl]. But then, A j=  ! , and therefore  2 TypeQk (A ; a1 : : :al ). It is easily seen, by considering the type of the empty sequence in the proof of Theorem 5.6, that the sentence A characterizes the structure A up to equivalence in Lk (Q). Moreover, by taking Q to be the empty set, both Theorem 2.12 and Corollary 2.18 can be derived as special cases of Theorem 5.6. The quanti er rank bound q that was used in the proof of Theorem 5.6 can be bounded above by the number of distinct Lk (Q)-types that are realized in A . To see this, consider the equivalence relations Qk;n on the k-tuples of A , whereby two tuples are equivalent, if and only if, they make true the same formulas of Lk (Q) of quanti er rank n or less. For each n, the relation Qk;n+1 is a re nement of the relation Qk;n . If we choose q to be the smallest number such that Qk;q+1 is the same relation as Qk;q , we can de ne a quanti er elimination such as the one used in the proof of Theorem 5.6. But clearly, this q must be no larger than the number of equivalence classes given by the relation Qk;q . This motivates the following de nition.

De nition 5.7 For any nite set Q of generalized quanti ers, and any nite structure A , k let kQ (A ) = card(fTypeQ k (A ; s) j s 2 jA j g):

We are now in a position to obtain a result similar to Lemma 4.6 for the case of logics with nitely many generalized quanti ers. This result is stated in the following corollary, which is a consequence of the proof of Theorem 5.6.

Corollary 5.8 For any nite set Q of generalized quanti ers, and any class of nite

structures C , sup(fkQ(A ) j A 2 Cg) < ! , if and only if, the set fTypeQ k (A ; s) j s 2 jA jk and A 2 Cg is nite.

76

Proof:

By the observations made above, every Lk (Q)-type realized in a structure A is isolated by a formula of quanti er rank at most kQ (A ) + k. Since sup(fkQ(A ) j A 2 Cg) < ! , there is an n such that every type realized in any structure in C is isolated by a formula of quanti er rank at most n. But, as we observed above, there are, up to logical equivalence, only nitely many such formulas. It is a direct consequence of the above proof that, for any class C that satis es the conditions of Corollary 5.8, there is an n such that any formula of Lk (Q) is equivalent, over C , to a formula of quanti er rank n or less. This is because such a formula can always be expressed as a disjunction of the formulas that isolate the types realized in structures in C . Furthermore, if we consider an in nitary disjunction (or conjunction) of formulas of Lk (Q), then this reduces, over C to a nitary disjunction (or conjunction). This is because each of the disjuncts (or conjuncts) can be replaced by a formula of quanti er rank n or less, and there are, up to equivalence, only nitely many such formulas. Proceeding by induction, we can take any formula  of Lk1! (Q) and obtain a formula of Lk (Q) that is equivalent to  over C . This establishes the following corollary which generalizes one part of Theorem 4.10.

Corollary 5.9 For any nite set Q of generalized quanti ers and any k 2 !, and any

class of nite structures C such that sup(fkQ(A ) j A 2 Cg) < ! , there are only nitely many queries over C that are expressible in Lk1! (Q), and each one of these is expressible over C by a formula of Lk (Q).

The other part of Theorem 4.10 also holds for logics with generalized quanti ers. If sup(fkQ (A ) j A 2 Cg)  ! , then there are clearly in nitely many inequivalent formulas of Lk (Q), and therefore 2! distinct queries de nable in Lk1! (Q). Corollary 5.9 allows us to establish a sucient condition for a class C to have the property that Lk1! (Q) collapses to Lk (Q), for all nite sets of quanti ers Q. To see this, we need to introduce the following de nitions.

De nition 5.10 For any structure A and any k 2 !, let 'k denote the equivalence rela-

tion on jA jk given by s 'k s0 , if and only if, there is an automorphism f of A such that f (s) = s0 . Let k (A ) denote the number of equivalence classes of the relation 'k in jA jk .

77

Note that, for any structure A and any tuples s; s0 2 jA jk , if s 'k s0 , then for any Q whatsoever, it must be that TypeQk (A ; s) = TypeQk (A ; s0). It follows that kQ (A )  k (A ) for any A and any Q. Then, the following corollary is a straightforward consequence of Corollary 5.9.

Corollary 5.11 For any k 2 ! and any class of nite structures C such that sup(f k (A ) j A 2 Cg) < ! , there are, for all nite sets Q of generalized quanti ers, only nitely many queries de nable in Lk1! (Q) over C , and each one of these is de nable over C by a formula of Lk (Q). The conditions imposed on C in Corollaries 5.8, 5.9 and 5.11 are, in general, stronger than requiring C to be k-compact. To see that these stronger hypotheses are necessary, we construct an example of a class C and a single quanti er Q such that C is k-compact for all k, but there is a k such that Lk1! (Q) expresses 2! distinct queries. The class E we use is the class of nite equivalence relations. That is, E is the collection of all nite structures A over the vocabulary fE g, where E is a binary relation symbol, such that E is interpreted by an equivalence relation on the universe of A . We rst show that this class is k-compact for all k.

Proposition 5.12 E is k-compact, for all k. Proof:

Observe that it suces to show that for any k, there are only nitely many structures in E , up to equivalence in k . This is because two structures that are equivalent realize the same ( nite) set of Lk -types. Fix k, and associate with each structure A 2 E , a label consisting of a sequence hn1; : : :; nk i of natural numbers de ned as follows: 1. for 1  i < k, ni = min(k; Ni), where Ni is the number of equivalence classes in A (under the equivalence relation E A ) of size i; 2. nk is the number of equivalence classes in A of size k or more, if this number is less than k, and nk is k otherwise. 78

Note that ni  k for all i, and therefore there are only nitely many distinct labels. We show next that if two structures A and B have the same label, then A k B . To show this, we exhibit a winning strategy for Player II in the k-pebble game played on these two structures. Suppose, without loss of generality, that at some point in the game, Player I places pebble ai on some element of A . If this element is in an equivalence class that already contains a pebble aj , then Player II places bi in the equivalence class containing bj . If ai is placed in an equivalence class that does not already contain a pebble, there are two cases: if the size n of the equivalence class in which ai is placed is smaller than k, then Player II picks an equivalence class in B of the same size which does not already contain a pebble; if n is k or more, then Player II picks any equivalence class in B of size k or more, which does not already contain a pebble. To see that a class of the right size can always be found, note that, in either case, either A and B have the same number of classes of the appropriate size, or they each have at least k of them. In the former case, an induction on the moves of the pebble game shows that there must be a class of size n in B with no pebble in it, if there is one in A . In the latter case, since there are only k pairs of pebbles, there must be a class of the appropriate size in B that does not contain a pebble. It is easily veri ed that this strategy does indeed preserve partial isomorphism between A and B . Let Q be the successor quanti er de ned in Example 5.1. De ne, inductively, the following formulas of L4 (Q).

1 (x) = 8y:Exy; m+1 (x) = 9w(Qyz(Exy; Ewz) ^ 9x(x = w ^ m (x))): Observe that for A 2 E and a 2 jA j, A j= n [a], if and only if, a is part of an equivalence class of size n and A contains equivalence classes of size m for all m < n. Thus, the formulas n are all inequivalent over E , and they can be used to de ne 2! formulas of L41! , which are pairwise inequivalent over E . 79

5.3 Finitely Many Quanti ers The results of the previous section can be used to show that, for each signature  , there is no nite set of generalized quanti ers Q such that LFP(Q) expresses exactly the collection of polynomial time properties over the class of nite structures of signature  . This observation is due to Hella [Hella, 1993]. Towards this end, we will examine a particular class of structures that meets the conditions of Corollary 5.11 for all k, i.e., a class such that k (A ) is bounded over the class for all k. For a xed signature  , let K be the class of complete structures over  , i.e., for every relation symbol R (of arity a) in  and every structure A 2 K , RA = Aa , where A is the universe of A . We write Kn for the unique (up to isomorphism) structure of size n in K (or just Kn and K, when  is understood). This notion is a direct generalization of the notion of a complete graph. Note that the class K is rst-order de nable. In order to study the class of complete structures of any signature, we also need the following de nition:

De nition 5.13 Given a structure A and a tuple of elements a from A , the basic equality

type of hA ; ai is the (unique up to equivalence) quanti er free formula , with no non-logical vocabulary, such that A j= [a] and for every quanti er free formula , with no non-logical vocabulary, exactly one of  j= or  j= : holds. That is, the basic equality type of a tuple is a formula that describes the tuple completely in the language of identity. Note that the number of distinct basic equality types of k-tuples in a structure of size k or greater depends only on k and not on the particular structure. Observe also, that for two k-tuples s and s0 in a complete structure, s 'k s0 , if and only if, s and s0 have the same basic equality type. It follows immediately that k (Kn ) is a bounded function of n. Let Q = fQ1; : : :; Qn g be any nite set of generalized quanti ers. Clearly, in any complete structure A , for any two k-tuples s; s0 2 A which have the same basic equality type, it must be that TypeQk (A ; s) = TypeQk (A ; s0). It follows that, if A is a complete structure, then the formulas 1; : : :; m used in the proof of Theorem 5.6 can be assumed to be quanti er free formulas. Thus, a complete structure, Kt is characterized up to 80

equivalence in Lk1! (Q) by a sentence t of the form:

t =

^

1im

9x1 : : : 9xk i ^

(5.5)

i^

(5.6)

8x1 : : : 8xk

^

1j r

_

1im

8x1 : : : 8xk (j $ j );

(5.7)

where each of the formulas i and j is quanti er free, and each of the j is of the form Qx1 : : : xs ( 1; : : :; s) for some Q 2 Q and quanti er free formulas 1 ; : : :; s (recall that the quanti ers 9 and 8 are assumed to be in the set Q). Here, (5.5) and (5.6) determine the value of t, i.e., whether it is k or more, or its precise value if it is less than k, and (5.7) depends upon what structures of size t are in each of the quanti ers Qi . We know, from Corollary 5.11 and the discussion which precedes it, that every sentence of Lk (Q) is equivalent, over K to a nite disjunction of sentences t (or to the sentence 9x(:x = x)). Suppose further that each of the quanti ers Q 2 Q is itself polynomial time computable. Since Q is nite, this means that there is a polynomial p, such that each quanti er in Q is computable in time bounded by p. Now, consider the time required to evaluate a sentence of the form t in the structure Kn . To determine the truth of the sentence, we only need to evaluate the matrixes of the formulas (5.5) { (5.7) at exactly one tuple for each basic equality type in Kn . That is, each sub-formula must be evaluated at most k (Kn ) times. As we observed, k (Kn ) is bounded by a value that depends only on k. Thus the entire sentence can be evaluated in time c  p(n), where the value of c may depend on k. This establishes the following lemma:

Lemma 5.14 For a nite set of generalized quanti ers Q, such that each quanti er in Q

is computable in polynomial time, there is a polynomial p, such that all queries expressible in FO(Q) are computable on K in time O(p(n)).

Since k (Kn ) is bounded for all k, we know by Corollary 5.11 that, on K, for any nite set of generalized quanti ers Q, L!1! (Q) collapses to FO(Q). It is a consequence of the Time Hierarchy Theorem (see [Hopcroft and Ullman, 1979]) that there is no polynomial p such that all PTIME queries are computable in time bounded by p. It can easily be veri ed that this remains true in the case of complete structures over any signature  1. 1

For this purpose, complete structures can be encoded as tally integers, for example.

81

Thus, we have established the following theorem, which is due to Hella [Hella, 1993].

Theorem 5.15 For every signature  and any nite set of generalized quanti ers Q, such that every quanti er in Q is a polynomial time computable query, there is a polynomial time property of  -structures that is not expressible in L!1! (Q). If Q contains any quanti er that is not computable in polynomial time, then clearly FO(Q) can express properties that are not in PTIME, because it can trivially express all the quanti ers in Q. Furthermore, since LFP(Q) is contained in L!1! (Q) for all Q, the following corollary follows immediately.

Corollary 5.16 For every signature  and any nite set of generalized quanti ers Q, such that every query over  -structures that is expressible in LFP(Q) is computable in polynomial time, there is a polynomial time computable property of  -structures that is not expressible in LFP(Q).

We observed that there is, for every signature  a single quanti er, P such that LFP(P ) (or even FO(P )) expresses all the PTIME properties of structures of signature . By Corollary 5.16, it immediately follows that FO(P ) also expresses queries that are not in PTIME, and in particular, P itself is not PTIME computable. Now, consider any nite set of quanti ers Q, not all of which are necessarily PTIME computable. Consider only sentences of the form Qx1 : : : xm (1; : : :; m ), where Q 2 Q and all the i are rst-order formulas. That is, we allow only one application of a generalized quanti er in each sentence, and this is the outermost quanti er. We show, below, that there must be polynomial time computable queries that are not expressible by such sentences. This is a result we use in proving Corollary 5.22, in the next section. Let a be an upper bound on the arities of the quanti ers in Q. Thus, any of the rst-order formulas i that occur in sentences of the form described above has at most a free variables. In any complete structure, any such rst-order formula i is equivalent to a disjunction of basic equiality types of a-tuples. Moreover, if k is the total number of distinct variables in i , a straightforward pebble game argument shows that for n1 ; n2  k, i is equivalent to the same disjunction of basic equality types in the structures Kn1 and Kn2 . Thus, if we let n0 be the maximum number of variables that occur in any of the formulas 82

i, then over the class of structures fKn j n  n0 g, Qx1 : : : xm(1; : : :; m) is equivalent to a formula of the form Qx1 : : : xm ( 1; : : :; m), where each of the i is a disjunction of basic

equality types. Since there are only nitely many basic equality types, and only nitely many quanti ers Q, this establishes the following result.

Proposition 5.17 For every nite set of generalized quanti ers, Q, there is a nite collection of sentences f1 ; : : :; t g, such that for each sentence  of FO(Q) of the form Qx1 : : : xm (1; : : :; m), where Q 2 Q and all the i are rst-order, there is an n0 and an i such that on the class of structures fKn j n  n0 g,  is equivalent to i .

This says that, on the class of complete structures, there are eventually nitely many distinct queries of the form Qx1 : : : xm (1 ; : : :; m). But, clearly there are eventually in nitely many distinct queries in PTIME (or in any non-trivial complexity class). Thus, some query in PTIME is not de nable by a sentence of the above form. Since L!1! collapses to rst-order logic on the class of complete graphs, we could weaken the requirement that the formulas i be FO in Proposition 5.17, to require that they be in LFP or L!1! .

5.4 Quanti ers and Reducibilities We now establish some connections between results on generalized quanti ers and the notion of logical reducibilities. By logical reducibilities, we mean reductions between problems that are determined, not by resource-bounds on the computation of the reduction, but by the de nability of the reduction in a logical language. The notion is derived from the idea of interpretations between theories (see, for instance, [Enderton, 1972]), and was used in [Lovasz and Gacs, 1977] and [Immerman, 1987]. The following de nitions are based on those in [Immerman, 1987].

De nition 5.18 Let  and  be two signatures, where  = hR1; : : :; Rri and the arity

of Ri is ni (for 1  i  r) and let L be a logic. An L-interpretation of  in  is a sequence, h8; 1; : : :; r i of formulas of L in the signature  , such that the free variables of 8 are among x1 ; : : :; xk (for some k) and the free variables of i (for each i) are among x1; : : :; xkni . The width of the interpretation is k.

83

An interpretation of  in  , of width k, can be seen as a map,  , from structures over the signature  to structures over  . If A is a structure over  , with universe A, then  (A ) = hB; RB1 ; : : :; RBr i, where B = fa 2 Ak j A j= 8[a]g and for each i, RBi = fa1 : : : ani j a1; : : :; ani 2 B and A j= i[a1 : : : ani ]g. In the rest of this section, we use  both for the interpretation and for the map it de nes when no confusion would result.

De nition 5.19 Given C1 { a class of structures over signature , C2 { a class of struc-

tures over signature  , and  , an L-interpretation of  in  ,  is an L-m-reduction of C1 to C2, if and only if, A 2 C1 , (A ) 2 C2. If such a  exists, we say that C1 is L-m-reducible to C2.

The m in L-m-reduction stands for many-one, and we will use it to distinguish it from a logical notion of Turing reduction that we introduce below. In the case where L is rst order logic, the notion of an L-m-reduction is essentially the same as that of a rst order translation in [Immerman, 1987] or an elementary reduction in [Lovasz and Gacs, 1977]. For an extensive discussion of these reductions in the context of descriptive complexity, the reader may consult [Immerman and Landau, 1993]. Examples of such reductions can be found in [Immerman and Landau, 1993] and [Lindell, 1987].

De nition 5.20 An L-m-reduction, , is a linear reduction if it has width 1. The following straightforward lemma links the notion of linear reduction with generalized quanti ers:

Lemma 5.21 For any class of structures C (over a signature  = hR1; : : :; Rri), there

is a generalized quanti er Q such that every class that is linearly L-m-reducible to C is expressed by a sentence of the form Qx(1; : : :; m ), where the i are formulas of L.

Proof: Let C 0 be the class of structures over the signature hU; R1; : : :; Rri (where U is a

unary relation) such that A 2 C 0, if and only if, the substructure of A generated by the set U A is in C . Then, if  = h8; 1; : : :; r i is a linear L-m-reduction from any class D to C , the sentence QC x(8; 1; : : :; r) expresses D. Recall that a problem A is hard for a complexity class with respect to some kind of reduction, if and only if, every problem in that class is reducible to A. Lemma 5.21, 0

84

Proposition 5.17 and the argument given at the end of the last section allow us to establish the following corollary.

Corollary 5.22 There are no problems that are hard for PTIME with respect to linear

L!1! -m-reductions.

The situation is di erent when we consider reductions that are not linear. Immerman shows in [Immerman, 1987] that there are problems that are complete for PTIME (and for LOGSPACE) via FO-m-reductions in the ordered case. That is, in these constructions, it is assumed that there is a linear order on the domain of every structure, and this order is available as a logical relation for the purpose of de ning the reduction. Lovasz and Gacs [Lovasz and Gacs, 1977] show that SAT is complete for NP via FO-m-reductions, with a weaker requirement on structures than a linear order. They also show that a number of other problems are NP-complete via FO-m-reductions when a linear order is present. We show below (in Corollary 5.30) that there is a problem that is complete for NP via FO-m-reductions, without any requirements on the domain of the structures. We also establish that there are properties that are complete for PTIME and LOGSPACE via FOm-reductions, if and only if, these classes have recursively enumerable index sets. This is done by a general construction linking the existence of complete problems for a complexity class to the existence of a recursive indexing of that class. To establish the link between generalized quanti ers and non-linear reductions, we need the following de nition, which associates with each class of structures, an in nite sequence of generalized quanti ers of unbounded arity. This is a natural extension of the notion of a generalized quanti er associated with a class of structures, which captures a natural notion of reduction, and overcomes the limitations of collections of quanti ers of bounded arity.

De nition 5.23 1. Given a class of structures C (over a signature  = hR1; : : :; Rr i, where the arity of Ri is ni ), for each k 2 ! , let Ck be a class of structures over the signature hUk ; Rk;1; : : :; Rk;ri (where the arity of Uk is k and the arity of Rk;i is k  ni ) such that a structure A is in Ck if and only if the structure with universe UkA and relations

85

R01; : : :; R0r (with arity of R0i being ni ) given by R0i = fha1 : : : ani i j aj = haj;1 : : :aj;k i 2 UkA and ha1;1 : : :ani ;k i 2 RAk;i g is in C . 2. If Qk is the generalized quanti er associated with Ck , we say that the sequence of quanti ers fQk j k 2 ! g is uniformly generated by C . 3. A countable collection of quanti ers, Q, is a uniform sequence if there is a class of structures C , such that Q is uniformly generated by C .

The de nition of uniform sequences of generalized quanti ers is intended to extend the notion of logical many-one reduction to something like a Turing reduction. Thus, for instance if  is an FO-m-reduction of a problem C 0 to C and  has width k, then C 0 can be expressed by a sentence of the form Qk x( ), where Q = fQi j i 2 ! g is the uniform sequence of quanti ers generated by C . It follows that FO(Q) can express all the problems that are FO-m-reducible to C . The notion of extending FO by means of the uniform sequence of quanti ers generated by C , is essentially the same as adding the operator associated with C , as de ned in [Immerman and Landau, 1993] and [Stewart, 1992]. As an example of a uniform sequence of generalized quanti ers, we consider the transitive closure operation, which has been extensively studied in descriptive complexity.

Example 5.24 Let TC be the class of structures over the signature with two binary rela-

tions, hE; T i, such that hA; R1; R2i 2 TC , if and only if, R2 contains a unique pair (a1; a2), and this pair is in the transitive closure of the relation R1 . If TCk is the kth generalized quanti er in the uniform sequence generated by TC, then A j= TCk x( ; 1; 2), if and only if, selects a subset U of jA jk , 2 selects a pair of elements from U that is in the transitive closure of the binary relation on U de ned by 1 . If we let TC = fTCk j k 2 ! g, then FOTC is the extension of FO with the transitive closure operator.

The following de nition is motivated by the view that adding a uniform sequence of generalized quanti ers to a logic is similar to adding the oracle for a problem to a Turing machine. Thus, we can extend the notion of logical reduction from many-one reductions to a counterpart for Turing reductions. This view is further justi ed in Proposition 5.32 below. 86

De nition 5.25 A class of structures C1 is L-T -reducible to a class C2 if C1 is expressible in L(Q), where Q is the sequence of generalized quanti ers uniformly generated by C2. The following lemma is a direct extension of Lemma 5.21.

Lemma 5.26 If C1 is L-m-reducible to C2, then C1 is L-T -reducible to C2. Indeed, we could de ne the notion of a linear L-T -reduction in a fashion analogous to a linear L-m-reduction. Thus, a class of structures is linearly L-T -reducible to C , if it is expressible in L(Q1), where Q1 is the rst quanti er in the uniform sequence generated by C . With this de nition, the following is a corollary to Theorem 5.15.

Corollary 5.27 There is no problem that is complete for PTIME with respect to linear FO-T -reductions.

However, it follows from the discussion in Section 5.3 that there are problems that are hard for PTIME with respect to linear FO-T -reductions. We turn our attention, next, to examining reductions that are not linear. In the next result, we establish a connection between the existence of complete problems for a complexity class and the recursive indexibility of the class. In particular, we show that PTIME is recursively indexable, in the sense of De nition 1.6, if and only if, it contains a problem that is complete for FO-m-reductions. However, this result does not hold for PTIME alone, and it relies on a general encoding technique that works for any complexity class satisfying a certain boundedness condition. This condition is stated in the following de nition.

De nition 5.28 A complexity class C is de ned by a machine model, some resource R

and a family of functions T . A problem is in C if it is recognized by a machine whose use of resource R on inputs of size n is bounded by t(n) for some function t 2 T . We say that C is bounded just in case there is a function s 2 T such that for every t 2 T , there is a k such that t(n) is eventually bounded by s(nk ).

For the purposes of this section, we will assume that the machine model de ning C is a Turing machine and the resource R is either time or space. We will also assume that the function s(n) in this de nition is at least n (for time) and log n (for space). The complexity classes L, NL, P, NP, PSPACE, etc. are all bounded, under this de nition. 87

We are now in a position to establish the following result:

Theorem 5.29 If C is any bounded complexity class that is closed under FO-m-reductions, then the following are equivalent:

1. there is a complete problem for C with respect to FO-m-reductions; 2. there is an index set for C in P; and 3. there is a recursively enumerable index set for C .

Proof: 1 ) 2 Let Q be the C -complete problem and let Q be the sequence of generalized quanti ers uniformly generated by Q. Since C is closed under rst order operations, the sentences of FO(Q) of the form Qi x(1; : : :; r ), where  is rst-order, and Qi 2 Q form an index set for C . This set of sentences is clearly in P. 2 ) 3 is trivial. 3 ) 1 We construct a class of structures Q that is complete for graph problems in C via FO-m-reductions. Since, for any signature  , there is an isomorphism preserving rst order translation from structures over  to graphs (see, for instance, [Lindell, 1987]), this suces. It is easily veri ed that if there is an r.e. index set for a class C , there is a recursive index set. Let I be a recursive index set for C , and let R be the resource de ning C . Since C is bounded, there is a function t such that for each i 2 I , there is an associated ki such that there is a machine recognizing the class determined by i whose use of resource R is bounded by t(nki ). Also, since I is a recursive set, there is a machine M and a recursive function g such that M accepts i 2 I , and whose use of resource R is bounded by g (i). We now de ne the class Q { a class of structures over the signature hV; E; ; I i, where V and I are unary and E and  are binary. A structure A = hA; V; E; ; I i is in Q if and only if: 1.  is a linear pre-order on A; 88

2. if a; b 2 I , a  b and b  a, i.e., I picks out one equivalence class from the pre-order (say the ith); 3. i is in I ; 4. jAj  jV jki ; 5. the graph hV; E i is in the class determined by i; and 6. g (i)  t(jAj). We verify that Q is in C . On input A , conditions 1, 2 and 4 are easily checked (in O(log n) space). Condition 3 is checked by running M on input i. If the machine exceeds resource bounds t(jAj), it is halted and the input is rejected, since it violates condition 6. Finally, we check condition 5, which by virtue of condition 4 and the de nition of ki can be done in resource bound t(jAj). Next, we verify that Q is complete for C . Let Pi be the class in C determined by i and let k0 be a natural number such that there are at least i distinct basic equality types of k0 -tuples. There are only nitely many structures in Pi of size at most max(k0; g(i)). Since each nite structure is determined up to isomorphism by a rst order sentence, we can write a rst order formula that picks out exactly these structures and maps them to a selected structure in Q. For larger structures, we de ne the translation as follows: let k = max(k0; ki). A graph hV; E i is mapped to hV k ; V 0 ; E 0; ; I i, where V 0 = fhv : : :vi j v 2 V g, E 0 is the natural extension of E to V 0,  is an arbitrary ordering of the basic equality types of k-tuples from V (this is rst order de nable, since there are only nitely many such types), and I picks out the ith type in this ordering. It is easily veri ed that all of these are rst order de nable. The reductions that are constructed in the proof of 3 ) 1, above, are of fairly low complexity. Indeed, Theorem 5.29 remains true even if we replace the notion of FO-mreduction with the weaker notion of a projection translation as de ned in [Immerman, 1987]. Since Fagin's characterization of the class NP as the properties expressible in 11 (Theorem 1.1) yields a recursive index set for this class, the following corollary is a consequence of Theorem 5.29. 89

Corollary 5.30 There is a class of structures that is complete for NP with respect to FO-m-reductions.

On the other hand, for complexity classes for which it is unknown whether there is a recursive index set, Theorem 5.29 gives us necessary and sucient conditions for the existence of such a set. In particular, for a class such as PTIME, if there is any recursively indexable collection of generalized quanti ers, which can be added to FO (or LFP) to yield a logic that expresses exactly the queries in PTIME, then such a logic clearly yields a recursive indexing of PTIME, and there must be a problem that is complete for this class. Thus, while we showed, in Section 5.3 that no nite set of generalized quanti ers would suce, Theorem 5.29 shows that if there is any set that does, there is one that satis es the uniformity conditions of De nition 5.23. This can be stated as the following corollary.

Corollary 5.31 There is a recursively indexable collection of generalized quanti ers Q in PTIME (resp. LOGSPACE, NLOGSPACE) such that FO(Q) captures PTIME (resp.

LOGSPACE, NLOGSPACE), if and only if, there is a uniform sequence of generalized quanti ers with this property.

It also follows that each of these complexity classes has a recursive indexing, if and only if, it has a complete problem with respect to rst order reductions. This shows that there is a close connection between recursive indexings and complete problems. Such a connection has been observed earlier, at least in one direction in the case of regular complexity classes (on strings), such as NP \ co-NP for which there is no known complete problem (see [Hartmanis et al., 1986]). We noted above that, intuitively, generalized quanti ers play a role similar to that of oracles. This can be made precise in the cases where a logic is known to correspond exactly to a natural complexity class. Thus, in particular, the proofs of the equivalences established in [Fagin, 1974; Immerman, 1986; Vardi, 1982] (see Theorems 1.1 and 1.4) can be easily modi ed for the case of oracle machines and generalized quanti ers. This is stated in the following result.

Proposition 5.32 If A is a language encoding a class of structures C , and Q is the

sequence of quanti ers uniformly generated by C , then:

90

1. NPA = 11(Q); and 2. on ordered structures PA = LFP(Q):

Note that, in order to de ne the logic LFP(Q), we need to de ne the positive occurrences of a relation symbol R in a formula of this logic. For the purposes of the proposition above, it suces if we consider all ocuurrences of R that are within the scope of a generalized quanti er (other than the usual rst order quanti ers) to be negative.

91

Chapter 6

Conclusions and Future Work In Chapter 1, we identi ed two directions to be explored in the area of descriptive characterizations of feasible computation. The rst of these is to characterize the expressive power of least- xed-point logic and other inductive logics in the context of arbitrary nite relational structures. The second is to study extensions of least- xed-point logic that might yield a characterization of PTIME over such structures. In this thesis, we have shown that many of the tools of classical model theory, suitably adapted to the context of nite relational structures, can serve as a foundation for research in both of the above directions. An important part of the adaptation of these tools consists in considering restricted versions obtained by bounding the number of variables used in each formula. In particular, several fundamental concepts of model theory, such as the notions of elementary equivalence and element types which, by themselves, are trivial in the context of nite structures yield interesting variants when the number of variables is bounded. This opens the way for the construction of a richer model theory of nite structures. What makes this particularly interesting, from the point of view of descriptive complexity theory, is that the notions of bounded variable element type and the in nitary logic L!1! form a basis for analyzing the expressive power of inductive logics, and in particular the least- xed-point logic, LFP. We showed, in Chapter 3, that an analysis of the inductive logics, LFP and PFP, in terms of bounded variable element types can be used to characterize the relationship between these two logics. In Chapter 4, we showed that such an 92

analysis also gives us insight into the expressive power of LFP on arbitrary classes of nite structures. In the other direction, i.e., that of examining extensions of LFP that might provide a descriptive characterization of the PTIME computable properties of all nite relational structures, we also showed that the tools developed in Chapter 2, suitably extended to logics that include generalized quanti ers, can be extremely useful. We used such techniques to establish, in Chapter 5 that no extension of LFP by means of nitely many generalized quanti ers would suce for a logical characterization of the PTIME computable properties, even for classes of structures over a xed signature. Moreover, we showed that if there is any descriptive characterization of the PTIME properties, indeed, if the class of PTIME properties is recursively indexable, then it is characterized by an extension of rst-order logic by means of a uniform sequence of generalized quanti ers. In doing this, we showed that the existence of a recursive indexing of the PTIME properties is linked to the existence of a complete problem for this class with respect to rst-order reductions. The work reported in this thesis, of course, leaves open many questions along the directions mentioned at the beginning of this chapter. At the same time, it opens research avenues and raises several new questions. An investigation of these questions might well provide greater insight into the problem of providing descriptive characterizations of feasible computation, as well as further enhancing the tool kit of nite model theory. In the remainder of this chapter, we outline some of the most important questions that are raised by the work reported in the preceding chapters.

6.1 Lk Canonical Structures In one of the results in Section 3.4, we showed that the class of queries expressible in LFP is properly contained in the class L!1! \ PTIME (see Corollary 3.25). This raises the question of whether the properties in the class L!1! \ PTIME are recursively indexable. Can we enumerate a set of polynomial-time Turing machines, for instance, each of which accepts a property in this class and such that every property in the class is accepted by some machine in the set. We know that the class LFP is recursively indexable, since there 93

is an e ective way to construct, from a sentence of LFP, a machine that accepts all models of the sentence. On the other hand, it is not known if the class PTIME, of polynomial time computable queries, is recursively indexable. We argued, in Section 1.4, that a polynomial time canonical labeling algorithm would yield a recursive indexing of PTIME. A similar situation holds with respect to the class L!1! \ PTIME. Suppose we have a Turing machine Ck , for every k 2 N, which computes a function Fk of the input with the property that Fk (A ) k A and if A k B then Fk (A ) = Fk (B ). We say that Ck computes an Lk canonical structure or an Lk -canon of its input. Suppose further that each of the Ck computes in polynomial time. If this is indeed the case, then the class L!1! \ PTIME is recursively indexable. To see this, consider an enumeration Mi (i 2 !) of clocked polynomial time Turing machines. We can then enumerate all machines of the form Ck ! Mi , which accepts input A , if and only if, Mi accepts Fk (A ). This is an indexing of the class L!1! \ PTIME. This situation is somewhat more promising than the problem of canonically labeling structures. For the latter case, even the problem of testing the equivalence relation in question, i.e., the structure isomorphism problem, is not known to be in polynomial time. We can, however, test the equivalence of two structures under the relation k in polynomial time. We can do this by computing the map Ek (de ned in Section 3.3) on the two structures and comparing the result. We show below that Ek (A ) and Ek (B ) are isomorphic just in case A k B . Because Ek (A ) and Ek (B ) are ordered structures, if they are isomorphic, they are represented by identical bit-strings, by the encoding discussed in Section 1.2. Thus, the function Ek computes an invariant of structures, under the equivalence relation k . In general, however, for arbitrary equivalence relations on structures, a polynomial time computable invariant does not necessarily yield a polynomial time computable canonical member (see [Blass and Gurevich, 1984]). We now give the proof that the map Ek does indeed compute an Lk -invariant structure and that this computation can be done in polynomial time.

Theorem 6.1 For any two structures A and B , A k B if and only if Ek(A ) = Ek (B ) Proof: ) If A k B then every Lk -type that is realized in A is realized in B and vice versa. 94

To see this, let a be a k-tuple from A . Recall from Corollary 2.18 that there is a formula (x1 : : :xk ) in Lk with k free variables that expresses this type. But then, A j= 9x1 : : :xk  and therefore B j= 9x1 : : :xk . This tells us that the structures Ek (A ) and Ek (B ) have the same size. Let f be the order-preserving map from Ek (A ) to Ek (B ). If f ([a]) = [b], then a and b have the same Lk -type. This is because the de nition of the ordering relation