efficient algorithms to detect and restore minimality, an extension of the regular restriction of...

34
Journal of Automated Reasoning 25: 1–34, 2000. © 2000 Kluwer Academic Publishers. Printed in the Netherlands. 1 Efficient Algorithms to Detect and Restore Minimality, an Extension of the Regular Restriction of Resolution BRUCE SPENCER and J. D. HORTON University of New Brunswick, P.O. Box 4400, Fredericton, New Brunswick, Canada E3B 5A3. e-mail: [email protected], [email protected], http://www.cs.unb.ca (Received: 2 August 1997; accepted: 5 March 1998) Abstract. A given binary resolution proof, represented as a binary tree, is said to be minimal if the resolutions cannot be reordered to generate an irregular proof. Minimality extends Tseitin’s regularity restriction and still retains completeness. A linear-time algorithm is introduced to decide whether a given proof is minimal. This algorithm can be used by a deduction system that avoids redundancy by retaining only minimal proofs and thus lessens its reliance on subsumption, a more general but more expensive technique. Any irregular binary resolution tree is made strictly smaller by an operation called Surgery, which runs in time linear in the size of the tree. After surgery the result proved by the new tree is nonstrictly more general than the original result and has fewer violations of the regular restriction. Furthermore, any nonminimal tree can be made irregular in linear time by an operation called Splay. Thus a combination of splaying and surgery efficiently reduces a nonminimal tree to a minimal one. Finally, a close correspondence between clause trees, recently introduced by the authors, and binary resolution trees is established. In that sense this work provides the first linear-time algorithms that detect minimality and perform surgery on clause trees. Key words: resolution, regularity, theorem proving, binary tree, clause tree. 1. Introduction The regular restriction [15] of binary resolution states that a resolution step resolv- ing on a given literal should not be used to deduce a clause containing that literal. In other words, that resolution step should not be an ancestor of such a clause in the binary derivation tree. We extend this restriction so that it applies also when a reordering of the resolutions brings such a clause below that step. We use rotations of edges in the binary tree to reorder the resolution steps, and require that the rotations neither weaken what is proved nor increase the size of the tree. If a binary resolution proof cannot be made irregular by such rotations, we call it minimal. This extension of regularity depends on sequences of rotations and thus appears to be expensive to compute. However, we characterize it with a condition that can be checked efficiently by examining the static tree. The condition is stated in terms of history paths in the binary resolution tree. Each history path tells the story of

Upload: bruce-spencer

Post on 03-Aug-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Journal of Automated Reasoning25: 1–34, 2000.© 2000Kluwer Academic Publishers. Printed in the Netherlands.

1

Efficient Algorithms to Detect and RestoreMinimality, an Extension of the Regular Restrictionof Resolution

BRUCE SPENCER and J. D. HORTONUniversity of New Brunswick, P.O. Box 4400, Fredericton, New Brunswick, Canada E3B 5A3.e-mail: [email protected], [email protected], http://www.cs.unb.ca

(Received: 2 August 1997; accepted: 5 March 1998)

Abstract. A given binary resolution proof, represented as a binary tree, is said to beminimal if theresolutions cannot be reordered to generate an irregular proof. Minimality extends Tseitin’s regularityrestriction and still retains completeness. A linear-time algorithm is introduced to decide whether agiven proof is minimal. This algorithm can be used by a deduction system that avoids redundancy byretaining only minimal proofs and thus lessens its reliance on subsumption, a more general but moreexpensive technique.

Any irregular binary resolution tree is made strictly smaller by an operation calledSurgery,which runs in time linear in the size of the tree. After surgery the result proved by the new treeis nonstrictly more general than the original result and has fewer violations of the regular restriction.Furthermore, any nonminimal tree can be made irregular in linear time by an operation calledSplay.Thus a combination of splaying and surgery efficiently reduces a nonminimal tree to a minimal one.

Finally, a close correspondence between clause trees, recently introduced by the authors, andbinary resolution trees is established. In that sense this work provides the first linear-time algorithmsthat detect minimality and perform surgery on clause trees.

Key words: resolution, regularity, theorem proving, binary tree, clause tree.

1. Introduction

The regular restriction [15] of binary resolution states that a resolution step resolv-ing on a given literal should not be used to deduce a clause containing that literal.In other words, that resolution step should not be an ancestor of such a clause inthe binary derivation tree. We extend this restriction so that it applies also when areordering of the resolutions brings such a clause below that step. We use rotationsof edges in the binary tree to reorder the resolution steps, and require that therotations neither weaken what is proved nor increase the size of the tree. If a binaryresolution proof cannot be made irregular by such rotations, we call itminimal.

This extension of regularity depends on sequences of rotations and thus appearsto be expensive to compute. However, we characterize it with a condition that canbe checked efficiently by examining the static tree. The condition is stated in termsof history paths in the binary resolution tree. Eachhistory pathtells the story of

2 B. SPENCER AND J. D. HORTON

a given literal. The tail of the history path is a leaf of the tree, and it tells wherethe literal was introduced in an input clause. The history path is said tocloseat thenode where its literal is resolved away. When one history path closes at a node thatoccurs in another history path, and the two paths are disjoint, we say the first his-tory pathdirectly precedesthe other. Theprecedesrelation on history paths is thereflexive transitive closure of directly precedes. See Section 2 for examples of thesedefinitions. History paths and the precedes relation are basic in our understandingof how binary resolution trees behave when rotations are performed. We providesimple conditions on history paths that characterize when one node can be rotatedbelow another (we say it isvisible from the other) and when one node cannot berotated from below another (we then say itsupportsthe other). By examining thehistory paths in a static tree, we can decide much about what can and cannot beaccomplished by sequences of rotations.

In particular, we can say whether rotations can convert a regular tree to an ir-regular one. A theorem prover can use this ability to screen the proofs it builds andretain only the minimal ones. Since every clause with a nonminimal proof is sub-sumed by some clause with a minimal proof, this theorem prover uses minimalityto lessen its reliance on subsumption. The running time of full subsumption growswith the number of retained clauses, which may become very large, while detectingminimality depends linearly on the size of each proof tree, which is typically muchsmaller.

Instead of using minimality simply as a filter, a theorem prover can convert anonminimal proof to a minimal one, using operations defined in this paper. Con-sider the branch of an irregular derivation tree that makes it irregular. This branchcontains the node where some given literal is resolved and, further down, contains aclause in which that literal occurs for a second time. Why resolve the literal away,only to have it reappear later? We can remove the resolution and reconstruct thebranch as closely as possible to the original, with this literal appearing additionallyin some of the clauses. If the second occurrence of the literal is resolved away inthe original tree, then we resolve both occurrences away in the constructed tree.The constructed tree is smaller, and the result it proves is at least as general as theoriginal one. We call this operationSurgery, and define a second operation,Splay,that rearranges a nonminimal tree so that it is irregular. Both operations run intime linear in the size of the tree. A combination of both operations will eventuallyreduce any nonminimal tree to some nonunique minimal one.

The first section below presents the regular restriction on binary resolution trees.In that section we introduce the surgery operation for irregular binary resolutiontrees. Then minimal binary resolution trees are introduced. This section also dis-cusses rotations and the set of rotation equivalent trees, which is all of the trees thatcan be generated from a given tree by a sequence of these rotations. In the followingsection, we discuss the “precedes” relation of history paths and use that to definethe “holds” relation on nodes. We then relate holds and visibility by showing thatif the nearest common descendant of two given nodes holds one of them, then that

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 3

one is not seen by the other, that is, it cannot be rotated below the other. Basedon this condition, we give an efficient algorithm for deciding visibility. We showhow a theorem prover can be restricted to retain only minimal proofs and disregardnonminimal ones, decreasing the number of proofs that must be considered. Thenwe show the splay operation for efficiently converting a nonminimal proof intoan irregular one, so that surgery can further convert it to a minimal one. Thusanother theorem prover can efficiently convert its nonminimal results to minimalones if desired. In the next section we use history paths to characterize support:the condition where one node in a binary resolution tree must be a descendant ofanother after any sequence of rotations.

Both minimality and surgery were first developed for clause trees [5]. Theclause tree is a tool for developing ideas in automated reasoning, and the binaryresolution tree is an efficient, compact data structure to implement clause trees. Inthe next to last section we show the close relationship between binary resolutiontrees and clause trees. Thus, this paper provides the first efficient algorithm forsurgery in clause trees. We close with some remarks on the relation between clausetrees and binary resolution trees and on related work.

This paper is an extension of [14].

2. Binary Resolution Trees

