Implementation of First Order Predicate Calculus Theorem Provers using Positive Hyperresolution and Connections Graph

Thesis submitted in partial fulfilment of the requirements for the award of the degree of

MASTER OF TECHNOLOGY in COMPUTER SCIENCE AND ENGINEERING
By

Rajiv Seelam 04CS3003
under the guidance of

Prof. Dipankar Sarkar

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING INDIAN INSTITUTE OF TECHNOLOGY Kharagpur May 2010

DECLARATION
I, Sri Rajiv Seelam Roll no. 04CS3003 registered as a student of program M.Tech. in the Department of Computer Science and Engineering, Indian Institute of Technology, Kharagpur, India (hereinafter referred to as the Institute) do hereby submit my thesis, title: Implementation of First Order Predicate Calculus Theorem Provers using Positive Hyperresolution and Connections Graph (hereinafter referred to as my thesis) in a printed as well as in an electronic version for holding in the library of record of the Institute. I hereby declare that: 1. The electronic version of my thesis submitted herewith on CDROM is in PDF format. 2. My thesis is my original work of which the copyright vests in me and my thesis do not infringe or violate the rights of anyone else. 3. The contents of the electronic version of my thesis submitted herewith are the same as that submitted as final hard copy of my thesis after my viva voce and adjudication of my thesis. 4. I agree to abide by the terms and conditions of the Institute Policy on Intellectual Property (hereinafter Policy) currently in effect, as approved by the competent authority of the Institute. 5. I agree to allow the Institute to make available the abstract of my thesis in both hard copy (printed) and electronic form. 6. For the Institutes own, non-commercial, academic use I grant to the Institute the non- exclusive license to make limited copies of my thesis in whole or in part and to loan such copies at the Institutes discretion to academic persons and bodies approved of from time to time by the Institute for non-commercial academic use. All usage under this clause will be governed by the relevant fair use provisions in the Policy and by the Indian Copyright Act in force at the time of submission of the thesis. 7. Furthermore (a) I agree to allow the Institute to place such copies of the electronic version of my thesis on the private Intranet maintained by the Institute for its own academic community. (b) I agree to allow the Institute to publish such copies of the electronic version of my thesis on a public access website of the Internet should it so desire. 8. That in keeping with the said Policy of the Institute I agree to assign to the Institute (or its Designee/s) according to the following categories all rights in inventions, discoveries i

or rights of patent and/or similar property rights derived from my thesis where my thesis has been completed: a. with use of Institute-supported resources as defined by the Policy and revisions thereof, I further recognize that: b. All rights in intellectual property described in my thesis where my work does not qualify under sub-clause 8(a) remain with me. 9. The Institute will evaluate my thesis under clause 6(b1) of the Policy. If intellectual property described in my thesis qualifies under clause 6(b1) (ii) as Institute-owned intellectual property, the Institute will proceed for commercialization of the property under clause 6(b4) of the Policy. I agree to maintain confidentiality as per clause 6(b4) of the Policy. 10. If the Institute does not wish to file a patent based on my thesis, and it is my opinion that my thesis describes patentable intellectual property to which I wish to restrict access, I agree to notify the Institute to that effect. In such a case no part of my thesis may be disclosed by the Institute to any person(s) without my written authorization for one year after the date of submission of the thesis or the period necessary for sealing the patent, whichever is earlier.

Rajiv Seelam (Name of student) Department: Computer Science and Engineering

Prof. Dipankar Sarkar (Name of supervisor)

Signature of the Head of the Department

ii

CERTIFICATE
The project titled ”Implementation of First Order Predicate Calculus Theorem Provers using Positive Hyperresolution and Connections Graph”, submitted by Mr. Rajiv Seelam, Roll No: 04CS3003 of The Department of Computer Science and Engineering in partial fulfillment of for the award of the degree M.Tech is a record of bonafide work carried out by him under my supervision and guidance during academic year 2009-2010. The report fulfills all the requirements as per regulations of the institute and in my opinion, worthy of consideration for the award of the M.Tech degree.

Date: Place:

Prof. Dipankar Sarkar Department of Computer Science and Engineering, IIT Kharagpur.

iii

ACKNOWLEDGEMENTS
At the outset, I would like to express my deepest gratitude and heart-felt thanks to my project guide, Prof. Dipankar Sarkar of the Department of Computer Science and Engineering, Indian Institute of Technology Kharagpur, for suggesting the problem and his valuable guidance. I would also like to express my hearty thanks to Mr.Vadlamudi Satya Gautam, Mr. Kunal Banerjee, Miss. Madapu Manasa and Mr. Varun Sukhabhogi for their valuable suggestions, support and help throughout. And also, thanks to the Department of Computer Science and Engineering for the software lab facilities. I want to express my deepest gratitude to my family, for their love and support throughout my life.

Rajiv Seelam 04CS3003

iv

An FOPL formula is taken as input and converted into clause form. v . An algorithm to find the most general unifier of two literals is designed using a special data structure called Unification Table. To improve the performance two important refinements: positive hyperresolution and connection graph resolution are implemented and a comparative study is made. The report ends with a discussion of the comparative study of positive hyperresolution and connection graph. With those building blocks an attempt is made to apply resolution principle which was successful. The deficiencies with exhaustively applying resolution principle are observed. a strategy is implemented to choose links in graph which improves performance dramatically. It is observed that choosing links non-deterministically in connection graph gives rise to more resolvents than hyperresolution and resolution principle applied exhaustively.ABSTRACT Resolution theorem proving is an approach to automated reasoning. In this project the theorem proving is applied to first order predicate calculus.So.

. . . . . . . . . . . . . . . . . . . 13 13 14 14 14 15 15 16 16 16 17 3 Parsing and Constructing an FOPL Formula 3.5 4. . . . . . . . . . . . . .CONTENTS List of Figures 1 Introduction 2 Background 2. . . . .2 Grammar . . . .1. . . . . Eliminate redundancy . .1 2. . . . . . .1. . 4 Clause Form 4. . . . . . . . . . . . . . . . . . . . .1. . . . . . . .1 2. . . . . . . . . . . . . . . . . . . .9 4. . . . . . . . . Internal representation .3 4. . . . . . . . . . . . .2 3. . . . . . . . . . . . . . 1 2 3 3 3 4 5 6 6 7 7 7 10 13 . . . . The resolution rule . . . . . . . .1 3. . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . .3 Representation . . .8 4. .1 4. . . . . . . . . . 2. . . . . . Advance universal quantifiers . . . . . . . . Parsing and constructing a formula . . . . . . . . Reduce scope of negation .2. . . . . . . . . . . . . . . .1. . . . . . . . . . . Remove conditional operator . Remove biconditional operator . . . . . . . . . . . . . . . . . 3. . . . . . . . . . .1. . . . . . . . . Set of Clauses . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . .2 Ground resolution method .2 The unification algorithm . . . . . . . . . . .6 4. . . . . . . . . . . . . . . General resolution method . . . . .1. . . . Structure of formula tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 4. . . . . . . . . . . . . .2. .2. . . . . . . . .2 Existential closure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Steps to obtain clause form 4. . . . . . . .4 4. . . . . . . Rename variables . . . .7 4. . .2. .1 3. . . . . . . . Eliminate existential quantifiers . . . . . . . . . Distribute AND over OR . . . . . . . . . . .

. . . . .2. . . . . . . .1 7. . .2 7. . . . . . . . . 5. . . . . . . . . . . . . . . . . . . . . . .1 Unification of literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 5. . . . . . . . . . . Algorithm . . .1 8. . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . .3 Unification Table . . . . . . . . . . . . . . . . . 7 Connection Graph Resolution 7. . . . . . . . . . . . . . . . .1. . . . . . . . . .3. . . .1 Implementation . 7. . . . .4 Constructing graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Algorithm : unify . . . . . . Implementation . . . . .2 7. . . . . . . . . . . . .2 5. . . . . . . . . . . . . . Positive hyperresolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Semantic resolution . . . . . . . . . 6. . . . . . . . . .2. . . 19 19 19 22 23 23 25 25 25 26 26 28 28 28 29 29 29 30 30 31 31 34 35 36 37 41 Factoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7. . .1 6. . . . . . . .3 Introduction . . . . . . . . . .1 7. . . . . . . . . . . . . . . . . . Results . . . . .2 Algorithm . . . . . . . . . . . . . . .5 Unification and Resolution 5. . . . . . . . . . Unification of clauses and resolution . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . .1 6. . . . . . . . 8 Results 8. . . . . . . . . . . . . . . . . . . . . . . . . 6 Positive Hyper Resolution 6. . . . . . . . . . . . Implementation . . . . . . . . .2 Test Cases . . . . . . . . . . . . . . .1 5. CONCLUSION THE BIBLIOGRAPHY Appendix A Appendix B ii . . . . . Incorporating efficiency . . . . . Efficient algorithm . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

