undecidability of the horn clause finite implication problem

16

Upload: askethi

Post on 21-Jul-2016

215 views

Category:

Documents


1 download

DESCRIPTION

undecidability of the horn clause finite implication problem

TRANSCRIPT

Page 1: undecidability of the horn clause finite implication problem

Undecidability of the Horn Clause Finite ImplicationProblem ?Jerzy MarcinkowskiInstitute of Computer ScienceUniversity of Wroc law,ul. Przesmyckiego 2051-165 Wroc law, [email protected] prove that the set IMPL of such pairs < H;G > of Horn clauses, that H�nitely implies G (i.e. G is true in all the �nite structures in which H is true), isnot recursive. Moreover, we prove that sets co-IMPL and RES=f< H;G > Gcan be derived from H by resolution g are recursively inseparable.1 Introduction1.1 Motivation and Previous ResultsQuestions concerning decidability of clause implication and similar problemsare motivated by arti�cial intelligence and automated deduction and used tobe an area of some interest. That is because redundancy elimination is believedto be an important issue in optimization of automated theorem provers (wheregeneral clauses are used) or logic programs and clausal knowledge bases (whereall clauses are Horn clauses). Less redundant clause sets require less storagespace, and, since the redundant clauses force the program to do redundantwork, allow better performance of proof procedures.The problem if a (general) clause H implies a clause G has been proved tobe undecidable by M. Schmidt-Schauss in 1988 ([SS88]). His theorem can beformulated also as: the problem, given three Horn clauses, does the �rst two ofthem imply the third, is undecidable. The decidability of a clause implicationproblem for Horn clauses (i.e. whether a Horn clause H implies a Horn clauseG ) remained open until 1992, when it was solved negatively by J. Marcinkowskiand L. Pacholski ([MP92]). In [M93] a particular Horn clause was constructed,which implies an undecidable set of Horn clauses.Meanwhile, su�cient conditions for decidability of Horn clause implicationwhere studied in ([S73], [GL85], [GL85a], [GL89],[SS88],[L88],[L89]). A surveyof the results can be found in [GL89].The following lemma allows us to use a more convenient language to speakabout problems of our interest:? This research has been supported by a KBN grant 2 P301 046 07. .

Page 2: undecidability of the horn clause finite implication problem

Lemma1. Let H1 and H2 be Horn clauses. LetH2 = (A1 ^ A2 ^ : : : ^ Ak =) A)Then :(H1 j= H2) [:(H1 j=f H2)] i� the set consisting of H1, �(Ai) fori = 1; 2; : : : k and :�(A) is [�nitely] satis�able, where � substitutes a constantcx, occurring neither in H1 nor in H2, for every variable x in H2.If H ranges over Horn clauses with one premise (of the form A0 =) A),then the problem if H implies a Horn clause G is decidable ([SS88]) and itis the strongest of the natural decidability results in this area. The problemhas two natural generalizations: �rst of them is to admit more than only onepremise. We get the full Horn Clause Implication Problem then, which wasproved to be undecidable and which �nite variant is the main topic of this pa-per. The second is the so called Cycle Uni�cation Problem: given a Horn clauseH = (Q(t1) =) Q(t2)) and two arbitrary terms s1 and s2, decide if there is anysubstitution � such that Q(�(s2)) a logical consequence of H and of Q(�(s1)).Similarly as in the case of Horn Clause Implication Problem there were somepapers written, giving su�cient conditions of decidability of the Cycle Uni�ca-tion Problem. The survey of the results, and proofs, can be found in [BHW92].The general problem was proved to be undecidable in 1992 by P. Devienne,P. Leb�egue and J.C. Routier, and independently by P. Haschke and J. W�urz([DLR92],[DLR92a],[W93],[HW93]).1.2 A Related Topic: Database Dependencies ImplicationOne of the questions that was frequently asked after we constructed ([MP92])the Thue trees encoding method, that is used also in this paper, was: to whatextend is the function symbol necessary in the language? In fact the followingtheorem is just a corollary from our technique:Theorem 2 The problem:Given two sentences in the language of �rst order logic, without function sym-bols. Suppose the sentences have the form8y1; y2 : : : ; yk9x1; x2; : : : ; xl(Q(t1) ^Q(t2) ^ : : : Q(tp)) =) Q(s)where ti; s denote vectors of variables of the length equal to the arity of Qand the existential quanti�ed variables occur only in the head of the clause.Does the �rst of those sentences imply anotheris undecidable.The theorem is weaker than the one asserting undecidability of Horn ClauseImplication Problem, but it translates our technique into database dependenciestheory language. The language of �rst order logic with equality, with no function

Page 3: undecidability of the horn clause finite implication problem

