Calling forward/backward chainer

201 views
Skip to first unread message

Vishnu Priya

unread,
Dec 5, 2016, 10:18:08 AM12/5/16
to opencog
Hello all,

i would like to try the forward/backward chaining. i found these pages 

I somehow understood, how overall process goes on. 

(cog-fc *source* *rule-base* *focus-set*)
But i don't know, how I can carry out this process.  i also don't know, how to specify rule-base, focus-set.. 
Can you anyone provide the steps to carry out  chaining process ?

Thanks,
Vishnu

Nil Geisweiller

unread,
Dec 5, 2016, 11:01:54 AM12/5/16
to ope...@googlegroups.com
Hi,

the backward chainer is not mature yet, it may or not work for you, I
think it will be mature enough after 2 week.

The forward chainer should work as expected. See
http://wiki.opencog.org/w/URE_Configuration_Format to define a rule base.

See also
https://github.com/opencog/atomspace/tree/master//examples/rule-engine
as well https://github.com/opencog/opencog/tree/master/examples/pln for
examples.

Nil
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/b0170017-7cd2-415a-9d64-7ed9f154ae35%40googlegroups.com
> <https://groups.google.com/d/msgid/opencog/b0170017-7cd2-415a-9d64-7ed9f154ae35%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Vishnu Priya

unread,
Feb 10, 2017, 5:26:40 AM2/10/17
to opencog
Hi,

I tried forward chaining as in https://github.com/opencog/atomspace/tree/master/examples/rule-engine/chaining for the following problem:

1. If X croaks and X eats flies - Then X is a frog
2. If X is a frog - Then X is green

When i ran forward chainer by (cog-fc source wiki (SetLink)), i got unbound variable error.

