opencog / atomspace

The OpenCog (hyper-)graph database and graph rewriting system
https://wiki.opencog.org/w/AtomSpace
Other
801 stars 225 forks source link

"Expecting GroundedPredicateNode!" error #46

Closed williampma closed 8 years ago

williampma commented 9 years ago

Empty atomspace, add the following

(EvaluationLink (stv 1.000000 0.000000)
  (PredicateNode "sell") ; [8621]
  (ListLink (stv 1.000000 0.000000)
    (VariableNode "$x") ; [8615]
    (VariableNode "$y") ; [8618]
    (VariableNode "$z") ; [8622]
  ) ; [8623]
) ; [8624]

Then do

(cog-satisfy (VariableNode "$B"))

gives me

Backtrace:
In ice-9/boot-9.scm:
 157: 10 [catch #t #<catch-closure 3ec3120> ...]
In unknown file:
   ?: 9 [apply-smob/1 #<catch-closure 3ec3120>]
In ice-9/boot-9.scm:
 157: 8 [catch #t #<catch-closure 38a2fe0> ...]
In unknown file:
   ?: 7 [apply-smob/1 #<catch-closure 38a2fe0>]
   ?: 6 [call-with-input-string "(cog-satisfy (VariableNode \"$B\"))\n" ...]
In ice-9/boot-9.scm:
2320: 5 [save-module-excursion #<procedure 3847600 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
  44: 4 [read-and-eval #<input: string 381c5b0> #:lang ...]
  37: 3 [lp (cog-satisfy (VariableNode "$B"))]
In unknown file:
   ?: 2 [opencog-extension cog-satisfy ((VariableNode "$B")
)]
In ice-9/boot-9.scm:
 102: 1 [#<procedure 38a3940 at ice-9/boot-9.scm:97:6 (thrown-k . args)> C++-EXCEPTION ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 38a2fa0> C++-EXCEPTION ...]

ERROR: In procedure apply-smob/1:
ERROR: In procedure cog-satisfy: Expecting GroundedPredicateNode! (/home/william/atomspace/opencog/atoms/execution/EvaluationLink.cc:177)
ABORT: C++-EXCEPTION

Why is that?

misgeatgit commented 9 years ago

But where is Var node $B ?

williampma commented 9 years ago

$B is to be mapped to all possible atoms inside

(EvaluationLink (stv 1.000000 0.000000)
  (PredicateNode "sell") ; [8621]
  (ListLink (stv 1.000000 0.000000)
    (VariableNode "$x") ; [8615]
    (VariableNode "$y") ; [8618]
    (VariableNode "$z") ; [8622]
  ) ; [8623]
) ; [8624]

right?

misgeatgit commented 9 years ago

I was just guessing. But even after inserting VariableNode $B and doing what u did, causes the same fault.

williampma commented 9 years ago

This uses to work last week. Probably the changes in https://github.com/opencog/atomspace/commit/b6256a356281e02ebc1ef158983134e926f1ffc4 treats all EvaluationLink as evaluatable.

linas commented 9 years ago

working on it. $B is being mapped to the evaluation link itself, and then the new code tries to execute it, and discovers it is not of the desired form. Will push a fix shortly.

linas commented 9 years ago

should be fixed now

linas commented 9 years ago

sorry, "haste makes waste" as they say.

williampma commented 9 years ago

Thanks, Linas!

williampma commented 9 years ago

Hello~ Sorry to be a bother, but this error is popping up again.

This time, have this in the atomspace

   (ImplicationLink
      (AndLink
         (EvaluationLink
            (PredicateNode "croaks")
            (ConceptNode "Fritz")
         )
         (EvaluationLink
            (PredicateNode "eats_flies")
            (ConceptNode "Fritz")
         )
      )
      (InheritanceLink
         (ConceptNode "Fritz")
         (ConceptNode "Frog")
      )
   )

Then do

(cog-satisfy
(AndLink (stv 1.000000 0.000000)
  (AndLink (stv 1.000000 0.000000)
    (EvaluationLink (stv 1.000000 0.000000)
      (PredicateNode "croaks") ; [3678]
      (VariableNode "$X") ; [3679]
    ) ; [3680]
    (EvaluationLink (stv 1.000000 0.000000)
      (PredicateNode "eats_flies") ; [3681]
      (VariableNode "$X") ; [3679]
    ) ; [3682]
  ) ; [3683]
  (ImplicationLink (stv 1.000000 0.000000)
    (AndLink (stv 1.000000 0.000000)
      (EvaluationLink (stv 1.000000 0.000000)
        (PredicateNode "croaks") ; [3678]
        (VariableNode "$X") ; [3679]
      ) ; [3680]
      (EvaluationLink (stv 1.000000 0.000000)
        (PredicateNode "eats_flies") ; [3681]
        (VariableNode "$X") ; [3679]
      ) ; [3682]
    ) ; [3683]
    (InheritanceLink (stv 1.000000 0.000000)
      (VariableNode "$X") ; [3679]
      (ConceptNode "Frog") ; [3684]
    ) ; [3685]
  ) ; [3686]
) ; [4970]
)

results in "Expecting GroundedPredicateNode!" again.

linas commented 9 years ago

well, this time it is "working as designed". We can change the design, but it would need some serious thinking & discussion. The issue is with the two nested AndLinks. Get rid of the inner AndLink and things will work as expected.

The wiki tries to explain this, but maybe not very clearly. I'm fixing the wiki now.

linas commented 9 years ago

OK, so I rewrote this section: http://wiki.opencog.org/w/SatisfactionLink_and_BindLink#Satisfiability to explain what is going on. The second, nested AndLink is turning that clause into an 'evaluatable' clause: the system is trying to run it, to find out if it is true or false. It is NOT doing a pattern-match! it is doing a true-false evaluation. Without the GPN, it does not know if it is true or false, and so throws an exception.

williampma commented 9 years ago

Humm... I see. That might make working with the modus ponens rule a bit awkward. I have to think about it.

Should I stop using SatisfactionLink for Pattern Matching?

linas commented 9 years ago

Well, we could invent new links types: say: BooleanAndLink, BooleanOrLink, BooleanNotLink; that would allow the crisp-truth combination of crisp terms like greater-than, etc. It would then allow AndLink to be searched for as a regular pattern.

you should continue to use SatisfactionLink for pattern matching .. that has not changed ... (well, it is almost identical to GetLink ... we have not decided to get rid of one or the other.

linas commented 8 years ago

I just discovered a work-around for you, that does what you want: it is this:

(cog-satisfy
(AndLink
  (ChoiceLink
  (AndLink
    (EvaluationLink
      (PredicateNode "croaks")
      (VariableNode "$X")
    )
    (EvaluationLink
      (PredicateNode "eats_flies")
      (VariableNode "$X")
    )
  ))
  (ImplicationLink
    (AndLink
      (EvaluationLink
        (PredicateNode "croaks")
        (VariableNode "$X")
      )
      (EvaluationLink
        (PredicateNode "eats_flies")
        (VariableNode "$X")
      )
    )
    (InheritanceLink
      (VariableNode "$X")
      (ConceptNode "Frog")
    )
  ) ) )

Basically, the AndLink gets wrapped with a ChoiceLink. The arity-1 ChoiceLink is identical to an arity-1 PresentLink -- it evaluates to 'true' when the thing that it's wrapping is present in the atomspace.

For additional discussion, see http://wiki.opencog.org/w/PresentLink -- but in short, I think this work-around does exactly what you need, and I think/hope its sufficient for your purposes, right?

linas commented 8 years ago

Closing; remaining work to be covered by issue #218 -- i.e. implement PresentLink.