List of Figures 1. 2. Figure 8.1: No. 21 34 1 . Figure 5. of resolvents produced to find an empty clause in a strategy.1: Unification Table for x and y.

If A is unsatisfiable (that is. The algorithm based on resolution rule takes a first order wff as input and if wff is valid. otherwise� it either reaches a REJECT halt or loops forever.CHAPTER 1 Introduction A wff�well formed formula) is said to be valid if it yields a true statement for all possible interpretations. otherwise if A is satisfiable (that is. otherwise. In our problem we deal with the wffs of a subclasses of second-order predicate calculus. the algorithm either reaches a REJECT halt or loops forever. if B is satisfiable. we apply resolution method to A and check whether or not A is unsatisfiable. if the wff is not valid. 2 . the procedure may run forever. A is valid) the procedure will eventually detect it and stop. The subclass which is of special interest: the wffs of the first order predicate calculus. A is not valid) the procedure may run forever*. The resolution method is a partial decision algorithm for deciding whether a given wff of first order predicate calculus is unsatisfiable. So. if a wff B is valid then negation of B (-B) should be unsatisfiable. *The procedure can be simulated by a turing machine that takes an arbitrary wff B of first order predicate calculus or propositional calculus as input and if B is unsatisfiable� it will eventually reach an ACCEPT halt. it takes a wff B as input and if B is unsatisfiable it will eventually detect it and stop it. the algorithm will reach an ACCEPT halt. to decide whether or not a given wff A is valid. Thus. If a wff is false for all interpretations it is said to be unsatisfiable. That is.

CHAPTER 2 Background As introduced in the introduction section.1 Ground resolution method The ground resolution method consists of a single inference rule called the ground resolution rule. the clauses are always in ground instances. The ground resolution rule is stated as follows: For any two ground clauses G1 and G2 containing a literal l and its complement l respectively. We need to know ground resolution method and its generalized method: the resolution method. S pecial case: If there are two one-literal clauses. Eliminate duplicate occurrences of literals in G3 . But for first order predicate calculus the number of ground clauses generated is very large. In order to avoid the generation of ground instances the ground resolution method is generalized. 2. the resolution method is partial decision algorithm for deciding whether a wff of the first order predicate calculus is unsatisfiable. a literal l and its complement l.2 General resolution method The basic part of general resolution method is the application of the unification algorithm. 2. this rule is applied right away. Key result: A finite conjunction S of ground clauses is unsatisfiable if and only if the empty clause can be derived from S by repeated application of the ground resolution rule. And the process must terminate because there are finite number of clauses. then their resolvent is the empty clause. which finds a most general unifier B for a given unifiable disjunction of atomic formulas 3 . so. and then letting G3 be the disjunction of resulting clauses G1 and G2 . construct a new clause G3 called the resolvent of G1 and G2 obtained by first deleting all occurrences of l and l in G1 and G2 respectively. For propositional calculus as they have no variables. The major drawback of applying the above rule is it needs to generate ground instances of clauses. And comparing all these clauses takes lot of time.

vN ) denoted by A1 V A2 V ...V AN is not unifiable.V AN and the process is terminated....= ANα...V AN is a most general unifier if for each unifier α for the disjunction..1 The unification algorithm Step 0.v2 . tk .t2 >.. The algorithm starts with empty substitution α 0 (the substitution that consists of no pairs) and constructs. and some term say.t2 . say.tn >.. Most general unifier: A unifier β for a disjunction of atomic formulas A1 V A2 V ...vN ) V p0(v1 .. for each i.�vn . first we determine the disagreement set. For any literal L..p0(v1 ..t1 >.c) V p(a.V AN and reports a failure when the disjunction is not unifiable. we report a failure: the disjunct A1 V A2 V . Disagreement Set: Disagreement set of a disjunction of atomic formulas A1 V A2 V . This can be done only if the disagreement set contains as members some variable. Unifier: A substitution α is called a unifier for a disjunction of atomic formulas A1 V A2 V .w) is y.we let ti be the sub term of Ai that begins with this symbol position..y.v2 . If all the atomic formula Aiαk are identical..... where vi ’s are the distinct individual variables and each term ti different from vi .�v2 .f(a).... V denotes OR or Disjunction To understand this clearly we need to introduce few definitions. 2. called a factor of A1 V A2 V .. in a step-by-step process.V AN if A1α = A2α = ... Suppose that at the kth step the substitution produced so far is α k..tn obtained as follows: We regard each of the atomic formulas Ai as a string of symbols and detect the first symbol position in which not all the Ai ’s have the same symbol. L = Lα is the literal obtained from L by replacing simultaneously each occurrence of variable vi in L by the term ti ..V Ak αk ... For examples disagreement set of the disjunction p(a. Dk ..of A1 αk V A2 αk V A3 αk . Aiα is an instance of Ai β (for all i).. such that tk does not contain vk . vk . Otherwise.z) V p(a. Now the algorithm attempts to modify the substitution αk (to obtain αk+1 ) in such away as to make two elements of the disagreement set equal. Substitution: We denote a substitution by a finite set of pairs of the form α = �v1 . say.b. If there exists a unifier for a disjunction.. Step k+1 (≥0).V AN is unique except for alphabetic variants. a most general unifier β if one exists.. (if no such members exist in Dk ..b.... Then..VAN is a set of sub terms t1 ...2. The atomic formula B where B = A1 β = A2 β = AN β obtained by any most general unifier β.v3 ...) Next we create 4 .f(a). the disjunction is said to be unifiable... then β = αk is a most general unifier of A1 V A2 V .

the modified substitution αk+1 . We start by applying the resolution rule to a pair of clause C1 and C2 from S to obtain a resolvent C3 . 5 . 2.2 The resolution rule The general resolution rule method for proving the unsatisfiability of a wff S in the clause form is based on repeated application of the resolution rule. We increment k and perform another step of the algorithm. and add to αk+1 the pair ¡vk .tk ¿.2. Key result:: A given wff S in clause form is unsatisfiable if and only if the empty clause can be derived eventually by repeated application of the resolution rule. We then add the new clause to S and apply the resolution rule again until the empty clause is derived. which consists of all pairs of αk obtained after replacing all occurrences of vk in the terms of αk by tk .

TERM: FUNCTION ’(’ TERMLIST ’)’ | CONSTANT | VARIABLE . QVLIST: ’E’ VARIABLE | ’V’ VARIABLE | QVLIST QVLIST .CHAPTER 3 Parsing and Constructing an FOPL Formula 3.sentence | QVLIST sentence | [ sentence ] . *�The grammar is written with the symbols used during implementation.1 Grammar The grammar* of First Order Predicate Calculus: sentence: atomsentence | sentence � sentence | sentence > sentence | sentence | sentence | sentence & sentence | .’ TERMLIST . TERMLIST: TERM | TERMLIST ’. atomsentence: PREDICATE ’(’ TERMLIST ’)’ .) 6 .

2. conditional.2. Variables are represented as v0 .. Quantifiers ∀ and ∃ are represented as V and E respectively. Symbol and symboltable: The data structure for symbol and symboltable are given below: [Data Structure] typedef char variable[4]. typedef struct � variable name. Function) is encountered a function GetSymIndex is called which stores the symbol in the symbol table and returns an index which is 7 . Predicates are represented as p0 . Variable. Functions are represented as f0 . | . } SYMBOL . conjunction and negation are � .2 Internal representation To give input to the program and to save the formula internally. typedef SYMBOL SYMTABLE[MAX]. > .p1 etc.. we need an internally representation. Constant.1 Representation Symbols: 1.. 5. 4.c1 etc.respectively. & and . 3. disjunction. 6. Constants are represented as c0 .3.2 Structure of formula tree An FOPL formula is represented as a tree internally. 3. The symbols for operators biconditional.v1 etc. 3.2..f1 etc. Whenever a symbol (Variable.

typedef struct NodeTag� nodeType type. [Function] int GetSymIndex�variable SymName). }. predNodeType is the node for the atomsentence of the formula.used throughout the program. Node for atomsentence. operNodeType oper. By prototype it means: the parameters passed to the function.typeOper. Function: Puts the symbol in symboltable and returns the Symbol Table Index. Formula tree: In the formula tree there are three types of nodes: 1. 8 . union� predNodeType pred. } Node. quanNodeType quan. typedef Node Formula. Node for quantified sentences. 3. The prototype1 of the function GetSymIndex is given below: � Throughout the report only the prototypes of the functions are given.typeQuan} nodeType. The three types of nodes: The three types of nodes with data structures are given below: 1. 2. The data structure for the nodes in the tree is given below: The Node: [Data Structure] typedef enum �typePred. Parameters: SymName is the Symbol.what is returns and what function it does. Node for sentence with connectives.

