Some basic questions about code in 'knowledge.scm' and 'imperative.scm' files

24 views
Skip to first unread message

Apil Tamang

unread,
Nov 23, 2016, 8:46:44 AM11/23/16
to opencog
Hi All,

Had a look through the 'knowledge.scm' and 'imperative.scm' files. Also, learning scheme syntax on the fly here... Have a couple of some fundamental questions which I believe would aide my understanding:

What are the differences between some very look-alike nodes such as: 
  - Reference Vs ReferenceLink, 
  - WordNode Vs Word, 
  - ConceptNode Vs Concept 
  - AnchorNode Vs Anchor ? 

Also, what do the nodes: "DefinedSchema", "DefinedPredicate" mean? Line 204 says: 

(Inheritance (Anchor "*-gaze-direction-*") (Concept "model-direction"))

Do the asterisk mean a wild-card matching?
 

The code here is a bit more involved, but I think I managed to understand most of it after reading about scheme a little. A few things I'm still in the dark are:

- What do 'DECL' semantically mean in this code? I'm comparing this against identifiers such as 'VERB-LIST' or 'LINKS' which are obvious by their names.
 
- I see that rules 'look-rule-1' and 'look-rule-2' have been redefined in this code, the second time using a template. I suppose scheme will just override the function bindings to these rules, so we won't really have a problem running the script. Thus, do we really need to maintain the earlier definitions for 'look-rule-1' and 'look-rule-2' ?
 
- Looked at this line over and over again. I still cannot completely parse this code against the standard Scheme syntax. How does this line work (or what does it do)? I suppose 'stv' stands for 'standard truth value' and 'print-msg' and 'display' are some scheme keywords for echoing data. Aside from just printing, what bindings happen within this statement?

(define (print-msg node) (display (cog-name node)) (newline) (stv 1 1))

Linas Vepstas

unread,
Nov 23, 2016, 9:03:45 PM11/23/16
to opencog
On Wed, Nov 23, 2016 at 9:46 PM, Apil Tamang <apil.tama...@gmail.com> wrote:
Hi All,

Had a look through the 'knowledge.scm' and 'imperative.scm' files.

FYI I plan on making major overhauls to these and nearby files over the next month
 
Also, learning scheme syntax on the fly here... Have a couple of some fundamental questions which I believe would aide my understanding:

What are the differences between some very look-alike nodes such as: 
  - Reference Vs ReferenceLink, 
  - WordNode Vs Word, 
  - ConceptNode Vs Concept 
  - AnchorNode Vs Anchor ? 

No difference. Just a short-hand.
 

Also, what do the nodes: "DefinedSchema", "DefinedPredicate" mean?

They are references to definitions elsewhere.
 
Line 204 says: 

(Inheritance (Anchor "*-gaze-direction-*") (Concept "model-direction"))

Do the asterisk mean a wild-card matching?
 
No -- asterisks are a scheme convention of indicating that something is a global (a constant, in this case)
 

The code here is a bit more involved,

Yeah. I really really needs to be simplfied.  Which is something I want to work on.
 
but I think I managed to understand most of it after reading about scheme a little. A few things I'm still in the dark are:

- What do 'DECL' semantically mean in this code? I'm comparing this against identifiers such as 'VERB-LIST' or 'LINKS' which are obvious by their names.

decl is a declaration of a variable. The way that BindLinks and GetLinks (and various other links) work is that one should declare the variables that appear in them.  DECL is just a small utility function that declares the variables.  (since declaring them is fairly verbose, otherwise)
 
- I see that rules 'look-rule-1' and 'look-rule-2' have been redefined in this code, the second time using a template. I suppose scheme will just override the function bindings to these rules, so we won't really have a problem running the script.

Yes.
Thus, do we really need to maintain the earlier definitions for 'look-rule-1' and 'look-rule-2' ?
 
No. They are there more as an example.  I was hoping that someone else would take over this code, so I wrote examples.  But this won't happen -- I'll have to do a lot of cleanup and rework.
 
 
- Looked at this line over and over again. I still cannot completely parse this code against the standard Scheme syntax. How does this line work (or what does it do)? I suppose 'stv' stands for 'standard truth value' and 'print-msg' and 'display' are some scheme keywords for echoing data. Aside from just printing, what bindings happen within this statement?

(define (print-msg node) (display (cog-name node)) (newline) (stv 1 1))

This defines a subroutine called 'print-msg' which takes one argument.  That argument better be an opencog node, because cog-name  will throw an error if it is not. The print-msg suroutiine then ends by returning the result of evaluating the last statement in it -- in this case, the stv 1 1 -- that is, it returns a simple truth value of 'TRUE_TV'    The return value allows it to be called from a GroundedPredicateNode, thus allowing it to be embedded into atomsese.

--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/521f8532-6406-4746-84b1-b1bc0f1b3d2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages