Giter Club home page Giter Club logo

opencog / atomspace Goto Github PK

View Code? Open in Web Editor NEW
795.0 86.0 225.0 165.93 MB

The OpenCog (hyper-)graph database and graph rewriting system

Home Page: https://wiki.opencog.org/w/AtomSpace

License: Other

Scheme 32.41% Shell 0.16% Python 1.93% C 0.05% CMake 3.39% C++ 59.03% Haskell 1.05% GDB 0.01% TeX 0.51% Cython 1.42% OCaml 0.04%
graph-database knowledge-representation query-engine logic-programming knowledge-graph knowledge-base query-language relational-database relational-algebra rewrite-system

atomspace's People

Contributors

alex-van-der-peet avatar amebel avatar czhedu avatar edajade avatar ferrouswheel avatar githart avatar huangdeheng avatar inflector avatar jswiergo avatar kasimebrahim avatar keyvan-m-sadeghi avatar kizzobot avatar leungmanhin avatar linas avatar marcospividori avatar misgeatgit avatar ngeiswei avatar noskill avatar rekino avatar rtreutlein avatar sebastianruder avatar shujingke avatar stellarspot avatar themixed avatar timothywangdev avatar tnick avatar tpsjr7 avatar vsbogd avatar williampma avatar xiaohui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atomspace's Issues

Evaluatable in non-logical link inside BindLink clause

Just thought I would throw this out there. Doing cog-bind on the following craziness

(BindLink
    (VariableList (stv 1.000000 0.000000)
        (VariableNode "$A") ; [80]
        (VariableNode "$B") ; [92]
        (VariableNode "$C") ; [103]
    )
    (MemberLink (stv 1.000000 1.000000)
        (BindLink (stv 1.000000 0.000000)
            (VariableList (stv 1.000000 0.000000)
                (TypedVariableLink (stv 1.000000 0.000000)
                    (VariableNode "$A") ; [80]
                    (TypeNode "ConceptNode") ; [100]
                ) ; [101]
                (TypedVariableLink (stv 1.000000 0.000000)
                    (VariableNode "$B") ; [92]
                    (TypeNode "ConceptNode") ; [100]
                ) ; [102]
                (TypedVariableLink (stv 1.000000 0.000000)
                    (VariableNode "$C") ; [103]
                    (TypeNode "ConceptNode") ; [100]
                ) ; [104]
            ) ; [105]
            (AndLink (stv 1.000000 0.000000)
                (InheritanceLink (stv 1.000000 0.000000)
                    (VariableNode "$A") ; [80]
                    (VariableNode "$B") ; [92]
                ) ; [106]
                (InheritanceLink (stv 1.000000 0.000000)
                    (VariableNode "$B") ; [92]
                    (VariableNode "$C") ; [103]
                ) ; [107]
                (NotLink (stv 1.000000 0.000000)
                    (EqualLink (stv 1.000000 0.000000)
                        (VariableNode "$A") ; [80]
                        (VariableNode "$C") ; [103]
                    ) ; [108]
                ) ; [109]
            ) ; [110]
            (ExecutionOutputLink (stv 1.000000 0.000000)
                (GroundedSchemaNode "scm: pln-formula-simple-deduction") ; [111]
                (ListLink (stv 1.000000 0.000000)
                    (InheritanceLink (stv 1.000000 0.000000)
                        (VariableNode "$A") ; [80]
                        (VariableNode "$B") ; [92]
                    ) ; [106]
                    (InheritanceLink (stv 1.000000 0.000000)
                        (VariableNode "$B") ; [92]
                        (VariableNode "$C") ; [103]
                    ) ; [107]
                    (InheritanceLink (stv 1.000000 0.000000)
                        (VariableNode "$A") ; [80]
                        (VariableNode "$C") ; [103]
                    ) ; [112]
                ) ; [113]
            ) ; [114]
        ) ; [115]
        (ConceptNode "URE") ; [116]
    ) ; [118]
    (ListLink
        (VariableNode "$A") ; [80]
        (VariableNode "$B") ; [92]
        (VariableNode "$C") ; [103]
    )
)

gives me

