Giter Site home page Giter Site logo

Comments (2)

ngeiswei avatar ngeiswei commented on May 25, 2024

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.

from ure.

ngeiswei avatar ngeiswei commented on May 25, 2024

I've added a (disabled) unit test for that issue

void xtest_tweety_not_green_alt();

To fix it I suppose one can add some checks in ForwardChainer::apply_rule, specifically in

// Wrap in try/catch in case the pattern matcher can't handle it
try
{
AtomSpace& ref_as(_search_focus_set ? _focus_set_as : _kb_as);
AtomSpace derived_rule_as(&ref_as);
Handle rhcpy = derived_rule_as.add_atom(rule.get_rule());
if (_search_focus_set) {
// rule.get_rule() may introduce a new atom that satisfies
// condition for the output. In order to prevent this
// undesirable effect, lets store rule.get_rule() in a
// child atomspace of parent focus_set_as so that PM will
// never be able to find this new undesired atom created
// from partial grounding.
BindLinkPtr bl = BindLinkCast(rhcpy);
FocusSetPMCB fs_pmcb(&derived_rule_as, &_kb_as);
fs_pmcb.implicand = bl->get_implicand();
bl->satisfy(fs_pmcb);
HandleSeq rslts;
for (const ValuePtr& v: fs_pmcb.get_result_set())
rslts.push_back(HandleCast(v));
add_results(_focus_set_as, rslts);
}
// Search the whole atomspace.
else {
Handle h = HandleCast(rhcpy->execute(&_kb_as));
add_results(_kb_as, h->getOutgoingSet());
}
}
catch (...) {}

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

https://github.com/opencog/atomspace/blob/6904dc0c2f0d3b122d46d5b00a6d28a0f2bfa279/opencog/atoms/pattern/PatternUtils.h#L45

from ure.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.