We use standard definitions [2] for atom, literal, substitution, unifier, and mostgeneral unifier. In the following aclauseis an unordered disjunction of literals. Wedo not use set notation because we do not want multiple occurrences of a literalto collapse to a single literal automatically. Thus our clauses can be viewed asmultisets. An atoma occurs ina clauseC if either a or¬a is one of the disjunctsof the clause. The clauseC subsumesthe clauseD if there exists a substitutionθsuch thatCθ ⊆ D (as sets, not as multisets). Avariable renaming substitutionis one in which every replacement of a variable maps to another variable, andno two variables map to the same variable. Two clausesC andD are equal upto variable renamingif there exists a variable renaming substitutionθ such thatCθ = D (as multisets). Two clauses arestandardized apartif no variable occurs inboth. Given twoparent clausesC1 ∨ a1 ∨ · · · ∨ am andC2 ∨ ¬b1 ∨ · · · ∨ ¬bnthat are standardized apart (a variable renaming substitution may be required),their resolvent is the clause(C1 ∨ C2)θ , whereθ is a most general unifier of{a1, . . . , am, b1, . . . , bn}. Theatom resolved uponis a1θ , and the set ofresolvedliterals is {a1, . . . , am,¬b1, . . . ,¬bn}.

It is convenient to define a mappingρ of literals for the resolution operation.This is used later to define history paths.

DEFINITION 1 (Resolution mapping). For each resolution operation we definethe resolution mappingρ from each occurrence of a literalc in each parent clauseeither to the atom resolved upon ifc is a resolved literal or otherwise to the occur-rence ofcθ in the resolvent.

4 B. SPENCER AND J. D. HORTON

Our presentation follows Robinson’s definition of resolution [12], which doesnot use factoring as a separate operation on a clause. Factoring consists of applyinga substitution that unifies two of its literals with the same sign and then removingone of these literals. This operation is not needed in binary resolution trees be-cause if a clause contains two identical or unifiable literals, both can be resolvedon whenever the clause is used in a resolution. By allowing several literals to beresolved on, instead of merging them before the resolution, we have just one typeof internal node in our binary resolution tree, instead of two. (De Nivelle usesresolution nodes and factorization nodes [3].) Moreover, an implementation is freeto merge or factor literals if desired. Factoring may be seen as an optimization ifthe factored clause can be used in several resolution steps, since the factoring isdone only once.

A binary resolution derivation is commonly represented by a binary tree, drawnwith its root at the bottom. Each edge joins aparentnode, drawn above the edge, toachild node, drawn below it. Theancestors(descendants) of a node are defined bythe reflexive, transitive closure of the parent (child) relation. Theproper ancestors(proper descendants) of a node are those ancestors (descendants) not equal to thenode itself. IfT andH are nodes in a tree, thenpath(T ,H) is the unique path fromT toH . Here,T is called thetail andH thehead.

DEFINITION 2. A binary resolution treeon a setS of input clauses is a labeledbinary tree. Each nodeN in the tree is labeled by aclause label, denotedcl(N).Each node either has two parents and then its clause label is the result of a resolu-tion operation on the clause labels of the parents, or has no parents and is labeledby an instance of an input clause fromS. In the case of a resolution, the atomresolved upon is used as another label of the node: the atom label, denotedal(N).Any substitution generated by resolution is applied to all labels of the tree. Theclause label of the root of the binary resolution tree is called theresultof the tree,result(T ). A binary resolution tree isclosedif its result is the empty clause,2.

For the binary resolution tree in Figure 1,S = {a∨ d,¬a∨ b∨¬e, c∨¬d, e∨f ∨ g, a ∨ b ∨ ¬c,¬h,¬a ∨ h,¬b,¬g}. The labels of a nodeN are displayedbeside the name of the node and separated by a colon; for example, the nodeN4

has atom labelc, and clause labela∨ b∨ b∨f ∨g. The order between the parentsof a node is not defined.

If instead of labeling the internal nodes by atoms, one labels each edge with thecomplement of the literal resolved upon, a binary resolution tree would becomean upside down semantic tree, and the leaves of the binary resolution tree wouldbecome failure nodes of the semantic tree.

Using the resolution mappingρ for each resolution operation in the tree, we cantrace what happens to a literal from its occurrence in the clause label of some leaf,down through the tree until it is resolved away. Clearly if all literals are eventuallymapped to the atom label of some internal node, the clause label of the root isempty. In this case by soundness of resolution, the clause labels of the leaves form

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 5

Figure 1. An irregular binary resolution tree.

an unsatisfiable set. Thus we are primarily concerned about tracing the “history”of a literal starting from its appearance in a leaf.

DEFINITION 3 (History path). Let the nodes(N0, . . . , Nn) occur in a binaryresolution treeT such thatN0 is a leaf whose clause label contains a literala,and for eachi = 1, . . . , n,Ni−1 is a parent ofNi . Letρi be the resolution mappingfrom the parents ofNi toNi. Also letρi . . . ρ2ρ1a occur incl(Ni), so thata is notresolved away at anyNi. SupposeNn either is the root ofT or has a childN suchthatρn . . . ρ1a is mapped by the resolution atN to the atom resolved upon atN .ThenP = (N0, . . . , Nn) is ahistory pathfor a. The history path is said tocloseatN if N exists. The nodeNn is thehead, the leafN0 is thetail anda is theliteral ofP , writtenhead(P ), tail(P ), andliteral(P ), respectively.

For example, in Figure 1,(M1,N2,N3) is a history path forc that closes atN4.The two history paths forb in Figure 1, corresponding to the two occurrences ofb, are(M3,N4,N5) and(M0,N1,N2,N3,N4,N5). Both of these close atN6. Theonly history path that does not close is the one forf , which is(M2,N3,N4,N5,N6,N7).

DEFINITION 4 (Regular). A binary resolution treeT is regular if there does notexist a nodeN of T and a descendantM of N such thatal(N) occurs incl(M).

6 B. SPENCER AND J. D. HORTON

The tree in Figure 1 is irregular becauseal(N1) is a anda occurs incl(N4).Irregular trees are never necessary. Why resolve away thea twice? One couldchoose to leave out the resolution atN1, leaving thea in the clause, do the otherresolutions as necessary (not all will be necessary), and later resolvea away, aswas done atN5. OperationSurgerymakes this idea more formal.

A new binary resolution treeT ′ is constructed fromT in whichM0 and all of itsancestors, and possibly otherMi , are removed. However, all leaves ofT ′ are alsoleaves ofT . Thus every history path inT ′ has a corresponding history path inT .The converse cannot be true because the history paths ofT throughM0 do not existin T ′. A new sequence(N ′1,N

′2, . . . , N

′n) is defined in which eitherN ′i = N ′i−1, (i.e.,

Mi is removed) orN ′i corresponds toNi in T .

OPERATION 1 (Surgery on irregular trees).LetT be an irregular binary resolu-tion tree witha = al(N1), (N1,N2, . . . , Nn) being the path of nodes fromN1 to theroot Nn, and withNj , 1 6 j 6 n, being the first node in this path whose clauselabel containsa. LetNi−1 andMi−1 be the parents ofNi for i = 1, . . . , n. LetN0

andM0 be the parents ofN1, so thata occurs in the clause label ofN0 with thesame sign as in cl(Nj ).

procedure Surgery(T ,N1)

LetN ′1 = N0 and let all ancestors ofN0 be inT ′. (M0 and all of its ancestorsare removed.) LetNk be the node at which some history pathPa for a in Njcloses, ifk exists.for i = 2, . . . , n do

if there is a history path inT ′ containingN ′i−1 for which the correspondinghistory path inT closes atNi then

PutMi−1 and all its ancestors intoT ′.DefineN ′i as a new node inT ′ which is the child ofN ′i−1 andMi−1.Let the resolution atN ′i be defined so that the history paths ofT ′i that closeatN ′i correspond to history paths ofT that close atNi.if i = k, then

Let the history path corresponding toPa also close atN ′k. (That is, thesame literals as far as possible are resolved atN ′i as atNi with onepossible addition.)

endifelse

There is no history path containingN ′i−1 which corresponds to a path thatcloses atNi.LetN ′i = N ′i−1. (Mi−1 and all of its ancestors are removed.)

endifendfor

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 7

Figure 2. Surgery on Figure 1.

Note that if the occurrence ofa in Nj is never resolved away, that is, its historypath continues to the root, then the two literals corresponding toa may occur in theroot ofT ′. However, they are both at least as general asa.

Figure 2 shows the effect of surgery on Figure 1. Surgery is performed atN1,usingN4 asNj andk = 5.M0,M2, andM6 are not needed inT ′. By insisting thatboth occurrences ofa are closed at the same node, we ensure thatT ′ does not havea in its result whenT does not. ThusN ′5 closes both history paths fora from N ′1andM3.

THEOREM 1. LetT be an irregular binary resolution tree on a setS of clauses,and letT ′ be constructed by OperationSurgeryon T . ThenT ′ is also a binaryresolution tree onS, T ′ is smaller thanT and the result ofT ′ subsumes the resultof T .

