I'm writing a Knowledge base for a robot system. The system is actually composed by two parts: the rules in the KB and a set of predicates generated by sensor readings.
For example, possible rules:
do(stop) :- obstacleDist(N), N<1.
do(shoot(E)) :- canSee(E), enemy(E).
The sensing system produces predicates like:
canSee(plane).
obstacleDist(3.5).
The workflow consists in consulting the predicates generated by the sensors, consulting the rule engine and then querying what to do. (es. do(X).)
The problem is that, if (for example) the canSee predicate is not produced by the sensors, prolog will complain about Undefined procedure when looking at the rule do(shoot(E)).
A possible workaround would be to generate a list of base predicates (like canSee(nothing)) in the rules, but i'm not sure this is the best way.
Any ideas?
You need some declaration for the predicate. Either by a directive :- dynamic(canSee/1).
Or by a rule like canSee(_):-false.