Compiling a Default Reasoning System Into Prolog
Total Page:16
File Type:pdf, Size:1020Kb
Compiling A Default Reasoning System into Prolog David Poole Department of Computer Science University of British Columbia Vancouver BC Canada VT W p o olecsub cca July Abstract Articial intelligence researchers have b een designing representa tion systems for default and ab ductive reasoning Logic Programming researchers have b een working on techniques to improve the eciency of Horn Clause deduction systems This pap er describ es how one such default and ab ductive reasoning system namely Theorist can b e translated into Horn clauses with negation as failure so that we can use the clarity of ab ductive reasoning systems and the eciency of Horn clause deduction systems Wethus showhowadvances in expressivepower that articial intelligence workers are working on can directly utilise advances in eciency that logic programming re searchers are working on Actual co de from a running system is given Intro duction Many p eople in Articial Intelligence have b een working on default reasoning and ab ductive diagnosis systems The systems implemented so far eg are only prototyp es or have b een develop ed in A Theorist to Prolog Compiler ways that cannot take full advantage in the advances of logic programming implementation technology Many p eople are working on making logic programming systems more ecient These systems however usually assume that the input is in the form of Horn clauses with negation as failure This pap er shows howto implement the default reasoning system Theorist by compiling its input into Horn clauses with negation as failure therebyallowing direct use advances in logic programming implementation technology Both the compiler and the compiled co de can takeadvantage of these improvements This work should b e seen as an instance of Stickels prop osal for a Prolog technology theorem prover Rather than redesigning and extending a Prolog compiler this is done by compiling to Prolog Rather than concentrating on the needs for theorem proving this work has concentrated on the needs for representing common sense knowledge in particular for default and ab ductive reasoning Wehave b een running this implementation on standard Prolog compilers and it outp erforms all other default reasoning systems that the author is aware of It is arguably not restricted to the control structure of Prolog There is nothing in the compiled co de which forces it to use Prologs depth rst search strategy all it requires is the implementation of Horn clauses with negation as failure Logic programmers and other researchers are working on alternate control structures which seem very appropriate for default and ab ductiv e reasoning Advances in parallel inference eg constraint satisfaction and dep endency directed backtracking should b e applicable to the co de pro duced by this compiler Wearethus eecting a clear distinction b etween the control and logic of our default reasoning systems We can let the control p eople concentrate on improving the eciency of Horn clause systems which will b e directly applicable to those of us building richer representation systems The Theorist system has b een designed to allow maximum exibilityincontrol strategies while still giving us the p ower of assumptionbased reasoning required for default and ab ductive reasoning This is a step towards having representation and reasoning systems which Indep endently and subsequently Stickel has also develop ed a compiler from a Theorem prover to Prolog He has however concentrated on the needs for theorem proving applications These are not emphasised in this pap er see section A Theorist to Prolog Compiler are designed for correctness b eing able to use the most ecientcontrol strate gies Wewant the b est of expressibility and eciency Theorist Framework Theorist is designed to b e a very simple logical reasoning sys tem for default and ab ductive reasoning It is based on the idea of theory formation from a xed set of p ossible hyp otheses We assume a rst order language with a countable set of constant symb ols see section for the syntax accepted by this implementation A ground instance of a formula is obtained by substituting variable free terms of the language for variables in the formula The user provides F is a set of closed formulae called the facts These are intended to b e true in the world b eing mo delled F is assumed to b e consistent is a set of p ossibly op en formulae whichactas possible hypotheses Denition A scenario of F is a set D of ground instances of elements of such that D F is consistent Denition If g is a closed formula an explanation of g from F is a scenario of F which together with F implies g That is g can b e explained from F if there is a set D of ground instances of elements of suchthat FD j g and FD is consistent D is an explanation of g Denition An extension of F is the set of logical consequences of the F together with a maximal with resp ect to set inclusion scenario of F A Theorist to Prolog Compiler In other pap ers wehave describ ed how the Theorist framework can b e the basis of default and ab ductive reasoning systems If we are using Theorist for prediction then p ossible hyp otheses can b e seen as defaults This is also a framework for ab ductive reasoning where the p ossible hyp otheses are the base causes we are prepared to accept as to whysome observation was made In this pap er we refer to p ossible hyp otheses as defaults but the implementation can b e used for either One restriction that can b e made with no loss of expressivepower is to restrict p ossible hyp otheses to just atomic forms with no structure This is done by naming the defaults Syntax The syntax of Theorist is designed to b e of maximum exibility Virtually any syntax is appropriate for formulae the formulae are translated into Prolog clauses without mapping out subterms The theorem prover implementedin the Compiler can b e seen as a nonclausal theorem prover Variables constants function symb ols predicate symb ols terms and atomic symb ols atoms are dened as in Prolog A well formed formula a w is made up of arbitrary combinations of implication disjunction or conjunction and and negation not of atomic symb ols As in Prolog There is no explicit quantication all facts are assumed to b e universally quantied and all queries existentially quantied names are atomic symb ol with only free variables as arguments The following gives the syntax of the Theorist co de fact w where w is a w means that w F ie the universal closure of w is a fact default d where d is a name means that d ie d is a p ossible hyp othesis w is the universal closure of w That is all variables in w are universally quantied V are the free variables in w w isVw Similarly w is the existential closure of If w allvariables are existentially quantied A Theorist to Prolog Compiler default d w where d is a name and w is a w means w with name d can b e used in a scenario if it is consistent Formally it means d andd w F explain w where w is an arbitrary w gives all explanations of w predict w where w is a arbitrary ground w returns yes if w is in every ex tension of F and no otherwise If it returns yes a set of explanations is returned if it returns no then a scenario from which g cannot b e explained is returned this follows the framework of Overview of Implementation In this section we assume that wehave a rst order predicate calculus deduc tion system denoted which has the following prop erties such a deduction system will b e dened in the next section It is sound ie if A g then A j g It is complete in the sense that if g follows from a consistent set of formulae then g or some formula more general than g can b e proven That is if A is consistentand A j g then A g If A g then A B g ie adding in extra facts will not preventthe system from nding a pro of which previously existed It can return instances of certain predicates used in the pro of The basic idea of the implementation follows the denition on explain ability Pro cedure to explain g from F This is called a pro cedure as in general it is not decidable whether an atom can b e explained A Theorist to Prolog Compiler try to prove g from F If no pro of exists then g cannot b e explained If there is a pro of let D b e the set of instances of elements of used in the pro of We then know FD j g by the soundness of our pro of pro cedure show D is consistentwithF by failing to prove it is inconsistent As F is consistent the completeness of our pro of pro cedure will ensure that if FD is inconsistent a pro of for D from F will b e found Consistency Checking The following two theorems are imp ortant for implementing the consistency check Lemma If A is a consistent set of formulae and D is a nite set of ground instances of p ossible hyp otheses then if we imp ose arbitrary ordering on the elements of D fd d g n A D is inconsistent if and only if there is some i i n suchthat A f d d g is consistentand i A fd d gj d i i Pro of If A D is inconsistent there is some least i such that Afd d g is inconsistent Then wemust have Afd d g i i is consistentas i is minimal and A fd d gj d by i i inconsistency This lemma says that we can showthatFfd d g is consistentif n we can showthatforalli i n Ffd d g d If our theorem i i prover can show there is no pro of of all of the d thenwehave consistency i This lemma indicates that we can implement Theorist by incrementally failing to prove inconsistencyWe need to try to prove