Perhaps you remember diagramming sentences in grade school. The task was to identify the parts of speech by their function. You began with an empty sentence diagram and copied words into the appropriate spots, according to the roles they played. Given the sentence "the dog sees a black cat", this is how the sentence diagram might appear. The subject, verb and object take their spots. Articles and adjectives that modify the subject and object are attach below:
dog | sees | cat
---------|---------+---------
\ \ \
\t \a \b
\h \l
\e \a
\ \c
\k
When we perform the same kind of analysis computationally, we call it parts-of-speech tagging. Each part of speech is linked into a data structure by its function. Links capture the way the concepts are interrelated. Once tagged, the language can be thrown away; it has been translated into knowledge.
o Root
/|\
/ | \
SUBJECT | OBJECT
/ | \
"dog" o VERB \
| | o "cat"
| o |\
| "sees" | \
ARTICLE | ATTRIBUTE
| ARTICLE \
o | o "black"
"the" o
"a"
Here are some other examples of statements that we could translate into knowledge:
You are in love.
The dog is hungry.
I was the king.
In Brainhat, "programs" are collections of statements like these, compiled into binary form. Each statement conveys a simple idea.
Here is a simple program in action. This program is made up of three explicit inferences, a proposition and an attribute assignment:
if dog has toy and dog is in room then toy is in room.
if a dog sees a cat then dog drops toy and dog chases cat.
if dog drops toy then dog does not have toy.
dog has a ball.
dog is in kitchen.
Below, we continue interactively. The statements preceded by '>>' are entered by the user:
>> dog is in bathroom.
dog is in bathroom.
a ball is in bathroom.
>> where is ball?
a ball is in bathroom.
>> dog sees cat.
dog in bathroom sees cat.
dog in bathroom drops toy.
dog in bathroom does not have toy.
dog in bathroom chases cat
>> dog is in bedroom.
dog is in bedroom.
>> where is ball?
a ball is in bathroom.
The dog had the ball at the outset, but now the dog is in the bedroom and yet the ball remains in the bathroom. Why is that? The bathroom is where the dog dropped the ball when the dog chased after the cat.
Human language captures knowledge and makes knowledge portable.
Programming Brainhat with simple English, then, is tantamount to
programming with simple knowledge. This is very different than
computing with data, which is what most of us are familiar with. To
highlight the difference, ask yourself how would you program this in
C, Perl or JavaScript?:
"I love you."
In Brainhat programming, this is a proper statement and it can be
just the right thing to say, too! As a minimum, the new knowledge
will be stored and indexed. There may also be changes to preexisting
stored knowledge, the exercise of inferences, the recall of memories
and some interprocess communication.
In this next example, we interactively teach Brainhat to play heads-or-tails. The first to reach a score of 5 wins:
>> your score is 0.
my score belonging to I is 0.
>> my score is 0.
your score belonging to You is 0.
>> if i say heads then add 1 to your score.
if You say head then add 1 number to my score.
>> if i say tails then add 1 to my score.
if You say tail then add 1 number to your score.
>> if my score is 5 then i am the winner and you are the loser.
if your score is 5 then You are the winner and I am the loser.
>> if your score is 5 then you are the winner and i am the loser.
if my score is 5 then I am the winner and You are the loser.
>> heads.
head.
my score belonging to I is 1.
>> heads.
head.
my score belonging to I is 2.
>> tails.
tail.
your score belonging to You is 1.
>> tails.
tail.
your score belonging to You is 2.
>> heads.
head.
my score belonging to I is 3.
>> heads.
head.
my score belonging to I is 4.
>> tails.
tail.
your score belonging to You is 3.
>> heads.
head.
my score belonging to I is 5.
I am the winner.
You are the loser.
>> am i the winner?
no.
You are not the winner.
>> how was your score when my score was 2?
score was 4.
score was 3.
score was 2.
>> what value was my score when your score was 4?
your score belonging to You is 3.
your score was 2.
The statement "if my score is 5 then i am the winner and you are the loser" is an explicit inference. When conditions match, the inference executes and causes side-effects like "you are the loser."
In these examples, we interact with Brainhat in simple language. But as we noted earlier, Brainhat doesn't process language; it compiles language into knowledge, and then executes over that. One could craft whole programs with no runtime use of language and no human interaction. Here's a very small example:
if you see a fire sound the alarm.
Perhaps you have experience with procedural and imperative
programming languages such as C, Perl or Python. These kinds of
languages feature data types. The number 3, TRUE, and "11 Oak Street"
are examples of data of type integer, boolean and string. For a datum
to have meaning it has to be associated with a variable or table
entry, as in k=3, complete=TRUE or address="11 Oak Street." Data do
not live unbound; they don't float around on their own.
integer i,j,k
string c
j = 2
k = 1
i = j + k
string = "here is a non-zero answer:"
if (i != 0)
print string, " ", i
end
Procedural languages also have flow control statements, such as 'if'
or 'while,' that implement branching. There may be subroutines or an
event loop. The program jumps from place to place, but execution will
always be somewhere within the code--somewhere that you can point to.
By contrast, there are no flow control statements within Brainhat.
There's no program in a regular sense. There's no distinction
between data and code. Rather, the data themselves direct
execution and are perhaps even the result of execution. Data
float around, unattached.
Brainhat is programmed in simple English. To read English, Brainhat has to recognize the words (tokens) and make sense of their arrangement. Tokens and possible ordering are prescribed by a vocabulary and a grammar. The vocabulary says what the tokens can be. The grammar says how they can be combined. The vocabulary and grammar create the possibilities for, and define the limits of, what Brainhat can understand.
I was the king.
Based on the grammar and tokens, the program tags parts of speech--the subject, verb, attributes and object, etc. and places them into a data structure that represents the English input.
o Root
/|\
SUBJECT / | \ OBJECT
o | \
You | o king
|
VERB |
o
to be
In Brainhat terminology, each of the vocabulary elements--"I", "to be" and king" is called a concept. A combination of concepts, like the data structure depicted above, is called a complex concept or CC. As CCs are created, they are threaded onto the memory-resident context in the order that they are learned.
new -> old
o--------o--------o--------o--------o---...
/|\ |\ /|\ | / \
o | o | o o | o o o o
o o o
: : :
: : :
: : "You are in love"
: :
: "dog is hungry"
:
"I was king"
Everything in the context is indexed and hashed for searching. This makes it possible to find knowledge quickly. The context or portions of the context may be stored on disk along with indexes and hashes. They can be restored to a new context at program initiation or dynamically, in pieces, as the program runs. It is also possible for one instance of Brainhat to access the memory-resident and disk-resident knowledge belonging to another instance of Brainhat across the network.
Language makes knowledge portable, but language can be imprecise.
When I say "the dog has a ball," chances are that your mental
image differs from mine--a different kind of dog, a different
ball. The differences are a consequence of the knowledge we have
acquired previously. Because of the ambiguity of language, our
shared knowledge will often disagree in the details. Instances of
Brainhat can share knowledge, too. However, Brainhat does not
have to translate knowledge back into human language in order to
share it. Ergo, knowledge shared between Brainhats can be more
precise than knowledge shared with language.
Brainhat's vocabulary is defined hierarchically. A husky is a dog, a dog is a pet, a pet is an animal, and so on. Concepts for hamster, cat, dog and wildebeest are children (hierarchically) of the concept for animal. We may ask if a wildebeest is an animal and whether it shares some features in common with dogs, and the answer will be "yes." However, there is no upward path from wildebeest to pet. Therefore a wildebeest is not a pet.
o things
/|\
vegetable o | o mineral
|
animal o
|\
| o wildebeest
pet o
/|\
/ | o cat
hamster o |
o dog
|
husky o
The taxonomy is important for generalization in inferences, memories and interaction. We might talk about fruit when saying something about bananas, pears and strawberries as a class. "The man sells bananas" satisfies the question "does the man sell fruit?" and "the dog sees the ball" satisifes "does something see something?"
Memories
Knowledge generated in a Brainhat session can survive past the end of the session and be made available for future use. We call these saved bits of knowledge "savesets." Savesets are collections of CCs threaded together, similar to the way the context is threaded. Savesets can be cumulative. Savesets from multiple sources can be combined.
o--------o--------o--------o--------o
/|\ |\ /|\ | / \
o | o | o o | o o o o a memory
o o o
Memories are savesets whose content is indexed for recall. They can be resurrected when conditions in the context are similar to those under which the memories were saved. When they are, the CCs within the memory may be merged into the running context.
Memories fall into three categories. The most basic memories are the products of attribute assignments and propositions such as "bananas are yellow" or "dogs like bones." These may be recalled when needed, such as when someone asks "what color are bananas?" Or, when dogs are mentioned. We call these Type-1 memories.
Type-2 memories are explicit inferences templates, like we saw above in the heads-or-tails example. They are characterized by an unevaluated set of conditions, any of which can invoke the inference template for evaluation. When they're proven true, the consequences become part of the context.
An example of a type-2 memory might be: "if i like you then you like me." "I like you" is the condition; "you like me" is the consequence. Elements can be abstract, too, as in: "if a thing is in the water then a thing is wet." When a dog or cat falls in the water, the memory will be retrieved and the dog or cat will be deemed wet. There can be many conditions and many consequences, and inferences can chain.
The third form, Type-3 memories, are savesets wherein every CC within saveset is indexed. When enough of the CCs become relevant, the saveset may be resurrected as a Type-3 memory. Type-3 memories are called implicit memories because the truth of some of the CCs in the saveset imply the truth of the rest of them. Consider this memory of walking on the beach:
the weather was beautiful.
the sun was shining.
i walked on the beach.
i lost my dog.
If you had lost your dog while walking along the beach, you would probably think about the dog anytime you walked on the beach thereafter. This would be an implied memory. Here is how that would look in a subsequent Brainhat session:
>> i walked on the beach
You did walk on the beach.
>> the sun was shining
the sun shines.
>> did i lose something?
yes. You did lose your dog.
Life goes on. You will have other beach experiences. You may not dwell on the dog as much. Inside Brainhat, as the collection of memories grows, the process of resurrecting them becomes more selective. Implicit memories will compete for relevance. Only the most pertinent will be restored.
Creating memories and making them available for future runs can give Brainhat personality and utility.
Scripts
Perhaps you have a specific task for Brainhat, such as making ice cream cones. One could construct Brainhat cone-making knowledge with explicit inferences. They could be cascaded to step Brainhat from chosing a flavor through handing off a dripping cone. However, for complex tasks it can be easier to orchestrate the process with a scripting framework.
The scripting framework in Brainhat is called "Motives." It allows the programmer to craft a state diagram in tabular form. The nodes are knowledge. The edges are inferences. Executing an inference will advance the state to the next node.
Returning to cones, a an edge might be "customer likes sprinkles." The node could be "add sprinkles." Other processing continues while scripts are in use. Motives can follow many paths at once, gather information from many sources and advance many agendas. Multiple Motive scripts can be active at the same time, making it possible for Brainhat to make ice cream cones at the same time it plays checkers.
Brainhat Networks
In development, one will typically create a collection of knowledge and inferences that address a small domain. Once programming is perfected, it can be distributed to other copies of Brainhat across a network. What one Brainhat knows, another can also know, instantly. Local memories can be pooled and shared, allowing the network to host single broad context spaning many computers.
There are several kinds of network interconnections:
1. copies of Brainhat can peer and trade information from their contexts.
As soon as one knows something, the other knows it too.
2. one copy of Brainhat can follow another, receiving instant context updates.
This is a one-way transfer.
3. one Brainhat may access the memories of another. In this mode, the copy
of Brainhat serving memories does so without affecting its own local context.
4. one copy of Brainhat can initialize another across the network.
Communication is built upon websockets--both for GUI and interprocess communications. No additional network programming is necessary.
Whenever a portion of the context or memories is donated by one Brainhat to another, it's consumption is subject to merging successfully with the context of the recipient. Going back to the memory of yellow bananas, consider that bananas can be red, too. Stored memories of yellow bananas will not combine with preexisting knowledge about red bananas. Similarly, observations about hungry animals will not combine with animals that are not hungry. In Brainhat parlance, these memories are orthogonal, which means that they cannot both describe same banana, dog or concept. We will see how orthogonality provides the necessary relief for Brainhat to differentiate between this time and that time, this location and that location, and this banana and that banana.
APIs
In order to be able to affect the outside world, Brainhat offers bi-directional application portability interfaces (APIs). Devices that Brainhat talks to might include robots, sensors or classifiers. The API interfaces are asynchronous. An operation can complete long after it was requested. The APIs can also accept unsolicited input, such as might be offered by a camera and classifier, e.g. "I see a bear!"
The commands issued by Brainhat may be in the imperative ("shut the door"). Confirmation or answers can be a simple "no"or "yes" or "blue" or "in the water", or can be provided in natural language. Brainhat also provides a response ID so that a response can be correlated with a request.
Brainhat also comes with code to link to OpenAI and search resources.
Even at 30 years and counting, it feels early. It is hard to envision what applications might develop. The obvious ones include domain or process experts with live connections to external data and interfaces. Other, less obvious possibilities include communications; a swarm of Brainhats can form a communication network that understands the topics, and can expand or limit communications to others as needed. Or, given neural data, Brainhat can provide reasoning for and give voice to cognitive processes. Or, it could make ice cream cones.