typedef struct � int oper. [Data Structure] typedef struct � int predicate. 9 . } quanNodeType. } predNodeType. typeVar : It’s a type to store a variable. [Data Structure] typedef struct tlist � int count. of operator(s). termList is a linked list which stores the terms. } operNodeType. the qvlist has the quantified variables along with quantification. struct NodeTag *arguments[2]. From the grammar we can see their are three types of terms: 1. struct tlist *T. typeCon : It’s a type to store a constant.2. struct TermTag *term. }termList. typedef struct � qlist *qvlist. structure termlist: The node predNodeType uses a structure tlist which is the termlist of the predicate. quanNodeType is the node for the quantified formula. int nodes. struct tlist *next. structure term: The structure of termList uses another structure term. operNodeType is the node for the formula which is connected with one or two formulas as children depending on the no. struct NodeTag *arguments. 2. 3. The following is the data structure of the termList.

2.typeVar. 3. union� funcTerm function. }funcTerm.3.typeCon} termType. Functions for three types of nodes. typedef struct TermTag� termType type. 3.3 Parsing and constructing a formula The parsing and constructing the formula in a tree structure is done simultaneously. [Data Structure] typedef enum �typeFunc. }Term. typeFunc : It’s a type to store the function and it’s termlist. struct tlist *T. Functions to construct a term and a termlist. typedef struct � int function. }. }varTerm. 10 . typedef varTerm conTerm. Functions to construct a qvlist. The functions can be categorized into following: 1. We use the tools Bison and Flex. conTerm con. varTerm var. typedef struct� int value. And in the actions of Bison we construct the formula tree using the following functions. To parse.

Functions for term and termlist [Function] construct constant Term *construct constant�int value). int var). Parameters: 1)termlist. 11 .1. [Function] create termlist termList *create termlist�). Function: Creates a term of type typeCon and returns the Term. [Function] add to termlist termList *add to termlist�termList *tl. Term *t). Parameters: 1)qlist 2)type (1 for ∀ and 2 for ∃) 3)var: the quantified variable Function: returns the qlist. [Function] add to qlist qlist *add to qlist�qlist *q. Function: Creates a new qlist and returns the pointer to it. tl and term. Parameters: Nothing. [Function] construct variable Term *construct variable�int value). Function: Creates a new termlist and returns a pointer to it. Parameters: value of the constant. t. Parameters: value of the variable. Function: add the term t to termlist tl and returns the termlist. int type. Functions for qvlist [Function] create qlist qlist *create qlist�). 2. Function: Creates a term of type typeVar and returns the Term. Parameters: Nothing.

Now. 12 . Parameters:1)qvlist and the formula.). termList *tl).. Parameters: function variable and it’s termlist. Formula *f ). Function: A term of type typeFunc with function variable “value” and termlist “tl” is constructed and returns the term. with “nopers” number of formulas is constructed and returns the formula. we have all the blocks to build the formula tree after reading the input: An FOPL formula.. Functions for three types of nodes [Function] construct pred Formula *construct pred�int value. [Function] construct quan Formula *construct quan�qlist *q. termList *tl).. Parameters: predicate variable and it’s termlist. int nopers. [Function] construct oper Formula *construct oper�int oper. Function: A node of type typePred with predicate variable “value” and termlist “tl” is constructed and returns the formula. Parameters:1)oper 2) number of nodes 3) nodes Function: A node of type typeOper with operator “oper”.[Function] construct function Term *construct function�int value. The next step is to convert the formula into clause form and obtain clauses. Function: A node of type typeQuan with qvlist “q” and formula “f ” is constructed and returns the formula. 3.

Take the existential closure of the formula. Advance universal quantifiers.1. 13 .1 Steps to obtain clause form Existential closure We find an existential closure of a formula by checking the formula for all free variables in the formula and adding an existential quantifier in front of the formula with the each of the free variables. 2. 4. Remove biconditional operator.CHAPTER 4 Clause Form The resolution method can be applied only to wffs of a special form called the clause form. Each step is discussed in detail in the following section. A literal is an atomic formula or the negation of an atomic formula. Rename any variable that is quantified twice in the formula more than once. 5. To convert a formula into clause form we need to apply the following steps : 1. 3. Eliminate existential quantifiers. Distribute “AND” over “OR”. Remove conditional operator 6.1 4. Eliminate in the formula all redundant quantifiers. 4. Reduce scope of negation 7. 8. 9.

4.1.1. This renaming process is repeated until all quantifiers in the wff have different variables. That is. chose one such quantifier and replace the quantified variable va .2 Eliminate redundancy If there is a quantified variable va and that variable is not present in the scope of that quantification. [Function] rename 3 Formula *rename 3�Formula *f ). Function: The formula checks the formula if there is any redundancy. 14 . Function: The function checks the formula for free variables and adds an existential quantifier for each of the free variable to the start of the formula and returns the formula. together with all free occurrences of v0 in the scope of the chosen quantifier.1. Parameters: The formula. 4. Parameters: The formula. Parameters: The formula. It renames such variables and returns the formula. If there is such removes it and returns the formula.4 Remove biconditional operator Remove any � operator.3 Rename variables Rename any variable that is quantified in formula more than once. The quantification can be removed. [Function] remove redundancy Formula *remove redundancy�Formula *f ). replace it with (a>b)&(b>a). Function: The function checks the formula for variables which are quantified twice or more. by a new variable vb that does not already occur in the wff. 4.[Function] e closure Formula *e closure�Formula *f ). If sentence a�b.

The forms and what action to be taken is given below: 1. [Function] remove implication Formula *remove implication�Formula *f ).6 Reduce scope of negation Negation in the formula can exist in 5 forms. Convert (p|q) to p & -q 3. replace it with -a|b. Convert –p to p 2. 4. If sentence a>b. Function: Search for the sentences of typeOper and with operator � and replaces p�q with (p�q)&(q�p) and returns the formula. Convert (p&q) to p|-q 4.5 Remove conditional operator Remove any > operator. (E)p to (V)-p [Function] push negation Formula *push negation�Formula *f ). Parameters: The formula. Function: Searches the sentences for the formula of typeOper and with operator � and replaces a�b with -a|b and returns the formula. Parameters: The formula.1.1. Parameters: The formula. 15 .[Function] remove biconditional Formula *remove biconditional�Formula *f ). Function: Searches the sentences for any of the five forms given above and takes the appropriate action and returns the formula. 4. (V)p to (E)-p 5.

If there are universal variables to the left of the existential quantifier. 4. Repeat the process until there are no more existential quantifiers.1. Parameters: The formula.9 Distribute AND over OR Distributing AND over OR is nothing but applying following rules: 1.7 Eliminate existential quantifiers Eliminate existential quantifiers... and (b).. that is there are no variables universally quantified to the left of ExB(x) which have free occurrence in ExB(x). Convert (p&q)|r to (p|r)&(q|r) 16 .xn )) where. Special Case: If n=0. (a).. Function: This function checks the formula for existential quantifiers and also notes the universal quantifiers to the left of it.1. int value).1.xn are all the distinct free variables of ExB(x) which are universally quantified to the left of ExB(x).. ExB(x) is replaced with B(a)..4. x1 . [Function] eliminate exis Formula *eliminate exis�Formula *f..x2 . So. It creates a new function with free variables and returns the formula. f is any n-ary function constant which does not already occur in the wff..8 Advance universal quantifiers Advancing universal quantifiers to left and removing is nothing but removing quantification for all sentences. Parameters: The formula. Pick out the leftmost wfp ExB(x) and replace it with B(f(x1 ..x2 .. a new constant is created and sent to Replace function for Replacement. If there are no universal quantifiers to left. after this step the formula tree has no typeQuan type of nodes as we have already eliminated existential quantifier and now we have removed universal quantification. 4. where a is any individual constant which does not already occur in the wff. Function: Removes quantification from sentences and returns the formula. [Function] drop universal Formula *drop universal�Formula *f ).

we have to extract clauses from the tree and store them in a Set. Convert p|(q&r) to (p|q)&(p|r) [Function] distribute and or Formula *distribute and or�Formula *f ). Returns the new clause. 4. This step is performed by function rename 4 which checks each the clause set and renames variables if they occur in two clauses. [Function] clause nodes int clause nodes�Formula *f ). After obtaining clauses we have to check if the variables in each clause are distinct. But. A literal could be p or -p. The clause nodes obtained from above are divided into literals. set of clauses The atomic part of a formula is a literal. All clauses are stored in a Set called clause set. Function: Traverses the tree and stores the node with a clause in an array of nodes and returns number of clauses At this stage each clause is just another formula tree. Function: This function traverses the tree and whenever it encounters a node with ’|’ as a parent and & as a child to it. 17 . literal. Function: Checks the clauses and renames the variables which are occurring in two different clauses.2 Set of Clauses We have obtained the clause form. Parameters: The formula. [Function] rename 4 Formula *rename 4�Formula *f ). Parameters: The formula.2. clause. Parameters: The formula. It applies the rules given and constructs a node accordingly and returns the formula.

