The Blawx Encoding Process

The Blawx Encoding Process

The process of encoding rules in Blawx typically follows a four-step process.

What Kinds of Things Are We Talking About?

The first step of the process is to tell Blawx what sorts of things you are going to be talking about. You do this by describing the “objects” and “categories” that are important.

A category is an abstract idea, like “Person”. An object is a specific example of a category like “Bob”.

Categories can be given attributes. An attribute is a piece of information that is associated with an object in that category. For example, “a Person has a name” describes “name” as an attribute of the category “Person”.

When you give attributes to a category, you need to give them a type. A type for an attribute can be a data type (text, number, or true/false) that describes the kind of information that can be put into that attribute. But the type for an attribute can also be any category you have described, even the one to which the attribute applies. So for example, “a Person has a best friend, which is a Person, and a name, which is text” will work fine.

An object is a specific example of a category. You create an object, make it part of a category, and set its attributes in three different steps. So “bob is an object”, “bob is a person”, and “bob’s age is 23” all have to be said separately.

When deciding what categories, attributes, and objects to use, it’s a good idea to think about what facts, rules, and questions you are going to need to be able to say. For example, if you want to be able to ask “who won this game of tic-tac-toe?”, you are going to need categories to describe games, and the game category is going to need to have an attribute called “winner”, or “outcome”, or some other way of storing information about who won.

It is entirely normal for you to need to come back to this step over and over as you better understand what pieces of information you need in order to do useful things.

All of the blocks that are used to describe the categories and objects in your problem need to be put in “We Know” fact blocks in the interface.

What Are the Rules?

The next step in the process is to start writing rules with the categories and objects.

A rule is something that applies to objects in the abstract. For example, the law says that a “person” cannot cut down their neighbour’s tree. It doesn’t say that “bob” cannot cut down his neighbour’s tree. So rules need to be written by referring to possible objects, not actual objects. In Blawx that’s done by using variables instead of objects or categories.

So for example, if you want to say that “all men are mortal” you would create a rule that says “a variable X is a mortal if that same variable X is in the category men.”

Generally, whenever you use a variable with the same name inside a rule, it refers to the same object in all the other parts of the rule. But that “I’m referring to the same thing” effect doesn’t carry between rules. So it is perfectly fine to use the variable X in the rule “X is a cat if X purrs”, and then to us the variable X in a different rule “X is mortal if X is a man”.

Usually, in the rules you will deciding the value of some attribute of an object on the basis of other objects’ values. So most of the blocks included in rules will be drawn from the Object, Known Objecjt, Known Attribute, and Variable categories in the toolbox.

What Are The Facts?

The next step in the process is to give the tool the facts that you want to ask a question about. If your question is going to be about who won a game, you are going to need to create a game object, and give that object all the values that it needs in order to answer the question (e.g. where all the Xs and Os are).

This part generally involves creating objects, and defining the values for their attributes. All those blocks then need to be placed in a “We Know” block.

If you are using Blawx’s API feature to integrate it with another tool online, the facts will often be provided by that other application. In that case, you need to make sure that Blawx can “translate” from the facts received from your web application, and the facts that fit into the ontology you have described.

What Question Do We Want An Answer For?

The last step in the process is to write your question. Usually, most of the hard work will have been done already, and writing the question is relatively simple. For example, if you want to know who won a game of tic-tac-toe, and you have defined “game” as a category of object with the attribute “winner”, and rules that set the value of winner correctly, and you have described the game you want to ask about as an object that you named “myGame”, then your question will be “what is the value of myGame’s winner attribute?”

In Blawx you create a query by using the query block and then describing the question. If you don’t include any variables in the question you will get a yes or no answer. If you include variables, you will get an answer that includes all the objects that could be slotted into those variables that would give a true answer.

So you could ask “is the winner of MyGame Player1?” Because there are no variables in that question, it will say “yes” or “no.” You could also ask “myGame’s winner is the variable X?” And then the system will give you all the answers for which that statement would be true, and tell you how many there are.

That’s It!

It’s not too bad, right? First, what are we talking about, here? Second, what are the general rules? Third, what are the facts for my specific question? Fourth, and last, what specific question am I asking?

The best way to learn the process of encoding rules in Blawx is to start with really small problems that you already know the answers to.

No Comments

Add your comment