ERROR: In procedure cog-bind: Unknown logical connective (MemberLink (stv 1.000000 1.000000)
...

I stumbled upon this when the BC algorithm tried to backward chain an untyped (VariableNode "$stuff") target (from modus ponens rule), which match to everything in the atomspace. Then since the variables inside the interior MemberLink are by current algorithmic definition "free", the MemberLink is added as a target as a "Variable Fullfillment Query", and then generate the above error when trying to ground it.

(use-modules (opencog)) doesn't seem to load scheme files

According to opencog/scm/opencog.scm scheme files like utilities.scm should be automatically loaded but aren't.

I've added a bunch of (display "~~~ N ~~~:") in opencog/scm/opencog.scm to see whether those loading lines are executed, they seem to be. I'm really puzzled, see below:

nilg@laptop:~/OpenCog/opencog/opencog/reasoning/pln$ guile --no-auto-compile
;;; note: source file /usr/local/share/opencog/scm/opencog.scm
;;;       newer than compiled /home/nilg/.cache/guile/ccache/2.0-LE-8-2.0/usr/local/share/opencog/scm/opencog.scm.go
~~~ 1 ~~~:~~~ 2 ~~~:~~~ 3 ~~~:~~~ 4 ~~~:~~~ 5 ~~~:GNU Guile 2.0.9
Copyright (C) 1995-2013 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (use-modules (opencog))
scheme@(guile-user)> (stv 1 1)
;;; <stdin>:2:0: warning: possibly unbound variable `stv'
<unnamed port>:2:0: In procedure #<procedure 1ba5020 at <current input>:2:0 ()>:
<unnamed port>:2:0: In procedure module-lookup: Unbound variable: stv

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> (load-from-path "utilities.scm")
scheme@(guile-user) [1]> (stv 1 1)
$1 = (stv 1 0.99999982)

As you can see (stv 1 1) only runs after re-loading utilities.scm. Obviously (using-modules (opencog)) is present in my .guile config file. Running out of idea, any advice is welcome, thanks!

forward chaining crashes with the nlp parse for sentences

I was making scheme code to load sentences into atom space and apply r2l scheme rules on them with forward chaining but it causes a crash. below are the details.

The code is available at

https://github.com/yantrabuddhi/opencog/tree/examples/opencog/nlp/relex2logic

https://github.com/yantrabuddhi/opencog/blob/examples/opencog/nlp/scm/nlp-fc.scm

guile> (load-scm-from-file "../opencog/nlp/scm/nlp-fc.scm")
0
guile> (nlp-files-fc "/home/mandeep/cat.txt" "../opencog/nlp/relex2logic/loader/load-rules.scm")
Connection closed by foreign host.
================================
[2015-07-21 10:15:39:106] [ERROR] Caught signal 11 (Segmentation fault) on thread 140567590885120
    Stack Trace:
    2: ./opencog/server/cogserver (opencog::Logger::Base::~Base() +0x5e) [0x4080de]
    3: ./opencog/server/cogserver (sighand(int) +0xe9) [0x407719]
    4: /lib/x86_64-linux-gnu/libc.so.6 (x +0x36d40) [0x7fd885382d40]
    5: /usr/local/lib/opencog/libquery.so (opencog::PatternMatchEngine::explore_link_branches(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&) +0x3b) [0x7fd876faa4ab]
    6: /usr/local/lib/opencog/libquery.so (opencog::InitiateSearchCB::neighbor_search(opencog::PatternMatchEngine*) +0x179) [0x7fd876f97cd9]
    7: /usr/local/lib/opencog/libquery.so (opencog::InitiateSearchCB::disjunct_search(opencog::PatternMatchEngine*) +0x55) [0x7fd876f9a6a5]
    8: /usr/local/lib/opencog/libquery.so (opencog::PatternLink::satisfy(opencog::PatternMatchCallback&) const +0x10e4) [0x7fd876fa16b4]
    9: /usr/local/lib/opencog/libruleengine.so (opencog::DefaultForwardChainerCB::choose_rules(opencog::FCMemory&) +0x86e) [0x7fd8739990fe]
    10: /usr/local/lib/opencog/libruleengine.so (opencog::ForwardChainer::do_step(opencog::ForwardChainerCallBack&) +0x157) [0x7fd873992e37]
    11: /usr/local/lib/opencog/libruleengine.so (opencog::ForwardChainer::do_chain(opencog::ForwardChainerCallBack&, opencog::Handle) +0x457) [0x7fd873993d87]
    12: /usr/local/lib/opencog/libruleengine.so (opencog::InferenceSCM::do_forward_chaining(opencog::Handle, opencog::Handle) +0x13d) [0x7fd8739a041d]
    13: /usr/local/lib/opencog/libruleengine.so (opencog::SchemePrimitive<opencog::InferenceSCM>::invoke(scm_unused_struct*) +0x10f5) [0x7fd8739a2145]
    14: /usr/local/lib/opencog/libsmob.so (opencog::PrimitiveEnviron::do_call(scm_unused_struct*, scm_unused_struct*) +0x24) [0x7fd884644b64]
    15: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0xecc00) [0x7fd8822cec00]
    16: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0x27) [0x7fd882246747]
    17: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0xecc00) [0x7fd8822cec00]
    18: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0x2e) [0x7fd88224681e]
    19: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0xecc00) [0x7fd8822cec00]
    20: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0x33) [0x7fd882246863]
    21: /usr/local/lib/opencog/libsmob.so (opencog::SchemeEval::do_eval(std::string const&) +0xc1) [0x7fd88463c5f1]
    22: /usr/local/lib/opencog/libsmob.so (opencog::SchemeEval::c_wrap_eval(void*) +0x33) [0x7fd88463c713]
    23: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0x5b2ca) [0x7fd88223d2ca]
    24: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0xecc00) [0x7fd8822cec00]
    25: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0x33) [0x7fd882246863]
    26: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0x5b9ff) [0x7fd88223d9ff]
    27: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0x35) [0x7fd88223da95]
    28: /usr/lib/x86_64-linux-gnu/libgc.so.1 (H๏ฟฝ +0x60) [0x7fd881191950]
    29: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0xd47d1) [0x7fd8822b67d1]
    30: /usr/lib/x86_64-linux-gnu/libgc.so.1 (H๏ฟฝ +0x12) [0x7fd88118bfe2]
    31: /usr/lib/libguile-2.0.so.22 (H๏ฟฝ +0x28) [0x7fd8822b6b48]
    32: /usr/local/lib/opencog/libsmob.so (opencog::SchemeEval::eval_expr(std::string const&) +0x2e) [0x7fd88463c6be]
    33: ./opencog/shell/libscheme-shell.so (H๏ฟฝ +0x7e94) [0x7fd876d6ee94]
    34: /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xb1a40) [0x7fd8859d8a40]
    35: /lib/x86_64-linux-gnu/libpthread.so.0 (H๏ฟฝ +0x8182) [0x7fd884417182]
    36: /lib/x86_64-linux-gnu/libc.so.6 (H๏ฟฝ +0x6d) [0x7fd88544647d]

Build errors on debian 7.8

As requested by linas:

gareth@sexy:~/atomspace/trunk/build$ make
[ 3%] Built target json_spirit
[ 4%] Built target opencog_atom_types
[ 5%] Built target atomutils
[ 17%] Built target lambda
[ 21%] Built target clearbox
[ 53%] Built target atomspace
[ 55%] Built target execution
[ 56%] Building CXX object opencog/guile/CMakeFiles/smob.dir/SchemeEval.cc.o
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:202:8: error: โ€˜thread_localโ€™ does not name a type
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc: In member function โ€˜void opencog::SchemeEval::per_thread_init()โ€™:
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:322:6: error: โ€˜thread_is_initedโ€™ was not declared in this scope
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:323:2: error: โ€˜thread_is_initedโ€™ was not declared in this scope
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc: In static member function โ€˜static opencog::SchemeEval* opencog::SchemeEval::get_evaluator(opencog::AtomSpace_)โ€™:
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:1085:9: error: โ€˜thread_localโ€™ does not name a type
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc: In destructor โ€˜opencog::SchemeEval::get_evaluator(opencog::AtomSpace_)::eval_dtor::eval_dtor()โ€™:
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:1091:19: error: โ€˜issuedโ€™ was not declared in this scope
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:1091:19: error: unable to deduce โ€˜autoโ€™ from โ€˜โ€™
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc: In static member function โ€˜static opencog::SchemeEval* opencog::SchemeEval::get_evaluator(opencog::AtomSpace_)โ€™:
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:1107:9: error: โ€˜thread_localโ€™ does not name a type
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:1109:12: error: โ€˜issuedโ€™ was not declared in this scope
/home/gareth/atomspace/trunk/opencog/guile/SchemeEval.cc:1109:26: error: unable to deduce โ€˜autoโ€™ from โ€˜โ€™
make[2]: *_* [opencog/guile/CMakeFiles/smob.dir/SchemeEval.cc.o] Error 1
make[1]: *** [opencog/guile/CMakeFiles/smob.dir/all] Error 2
make: *** [all] Error 2
gareth@sexy:
/atomspace/trunk/build$ guile --version
guile (GNU Guile) 2.0.5-deb+1-3
Copyright (C) 2011 Free Software Foundation, Inc.

License LGPLv3+: GNU LGPL 3 or later http://gnu.org/licenses/lgpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
gareth@sexy:~/atomspace/trunk/build$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)

"SatisfactionLink with no VariableNode" crashes

I assume SatisfactionLink is still a thing (kind of lost track with the recent changes).

I tried doing this weird call

(cog-satisfy (SatisfactionLink (ConceptNode "ABC")))

and cogserver crashed with

[2015-06-02 03:52:50:762] [ERROR] Caught signal 11 (Segmentation fault) on thread 140036640466688
    Stack Trace:
    2: basic_string.h:539   ~basic_string()
    3: CogServerMain.cc:79  _Z7sighandi()
    4: ??:0 killpg()
    5: PatternMatchEngine.cc:948      opencog::PatternMatchEngine::explore_link_branches(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    6: InitiateSearchCB.cc:286    opencog::InitiateSearchCB::neighbor_search(opencog::PatternMatchEngine*)
    7: InitiateSearchCB.cc:481    opencog::InitiateSearchCB::disjunct_search(opencog::PatternMatchEngine*)
    8: PatternMatch.cc:341    opencog::PatternLink::satisfy(opencog::PatternMatchCallback&) const
    9: shared_ptr_base.h:779    __shared_ptr()
    10: SchemeModule.cc:41    opencog::FunctionWrap::prapper(opencog::Handle)
    11: shared_ptr_base.h:545   ~__shared_count()
    12: SchemePrimitive.cc:158    opencog::PrimitiveEnviron::do_call(scm_unused_struct*, scm_unused_struct*)
    13: ??:0    scm_vm_engine()
    14: ??:0    scm_call_1()
    15: ??:0    scm_vm_engine()
    16: ??:0    scm_call_3()
    17: ??:0    scm_vm_engine()
    18: ??:0    scm_call_4()
    19: SchemeEval.cc:606     opencog::SchemeEval::do_eval(std::string const&)
    20: SchemeEval.cc:535     opencog::SchemeEval::c_wrap_eval(void*)
    21: ??:0    scm_at_abort()
    22: ??:0    scm_vm_engine()
    23: ??:0    scm_call_4()
    24: ??:0    scm_at_abort()
    25: ??:0    scm_c_with_continuation_barrier()
    26: ??:0    GC_call_with_gc_active()
    27: ??:0    scm_current_processor_count()
    28: ??:0    GC_call_with_stack_base()
    29: ??:0    scm_with_guile()
    30: SchemeEval.cc:502     opencog::SchemeEval::eval_expr(std::string const&)
    31: basic_string.h:293    std::string::_M_data() const
    32: ??:0      std::this_thread::__sleep_for(std::chrono::duration<long, std::ratio<1l, 1l> >, std::chrono::duration<long, std::ratio<1l, 1000000000l> >)
    33: pthread_create.c:312    start_thread()
    34: clone.S:113 clone()

Add support for optional arguments in define_scheme_primitive

I tried overloading a scheme definition with multiple define_scheme_primitive on the same scheme function name, see ngeiswei@ee6995c

When calling cog-fc with a single argument it works, but when calling with 2 it tells me that the number of arguments is wrong.

I'd like to upgrade define_scheme_primitive to somehow support optional arguments, but before I start doing that I'll like to know if that's a good idea, maybe there's already an available workaround I am not aware of. Thanks.

Potential illegal memory access in Node::toString called by python binding

I found this behavior during writing unit test of my python conceptual blending project.

When I make new node with no name, AtomSpace returns wrong node with name "(".

Furthermore when I try to make new node with new AtomSpace, this problem getting worse, because it prints machine's memory contents.

This code:

from opencog.atomspace import AtomSpace
from opencog.type_constructors import *

my_as = AtomSpace()
# Make new node with **blank name**
print my_as.add_node(types.ConceptNode, "")
del my_as

my_as = AtomSpace()
print my_as.add_node(types.ConceptNode, "")
del my_as

my_as = AtomSpace()
print my_as.add_node(types.ConceptNode, "")
del my_as

...(skip)

makes this problem.

(ConceptNode "(") ; [2]

(ConceptNode " "") ; [4]

(ConceptNode "") ; [6]


...(skip)...


(ConceptNode "]
") ; [14]

(ConceptNode "") ; [16]

(ConceptNode "") ; [18]

(ConceptNode "%s "%s" (av %d %d %d) %s) ; [%lu]
") ; [20]

(ConceptNode " "%s" (av %d %d %d) %s) ; [%lu]


...(skip)...


(ConceptNode "") ; [58]

(ConceptNode "asic_string::_S_construct null not valid") ; [60]

(ConceptNode "ic_string::_S_construct null not valid") ; [62]

(ConceptNode "_string::_S_construct null not valid") ; [64]

(ConceptNode "tring::_S_construct null not valid") ; [66]

It seems problem was caused by c_str() method in Node::toString() at Node.cc:68 but I'm not sure.

My unit test makes new AtomSpace instance for each test case, and my blender has 'blank' ConceptNode to express default prefix name of new blend node.

Now I'm trying to avoid using the 'blank' ConceptNode because now I think it seems little wrong design conceptually. And the method AtomSpace::atomAsString() at AtomSpace.h:680, which was deprecated:

   /** DEPRECATED! Do NOT USE IN NEW CODE!
     * If you need this, just copy the code below into your app! */
    std::string atomAsString(Handle h, bool terse = true) const {
        if (terse) return h->toShortString();
        return h->toString();
    }

makes this problem because it calls toString() method. But since python users use this method very often because python binding of Atom uses it in __str__, so I think I have to report this problem to community.

Haskell build break.

Something about the haskell bindings breaks the build. I get

cabal: Could not resolve dependencies:
trying: opencog-atomspace-0.1.0.0

DefineLink full support

We're getting close to being able to use Atomese as a real programming language. It seems we still need to add (full) support for DefineLink.

I think the following wiki page

http://wiki.opencog.org/w/Definelink#SchemaNode

correctly defines what we want.

Do we agree on that?

Or do you think PutLink/GetLink can be substituted to DefineLink?

PMCB's node_match pathing question

Anyone know why didn't this pattern in the test match to anything?

https://github.com/opencog/atomspace/blob/8112ab7731bea56a635d402bac80d46ebea5b94c/tests/query/MissingUTest.cxxtest

I overwrote node_match to allow any node to match to VariableNode, so this should results in (ConceptNode "John") being matched to (VariableNode "$Z"), but the Pattern Matcher didn't even go into the node_match callback and produced no grounding.

It only does this in some cases. For example, with the current bc-example.scm (https://github.com/opencog/atomspace/blob/master/tests/rule-engine/bc-example.scm) searching

(ImplicationLink
 (VariableNode "$A")
 (InheritanceLink
  (ConceptNode "Fritz")
  (ConceptNode "green")
  )
)

can match (ConceptNode "Fritz") to (VariableNode "$Z"). However, as soon as I changed to search for a non-existence name

(ImplicationLink
 (VariableNode "$A")
 (InheritanceLink
  (ConceptNode "RandomName")
  (ConceptNode "green")
  )
)

it fails to match to (VariableNode "$Z"). Not sure if there's something I am not seeing with the pattern. Maybe some path exploration problem that only happens on some rare instances when a node is to be matched to another node that is already wrapped by another VariableNode?

Derived AtomSpace's getHandlesByType() bug?

Some inconsistency while working with InitiateSearchCB::link_type_search() lead me to this problem:

Empty AtomSpace _as:

    AtomSpace temp(_as);

    _as->addNode(CONCEPT_NODE, "lalala");
    temp.addNode(CONCEPT_NODE, "kakaka");

    HandleSeq handle_set;
    temp.getHandlesByType(handle_set, CONCEPT_NODE);

I expected handle_set will be size 2, but instead got size 1. Only "kakaka" was found, even though "lalala" should also be considered part of "temp"?

unbound variable on cog-execute! from the cogserver

Trying to run #57

Backtrace:
In ice-9/boot-9.scm:
 157: 12 [catch #t #<catch-closure 3339bc0> ...]
In unknown file:
   ?: 11 [apply-smob/1 #<catch-closure 3339bc0>]
In ice-9/boot-9.scm:
 157: 10 [catch #t #<catch-closure 33398e0> ...]
In unknown file:
   ?: 9 [apply-smob/1 #<catch-closure 33398e0>]
   ?: 8 [call-with-input-string "(counter) (counter)(counter)(counter)\n" ...]
In ice-9/boot-9.scm:
2320: 7 [save-module-excursion #<procedure 3119510 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
  44: 6 [read-and-eval #<input: string 1be8dd0> #:lang ...]
  37: 5 [lp (counter)]
In ice-9/eval.scm:
 386: 4 [eval # #]
 393: 3 [eval # #]
In unknown file:
   ?: 2 [memoize-variable-access! #<memoized cog-execute!> #<directory # 18aac60>]
In ice-9/boot-9.scm:
 102: 1 [#<procedure 3118780 at ice-9/boot-9.scm:97:6 (thrown-k . args)> unbound-variable ...]
In unknown file:
   ?: 0 [apply-smob/1 #<catch-closure 3339860> unbound-variable ...]

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

on the cogserver. .guile has the following

; OpenCog paths
(add-to-load-path "/opencog")
(add-to-load-path "/opencog/build")
(add-to-load-path "/opencog/opencog/scm")
(add-to-load-path) "/usr/local/share/opencog")
(add-to-load-path "/usr/local/share/opencog/scm")
(add-to-load-path ".")

; Enable readline features for the REPL
(use-modules (ice-9 readline))
(activate-readline)

It used to work without the following lines in .guile

(add-to-load-path "/usr/local/share/opencog")
(add-to-load-path "/usr/local/share/opencog/scm")

what am i missing?

Remove ImplicationLink from PM BindLink

Overview

I think we can make BindLink take 3 arguments (or 2 when no variable restrictions) and remove the ImplicationLink without hurting anything.

Specification

Instead of

BindLink
   <Variables> (optional)
   ImplicationLink
      <Clauses>
      <Rewrite>

we would have

BindLink
   <Variables> (optional)
   <Clauses>
   <Rewrite>

Example

For example, instead of

BindLink
   VariableNode X
   ImplicationLink
      InheritanceLink
         VariableNode X
         ConceptNode "Earth"
      VariableNode X

we would have

BindLink
   VariableNode X
   InheritanceLink
      VariableNode X
      ConceptNode "Earth"
   VariableNode X

(which would return a SetLink of all things that inherit "earth").

It is simpler, why not go for it?

Motivation

  1. The PM is such a fundamental part of the AtomSpace, it has to be as perfect as possible, people are gonna use this zillions of times, we cannot afford any cruft on it.
  2. No more interferences with PLN rules.

Yours

If you guys approve I'm happy to take care of it.

PatternLink::setup_components is likely buggy

There is probably something wrong with PatternLink::setup_components, to see why you may do as follows

*1. Add the followning at l.93 of opencog/atoms/bind/PatternLink.cc

        std::cout << "PatternLink::setup_components h = " << h << std::endl;

in PatternLink::setup_components' loop after the definition of h.

*2. Run any pattern matcher example from examples/pattern-matcher, or any rule-engine example, you may see that h is always UNDEFINED.

That cannot be right, right? I think the problem is that the created patternLink is not added to the AtomSpace so no Handle can be associated to it. I'm not sure it should be added to atomspace, so maybe the solution is to have _component_patterns take PatternLinkPtrs instead of Handles.

Python API: scheme_eval_h not working

After an entirely fresh install and build of opencog/atomspace, Python code using scheme_eval_h that previously ran under the old (February 2015) opencog/opencog build is failing.

Here is a Python test program running against opencog/atomspace that demonstrates that the Atomspace is working and the Python API add_node method is working, while attempting to add a node via scheme_eval_h fails:

from opencog.atomspace import Atom, AtomSpace, TruthValue, types, get_type_name
from opencog.scheme_wrapper import load_scm, scheme_eval, scheme_eval_h, __init__

atomspace = AtomSpace()
__init__(atomspace)

TRUTH_VALUE = TruthValue(1,1000000000)

data = ["opencog/atomspace/core_types.scm",
        "opencog/scm/utilities.scm"]

for item in data:
    load_scm(atomspace, item)

atomspace.add_node(types.ConceptNode, "Object_001",TRUTH_VALUE)
atomspace.add_node(types.ConceptNode, "Object_002",TRUTH_VALUE)

my_nodes = atomspace.get_atoms_by_type(types.ConceptNode)

for i in my_nodes:
        print i

scheme_string = \
    '''
    (ConceptNode "Object_003")
    '''

result = scheme_eval_h(atomspace, scheme_string)

Running that program produced the following errors:

Traceback (most recent call last):
File "/home/jimrutt/PycharmProjects/SchemeEvalTests/SchemeEvalTest001.py", line 23, in
result = scheme_eval_h(atomspace, scheme_string)
File "scheme_wrapper.pyx", line 58, in opencog.scheme_wrapper.scheme_eval_h (/home/jimrutt/atomspace/build/opencog/cython/opencog/scheme_wrapper.cpp:1241)
RuntimeError: Backtrace:
In ice-9/boot-9.scm:
157: 12 [catch #t # ...]
In unknown file:
?: 11 [apply-smob/1 #]
In ice-9/boot-9.scm:
157: 10 [catch #t # ...]
In unknown file:
?: 9 [apply-smob/1 #]
?: 8 [call-with-input-string "(ConceptNode "Object_004")" ...]
In ice-9/boot-9.scm:
2401: 7 [save-module-excursion #<procedure a1e7690 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
44: 6 [read-and-eval #<input: string 9e4dc30> #:lang ...]
37: 5 [lp (ConceptNode "Object_004")]
In ice-9/eval.scm:
386: 4 [eval #<memoized (ConceptNode (quote "Object_004"))> ()]
393: 3 [eval # ()]
In unknown file:
?: 2 [memoize-variable-access! # #<directory # 9f1e630>]
In ice-9/boot-9.scm:
102: 1 [#<procedure a1e5a20 at ice-9/boot-9.scm:97:6 (thrown-k . args)> unbound-variable ...]
In unknown file:
?: 0 [apply-smob/1 # unbound-variable ...]

ERROR: In procedure apply-smob/1:
ERROR: Unbound variable: ConceptNode
ABORT: unbound-variable
(/home/jimrutt/atomspace/opencog/guile/SchemeEval.cc:879)

Build problem in Ubuntu 14.10

Keep getting opencog/atomspace_api.h: No such file or directory when trying to build atomspace.

Tried all sort of things, removing python3/cython3, also can't seem to find where atomspace_api.h is generated and I did look believe you me :)

Here's what the output looks like:

admin2@ubuntu:~/Documents/atomspace/build$ uname -a
Linux ubuntu 4.1.0-rc4+ #1 SMP Sun May 24 11:52:18 PDT 2015 x86_64 x86_64 x86_64 GNU/Linux

admin2@ubuntu:~/Documents/atomspace/build$ cmake ..
-- Build type: Release
-- Boost version: 1.55.0
-- Found the following Boost libraries:
-- date_time
-- filesystem
-- program_options
-- regex
-- serialization
-- system
-- thread
-- Boost version 105500 found.
-- Found CogUtil version 2.0.1 at /usr/local/lib/libcogutil.so
-- CogUtil found.
-- GHC was found.
-- GSL found.
-- Guile (2.0.11 >= 2.0.0) was found.
-- HyperTable was not found. Make sure HYPERTABLE_LIBRARY and HYPERTABLE_INCLUDE_DIR are set.
-- Hypertable not found; the experimental distributed persistence DB needs it.
-- Python libs found.
-- Cython ( 0.23 >= 0.19.0) found.
-- Python destination dir found: /usr/lib/python2.7/dist-packages

-- Found Intel TBB

-- UnixODBC was found.
-- Valgrind Prefix:
-- Could NOT find VALGRIND (missing: VALGRIND_INCLUDE_DIR VALGRIND_PROGRAM)
-- VALGRIND missing: needed for thread debugging.
-- Found ZeroMQ library: /usr/lib/x86_64-linux-gnu/libzmq.so
-- Detected ZeroMQ version number: 4.0.4
-- ZeroMQ was found.
CMake Warning at tests/persist/sql/CMakeLists.txt:45 (MESSAGE):
/usr/bin/psql: psql: could not connect to server: Connection refused

Is the server running on host "localhost" (127.0.0.1) and accepting

TCP/IP connections on port 5432?

CMake Warning at tests/persist/sql/CMakeLists.txt:60 (MESSAGE):
Postgres database not configured for unit tests! See the README!

The following components will be built:

AtomSpace - A weighted and typed hypergraph database.
Cython bindings - Cython (python) bindings.
Doxygen - Code documentation.
Python tests - Python bindings nose tests.
Scheme bindings - Scheme bindings and shell.
SQL persistance - Save/Restore of AtomSpace to database.
TBB - Intel TBB (Threaded Building Blocks) for multithreading.
Unit tests - Unit tests.

The following components WILL NOT be built:

Hypertable - HyperTable for scalable persistance (experimental).

-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin2/Documents/atomspace/build
admin2@ubuntu:~/Documents/atomspace/build$ make -j6
[ 0%] Cythonizing logger.pyx
[ 2%] [ 2%] [ 4%] [ 4%] [ 6%] Building CXX object lib/json_spirit/CMakeFiles/json_spirit.dir/json_spirit_reader.cpp.o
Generating opencog types
Building CXX object lib/json_spirit/CMakeFiles/json_spirit.dir/json_spirit_value.cpp.o
Building CXX object lib/json_spirit/CMakeFiles/json_spirit.dir/json_spirit_writer.cpp.o
Building CXX object opencog/cython/CMakeFiles/PythonEval.dir/PythonEval.cc.o
-- Atom type name: Notype
-- Atom type name: Atom
-- Atom type name: Node
-- Atom type name: Link
-- Atom type name: ConceptNode
-- Atom type name: NumberNode
-- Atom type name: OrderedLink
-- Atom type name: UnorderedLink
-- Atom type name: SetLink
-- Atom type name: ListLink
-- Atom type name: MemberLink
-- Atom type name: SubsetLink
-- Atom type name: IntensionalInheritanceLink
-- Atom type name: ExtensionalSimilarityLink
-- Atom type name: IntensionalSimilarityLink
-- Atom type name: AndLink
-- Atom type name: OrLink
-- Atom type name: NotLink
-- Atom type name: SequentialAndLink
-- Atom type name: AbsentLink
-- Atom type name: ChoiceLink
-- Atom type name: ContextLink
-- Atom type name: TypeNode
-- Atom type name: TypeChoice
-- Atom type name: VariableNode
-- Atom type name: TypedVariableLink
-- Atom type name: VariableList
-- Atom type name: QuoteLink
-- Atom type name: ScopeLink
-- Atom type name: DefineLink
-- Atom type name: BetaRedex
-- Atom type name: PatternLink
-- Atom type name: GetLink
-- Atom type name: SatisfactionLink
-- Atom type name: BindLink
-- Custom atom type name specified: "ForAllLink"
-- Atom type name: ForAllLink
-- Atom type name: ExistsLink
-- Atom type name: AverageLink
-- Atom type name: SatisfyingSetLink
-- Atom type name: ScholemLink
-- Atom type name: ImplicationLink
-- Atom type name: EquivalenceLink
-- Atom type name: AssociativeLink
-- Atom type name: InheritanceLink
-- Atom type name: SimilarityLink
-- Atom type name: AttractionLink
-- Atom type name: FreeLink
-- Atom type name: PutLink
-- Atom type name: EvaluationLink
-- Atom type name: ExecutionLink
-- Atom type name: ProcedureNode
-- Atom type name: GroundedProcedureNode
-- Atom type name: SchemaNode
-- Atom type name: GroundedSchemaNode
-- Atom type name: PredicateNode
-- Atom type name: GroundedPredicateNode
-- Atom type name: DefinedRelationshipNode
-- Atom type name: SchemaExecutionLink
-- Atom type name: SchemaEvaluationLink
-- Atom type name: AnchorNode
-- Atom type name: QuantityLink
-- Atom type name: VirtualLink
-- Atom type name: GreaterThanLink
-- Atom type name: EqualLink
-- Atom type name: FunctionLink
-- Atom type name: ExecutionOutputLink
-- Atom type name: FoldLink
-- Atom type name: ArithmeticLink
-- Atom type name: PlusLink
-- Atom type name: TimesLink
-- Atom type name: DeleteLink
-- Atom type name: AssignLink
-- Atom type name: InsertLink
-- Atom type name: RemoveLink
[ 6%] Built target opencog_atom_types
[ 6%] Building CXX object opencog/atomutils/CMakeFiles/atomutils.dir/AtomUtils.cc.o
Scanning dependencies of target logger_cython
[ 6%] Building CXX object opencog/cython/opencog/CMakeFiles/logger_cython.dir/logger.cpp.o
/home/admin2/Documents/atomspace/opencog/cython/PythonEval.cc:39:35: fatal error: opencog/atomspace_api.h: No such file or directory
#include "opencog/atomspace_api.h"
^
compilation terminated.
[ 9%] Building CXX object opencog/atoms/core/CMakeFiles/atomcore.dir/FreeLink.cc.o
Linking CXX shared library logger.so
[ 9%] Built target logger_cython
[ 11%] Building CXX object opencog/atomspaceutils/CMakeFiles/atomspaceutils.dir/AtomSpaceUtils.cc.o
[ 11%] Building CXX object opencog/atoms/core/CMakeFiles/atomcore.dir/PutLink.cc.o
Linking CXX shared library libatomutils.so
[ 11%] Built target atomutils
opencog/cython/CMakeFiles/PythonEval.dir/build.make:54: recipe for target 'opencog/cython/CMakeFiles/PythonEval.dir/PythonEval.cc.o' failed
make[2]: *** [opencog/cython/CMakeFiles/PythonEval.dir/PythonEval.cc.o] Error 1
CMakeFiles/Makefile2:1354: recipe for target 'opencog/cython/CMakeFiles/PythonEval.dir/all' failed
make[1]: *** [opencog/cython/CMakeFiles/PythonEval.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking CXX shared library libatomspaceutils.so
[ 11%] Built target atomspaceutils
Linking CXX shared library libatomcore.so
[ 11%] Built target atomcore
Linking CXX shared library libjson_spirit.so
[ 11%] Built target json_spirit
Makefile:133: recipe for target 'all' failed
make: *** [all] Error 2

Any help would be appreciated!

Thanks.

Bug or feature? deleting an atom using a variable in scm shell does remove the atom from the atomspace but not from the scheme enviroment.

1. Inpute atoms

opencog> (clear)
Entering scheme shell; use ^D or a single . on a line by itself to exit.
guile> 
guile> (cog-prt-atomspace)

guile> (define x (cog-new-node 'ConceptNode "abc")) 

guile> (cog-prt-atomspace)
(ConceptNode "abc")

guile> (define y (cog-new-node 'ConceptNode "def")) 

guile> (cog-prt-atomspace)
(ConceptNode "def")
(ConceptNode "abc")

guile> (define l (cog-new-link 'ListLink x y)) 

guile> (cog-prt-atomspace)
(ListLink
   (ConceptNode "abc")
   (ConceptNode "def")
)

2. delete the link

guile> (cog-delete l)
#t
guile> (cog-prt-atomspace)
(ConceptNode "def")
(ConceptNode "abc")

3. part that caused me to doubt what the scheme shell does,

@williampma informed me that the following was always the case.

guile> l
(ListLink
   (ConceptNode "abc")
   (ConceptNode "def")
)

guile> (cog-prt-atomspace)
(ConceptNode "def")
(ConceptNode "abc")

guile> (cog-handle l)
59
guile> (cog-outgoing-set l)
((ConceptNode "abc")
 (ConceptNode "def")
)
guile> (cog-atom (cog-handle l))
#<Invalid handle>

guile> (SetLink l)
(SetLink (av 0 0 0)
   (ListLink
      (ConceptNode "abc")
      (ConceptNode "def")
   )
)

guile> (cog-prt-atomspace)
(SetLink (av 0 0 0)
   (ListLink
      (ConceptNode "abc")
      (ConceptNode "def")
   )
)

My assumption (used to think that I knew, thus this issue) was that on evaluating the varaible l , after deleting the atom, the print out on the shell was a confirmation that the atom has been reinserted into the atomspace, which is not the case. So, is this a bug or a feature? @linas

Support executing ungrounded Schemata/Predicates

Disclaimer

I'm writing that based solely on

http://wiki.opencog.org/w/Scheme#cog-execute.21

and

http://wiki.opencog.org/w/ExecutionLink

I didn't try to run cog-execute! to actually see what is or not supported.

Proposal

Given

ExecutionLink
   SchemaNode "S"
   <Inputs>
   <Output>
[1]

and

ExecutionOutputLink
   SchemaNode "S"
   <Inputs>
[2]

If cog-execute! is called on [2] it should return the output defined in [1].

Dealing with Multiple Outputs

If there are more than one output for the same inputs, then it may either

  1. raise an error,
  2. return the distribution of outputs,
  3. or select one according to that distribution.

The distribution would be defined by the TVs on the ExecutionLinks (TVs representing probabilities according to http://wiki.opencog.org/w/OpenCogPrime:FunctionNotation#Execution_Links).

It seems acceptable if, for starter, it simply raises an error. Maybe the other options should be delegated to other functions than cog-execute!.

Motivation Behind the Proposal

That way whether you store a value using an ExecutionLink, a GroundedSchemaNode or a PutLink, the way to obtain it would be almost the same, a call of cog-execute! over an ExecutionOutputLink or GetLink.

cog-delete-recursive documentation isn't correct

cog-delete-recursive's documentation isn't exactly correct here

       ; Verify that the link l is gone:
       guile> l
       Invalid handle

       ; Verify that the node x is gone:
       guile> x
       Invalid handle

in reality it shows the atoms referenced by l and x

scheme@(guile-user)> l
$8 = (Link
   (ConceptNode "abc")
   (ConceptNode "def")
)

scheme@(guile-user)> x
$9 = (ConceptNode "abc")

However the behavior of cog-delete-recursive is correct, using prt-atomspace as given in http://wiki.opencog.org/w/Scheme#Print_all_atoms_in_the_AtomSpace (EDIT: you can use directly cog-prt-atomspace) I can see that the atoms corresponding to l and x are indeed missing.

I'm not sure whether the documentation should be fixed or what is returned by l and x should be fixed.

Pattern matcher branch exploration problem

There is a bug in pattern matcher for queries having common atoms shared by different sub-patterns (sub-tree branches). See example:

(define (SharedAtom)
        (AndLink
                (ConceptNode "A")
        )
)

(define (Tree)
        (ListLink
                (SharedAtom)
                (ListLink
                        (SharedAtom)
                        (ConceptNode "B")
                )
        )
)
(Tree)

(define (query1)
        (AndLink
                (VariableNode "$a")
        )
)

(define (query2)
        (VariableNode "$a")
)

(define (tree-query input-query)
        (BindLink
                (VariableList
                        (VariableNode "$a")
                        (VariableNode "$b")
                )
                (AndLink
                        (ListLink
                                (input-query)
                                (ListLink
                                        (input-query)
                                        (VariableNode "$b")
                                )
                        )
                )
                (ListLink
                        (VariableNode "$a")
                        (VariableNode "$b")
                )
        )
)

(cog-bind (tree-query query1))
(cog-bind (tree-query query2))

The answer is:

$2 = (SetLink
   (ListLink
      (ConceptNode "A")
      (ConceptNode "B")
   )
   (ListLink
      (ConceptNode "A")
      (ConceptNode "B")
   )
)

$3 = (SetLink
   (ListLink
      (AndLink
         (ConceptNode "A")
      )
      (ConceptNode "B")
   )
)

The answer for query1 is duplicated. The right size of satisfying set is 1 for both queries. This is simple example but this may bring weird problems for more complicated settings.

I have checked that it happens when there exists an atom shared by sub-patterns and moreover the main pattern is explored recursively bottom-up. Then all branches are explored.
The difference between this two queries is because the pattern matcher uses "choose thinnest term strategy" and finds as starters different terms.
For query1 the starter is a bottom atom:

Start term is: (AndLink (stv 1,000000 0,000000)
  (VariableNode "$a") ; [7]
) ; [10]

For query2 the starter is a top atom:

Start term is: (ListLink (stv 1,000000 0,000000)
  (VariableNode "$a") ; [7]
  (ListLink (stv 1,000000 0,000000)
    (VariableNode "$a") ; [7]
    (VariableNode "$b") ; [8]
  ) ; [14]
) ; [19]

It seems that the shared pattern should be explored only in one location and this is a fix. I am not sure yet.

Build fail: /bin/sh: 1: cabal: not found

william@william-VirtualBox:~/atomspace/build$ make
[  2%] Built target json_spirit
[  2%] Built target opencog_atom_types
[  4%] Built target atomutils
[  6%] Built target atomcore
[ 13%] Built target lambda
[ 20%] Built target clearbox
[ 46%] Built target atomspace
[ 46%] Built target atomspaceutils
[ 48%] Built target atomspace_cython
[ 51%] Built target PythonEval
[ 60%] Built target smob
[ 69%] Built target query
[ 72%] Built target execution
[ 81%] Built target ruleengine
[ 81%] Built target atomspace_bm
[ 81%] Built target persist
[ 83%] Built target persist-sql
[ 83%] Built target sniff
[ 86%] Built target bindlink_cython
[ 88%] Built target logger_cython
[ 93%] Built target scheme_wrapper
[ 93%] Built target type_constructors
[ 97%] Built target utilities_cython
[100%] Built target haskell-atomspace
[100%] Installing: opencog-atomspace haskell library...
/bin/sh: 1: cabal: not found
make[2]: *** [opencog/haskell/dist] Error 127
make[1]: *** [opencog/haskell/CMakeFiles/haskell-atomspace-lib.dir/all] Error 2
make: *** [all] Error 2

Do I need to install cabal?

Pattern matcher disconnected components error thrown with Abduction rule

Grounding variable "$C" in the abduction rule leads the pattern matcher to throw an error that the bindlink consists of multiple disconnected components.

Here's the grounded abduction rule bindlink (with VariableNode C replaced by ConceptNode X:)

(BindLink (av 0 0 0)
   (VariableList (av 0 0 0)
      (VariableNode "$A")
      (VariableNode "$B")
   )
   (ImplicationLink
      (AndLink
         (InheritanceLink
            (VariableNode "$A")
            (ConceptNode "X")
         )
         (InheritanceLink
            (VariableNode "$B")
            (ConceptNode "X")
         )
      )
      (ExecutionOutputLink
         (GroundedSchemaNode "scm: pln-formula-abduction")
         (ListLink
            (InheritanceLink
               (VariableNode "$A")
               (VariableNode "$B")
            )
            (InheritanceLink
               (VariableNode "$A")
               (ConceptNode "X")
            )
            (InheritanceLink
               (VariableNode "$B")
               (ConceptNode "X")
            )
            (VariableNode "$A")
            (VariableNode "$B")
            (ConceptNode "X")))))

And here's the error:
ERROR: In procedure cog-fc-em: BindLink consists of multiple disconnected components! (/home/eddie/opencog/atomspace/opencog/query/PatternMatch.cc:323)

Note that this error is thrown in the forward chainer, but is not thrown through use of (cog-bind). This is because cog-bind leads to bindlink->imply() being called with the check_connectivity argument set to false, so with cog-bind checking for connected components doesn't occur. In the forward chainer check_connectivity gets set to the default of true, and the error is thrown.

BindLink clause with a single evaluatable

Come across this while marking a single (VariableNode $A) clause as "evaluatable" (since if it maps to an "evaluatable", special treatment is need to evaluate the mapped stuff)

guile> (define B 
   (BindLink 
      (VariableList (VariableNode "$A") (VariableNode "$B")) 
      (EqualLink (VariableNode "$A") (VariableNode "$B"))
      (ListLink (VariableNode "$A") (VariableNode "$B"))))

guile> (cog-bind B)
(SetLink
)

ie. a BindLink with a single virtual clause currently is not run and not grounded. Should it? The above query should produce every single atom in the AtomSpace right?

EinsteinUTest taking too long

Normally, EinsteinUTest runs in 10 seconds, but it is currently running in 300 seconds. This is due to some pattern matcher bug .. this has happened before, and bisection should reveal what the problem is.

(do-em-all) throws a C++ exception after loading around 50,000-60,000 atoms

I am gathering statistics on a parse server that Linas has set up for gathering data related to the language learning project. I ran (do-em-all) after I gathered some substantial amount of word pairs, so that the MI could be computed and further processing could begin. This was the error/exception that I was getting:

Backtrace:
In ice-9/boot-9.scm:
157: 12 [catch #t #<catch-closure 40bb4bc0> ...]
In unknown file:
?: 11 [apply-smob/1 #<catch-closure 40bb4bc0>]
In ice-9/boot-9.scm:
157: 10 [catch #t #<catch-closure 40bb4a80> ...]
In unknown file:
?: 9 [apply-smob/1 #<catch-closure 40bb4a80>]
?: 8 [call-with-input-string "(do-em-all)\n" ...]
In ice-9/boot-9.scm:
2320: 7 [save-module-excursion #<procedure 40b5f7b0 at ice-9/eval-string.scm:65:9 ()>]
In ice-9/eval-string.scm:
44: 6 [read-and-eval #<input: string 4184a270> #:lang ...]
37: 5 [lp (do-em-all)]
In /home/rohit/../..//home/opencog/src/opencog/opencog/nlp/learn/compute-mi.scm:
1018: 4 [batch-all-pair-mi (LinkGrammarRelationshipNode "ANY" (ctv 1 0 22408396))
]
717: 3 [batch-all-pair-wildcard-counts #]
In unknown file:
?: 2 [opencog-extension fetch-incoming-set (#)]
In ice-9/boot-9.scm:
102: 1 [#<procedure 3e597a00 at ice-9/boot-9.scm:97:6 (thrown-k . args)> C++-EXCEPTION ...]
In unknown file:
?: 0 [apply-smob/1 #<catch-closure 40bb4a40> C++-EXCEPTION ...]

ERROR: In procedure apply-smob/1:
ERROR: In procedure fetch-incoming-set: Unexpected handle mismatch! Expected 15981 got 1792030
(/home/opencog/src/atomspace/opencog/atomspace/AtomSpace.cc:303)
ABORT: C++-EXCEPTION

PatternMatcherCallBack grounding var_soln corrupted?

This one is tough. Need to write some custom code to test this.

First, assume the following are in the AtomSpace

(EvaluationLink
   (PredicateNode "chirps")
   (ConceptNode "Tweety")
)
(EvaluationLink
   (PredicateNode "eats_flies")
   (ConceptNode "Tweety")
)
(InheritanceLink
   (ConceptNode "Tweety")
   (ConceptNode "Yello")
)
(BindLink (av 0 0 0)
   (VariableList (av 0 0 0)
      (VariableNode "$A")
      (VariableNode "$B")
   )
   (AndLink
      (VariableNode "$A")
      (ImplicationLink
         (VariableNode "$A")
         (VariableNode "$B")
      )
   )
   (ExecutionOutputLink
      (GroundedSchemaNode "scm: pln-formula-simple-modus-ponens")
      (ListLink
         (VariableNode "$B")
         (ImplicationLink
            (VariableNode "$A")
            (VariableNode "$B")
         )
      )
   )
)
(ListLink
   (InheritanceLink
      (ConceptNode "Fritz")
      (ConceptNode "green")
   )
   (ImplicationLink
      (InheritanceLink
         (ConceptNode "Fritz")
         (ConceptNode "Frog")
      )
      (InheritanceLink
         (ConceptNode "Fritz")
         (ConceptNode "green")
      )
   )
)
(ListLink
   (InheritanceLink
      (ConceptNode "Fritz")
      (ConceptNode "Frog")
   )
   (ImplicationLink
      (AndLink
         (EvaluationLink
            (PredicateNode "croaks")
            (ConceptNode "Fritz")
         )
         (EvaluationLink
            (PredicateNode "eats_flies")
            (ConceptNode "Fritz")
         )
      )
      (InheritanceLink
         (ConceptNode "Fritz")
         (ConceptNode "Frog")
      )
   )
)
(ImplicationLink
   (AndLink
      (EvaluationLink
         (PredicateNode "chirps")
         (VariableNode "$Y")
      )
      (EvaluationLink
         (PredicateNode "sings")
         (VariableNode "$Y")
      )
   )
   (InheritanceLink
      (VariableNode "$Y")
      (ConceptNode "Canary")
   )
)
(ImplicationLink
   (AndLink
      (EvaluationLink
         (PredicateNode "croaks")
         (VariableNode "$X")
      )
      (EvaluationLink
         (PredicateNode "eats_flies")
         (VariableNode "$X")
      )
   )
   (InheritanceLink
      (VariableNode "$X")
      (ConceptNode "Frog")
   )
)
(ImplicationLink
   (InheritanceLink
      (VariableNode "$Z")
      (ConceptNode "Frog")
   )
   (InheritanceLink
      (VariableNode "$Z")
      (ConceptNode "green")
   )
)
(ImplicationLink
   (InheritanceLink
      (VariableNode "$A")
      (ConceptNode "Canary")
   )
   (InheritanceLink
      (VariableNode "$A")
      (ConceptNode "yellow")
   )
)

Then, write a new PatternMatcherCallBack with a new grounding method that just print the var_soln mapping

bool NewPMCB::grounding(const std::map<Handle, Handle> &var_soln,
                               const std::map<Handle, Handle> &pred_soln)
{
    for (auto& p : var_soln)
        logger().debug("var_soln map " + p.first->toShortString() + " to " + p.second->toShortString());

    return false;
}

Then have some variable Handle htarget then contains the following additional atom

(AndLink (stv 1.000000 0.000000)
  (InheritanceLink (stv 1.000000 0.000000)
    (VariableNode "$Z") ; [142]
    (ConceptNode "Frog") ; [115]
  ) ; [150]
  (ImplicationLink (stv 1.000000 0.000000)
    (InheritanceLink (stv 1.000000 0.000000)
      (VariableNode "$Z") ; [142]
      (ConceptNode "Frog") ; [115]
    ) ; [150]
    (InheritanceLink (stv 1.000000 0.000000)
      (VariableNode "$Z") ; [142]
      (ConceptNode "green") ; [113]
    ) ; [151]
  ) ; [152]
) ; [477]

And call the Pattern Matcher code like this

    // Get all VariableNodes (unquoted)
    FindAtoms fv(VARIABLE_NODE);
    fv.search_set(htarget);

    HandleSeq vars;
    for (auto& h : fv.varset)
        vars.push_back(h);

    Handle htarget_vardecl = _as->addAtom(createVariableList(vars));

    PatternLinkPtr sl(createPatternLink(htarget_vardecl, htarget));
    NewPMCB pmcb(_as);

    logger().debug("Before patterm matcher");

    sl->satisfy(pmcb);

    logger().debug("After running pattern matcher");

cogserver crash at the line printing var_soln (in particular, when printing p.second. Printing p.first was fine).

In my case, the crash code is like this

[2015-06-04 04:18:41:696] [ERROR] Caught signal 11 (Segmentation fault) on thread 140051551868672
    Stack Trace:
    2: basic_string.h:539   ~basic_string()
    3: CogServerMain.cc:79  _Z7sighandi()
    4: ??:0 killpg()
    5: BackwardChainerPMCB.cc:57      opencog::BackwardChainerPMCB::grounding(std::map<opencog::Handle, opencog::Handle, std::less<opencog::Handle>, std::allocator<std::pair<opencog::Handle const, opencog::Handle> > > const&, std::map<opencog::Handle, opencog::Handle, std::less<opencog::Handle>, std::allocator<std::pair<opencog::Handle const, opencog::Handle> > > const&)
    6: PatternMatchEngine.cc:1295     opencog::PatternMatchEngine::do_next_clause()
    7: PatternMatchEngine.cc:1104     opencog::PatternMatchEngine::do_term_up(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    8: PatternMatchEngine.cc:1048     opencog::PatternMatchEngine::explore_single_branch(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    9: shared_ptr_base.h:545    ~__shared_count()
    10: PatternMatchEngine.cc:1208    opencog::PatternMatchEngine::do_term_up(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    11: PatternMatchEngine.cc:1048    opencog::PatternMatchEngine::explore_single_branch(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    12: PatternMatchEngine.cc:1335    opencog::PatternMatchEngine::do_next_clause()
    13: PatternMatchEngine.cc:1104    opencog::PatternMatchEngine::do_term_up(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    14: PatternMatchEngine.cc:1048    opencog::PatternMatchEngine::explore_single_branch(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    15: shared_ptr_base.h:545   ~__shared_count()
    16: PatternMatchEngine.cc:1208    opencog::PatternMatchEngine::do_term_up(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    17: PatternMatchEngine.cc:1048    opencog::PatternMatchEngine::explore_single_branch(opencog::Handle const&, opencog::Handle const&, opencog::Handle const&)
    18: InitiateSearchCB.cc:286   opencog::InitiateSearchCB::neighbor_search(opencog::PatternMatchEngine*)
    19: InitiateSearchCB.cc:481   opencog::InitiateSearchCB::disjunct_search(opencog::PatternMatchEngine*)
    20: PatternMatch.cc:341   opencog::PatternLink::satisfy(opencog::PatternMatchCallback&) const
    21: BackwardChainer.cc:112    opencog::BackwardChainer::do_until(unsigned int)
    22: InferenceSCM.cc:134   opencog::InferenceSCM::do_backward_chaining(opencog::Handle)
    23: shared_ptr_base.h:545   ~__shared_count()
    24: SchemePrimitive.cc:158    opencog::PrimitiveEnviron::do_call(scm_unused_struct*, scm_unused_struct*)
    25: ??:0    scm_vm_engine()
    26: ??:0    scm_call_1()
    27: ??:0    scm_vm_engine()
    28: ??:0    scm_call_3()
    29: ??:0    scm_vm_engine()
    30: ??:0    scm_call_4()
    31: SchemeEval.cc:606     opencog::SchemeEval::do_eval(std::string const&)
    32: SchemeEval.cc:535     opencog::SchemeEval::c_wrap_eval(void*)
    33: ??:0    scm_at_abort()
    34: ??:0    scm_vm_engine()
    35: ??:0    scm_call_4()
    36: ??:0    scm_at_abort()
    37: ??:0    scm_c_with_continuation_barrier()
    38: ??:0    GC_call_with_gc_active()
    39: ??:0    scm_current_processor_count()
    40: ??:0    GC_call_with_stack_base()
    41: ??:0    scm_with_guile()
    42: SchemeEval.cc:502     opencog::SchemeEval::eval_expr(std::string const&)
    43: basic_string.h:293    std::string::_M_data() const
    44: ??:0      std::this_thread::__sleep_for(std::chrono::duration<long, std::ratio<1l, 1l> >, std::chrono::duration<long, std::ratio<1l, 1000000000l> >)
    45: pthread_create.c:312    start_thread()
    46: clone.S:113 clone()


Enabling DEBUG print in PatternMatchEngine.cc doesn't compile

I'm getting the following error

/home/nilg/OpenCog/atomspace/opencog/query/PatternMatchEngine.cc:569:9: error: โ€˜perm_countโ€™ was not declared in this scope
         perm_count[Unorder(hp, hg)], num_perms, hp.value(),

and it's not obvious to me what perm_count should be replaced by.

"Expecting GroundedPredicateNode!" error

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?

Bug with deleting atom spanning multiple atomspace

Not sure whether to put this in "atomspace" or "opencog".

Have a module that does the following, which get called in cogserver's scheme shell

    AtomSpace* temp = new AtomSpace(_as);   // temp has _as parent

    Handle h1 = _as->addAtom(createNode(CONCEPT_NODE, "aaa"));
    Handle h2 = temp->addAtom(createNode(CONCEPT_NODE, "bbb"));
    temp->addAtom(createLink(LIST_LINK, h1, h2));

    delete temp;
    return;

then do cog-prt-atomspace, cogserver crashes.

Make rule implicand explicit for the backward chainer

The backward chainer needs to know the structure of its implicand in order to select the applicable rules of a target. The problem is that given the way rules are currently represented, the implicand does not need to be explicit. Given the following format

BindLink
   AndLink
      <Implicant>
   <Implicand>

Implicand is usually hidden in an ExecutionOutputLink like

ExecutionOutputLink
   "scm:compute-the-implicand"
   ListLink
      ARG1 ... ARGn

Currently the backward chainer looks at ARG1 to ARGn to guess the implicand, but nothing guaranties that this guess is correct, ARG1 to ARGn may turn out not to represent the implicand at all. Besides, even when the implicand is in there, the rule is harder to filter due to the other arguments which are not the implicand (@williampma correct me if I'm wrong).

We need to set an additional constraint on the rule format to make the implicand explicit. I think ideally we'd use a SetTVLink, see below.

Let's assume SetTVLink has the following format

SetTVLink
   <Atom>
   <TV>

So this would assign to . It's not clear what should be, it could be a TVLink that takes 2 NumberNode arguments, or something like that, anyway.

The rule would have the following format

BindLink
   <Variables> (optional)
   <Implicants>
   SetTVLink
      <Implicand>
      <TV>

For instance a deduction rule would look like

BindLink
   AndLink
      ImplicationLink
         VariableNode "$A"
         VariableNode "$B"
      ImplicationLink
         VariableNode "$B"
         VariableNode "$C"
   SetTVLink
      ImplicationLink
         VariableNode "$A"
         VariableNode "$C"
      ExecutionOutputLink
         GroundedSchemaNode "scm:deduction-formula"
         ListLink
            ImplicationLink
               VariableNode "$A"
               VariableNode "$B"
            ImplicationLink
               VariableNode "$B"
               VariableNode "$C"

the scheme code deduction-formula would still need to take Implication(A B) and Implication(B C) to get their TVs and compute the TV of Implication(A C).

If we don't want to wait for SetTVLink, we could still use that format replacing SetTVLink by ExecutionOutputLink + some scheme code, like

BindLink
   AndLink
      ImplicationLink
         VariableNode "$A"
         VariableNode "$B"
      ImplicationLink
         VariableNode "$B"
         VariableNode "$C"
   ExecutionOutputLink
      GroundedSchemaNode "scm:set-tv"
      ListLink
         ImplicationLink
            VariableNode "$A"
            VariableNode "$C"
         ExecutionOutputLink
            GroundedSchemaNode "scm:deduction-formula"
            ListLink
               ImplicationLink
                  VariableNode "$A"
                  VariableNode "$B"
               ImplicationLink
                  VariableNode "$B"
                  VariableNode "$C"

Slightly more verbose but allows to move on without having to define SetTVLink. Although I think taking the time to implement Set/Get TV links would be a good thing.

Also in both cases we could define some scheme function to build the BindLink given the rule's implicants, implicand and formula code. Or maybe store it that way, and let the URE build the BindLink as appropriate.

Fail to find the HyperTable library in cmake

Hello,

When I'm trying to cmake, I'm getting the following error even I installed HyperTable library.

"Hypertable not found; the experimental distributed persistence DB needs it."

After finding cause of this problem, I can build with successfully when I changed to content of lib/FindHyperTable.cmake

FIND_LIBRARY(HYPER_DFS_BROKER NAMES HyperDfsBroker PATHS ${HYPER_LIB_PATHS})
to
FIND_LIBRARY(HYPER_DFS_BROKER NAMES HyperFsBroker PATHS ${HYPER_LIB_PATHS})

HyperDfsBroker to HyperFsBroker works with me, but I'm not sure why name of library in HyperTable is different.

I'm using Ubuntu 14.04 LTS x64 and I installed HyperTable library by aptitude. Version of library is 0.9.8.4.

Thanks,
DongMin

Garbage left in atomspace by executing AssignLink

@linas if I understood https://github.com/opencog/atomspace/blob/master/opencog/atoms/reduct/AssignLink.h#L70 correctly, there shouldn't be a (NumberNode "1.000000" (av 0 0 0)) in the atomspace.

guile> (clear)
guile> (define (counter)
    (define (increment-number str)  (+ (string->number str) 1))
     (let ((nn (cog-chase-link 'ReferenceLink 'NumberNode (AnchorNode "count"))) )
        (if (null? nn)
            (ReferenceLink
                (AnchorNode "count")
                (NumberNode 1)
                )
            (begin
                (cog-execute!
                    (AssignLink
                        (TypeNode "ReferenceLink")
                        (AnchorNode "count")
                        (NumberNode (increment-number (cog-name (car nn))))
                    )
                )

            )
        )
    )
)

guile> (define (ncount n)
    (while (not (= 0 n) ) (begin (set! n (- n 1)) (counter) )  )
)
guile> (ncount 5)
guile> (cog-prt-atomspace)
(ReferenceLink
   (AnchorNode "count")
   (NumberNode "5.000000" (av 0 0 0))
)
(AssignLink
   (TypeNode "ReferenceLink" (av 0 0 0))
   (AnchorNode "count")
   (NumberNode "5.000000" (av 0 0 0))
)
(AssignLink
   (TypeNode "ReferenceLink" (av 0 0 0))
   (AnchorNode "count")
   (NumberNode "4.000000" (av 0 0 0))
)
(AssignLink
   (TypeNode "ReferenceLink" (av 0 0 0))
   (AnchorNode "count")
   (NumberNode "3.000000" (av 0 0 0))
)
(AssignLink
   (TypeNode "ReferenceLink" (av 0 0 0))
   (AnchorNode "count")
   (NumberNode "2.000000" (av 0 0 0))
)
(NumberNode "1.000000" (av 0 0 0))

Can't make guile example work

I'm trying to follow what is described in

atomspace/examples/guile/README.md

but I'm getting the following error

nilg@laptop:~/OpenCog/atomspace/examples/guile$ guile
GNU Guile 2.0.9
Copyright (C) 1995-2013 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (add-to-load-path "/usr/local/share/opencog/scm")
scheme@(guile-user)> (add-to-load-path ".")
scheme@(guile-user)> (use-modules (ice-9 readline))
scheme@(guile-user)> (activate-readline)
scheme@(guile-user)> (use-modules (opencog))
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;;       or pass the --no-auto-compile argument to disable.
;;; compiling /usr/local/share/opencog/scm/opencog.scm
;;; opencog.scm:22:0: warning: possibly unbound variable `cog-set-atomspace!'
;;; opencog.scm:22:20: warning: possibly unbound variable `cog-new-atomspace'
;;; compiled /home/nilg/.cache/guile/ccache/2.0-LE-8-2.0/usr/local/share/opencog/scm/opencog.scm.go
While compiling expression:
ERROR: In procedure dynamic-link: file: "libsmob", message: "file not found"

use __path__ to locate additional python locations!

add the/usr/local/share/opencog/python system directory to the __path__ in the __init__.py's of the "opencog" build packages.

This page looks helpful:
http://stackoverflow.com/questions/2699287/what-is-path-useful-for

I'm guessing that the source/build dir should use __path__ to say "hey if you did not find it here, then look at the install location, but let the source/build always have priority over install"ย 

By contrast, the installed __init__ should NOT use __path__ since the install location should be "unique" from its own point of view ...

Exceptions thrown message turn into numbers in guile

It seems I can't get the exception message of a function in guile.

Specifically when trying to executing the example

examples/rule-engine/simple-deduction.scm

I get something like

ERROR: In procedure opencog-extension:
ERROR: Throw to key `decoding-error' with args `("scm_from_stringn" "input locale conversion error" 84 #vu8(66 97 99 107 116 114 97 99 101 58 10 73 110 32 115 121 115 116 101 109 47 118 109 47 116 114 97 112 45 115 116 97 116 101 46 115 99 109 58 10 32 49 55 50 58 32 49 57 32 91 119 105 116 104 45 100 101 102 97 117 108 116 45 116 114 97 112 45 104 97 110 100 108 101 114 32 35 102 32 46 46 46 93 10 73 110 32 105 99 101 45 57 47 98 111 111 116 45 57 46 115 99 109 58 10 49 54 52 53 58 32 49 56
...

Tracking down the problem in gdb it seems to occur when an exception is thrown.

Any need to keep these protobuf message types?

What is the purpose of these messages? Is there any reason for keeping this message types?

  1. https://github.com/opencog/atomspace/blob/master/opencog/persist/zmq/atomspace/ZMQMessages.proto#L43 . Last commit refering to Trail is c9bacab . Trail seems to have been a continaer for storing a series of atoms, could have been used similarly to inference history in the python-pln
  2. https://github.com/opencog/atomspace/blob/master/opencog/persist/zmq/atomspace/ZMQMessages.proto#L20 . Last commit refering to VersionHandle is 518f603

This follows from @ceefour's suggestion @ https://groups.google.com/d/msg/opencog/KUrO5fx0bKg/uilwdioF9nYJ for the neo4j backing store.

@cosmoharrigan @linas @ngeiswei

fail to compile BasicSaveUTest

[ 51%] Building CXX object tests/persist/sql/CMakeFiles/BasicSaveUTest.dir/BasicSaveUTest.cpp.o
In file included from /atomspace/build/tests/persist/sql/BasicSaveUTest.cpp:24:0:
/atomspace/tests/persist/sql/BasicSaveUTest.cxxtest:36:42: fatal error: opencog/nlp/types/atom_types.h: No such file or directory
 #include <opencog/nlp/types/atom_types.h>
                                          ^
compilation terminated.
make[3]: *** [tests/persist/sql/CMakeFiles/BasicSaveUTest.dir/BasicSaveUTest.cpp.o] Error 1
make[2]: *** [tests/persist/sql/CMakeFiles/BasicSaveUTest.dir/all] Error 2
make[1]: *** [CMakeFiles/tests.dir/rule] Error 2
make: *** [tests] Error 2

I think this has to be moved to opencog, and add scheme binding test in its place, right ? @linas

ptv, stv, ftv values are not checking for strength to be between [0, 1]

guile> (define foo (stv 748357403 1))

guile> (cog-tv->alist foo)
((count . 4473923584.0) (mean . 748357376.0) (confidence . 0.9999998211860657))
guile> (define bar (stv 748357403 17584760854376))

guile> (cog-tv->alist bar)
((count . 4473923584.0) (mean . 748357376.0) (confidence . 0.9999998211860657))

This might be the wanted feature of stv as it is being used differently by different codebases. But, ptv and ftv shouldn't, and if I am not mistaken ptv should have confidence2count method similar to https://github.com/opencog/atomspace/blob/master/opencog/atomspace/FuzzyTruthValue.cc#L122 maybe with a different formula

haskell errors during install

make install seems to work, but ends with a warning:

Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal update' to download it.
cabal: Could not resolve dependencies:
trying: opencog-atomspace-0.1.0.0

the cmakefiles should not attempt to build haskell unless it is full installed.

GetLink usage

Scenario 1

Defined

(define (counter)
    (define (increment-number str)  (+ (string->number str) 1))
    (let ((nn (cog-chase-link 'ReferenceLink 'NumberNode (AnchorNode "count"))) )

        (if (null? nn)
            (ReferenceLink
                (AnchorNode "count")
                (NumberNode 1)
                )
            (cog-execute! (cog-execute!
                (AssignLink
                    (TypeNode "AssignLink")
                    (TypeNode "ReferenceLink")
                    (AnchorNode "count")
                    (NumberNode (increment-number (cog-name (car nn))))
                )
            ))

        )
    )
)

(define get
    (GetLink
        (AssignLink
            (TypeNode "AssignLink")
            (TypeNode "ReferenceLink")
            (AnchorNode "count")
            (VariableNode "x")
        )
    )
)

Run on the cogserver

guile> (counter) (counter)(counter)(counter) ; run as many time as you like
guile> (cog-satisfying-set get)
(SetLink
)

Senario 2:

load AssignLinks from https://github.com/opencog/atomspace/blob/master/examples/guile/assign.scm#L61

Defined

(define get2
    (GetLink 
        (AssignLink
        (TypeNode "EvaluationLink")
        (PredicateNode "some property")
        (ListLink
            (ConceptNode "thing A")
            (VariableNode "x")))))

Run on the cogserver

guile> (cog-satisfying-set get2)
(SetLink
   (ConceptNode "alternative B")
   (ConceptNode "The V alternative")
)

@linas why doesn't Scenario 1 work? Is it a feature or a bug?

Functional type system for hypegraphs

Object

Proposal for an hypergraph type checker.

Motivation

The current type system is too limiting and doesn't allow to overload
operators. Here's an example when using PLN Or/And rules.

For instance, one might want to write

OrLink
    ConceptNode "Big"
    AndLink
        ConceptNode "Tall"
        ConceptNode "Slim"

But we need to tell that OrLink arguments are ConceptNode or AndLink,
however an AndLink may not necessarily have the right type, for
instance the following is ill-formed:

OrLink
    ConceptNode "Big"
    AndLink
        PredicateNode "is_tall"
        PredicateNode "is_slim"

So is the following:

OrLink
    ConceptNode "Big"
    AndLink
        EvaluationLink
            PredicateNode "is_tall"
            ConceptNode "John"
        EvaluationLink
            PredicateNode "is_slim"
            ConceptNode "Cathy"

Maybe one can address that by creating several OrLink types, like
OrConceptLink, OrPredicateLink, OrFuzzyTVLink. Or alternatively use
SatifyingSet implicitly, etc. However even if that would not solve the
problem generally, as in the cases involving Schemas, etc. We need a
real type system to handle those cases.

Proposal

I suggest a type system kinda on top of the current atom type system
as defined in atom_types.script. Let's call it the "functional type
system" or the FT system for short. Let me jump straight into the
definitions, then I'll give a few examples.

Terminology

I'm using Haskell terminology as much as possible, so

E :: T

is used to denote the type T of expression (or hypergraph) E.

T1 -> T2

denotes the type of a function with domain T1 and co-domain T2.

T1 -> T2 -> T3

similarly denotes a function that take 2 arguments of types T1 and
T2, and return type T3.

P => T

denotes the precondition P of type T.

T1 == T2

means that T1 is exactly equal to T2.

T1 <= T2

means T1 inherits T2 (this one doesn't exist in Haskell I think).

Simple primitive functional types (non exhaustive list)

Primitive types start in upper case, while type variables start in
lower case.

ATOM :: Atom
CONCEPT_NODE :: Concept
NUMBER_NODE :: Number
VARIABLE_NODE :: Variable

You may notice the absence of Node in the type name, that is because
that notion is now represented with the type signature itself. We'll
see that with type functions such as lists.

Of course all types above inherit from Atom, that is

Concept <= Atom, Number <= Atom, etc.

Finally we've got the type

TV

which denotes a truth value. By truth value I mean its most general
form, a pdf over [0, 1], I don't make the distinction between
probabilistic and fuzzy truth value, because it turns out the type
system can be used for that, and besides, the real nature of a truth
value is both fuzzy and probabilistic, depending on the way the PLN
rules are gonna use them.

Composite functional types (non exhaustive list)

LIST_LINK :: [a]

[a] is in fact syntactic sugar for List a

MEMBER_LINK :: Atom -> Concept -> TV

so this means that MEMBER_LINK takes an atom, a concept and returns a
TV.

PREDICATE_NODE :: [Atom] -> TV

Let's also define a type for it since it is used a lot

Predicate == [Atom] -> TV
EVALUATION_LINK :: Predicate -> [Atom] -> TV
IMPLICATION_LINK :: Predicate -> Predicate -> TV
EQUIVALENCE_LINK :: Predicate -> Predicate -> TV
INHERITANCE_LINK :: Concept -> Concept -> TV
SIMILARITY_LINK :: Concept -> Concept -> TV
AND_LINK :: a <= Concept or a <= Predicate or a == TV => a -> a -> a
OR_LINK :: a <= Concept or a <= Predicate or a == TV => a -> a -> a
NOT_LINK :: a <= Concept or a <= Predicate or a == TV => a -> a
BindLink :: [Variable] -> Atom -> Predicate
ForAllLink :: [Variable] -> Atom -> TV

As you may see BindLink and ForAllLink have different type signatures,
BindLink is used to define a predicate, while ForAllLink defines a
TV.

SchemaNode :: [Atom] -> Atom

Or more precisely

SchemaNode "+" :: [Number] -> Number

You may notice that I use [Atom] as argument of PredicateNode, that's
because I noticed that all over the code a PredicateNode has always a
ListLink. For instance a 0-ary predicate is only defined over an empty
list. I don't know if that's necessarily a good idea, but as it's seem
expressive enough, I chose to have my notations as alligned as
possible with the existing use.

Tuple

It seems useful to have something finer than List, to be able to
express the number of elements and their types, for that we introduce
N-Tuple that inherit lists.

ListLink
    NumberNode "3"
    NumberNode "2"
:: [Atom]
:: [Number]
:: 2-Tuple Number Number

with of course

(2-Tuple Number Number) <= [Number] <= [Atom]

That way we can express things like

SchemaNode "/" :: (2-Tuple Number Number) -> Number

Examples

Now let's show the type of some hypergraphs:

Apply a predicate

EvaluationLink <tv>
    PredicateNode "P"
    ListLink
        ConceptNode "A"
        ConceptNode "B"
:: TV

Build a predicate

BindLink
    ListLink
        VariableNode "$X"
    AndLink
        EvaluationLink
            PredicateNode "Tall"
            ListLink
                VariableNode "$X"
        EvaluationnLink
            PredicateNode "Slim"
            ListLink
                VariableNode "$X"
:: Predicate

Apply a schema

ExecutionOutputLink
    SchemaNode "+"
        ListLink
            NumberNode "3"
            NumberNode "2"
:: Number

Further remarks

Extensional, intensional and mixed

Following the type system we can type check mixed
relationships. For instance we know that

InheritanceLink
    A
    B
:: TV

is equivalent to

OrLink
    ExtensionalInheritanceLink
        A
        B
    IntentionalInheritanceLink
        A
        B
:: TV

assumming that both ExtensionalInheritanceLink and
IntentionalInheritanceLink return TV, then we can use the OrLink type

OrLink :: a <= Concept or a <= Predicate or a == TV => a -> a -> a

with a == TV, to obviously type check mixed inheritance.

IO monad

Could we represent procedure's side effects with IO monad? For
instance

PredicateNode "is_pixel_blue" :: (2-tuple Number Number) -> IO TV

Constify the AtomSpace API

Proposal

I think the AtomSpace API can be properly constified. I had tried many months ago but this time I got a bit further. I think this is sufficiently important to get some attention. Ultimately it might help to avoid some bugs.

For instance

const Handle h;

would not allow to modify the atom attributes referred by h.

Or perhaps one may want to define a ConstHandle type (like const_iterator in STL). I personally don't think it would be necessary. I don't think we care in practice to have the freedom of modifying a Handle while not having the freedom of modifying its constant. So a mere const Handle, meaning

  1. Can't change Handle
  2. Can't change Atom

would do.

Failed attempt

I tried but failed, thought I think it's possible. The mutex _mtx needs to be mutable. And one needs to use for the const accessors AtomConstPtr, NodeConstPtr, LinkConstPtr, etc beside AtomPtr, etc.

Any remarks?

I would like to hear about your remarks before I try again.

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.