Previous Chapter: Getting Oriented

Structured Knowledge & Simple Queries

In the last chapter, we learned how we can think of the Atomspace as a database of documents. Each Atom is like a document that can contain a set of key-value pairs. But document-store database solutions are already plentiful and the value of the Atomspace comes from other capabilities.

So now we’ll begin to explore the Atomspace as a knowledge representation format, or Knowledge Base; Often abbreviated as KB.

KBs hold a collection of concepts and define them in relationship to other concepts. KBs are a relatively old idea, not unique to the Atomspace, and there is a Wikipedia page covering the basics: https://en.wikipedia.org/wiki/Knowledge_base

This guide and nearly every other piece of documentation on KBs I’ve encountered describe the primitives of knowledge representation using concrete examples from the real world, such as “A dog is an animal.” This is helpful for learning the particulars of the KB because the fundamental conceptual relationships are already familiar to most people. However, I believe a large amount of the value of KBs and ontologies come from the ability to reason within an abstract systems of precise relationships where that precision has been imposed elsewhere, at another level, or where ambiguity never existed to begin with. For example, a KB could be used to reason about the behavior of a computer program, given a hypothetical set of inputs.

In general, strictly regular KBs have many limitations when representing data from real world. For example, the InheritanceLink documentation points out the difference between Extensional vs. Intentional Inheritance. I’d argue this is just the tip of the iceberg when trying to formalize knowledge about the fuzzy real world into a crisp ontology. That being said, the Atomspace is better than most other KB formats, because of the tools it provides for expressing nuance, partial truth and uncertainty. All the same, in my opinion, a symbolic KB alone is not sufficient for many aspects of real-world knowledge representation. Regardless, I’ll attempt to refrain from injecting too much of my own personal opinions and conclusions into this guide dedicated to understanding the Atomspace.

Ultimately, any formal language is only as precise as the axioms and definitions it is built upon, and you will have to define your own meanings and maybe even your own grammar. Personally I view the Atomspace less as a language and instead as the building-blocks out of which a language can be created. Some people have used the Atomspace to represent tokens and grammar from a natural language such as English, while others have used it to represent interactions between proteins and genes. In its purest form, the Atomspace is a system where data and rules about how the data can interact can be described side-by-side, and then queried and simulated.

Executing Atoms

Atoms in the Atomspace can represent both data as well as the transformations and operations that can be done to the data. The code and the data exist side-by-side. From the perspective of the Atomspace, they’re all just atoms.

We just saw how we can use a link atom to create a compound concept, i.e. “Fido the Dog’s weight_in_kg”. Take a look at another compound concept formed with a link:

(PlusLink
   (NumberNode 2)
   (NumberNode 3)
)

In English, those 3 atoms would be interpreted as the sentence fragment “The sum of 2 and 3”. If you paste the above Scheme snippet into the Guile interpreter, it just puts those 3 atoms into the Atomspace. Boring!

But PlusLink has a special property; it is an Active or “executable” atom type.

So far, the atoms we’ve seen, like the ListLink we used above, have been declarative, but Active atoms can be executed. Executing an atom means some computational operation is performed. The behavior varies from one atom type to another, and the effects can range from synthesizing a new Value, creating new atoms in the Atomspace or even deleting existing atoms.

Some Link types may be Active as well as declarative, and which operation occurs depends on the context in which the link is accessed.

We execute an atom with the cog-execute! OpenCog function call.

(cog-execute!
   (PlusLink
      (NumberNode 2)
      (NumberNode 3)
   )
)

If you just ran the Scheme snippet above, you probably noticed that it returned (NumberNode 5). And if you were being very thorough, you also may have also noticed that the (NumberNode 5) atom was created and added to the Atomspace. When the output of cog-execute! is an atom, it will be added to the Atomspace.

Remember, Atoms can’t exist outside the Atomspace, so even atoms that are created for a temporary operation are added to the Atomspace and remain there until something explicitly removes them. Sometimes this is desireable. Sometimes this is annoying. For now, it’s just something to be aware of.