Proof.We use the following lemma: If clausesC1 andC resolve to giveR1, andif clauseC2 subsumesC1, then either the resolution ofC2 andC is not possible andC2 subsumesR1, or it is possible and its result,R2, subsumesR1. This assumes thatall literals fromC resolved in the first resolution are also resolved in the second,and furthermore that literals fromC2 are resolved in the second resolution if theycorrespond (in the subsumption) to literals fromC1 resolved in the first resolution.

Each leaf inT ′ has the same label as a leaf inT , and thereforeT ′ is defined onS.Also, each internal node is defined by a resolution of its parents, soT ′ is a binaryresolution tree. Note thatcl(N ′1) = cl(N0) subsumescl(N1) ∨ a becausecl(N1)

contains all the literals incl(N0) except possiblya. With repeated applications ofthe lemma, it follows thatcl(N ′i ) subsumescl(Ni) ∨ a for i = 2, . . . , n. Also,cl(N ′j ) subsumescl(Nj), sincea occurs incl(Nj). Thencl(N ′i ) subsumescl(Ni)for i = j + 1, . . . , n, so the result ofT ′ subsumes that ofT . SinceM0 is not inT ′and since all other nodes inT ′ are taken at most once fromT , it follows thatT ′ hasfewer nodes thanT . 2

8 B. SPENCER AND J. D. HORTON

Figure 3. A binary tree rotation.

THEOREM 2 (Completeness [15]).If S is unsatisfiable, there exists a closed regu-lar binary resolution tree onS. Furthermore, the smallest closed binary resolutiontree is regular.

Proof. If S is unsatisfiable, there exists a closed binary resolution tree [12]. Ifit is irregular, apply OperationSurgeryrepeatedly until it is regular. This processmust terminate because the tree is smaller at each step.

If the smallest closed binary resolution tree is not regular, surgery can be appliedto it, making a smaller closed tree. 2

3. Minimal Binary Resolution Trees

A rotation of an edge in a binary tree is a common operation in computer science,for example, with AVL trees [1]. Before we apply it to binary resolution trees, wereview the operation on binary trees. Given the binary tree fragment on the left ofFigure 3, a rotation is the reassignment of edges so that the tree on the right ofFigure 3 is produced. The parentC of E becomes the child ofE and the parentBof C becomes the parent ofE. If E has a child inT , thenC takes that child inT ′.In other words, the edges(B,C), (C,E) and(E, F), if F exists, are replaced bythe edges(B,E), (E,C), and(C, F) if necessary.

OPERATION 2 (Edge rotation).Let T be a binary resolution tree with an edge(C,E) between internal nodes such thatC is the parent ofE andC has two parentsA andB. Further, suppose that no history path throughA closes atE. Then theresult of arotationon this edge is the binary resolution treeT ′ defined by resolvingcl(B) and cl(D) on al(E), giving cl(E) in T ′, and then resolving cl(E) with cl(A)on al(C), giving cl(C) in T ′. Any history path closed atC in T is closed atC inT ′; similarly any history path closed atE in T is closed atE in T ′. Also, the childofE in T , if it exists, is the child ofC in T ′.

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 9

A rotation may introduce tautologies to clause labels of internal nodes. Forinstance, ifal(C) occurs incl(D) in T , then cl(E) in T ′ may be tautological.However, the clause label of the root is not changed up to variable renaming(Corollary 4). We prove a slightly more general result first, which is also usedlater.

DEFINITION 5. Let T1 and T2 be two binary resolution trees defined on thesame set of input clauses. ThenT1 andT2 resolve input literals similarlyif there isa one-to-one and onto mappingν from nodes inT1 to those inT2, such that

(1) If N is a leaf, thenν(N) is a leaf, and both are labeled with the same instance(up to variable renaming) of an input clause. Thus there is a natural one-to-onecorrespondence, from literals incl(N) to those incl(ν(N)). Moreover, thismapping of literals provides a mapping from history paths inT1 to those inT2,defined so that they start from the same literal in the input clause, up to variablerenaming. We represent these other two mappings also withν. We require forall history pathsP in T1 that tail(ν(P )) = ν(tail(P )) and literal(ν(P )) =literal(P ) up to variable renaming.

(2) For every history pathP of T1, P closes at a nodeN if and only if ν(P ) closesatν(N).

Thus two binary resolution trees resolve input literals similarly if they resolvethe same input literals against each other, albeit in a possibly different order.

LEMMA 3. If two binary resolution treesT1 andT2 resolve input literals similarly,the result ofT1 and the result ofT2 are the same, up to variable renaming.

Proof.Note thatresult(T1) andresult(T2) are composed entirely of literals fromhistory paths that do not close, and since the same history paths are closed in each,the same literals are not resolved away. Also the composition of mgus inT1 and thatin T2 are unique up to variable renaming, since given a nodeN , the same literalsare unified atN andν(N), up to variable renaming. 2

COROLLARY 4. Given a binary resolution treeT with an internal nodeC andits childE, OperationEdge Rotationgenerates a new binary resolution tree andcl(C) = cl(E) up to variable renaming.

Proof.Observe that OperationEdge Rotationproduces a tree that resolves inputliterals similarly. 2

A rotation changes the order of two resolutions in the tree. Rotations are invert-ible; after a rotation, no history path throughD closes atC, so another rotationat (E,C) can be done, which generates the original tree again. We say that twobinary resolution trees arerotation equivalentif one can be generated from theother by a sequence of rotations. For instance, the first binary resolution tree in

10 B. SPENCER AND J. D. HORTON

Figure 4. From Figure 1 rotate(N4,N5), then(M4,N5).

Figure 4 is produced by rotating the edge(N4,N5) in Figure 1. The second treein Figure 4 is then produced by rotating the edge(M4,N5). Thus, both trees arerotation equivalent to Figure 1. Rotation equivalent is an equivalence relation. Itis not surprising that rotation equivalent binary resolution trees must resolve inputliterals similarly, but the converse is true as well.

THEOREM 5. Two binary resolution treesT1 and T2 are rotation equivalent ifand only if they resolve input literals similarly.

Proof.(⇒) Since one rotation ofT1 creates a binary resolution tree that resolvesinput literals similarly to it, so too does the sequence of rotations creatingT2.(⇐) The converse is proved by induction on the number of internal nodes.

SupposeT1 andT2 resolve input literals similarly. Then they must have the samenumbern of internal nodes since they have the same number of leaves. Ifn = 0

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 11

or n = 1, then no rotation is possible and the theorem holds. LetN be a node inT1 with parentsL1 andL2 that are leaves. Then inT2, ν(N) has proper ancestorsν(L1) andν(L2), which also are leaves, andν(N) closes only history paths withtailsν(L1) andν(L2). We createT ′2 by rotating edges ofT2 so thatν(L1) andν(L2)

become parents ofν(N), if this is not already the case. LetC be either parent ofν(N), and letA andB be the parents ofC. If ν(L1) andν(L2) are both ancestorsof C, then neither is an ancestor of the other parent ofν(N). But ν(N)must close ahistory path from that other parent, contradiction. Thus the edge(C, ν(N)) can berotated, since not bothA andB contain a history path closing atν(N). This rotationreduces the total number of nonleaf ancestors ofν(N). After a finite number of suchrotations, both parents ofν(N) are leaves. Call this treeT ′2.

Let T ∗1 beT1 with leavesL1 andL2 deleted, and letT ∗2 beT ′2 with leavesν(L1)

andν(L2) deleted. ThenT ∗1 andT ∗2 resolve input literals similarly, sinceT1 andT ′2 resolve input literals similarly. By inductionT ∗1 andT ∗2 are rotation equivalent.The sequence of rotations to convertT ∗1 to T ∗2 will also convertT1 to T ′2, which isrotation equivalent toT2. 2

We focus on the set of rotation equivalent trees that do not contain an irregularbinary resolution tree. Any tree in this set is said to be minimal, since surgerycannot be applied to make it smaller.

DEFINITION 6. A binary resolution treeT is minimalif no sequence of rotationsof edges generates a treeT ′ that is irregular.

THEOREM 6. If a binary resolution treeT on S is nonminimal, there exists aminimal binary resolution treeT ′ onS that is smaller thanT , and the result ofT ′subsumes the result ofT .

Proof. If T is not minimal, apply edge rotations and surgery operations so thata regular tree is produced. If this tree is minimal, then letT ′ be this tree. Otherwiserepeat from the beginning untilT ′ is defined. This process must terminate becausethe tree is getting smaller at each application of OperationSurgery. Also the oldresult is subsumed by the new result at each step. 2

4. Checking Minimality

Determining whether a given binary resolution tree is minimal seems to be la-borious, since the straightforward application of the definition, as is done in theproof of Theorem 6, checks every possible sequence of rotations, and there can beexponentially many. In this section we give an efficient algorithm for determiningvisibility – which nodes can be rotated below which – so deciding minimality isefficient.

12 B. SPENCER AND J. D. HORTON

DEFINITION 7 (Visible). In a given binary resolution tree with internal nodesN

andM, we say thatM is visible from N and thatN canseeM if there exists asequence of rotations such thatM is a descendant ofN . OtherwiseM is invisiblefromN .