symbols, and with one n-ary predicate symbol A is used there. A dependencyis a sentence8y1; y2 : : : ; yk9x1; x2; : : : ; xl(A(t1) ^ A(t2) ^ : : : A(tp))=) (B(s1) ^ B(s2) ^ : : : B(sq))where each B is either A or =, si; tj denote vectors of variables of properlength, the variables occurring in the premises of the implication are exactlyy1; y2 : : : ; yk and the set of variables occurring in the conclusions contains x1; x2; : : : ;xl. The (�nite) implication problem for data dependencies is the problem ofdeciding whether a given set of dependencies logically (�nitely) implies an-other dependency. Many types of dependencies have been considered and someresults concerning undecidability of �nite implication have been proved (e.g.[BV81],[CV85], [H92], a survey of results in [K90]). The theorem above can beexpressed in this language as: it is undecidable whether an unirelational single-head dependency implies another one of this sort.That is, however, �nite implication rather than the classical one which isconsidered to be important in the database theory. That motivated us to studythe problem if our Thue trees method can also deal with the �nite implication.1.3 The ResultsLet IMPL=f<H ,G >: H �nitely implies G gand letRES=f<H ,G >: G can be derived from H by resolutiong.resolution is a standard technique of enumerating (some) of the elementsof IMPL. Since RES is a recursively enumerable set and, as it was proved in[MP92], not a recursive set, and since IMPL is co-recursively enumerable set itis clear that resolution, still being an important tool, is not complete for �niteimplication in the sense, that it does not enumerate all elements of IMPL.In the technical part of this paper we prove that IMPL is undecidable.Moreover, we prove that RES and co-IMPL are recursively inseparable. Thatmeans, that for every set R such that (i) R is recursive and (ii) R �IMPL (i.e.for every (i) terminating and (ii) sound method of detecting redundancy in aprogram) RES 6� R. This results shows that, in some sense, there is nothingmore complete than resolution, even when we consider �nite implication as amodel of the notion of logical consequence.The method of encoding used in this paper was already used in [MP92] and,although it was re�ned and improved here, it is not the main technical ideaof this paper. The problem which we found di�cult to solve was not how butwhat should be encoded to let the encoding work in the �nite implication case,and to make the construction of the �nite model possible.

Page 4: undecidability of the horn clause finite implication problem

2 Technical Part2.1 The Main TheoremConvention 3 When we write logic program we always mean a program con-sisting of one Horn clause and a �nite set of ground atoms (facts).Let IMPL=f<PROG , A >: PROG implies A in all �nite models g, wherePROG is a logic program and A is a ground atom. Notice that, by Lemma1.1 IMPL is, up to unimportant formal di�erences, the same as de�ned insubsection 1.3. Let RES=f<PROG , A >: A can be derived from PROG byresolution g.Theorem 4 (i) RES and co-IMPL are recursively inseparable.(ii) IMPL is not a recursive set.Plan of the proof:In subsection 2.2. we de�ne a set VSTM and two its recursively inseparablesubsets: ACC and REJ . In sections 2.2-2.6. we, step by step, construct (for�xed T2VSTM) a logic program PROG2 and a ground atom A . The con-struction is uniform with respect to T, so it de�nes a total recursive mappingmap from VSTM to the set of pairs <logic program, ground atom>. In subsec-tion 2.6. we prove that if T2ACC , then map(T) 2 RES. In subsection 2.7.we prove, that if T2REJ then map(T) =2 IMPL.(i) Suppose that there exists a recursive set R such that RES� R and co-IMPL\R = ;. Then map�1(R) is also recursive. And it is a recursiveseparator of ACC and REJ . Contradiction.(ii) That follows from (i).(see Figure 1.)2.2 The Translation. First StepWe will consider a set VSTM of Very Strange Turing Machines T that satisfythe following conditions:(i) the tape of T is right-in�nite.(ii) the tape symbols of T are !, 0 and 1.(iii) T is deterministic and it is not able to delete symbols from the tape (towrite new blancs).(iv) ! is a special symbol: machine neither can write nor overwrite it. ! marks the(left) end of the tape, so T has no instruction of the form: "while scanning! in the state q move left".

Page 5: undecidability of the horn clause finite implication problem