Formula *F. 18 .[Data Structure] typedef struct � litType type. typedef literal clause[MAX]. typedef clause clause set[MAX]. } literal. Now. The next step is to apply unification and resolution. int predicate. at this stage we have the clause set with clauses in it.

1. We shall approach the big problem in these steps. typedef enum �VAR. 5. typeFORM} typeROW.We need to apply the unification to clauses and check if we can get an empty clause.CHAPTER 5 Unification and Resolution The most difficult step in applying resolution method to FOPL is unification. The unification algorithm is given clearly in the chapter 2 of this report. Factoring 3. There are many algorithms to apply unification. 19 . implementing that efficiently and how to implement is the key feature. Unification of literals 2. In this chapter we apply an algorithm which uses a data structure called Unification Table. Unification of clauses and resolution The main problem for now is unification of literals.1 Unification Table [Data Structure] typedef enum �typeTERM. If we can do that. The idea of algorithm is borrowed from “Yet Another Efficient Unification Algorithm’ by Alin Suciu[2]. Additionally the occur check is also implemented. but. 1. 5.1 Unification of literals Our input is two literals and we have to find a most general unifier of those two literals. We discuss that below. using that we can solve all the other problems efficiently. We use a data structure Unification Table to solve our problem. STR} rowType.

Let’s the two formulas be: 20 . arity greater than 0).typedef struct clist� int count. 5. variables (type VAR. functions or predicates (type STR. }. struct clist *next. int functor. It parses into the table. arity 0) 3. Formula *F. In UTTable every variable appears only once. } UT ROW. }clist. and all the subterms of p andq are included. int arity. typedef UT ROW UT TABLE[MAX].1. clist *list. typedef struct� typeROW typer. The function fillTable() fills the UTTable. rowType rtype. constants (type STR. arity 0) 2. int component.1 Filling unification table The algorithm’s very important step is parsing inputs p and q and building a Unification Table which will we call UTTable from now.1. The UTTable contains three types of entries: 1. union� Term *T.

f1 (v3 )) Index 0 1 2 3 4 5 6 7 8 9 10 11 Functor v1 c0 f1 f0 v0 f1 p0 v3 f1 v2 f0 p0 Type VAR STR STR STR VAR STR STR VAR STR VAR STR STR Arity 0 0 1 2 0 1 3 0 1 0 2 3 Components — — 1 02 — 4 530 — 7 — 97 9 10 8 Table 5.f0 (v1 .f1 (c0 )).1: Unification Table for x and y. For composite terms. 2. Index . Functor . Components . Arity .v3 ).is the main functor of the term or formula. for variables and constants.is the arity of the term. 5.f(c0 )) v0 f1 (v0 ) p0 (f1 (v0 ).v3 ) p0 (v2 . 6. The list of components for a given term consists 21 . Type .For variables and constants.f0 (v1 . the list of components is the empty list. starts with 0 and uniquely identifies the term or formula.v3 ). x = p0 (v2 . the order is important it is from left to right. 4.is VAR for variables and STR for constants and composite terms.is the index of the table entry for some term or formula. the list of components is the sequence of the indexes of the component subterms. 3.is the actual term or the formula.f1 (v3 )) y = p0 (f1 (v0 ).v1 ) v3 f1 (v3 ) v2 f0 (v2 . Each variable has exactly one entry in the table but same constants or composite terms may have different entries. The table is filled by parsing the terms x and y from right to left starting with y in a bottom up manner.Term/Formula v1 c0 f1 (c0 ) f0 (v1 .f0 (v2 .f1 (c0 )).v1 ) The structure of the UTTable for each type of entry is the following: 1. Term/Formula .f0 (v2 . it is 0.

of the indexes of its components.j) == 1) return�FAIL) // report failure if �j is a free variable) bind j to i // add �j. that is 6 and 11.1. y) � initialize stack Sx initialize stack Sy push x on stack Sx push y on stack Sy while �not empty�Sx) and not empty�Sy)) �// start while loop pop i from Sx pop j from Sy // case 1: i is of type STR and j is of type STR if �type�i) == STR and type�j) == STR) if �main functors of i and j match �both name and arity)) if �arity > 0) push components of i on Sx in sequence push components of j on Sy in sequence else return�FAIL) // report failure // case 2: i is of type STR and j is of type VAR if �type�i) == STR and type�j) == VAR) if�occur check�i.j> to most general unifier if �i is free and j is bound) bind i to j // add �i.i> to most general unifier if �i is bound and j is bound) push the index of the term to which i is bound on Sx push the index of the term to which j is bound on Sy 22 .2 Algorithm : unify The algorithm of unify is given in psuedo C code form is given below: function unify�x. so the call will be unify�6.i> or �i.i> to most general unifier else // j is bound k = dereference j if �j is bound to a STR) push i on Sx push k on Sy // case 3: i is of type VAR and j is of type STR if �type�i) == VAR and type�j) == STR) // perfectly symmetric to case 2 // case 4: i is of type VAR and j is of type VAR if �type�i) == VAR and type�j) == VAR) if �i is free and j is free) bind i to j �or vice versa) // add �j. 5.j> to most general unifier if �i is bound and j is free) bind j to i // add �j. 11). The unification function will start with the indexes of x and y.