Thus a node can see the nodes that can be rotated below it. Although thisis a property defined in terms of rotations, it is possible to inspect a static tree,without doing any rotations, to determine visibility. Because of this, visibility canbe computed in linear time. That static property, holds, is defined after one moreconcept, precedes.

DEFINITION 8 (Precedes). A history pathP directly precedesa history pathQif P andQ have no nodes in common, andP closes at some node inQ. We writeP ≺ Q. Moreover, we sayP precedesQ, and writeP ≺∗ Q if there is a sequenceof history paths(P1, . . . , Pk) with P = P1 andQ = Pk andPi directly precedesPi+1 for i = 1, . . . , k − 1. A history pathP precedesa nodeN if N closes somehistory pathQ andP ≺∗ Q.

The precedes relation on history paths is the reflexive and transitive closure ofdirectly precedes. In particular, a history path precedes itself, even though it doesnot directly precede itself. Also note that precedes defines a partial order on the setof history paths.

In most cases a rotation does not change the precedes relation on history paths.

LEMMA 7. Let the history pathP precede the history pathQ in the binary res-olution treeT , and letP ′,Q′, andT ′ be the images ofP,Q, andT , respectively,after a rotation of the edge(C,E) in T as in the definition of edge rotation. Furthersuppose that inT the head ofQ is notC. ThenP ′ precedesQ′ in T ′.

Proof. If the tail of P is not an ancestor ofE, then the rotation cannot affectwhetherP ′ ≺∗ Q′. Assume thattail(P ) is an ancestor ofE. LetTA, TB , andTD bethe subtrees ofT rooted atA,B, andD, respectively. If the node at whichP closesandhead(Q) are in the same one of these subtrees, again the rotation has no effecton whetherP ′ ≺∗ Q′. Assume that they are not in the same subtree. We know thathead(Q) is a descendant of the node at whichP closes, sohead(Q) cannot be inany of the subtreesTA, TB , or TD. Also head(Q) is notC so head(Q) must be a(nonstrict) descendant ofE.

Now if tail(P ) and tail(Q) are in the same subtreeTA, TB or TD, then therotation does not affectP ′ ≺∗ Q′ because the node ofQ thatP precedes is also inthat subtree.

Assume thattail(P ) andtail(Q) are not in the same subtreeTA, TB , or TD. LetP1 be the path closing at the node ofQ thatP precedes. ThusP ≺∗ P1 ≺ Q. Wehave these cases, which are illustrated in Figure 5.

(1) tail(Q) is in TA. If tail(P ) is in TB , thenP1 closes atC. After the rotation,P ′1,which is one node longer, closes atC in T ′. P ′ ≺∗ P ′1 ≺ Q′.

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 13

Fig

ure

5.C

ases

ofL

emm

a7.

14 B. SPENCER AND J. D. HORTON

Otherwisetail(P ) is in TD. LetP0 denote a path throughB closing atC. Afterthe rotationP ′ ≺∗ P ′1 ≺ P ′0 ≺ Q′.

(2) tail(Q) is in TB . If tail(P ) is in TA, then after the rotationP ′ ≺∗ P ′1 ≺ Q′.Otherwise, iftail(P ) is in TD, then after the rotation,P ′ ≺∗ P ′1 ≺ Q′.

(3) tail(Q) is in TD. Since no path throughA closes atE, we knowtail(P ) is notin TA. Thustail(P ) is in TB . After the rotation,P ′ ≺∗ P ′1 ≺ Q′.

(4) tail(Q) is not an ancestor ofE. In T , there is a pathR such thatP ≺ R ≺ QandE is onR. By the cases aboveP ′ ≺ R′ in T ′. AlsoR′ ≺ Q′ in T ′, since theprecedes relation of paths that close belowE are not affected by the rotation.2

DEFINITION 9 (Hold). Two history pathsP1 andQ1 directly hold an internalnodeM of a binary resolution tree ifM is the first node that occurs on bothP1 andQ1 (i.e., neither parent ofM occurs on both). We say that history pathsP andQholdM if there exist history pathsP1 andQ1 such thatP1 ≺∗ P,Q1 ≺∗ Q whileP1 andQ1 directly holdM. A nodeN holdsM if P andQ holdM and bothP andQ close atN . Also, if P andQ holdM and are in a set of history paths, we saythat the set holdsM.

The following theorem relates “invisible”, a property that depends on all ro-tation equivalent trees, to “holds”, a property that can be checked by examiningjust the one tree of interest. Consider the second tree of Figure 4. In this treeN5 isvisible fromN4, and hence also fromN1. This can be seen by undoing the rotationsperformed, resulting in Figure 1, whereN5 is a descendant ofN4. This can also beobserved directly, without undoing the rotations, by noting thatN4 does not holdN5 in the second tree of Figure 4. The history paths aboveM4 are shown in the firstpart of Figure 6. No path fromL2 precedesN4.

WhenN5 is rotated belowN4 it becomes a descendant ofN1 also, and thisbrings about an opportunity for surgery to be applied.

Now if ¬c had occurred atL2 and was resolved away atN4, then a new historypath would exist fromL2 toM4. ThenN5 would be directly held byN4 via the twopaths for¬c, as shown in the second part of Figure 6. If¬c were instead added toL1, then a new history path fromL1 toM4 would exist, andN5 would be directlyheld by the path forh and a path for¬c. N5 would be held by both paths for¬cclosing atN4, since the path forh directly precedes the new path for¬c. This isshown in the third part of Figure 6. In both the second and third treesN5 is notvisible fromN4.

THEOREM 8. In a binary resolution tree, the nearest common descendant of twointernal nodesM andN holdsM if and only ifM is invisible fromN .

Proof. (⇒) We show that if the nearest common descendant ofM andN holdsM, then after a rotation, the (possibly new) nearest common descendant ofM andN holdsM. ThusM can never be a descendant ofN , for if it were, then the nearestcommon descendant would beM. But a node cannot hold itself. Cases in the proofof the forward direction are shown in Figure 7.

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 15

Figure 6. N4 does not holdN5 in the first tree, but does in the others.

Let F be the nearest common descendant ofN andM, let the rotated edge be(C,E), and let nodesA,B andD adjacent to it be as defined in OperationEdgeRotation. Let P andQ holdM and close atF , while P1 andQ1 directly holdM,andP1 ≺∗ P andQ1 ≺∗ Q.

In Cases 0 and 1, supposeF 6= E, so that after the rotationF is still the nearestcommon descendant ofM andN . ThenC is not the head ofP orQ. By Lemma 7,P ′1 ≺∗ P ′ andQ′1 ≺∗ Q′. Suppose (Case 0)M 6= E. Then after the rotation,M isstill the first common node onP ′1 andQ′1, soF still holdsM.

Now suppose (Case 1) thatM = E. Without loss of generality assume thatP1

containsC andQ1 containsD. If (Case 1a)P1 containsB, then after the rotation,P ′1 andQ′1 still hold E, soF holdsM. If (Case 1b)P1 containsA, then considerthe pathR containingB and closing atC. After the rotation,R′ ≺ P ′1 ≺∗ P ′, sothatR′ andQ′1 holdE, so againF holdsM.

For Cases 2 and 3, suppose thatF = E. If (Case 2)M is an ancestor ofC, thenN is eitherE or an ancestor ofD. Since no history path can containA andC andclose atE, M 6= C. For the same reason,P andQ containB and close atE. If(Case 2a)M is an ancestor ofA, then the paths that directly precedeP andQclose atC and holdM. ThusC holdsM. After the rotation the nearest commondescendant ofM andN isC, andC still holdsM. Otherwise (Case 2b) ifM is anancestor ofB, then after the rotation the nearest common descendant ofM andNisE andE still holdsM.

Finally consider the case (Case 3) whereM is an ancestor ofD. If (Case 3a)Nis eitherE or an ancestor ofB, then after the rotation,E still holdsM and is stillthe nearest common descendant ofN andM. If (Case 3b)N isC or is an ancestorof A, then consider pathR with head atB which closes atC. After the rotation, thenearest common descendant ofM andN is C, whileR′ directly precedes bothP ′andQ′. ThusC holdsM after the rotation.(⇐) Conversely, suppose thatM is not held by the nearest common descendant

F of M andN . We generate a sequence of rotations so thatM is a descendant ofN . If F = M, thenM is a descendant ofN and therefore visible fromN . If F isthe child ofM, then the edge(M,F) can be rotated becauseM is not held byF .This rotation makesM a descendant ofF and therefore ofN . Now supposeF is

16 B. SPENCER AND J. D. HORTON

Fig

ure

7.C

ases

ofT

heor

em8.

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 17