(v) q1begand q2begare two distinct beginning states. !q1begand !q2begare two begin-ning con�gurations of T, where !q1begdenotes empty tape (i.e. only the leftend marker ! on the tape) and the head in the state q1begover !.De�nition 5 (i) Let ACC =fT 2VSTM: the computation of T beginning fromthe con�guration !q1beg terminates, and needs less tape space than the com-putation of T beginning from the con�guration !q2begg (we do not care if thelast terminates or not).(ii) Let REJ =f T 2VSTM: both the computations of T beginning from the con-�guration !q1begand beginning from the con�guration !q2begterminate. More-over, they terminate in the same con�guration g.If c1 and c2 are con�gurations of T then we will write c1!c2 if c2 is obtainedfrom c1 in one computation step of T. O(c1) will denote an equivalence classof con�guration c1 with respect to the minimal equivalence relation containing!.Lemma6. (i) ACC and REJ are disjoint and recursively inseparable.(ii) if T 2 ACC [ REJ then O(!q1beg) is �nite.Proof:(i) We use the fact that A0 and A1 are recursively inseparable, where Ai = fn :�n(n) = ig (see [R67] Ch. 7 Th. 12).(ii) That is because T is deterministic and does not write new blancs.For a given T2VSTM we consider the alphabet ALF such that the symbolsin ALF are triples htapesymbol; state; endofthetapei where tapesymbol is oneof 0,1,! state is one of the states of T or 0 and endofthetape is 0 or 1. Symbolsh:; :; 0i we call static symbols. Symbols that are not static we call dynamic.Symbols h:; q; :i where q 6= 0 we call headmarking Notice, that con�gurations ofT can be, in a natural way, uniquely identi�ed with words w over ALF suchthat only one symbol of w is headmarking, and only one, the last symbol of w,is dynamic. ALF is an alphabet of a Thue process T . We will require from Tto satisfy the following conditions:(i) if < u; v > is a production of T then each of u and v has no more than 2symbols and no less than one symbol. u and v are not both single symbols,(ii) if a symbol i 2ALF occurs in any production of a form< i;w >then it is dynamic,(iii) if a symbol i occurs in any production of a form< ji; k >where j; k are symbols, then it is dynamic,

Page 6: undecidability of the horn clause finite implication problem

(iv) if a symbol i occurs in any production of the form < ij; v > then it is static,(v) if < ij; kl > is a production of T and j is dynamic, so is l .De�nition 7 For every word w over the alphabet ALF let the set Thue(w)=fv : v �T() wg .For every set W of words over the alphabet ALF let the set THUE(W)=fv : 9w 2 W 9u: v is a pre�x of u and w �T() ug.It is easy to prove that we can construct T in such a way, that Thue(w)=O(w).Once we know what is the meaning of symbols in ALF (they representinformation about status of a cell on the Turing Machine tape) we can simplifyour notation: let p denote the number of elements of ALF . We �x a numberingof the symbols of ALF with numbers 1; 2 : : : p; and identify symbols with theirnumbers. We number h!;q1beg ; 1i with 1, and h!;q2beg ; 1i with 2. We write 1 and 2also to denote one-symbol words. Notice that in this way 1 and 2 are identi�edwith the two beginning con�gurations of T.Lemma8. (i) If T2ACC [REJ then THUE(1) is �nite.(ii) If T2ACC , then 2 62THUE(1).(iii) If T2REJ , then THUE(1)=THUE(2).2.3 The Translation. Second Step.De�nition 9 (i) Let us call an ALF tree (or simply tree) every (not neces-sarily �nite) set P of words over the alphabet ALF such that w 2P andw = uv implies u 2 P . Let Pw = fv : 9u 2 P u = wvg.(ii) Let P be a ALF tree. We call a node w 2P semiregular if for every produc-tion hv; ui 2T Pwv = Pwu .(iii) Lets call a ALF -tree P semiregular, if every its node is semiregular.The following two lemmas present the main idea of representing a compu-tation as a semiregular tree:Lemma 10 For every set W of words over the alphabet ALF THUE(W) is asemiregular tree.Lemma 11 Every semiregular tree containing a node w contains all elementsof the set Thue(w). So if there exists a �nite semiregular tree containing w thenalso the sets Thue(w) and THUE(w) are �nite.Proof: Induction on the length of a derivation of v from w.Lemma12. (i) If T2ACC then there exists a �nite, semiregular tree P suchthat 12P , 262P .(ii) If T2REJ and P is a semiregular tree such that 12P then 22P .

Page 7: undecidability of the horn clause finite implication problem

2.4 The Logic ProgramDe�nition 13 (i) Let H be a Horn clauseQ(�1) ^Q(�2) ^ : : : ^Q(�l) ) Q(�0)where � 's denote vectors of terms of length equal to the arity of Q. A H-derivation is a �nite full l-tree D such that every its node w is labeled withvector �(w) of ground terms of the same length as � 's and that for eachinner node w of D there exists a substitution � such that ��0 = �(w) and��i = �(wi) for every i � l.(ii) Suppose S is a �nite set of vectors of constant terms of length equal to thearity of Q. Let PROG be a logic program consisting of the clause H and ofthe set S of facts. Then an H-derivation will be called a PROG -derivationif �(w) 2 S for every its leaf w.Important Convention 14 We assume from here that terms are built of vari-ables, a p-ary functional symbol g and of a constant c. So a constant term isuniquely described by a tree (i.e a set of words in f1; 2; : : : ; pg�) of its symbolsg. We will not distinguish between them.De�nition 15 H will be the Horn clauseQ(�1) ^ Q(�2) ^ : : : ^ Q(�p) ) Q(� )where Q is an unary relation symbol and:� = g(�1; �2; : : : �p)is a term built over the language containing exactly one p-ary functional symbolg and no constant symbols. � has a g symbol on the position w i� w is a single,static, symbol of ALF . The variables on positions u and v in � are equal i�< u; v >2 T .Notice, that the Thue process was chosen in such a way, that there exists aunique H ful�lling the requirements of the de�nition.De�nition 16 (i) Let gc = g(c; : : : ; c)(ii) Let S = fQ(c);Q(gc)g.(iii) Let PROG be a program consisting of H and S .Next lemmas describe the structure of PROG -derivation.Lemma 17 (i) Suppose the root of a H derivation D is labeled with a constantterm �. If there is a node w in the derivation then �(w) = �w (where�(w) is, as in De�nition 2.11(i), the label of the node w and �w is, as inDe�nition 2.7(i) a subtree of � rooted in w).

