| AutoFacts are generic clause sets. AutoFacts facilitate the task of integrating facts
generated from data into the knowledge base at run time (=time when we run the inference engine).
It is very useful to subclass AutoFacts , overridding the method getExtension(Class type) .
This method returns a collection of instances for the respective type. E.g., assume we have an
instance af of such a subclass with getExtension returning
(the Integer instances) 1,2 and 3 for Integer.class . Now assume that we perform
af.clauses(1<x,null) , where 1<x stands for the fact consisting of the
IntArithmetic.LESS_THAN predicate, a constant term wrapping the integer 1,
and a variable term of the type Integer named "x". Then the iterator returned
iterates over two facts: 1<2 and 1<3 . If we perform
af.clauses(x<y,null)
(two variables!), the iterator iterates over three facts 1<2 ,1<3 ,
2<3 . This will also work if the parameter(s) contains functions (with a known semantics),
e.g., the iterator returned by af.clauses(x*x<x+x,null) (where * and + stand for
the respective function defined as static members in IntArithmetic ) will iterate over
one fact only: 1*1<1+1 .
If clauses() is used without parameters, the set of facts iterated is defined as
follows:
- The predicate of each fact must be in the array returned by
getPredicates() .
- For each type of any slot of the predicate, the extension
is computed, and a fact is build for each combination of these extensions.
E.g., if getPredicates() returns {IntArithmetic.LESS_THAN,IntArithmetic.EQUALS} ,
and the extension for Integer.class is defined as {1,2,3}, then clauses() returns an
iterator iterating over the following facts: 1=1 ,2=2 ,3=3 ,
1<2 , 1<3 and 2<3 .
In the math test package and in the example.crm package are a couple of examples showing how to use
auto facts.
author: Jens Dietrich version: 3.4 <7 March 05> since: 1.2 |