a proper descendant of the child ofM. There exists a path(H0,H1, . . . , Hn) forn > 1 whereF = Hn, M = H1, so thatHi−1 andKi−1 are the parents ofHi, fori = 1, . . . , n. We use induction onn. Without loss of generalityK0 is chosen sothatal(H2) occurs incl(K0); thus a history path throughK0 closes atH2. If thereexistsi in {2, . . . , n} such that no history path throughHi−2 closes atHi, then theedge(Hi−1,Hi) can be rotated, shown as Rotation 1 in Figure 8. We say thatHihas been rotated to the side of thepath(M,F), and soM is now closer toF andthe theorem holds by induction.

Thus for eachi in {2, . . . , n}, some history path throughHi−2 closes atHi. Ifthere is noj in {1, . . . , n} such thatHj is held byF , then in particularHn−1 is notheld so the edge(Hn−1,Hn) can be rotated, rotatingNn−1 off the bottom of the path.This is shown in Figure 8 as Rotation 2. But then the distance fromM to the nearestcommon descendant ofM andN isn−1 edges, and the theorem holds by induction.Choose the smallestj in {1, . . . , n} so thatHj is held byF . Note thatj 6= 1 byassumption. If there is a history path throughKj−2 closing atHj , then this pathand the path throughHj−2 closing atHj directly holdHj−1. ThusHj−1 is held byF , contradicting the definition ofj . Therefore, no such path throughKj−2 exists,and the edge(Hj−1,Hj) can be rotated as illustrated in Rotation 3 of Figure 8. Ifj = 2, thenH1 is closer toF after the rotation; we say thatHj has been rotated offthe top of thepath(M,F), and the theorem holds by induction. Otherwise considerthe history paths throughHj−2 closing atHj . If one of these includesHj−3 andanother includesKj−3, thenHj−2 is held byF after the rotation. This means thatHj−2 was held byF before the rotation, contradicting the definition ofj . Thusthe edge(Hj−2,Hj−1) can be rotated. The result of this rotation is thatHj will berotated either to the side of thepath(M,F), or closer toM. By a second inductionon the distance fromM to Hj , Hi will eventually be rotated off the top or to theside. Thus the distance fromM to F will decrease by the constructed sequence ofrotations. 2

The sequence of rotations, constructed in the proof of the converse direction ofTheorem 8, rotates the visible nodeM to below the nodeN that can see it. Thus ifthe tree were regular but nonminimal, the rotations would make it irregular, expos-ing the nonminimal parts. Using surgery, we can remove all nonminimal sectionsof a tree, and reconstruct a minimal tree from the pieces left behind.

As an example, consider the second tree of Figure 4, whereN5 is visible fromN1. We generate the sequence of rotations to bringN5 belowN1. The commondescendant isN4. The path ofH ’s is (M3,N5,M4,N4). The first step of the con-struction in the converse proof above, to show the visibility, is to rotate edge(N5,M4), as no path throughM3 closes atM4. This rotatesM4 to the side, togive the top tree of Figure 4. Now the path ofH ’s is (M4,N5,N4). Since no paththroughM4 closes atN4, N4 can be rotated to the side by rotating edge(N5,N4).N5 is now a descendant ofN1 as in Figure 1.

18 B. SPENCER AND J. D. HORTON

Rotation 1: to the side

Rotation 2: off the bottom

Rotation 3: off the top

Figure 8. Rotations in the proof of Theorem 8.

Unfortunately the number of rotations required to expose a nonminimality maybe quadratic in the length of the path in the tree. Since the trees are not balanced,this is quadratic in the size of the tree in the worst case. Later we give a linear timeoperation, calledSplay, to bring a visible node to a descendant. In the next section,however, we detect and avoid nonminimal trees.

5. Minimality as a Restriction

Now we turn our attention to a theorem prover that keeps only minimal binaryresolution trees. Since every nonminimal tree is subsumed by some minimal tree,

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 19

this strategy uses the minimal criteria to reduce redundancy, lessening reliance onsubsumption.

DEFINITION 10. LetT be a binary resolution tree. Thenatoms(T ) = {al(N)|Nis a node ofT } is called theset of atomsof T . A subbrtof T is a binary resolutiontree whose node set consists of a node ofT called the root of the subbrt, and all ofits ancestors. For a subbrtT ′ of T , V is(T ′) = {al(N)|N is a node ofT ′ andN isVisvisible from the root ofT } is called the set ofvisible atoms ofT ′.

THEOREM 9. Let a binary resolution treeT consist of a root nodeR and twosubbrt’sT1 andT2. T is minimal if and only if

(1) T1 andT2 are minimal,(2) no atom in cl(R) is in atoms(T ),(3) atoms(T1) ∩ V is(T2) = φ, and(4) atoms(T2) ∩ V is(T1) = φ.

Proof. Assume thatT is minimal. If T1 or T2 were not minimal, then therewould be a sequence of edge rotations that would make the subbrt irregular. Thesame sequence performed onT would makeT irregular as well. Hence the firstcondition is true. If the second condition were false, thenT would be irregularimmediately. Assume that the third condition is false. Then there are two nodes,N ∈ T1 andM ∈ T2 whose atom labels are the same, andM is visible fromR.Also M can be rotated belowR, without rotating any edges inT2. Now M is adescendant ofN , makingT irregular, because the parent ofM betweenN andMmust haveal(N) in its clause label. The fourth condition is symmetric to the third.

Conversely, assume thatT is not minimal. Then there is a sequence of rotationsthat create an irregular treeT ′. Some nodeN has a descendantM1 in T ′ such thatal(N) occurs incl(M1). Since the rotations do not changecl(R), if al(N) occurs inthe result ofT ′, it occurs incl(R) in T , and thenT violates the second condition.Thusal(N) does not occur incl(R), so there is a descendantM of N in T ′ suchthatal(N) = al(M). Back inT , M is visible fromN . Hence inT by Theorem 8,the nearest common descendant ofM andN – call it F – does not holdM. If MandN are in the sameTi thenF is also inTi and does not holdM. ThusM isvisible fromN in Ti. ThenTi is not minimal and violates the first condition.

AssumeM andN are in differentTi . SinceM has been rotated belowN , Mis visible fromN in T , and by Theorem 8M is not held by the nearest commondescendantR ofM andN . ThusM is visible fromR. Thereforeal(M) is in Vis(Ti)while al(N) is in atoms(T3−i). This violates condition 3 or 4. 2

Any theorem prover based on binary resolution that keeps only minimal treeshas already satisfied the first condition in Theorem 9 for any newly constructedtree, since only minimal trees are used in the construction. It is easy to check thatthe new result does not contain an atom inatoms(T ). What is left is to find an easyway to calculate those atoms in each subbrtTi that are visible from the root ofT .

20 B. SPENCER AND J. D. HORTON

Vis(N,PN) returns the atoms labels of nodes at and above nodeN in T visiblefrom the root ofT , wherePN is the paths throughN that precede the root. The ideain procedureVis is that a node is visible from the root if and only if it is not heldby the root, by Theorem 8. So for each nodeN we need to calculate the historypaths going through it that precede the root. If some of these paths go through oneparent ofN , and some go through the other, thenN is held by the root; otherwiseN is visible from the root.

In each procedure callVis(N,PN), the first argumentN is a node in the tree,and we want to know whether or not it is held by the root. Initially it is one of theparents of the root, but as we traverse upward, it becomes instantiated with eachancestor of this parent. The invariant we maintain is that the second argument,PN ,is the set of paths that includeN and precede the root. The paths through the parentof the root that precede the root are simply those whose heads are that parent, sothe invariant is easy to establish in the first place. SupposeN has parentsA andB.To calculate the pathsPB throughB that precede the root, we start withPN , andremove those paths that go throughA if there are any. If there are none, thenPB

is PN . If there is some path inPN throughA, we need to add toPB any path withhead atB, since these paths precede that path throughA, and thus precede the root.

Since we know that the paths inPN must go through at least one of the parentsof N , we assume thatB is that parent.

procedure Vis(N,PN)

if N is a leafthen return φelse

Let A andB be the parents ofN and partitionPN into PA andPB , whichare the sets of paths that go throughA and throughB, respectively. Assumewithout loss of generality thatB is chosen so thatPB is nonempty.LetCA andCB be the sets of history paths with heads atA andB respectively,and hence close atN .if PA is nonemptythen

//N is held

return Vis(A,PA ∪ CA) ∪ V is(B,PB ∪ CB);

else//PA = φ andN is not held, so it is visible

return {al(N)} ∪ Vis(A,CA) ∪ Vis(B,PB)

endifendif

The third and fourth conditions in Theorem 9 require us calculateVis(Ti) whichis done by callingVis(Ri,Qi ), whereR is the root of the binary resolution tree,R1

andR2 are the parents ofR, andQi is the set of paths with heads atRi.

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 21

ProcedureVis runs in a number of set union calculations that is proportional tothe number of nodes in the tree. With hashing, these operations can in principle beperformed in time proportional to the size of the clauses. HenceVis is a linear-timealgorithm, which is as fast as one could expect.

6. Restoring Minimality