Page 8: undecidability of the horn clause finite implication problem

(ii) Suppose the root of a PROG - derivation D is labeled with a constant term� . Then � is a semiregular tree.Lemma18. Suppose T2REJ . If t is a label of a root of a PROG - derivationand if 12 t then also 22 t.Unfortunately not every semiregular tree is a label of a root of some PROG -derivation. That is why we are still not able to prove that if T2ACC then someterm t such that 1 2 t and 2 62 t is a label of a root of a PROG - derivation.2.5 The Case T2ACCDe�nition 19 (i) We call a node w regular if it is semiregular and if i 2 Pwfor every static i 2ALF .(ii) Let us call a ALF -tree P regular if every its node w is regular or is a leaf.Lemma 20 (i) Suppose a root of a constant term � is a regular node. Thenthere exists a substitution � such that �i = ��i for i 2ALF and � = ��.(ii) Suppose a constant term � is a regular tree. Then � is a label of the rootof a PROG - derivation D. D is a full p-tree that has the same set of innernodes as �. If w is a leaf of � then it is labeled by gc in D. If w is a leafof D but is not in � then it is labeled by c in D.Suppose P = THUE(1) is a �nite tree. Let d denote its depth. Let Pd =P .For given Pk let Pk�1 be the result of the followingProcedure:{ substitute P :=Pk .{ while there exists a non regular inner node w of P , such that jwj � k, dotake the static symbol i such, that wi =2P and substitute P := THUE(P [fwig).{ substitute Pk�1 := P .So to obtain P0 we execute the Procedure d times.Lemma 21 (i) if w is an inner node of Pd then w contains no dynamic sym-bols.(ii) if w is an inner node of Pk (k � d ) then w contains no dynamic symbols.(iii) the tree THUE(P [fwig) in the substitution above is �nite.(iv) the procedure terminates.(v) if w is an inner node of Pk and jwj � k then w is a regular node of Pk

Page 9: undecidability of the horn clause finite implication problem

(vi) P0 is a regular tree.Proof:(i) it follows, since 1 is a one-symbol word, so it has only one dynamic symbol,as its last symbol. There is no production in T that can write a static symbolright of it.(ii) the procedure chooses w that is not a leaf of P and hence contains nodynamic symbols. i is a static symbol. There is no production in T that canincrease the number of dynamic symbols in a word. So every v 2 THUE(wi)contains only static symbols. THUE(P[fwig) = THUE(P)[THUE(wi).Since P is already semiregular it equals P [THUE(wi).(iii) THUE(wi) contains only words not longer, than jwij.(iv) it produces an increasingly ordered by inclusion sequence of trees, none ofthem deeper than d(v) this is why there is while in the procedure(vi) it follows from (v), since 0 � jwj for every wDe�nition 22 A speci�cation spec (t) of a constant term t is a tree (i.e. aterm) t \ f1; 2g�So spec (t) is a ground term that has the symbol g on position w i� w 2 f1; 2g�and if t has g on position w.Lemma23. spec (P ) = g(gc; c; c; : : : c). or spec (P ) = g(gc; gc; c; : : : c).Proof:Every path from the root to a leaf of P is a con�guration of a Turing MachineT. So there can be only one headmarking symbol on the path. Both 1 and 2are headmarking. Hence depth spec (P ) is 1. By de�nition P =THUE(1), so12 P \ f1; 2g�.Lemma24. Suppose that T2 ACC .(i) spec (P0) = g(gc; c; c; : : : c).(ii) There exists a term t such that 1 2 t, 2 =2 t and t is a label of a root of somePROG - derivation.Proof:(i) By lemma 2.19 P0 is a regular (and hence semiregular) tree of the samedepth d as P =THUE(1). By the de�nition 2.3 THUE(2) is deeper than d.So THUE(2) 6� P0. Since P0 is semiregular we get 2=2 P0.(ii) By (i), lemma 2.19(vi) and lemma 2.18(ii) P0 is such a term.

Page 10: undecidability of the horn clause finite implication problem

2.6 Ground GoalWe have already proved that if T2 ACC then some term of the speci�cationg(gc; c; c; : : : c) can be derived from PROG and if T2 REJ then no such termcan be derived. But, while we know its speci�cation, the derived term itself iscompletely unpredictable. That is why we will de�ne the new program PROG1now. It will compute simultaneously a term and its speci�cation. The idea ofthe next step will be to forget the term, and compute only the speci�cation.De�nition 25 (i) Let Q1 be a binary relation symbol. Then H1 isQ1(x1; �1) ^ Q1(x2; �2) ^ : : : ^Q1(x2; �p)) Q1(g(x1; x2; c; c; : : : )�; � )where � 's are as in de�nition 2.13 , and x' are new variables.(ii) S1 =fQ1(c; c);Q1(gc; gc)g(iii) PROG1 consists of the clause H1 and of the set of premises S1 .Lemma26. PROG1 j=Q1(s; t) if and only if t is a regular tree and s =spec(t).Now, once we know that s is a speci�cation of a valid computation i� thereexists a term t such that PROG1 j=Q1(s; t) , we can forget of t:De�nition 27 (i) Let Q2 be a ternary relation symbol. Then H2 isQ2(z1; z2; y0) ^ Q2(x1; �1; y1)^Q2(x2; �2; y2) ^ : : : ^Q2(xp; �p; yp)) Q2(g(x1; x2; c; c; : : : )�; �; z1)where � 's and x's are as in de�nition 2.23 , y's and z' are new variables.(ii) S2 =fQ1(c; c; c);Q1(gc; gc; c)g(iii) PROG2 consists of the clause H2 and of the set of premises S2 .Lemma28. PROG1 j=Q2(r; u; s) if and only if u is a regular tree , r =spec(u), and s is a speci�cation of some regular tree .It is clear that it is s in the lemma above, what is interesting for us. u andr are there for purely technical reasons. Let now u = g(k1; k2; : : : kp), whereki = c if i is a dynamic symbol, and ki = gc if i is static. It is easy to observe,that u is regular and spec (u) = gc.De�nition 29 A = Q2(gc; u; g(gc; c; c; : : : ; c))

Page 11: undecidability of the horn clause finite implication problem

Notice, that A is a ground atomic formula.Lemma30. (i) If T 2ACC , then PROG2 j=A .(ii) If T 2REJ , then PROG2 6j= A .Proof:(i) By lemma 2.26 PROG2 j=A if g(gc; c; c; : : : ; c) is a speci�cation of a regulartree. But if T 2 ACC , then, by lemma 2.22 g(gc; c; c; : : : ; c) is a speci�cationof a regular tree P0 .(ii) That follows from lemma 2.26 since if T 2REJ then g(gc; c; : : : c) is not aspeci�cation of any regular tree (by lemma 2.10(ii) if P is semiregular and1 2P then also 2 2P ).<PROG2 ,A > is the value of the mapping map (of Theorem 2.2) for theargument T.2.7 The Case T2 REJIn this subsection we suppose, that T2 REJ . We already know that PROG26j=A (in the classical sense) (so <PROG2 ,A >62RES). It should be proved thatPROG2 6j=fA . We will construct a �nite model in which clauses of PROG2 aresatis�ed but A is not true.Since T2 REJ , THUE(1)=THUE(2) is a �nite semiregular tree. Denote itsdepth as d� 2 (this is only to secure, that d � 2). The idea here is to constructthe model big enough to embed in it a proof of the fact that 2 2 THUE(1).De�nition 31 (i) Let t; s be ground terms. We de�ne t�s if t\f1; 2; : : : pgd =s \ f1; 2; : : : pgd (it is clear that � is an equivalence and a congruence withrespect to g)(ii) Let HERB be the Herbrand universe of all ground terms (in our signature).We de�ne M as HERB/�. Elements of M will be denoted as �t; �s; �r; �u. Wewill denote �u = u \ f1; 2; : : : pgdIt is clear that M is a �nite set. We can think of M as of set of terms (trees)not deeper than d where �g is the interpretation of g de�ned as follows:{ to compute �g(�u1; �u2; : : : �up) take the tree g(�u1; �u2; : : : �up).{ if the computed tree is deeper than d, forget its lowest level.Notice, that if a term t 2 HERB is of depth less than d then it is the onlyelement of its equivalence class. We will identify the term and its class then.We shall de�ne the interpretations Q, Q1 and Q2 ofQ,Q1 and Q2 inM now.We de�ne them, as the minimal relations such, that M is a model of PROG, PROG1 and PROG2 respectively. It is easy to make a mistake here: clearly if

Page 12: undecidability of the horn clause finite implication problem

there exists term t such that �t = �u and PROG j=Q(t) thenQ(�u). But the oppo-site implication is not valid: it can happen that Q(�t) but there is no such u that�t=�u. That takes place, for example, when PROG j=Q(t), Q(t1) : : : Q(tp),�t =�u; �t1 = �u1 : : : �tp = �up and Q(t) can be derived from Q(t1);Q(t2); : : :Q(tp) by asingle use of clause H .De�nition 32 We de�ne simultaneously the interpretation of Q in M and afunction rank such that rank (�t) is de�ned if and only if M j= Q(�t).(i) M j= Q(gc) , M j= Q(c). rank (c) and rank (gc) is 0, and they are theonly terms of rank equal to 0.(ii) M j= Q(�t) and rank (�t) = k i� there exists a �nite tree P of depth k beinga derivation of �t in M . That means, that every node of P is labeled by anequality class of �, in such a way that the following conditions are satis�ed:(a) The root of P is labeled with �t.(b) If �u is a label of a leaf of P then �u = c or �u = gc(c) If �u is a label of any node of P (di�erent than the root), then M j=Q(�u) and rank (�u) is less than k(d) If �u is a label of an inner node of P and �u1; �u2; : : : �up are labels of sonsof the node then there are terms t; t1; t2 : : : tp such that �t = �u; �t1 =�u1 : : : �tp = �up and Q(t) can be derived from Q(t1);Q(t2); : : :Q(tp) by asingle use of clause H .Interpretations of Q1 and Q2 and ranks of pairs and triples of terms withrespect to Q1 and Q2 are de�ned analogously.In particular, the only pairs of terms of rank 0 (with respect to Q1 ) are(c; c) and (gc; gc) and the only triples of terms of rank 0 with respect to Q2 are(c; c; c) and (gc; gc; c) (compare with de�nitions 2.23(ii) and 2.25(ii)).We do not claim, that a tree P satisfying requirements of De�nition 2.30.(ii)is unique.Now we are going to prove that A is not true in M . Our �rst step will bethe elimination of Q1 and Q2 . We prove that if M j= A then M j= Q(�t) forsome term �t, such that 1 2 �t and 2 =2 �t.Lemma33. (i) If M j= Q2(�r; �u; �s) then M j= Q1(�r; �u)(ii) If M j= A then M j= Q1(�g(gc; c; c; : : : ; c); �u; �s) for some terms �u; �s(iii) If M j= A then M j= Q1(�g(gc; c; c; : : : ; c); �u) for some term �u(iv) If M j= Q1(�s; �t) then M j= Q(�t) .(v) If M j= Q1(c; �t) then �t = c.(vi) If M j= Q1(g(gc; c; c; : : : ; c); �t) then 2 =2 �t.

Page 13: undecidability of the horn clause finite implication problem

(vii) If M j= Q1(�t; c) then �t = c.(viii) If M j= Q1(g(gc; c; c; : : : ; c); �t) then 1 2 �t.(ix) If M j= A then M j= Q(�t) for some term �t, such that 1 2 �t and 2 =2 �t.Proof:(i) Induction on rank (�r; �u; �s). If it is 0, then the claim is true. Supposewe have Q2(�r; �u; �s) and rank (�r; �u; �s)=k. Then there are triples of terms(�r0; �u0; �s0); (�r1; �u1; �s1) : : : ; (�rp; �up; �sp), all of rank � k�1 such thatQ2(�r; �u; �s)can be derived from Q2(�r0; �u0; �s0); Q2(�r1; �u1; �s1) : : : ; Q2(�rp; �up; �sp) by a sin-gle use of clause H2 . By hypothesis we have Q2(�r0; �u0); Q1(�r1; �u1) : : : ;Q1(�rp; �up). By de�nitions of clauses H1 and H2 Q1(�r; �u) can be derivedfrom them by a single use of H1 . So M j= Q1(�r; �u) .(ii) Since A is not in S2 , if M j= A then rank (A ) is some k � 1 and thereare triples of terms (�r0; �u0; �s0); (�r1; �u1; �s1) : : : ; (�rp; �up; �sp) all of rank � k�1such thatA can be derived from Q2(�r0; �u0; �s0);Q2(�r1; �u1; �s1) : : : ; Q2(�rp; �up; �sp)by a single use of clause H2 . By de�nitions of A and of the clause H2 wehave �r0 = g(gc; c; c; : : : ; c).(iii) It follows from (i) and (ii).(iv) We proceed here in the same way, as in (i).(v) If rank (c; �t) = 0 then the claim is obvious. Suppose rank (c; �t) is some k �1. Then, there are pairs of terms (�s1; �t1); (�s2; �t2) : : : ; (�sp; �tp) all of rank �k�1 such that Q1(c; �t) can be derived from Q1(�s1; �t1); Q1(�s2; �t2) : : : ; Q1(�sp; �tp)by a single use of clause H1 . But then c = �g(�s1; �s2; c; : : : ; c), what is notpossible in M .(vi) It is clear that rank (g(gc; c; c; : : : ; c); �t) is not 0. So rank (g(gc; c; c; : : : ; c); �t)is some k � 1. There are pairs of terms (�s1; �t1); (�s2; �t2) : : : ; (�sp; �tp) all of rank� k � 1 such that Q1(g(gc; c; c; : : : ; c); �t) can be derived fromQ1(�s1; �t1); Q1(�s2; �t2) : : : ; Q1(�sp; �tp) by a single use of clause H1 . By the def-inition of clause H1 s2 = c. So, since M j= Q1(�s2; �t2) by (v) we get t2 = c.So 2 =2 �t.(vii) We argue here as in (vi)(viii) As in (vi) we know that rank (g(gc; c; c; : : : ; c); t) is some k � 1 and thereare pairs of terms (�s1; �t1); (�s2; �t2) : : : ; (�sp; �tp) all of rank � k� 1 such thatQ1(g(gc; c; c; : : : ; c); �u) can be derived from Q1(�s1; �t1); Q1(�s2; �t2) : : : ; Q1(�sp; �tp)by a single use of clauseH1 , and �u = �t . By the de�nition of clauseH1 we gets1 = gc. So, sinceM j= Q1(�s1; �t1) by (vii) �t1 6= c. Hence �t1 = �g(�u1; �u2; : : : �up)and 1 2 �t by the de�nition of clause H1 .(ix) The claim is just a summary of claims (i)-(viii)

Page 14: undecidability of the horn clause finite implication problem

It remains to prove that for every term �t such that M j= Q(�t) and 1 2 �t also2 2 �t. We start with a lemma analogous with lemma 2.15(i): if a term can bederived then it is equal (to some extend) to its derivation:Lemma34. Let �t and P be like in De�nition 2.30. Let P0 be a subtree of thosenodes of P that are not labeled with c. Then �t = P0 \ f1; 2; : : : pgdProof: Induction on rank (�t). If rank is 0 then the claim is true. Supposerank (�t) is some k � 0. Let w = iv. Suppose �t1; �t2; : : : �tp are labels of nodes1; 2; : : : p of P and �t can be derived from t1; t2; : : : tp by a single use of clauseH . Notice, that Pi is a derivation of �ti in M , and that rank (�ti) � k. So, byhypothesis,�ti = P0i \ f1; 2; : : : pgd for i 2 f1; 2; : : : ; pg. The more�ti \ f1; 2; : : : pgd�1 = P0i \ f1; 2; : : : pgd�1 for i 2 f1; 2; : : : ; pg. Hence �t =P0 \ f1; 2; : : : pgd.The following lemma is analogous with lemma 2.15(ii):Lemma35. Suppose w = w1w2w3, v = w1v2w3 and < w2; v2 > is a productionof our Thue process.If w 2 f1; 2; : : : pgd then also v 2 P0.Proof: If w 2 P0 then also w1 2 P0, and w1w2 2 P0. Let �u be the labelof w1 . Since M j= Q(w1), by the condition (ii)(d) of the de�nition 2.30. weget that label of w1w2 in P0 is the same as the label of w1v2. Denote this labelas �r. One must be careful here: P0w1w2 is (in general) not equal P0w1v2 (since itis possible, that Q(�r) was derived in two di�erent ways). But, by lemma 2.32.P0w1w2 \ f1; 2; : : : pgd = P0w1v2 \ f1; 2; : : : pgd = �r and we get the claim sincejw3j � d.Lemma36. If M j= Q(�t) and 1 2 �t then also 2 2 �t.Proof: Let P0 be like in Lemma 2.32. Since 1 2 �t then, by lemma 2.32.also 1 2 P0. Now we use lemma 2.33. and the fact that depth of THUE(1) isless than d to prove that THUE(1)� P0 \ f1; 2; : : : ; pgd. So, since T2 REJ ,2 2 P0 \ f1; 2; : : : ; pgd. We, once again, use lemma 2.33. to get 2 2 �t.Lemma37. If T 2 REJ , then A is not true in M .Proof: It follows from Lemma 2.31(ix). and from Lemma 2.34.3 References[BV81] C. Beeri, M.Y. Vardi: the implication problem for data dependencies;Proc. International Coll. on Automata, Languages and Programming 1981, Lec-ture Notes in Computer Science, vol 115, pp 73-85, Springer, Berlin.

Page 15: undecidability of the horn clause finite implication problem

[BHW92] W. Bibel, S. H�olldobler and J. W�urtz: Cycle Uni�cation; in D.Kapur (ed.), Proc. the Conference on Automated Deduction, Lecture Notes inArti�cial Intelligence, vol 607, Springer (June 1992).[CV85] A. K. Chandra, M. Y. Vardi: The implication problem for functionaland inclusion dependencies is undecidable; SIAM J. Comput. vol 14, No 3, pp672-677 (1985).[DLR92] P. Devienne, P. Leb�egue and J.C. Routier: Halting Problem of oneBinary Horn Clause is undecidable; proc. of STACS 93, Springer Lecture Notesin Computer Science, vol 665 pp 48-58.[DLR92a] P. Devienne, P. Leb�egue and J.C. Routier: Cycle Uni�cation isUndecidable. preprint[FL94] C.G. Ferm�uller, A. Leitsch: Hyperresolution and Automated ModelBuilding, preprint 1994.[GL85] G. Gottlob, A. Leitsch: Fast Subsumption Algorithms; Lecture Notesin Computer Science 204-II (Springer, Berlin, Heidelberg, 1985), pp. 64-77.[GL85a] G. Gottlob, A. Leitsch: On the E�ciency of Subsumption Algo-rithms; JACM vol 32 No. 2 (April 1985), pp. 280-295.[GL89] G. Gottlob, A. Leitsch: Deciding Horn clause implication problemby ordered semantic resolution; Computational intelligence II, F. Gardin andG. Mauri, ed., 1990, pp.19-26.[HW93] P. Hanschke, J. W�urtz: Satis�ability of the Smallest Binary Pro-gram; Information Processing Letters 496 (1993) pp. 237-241.[H92] C. Herrmann: On the undecidability of implications between embeddedmultivalued database dependencies; preprint.[K90] P.C. Kanellakis: Elements of Relational Database Theory; in Hand-book of Theoretical Computer Science vol B., J. van Leeuwen (ed). 1990.[L88] A. Leitsch, Implication Algorithms for Classes of Horn Clauses; Statis-tik, Informatik und �Okonomie, Springer Verlag 1988, pp 172-179.[L89] A. Leitsch, Deciding Horn Clauses by Hyperresolution, Proc. ComputerScience Logic 89, Lecture Notes in Computer Science 440 (1989), pp 225-241[MP92] J. Marcinkowski, L. Pacholski: Undecidability of the Horn ClauseImplication Problem; Proc 33rd Annual Symposium on the Foundations of Com-puter Science (1992). pp. 354-362.[M93] J. Marcinkowski: A Horn Clause That Implies an Undecidable Set ofHorn Clauses; Proc. of 1993 Annual Conference of the European Association ofComputer Science Logic. (Springer, LNCS, to appear).[R67] H. Rogers: Theory of Recursive Functions and E�ective Computability;Mc-Graw Hill 1967.[S73] R.B.Stillman: The Concept of Weak Substitution In Theorem-proving;JACM vol.20.4(Oct. 1973), 648-667.[SS88] M.Schmidt-Schauss: Implication of Clauses is Undecidable; Theoret-ical Computer Science 59 (1988), pp. 287-296.[W93] J. W�urtz: Unifying Cycles; ECAI 1982, B. Neumann ed. pp 60-64.This article was processed using the LATEX macro package with LLNCS style

Page 16: undecidability of the horn clause finite implication problem

'& $%

'& $%

'& $%

'& $%

'& $%

'&$%'&$%

'&$%'&$%

'&$%'&$%

'& $%#" !'&$%'&$%

VSTMTHUEPROCESSES

SEMIREGULARTREESLOGIC PROGRAMS(non-ground goal)LOGIC PROGRAMS(ground goal)

ACC REJT

map(T)

Section 2.2Section 2.3Sections2.4, 2.5Sections2.6, 2.7JMPLRES

�������������6 CCCCCCC

CCCCCOCCCCCCC

CCCCCO���������

�����������

������CCCCCCCCCCCCO 6

Lemma 2.6Lemma 2.10LemmasLemmas

2.16, 2.22(i)2.28, 2.35

Lemma 2.4Fig. 1. Plan of the proof of Theorem 2.2