If L1 and -L2 have a most general unifier σ. We need to look what is a resolvent.L1 σ)∪(C2 σ .1 Unification of set of literals In order to find a most general unifier of a set of expressions. In the end removing the duplicate literals what we are left with is a factor of clause C. Now. So. then the clause (C1 σ . then Cσ is called a factor of C. the question is how we will find the factor of a clause. We just call the function unify for every two literals.} // end while loop return�SUCCESS) } // end function unify If we applied this algorithm to unify(6. 5.L2 σ) 23 . Let L1 and L2 be two literals in C1 and C2 respectively.�v0 .f1 (f1 (c0 ))>. it is called a unit factor of C.2.f1 (f1 (c0 ))>. we find the most general unifier of the set of literals and apply the all set of literals.f1 (c0 )>. It is simple. an FOPL Formula.2 Factoring Definition: If two or more literals (with same sign) of a clause C have a most general unifier σ.1. We already have a solution to find most general unifier of a set of literals. But we need a strategy to apply Resolution to a set of clauses.�v3 .f1 (c0 )>} 5.3 Unification of clauses and resolution At last the solution of the main problem is simple. Definition: Let C1 and C2 be two clauses (called parent clauses) with no variables in common. Before that. If Cσ is a unit clause. 11) we would get the output: The most general unifier for x and y is: ��v0 . On that set of clauses we apply unification and see if the resolved clause is an empty clause. We convert it into clause form and form a set of clauses.�v2 . 5. After we read the input. A clause is a disjunction of literals which we can call as set of literals as in our program we represent a clause that way.

a1 ) V p(a2 ..a2 .b2 . The literals L1 and L2 are called literals resolved upon... Pick two clauses from the N number of clauses...is called a binary resolvent of C1 and C2 .. V -p(bM .....b1 ) V -p(b2 ...a1 ) V p(a2 ..a2 ) V . But a better strategy could be designed............a2 ) V .... So.0.... by taking disjunction of C1 σ and C2 σ after eliminating all occurrences of p(r1 ..aN ..aN . Step 0....... Then we can construct a new clause C3 .b1 .. then we have encountered an empty clause... V p(aN .bM ) 1 2 n 1 2 n 1 2 n is a subdisjunction of C2 such that most general unifier σ exists for disjunction p(a1 . V p(aN .... Key Result: If the new formed clause C3 has no literals in it.aN ) 1 2 n 1 2 n 1 2 n is a subdisjunction of C1 and -p(b1 ..).. Let C1 and C2 be two clauses such that no individual variable is common to both C1 and C2 .b2 ) V ..b2 ) V .3.r1 ) in C1 σ and all occurrences of -p(r1 . terminate the program saying that the input is Unsatisfiable (Negation of Input is Valid.. 5........b1 ...a1 ..............aN ) 1 2 n 1 2 n 1 2 n V p(b1 . V p(bM ... But if we did not encounter a empty clause and we compared all clauses terminate the program saying the input is Satisfiable.a2 ............2 Strategy Algorithm 1: Lets say there are N number of clauses first..a1 .. Suppose that p(a1 ...bM ) 1 2 n 1 2 n 1 2 n Let us denote by p(r1 . Another problem is to find an efficient strategy to apply resolution...b2 ..r1 ) in C2 σ..bM .....bM .b1 ) V p(b2 . 24 .... A strategy is given here.. The results of a test case is given in the Appendix A of the report.r1 ) the factor of this disjunction.

Although deletion strategy can be used to delete some of those irrelevant and redundant clauses after they are generated. 25 .try resolutions whose input clauses have fewer literals first. 6. There are many important refinements of resolution. we must prevent large numbers of useless clauses from being generated. 6. Restriction strategies : In restriction strategies we put restrictions on the clauses that may be considered for resolutions. A clause is called mixed or non-positive if it neither positive nor negative. So.2 Positive hyperresolution Positive clause � Negative clause: A clause is called positive if it does not contain any negation sign. These restrictions are intended to improve performance by cutting down the number of possibilities that need to be considered. hence actually pruning the search space of possible resolutions. in order to have efficient theorem-proving procedures. We will follow a particular strategy called Positive hyperresolution. for instance.CHAPTER 6 Positive Hyper Resolution We have seen that unlimited applications of resolution may generate many irrelevant and redundant clauses besides useful ones.1 Semantic resolution We can apply strategies in two ways: Restriction strategies and Order strategies. A clause is called negative if every literal of it contains the negation sign. we shall consider semantic resolution and implement positive hyperresolution. Order strategies : This strategies constraint the order in which the possibilities are considered . Now. time has already been wasted by generating them. a special case of semantic resolution.

The order could be anything. where C1 is an ordered clause in M. where C1 is an ordered clause in T. S tep 6. Go to Step 3. the empty clauses can be generated by the above algorithm. respectively. In the above algorithm.. go to step 8. a contradiction if found. Otherwise. S tep 7. Set i = i+1 and go to Step 4.2. S tep 5. we pick an order for predicates. It is not hard to see that is Set of Clauses is Unsatisfiable. C2 is an ordered clause in Bi .. Otherwise. S tep 1. terminate.2 Implementation First. Set i = 0 S tep 4. go to the next step. Set j = 1 S tep 2.} Let Ai+1 and Bi+1 be the sets of all positive and nonpostive ordered clauses in Wi+1 . S tep 9.U Ai and M = T U M.2. Let A0 = NULL and B0 = N S tep 3. If Ai contains empty clause. S tep 8.6. The resolved literal of C1 contains the ‘largest‘ predicate symbol in C1 . All the clauses in each Ai are positive hyperresolvents.. Set T = A0 U. that is for each j. Set j = j+1. respectively.. Computer the Set R: � Ordered resolvents of C1 against C2 . for each cycle. Bi will eventually be empty since the maximum number of negative literals in any order clause of Bi decreases by one as i increases by one. S tep 11. respectively.} Let A0 and B0 be the sets of all positive and nonpostive ordered clauses in R. and the resolved literal of C2 is the last literal of C2 . Let M and N be the sets of all positive and nonpositive ordered clauses in S. If Bi is empty. The resolved literal of C1 contains the ‘largest‘ predicate symbol in C1 . S tep 10. C2 is an ordered clause in N. 6.1 Algorithm S tep 0. Computer the Set Wi+1 : � Ordered resolvents of C1 against C2 . And then we order the clauses in the SET with the following function: 26 . go to the next step.

Parameters: Nothing. The Results of some test cases are given in the chapter: Results. Function: The function implements the Algorithm we discussed and returns the number of hyperresolvents were produced.[Function] OrderClauses int OrderClauses�). As we already have the function to unify two literals and get the resolvent. Function: The function order the clauses in the SET according to the order we decided. The work we do here is dividing sets into positive and non-positive and implement the algorithm carefully. After ordering clauses we call the function: [Function] HyperResolution int HyperResolution�). 27 . Parameters: Nothing.

If there is no such clause go to Step 2. Check if there is an empty clause. the use of graph makes it possible to avoid ever doing any work twice. so that you can easily see the parts of the space which can be pruned without further exploration. Go to Step 1. Go to Step 3. and so that you can sometimes tell in advance that some problem is going to be insoluble without going through all the steps of trying to find a solution. Kowalski[5] pointed out that representing the set of clauses as a graph. Pick a link and get the resolvent. it gives you a view of the problem space as a whole. the chance of avoiding repeated work is very tempting. where the nodes are clauses and the connections are links between resolvable literals. S tep 3.CHAPTER 7 Connection Graph Resolution We have seen that we can improve the performance of applying resolution theorem using positive hyperresolution. Firstly. If there is terminate. 28 . Delete the link. Add the new resolvent to the graph. Construct a graph. can lead to dramatic improvements. S tep 2. Secondly. 7. S tep 1. 7. Given that resolution theorem proving is inherently a search task in which the steps that lead to a dead end may easily be repeated on a later branch of the search. However. Clauses are viewed as nodes and undirected links are drawn between two literals of different clauses which are unifiable.2 Algorithm S tep 0.1 Introduction Representing a set of clauses as a connection graph leads to two different kinds of benefit.

And a graph is just a set of such links. So an item (i.3 Implementation To implement the above given algorithm we first need to construct a graph for the set of clauses.3.lL. That is possible if the both clauses between which the link is present has single literal. After constructing the graph we pick a link and do that till we find an empty clause or all links are exhausted. Now.j) can be viewed as a jth literal of ith clause.3. So. where rows correspond to a clause. doing this without any guidance will results in lot of unnecessary clauses. Another way of looking at is resolving a link which will give a resolvent of 0 literals. 7. Basically it is to give importance to single literal clauses as we are going derive empty clause resolving two single literal clauses. 7.7. we need a better strategy to implement this. int cL. in fact it can viewed as matrix. So. As we have already seen in Chapter 5 that we represented clauses as a Set.2 Incorporating efficiency We need a strategy to search through the links to choose which link. But. typedef links graph instance[MAX]. 29 . } links. One way to do that is to choose a link with minimum number of clauses. it makes sense when we represent a link connecting two literals with the ordered pair of the ends the link.lR.1 Constructing graph The graph can be viewed as a following data structure: [Data Structure] typedef struct � int cR.

1 Implementation Constructing graph The graph can be viewed as a following data structure: [Data Structure] typedef struct � int count. If there is terminate. int cR. Check if there is an empty clause.4. typedef links graph instance[MAX]. Clauses are viewed as nodes and undirected links are drawn between two literals of different clauses which are unifiable. It makes sense as two literals will be removed from the both clauses. count in the link is Number of Literals in cR + Number of Literals in cL . } links. The Results of some test cases are given in the chapter: Results.2. So. Pick a link which will give rise minimum number of literals and get the resolvent. Go to Step 3. S tep 1. 30 . S tep 2.lL. everytime we want to pick a link we pick a link with minimum value of count.4 Efficient algorithm S tep 0.1 7. int cL.4. If there is no such clause go to Step 2. Delete the link. Go to Step 1.7.lR. S tep 3.1. 7. Add the new resolvent to the graph. Construct a graph.

In this section only the problem statements and it’s encoding is given.CHAPTER 8 Results Here are the results of some testcases. A comparision of different strategies is discussed. A1: Vv0�p0(v0) > p1(v0)} A2: Vv0�[p1(v0) & p3(v0)] > p2(v0)} A3: p0(c0) A4: p3(c0) G: p2(c0) F : A1 & A2 & A3 & A4 & -G Input : Vv0�p0(v0) > p1(v0)} & Vv0�[p1(v0) & p3(v0)] > p2(v0)} & p0(c0) &p3(c0) & -p2(c0) Test Case 2: Anyone who likes George will choose Nick for his team. Peter is an athelete. is strong. will succeed.1 Test Cases Test Case 1: Every athelete is strong. Nick is not a friend of anyone who is a friend of Mike. Therefore. Therefore. The detailed results is in the Appendix B of the report. if 31 . is intelligent. Peter will succeed in his career. is an athelete. Encoding: p0(v0): v0 p1(v0): v0 p2(v0): v0 p3(v0): v0 c0: Peter. Everyone who is strong and inteligent will succeed in his career. Jay will choose no one but a friend of Ken for his team. Peter is intelligent. 8.