There are two basic ways to restore minimality. If a binary resolution tree is irregu-lar, then the surgery operation removes the nonminimality. For a binary resolutiontree that is regular but nonminimal, some rotations need to be done to make itirregular – we call thisexposingthe nonminimality. This irregularity involves twointernal nodesM andN that resolve upon the same atoma and neither is a descen-dant of the other but (at least) one is visible from the other. SupposeM is visiblefromN . WhenM is rotated belowN , one parent ofM also becomes a descendantof N . Sincea occurs in that parent’s clause label, surgery fromN can be done.

In the proof of the converse of Theorem 8 we gave a quadratic length sequenceof operations for moving visible nodes down to become descendants. OperationSplayuses a linear number of operations. It is related to the splay operation [13]for binary trees in that it brings a node closer to the root. In our case, to splaya binary resolution tree atM, we divide the descendants ofM into two sets: theobserversO for those that can seeM, and the nonobserversO for those that cannot.Then we rearrange the tree so that all the nodes inO are ancestors ofM, leavingjust those nodes inO as descendants ofM. ThusM is brought as close to the rootas possible. This is done in a way that guaranteesN is an ancestor ofM, so thatsurgery can be accomplished.

The first step in theSplay is to determine theobserversof M, which are thedescendants ofM that can seeM. ProcedureObsdoes this. Given a nodeM in abinary resolution treeT such thatP1 is the complete set of history paths containingbothM and one parent ofM andP2 is the paths containingM and the other parent,Obs(M,P1,P2) returns the set of proper descendants ofM that can seeM.

procedure Obs(M,P1,P2)

if M is the root ofT thenreturn φ

elseLetD be the child ofM and letK be the other parent ofD.Let C1 be the paths fromP1 that close atD andC2 be the paths fromP2 thatclose atD.Let K be the paths that contain bothK andD.

if C1 6= φ andC2 6= φ then//D holdsM

22 B. SPENCER AND J. D. HORTON

return Obs(D,K ∪P1− C1,K ∪P2− C2)

else ifC2 = φ thenreturn {D} ∪Obs(D,K ∪P1− C1,P2)

else//C1 = φreturn {D} ∪Obs(D,P1,K ∪P2− C2)

endifendif

Every timeObsis called, every pair of paths one fromP1 and the other fromP2

holds the initialM. If we ever find a descendantD that closes a member of each,thenD holdsM and so cannot seeM, and thereforeD is not returned; otherwiseit is returned as part of the final set of observers. To maintain the invariant as wego fromM toD, if D closes paths inPi, we need to add toPi all of the pathsKthat come fromK throughD, because each one of these paths precedes a path thatcontainsM. If D does not close any path throughPi , then we have nothing to addto Pi. In either case we remove fromPi any path that closes atD, since these donot containD.

OperationSplayuses code similar to procedureObs, but not the procedure itself,to decide how the resolutions belowM should be re-ordered in the new tree. TheparentsS1 andS2 of M are considered stubs to be built upon. The observers ofM are put into one of two queuesQ1 andQ2, and the nonobservers are put intoQ3. Along with each node put in the queue, we also put the subtree rooted at theother parent of the node, so that the resolution can be reconstructed later. Those putintoQ1 become descendants ofS1, while those inQ2 become descendants ofS2.After this is done, the two subtrees are joined by a resolution corresponding toM.Finally all of the nodes inQ3 are made descendants ofM. Each of the resolutionsis done so that all of the history paths closed at a node in the given tree are closed atthe same node in the constructed tree. Thus the resulting tree resolve input literalssimilarly with the given tree.

OPERATION 3 (Splay).A splay at an internal nodeM in a binary resolution treeT produces a new binary resolution treeT ′ such that all descendants ofM cannotseeM in T ′.

All resolutions in this operation must be done so that the resulting binary reso-lution tree resolves input literals similary withT .

procedure Splay(T ,M)

Initially Q1,Q2 andQ3 are three empty queues.Initially P1 is the set of history paths throughM and one parentS1 ofM, whileP2 is the set of history paths throughM and the other parentS2 of M.call Splay1(M,P1,P2)

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 23

return ProcessQ(

resolve(ProcessQ(S1,Q1), ProcessQ(S2,Q2)),

Q3)

procedure Splay1(M,P1,P2)

if M is the root ofT thenreturn

elseLetD be the child ofM and letK be the other parent ofD.Let C1 be the paths fromP1 that close atD andC2 be the paths fromP2 thatclose atD.Let K be the paths that contain bothK andD.

if C1 6= φ andC2 6= φ then//D holdsM

enqueueD and the subtree rooted atK intoQ3

Splay1(D,K ∪P1− C1,K ∪P2− C2)

else ifC2 = φ thenenqueueD and the subtree rooted atK intoQ1

Splay1(D,K ∪P1− C1,P2)

else//C1 = φenqueueD and the subtree rooted atK intoQ2

Splay1(D,P1,K ∪P2− C2)

endifendif

procedure ProcessQ(T ,Q)

if Q is emptythen return Telse

dequeueT1 andN fromQ leavingQ1

constructT2 by resolvingT andT1 making them parents ofN

return ProcessQ(T2,Q1)

endif

For example, the binary resolution tree in Figure 9 shows the result of perform-ing a splay from the nodeM = N5 on the second tree in Figure 4. The subtreesS1

andS2 are the leaves labeleda∨b∨¬c, and¬a∨h, respectively. The descendantsofN5 areM4,N4,N6 andN7, of whichN4,N6 andN7 are put intoQ1, whileM4 isput intoQ2. These end up aboveN5 in the resulting tree, andN5 becomes the root,since every node can seeN5.

24 B. SPENCER AND J. D. HORTON

Figure 9. Result of OperationSplayatN5 on the second tree in Figure 4.

LEMMA 10 If T is a binary resolution tree andM is an internal node ofT , thenthe resultT ′ of Splay(T ,M) is a binary resolution tree.T ′ is defined on the sameset of clauses asT, is the same size asT and has the same result asT .

Proof.T ′ resolves input literals similarly toT . 2OPERATION 4 (SplaySurgery).Let T be a binary resolution tree containing apair M,N of nodes such that al(M) = al(N) andN can seeM.

procedure SplaySurgery(T ,M,N).

if M is a descendant ofN in T thenreturn Surgery(T ,N)

elsereturn Surgery(Splay(T ,M),N)

endif

To see that a splay actually bringsM below N , so that surgery is possible,suppose that the nearest common descendant ofM andN is notM. Thus eitherN is that nearest common descendant orN andM are on different branches.N iseitherD or an ancestor ofK at some point inSplay1. We also knowN can seeM,so it must be put into one of the queuesQ1 orQ2 and cannot be part ofQ3. Thuswhen the tree is rebuilt,N is put in while we are processing eitherQ1 orQ2.M isput in afterQ1 andQ2 are empty, so it is belowN .

Returning to our example, after the splay, the nodeN5 in Figure 9 is belowN1

and surgery fromN1 can be done. The result of this surgery is the same as that

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 25

shown in Figure 2. Notice that in this example we also have the option to splayat N1 and do surgery fromN5, sinceN1 is also visible fromN5. The resultingtree would be different: it would not require the leaf¬a ∨ h nor¬h, and its resultwould have beenf . Thus splay surgery does not produce a unique result. However,its result is at least as general, and the tree is always smaller.

SplaySurgerydoes a linear number of set operations, since it does at mostn

resolution steps wheren is the length of a branch, and then performs surgery, whichitself does a number of resolutions limited by the length of a branch. Thus it iseffectively a linear-time algorithm.

7. Support

Often a node that is visible from another can be rotated so that it is not a descendant,but sometimes no sequence of rotations can bring a node from below another. Inthis case we say the nodesupportsthe other, since it is always beneath it. Support,like visibility, is a property that depends on the entire set of rotation equivalenttrees. In this section we characterize support in terms of history paths, so it can bechecked by examining a static tree.

DEFINITION 11 (Support). A nodeN in a binary resolution treeT supports anodeM if after every sequence of rotations,M is an ancestor ofN .

DEFINITION 12 (Tightly holds). Two history pathsP = Pm andQ = Qn tightlyhold a nodeN if there exist two sequencesP1, . . . , Pm andQ1, . . . ,Qn of historypaths such that

(1) for i = 1, . . . ,m− 1, Pi ≺ Pi+1,(2) for j = 1, . . . , n− 1,Qj ≺ Qj+1,(3) the pairP1 andQ1 directly holdsM, and(4) for no pairi, j,1 6 i < m and 16 j < n does the head ofPi equal the head

of Qj .

A nodeN tightly holdsM if both P andQ close atN .

Tightly holds is the special case of holds, where no two paths in the sequenceshave the same head except the bottom two. This turns out to be the exact conditionfor one node being below another after every sequence of rotations.

THEOREM 11. In a binary resolution tree, an interior nodeN tightly holds aninterior nodeM if and only ifN supportsM.

