forward chainer finds that Tweety is a green frog in examples/ure/frog
astroseger opened this issue · 2 comments
If in examples/ure/frog (Forward Chainer (using the frog rule base)) replace source with (Evaluation (stv 1.0 1.0) (Predicate "eats_flies") (Concept "Tweety"))
then forward chainer infer that Tweety is green frog.
you should run it from examples/ure/frog
(use-modules (opencog exec))
(use-modules (opencog ure))
(load "frog-rule-base.scm")
(define source (Evaluation (stv 1.0 1.0) (Predicate "eats_flies") (Concept "Tweety")))
(cog-fc frog-rb source)
It infers that Tweety is a green frog
Good catch! The problem is that partially instantiating the rule creates knowledge that enables it, as the log seems to show
[2019-08-27 07:39:06:592] [DEBUG] [URE] Iteration 1/20
[2019-08-27 07:39:06:592] [DEBUG] [URE] Positively weighted sources (1/1):
1 [18165890790953396687][1]
[2019-08-27 07:39:06:592] [DEBUG] [URE] Selected source:
body:
(EvaluationLink (stv 1.000000 1.000000)
(PredicateNode "eats_flies") ; [7213660049930235279][1]
(ConceptNode "Tweety") ; [3735456478155215117][1]
) ; [18165890790953396687][1]
vardecl:
nullatom
complexity: 0
exhausted: 0
rules:
size = 0
[2019-08-27 07:39:06:592] [DEBUG] [URE] The following rules are valid:
size = 1
rule[0]:
if-croaks-and-eats-flies-then-frog-rule [13721906382592422519][-1]
[2019-08-27 07:39:06:592] [DEBUG] [URE] Rule weights:
1 if-croaks-and-eats-flies-then-frog-rule
[2019-08-27 07:39:06:592] [DEBUG] [URE] Selected rule, with probability 0.9 of success:
name: if-croaks-and-eats-flies-then-frog-rule
tv: (stv 0.900000 1.000000)
rule:
(BindLink
(PresentLink
(EvaluationLink
(PredicateNode "croaks") ; [7951887459888016198][1]
(ConceptNode "Tweety") ; [3735456478155215117][1]
) ; [12949780631530868304][-1]
(EvaluationLink
(PredicateNode "eats_flies") ; [7213660049930235279][1]
(ConceptNode "Tweety") ; [3735456478155215117][1]
) ; [18165890790953396687][-1]
) ; [13188132327173885393][-1]
(InheritanceLink
(ConceptNode "Tweety") ; [3735456478155215117][1]
(ConceptNode "frog") ; [780748648436154616][1]
) ; [11901928757656513900][-1]
) ; [13721906382592422519][-1]
[2019-08-27 07:39:06:592] [DEBUG] [URE] Results:
size = 1
atom[0]:
(InheritanceLink
(ConceptNode "Tweety") ; [3735456478155215117][1]
(ConceptNode "frog") ; [780748648436154616][1]
) ; [11901928757656513900][1]
I thought I had fixed it but apparently it's been broken again, pointing out to the lack of good unit test.
I will attempt to fix it later this week or early next week. You are welcome to attempt to fix it yourself if so you wish.
I've added a (disabled) unit test for that issue
To fix it I suppose one can add some checks in ForwardChainer::apply_rule
, specifically in
ure/opencog/ure/forwardchainer/ForwardChainer.cc
Lines 407 to 436 in 7f96a6d
to make sure that all constant clauses are present in the kb atomspace before triggering the rule. To identify constant clauses one probably can use