
The Functional Side of Logic Programming Massimo Marchiori Department of Pure and Applied Mathematics UniversityofPadova Via Belzoni Padova Italy maxhilbertmathunipdit between functional and logic programming its outcome was Abstract a transformation from a lo cal class of logic programs to In this pap er we study the relationships b etween logic pro functional programs that is sound that is informally ev gramming and functional programming trying to answer erything calculated by the obtained functional program is the following basic question to what extent is logic pro calculated by the original logic program to o gramming just functional programming in disguise We However Reddys transformation fails to identify a func develop a theory to formally express this corresp ondence tional class of logic programming for various reasons and exhibit a class that can by right b e considered as the First for the transformation to b e sound the target func functional core of logic programming Moreover since the tional language must employanad ho c fairparallel reduc functional meaning of each program in this class is provided tion strategy This means that the translation of a logic constructively via a transformation from logic to functional program its functional meaning is not a pure functional programs we showhow the obtained theoretical results are program which is quite unsatisfactoryWe also remark that useful also in the study of languages integration termination from a practical p oint of view not only the obtained co de issues and practical implementations cannot in general run on any implementation not supp orting fair paralleli sm but even using a parallel functional language an eective use is unfeasible indeed the degree of paral Intro duction lelism required is far b eyond the so called orparalleli sm of logic programming which is already considered imprac During the recentyears a huge amount of eort was devoted tical since even shallowbacktracking can instigate an ar to integrating the two paradigms of functional programming bitrary numb er of innite computations see also b elow and logic programming and to develop languages combining Second the transformation is not complete thatisthe them see for instance However much less attention obtained functional program may not terminate despite the was devoted to the basic problem of studying what are the original logic program terminates Of course this is unac intimate relationshi ps b etween logic programming and func ceptable for a functional class of logic programs a mini tional programming So far the research only scratched the mal requirement should b e that its transformed functional surface nding out the dierences eg usage of unication program b ehaves just in the same way not losing a funda versus matching resolution vs reduction nondeterminism mental prop ertylike termination in fact we guess Reddy vs determinism etc see for example but not the was aware of this problem since alb eit not mentioning the connections that is howmuchtheydohave in common To lack of completeness he only refers to his transformation as the b est of our knowledge only Reddy eg in tried being sound to shed some light on this fundamental topic In this pap er we aim to answer the following basic ques Thus Reddys transformation only started shaping the tion to what extent is logic programming just functional b orders of the problem In fact the rst thing that should programming in disguise That is to say what class of logic b e claried is what means for a logic program to b e func programs can b e considered the functional core of logic pro tional in nature As hinted b efore this should mean it is gramming equivalent to a functional program b ehaving in the same A rst requirementwe imp ose on such a class if it ex way hence the need for a transformation from logic to func ists is to b e a neat sublanguage of logic programming one tional programs to nd out the functional meaning How should b e able to sayofevery clause of a logic program ever the problem lies in what b ehaving in the same way whether it is functional or not the functional avor should should signify A natural resp onse is requiring the trans a fundamental prop erty visible at clause level This will b e formation to functional programs to b e complete thatisto referred to as lo cality every class we consider henceforth preserve termination and computed answers this wayan will b e understo o d to b e lo cal external observer should not see any dierence on what the Reddy in his work started studying the relationships program computes Completeness is a minimal requirement but still is not the full answer since it do es not rule out Turingcarp et lowlevel transformations such a transfor mation would b e complete for the whole class of logic pro grams hence identifying logic programming with functional Backtracking due to nondeterminism is implemented via parallel pro cesses Failure of a goal to resolve with a clause We will consider functional programs of the following programming a not very interesting result This is nothing P more than a restatementoftheChurchTuring thesis ev op pat e P ery other Turingcomplete paradigm for calculation would op pat e b e equivalenthaving the same computational p ower of function kind a nite sequence The answer we found is to slightly stress the notion of P op pat e n n n equivalence we said an external observer should not see denitions where the op are operators not necessarily dis i any dierence on what the program computes Wealsore tinct the pat are patterns and the e are expressions As i i quire he should not see any dierence on how the program usual in this basic functional language op erators are func computes it should not increase in time complexityMore tion symb ols that cannot o ccur in patterns patterns are formally logic programs b elonging to a certain complexity linear terms and expressions are terms We remark that class should b e transformed into functional programs of the patterns in a program can also b e overlapping that is two same or lower complexity class This turns out to b e a or more pat s in the denitions of some op erator could b e i go o d answer with this requirement a class can b e found uniable in which case the dierent alternatives are tried that is maximal among those complete A great surprise is out one at a time from top to b ottom that this result holds all the same even if the requirementis considerably weakened we can allow the transformation to As far as the reduction strategy is concerned in accor arbitrarily worsen the time complexity of a program pro dance to what said ab ove on the generality of the language vided only this worsening is computable weleaveitunspecied thatistosay all the results weare going to prove should hold indep endentl y on the particular These results will b e proven rst on denite logic pro reduction strategy b e it strict or lazy when this is not the gramming and then also extended to normal logic program case we will say it explicitly ming where use of negation is allowed Given a functional program F and an expression ewe Also as a bypro duct of these corresp ondence results we will indicate with F e the result of reducing e wrt F will showhow such transformational metho dology can pro vide new contributions to a clean integration of logic and Lo cality functional programming and to the study of termination prop erties for logic programs Finallywe will test this ap We study classes of logic programs under a lo cal p ointof proach from a practical p oint of view b enchmarking the view that is requiring their description can b e given clause co de pro duced by the transformation byclause Denition A class of logic programs is said to b e local Preliminaries when every program b elongs to it i each of its clauses do es Notation Such lo cal classes are very useful b ecause as mentioned in Sequences of terms will b e written in vectorial notation eg the Intro duction they allow to neatly dene a sublanguage t and jtj denotes their length viz if t t t m m of logic programming simply restricting the syntax of each then jtj m Sequences in formulas should b e seen just as program clause to those characterizing the class abbreviations for instance t with t t t denotes m Non lo cal classes instead are in general not very useful the string t t Accordingly given two sequencess m for dening a sublanguage not only do they require the s s and t t t s t stands for the sequence n m programmer to takeinto account many program lines all at s s t t n m once but in case of program development two fundamental Given a family S of ob jects terms atoms etc VarS op erations like deleting a clause or adding a clause of the is the set of all the variables contained in it moreover S class to the program can b e dangerous indeed they are is said to b e linear if no variable o ccurs more than once b oth safe op erations if and only if the class is lo cal in it To makeformulas more readable we will sometimes Thus from nowonwe assume that every class of logic omit brackets from the argument of unary functions eg programs we talk ab out is understo o d to b e lo cal f g X may b e written fgX Also we will consider in full generality classes that can For standard logic programming terminologywewill constrain b oth the logic program and the goal for nota mainly follow Logic programs will b e considered as tional convenience we will talk by abuse of a class of logic executed with leftmost
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages11 Page
-
File Size-