Proof. (⇒) We show that ifN tightly holdsM before a rotation, it also doesafterwards, and thus must be a descendant ofM. Consider a rotation of edge(C,E)where nodesA,B,C,D andE are defined as in OperationRotation. Also let

26B

.SP

EN

CE

RA

ND

J.D.H

OR

TO

NFigure 10. Cases showing tightly holds is invariant under rotations.

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 27

Case 1

Case 2

Figure 11. Cases showing support implies tightly holds.

P1, . . . , Pm andQ1, . . . ,Qn be the paths by whichN tightly holdsM. We indicatethe image of any history pathP after the rotation byP ′.

At first assume that{C,E} is disjoint from{M,N}. By Lemma 7,P ′1 ≺∗ P ′mandQ′1 ≺∗ Q′n. Before the rotation all heads of paths in the sequences were distinctso they must be distinct after the rotation, unless there is a new path in eitherof the sequences. There is one case where such a new path occurs. In Lemma 7,the new pathP0 is introduced whentail(Q) is in TA and tail(P ) is in TD. In thatcase the head of the new history path was not onpath(M,N). Thus the headsof paths of the new sequences(P ′1, . . . , P

′m) and(Q′1, . . . ,Q

′n) are distinct except

head(P ′n) = head(Q′n). Also M is still directly held byP ′1 andQ′1 soN tightlyholdsM.

Now suppose{C,E} is not disjoint from{M,N}. (Case 1) IfC = M, thenwithout loss of generality letP1 containA andQ1 containB. We know thatP1

does not close atE, since the rotation is possible. Suppose first thatQ1 does notclose atE, as in Figure 10.1a. Then after the rotationC is directly held byP ′1 andQ′1 and so is tightly held byN . Now supposeQ1 closes atE, as in Figure 10.1b.Note thatQ2 must exist, since otherwiseE holdsM. ThusQ1 andP1 both close atE = N , and then the rotation is not possible. After the rotation,C is directly heldbyP ′1 andQ′2, and so is still tightly held byN .

(Case 2). Now letC = N . Both Pm andQn close atN , and either they bothincludeA, as in Figure 10.2a, or they both includeB as in Figure 10.2b. In either

28 B. SPENCER AND J. D. HORTON

case, after the rotation,N tightly holdsM by the sequences(P ′1, . . . , P′m) and

(Q′1, . . . ,Q′n).

(Case 3). Now ifE = M, then assume without loss of generality thatC is inP1 andD is in Q1. If A is also inP1 as in Figure 10.3a, then there is a pathP0

with head atB andP0 ≺ P1. After the rotation, the sequences(P ′0, P′1, . . . , P

′m)

and(Q′1, . . . ,Q′n) ensure thatN tightly holdsM. If B is in P1, as in Figure 10.3b,

then after the rotation the paths(P ′1, . . . , P′m) and(Q′1, . . . ,Q

′n) ensureN tightly

holdsM.(Case 4). Finally ifE = N , then eitherPm andQn both containC or both

containD. If they both containC, then note that they both contain the same parentB of C; else the rotation is not possible. Then after the rotation,B is a parent ofEand althoughP ′m andQ′n are one node shorter than before,N tightly holdsM bythe paths(P ′1, . . . , P

′m) and(Q′1, . . . ,Q

′n). If Pm andQn both containD, then after

the rotation there is no change to the history paths; thusN tightly holdsM.(⇐) AssumeM supportsN . We construct the pair of sequences of history

paths by whichM tightly holdsN . We induct on the length ofpath(M,N) =(N1,N2, . . . , Nk), whereM = N1,N = Nk, andNi is a parent ofNi+1 fori = 1, . . . , k − 1. If k = 2,M is a parent ofN , and then a rotation of the edge(M,N) is possible unless there exist history paths that tightly holdM and closeatN . Supposek > 2. First assume (Case 1) thatNk does not supportNk−1. Thenby the first half of this theoremNk does not tightly holdNk−1 and so the edge(Nk−1,Nk) can be rotated. SinceM must remain an ancestor ofN, M must be anancestor ofB in the rotation, as shown in Figure 11.1. Thus the path fromM toNis shorter, and by inductionN tightly holdsM in the new binary resolution tree. Byrotating the edge back again, one sees thatN tightly holdsM in T , because tightlyholds is invariant under rotation. As this case is covered, from now on we assumethatNk supportsNk−1.

Next assume (Case 2) thatNk does not supportNk−2. ThenNk−1 does notsupportNk−2, for otherwiseNk supportsNk−1 supportsNk−2 and, by transitivityof support, there is a contradiction. By the first half of this theorem, we may rotatethe edge(Nk−2,Nk−1). Then we may rotate the edge(Nk−2,Nk), sinceNk doesnot tightly holdNk−2. In this second rotation,Nk must remain a descendant ofNk−1 so it must be as shown in the third binary resolution tree in Figure 11.2. Thuspath(M,N) is shorter, so by inductionN tightly holdsM. Because tightly holdsis invariant under rotation,N tightly holdsM in T also. From now on we assumethatNk supportsNk−2. By similar arguments we assume thatNk supports each ofNk−3, . . . , N2.

(Case 3). If the edge(M,N2) can be rotated inT , thenpath(M,N) is shorter inthe resulting treeT ′, and by inductionN tightly holdsM in T ′. Since tightly holdsis invariant under rotation,N tightly holdsM in T .

Finally, if the edge(M,N2) cannot be rotated, then there are paths from eachparent ofM closing atN2 in T . We know by induction thatN tightly holdsN2 andassume that(P1, . . . , Pm) and(Q1, . . . ,Qn) are the paths that make this so. Either

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 29

P1 orQ1 includesN1 = M. Assume without loss of generality thatP1 includesN1.ThenQ1 must include the other parent ofN2, sinceN2 is the first node thatP1 andQ1 have in common. No matter which parent ofM is in P1, there is a path closingatN2 containingM andM ’s other parent. Call this pathQ0. Since the head ofQ0

isM, it is distinct from the heads of the otherPi andQj in the sequences. ThusNtightly holdsM by the paths(Q0,Q1, . . . ,Qn) and(P1, . . . , Pm). 2

In this final theorem, we relate the notions of visibility and support.

THEOREM 12. In a binary resolution tree, a nodeM is invisible from a nodeNiff there is a supportS ofM on path(M,N).

Proof. (⇒) AssumeM is invisible fromN . Let D be the nearest commondescendant ofM andN . Consider the path sequencesP1, . . . , Pm andQ1, . . . ,Qn

by whichD holdsM. Consider the leasti andj such thathead(Pi) = head(Qj),and letS be the node wherePi andQj both close. Thesei andj must exist becausethehead(Pm) = head(Qn). Since the heads of paths beforePi andQj are distinct,S tightly holdsM and thusS supportsM.(⇐) Assume thatS on path(M,N) is a support ofM. Let P1, . . . , Pm and

Q1, . . . ,Qn be the sequences of paths by whichS tightly holdsM. SinceS is onpath(M,N), andS is a descendant ofM, S must be an ancestor of the nearestcommon descendantD of M andN . Thus there are pathsR1, . . . , Rk, whereRi ≺Ri+1 for i = 1, . . . , k − 1, such thatS is onR1 andRk closes atD. ThusD holdsM via the sequences(P1, . . . , Pm,R1, . . . , Rk) and(Q1, . . . ,Qn,R1, . . . , Rk). 2

8. Relation to Clause Trees

The results in this paper were developed after we understood clause trees [5], andthen primarily as a means to implement clause trees. We eventually found thatmost of our ideas from clause trees could be expressed in binary resolution trees.Binary resolution trees are simpler in some ways since they are easier to implement,but often clause trees are easier to use when exploring new ideas. In particular,visibility and support can be read almost directly from a clause tree, whereas theproperties held and tightly held are somewhat harder to see in binary resolutiontrees. In this section we relate the two.

Referring once again to the example, the rotation equivalent binary resolutiontrees in Figures 1, 4, and 9 all correspond to the first clause tree in Figure 12.The binary resolution tree in Figure 2 corresponds to the second clause tree inFigure 12. A reader familiar with clause trees will note that the second clause treein Figure 12 can be constructed directly from the first by adding a merge pathbetween thea atom nodes and then doing surgery to remove the subtree beyondthe tail of the new merge path.

Some of the correspondences between binary resolution trees and clause treesare obvious. The leaves of a binary resolution tree are the clause nodes of the

30 B. SPENCER AND J. D. HORTON

Figure 12. Clause trees corresponding to Figures 1, 4, and 9 and to Figure 2.

clause tree; both are labeled by an instance of an input clause. The internal nodesof a binary resolution tree are the atom nodes of a clause tree. A history path in abinary resolution tree, which we associate with a literal, corresponds to a labelededge in a clause tree, also associated with a literal. If the history path is not closed,it corresponds to an edge incident with an atom node leaf; a closed history pathcorresponds to an edge incident with a closed atom node.

