Override Block and Encoding Defaults and Exceptions
In order to make your code as similar as possible to the rules you are encoding, you need to be able to write rules that are exceptions to other rules. Blawx allows you to do that using the “Override” block.
In order to use the override block successfully, you need to understand how Blawx deals with conflicts.
First, Blawx tries to find out if there is a conflict. If there is a conflict, Blawx will look for an override that settles the conflict. If Blawx cannot find an override, both of the conflicting facts will be treated as proven false.
What counts as a conflict?
There are currently two things that Blawx will detect as a conflict. The first is anything that is known, and its negation is also known. For example, if you say Socrates is Human, and you say Socrates is not human, that will be a conflict.
Blawx will also recognize one other scenario as a conflict. If there is a category that has an attribute that has been defined as being a “True/False” attribute, and that attribute has been set to both True and False, that will also be a conflict.
How Does Blawx Resolve Conflicts?
If the two conflicting conclusions are set by conflicting rules, and there is an override statement that makes one of those rules override the other, the result from the overridden rule will be ignored.
You can use this to create default conclusions that are overridden in specific cases. Consider the following two rules:
Birds can fly. Penguins are birds, but they can't fly.
We always start by setting out our ontology. Here, we want a category called Bird, and we want an attribute that describes whether they can fly. We also want a category called Penguin, and to say that all Penguins are Birds.
Now we need to encode the rule that if you are a bird, you can fly. We call this rule “birds_fly”. This is the default.
Now we want to encode a rule that says “penguin’s can’t fly”, which we will call “penguins_dont_fly”. This is the exception to the default rule.
Now if we create an object in the category Penguin, we will have a conflict between the result of the two rules, both of which apply.
If we create a Penguin called Kowalski, we can ask Blawx whether it knows anything about whether or not Kowalski can fly.
If you run this code, at this point, the reasoner will respond “The answer is: No.” It actually knows two things, but those two things are in conflict, so it forgets both of them.
Now, we add the override block that indicates that the penguins rule is an exception to the birds can fly rule.
Now if we run the code again, the reasoner will respond “The answer is: Yes” (which in this case means it does know something about whether Kowalski can fly), and then it will say “A: False”, (indicating it knows that he can’t, because he is a penguin).