Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
List of first-order theories wikipedia , lookup
Propositional calculus wikipedia , lookup
New riddle of induction wikipedia , lookup
Non-standard analysis wikipedia , lookup
Model theory wikipedia , lookup
First-order logic wikipedia , lookup
Halting problem wikipedia , lookup
Interpretation (logic) wikipedia , lookup
Chapter 2 Finite-variable fragments of first-order logic We explained in Chapter 1 that the counting quantifiers are of interest primarily in terms of their computational effect on certain decidable fragments of first-order logic. The purpose of this chapter is to lay the groundwork for our investigation of counting quantifiers by introducing some of these fragments. For k > 1, the k-variable fragment of first-order logic with equality, denoted Lk≈ , is the set of first-order formulas over a purely relational signature involving no variables other than x1 , . . . , xk . The k-variable fragment of first-order logic (without equality), denoted Lk , is the set Lk≈ -formulas not involving the equality predicate ≈. For ease of reading, we write x, y, z instead of x1 , x2 , x3 . 2.1 Fragments with one variable We begin with the 1-variable fragments L1 and L1≈ , whose treatment is nearly trivial. Since we are working with a purely relational signature (no individual constants of function-symbols), the only equality atom in L1≈ is x ≈ x, which may be equivalently replaced by ⊤. Therefore, we consider only L1 . In fact, we may as well assume that all predicates have arity 0 or 1, since predicates of higher arity evidently do not essentially increase expressive power in L1 . For the remainder this section, then, we assume a signature of nullary and unary predicates only. Lemma 2.1. Let ϕ be an L1 -formula. We can construct, in time bounded by a polynomial function of kϕk, an L1 -formula ^ ∃xβh , (2.1) ψ := ∀xα ∧ 1≤h≤m where 1 ≤ m ≤ kϕk, and α, β1 , . . . , βm are quantifier-free L1 -formulas, such that ϕ and ψ are satisfiable over the same domains. 9 10 CHAPTER 2. FINITE-VARIABLE FRAGMENTS Proof. By prefixing an existential quantifier if necessary, we may assume that ϕ is a sentence. Set ϕ0 := ∀xϕ. If ϕ0 has a subformula θ = ∃xχ, with χ quantifier-free, let p be a new nullary predicate, let ϕ1 = ϕ[p/θ], and let ψ1 = ∃x(p → χ) ∧ ∀x(χ → p). It is easy to see that ϕ0 and ϕ1 ∧ ψ1 are satisfiable over the same domains. For, on the one hand, ϕ1 ∧ ψ1 entails ϕ0 , and on the other, any model A of ϕ0 may be expanded to a model of ϕ1 ∧ ψ1 by interpreting p to be true if and only if A |= θ. Similarly, if ϕ0 has a proper subformula θ = ∀xχ, with χ quantifier-free, define ϕ1 and ψ1 analogously, subject to the obvious adjustments. Now process ϕ1 in the same way, and continue until some formula ϕm is reached having the form ∀xχ, with χ quantifier-free. Thus, ϕ0 and ϕm ∧ ψm ∧ ψm−1 ∧ · · · ∧ ψ1 are satisfied over the same domains. Re-arrangement of conjuncts yields the desired formula ψ. Lemma 2.2. Let ϕ be a formula in L1 . If ϕ is satisfiable, then it is satisfiable over a domain of size at most kϕk. Proof. By Lemma 2.1, we may assume ϕ to be of the form (2.1). If A |= ϕ, let a1 , . . . am ∈ A be witnesses for the respective conjuncts ∃xβh . Let B be the restriction of A to {a1 , . . . , am }. It is then obvious that B |= ϕ. Theorem 2.1. The problem Sat-L1 is NP-complete. Proof. Membership in NP follows from Lemma 2.2. NP-hardness is immediate, since L1 includes propositional logic. We remark that allowing individual constants to appear in the fragment has no effect on the above results (though it clutters the exposition); the details are routine and left to the reader. Consider the sub-fragment S of L1 consisting of all formulas having the following forms ∃x(p(x) ∧ q(x)) ∀x(p(x) → q(x)) ∃x(p(x) ∧ ¬q(x)) ∀x(p(x) → ¬q(x)), (2.2) where p and q are unary predicates. This fragment is of some historical and linguistic interest, because we can think of unary predicates as corresponding to common nouns, and the formulas (2.2) to English sentences of the forms Some p is a q Every p is a q Some p is not a q No p is a q, (2.3) respectively. This is, in essence, the language of the syllogistic set out in Aristotle’s Prior analytics. Inspection of the above forms shows that, if ϕ is an 2.2. FRAGMENTS WITH TWO VARIABLES 11 S-formula, then there is an S-formula ϕ̄ logically equivalent to its negation. Thus, validity and satisfiability are dual in S in the usual way: an argument with premises Φ and conclusion ϕ is valid if and only if the set ϕ ∪ {ϕ̄} is not satisfiable. Note, however that S is not closed under conjunction. (Thus, it is generally only interesting to consider the satisfiability of sets of S-formulas.) Theorem 2.2. The satisfiability problem for S is in PTIME. Proof. Let a finite set Φ of L-formulas be given, and let Γ be the result of Skolemizing Φ and converting to clause form. The clauses in Γ all have the forms ±p(c) or ¬p(x) ∨ ±q(x), where c is a (Skolem) constant, and p, q are unary predicates appearing in Φ. Applying resolution theorem-proving to such clauses yields only more clauses of this form, whose number is evidently bounded by 2kΦk2 . Thus, after at most quadratically many steps, either a contradiction is found (Φ is satisfiable) or saturation is reached (Φ is unsatisfiable). Adding individual constants to S makes no difference to Theorem 2.2, a detail we leave to the reader to verify. Adding counting quantifiers, by contrast, does make a difference, and we consider this matter in Chapter 2. 2.2 Fragments with two variables In this section, we show that the fragments L2 and L2≈ have the finite model property, and that their satisfiability (= finite satisfiability) problems are NEXPTIME-complete. In dealing with these fragments, we may as well assume that all predicates have arity at most 2, since predicates of higher arity evidently do not essentially increase expressive power in L2 . For the remainder of this section, then, we assume a signature of nullary, unary and binary predicates only. Lemma 2.3 (Scott normal form). Let ϕ be a formula in L2≈ . We can construct, in time bounded by a polynomial function of kϕk, an L2 -formula ^ ∀x∃y(βh (x, y) ∧ x 6≈ y), (2.4) ψ := ∀x∀y(α ∨ x ≈ y) ∧ 1≤h≤m where 1 ≤ m ≤ kϕk, and α, β1 , . . . , βm are quantifier-free L2 -formulas, such that ϕ and ψ are satisfiable over the same domains containing at least 2 elements. Proof. We proceed as for Lemma 2.1. By prefixing existential quantifiers if necessary, we may assume that ϕ is a sentence. Set ϕ0 := ∀xϕ. In the sequel, let u, v be the variables x, y, in either order. Suppose ϕ0 has a subformula θ(v) = ∃uχ, with χ quantifier-free. Let p be a new unary predicate, let ϕ1 be ϕ[p(v)/θ(v)], and let ψ1 := ∀v∃u(p(v) → χ) ∧ ∀v∀u(χ → p(v)). It is easy to see that ϕ0 and ϕ1 ∧ ψ1 are satisfiable over the same domains. For, on the one hand, ϕ1 ∧ ψ1 entails ϕ0 , and on the other, any model A of ϕ0 12 CHAPTER 2. FINITE-VARIABLE FRAGMENTS may be expanded to a model of ϕ1 ∧ ψ1 by interpreting p to be satisfied by an element a ∈ A if and only if A |= θ[a]. Similarly, if ϕ0 has a proper subformula θ(v) = ∀xχ, with χ quantifier-free, define ϕ1 and ψ1 analogously, subject to the obvious adjustments. Now process ϕ1 in the same way, and continue until some formula ϕm is reached having the form ∀xp(x)—which we may re-write as ∀x∀yp(x). Thus, ϕ0 and ϕm ∧ ψm ∧ ψm−1 ∧ · · · ∧ ψ1 are satisfied over the same domains. Re-arrangement of conjuncts yields a formula ^ ψ ′ := ∀x∀yα′ (x, y) ∧ ∀x∃y(βh′ (x, y)), 1≤h≤m ′ βh′ (x, y) are quantifier-free L2≈ -formulas. where α (x, y) and the It remains only to reform the occurrences of ≈ in α′ (x, y) and the βh′ (x, y). Restricting attention to domains containing at least 2 elements, we have the following logical equivalences: ∀x∀yα′ (x, y) ≡ ∀x∀y((α′ (x, x) ∧ α′ (x, y)) ∨ x ≈ y) ∀x∃yβh′ (x, y) ≡ ∀x∃y((βh′ (x, x) ∨ βh′ (x, y)) ∧ x 6≈ y). Now, if θ is any L2≈ -formula, denote by θ∗ the result of replacing all atoms of the forms x ≈ x and y ≈ y in θ by ⊤, and all atoms of the forms x ≈ y and y ≈ x by ⊥. Thus, we have the logical equivalences θ ∨ x ≈ y ≡ θ∗ ∨ x ≈ y θ ∧ x 6≈ y ≡ θ∗ ∧ x 6≈ y. Setting ∗ α := α′ (x, y) ∧ α′ (x, x) ∗ βh := βh′ (x, y) ∨ βh′ (x, x) , for all h (1 ≤ h ≤ m), and then ψ := ∀x∀y(α(x, y) ∨ x ≈ y) ∧ ^ ∀x∃y(βh (x, y) ∧ x 6≈ y), 1≤h≤m we see that ψ and ψ ′ are logically equivalent over domains containing at least 2 elements. Thus, ψ has the properties required for the lemma. At this point, we introduce some familiar concepts which will feature prominently in the sequel. Fix some purely relational signature Σ. A literal (over Σ) is an atomic formula or the negation of an atomic formula. A 1-type (over Σ) is a maximal consistent set of equality-free literals over Σ involving only the variable x. A 2-type (over Σ) is a maximal consistent set of equality-free literals over Σ involving only the variables x and y. Reference to Σ is suppressed where clear from context. If A is any structure interpreting Σ, and a ∈ A, then there 2.2. FRAGMENTS WITH TWO VARIABLES 13 exists a unique 1-type π(x) over Σ such that A |= π[a]; we denote π by tpA [a]. If, in addition, b ∈ A is distinct from a, then there exists a unique 2-type τ (x, y) over Σ such that A |= τ [a, b]; we denote τ by tpA [a, b]. We do not define tpA [a, b] if a = b. If π is a 1-type, we say that π is realized in A if there exists a ∈ A with tpA [a] = π. If τ is a 2-type, we say that τ is realized in A if there exist distinct a, b ∈ A with tpA [a, b] = τ . Notation 1. Let τ be a 2-type over a purely relational signature Σ. The result of transposing the variables x and y in τ is also a 2-type, denoted τ −1 ; the set of literals in τ not featuring the variable y is a 1-type, denoted tp1 (τ ); likewise, the set of literals in τ not featuring the variable x is also a 1-type, denoted tp2 (τ ). Remark 2.1. If τ is any 2-type over a purely relational signature Σ, then tp2 (τ ) = tp1 (τ −1 ). If A is a structure interpreting Σ, and a, b are distinct elements of A such that tpA [a, b] = τ , then tpA [b, a] = τ −1 , tpA [a] = tp1 (τ ) and tpA [b] = tp2 (τ ). A terminological note: in books on model theory, the word “type” is standardly used to refer to a maximal consistent set of formulas (over some signature) featuring a fixed collection of variables—including formulas involving quantifiers. What we are calling types here are known, in that nomenclature, as “rank-0 types”. In the sequel, however, we only ever have occasion to refer to rank-0 types, and so we continue to use the more abbreviated terminology. Remark 2.2. If Σ features only unary and binary predicates, and |Σ| = s, then there are exactly 2s 1-types over Σ and at most 24s 2-types. Lemma 2.4. Let ϕ be a satisfiable L2≈ -formula, and let n = kϕk. Then ϕ has a model of size at most 3n.2n . Proof. If ϕ is satisfiable over a 1-element domain, there is nothing to prove. Moreover, we may assume without loss of generality that the signature of ϕ features only unary and binary predicates, since any nullary predicates can be replaced by ⊤ or ⊥ according to their truth-value in some model. Now let ψ be the formula (2.4) constructed in Lemma 2.3, and suppose A |= ψ. Let the signature of ψ be Σ∗ ; thus m ≤ n and |Σ∗ | ≤ n. It suffices to construct a model B of ψ with |B| ≤ 3n.2n . In the rest of the proof, we employ the symbols α, m β1 , . . . , βm as they appear in (2.4). If a ∈ A, we say that a is a king if a is the only element a′ ∈ A such that tpA [a′ ] = tpA [a]. Let K be the set of kings. Evidently, |K| ≤ 2n . We now define a set of elements C ⊆ A, called the court, as follows: every king is a member of court; and, for each king a, and every h (1 ≤ h ≤ m), we select one element b ∈ A \ {a} such that A |= βh [a, b], and let b be a member of court. (These elements need not be distinct, and may themselves be kings.) Evidently, |C| ≤ (m + 1)K. Let C be the structure on C induced by A. Notice that, for any element a ∈ A, and any h (1 ≤ h ≤ m), there exists an element b ∈ A \ {a} (depending on a and h) such that A |= βh [a, b]. As we might say, b satisfies the ‘existential requirement’ ∃y(βh (x, y) ∧ x 6≈ y) of a. 14 CHAPTER 2. FINITE-VARIABLE FRAGMENTS t A A A AU t t t K C a b t * XXXX XXX XX zt X t hi, j, 0i hi, j, 1i hi, j, 2i D Figure 2.1: The small model property for L2≈ , showing the absence of clashes in Stage 3 of the proof of Lemma 2.4 Let π1 , . . . , πL be the 1-types realized in A by more than one element (i.e. realized in A, but not by kings). Evidently, L ≤ 2n − K. Let D be the set of integer triples {hi, h, ki|1 ≤ i ≤ L, 1 ≤ h ≤ m and 0 ≤ k ≤ 2}, and assume without loss of generality that C and D are disjoint. Now let B = C ∪ D. Hence |B| ≤ (m + 1)K + 3m(2n − K) ≤ 3n2n . We define a structure on B satisfying ψ. In defining this structure (Fig. 2.1), we ensure that all the existential requirements of successive elements of B are satisfied. We proceed in three stages. Stage 1: Import the structure C onto the elements C ⊆ B (so that A and B agree on the court). Consider any king a; and let 1 ≤ h ≤ m. By construction of C, there exists b ∈ C \ {a} such that A |= βh [a, b], whence B |= βh [a, b]. Thus, all kings have their existential requirements satisfied. Stage 2: First, fix the 1-type of any element hi, h, ki ∈ D by setting tpB [hi, h, ki] = πi . Now consider any a ∈ C which is not a king, and any h such that 1 ≤ h ≤ m. Choose some b ∈ A \ {a} such that A |= βh [a, b]. If b is a king, then tpB [a, b] = 2.2. FRAGMENTS WITH TWO VARIABLES 15 tpA [a, b] from Stage 1, so that we already have B |= βh [a, b]. If b is not a king, then its 1-type is πi for some i (1 ≤ i ≤ L), so let b′ = hi, h, 0i ∈ D, and set tpB [a, b′ ] = tpA [a, b]. Since tpA [b] = πi = tpB [b′ ], there is no clash with any of the 1-types already assigned to elements of B; hence this assignment is legitimate. Proceeding in this way, we can satisfy the existential requirements of all the elements in C. Stage 3: Consider any a = hi, h, ki ∈ D, and any h such that 1 ≤ h ≤ m. Let a′ ∈ A be such that tpA [a′ ] = πi , and pick b′ ∈ A \ {a} such that A |= βh [a′ , b′ ]. If b′ is a king, let b = b′ ; otherwise, let i′ be such that tpA [b′ ] = πi′ , and let b = hi′ , h, k + 1i. Set tpB [a, b] = tpA [a′ , b′ ] (we show presently that we are free to do this). Proceeding in this way, we can satisfy the existential requirements for all a ∈ D. It is immediate that the 2-type assignments made in this stage cannot clash with any previously assigned 1-types. However, we must show that the assignment to tpB [a, b] described above made in this Stage cannot clash with any previously-made assignment to tpB [b, a]. To see that this is so, suppose first that b′ is a king. Then b = b′ , and any previous assignment to tpB [b, a] must have occurred in Stage 1. But that is impossible, because, in Stage 1 kings had their 2-types fixed only only with respect to other members of court. Suppose, on the other hand, that b′ is not a king, so that b ∈ D, and any previous assignment to tpB [b, a] must have occurred in Stage 3. Writing a = hi1 , h1 , k1 i and b = hi2 , h2 , k2 i, we then have k2 = k1 + 1 mod 3 and k1 = k2 + 1 mod 3, which is impossible (see Fig 2.1, where k1 = 0). Hence, none of the 2-type assignments made in Stage 3 clashes with any other. Stage 4: To complete the definition of B, suppose tpB [a, b] was not assigned in any of the Stages 1–3. Certainly, then, a and b cannot both be kings; in particular, if tpB [a] = tpB [b], it follows that this common 1-type is realized more than once in A. Therefore, we can always find distinct elements a′ , b′ of A such that tpB [a] = tpA [a′ ] and tpB [b] = tpA [b′ ]. Now make the 2-type assignment tpB [a, b] = tpA [a′ , b′ ]. This obviously does not clash with any previously-made 1-type assignments, and completes the definition of B. Since all existential requirements are satisfied following Stages 1–3, we have ^ ∀x∃y(βh (x, y) ∧ x 6≈ y). B |= 1≤h≤m And since all 2-types realized in B are also realized in A, we have B |= ∀x∀y(α ∨ x ≈ y). Corollary 2.1. The problem Sat-L2≈ (=Fin-Sat-L2≈ ) is in NEXPTIME. We now establish a lower bound to match Corollary 2.1. We employ the apparatus of bounded tiling problems. 16 CHAPTER 2. FINITE-VARIABLE FRAGMENTS A tiling system is a triple T = (C, H, V ), where C is a finite set, and H, V are binary relations over C. We call the elements of C colours, and we call H and V the horizontal constraints and the vertical constraints, respectively. A tiling of size N is a function t : N2N → C such that: (i) for all i, j (1 ≤ i < f (n), 1 ≤ j ≤ f (n)), ht(i, j), t(i + 1, j)i ∈ H, (ii) for all i, j (1 ≤ i ≤ f (n), 1 ≤ j < f (n)), ht(i, j), t(i, j +1)i ∈ V . (Here + denotes addition modulo N .) Intuitively, the elements of C represent types of unit square tile which must be arranged so as to fill an N × N -grid: the pairs in H list which colours can go immediately to the ‘right’ of which others; the pairs in V list which colours can go immediately ‘above’ which others. If t is an N -tiling and 0 ≤ n < N, we say that the sequence t(0, 0), . . . t(n−1, 0) of elements of C is an initial segment of t. Given any Turing machine M over a (finite) alphabet A, it is straightforward to construct a tiling system, TM = (C, H, V ), together with a mapping eM : A → C such that, for all N , M halts with output 1 in time at most N on input a0 , . . . , an−1 if and only if TM has a tiling of size N with initial segment eM (a0 ), . . . , eM (an−1 ). Roughly speaking, the tiling in question is a ‘movie’ of the (first N squares of the) Turing machine’s tape, over the first N time steps. By a bounded tiling problem, we understand a quadruple P = (C, H, V, f ), where (C, H, V ) is a tiling system and f : N → N a function, regarded as a problem over the alphabet C as follows: an instance c0 , . . . cn of P counts as positive just in case (C, H, V ) has a tiling of size f (n) with intial segment c0 , . . . cn . Now let F be a set of functions from N to itself, and suppose there exists a problem P which is complete for the class N(F )TIME. Thus, there exists a Turing machine M which nondeterministically solves P, and a function f ∈ F such that any run of M on an input a0 , . . . , an−1 terminates in time f (n). Constructing TM and eM as just described, we have that a0 , . . . , an−1 is a positive instance of P if and only if eM (a0 ), . . . , e(an−1 ) has a TM -tiling of size f (n). Hence: Theorem 2.3. Let F be a set of functions from N to itself such that there exists a problem P which is complete for N(F )TIME. There exists a tiling system (C, H, V ) and a function f ∈ F such that the bounded tiling problem (C, H, V, f ) is also complete for N(F )TIME. To show that a problem P is N(F )TIME-complete (under polynomial reduction), it therefore suffices to find, for any tiling system T = (C, V, T ), and any f ∈ F , a mapping gT from instances c of T to instances of P, such that (i) c is a positive instance of the bounded tiling problem T = (C, H, V, f ) if and only if gT (c) is a positive instance of P; and (ii) gT can be computed in time bounded by a polynomial function of the size of c. Lemma 2.5. The problem Sat-L2 is NEXPTIME-hard. Proof. Fix some tiling system problem T = (C, H, V, 2p(x) ), where p(x) is a polynomial. Let c = c0 , . . . , cn−1 be any instance of T . We construct a formula ϕc of L2Mon such that ϕc is satisfiable if and only if c is a positive instance of T . The construction proceeds in time bounded by some polynomial function of n. 2.2. FRAGMENTS WITH TWO VARIABLES 17 Before we give the construction in detail, recall the procedure for incrementing a binary numeral with digits dn−1 , . . . , d0 (d0 is least significant). Assuming that not all the digits are 1, the incremented numeral is given by dn−1 , . . . , di+1 , 1, 0, . . . , 0, where i is the greatest number such that the digits dj with j < i are all 1. To motivate the definition of ϕc , we first assume that c = c0 , . . . cn−1 is a positive instance of the tiling problem (C, H, V, 2p(n) ), with tiling t : (N2p(n) )2 → C. We simultaneously build the formula ϕc and a model A. Let N = 2p(n) , and let A = {hs, ti | 0 ≤ s < N, 0 ≤ t < N }. Think of the elements of A as positions on an N × N grid which wraps around in both dimensions to form a torus. We treat the elements of C as unary predicates interpreted in A in the obvious way: cA = {a ∈ A | t(a) = c} for all c ∈ C. We further interpret the additonal unary predicates ∗ ∗ X0 , . . . , Xp(n)−1 , Y0 , . . . , Yp(n)−1 , X0∗ , . . . , Xp(n) , Y0∗ , . . . , Yp(n) as follows. Set XiA YiA = {hs, ti | the ith digit in the binary representation of s is 1} = {hs, ti | the ith digit in the binary representation of t is 1} for all i (0 ≤ i < p(n)). And interpret the predicates Xi∗ and Yi∗ in the structure A in such a way as to ensure the truth of the formulas V V ∗ ∀x Xi∗ (x) ↔ ¬Xi (x) ∧ 0≤j<i Xj (x) ∀x Xp(n) (x) ↔ 0≤j<p(n) Xj (x) V V ∗ ∀x Yi∗ (x) ↔ ¬Yi (x) ∧ 0≤j<i Yj (x) ∀x Yp(n) (x) ↔ 0≤j<p(n) Yj (x) for all i (1 ≤ i < p(n)). Thus A |= Xi∗ [a] if and only if i is the largest number such that all the digits of the first coordinate of a before the ith are 1; similarly for Yi∗ . Now define ^ α1 (x, y) := (Xi∗ (x) → ¬Xj (y))∧ 0≤j<i≤p(n) ^ (Xi∗ (x) → Xi (y))∧ 0≤i<p(n) ^ (Xi∗ (x) → (Xj (x) ↔ ¬Xj (y))); 0≤i<j≤p(n) and define α2 (x, y) similarly, but with “X” replaced throughout by “Y ”. Thus, A |= α1 [a, b] if and only if the first coordinate of b is 1 greater (modulo 2p(n) ) 18 CHAPTER 2. FINITE-VARIABLE FRAGMENTS than the first cordinate of a; and similarly for α2 . In addition, define ^ (Xi (x) ↔ ¬Xi (y)) β1 (x, y) := 0≤i<p(n) β2 (x, y) ^ := (Yi (x) ↔ ¬Yi (y)) 0≤i<p(n) Thus, A |= β1 [a, b] if and only if a and b have the same first-coordinate; and similarly for β2 . Finally, define η(x, y) ν(x, y) := := α1 (x, y) ∧ β2 (x, y) α2 (x, y) ∧ β1 (x, y). Thus, A |= η[s, t] if and only if t is immediately to the right of s in the grid, and A |= ν[s, t] if and only if t is immediately above s in the grid, remembering that the grid in question is toroidal. Since the tiling t is a function from A to C, the following formula is true in A: ^ _ c(x) ∧ ∀x (2.5) ¬(c(x) ∧ c′ (x)). ∀x c∈C c∈C;c6=c′ Since t has initial segment c, the following formula is true in A: ∃x(c0 (x) ∧ (¬X0 (x) ∧ · · · ∧ ¬Xp(n) (x)) ∧ (¬Y0 (x) ∧ · · · ∧ ¬Yp(n) (x))∧ ∃x(c1 (x) ∧ (X0 (x) ∧ · · · ∧ ¬Xp(n) (x)) ∧ (¬Y0 (x) ∧ · · · ∧ ¬Yp(n) (x))∧ (2.6) .. ., where the conjuncts in the ith line (1 ≤ i ≤ n) specify that the grid position hi, 0i is assigned colour ci by the tiling t. From the construction of η and ν, the following formulas are true in A: ∀x∃yη(x, y) (2.7) ∀x∃yν(x, y). (2.8) Moreover, since t respects the constraints H and V , the following formulas are also true in A: ^ ∀x∀y(η(x, y) ∧ c(x) → ¬c′ (y)) (2.9) hc,c′ i6∈H ^ ∀x∀y(ν(x, y) ∧ c(x) → ¬c′ (y)). (2.10) hc,c′ i6∈V Let ϕc be the conjunction of the formulas in (2.5)–(2.10). Thus, if c has a tiling, ϕc has a model. It is easy to check that ϕc depends only on c (and not on the tiling t), and can be constructed from ϕ in polynomial time. 2.3. FRAGMENTS WITH THREE OR MORE VARIABLES 19 Conversely, suppose that ϕc has a model, A. Pick an element a0,0 which is a witness for x in (2.6), and pick a1,0 , . . . , aN −1,0 such that, for all i (0 ≤ i < N ), ai+1,0 is a witnesses for y in (2.7) when x takes the value ai,0 . Similarly, for all i (0 ≤ i < N ), pick ai,1 , . . . , ai,N −1 such that ai,j+1 is a witnesses for y in (2.8) when x takes the value ai,j . It is obvious that the elements ai,j form an N × N grid with toroidal wrap-around under the relations defined by the formulas η and ν. By Formula (2.5), for each such ai,j satisfies exactly one predicate c, and so we can define the function t : (NN )2 → C is by setting t(i, j) to be the c such that A |= c[ai,j ]. Formula (2.6) guarantees that c is an initial segment of t. Formulas (2.9) and (2.10) guarantee that t respects the constraints H and V . Hence c is a positive instance of (C, H, V, 2p(n) ). This completes the reduction. Theorem 2.4. The satisfiability problem for any logic lying between L2Mon and L2≈ is NEXPTIME-complete. Proof. The upper bounds follow from Lemma 2.4. The lower bounds follow from Lemma 2.5. 2.3 Fragments with three or more variables In this section, we show that the fragment L3 is undecidable. Let (C, H, V ) be a tiling system. An unbounded tiling is a function t : N2 → C such that: (i) for all i, j ∈ N, ht(i, j), t(i + 1, j)i ∈ H, (ii) for all i, j ∈ N, ht(i, j), t(i, j + 1)i ∈ V . (Here + denotes ordinary integer addition.) As with tilings of finite size, if n ∈ N, we say that the sequence of C-elements t(0, 0), . . . t(n − 1, 0) is an initial segment of t. By an unbounded tiling problem, we understand a quadruple P = (C, H, V, ∞), where (C, H, V ) is a tiling system and ∞ is just a fixed symbol, regarded as a problem over the alphabet C as follows: an instance c0 , . . . cn of P counts as positive just in case (C, H, V ) has an unbounded tiling with intial segment c0 , . . . cn . Let M be a Turing machine which, when given input a0 , . . . , an−1 , terminates with output 1 if and only if the Turing machine coded by the sequence a0 , . . . , an−1 terminates with output 1 on input a0 , . . . , an−1 . Constructing TM and eM as just described, we have that M terminates with output 1 on input a0 , . . . , an−1 if and only if eM (a0 ), . . . , e(an−1 ) has anbounded TM -tiling. Hence: Theorem 2.5. There exists a tiling system (C, H, V ) such that the unbounded tiling problem (C, H, V, ∞) is undecidable. To show that a problem P is undecidable, it therefore suffices to find, for any tiling system T = (C, V, T ), a mapping gT from instances c of T to instances of P, such that (i) c is a positive instance of the bounded tiling problem T = (C, H, V, ∞) if and only if gT (c) is a positive instance of P; and (ii) gT can be effetively computed. Theorem 2.6. The problem Sat-L3≈ is undecidable. 20 CHAPTER 2. FINITE-VARIABLE FRAGMENTS Corollary 2.2. The problem Sat-L3 is undecidable. Proof. Construct ϕT as in theproof of Theorem 2.6. Let ψT be the result of replacing ≈ in ϕT by e (e is a new binary predicate), adding conjuncts stating that e is an equivalence relation, and adding the further conjuncts ∀x∀y(α(x) ∧ e(x, y) → α(y)) ∀x∀y∀z(β(x, y) ∧ e(y, z) → β(x, z)) for every unary literal α(x) and every binary literal β(x, y) over the signature of ϕT . It is obvious that ψT is satisfiable if and only ϕT is satisfiable. The presence of binary relations in these fragments is essential for undecidability, as we now proceed to show. We employ the familiar apparatus of Ehrenfeucht-Fraı̈ssé games. Given structures A and B, the k-round Ehrenfeucht-Fraı̈ssé game on A and B proceeds as follows. There are two players: a spoiler and a duplicator. In each round of the game, the spoiler chooses an element from either A or B; and the duplicator responds by choosing an element from the other domain (B or A). Suppose the elements thus chosen after the ith round are, in order, a0 , . . . , ai from A and b0 , . . . , bi from B. The duplicator’s goal is to ensure, that, for all i (1 ≤ i ≤ k), the substructure of A induced by a0 , . . . , ai is isomorphic to the substructure of B induced by b0 , . . . , bi . The spoiler’s goal is to choose the elements so that the duplicator cannot do so. If the duplicator can survive until the kth round has been played, she wins; otherwise the spoiler wins. (Spoilers are by convention male, duplicators female.) We write A ≡k B if, however the spoiler plays, the duplicator can win the k-round Ehrenfeucht-Fraı̈ssé game on A and B. Ehrenfeucht-Fraı̈ssé games sometimes provide a vivid demonstration that two models agree on formulas of limited complexity. (See, e.g. [16].) Definition 2.1. The quantifier rank of a formula ϕ (over a purely relational signature), denoted qr(ϕ) is the maximum depth of its quantifier-nesting: qr(ϕ) = 0 for ϕ atomic qr(¬ϕ) = qr(ϕ) qr(ϕ ∧ ψ) = max(qr(ϕ), qr(ψ)) etc. qr(∀xϕ) = qr(∃xϕ) = qr(ϕ) + 1. Theorem 2.7. Let A and B be structures over some purely relational signature. Then A ≡k B if and only if A and B agree on all sentences of quantifier rank at most k. Lemma 2.6. Let ϕ be a formula in LMon,≈ , the monadic framgment of firstorder logic with equality. If ϕ is satisfiable, then it is satisfiable over a domain of size at most n2n , where n = kϕk. 2.3. FRAGMENTS WITH THREE OR MORE VARIABLES 21 Proof. Let A and B interpret a signature of unary prediates, and suppose that, for any 1-type π over this signature, min(|{a ∈ A : A |= π[a]}|, k) = min(|{b ∈ B : B |= π[b]}|, k). (2.11) Then it is easy to see that A ≡k B. Now, given any model A of ϕ, we select, for each 1-type π, a maximal subset Bπ of {a ∈ A | A |= π[a]} having cardinality at most qr(ϕ). Let B be the union of all the Bπ and B the induced submodel of A. Then |B| ≤ n2n ; and Equation (2.11) certainly holds for k = qr(ϕ). By Theorem 2.7, B |= ϕ. Theorem 2.8. The problems Sat-LMon , Sat-LMon,≈ , Sat-LkMon and Sat-LkMon,≈ , for k ≥ 2 are all NEXPTIME-complete. Proof. The upper bounds follow from Lemma 2.4. The lower bounds follow from Lemma 2.5 Proof. Let T = (C, c0 , H, V ), be an unbounded tiling problem. We effectively compute a sentence ϕT of L3≈ such that Write C = {c0 , . . . , cm }. We employ a signature with unary predicates c0 , . . . , cm and binary predicates h, v. Let ϕT be the conjunction of the following sentences: _ ci (x) (2.12) ∀x 0≤i≤n ∀x ^ ¬(ci (x) ∧ cj (x)) (2.13) 0≤i<j≤n ∃xc0 (x) ∀x∃yh(x, y) (2.14) (2.15) ∀x∃yv(x, y) ∀x∀y∀z(∃z(h(x, z) ∧ v(z, y)) ∧ ∃y(h(x, y) ∧ v(y, z)) → y ≈ z). ^ (c(x) ∧ h(x, y) → ¬c′ (y)) ∀x∀y (2.16) (2.17) (2.18) hc,c′ i6∈H ∀x∀y ^ (c(x) ∧ v(x, y) → ¬c′ (y)) (2.19) hc,c′ i6∈V We show that ϕT is satisfiable if and only if L3≈ has a tiling. This proves the theorem, since any method for determining Sat-L3≈ would be a method for determining whether an unbounded tiling proble has a tiling, and hence for solving the halting problem. Suppose T has a tiling t. Let A be a structure with domain A = N2 , such that hA = {(hi, ji, hi + 1, ji)|i, j ∈ N}, hA = {(hi, ji, hi + 1, ji)|i, j ∈ N} and cA = {hi, ji|i, j ∈ N, t(i, j) = c} for all c ∈ C. It is routine to check that A |= ϕT . Conversely, suppose A |= ϕT . From (2.15)–(2.17), we may choose functions fh , fv : A → A such that for all a ∈ A, A |= h[a, fh (a)] and A |= h[a, fv (a)]. 22 CHAPTER 2. FINITE-VARIABLE FRAGMENTS From (2.17), fh (fv (a)) = fv (fh (a)), and from (2.14), we may choose a0 ∈ A such that A |= c0 [a0 ]. Define the function g : N2 → A by g(i, j) = H i (V j (a0 )) for all i, j ∈ N. Obviously, g(i + 1, j) = fh (g(i, j)); and since fh (fv (a)) = fv (fh (a)), we have also g(i, j + 1) = fv (g(i, j)). Finally, from (2.12)–(2.13), every a ∈ A satisfies a unique ci ∈ C in A. Hence we may define the function t :N2 → C by letting t(i, j) be the element of C satisfied in A by g(i, j). In particular, t(0, 0) = c0 . That t is a tiling is then immediate from (2.18)–(2.19). 2.4 Bibliographic notes The locus classicus for the Syllogistic—the fragment here denoted S—is Aristotle [1]. The study of the syllogistic dominated logic until the end of the 19th Century. The fragment L2≈ has an interesting history. Lemma 2.3, which is due to Scott [27], reduces the problem Sat-L2≈ to the satisfiability problem for the socalled Gödel fragment with equality: the set of first-order formulas in prenexform having quantifier prefix matching ∃∗ ∀∀∃∗ . Essentially the same argument reduces Sat-L2 to the satisfiability problem for the Gödel fragment without equality. Gödel [7] had earlier shown that the Gödel fragment (without equality) has the finite model property, and is thus decidable. Unfortunately, Gödel also claimed that adding equality would not affect this result, a claim which was only later shown to be false by Goldfarb [8]. Relying on Gödel’s incorrect assertion, Scott claimed to have a proof that L2≈ is decidable. (What Scott actually showed was the decidability for L2 only.) That the full two-variable fragment does indeed have the finite model property was eventually established by Mortimer [18]. The tight NEXPTIME complexity bound was first obtained by Grädel, Kolaitis and Vardi [10], whose proof Lemma 2.4 repeats. 2.5 Exercises 1. The Bernays-Schönfinkel class is the set of all function-free, first-order formulas having the form ∃x1 . . . ∃xm ∀y1 . . . ∀yn ψ, where ψ is quantifier-free. Show that, if a formula ϕ in the BernaysSchönfinkel class has a model, then it has a model whose size is bounded by a polynomial function of kϕk. What can we say about the complexity of the satisfiability problem for formulas of this fragment? What can we say about this complexity if we additionally restrict the arity of predicates to some fixed number k?