Minimal clause trees correspond to minimal binary resolution trees whose resultdoes not contain two identical atoms. The minimal condition on clause trees doesnot allow any legal unchosen merge path or legal tautology path, including leaf toleaf paths. A minimal binary resolution tree may correspond to a clause tree with alegal unchosen leaf to leaf merge path, or legal leaf to leaf tautology path. This isbecause the regularity condition in binary resolution trees requires one of the nodesto be internal.

Finally, visibility (resp. support) between internal nodes in a binary resolutiontree correspond to visibility (resp. support) between closed atom nodes in a clausetree. Table I shows a number of the corresponding notions.

9. Related, Past, and Future Work

Regularity is one of the most important restrictions and some form of it is used inmany theorem-proving methods related to resolution, including tableau [11] andall variants of model elimination [9].

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 31

Table I. Corresponding notions.

Clause Trees Binary Resolution Trees

clause node leaf node

internal atom node internal node

edge history path

open leaf atom node literal in result

cl(T ) result

internal-to-internal surgery splay surgery

internal-to-leaf surgery surgery

merge path two history paths with a common head

merge set all history paths closing at a given node

equivalence classes of reversal equivalentequivalence classes of rotation equivalent

minimal (up to leaf-to-leaf) minimal

visible internal atom nodes visible (not held by a common descendant)

support on internal atom nodes support, tightly hold

path reversal no structural change

no structural change (change in derivation)rotation

By Theorem 6 a smallest binary resolution tree is minimal. Goerdt has shown[4] that a smallest regular binary resolution directed acyclic graph (DAG) may beexponentially larger than an irregular binary resolution DAG. Thus, by consideringonly regular or minimal binary resolution DAGs, a theorem prover may not find thesmallest proof, and hence may require more inferences to prove a given theorem.However, in most cases we believe that the space of minimal binary resolutionDAGs is much smaller than the space of all binary resolution DAGs and that con-siderable time can be saved by restricting to minimal ones. (Similar arguments canbe made for and against most restrictions of resolution, including set of supportand hyperresolution.)

Permuting inference steps has been investigated by Kleene [8], in the context ofGentzen’s sequent calculus, both classical and intuitionistic. Kleene’s permutationssometimes increase the size of the proof. It is interesting to note that he defines theancestor relation between instances of formulas in each inference, allowing him to

32 B. SPENCER AND J. D. HORTON

state which instances of formulas in the deduction belong to a given instance in theend sequent. This is analogous to our notion of history paths.

In the context of binary resolution derivations, de Nivelle [3] has two typesof nodes: resolution nodes have two parents, and factoring nodes have one. Hedefines four types of edge rotations, depending on the type of nodes incident withthe edge. We disallow the rotation where a factorization node is parent to a res-olution node, because in this case the size of the derivation must be increased.His application is to constructresolution games, which are then used to showvarious completeness results for restrictions of resolution based on ordering lit-erals. Both de Nivelle’s paper and ours show that basic properties of resolutionmay be explored by considering the set of trees equivalent modulo permutations ofresolutions.

The main contribution of this paper is to present the minimal restriction ofresolution, originally developed in terms of clause trees, using the well-knownproof format of binary resolution derivations. The original motivation for doingso was to implement bottom-up algorithms for constructing minimal clause trees.A direct implementation based on the structural definition of clause trees was done,but each new tree needed its own storage space, and the visibility algorithm wascumbersome. To remedy both of these problems, we used the notion of binaryresolution derivations and implemented each new clause tree as a single storagecell with two parent clause trees. (For propositional logic this solves the spaceproblem, since each tree can be used as part of other trees.) The surprising resultis that visibility can be expressed easily and requires a linear algorithm using thisdata structure. We then decided to explain as much of our clause tree work as wecould using binary resolution trees, to make our work more accessible to readersfamiliar with resolution. This task turned out to be difficult until we discovered thatedge rotations, history paths, and the “precedes” relation between history paths arethe fundamental concepts needed. Then we related visibility and support to historypaths using the “holds” and “tightly holds” relations. In retrospect we still believethat it is easier to work conceptually with clause trees. We have anecdotal evidence,from a graduate course in automated reasoning given once with clause trees onlyand twice with binary resolution trees followed by clause trees, that the intuitionsfor support and visibility are quite understandable using either data structure.

We are at present developing the full theorem provers described here, one to useminimality as a restriction and another to use splay and surgery to improve proofsafter they are constructed by resolution. Both retain only minimal binary resolutiontrees so that the recursive calls in the first condition of Theorem 9 are not needed.Our implementations actually build binary resolution DAGs, instead of trees, tosave space. This is important because theorem provers are limited by space as wellas by time. Note that ProcedureVis traverses the entire implicit tree, so it may visita single stored node more than once. Thus its runtime is not guaranteed to be linearin the size of the DAG.

EFFICIENT ALGORITHMS TO DETECT AND RESTOREMINIMALITY 33

Redundancy elimination by subsumption is always an important considerationfor theorem provers. Unfortunately, the minimal restriction is not complete withfull subsumption. For instance, one cannot refute{p,¬p ∨ q,¬p ∨ ¬q} with aminimal binary resolution tree if one resolvesp against¬p ∨ q, generatingq,and then uses back subsumption to remove¬p ∨ q before the resolution between¬p∨q and¬p∨¬q is done. The latter resolution is part of the only minimal binaryresolution refutation of these clauses. The former resolution step leads to a binaryresolution tree in whichp is resolved at two different nodes on one branch. How-ever, we have discovered [7] that one can retain completeness by giving up someof the power of minimality, without giving up any of the power of subsumption.

The implementations optionally include the rank/activity restriction, discussedin [6], which ensures that from each set of rotation equivalent binary resolutiontrees, exactly one is found.

The space of minimal binary resolution trees is interesting for the followingreasons: (1) it is refutationally complete, (2) it extends the well-known regularityrestriction of resolution, (3) it contains the smallest binary resolution tree, (4) non-minimal (sub)trees can be identified in time linear in the size of the tree, and (5)nonminimal trees can be reduced to minimal ones efficiently.

Acknowledgments

The authors are grateful to NSERC of Canada for funding, and to the anonymousreviewers for their constructive comments. The first author did some initial workwhile visiting the Technical University of Darmstadt.

References

1. Adelson-Velskii, G. M. and Landis, E. M.: An algorithm for the organization of information,Soviet Math. Dokl.3 (1962), 1259–1263.

2. Chang, Chin-Liang and Char-Tung Lee, Richard:Symbolic Logic and Mechanical TheoremProving, Academic Press, New York, 1973.

3. de Nivelle, Hans: Resolution games and non-liftable resolution orderings,Collegium Logicum,Ann. of the Kurt Gödel Soc.2 (1996), 1–20.

4. Goerdt, Andreas: Regular resolution versus unrestricted resolution,SIAM J. Comput.22(1993),661–683.

5. Horton, J. D. and Spencer, B.: Clause trees: A tool for understanding and implementingresolution in automated reasoning,Artif. Intell. 92 (1997), 25–89.

6. Horton, J. D. and Spencer, B.: Rank/activity: A canonical form for binary resolution, in:C. Kirchner and H. Kirchner (eds),Automated Deduction – CADE-15, Lecture Notes in Artif.Intell. 1421, Springer-Verlag, Berlin, July 1998, pp. 412–426.

7. Horton, J. D. and Spencer, B.: Bottom up procedures to construct each minimal clause tree once,Technical Report TR97-115, Faculty of Computer Science, University of New Brunwsick, POBox 4400, Fredericton, New Brunswick, Canada, 1997.

8. Kleene, S.: On the permutability of inferences,Memoirs of the AMS10 (1952), 1–26.9. Loveland, Donald: Mechanical theorem proving by model elimination,J. ACM15(1968), 236–

251.

34 B. SPENCER AND J. D. HORTON

10. McCune, W. W.: Otter 3.0 users guide, Technical Report ANL-94/6, Mathematics andComputer Science Division, Argonne National Laboratory, Argonne, IL, 1994.

11. Letz, R., Mayr, K. and Goller, C.: Controlled integration of the cut rule into connection tableaucalculi,J. Automated Reasoning13 (1994), 297–337.

12. Robinson, J. A.: A machine-oriented logic based on the resolution principle,J. ACM12 (1965),23–41.

13. Sleator, D. D. and Tarjan, R. E.: Self-adjusting binary search trees,J. ACM32 (1985), 652–686.14. Spencer, Bruce and Horton, J. D.: Extending the regular restriction of resolution to non-linear

subdeductions, inProceedings of the Fourteenth National Conference on Artificial Intelligence,AAAI Press/MIT Press, 1997, pp. 478–483.

15. Tseitin, G. S.: On the complexity of derivation in propositional calculus, inStudies in Construc-tive Mathematics, Seminars in Mathematics: Matematicheskii Institute, Consultants Bureau,1969, pp. 115–125.