v0): v0 owns v1. p1(v0.c1)} A2: Vv0�p2(v0.v1)}} F : A1 & A2 & A3 & -G 32 . Encoding: p0(v0.v0)] > p4(v1. c2: Mike.c2) > -p2(c1.Ken is a friend of Mike. A1: Vv0�p0(v0) > Vv1�p1(v1. p2(v0.c0) > p1(v0. then Jay does not like George. p1(v1. c0: George.v1)}} A2: Vv1Vv0�[p3(v0) & p1(v1.c0)] Test Case 3: Vacant lots provide no income to their owners. any owner of a vacant lot must pay taxes on something that provides no income to him.v0) > p2(v0.v0)} A3: Vv0�p0(v0) > p3(v0)} (Auxiliary Premise) G: Vv1�Ev0�p0(v0) & p1(v1.c0)] F : A1 & A2 & A3 & -G Input : Vv0�p0(v0.c4)} G: [p2(c4. p4(v0.v0) > p2(v0. Therefore. p3(v0): v0 is a real estate.c1)} & Vv0�p2(v0.v0) & -p2(v0.v2): v0 is a friend of v1.v1): v0 pays taxes on v1. c1: Nick.v1): v0 likes v1.v1): v0 provides income to v1.c2) > -p2(c1. c4: Ken. Encoding: p0(v0): v0 is a vacant lot.c0) > p1(v0. p2(v0.c2) > -p0(c3.c4)} & -[p2(c4.v1): v0 will choose v1. c3: Jay.v0) & -p2(v0. Any owner of real estate must pay taxes on it..v0)} > Ev0�p4(v1.c2) > -p0(c3.v0)} A3: Vv0�p1(c3. A1: Vv0�p0(v0.v0)} & Vv0�p1(c3.

v1) & p3(v1)}} A2: Ev0�p4(v0) & p0(v0) & Vv1�p2(v0. Some of the drug pushers entered this country and they were only searched by drug pushers. No drug pusher was a VIP.v1)}} G: Vv0�p1(v0) > -p3(v0)}} F : A1 & A2 & -G Input : Ev0�p0(v0) & Vv1�p1(v1) > p2(v0.Input : Vv0�p0(v0) > Vv1�p1(v1.v1)}} & Vv1Vv0�[p3(v0) & p1(v1. Some officials were drug pushers.v1) & p3(v1)}} & Ev0�p4(v0) & p0(v0) & Vv1�p2(v0.v1) > p4(v1)}} & Vv0�p4(v0) > -p1(v0)} & -Ev0�p4(v0) & p3(v0)} Test Case 5: A1: Ev0�p0(v0) & Vv1�p1(v1) > p2(v0. Therefore. A1: Vv0�[p0(v0) & -p1(v0)] > Ev1�p2(v0.v0) & -p2(v0. p3(v0): v0 was a custom official.v0)} > Ev0�p4(v1.v1)} A2: Vv0�p0(v0) > Vv1�p3(v1) > -p2(v0. Encoding: p0(v0): v0 entered this country. Some of the drug pushers entered this country who was not a VIP. p2(v0. p4(v0): v0 was a drug pusher.v1): v1 searched v0.v0) & -p2(v0.v0)} & Vv0�p0(v0) > p3(v0)} &-Vv1�Ev0�p0(v0) & p1(v1.v1)}} & -Vv0�p1(v0) > -p3(v0)}} 33 .v1)}} & Vv0�p0(v0) > Vv1�p3(v1) > p2(v0.v1)}} Test Case 4: The custom officials searched everyone who entered this country who was not a VIP. p1(v0): v0 was a VIP.v0)] > p4(v1.v1) > p4(v1)}} A3: Vv0�p4(v0) > -p1(v0)} G: Ev0�p4(v0) & p3(v0)} F : A1 & A2 & A3 & -G Input : Vv0�[p0(v0) & -p1(v0)] > Ev1�p2(v0.

Detailed output of the test case 3 is given in Appendix B. as with most problems. of resolvents produced to find an empty clause in a strategy. the choice will depend on characteristics of the kind of problem being solved as much as on the general properties of resolution.1: No. Table 8. As we can see Connection Graph Resolution (with Incorporating Efficiency) works better than Hyper Resolution but still there is a case where Hyper Resolution works better which supports out previous argument. � Efficient Algorithm 8. There is no universal agreement as to which are the best strategies . 34 .1 gives the number of resolvents produced to find an empty clause.almost certainly.Test Test Test Test Test Test Case Case Case Case Case Case 1 2 3 4 5 Hyper Resolution 5 4 16 11 5 CG Resolution� 4 5 9 10 4 Table 8.2 Results A very substantial proportion of the work on resolution theorem provers has been concerned with devising good search strategies.

CONCLUSION The quest for efficient unification algorithms and efficient strategy to apply resolution is the foundation of increasing the efficiency of logic programs. We have used a strategy to apply resolution rule. Converting it into a clause form and obtaining clauses. we must prevent large numbers of useless clauses from being generated. Connection Graph resolution could be more efficient. in order to have efficient theorem-proving procedures. We considered the resolution principle as an inference rule that can be used to generate new clauses from old ones. The unlimited applications of resolution may generate many irrelevant and redundant clauses beside useful ones. In this implementation we have used an efficient unification algorithm. 35 . An unification procedure which finds the factor of a clause by finding the most general unifier of a set of literals. It is possible as we come up with better search strategy as to choose which link. We have seen dramatic improvements over normal exhaustive resolution application. So. But. we implement the refinements: Positive Hyperresolution and Connection Graph resolution. Therefore. but its efficiency can be improved a lot. Basically first we have constructed all the basic building blocks: reading an FOPL Formula.

Mathemetical Theory of Computation. October 1975. 1988. A Proof Procedure Using Connection Graphs.595. McGraw-Hill.THE BIBLIOGRAPHY [1] Zohar Manna. [4] Allan Ramsay. Journal of the ACM. Volume 22 . [3] Chin-Liang Chang and Richard Char-Tung Lee.. Symbolic Logic and Mechanical Theorem Proving. [2] Alin Suciu. Yet Another Efficient Unification Algorithm. Cambridge University Press. Academic Press. Inc. Pages: 572 .Issue 4. Formal Methods in Artificial Intelligence. 36 . [5] Robert Kowalski. 1973.1974.

Some of the drug pushers entered this country and they were only searched by drug pushers.” and p4(v0) mean ”a was adrug pusher.” p1(v0) mean ”x was a VIP.v1)>p4(v1)}}&Vv0�p4(v0)>-p1(v0)}&-Ev0�p4(v0)&p3(v0)} ——————————————Clause Form ——————————————Step 1: e closure Vv0�p0(v0)&-p1(v0)>Ev1�p2(v0.v1)&p3(v1)}}&Ev0�p4(v0)&p0(v0) &Vv1�p2(v0.v1) mean ”v1 searched v0.v1)&p3(v1)}}&Ev0 �p4(v0)&p0(v0)&Vv1�p2(v0.v1)>p4(v1)}} F3: Vv0�p4(v0)>-p1(v0)} and the conclusion G: Ev0�p4(v0)&p3(v0)} So the statement would be: F1 & F2 & F3 > G To apply resolution we need to give the negation of the statement: -(F1 & F2 & F3 > G) = F1 & F2 & F3 & -G = Vv0�p0(v0)&-p1(v0)>Ev1�p2(v0.” p3(v0) mean ”v0 was a custom official. No drug pusher was a VIP.v1)&p3(v1)}}&Ev0 �p4(v0)&p0(v0)&Vv1�p2(v0. Let p0(v0) mean ”v0 entered this country.Appendix A Premises: The custom officials researched everyone who entered this country who was not a VIP.” p2(v0.” Premises are represented by the following formulas: F1: Vv0�p0(v0)&-p1(v0)>Ev1�p2(v0.v1)&p3(v1)}} F2: Ev0�p4(v0)&p0(v0)&Vv1�p2(v0.v1)>p4(v1)}}&Vv0�p4(v0)>-p1(v0)}&-Ev0�p4(v0)&p3(v0)} Welcome Enter a Formula Parsed ——————————————Entered Formula Vv0�p0(v0)&-p1(v0)>Ev1�p2(v0.v1)>p4(v1)}}&Vv0�p4(v0)>-p1(v0)}&-Ev0�p4(v0)&p3(v0)} 37 . Conclusion: Some of the officials were drug pushers.

