opencog / atomspace

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

Compostionality of Atomese processing stages (was "StopUsing SetLinks!) #2911

Open linas opened 3 years ago

linas commented 3 years ago

Issue #1502 "Stop using SetLink for search results!" highlights a problem with the compositionality of the search and processing primitives in Atomese. Search results were (still are) delivered wrapped in a SetLink. This presents challenges for the cleanup of search results, and various other core issues (See issues described on the SetLink wiki.)

Basically, it is difficult to create long processing pipelines, such as (cog-evaluate! (SequentialAnd ... (Put .... (State ... (Get ... (SequentialOr ... (Delete ... (Bind ... with the top-level SequentialAnd written to be tail recursive. Such long pipelines have been implemented (in the robot code, circa 2017) and they do work (see for example the tail-recusion demo and older copies of the https://github.com/opencog/ros-behavior-scripting repo) However, there are problems:

A replacement solution is needed. Desirable properties:

So basically, there are two issues being explored here, in tandem:

A wholly unexplored idea:

The best idea seems to be:

The following progress has been made:

The cogutils provides five thread-safe tools for building these things:

Note that QueueValue is built on top of concurrent_queue.h

Implementing compositionality requires finishing work on the $vau-ization (fexpr-ization) of Atomese functions. See $vau (aka fexper) on Wikipedia. Many or most functions now work like this; the grand exceptions include the PutLink and most of the TruthValue subsystem.

Possible building block for monads or related:

To explore these issues, and possible solutions, some demos are suggested. So far, we have the following demos and related issues:

linas commented 1 year ago

At this time, building on top of QueueValue seems the most sensible thing to do. This could be formalized by providing an API within QueuueValue itself, instead of inheriting from what's in cogutils.

linas commented 1 year ago

The following attempt was made:

The reason that this was reverted is because it didn't seem to be needed, and there seems to be a more generic solution: if one really needs stuff stuck to an AnchoreNode, then create a new kind of Value, that dequeues from the QueueValue, as results come in, and sticks them onto an AnchoreNode. This could be done for any kind of data stream, and not just for queries.

There has been some minor exploration of how compositionality works; it is demoed in the (still existing) example query.scm This example uses AnchorNodes, but without needing pull req #2500 to do it. It "works". It's even multi-threaded, so its "naturally" parallel. Is it clunky? I dunno. It posts results to the AtomSpace, ... but why? was this really needed?