[jboss-jira] [JBoss JIRA] (DROOLS-1001) Tabled Logic Programming-like mechanism to avoid infinite query recursion
Fabian Meyer (JIRA)
issues at jboss.org
Tue Dec 8 03:54:00 EST 2015
Fabian Meyer created DROOLS-1001:
------------------------------------
Summary: Tabled Logic Programming-like mechanism to avoid infinite query recursion
Key: DROOLS-1001
URL: https://issues.jboss.org/browse/DROOLS-1001
Project: Drools
Issue Type: Feature Request
Reporter: Fabian Meyer
Assignee: Mark Proctor
Priority: Optional
Queries, such as a transitive closure, will lead to an infinite query recursion in PHREAK:
{code:drl}
declare Resource
name : String @key
end
declare partOf
subject : Resource @key
object : Resource @key
end
rule "init"
when
then
Resource a = new Resource("a");
Resource b = new Resource("b");
Resource c = new Resource("c");
insert (new partOf(a,b));
insert (new partOf(a,c));
end
rule "print container"
when
trans_partOf(part, container;)
then
System.out.println(part + " partOf " + container);
end
query trans_partOf(Resource part, Resource container)
// Find direct asserted fact
partOf(part,container;)
or
// Find the transitive closure
trans_partOf(part, p;)
and
trans_partOf(p, container;)
end
{code}
The algorithm can easily be rewritten as a production rule, resulting in a huge amount of materialized facts in large knowledge bases, which are probably never needed.
In Logic Programming, a mechanism called Tabled Logic Programming is used to avoid such infinite recursion. Maybe the tabling mechanism can be adapted to PHREAK, in order to avoid fact materilization when using production rules instead of queries.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
More information about the jboss-jira
mailing list