v3)|p4(v3)}&Vv4�-p4(v4)|-p1(v4)}&Vv5�-p4(v5)|-p3(v5)} ——————————————Step 8: Drop Universal Quantifier -p0(v0)|p1(v0)|p2(v0.f0(v0))&p3(f0(v0))}&p4(c0)&p0(c0)&Vv3�p2(c0.v1)&p3(v1)}}&Ev2�p4(v2)&p0(v2) &Vv3�p2(v2.v1)&p3(v1)}}&Ev0�p4(v0)&p0(v0) &Vv1�p2(v0.v1)&p3(v1)}}&Ev2�p4(v2)&p0(v2) &Vv3�-p2(v2.v1)>p4(v1)}}&Vv0�p4(v0)>-p1(v0)}&-Ev0�p4(v0)&p3(v0)} ——————————————Step 3: Rename Variables Vv0�p0(v0)&-p1(v0)>Ev1�p2(v0.v1)&p3(v1)}}&Ev2�p4(v2)&p0(v2) &Vv3�-p2(v2.f0(v0))&p3(f0(v0))&p4(c0)&p0(c0)&-p2(c0.v1)&p3(v1)}}&Ev2�p4(v2)&p0(v2) &Vv3�p2(v2.v3)|p4(v3)}}&Vv4�-p4(v4)|-p1(v4)}&Vv5�-p4(v5)|-p3(v5)} ——————————————Step 7: Eliminate Existential Quantifier Vv0�-p0(v0)|p1(v0)|p2(v0.v3)|p4(v3)&-p4(v4)|-p1(v4)&-p4(v5)|-p3(v5) ——————————————After Renaming Variables (in each clause) Clauses: Clause 1 : -p0(v0) V p1(v0) V p2(v0.v3)>p4(v3)}}&Vv4�p4(v4)>-p1(v4)}&-Ev5�p4(v5)&p3(v5)} ——————————————Step 4: Remove Biconditional Vv0�p0(v0)&-p1(v0)>Ev1�p2(v0.v3)|p4(v3)}}&Vv4�-p4(v4)|-p1(v4)}&-Ev5�p4(v5)&p3(v5)} ——————————————Step 6: Push Negation Vv0�-p0(v0)|p1(v0)|Ev1�p2(v0.f0(v0))&-p0(v0)|p1(v0)|p3(f0(v0))&p4(c0)&p0(c0)&p2(c0.f0(v0)) Clause 2 : -p0(v6) V p1(v6) V p3(f0(v6)) 38 .——————————————Step 2: Remove Redundancy Vv0�p0(v0)&-p1(v0)>Ev1�p2(v0.v3)|p4(v3)&-p4(v4)|p1(v4)&-p4(v5)|-p3(v5) ——————————————Step 9: Distribute -p0(v0)|p1(v0)|p2(v0.v3)>p4(v3)}}&Vv4�p4(v4)>-p1(v4)}&-Ev5�p4(v5)&p3(v5)} ——————————————Step 5: Remove Implication Vv0�-p0(v0)&-p1(v0)|Ev1�p2(v0.

v3) V p4(v3) -p4(v4) V -p1(v4) -p4(v5) V -p3(v5) Resolution of 3 and 6 THE MGU: ��v4.f0(c0)) Resolution of 8 and 11 THE MGU: �} Clause 12 : p2(c0.c0>} Clause 8 : -p1(c0) Resolution of 2 and 4 THE MGU: ��v6.c0>} Clause 9 : p1(c0) V p3(f0(c0)) Resolution of 8 and 9 THE MGU: �} Clause 10 : p3(f0(c0)) Resolution of 1 and 4 THE MGU: ��v0.Clause Clause Clause Clause Clause 3 4 5 6 7 : : : : : p4(c0) p0(c0) -p2(c0.f0(c0)) Resolution of 12 and 5 THE MGU: ��v3.c0>} Clause 11 : p1(c0) V p2(c0.f0(c0)>} Clause 13 : p4(f0(c0)) 39 .

Resolution of 13 and 7 THE MGU: ��v5.f0(c0)>} Clause 14 : -p3(f0(c0)) Resolution of 10 and 14 THE MGU: �} Empty Clause 40 .