guile> (cog-fc source wiki (SetLink))
Backtrace:
In ice-9/boot-9.scm:
 157: 12 [catch #t #<catch-closure 229ac80> ...]
In unknown file:
   ?: 11 [apply-smob/1 #<catch-closure 229ac80>]
In ice-9/boot-9.scm:
 157: 10 [catch #t #<catch-closure 229a7e0> ...]
In unknown file:
   ?: 9 [apply-smob/1 #<catch-closure 229a7e0>]
   ?: 8 [call-with-input-string "(cog-fc source wiki (SetLink))\n" ...]
In ice-9/boot-9.scm:
2320: 7 [save-module-excursion #<procedure 1e18bd0 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
  44: 6 [read-and-eval #<input: string 20ce340> #:lang ...]
  37: 5 [lp (cog-fc source wiki (SetLink))]
In ice-9/eval.scm:
 386: 4 [eval #<memoized (cog-fc source wiki (SetLink))> ()]
 393: 3 [eval #<memoized cog-fc> ()]
In unknown file:
   ?: 2 [memoize-variable-access! #<memoized cog-fc> #<directory # 13a2c60>]
In ice-9/boot-9.scm:
 102: 1 [#<procedure 18a4d40 at ice-9/boot-9.scm:97:6 (thrown-k . args)> unbound-variable ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 229a7a0> unbound-variable ...]

ERROR: In procedure apply-smob/1:
ERROR: Unbound variable: cog-fc
ABORT: unbound-variable

I have these lines in .guile:
(add-to-load-path "/usr/local/share/opencog/scm")
(use-modules (opencog))
(use-modules (opencog query))
(use-modules (opencog exec))
 (load-from-path "opencog.scm")


How can i get it working?


Thanks
Vishnu

Nil Geisweiller

unread,
Feb 10, 2017, 5:53:38 AM2/10/17
to ope...@googlegroups.com
Hi, it looks like you didn't import the rule-engine modules, see for
instance

https://github.com/opencog/atomspace/blob/master/examples/rule-engine/crisp.scm#L16

Nil
> <https://github.com/opencog/atomspace/tree/master//opencog/rule-engine#how-to-call-the-forward-chainer-from-a-scheme-interface>
>
> > http://wiki.opencog.org/w/Unified_rule_engine
> <http://wiki.opencog.org/w/Unified_rule_engine>
> >
> > I somehow understood, how overall process goes on.
> >
> > (cog-fc *source* *rule-base* *focus-set*)
> > But i don't know, how I can carry out this process. i also don't
> know,
> > how to specify rule-base, focus-set..
> > Can you anyone provide the steps to carry out chaining process ?
> >
> > Thanks,
> > Vishnu
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "opencog" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to opencog+u...@googlegroups.com <javascript:>
> > <mailto:opencog+u...@googlegroups.com <javascript:>>.
> > To post to this group, send email to ope...@googlegroups.com
> <javascript:>
> > <mailto:ope...@googlegroups.com <javascript:>>.
> <https://groups.google.com/group/opencog>.
> <https://groups.google.com/d/msgid/opencog/b0170017-7cd2-415a-9d64-7ed9f154ae35%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/68bd5322-8dec-4983-abd7-0f2e1072606b%40googlegroups.com
> <https://groups.google.com/d/msgid/opencog/68bd5322-8dec-4983-abd7-0f2e1072606b%40googlegroups.com?utm_medium=email&utm_source=footer>.

Vishnu Priya

unread,
Feb 10, 2017, 8:18:12 AM2/10/17
to opencog

Hi Nil,
 Thanks. 
I also got an exception when i typed the following line in scheme as in   

guile> (DefineLink rule1-name rule1)

Backtrace:
In ice-9/boot-9.scm:
 157: 10 [catch #t #<catch-closure 211c720> ...]
In unknown file:
   ?: 9 [apply-smob/1 #<catch-closure 211c720>]
In ice-9/boot-9.scm:
 157: 8 [catch #t #<catch-closure 2123cc0> ...]
In unknown file:
   ?: 7 [apply-smob/1 #<catch-closure 2123cc0>]
   ?: 6 [call-with-input-string "(DefineLink rule1-name rule1)\n" ...]
In ice-9/boot-9.scm:
2320: 5 [save-module-excursion #<procedure 20c07e0 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
  44: 4 [read-and-eval #<input: string 28fba90> #:lang ...]
  37: 3 [lp (DefineLink rule1-name rule1)]
In unknown file:
   ?: 2 [cog-new-link 44 (Node "rule1")
 ...]
In ice-9/boot-9.scm:
 102: 1 [#<procedure 211fd40 at ice-9/boot-9.scm:97:6 (thrown-k . args)> C++-EXCEPTION ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 2123c80> C++-EXCEPTION ...]

ERROR: In procedure apply-smob/1:
ERROR: In procedure cog-new-link: Expecting Defined(Schema/Predicate/Type)Node, got Node (/opt/atomspace/opencog/atoms/core/DefineLink.cc:47)
ABORT: C++-EXCEPTION.  


So when i ran fc,  it  showed  "ERROR: In procedure cog-fc: Cannot find defined hypergraph for atom (Node "rule1") ; [35727][1]"

Linas Vepstas

unread,
Feb 10, 2017, 2:56:26 PM2/10/17
to opencog
It looks like you did not actually define node1 before using it.

--linas
> email to opencog+u...@googlegroups.com.
> To post to this group, send email to ope...@googlegroups.com.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/c9b144df-0031-4dd5-b9b7-608a5381c3a7%40googlegroups.com.

Linas Vepstas

unread,
Feb 10, 2017, 2:59:39 PM2/10/17
to opencog
However, that example should be changed to load all modules that it
needs, instead of leaving the user to guess what needs to be done.
Its not a very user-friendly example.

Perhaps you could try to do this?

Ideally, one should be able to just run "guile -l someexample.scm" and
have it just work, with no (or minimal) junk in the ~/.guile file

--linas



On Fri, Feb 10, 2017 at 7:18 AM, Vishnu Priya <vishnup...@gmail.com> wrote:
>
> email to opencog+u...@googlegroups.com.
> To post to this group, send email to ope...@googlegroups.com.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/c9b144df-0031-4dd5-b9b7-608a5381c3a7%40googlegroups.com.

Alex

unread,
Apr 2, 2017, 4:22:15 PM4/2/17
to opencog, linasv...@gmail.com
I am also trying to run this https://github.com/opencog/atomspace/tree/master/examples/rule-engine/chaining example and I enter SCM commands one by one and I am also stopped at lines DefineLink

(define rule1-name (Node "rule1")
(DefineLink rule1-name rule1)

DefineLinke requires as the first argument not the BindLink/rule node and it requires Defined(Schema/Predicate/Type) Node. So - at present I don't understant how to proceed. As far as I understandt then these two lines prepare the BindLink for the addition to the rule base, but why should we use DefineLink? I guess these are some idiomatic lines with no clear prupose but Rule Engine requires them... 

Misgana Bayetta

unread,
Apr 2, 2017, 10:31:35 PM4/2/17
to opencog, Linas Vepstas
Hi, here are the steps to take in order to define rules and a rule base for the chainer:

step 1. Define the rules
  eg.   (define Rule_A (BindLink....) )

Step 2. Create a DefineLink
 eg. (DefineLink (DefinedSchemaNode "Rule_A")  Rule_A)

Step 3. Define a rulebase 
eg. (define RuleBase_X (InheritanceLink (ConceptNode "RuleBase_X")  (ConceptNode "URE")) )

Step 4. Add rules to rule base
eg. (ure-add-rules Rule_A RuleBase_X)

You might use this file as a template to write your custom rulebase configuration.

--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+unsubscribe@googlegroups.com.

To post to this group, send email to ope...@googlegroups.com.
Visit this group at https://groups.google.com/group/opencog.

For more options, visit https://groups.google.com/d/optout.



--
Belachew Misgana Bayetta
'For everyone who asks receives, and the one who seeks finds, and to the one who knocks it will be opened ' --Jesus
'The future belongs to those who believe in the beauty of their dreams' --Eleanor Rusvelt

Nil Geisweiller

unread,
Apr 3, 2017, 1:55:27 AM4/3/17
to ope...@googlegroups.com
There were some errors in the readme, now corrected.

Nil

On 04/02/2017 11:22 PM, Alex wrote:
> I am also trying to run
> this https://github.com/opencog/atomspace/tree/master/examples/rule-engine/chaining
> example and I enter SCM commands one by one and I am also stopped at
> lines DefineLink
>
> (define rule1-name (Node "rule1")
> *(DefineLink rule1-name rule1)*
>
> DefineLinke requires as the first argument not the BindLink/rule node
> and it requires Defined(Schema/Predicate/Type) Node. So - at present I
> don't understant how to proceed. As far as I understandt then these two
> lines prepare the BindLink for the addition to the rule base, but why
> should we use DefineLink? I guess these are some idiomatic lines with no
> clear prupose but Rule Engine requires them...
>
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/604300d3-214b-4948-b2b7-c86b2cdbdc1f%40googlegroups.com
> <https://groups.google.com/d/msgid/opencog/604300d3-214b-4948-b2b7-c86b2cdbdc1f%40googlegroups.com?utm_medium=email&utm_source=footer>.

Linas Vepstas

unread,
Apr 3, 2017, 2:31:01 AM4/3/17
to Misgana Bayetta, opencog

On Mon, Apr 3, 2017 at 5:31 AM, Misgana Bayetta <misgana...@gmail.com> wrote:
Hi, here are the steps to take in order to define rules and a rule base for the chainer:

step 1. Define the rules
  eg.   (define Rule_A (BindLink....) )

Step 2. Create a DefineLink
 eg. (DefineLink (DefinedSchemaNode "Rule_A")  Rule_A)

Step 3. Define a rulebase 
eg. (define RuleBase_X (InheritanceLink (ConceptNode "RuleBase_X")  (ConceptNode "URE")) )

Step 4. Add rules to rule base
eg. (ure-add-rules Rule_A RuleBase_X)


why is step 2 even needed in the above? The DSN is not used in either step 3 or step 4.   (I imagine it could be used in step 4 ... just that it isn't)

Nil Geisweiller

unread,
Apr 3, 2017, 2:52:36 AM4/3/17
to ope...@googlegroups.com
Step 2 is used by step 4 (it is a bit obfuscated by the helper
ure-add-rules, which creates a MemberLink between the rule name and the
rule base).

In practice, the only reason we need is to store the rule name in the
AtomSpace (the scheme rule name alone isn't loaded in the atomspace).
And this is only used to store the inference trace. Actually only the
forward chainer needs that, the backward chainer uses formula names
instead. I don't know at this point if we can afford to drop the rule
name so I prefer to let it there.

Nil
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/CAHrUA37Xqg9dMspd0JLamXHVDX9Ur3owrbtychu5a2W4AYBeWQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/opencog/CAHrUA37Xqg9dMspd0JLamXHVDX9Ur3owrbtychu5a2W4AYBeWQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Linas Vepstas

unread,
Apr 3, 2017, 3:01:26 AM4/3/17
to opencog
OK, thanks.  --linas


To post to this group, send email to ope...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+unsubscribe@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Alex

unread,
Apr 9, 2017, 10:48:39 AM4/9/17
to opencog
OK, I followed with updated tutorial https://github.com/opencog/atomspace/tree/master/examples/rule-engine/chaining and I managed to run my first cog-fc with the normal result. I would like to raise two points:

1) tutorial says that cog-fc has 4 arguments, but my version of opencog (as or start of 2017) of cog-fc still has 3 arguments: source/rule base/focus set. There is no variable-declaration argument. Just wanted to note for those who use this thread for troubleshooting cog-fc.

2) I wonder about necessity of source as an argument, why we need this? Business Rule engines (like JBoss Drools) use entire Atomspace working memory as domain for reasoning - somehow first rule is selected and matched with facts and first inference is made and so this process continues? Focus set can be emtpy Set and then the entire Atomspace becomes the focus set. Maybe we can do this with source as well - maybe empty source will designed entire Atomspace as a source?

Misgana Bayetta

unread,
Apr 9, 2017, 11:39:42 AM4/9/17
to opencog

--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+unsubscribe@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at https://groups.google.com/group/opencog.

For more options, visit https://groups.google.com/d/optout.



--

Linas Vepstas

unread,
Apr 9, 2017, 3:04:36 PM4/9/17
to opencog
On Sun, Apr 9, 2017 at 6:39 PM, Misgana Bayetta <misgana...@gmail.com> wrote:


On Sun, Apr 9, 2017 at 10:48 PM, Alex <alexand...@gmail.com> wrote:
OK, I followed with updated tutorial https://github.com/opencog/atomspace/tree/master/examples/rule-engine/chaining and I managed to run my first cog-fc with the normal result. I would like to raise two points:

1) tutorial says that cog-fc has 4 arguments, but my version of opencog (as or start of 2017) of cog-fc still has 3 arguments: source/rule base/focus set. There is no variable-declaration argument. Just wanted to note for those who use this thread for troubleshooting cog-fc.

2) I wonder about necessity of source as an argument, why we need this? Business Rule engines (like JBoss Drools) use entire Atomspace working memory as domain for reasoning - somehow first rule is selected and matched with facts and first inference is made and so this process continues? Focus set can be emtpy Set and then the entire Atomspace becomes the focus set. Maybe we can do this with source as well - maybe empty source will designed entire Atomspace as a source?


well, the wiki page, and the example/tutorial should point this out. Its a good question.  I don't even know if we have a good wiki page reviewing the forward chainer, how it works, how to use it?

--linas

--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+unsubscribe@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at https://groups.google.com/group/opencog.
To view this discussion on the web visit https://groups.google.com/d/msgid/opencog/7c03321c-8e84-408e-bfc6-24b4a72f016b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Belachew Misgana Bayetta
'For everyone who asks receives, and the one who seeks finds, and to the one who knocks it will be opened ' --Jesus
'The future belongs to those who believe in the beauty of their dreams' --Eleanor Rusvelt

--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+unsubscribe@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at https://groups.google.com/group/opencog.

Nil Geisweiller

unread,
Apr 10, 2017, 2:07:47 AM4/10/17
to ope...@googlegroups.com
I've added a bit more explanation here

http://wiki.opencog.org/w/URE_Configuration_Format#Usage

Nil

On 04/09/2017 10:04 PM, Linas Vepstas wrote:
>
>
> On Sun, Apr 9, 2017 at 6:39 PM, Misgana Bayetta
> <misgana...@gmail.com <mailto:misgana...@gmail.com>> wrote:
>
>
>
> On Sun, Apr 9, 2017 at 10:48 PM, Alex <alexand...@gmail.com
> <mailto:alexand...@gmail.com>> wrote:
>
> OK, I followed with updated tutorial
> https://github.com/opencog/atomspace/tree/master/examples/rule-engine/chaining
> <https://github.com/opencog/atomspace/tree/master/examples/rule-engine/chaining>
> and I managed to run my first cog-fc with the normal result. I
> would like to raise two points:
>
> 1) tutorial says that cog-fc has 4 arguments, but my version of
> opencog (as or start of 2017) of cog-fc still has 3 arguments:
> source/rule base/focus set. There is no variable-declaration
> argument. Just wanted to note for those who use this thread for
> troubleshooting cog-fc.
>
> 2) *I wonder about necessity of/_source_ /as an argument, why we
> need this? *Business Rule engines (like JBoss Drools) use entire
> Atomspace working memory as domain for reasoning - somehow first
> rule is selected and matched with facts and first inference is
> made and so this process continues? Focus set can be emtpy Set
> and then the entire Atomspace becomes the focus set. Maybe we
> can do this with source as well - maybe empty source will
> designed entire Atomspace as a source?
>
>
> Yes, you can pass empty SetLink. see here
> https://github.com/opencog/atomspace/blob/master/opencog/rule-engine/forwardchainer/ForwardChainer.cc#L110
> <https://github.com/opencog/atomspace/blob/master/opencog/rule-engine/forwardchainer/ForwardChainer.cc#L110>.
>
>
> well, the wiki page, and the example/tutorial should point this out. Its
> a good question. I don't even know if we have a good wiki page
> reviewing the forward chainer, how it works, how to use it?
>
> --linas
>
> --
> You received this message because you are subscribed to the
> Google Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> <https://groups.google.com/group/opencog>.
> <https://groups.google.com/d/msgid/opencog/7c03321c-8e84-408e-bfc6-24b4a72f016b%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
>
>
> --
> Belachew Misgana Bayetta
> 'For everyone who asks receives, and the one who seeks finds, and to
> the one who knocks it will be opened ' --Jesus
> 'The future belongs to those who believe in the beauty of their
> dreams' --Eleanor Rusvelt
>
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> <https://groups.google.com/group/opencog>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/CAOgrVvWaBFaV65C77%2BVHZcVgjxRTin5XXp68Nw%3Dt_7UkVsE0ZQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/opencog/CAOgrVvWaBFaV65C77%2BVHZcVgjxRTin5XXp68Nw%3Dt_7UkVsE0ZQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/CAHrUA37Jb1jzzCgs6kcb7W9rp_0-bKuD-LXyma3fjdFgQMZJCw%40mail.gmail.com
> <https://groups.google.com/d/msgid/opencog/CAHrUA37Jb1jzzCgs6kcb7W9rp_0-bKuD-LXyma3fjdFgQMZJCw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Vishnu Priya

unread,
Apr 20, 2017, 3:54:10 PM4/20/17
to opencog


I  installed the recent version and tried FC. Previously i used to work with only three arguments. But now as it requires four parameters, i gave empty ListLink additionally. But it throws Error. 

My scm has: 
  
 (load "/opt/opencog/opencog/pln/rules/deduction-rule.scm") 

(InheritanceLink (stv 0.9 0.9)
    (ConceptNode "tom")
    (ConceptNode "human"))


(InheritanceLink (stv 0.9 0.9)
    (ConceptNode "human")
    (ConceptNode "speak"))


(define source
(InheritanceLink (stv 0.9 0.9)
    (ConceptNode "tom")
    (ConceptNode "human")))


(define base (ConceptNode "rule-base"))

(InheritanceLink  
  (ConceptNode "rule-base")
  (ConceptNode "URE")
)

(ExecutionLink
   (SchemaNode "URE:maximum-iterations")
   (ConceptNode "rule-base")
   (NumberNode 20)
)

(MemberLink (stv 0.9 1)
  deduction-inheritance-rule-name
  (ConceptNode "rule-base")
)

(MemberLink (stv 0.5 1)
  deduction-implication-rule-name
  (ConceptNode "rule-base")
)

(MemberLink (stv 0.5 1)
  deduction-subset-rule-name
  (ConceptNode "rule-base")
)

When i run, 
(cog-fc source base (List) (SetLink))

I get the following:

Backtrace:
In ice-9/boot-9.scm:
 157: 10 [catch #t #<catch-closure 46b4260> ...]
In unknown file:
   ?: 9 [apply-smob/1 #<catch-closure 46b4260>]
In ice-9/boot-9.scm:
 157: 8 [catch #t #<catch-closure 46b4140> ...]
In unknown file:
   ?: 7 [apply-smob/1 #<catch-closure 46b4140>]
   ?: 6 [call-with-input-string "(cog-fc source base (List) (SetLink))\n" ...]
In ice-9/boot-9.scm:
2320: 5 [save-module-excursion #<procedure 2f77cf0 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
  44: 4 [read-and-eval #<input: string 46b5270> #:lang ...]
  37: 3 [lp (cog-fc source base (List) (SetLink))]
In unknown file:
   ?: 2 [opencog-extension cog-fc (# # # #)]
In ice-9/boot-9.scm:
 102: 1 [#<procedure 4a9da80 at ice-9/boot-9.scm:97:6 (thrown-k . args)> C++-EXCEPTION ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 46b4100> C++-EXCEPTION ...]

ERROR: In procedure apply-smob/1:
ERROR: In procedure cog-fc: Not a node! (/home/vishnu/atomspace/opencog/atoms/base/Atom.h:193)
Function args:
((InheritanceLink (stv 0,9 0,9)
   (ConceptNode "tom")
   (ConceptNode "human")
)
 (ConceptNode "rule-base")
 (ListLink
)
 (SetLink
)
)
ABORT: C++-EXCEPTION



Linas Vepstas

unread,
Apr 21, 2017, 10:50:13 AM4/21/17
to opencog
Maybe the (List) should have been a node?? At any rate, cog-fc should check its arguments for validity, before proceeding.

--linas

--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+unsubscribe@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Vishnu Priya

unread,
Apr 21, 2017, 10:55:40 AM4/21/17
to opencog

Hi Linas,

I have also tried providing variable declaration parameter and ran myfrog.scm

(cog-fc source wiki (VariableNode "x" ) (SetLink)). Still got the same error. :-(

 Backtrace:
In ice-9/boot-9.scm:
 157: 10 [catch #t #<catch-closure 49b2d40> ...]
In unknown file:
   ?: 9 [apply-smob/1 #<catch-closure 49b2d40>]
In ice-9/boot-9.scm:
 157: 8 [catch #t #<catch-closure 49b2c20> ...]
In unknown file:
   ?: 7 [apply-smob/1 #<catch-closure 49b2c20>]
   ?: 6 [call-with-input-string "(cog-fc source wiki (VariableNode \"x\" ) (SetLink))\n" ...]
In ice-9/boot-9.scm:
2320: 5 [save-module-excursion #<procedure 30b2f00 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
  44: 4 [read-and-eval #<input: string 49a6c30> #:lang ...]
  37: 3 [lp (cog-fc source wiki (VariableNode "x") (SetLink))]
In unknown file:
   ?: 2 [opencog-extension cog-fc (# # # #)]
In ice-9/boot-9.scm:
 102: 1 [#<procedure 499fb80 at ice-9/boot-9.scm:97:6 (thrown-k . args)> C++-EXCEPTION ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 49b2be0> C++-EXCEPTION ...]

ERROR: In procedure apply-smob/1:
ERROR: In procedure cog-fc: Not a node! (/home/vishnu/atomspace/opencog/atoms/base/Atom.h:193)
Function args:
((InheritanceLink
   (ConceptNode "fritz")
   (ConceptNode "croaks")
)
 (ConceptNode "wikipedia-fc")
 (VariableNode "x")
 (SetLink
)
)
ABORT: C++-EXCEPTION



Thanks and regards,
Vishnu
myfrog.scm

Linas Vepstas

unread,
Apr 21, 2017, 11:58:21 AM4/21/17
to opencog, Nil Geisweiller
I assume that this is a bug somewhere, in the example, or wherever, and Nil is the one to look at it. If this is in regard to a block of code in some examples directory, open a bug report.  If you want to be totally awesome .... then track down the bug, and provide a patch?

--linas

--
You received this message because you are subscribed to the Google Groups "opencog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opencog+unsubscribe@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.

Nil Geisweiller

unread,
Apr 21, 2017, 1:47:13 PM4/21/17
to ope...@googlegroups.com
Hi Vishnu,

that's cause now the rule base comes first, as documented here
http://wiki.opencog.org/w/URE_Configuration_Format#Usage

you need to enter

(cog-fc base source (List) (SetLink))

I did that change while streamlining the FC and the BC APIs.

So he URE tried to parse your source as if it were a rule-base. It's not
a bug but ideally the URE should be able to detect that user error and
return an appropriate message. If you could create an issue for that,
that would be awesome, otherwise let me know I'll do it.

Nil
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/640355b3-8649-4ee3-a682-85bbeb76811b%40googlegroups.com
> <https://groups.google.com/d/msgid/opencog/640355b3-8649-4ee3-a682-85bbeb76811b%40googlegroups.com?utm_medium=email&utm_source=footer>.

Nil Geisweiller

unread,
Apr 21, 2017, 1:48:41 PM4/21/17
to ope...@googlegroups.com
Needless to say if you've got that from a documentation or example file,
let me know so you or I can update it.

Nil

On 04/20/2017 10:54 PM, Vishnu Priya wrote:
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/640355b3-8649-4ee3-a682-85bbeb76811b%40googlegroups.com
> <https://groups.google.com/d/msgid/opencog/640355b3-8649-4ee3-a682-85bbeb76811b%40googlegroups.com?utm_medium=email&utm_source=footer>.

Vishnu Priya

unread,
Apr 21, 2017, 5:09:13 PM4/21/17
to opencog


Thanks Nil. Yeah. That was the problem. I have mistakenly entered the parameters. I did not get from any example file. Now it works as expected. 
I have also created a GitHub Issue for not returning appropriate err message. 


Cheers,
Vishnu



    


  

Nil Geisweiller

unread,
Apr 21, 2017, 5:22:34 PM4/21/17
to ope...@googlegroups.com
Cool. Thanks. It's not high priority, though still important, to have a
user error check so it might take a while before I add it. Of course if
you or anyone wants to give it a stab it's always welcome.

Nil
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/0bb6bf13-5ea0-46ec-948b-86c5b03ae9e5%40googlegroups.com
> <https://groups.google.com/d/msgid/opencog/0bb6bf13-5ea0-46ec-948b-86c5b03ae9e5%40googlegroups.com?utm_medium=email&utm_source=footer>.

Vishnu Priya

unread,
Apr 22, 2017, 11:53:03 AM4/22/17
to opencog


Hi Nil,

Currently, as there are no working example files for FC/BC, i thought i could come up with some examples and contribute. 

So far, i have tested simple rule like Deduction and got that working. But now i wanted to try some other different rule.  

So, as per https://github.com/opencog/atomspace/blob/master/tests/rule-engine/BackwardChainerUTest.cxxtest#L510,   where on "criminal.scm",  few rules  (conditional-instantiation-meta-rule.scm, fuzzy-conjunction-introduction-rule.scm, deduction rule) have been applied for testing. I have also tried the same rules on same input but i does not get any inference. I got only empty SetLink.

I have attached the input file for your reference.

i also tested the same rules on animals.scm example but got no output. :-(

I don't know what is missing here. It would be very helpful if i get some help. 

Thanks in advance,
Vishnu
Criminal.scm

Nil Geisweiller

unread,
Apr 23, 2017, 3:00:10 AM4/23/17
to ope...@googlegroups.com
Hi Vishnu,

there are actually examples (besides the unit tests) under

<ATOMSPACE_REPO>/examples/rule-engine

including the animal (called frog).

There are also examples of PLN under

<OPENCOG_REPO>/examples/pln

not all of these examples are complete though.

Adding more examples is welcome good, feel free to create PRs for that
if you want to.

Thanks,
Nil
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/2ef709b3-8166-4707-bd9a-486c30c9323d%40googlegroups.com
> <https://groups.google.com/d/msgid/opencog/2ef709b3-8166-4707-bd9a-486c30c9323d%40googlegroups.com?utm_medium=email&utm_source=footer>.

Vishnu Priya

unread,
Apr 24, 2017, 8:46:44 AM4/24/17
to opencog


Thanks Nil. I did not know this recently added  page.!! That was very helpful.
 
I tried BC and got the expected result.
  But when i run FC, as shown in  https://github.com/opencog/atomspace/tree/master/examples/rule-engine/frog under the heading "Forward Chainer",  i got some weird ouput but i followed the same steps with no change: 
 
guile> (cog-fc ci-rbs source vardecl focus-set)
(SetLink
   (AndLink (stv 0 1)
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
      (EvaluationLink (stv 0 1)
         (PredicateNode "URE:attention-allocation")
         (ConceptNode "ci-rbs")
      )
   )
   (AndLink (stv 1 1)
      (EvaluationLink (stv 1 1)
         (PredicateNode "eats_flies")
         (ConceptNode "Fritz")
      )
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
   )
   (AndLink
      (InheritanceLink
         (ConceptNode "ci-rbs")
         (ConceptNode "URE")
      )
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
   )
   (AndLink
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
      (EvaluationLink
         (PredicateNode "eats_flies")
         (VariableNode "$X")
      )
   )
   (AndLink (stv 1 1)
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (AndLink
      (EvaluationLink
         (PredicateNode "croaks")
         (VariableNode "$X")
      )
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
   )
   (AndLink
      (InheritanceLink
         (VariableNode "$X")
         (ConceptNode "green")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (InheritanceLink (stv 1 1)
      (ConceptNode "Fritz")
      (ConceptNode "green")
   )
   (AndLink
      (InheritanceLink
         (VariableNode "$X")
         (ConceptNode "frog")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (InheritanceLink (stv 1 1)
      (ConceptNode "Fritz")
      (ConceptNode "frog")
   )
   (AndLink (stv 1 1)
      (EvaluationLink (stv 1 1)
         (PredicateNode "eats_flies")
         (ConceptNode "Fritz")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (AndLink
      (InheritanceLink
         (ConceptNode "ci-rbs")
         (ConceptNode "URE")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (AndLink
      (EvaluationLink
         (PredicateNode "eats_flies")
         (VariableNode "$X")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (AndLink (stv 1 1)
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (AndLink (stv 0 1)
      (EvaluationLink (stv 0 1)
         (PredicateNode "URE:attention-allocation")
         (ConceptNode "ci-rbs")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (AndLink
      (EvaluationLink
         (PredicateNode "croaks")
         (VariableNode "$X")
      )
      (EvaluationLink (stv 1 1)
         (PredicateNode "croaks")
         (ConceptNode "Fritz")
      )
   )
   (AndLink (stv 1 1)
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
   )
   (AndLink (stv 1 1)
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "frog")
      )
   )
   (AndLink
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
      (InheritanceLink
         (VariableNode "$X")
         (ConceptNode "green")
      )
   )
   (AndLink
      (InheritanceLink (stv 1 1)
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
      (InheritanceLink
         (VariableNode "$X")
         (ConceptNode "frog")
      )
   )
)



I  tried also with my own small modified input. But  got similar random output.  :-(


Thanks,
vishnu

Nil Geisweiller

unread,
Apr 24, 2017, 2:20:43 PM4/24/17
to ope...@googlegroups.com
Hi,

On 04/24/2017 03:46 PM, Vishnu Priya wrote:
> But when i run FC, as shown in
> https://github.com/opencog/atomspace/tree/master/examples/rule-engine/frog
> under the heading "*Forward Chainer*", i got some weird ouput but i
> followed the same steps with no change:
>
> guile> (cog-fc ci-rbs source vardecl focus-set)
> ...
> (InheritanceLink (stv 1 1)
> (ConceptNode "Fritz")
> (ConceptNode "green")
> )

You did get the result actually, amongst many others. So it works,
however this result

> (AndLink
> (InheritanceLink
> (VariableNode "$X")
> (ConceptNode "frog")
> )
> (EvaluationLink (stv 1 1)
> (PredicateNode "croaks")
> (ConceptNode "Fritz")
> )
> )

with null confidence indicates that some rule got triggered for no
reason, so I should look into that.

Nil
> --
> You received this message because you are subscribed to the Google
> Groups "opencog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to opencog+u...@googlegroups.com
> <mailto:opencog+u...@googlegroups.com>.
> To post to this group, send email to ope...@googlegroups.com
> <mailto:ope...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/opencog.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/opencog/d99a6d22-de17-42a5-b76e-a4a5f98049e1%40googlegroups.com
> <https://groups.google.com/d/msgid/opencog/d99a6d22-de17-42a5-b76e-a4a5f98049e1%40googlegroups.com?utm_medium=email&utm_source=footer>.

Vishnu Priya

unread,
Apr 26, 2017, 8:05:38 AM4/26/17
to opencog


I think, it's not only the problem of null confidence. Because this time, i did not get any convincing result but got something like this:
  ................
 (AndLink
      (EvaluationLink
         (DefinedLinguisticRelationshipNode "_det")
         (ListLink
            (VariableNode "$iobj")
            (VariableNode "$qVar")
         )
AndLink
      (EvaluationLink
         (LinkGrammarRelationshipNode "Qd")
         (ListLink
            (VariableNode "$wall-inst")
            (VariableNode "$word-inst")
         ).....................

I have attached Knowledge base, rule base and result for your reference. 
For the same knowledge base, and rule base,  BC works as expected.

knowledge-base.scm
rule-base.scm
Result.scm
Reply all
Reply to author
Forward
0 new messages