From: Murat K. <mur...@st...> - 2008-09-06 20:45:33
|
Hi, I have a question regarding built-ins. Having taken a look at the source code, I would like to understand why the following datalog programs do not work as (I) expected. (They are appended below.) Program 1 works as expected, but 2 and 3, on the other hand, do not. With 2 I expected to get the correct answer to the calculation, i.e. 24. Program 3 was supposed to deliver 6, obviously. This ought to be possible through the IRIS feature of deducing the last number involved e.g. in a ternary mathematical predicate, but which also applies to the EQUAL-predicate. My explanation is that, after building the knowledge base, the facts are all that is left - the rules are not looked at again during query evaluation. This results in the might of the UNIVERSE variable, which ought to solve problems like program 3, to get lost . It also leads to the deduction capabilities of the EQUAL-predicate to not be applied to the constant in the query - producing an empty result set. Is my understanding of the matter correct? And I would like to know if the following is a bug or intended behavior. FiniteUniverseFact: The method void extractGroundTerms( Collection<IRule> rules ) twice extracts the ground terms from the rule's head but never from the body. I suppose this is a copy-and-paste error? http://iris-reasoner.svn.sourceforge.net/viewvc/iris-reasoner/iris/trunk/src/org/deri/iris/facts/FiniteUniverseFacts.java?view=markup&pathrev=1593 Thanks, Murat ==== 1. ==== pred1('p1' , 'p2'). pred2('p2' , 'p3'). pred(?X,?Z) :- pred1(?X,?Y), pred2(?Y,?Z). ?-pred('p1',?X). ---------------------------------- Query: ?- pred('p1', ?X). ==>> 1 row in 0ms Variables: ?X ('p3') ==== 2. ==== some_calc(?X,?Z) :- MULTIPLY(?X,?X,?Y), ADD(?Y,-1, ?Z). ?-some_calc(5,?Z). ---------------------------------- Query: ?- some_calc(5, ?Z). ==>> 0 rows in 0ms Variables: ?Z ==== 3. ==== eq_ordinary(?x, ?y) :- EQUAL(?x,?y). ?-eq_ordinary(6,?q). ---------------------------------- Query: ?- eq_ordinary(6, ?q). ==>> 0 rows in 0ms Variables: ?q |