opencog / atomspace

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

ERROR: In procedure cog-reduce!: Expecting a FoldLink #353

Closed amebel closed 8 years ago

amebel commented 9 years ago

running https://github.com/opencog/atomspace/blob/master/examples/guile/get-put.scm#L40

guile> (show-eval-links)
(EvaluationLink
   (PredicateNode "some property")
   (VariableNode "$x")
)
#f
guile> (cog-reduce! to-be-added)
Backtrace:
In ice-9/boot-9.scm:
 157: 10 [catch #t #<catch-closure 1a2c9c0> ...]
In unknown file:
   ?: 9 [apply-smob/1 #<catch-closure 1a2c9c0>]
In ice-9/boot-9.scm:
 157: 8 [catch #t #<catch-closure 1a2c4e0> ...]
In unknown file:
   ?: 7 [apply-smob/1 #<catch-closure 1a2c4e0>]
   ?: 6 [call-with-input-string "(cog-reduce! to-be-added)\n" ...]
In ice-9/boot-9.scm:
2320: 5 [save-module-excursion #<procedure 1d73750 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
  44: 4 [read-and-eval #<input: string 1d5f340> #:lang ...]
  37: 3 [lp (cog-reduce! to-be-added)]
In unknown file:
   ?: 2 [opencog-extension cog-reduce! (#)]
In ice-9/boot-9.scm:
 102: 1 [#<procedure 1f2dfc0 at ice-9/boot-9.scm:97:6 (thrown-k . args)> C++-EXCEPTION ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 1a2c4a0> C++-EXCEPTION ...]

ERROR: In procedure apply-smob/1:
ERROR: In procedure cog-reduce!: Expecting a FoldLink (PlusLink, TimesLink, etc (/atomspace/opencog/atoms/execution/ExecSCM.cc:54)
ABORT: C++-EXCEPTION
linas commented 9 years ago

Functioning as designed; you can only call cog-reduce on reducible atoms.

Anyway, I've sort of decided that cog-reduce is maybe a bad idea, and should almost surely be removed or re-thought and re-designed. The general concept of reduction would be better handled by the URE, after writing some rules that know how to reduce things. Reducing a hand-full of arithmetic nodes in C++ code is ... a poor design choice.

To be clear, buy "reduce" I really mean this: https://en.wikipedia.org/wiki/Rewriting which is what the URE is supposed to be doing, in general.