c1)&Vv7{-p4(c0.v0)&-p2(v0.v6)}>Ev7{p4(v5.v3)|p4(v2.v5)}} ------------------------------------------Step 7: Eliminate Existential Quantifier Vv0{-p0(v0)|Vv1{p1(v1.v0)&-p2(v0.c0)} ------------------------------------------Step 8: Drop Universal Quantifier 41 .v0)&p2(v0.v7)|p2(v7.v5)}} ------------------------------------------Step 4: Remove Biconditional Vv0{p0(v0)>Vv1{p1(v1.v1)}}&Vv1Vv0{p3(v0)&p1(v1.v0)&-p2(v0.v1)}}&Vv1Vv0{p3(v0)&p1(v1.v6)}&Vv7{p4(v5.v3)|p4(v2.v7)| p2(v7.v3)|p4(v2.Appendix B Test Case 3: Welcome Enter a Formula Parsed ------------------------------------------Entered Formula Vv0{p0(v0)>Vv1{p1(v1.v0)&p2(v0.v3)}&Vv4{p0(v4)>p3(v4)}&Vv5{Ev6{p0(v6)&p1(v5.v0)&-p2(v0.v1)}}&Vv2Vv3{p3(v3)&p1(v2.v1)}} ------------------------------------------Step 3: Rename Variables Vv0{p0(v0)>Vv1{p1(v1.v1)}} ------------------------------------------Step 2: Remove Redundancy Vv0{p0(v0)>Vv1{p1(v1.v0)}>Ev0{p4(v1.v1)}}&Vv2Vv3{-p3(v3)|-p1(v2.v0)>p4(v1.v3)}&Vv4{p0(v4)>p3(v4)}&Vv5{Ev6{p0(v6)&p1(v5.v0)&p2(v0.v3)}&Vv4{p0(v4)|p3(v4)}&Ev5{Ev6{p0(v6)&p1(v5.v5)}} ------------------------------------------Step 5: Remove Implication Vv0{-p0(v0)|Vv1{p1(v1.v0)}>Ev0{p4(v1.v6)}>Ev7{p4(v5.v3)>p4(v2.v1)}}&Vv2Vv3{p3(v3)&p1(v2.v1)}}&Vv2Vv3{-p3(v3)&p1(v2.v0)&-p2(v0.v0)>p4(v1.v7)&-p2(v7.v0)}>Ev0{p4(v1.v0)}&Vv0{p0(v0)>p3(v0)}&Vv1{Ev0{p0(v0)&p1(v1.v0)}&Vv0{p0(v0)>p3(v0)}&Vv1{Ev0{p0(v0)&p1(v1.v3)>p4(v2.v1)}} ------------------------------------------Clause Form ------------------------------------------Step 1: e_closure Vv0{p0(v0)>Vv1{p1(v1.v0)>p4(v1.v0)&p2(v0.v0)&-p2(v0.v7)&-p2(v7.v1)}}&Vv1Vv0{p3(v0)&p1(v1.v0)}&Vv0{p0(v0)>p3(v0)}&Vv1{Ev0{p0(v0)&p1(v1.v3)}&Vv4{p0(v4)|p3(v4)}&-Vv5{-Ev6{p0(v6)&p1(v5.v6)}| Ev7{p4(v5.v5)}} ------------------------------------------Step 6: Push Negation Vv0{-p0(v0)|Vv1{p1(v1.v3)}&Vv4{p0(v4)|p3(v4)}&p0(c1)&p1(c0.v7)&-p2(v7.v1)}}&Vv2Vv3{-p3(v3)|-p1(v2.v0)&p2(v0.

p1(c0.v3)|p4(v2.v3)&-p0(v4)| p3(v4)&p0(c1)&p1(c0.v9) Clause 3 : -p3(v3) V -p1(v2.N: {p1(v1.v0) V -p0(v0) Clause 2 : -p0(v8) V -p2(v8.v0) V -p0(v0) .v0) Clause 2 : -p0(v8) V -p2(v8.v7)|p2(v7.v1)&-p3(v3)|-p1(v2. -p0(v8) V -p2(v8.M: {p0(c1) .v1)&-p3(v3)|-p1(v2. p3(v4) V -p0(v4) .v0) V -p0(v0) .v3) V -p3(v3) .v3) V p4(v2.c1) Clause 7 : p2(v7.v3) V -p3(v3) Clause 4 : p3(v4) V -p0(v4) Clause 5 : p0(c1) Clause 6 : p1(c0.c0) ------------------------------------------Positive Hyper Resolution Predicates Order : p0 < p1 < p2 < p3 < p4 Ordered Clauses: Clause 1 : p1(v1. p4(v2.c1)} Non-Positive Clauses.c0) ------------------------------------------Step 9: Distribute -p0(v0)|p1(v1.v0)&-p0(v0)|-p2(v0. p3(v4) V -p0(v4) .v9) Clause 3 : p4(v2.v3) V -p1(v2.c1)&-p4(c0.c1)&-p4(c0.v7)|p2(v7.v3)|p4(v2.v7)} ------------------------------------------~Step 1~ J = 1 ------------------------------------------~Step 2~ A0: NULL B0: {p1(v1.v0)&-p2(v0.v9) . -p0(v8) V -p2(v8.v3)&-p0(v4)| p3(v4)&p0(c1)&p1(c0. p4(v2.v7) ------------------------------------------Step 0 Positive Clauses.v9) .v3) V -p1(v2.c0) ------------------------------------------After Renaming Variables (in each clause) Clauses: Clause 1 : -p0(v0) V p1(v1.v7) V p2(v7.c0) V -p4(c0.v3) Clause 4 : -p0(v4) V p3(v4) Clause 5 : p0(c1) Clause 6 : p1(c0.v3) V -p1(v2.v3) V -p3(v3) .c0) V -p4(c0. p2(v7.v7)} ------------------------------------------~Step 3~ I = 0 ------------------------------------------~Step 4~: Check for Empty Clause in A0 ------------------------------------------~Step 5~: Check if B0 is Empty ------------------------------------------42 . p2(v7.c1) Clause 7 : -p4(c0.-p0(v0)|p1(v1.c0) V -p4(c0.

c1)} B1: {} ------------------------------------------~Step 7~ I = 1 43 . p4(v1. p3(c1)} W1 divided into A1 and B1 A1: {p1(v1.c1)} W1 divided into A1 and B1 A1: {p4(c0.c1)p0(c1) .c1) .c1) . p4(v1.U A1) {p1(v1.c1) . p4(v2. p4(v1.c1)p3(c1) . p3(c1)} M:(T U M) {p0(c1) . ~Step 8~ T:(A0 U. p3(c1)} ------------------------------------------~Step 9~ J = 2 ------------------------------------------~Step 10~: Ordered Resolvents of T & N R: {p4(v1.c1) .c1)} R divided into A0 and B0 A0 {} B0: {p4(v1..c1) .c1) . p3(c1)p3(c1) V -p0(c1)} B1: {} ------------------------------------------~Step 7~ I = 1 ------------------------------------------~Step 4~: Check for Empty Clause in A1 ------------------------------------------~Step 5~: Check if B1 is Empty As B1 is Empty.. p4(v1.c1) V -p3(c1) .c1)} ------------------------------------------~Step 11~ : Go to Step3 ------------------------------------------~Step 3~ I = 0 ------------------------------------------~Step 4~: Check for Empty Clause in A0 ------------------------------------------~Step 5~: Check if B0 is Empty ------------------------------------------~Step 6~: Ordered Resolvents of M & B0 W1: {p4(c0.c1) V -p3(c1) . p1(c0. p1(v1.~Step 6~: Ordered Resolvents of M & B0 W1: {p1(v1.c1) V -p1(v2.c1)p4(v1.c1) V -p3(c1) .c1) V -p1(v2.. p4(v2.

p4(v1..c1) .c0) . p4(v1. p4(c0..c1) . p4(v1. p2(c1.U A0) {p2(c1. p4(v1. -p0(c1) . p2(c1. -p0(c1)} ------------------------------------------~Step 11~ : Go to Step3 ------------------------------------------~Step 3~ I = 0 44 . p1(v1.c0)p2(c1..c1)} ------------------------------------------~Step 9~ J = 3 ------------------------------------------~Step 10~: Ordered Resolvents of T & N R: {p2(c1. p2(c1. p4(c0. p2(c1.c0) .c1) . ~Step 8~ T:(A0 U. p1(c0.c0)} M:(T U M) {p0(c1) . p4(v1.c1) . ~Step 8~ T:(A0 U. p3(c1) .c1) .c0) . p2(c1. p2(c1.c1) .c0)} B0: {} ------------------------------------------~Step 11~ : Go to Step3 ------------------------------------------~Step 3~ I = 0 ------------------------------------------~Step 4~: Check for Empty Clause in A0 ------------------------------------------~Step 5~: Check if B0 is Empty As B0 is Empty. p1(v1. p2(c1.c0) .c0)} R divided into A0 and B0 A0 {p2(c1.c1) .U A1) {p4(c0.c0) . -p0(c1) .c1) .c1) .c0) V -p4(c0. p2(c1.. p2(c1.------------------------------------------~Step 4~: Check for Empty Clause in A1 ------------------------------------------~Step 5~: Check if B1 is Empty As B1 is Empty.c1) ..c0) . p1(c0.c1) . -p0(c1)} R divided into A0 and B0 A0 {} B0: {-p0(c1) . p4(v1..c1) .c0)} ------------------------------------------~Step 9~ J = 4 ------------------------------------------~Step 10~: Ordered Resolvents of T & N R: {-p0(c1) .c0)p4(c0.c1) . p3(c1) .c1)} M:(T U M) {p0(c1) .

0) Link6: (2.1)-(2.c1) Clause 7 : -p4(c0.v7) V p2(v7.1)-(5.1) Link2: (1.1) Link5: (2.0)-(6.0) Resolving Link No: 0 Clause 8 : p1(v1.v9) Clause 3 : -p3(v3) V -p1(v2.0)-(4.1)-(6.v9) New Links: Link9: (8.v3) Clause 4 : -p0(v4) V p3(v4) Clause 5 : p0(c1) Clause 6 : p1(c0.0)-(3.v0) Clause 2 : -p0(v8) V -p2(v8.0) Link7: (3.1) Resolving Link No: 2 Clause 9 : -p2(c1.0) Link1: (0.0)-(4.1) Resolving Link No: 7 45 .1) Link4: (2.v3) V p4(v2.0)-(2.------------------------------------------~Step 4~: Check for Empty Clause in A0 ------------------------------------------~Step 5~: Check if B0 is Empty ------------------------------------------~Step 6~: Ordered Resolvents of M & B0 empty empty empty W1: {.0)-(4.c0) Graph: Link0: (0.0) Link3: (1. .} W1 divided into A1 and B1 A1: {p0(c1) .2)-(6. } B1: {} ------------------------------------------~Step 7~ I = 1 ------------------------------------------~Step 4~: Check for Empty Clause in A1 Empty Clause 'The Formula entered is Unsatisfiable' ==================================== Connection Graph Clause 1 : -p0(v0) V p1(v1.c1) New Links: Link8: (7. -p0(c1) .

1)-(10.1) Link16: (13.c1) New Links: Link14: (12.0)-(2.0) Link22: (14.0) Resolving Link No: 21 !! ** Empty Clause ** !! The Formula entered is Unsatisfiable Clauses with Hyper Resolution: 16 Clauses with Connection Graph: 9 ==================================== 46 .1)-(11.Clause 10 : p3(c1) New Links: Link10: (9.0) Link17: (13.0) Link13: (11.0)-(3.1)-(2.2) Resolving Link No: 3 Clause 12 : -p0(v8) V -p4(c0.0) Link21: (14.0) Link18: (13.0)-(12.0)-(2.0)-(11.0)-(2.2) Resolving Link No: 5 Clause 14 : -p3(c1) V p4(c0.c1) New Links: Link15: (13.0)-(10.1)-(6.1) Link23: (14.0) Link19: (13.2) Resolving Link No: 12 Clause 13 : -p4(c0.c1) New Links: Link20: (14.0) Resolving Link No: 9 Clause 11 : -p4(c0.1) Resolving Link No: 16 Clause 15 : p4(c0.c1) New Links: Link11: (10.0)-(4.0)-(9.v8) New Links: Link12: (11.0)-(6.