Docendo
discimus
Business Rules Technology and Rule-Based Systems

"Inference Engines for Everyone"

Aut inveniam
viam aut faciam
Home News About This Site All Pages All Tags Wiki

BasicLogic

The Basics of Logic

Much of the complexity of a collection of rules arises from interactions between logical expressions within the rules ( also called logical 'terms' ). Unless rule base designers work assiduously to simplify rule expressions, they will be rapidly overwhelmed by the complexity of the rule base.

Venn Diagrams

One of the most powerful tools available to rule base designers to help simplify complex rule expressions is Venn Diagrams. The idea is simple - every example of something in the world can be put inside of a circle. It helps rule base designers to visualize the consequences of rules. For instance, there is the most classically Greek or all logical expressions is:

Socrates is a man
All men are mortal
Therefore Socrates is mortal

The same expression in Venn Diagram form is:

The deduction appears to be almost trivial when the terms are expressed in a diagram. It's like big fish swallowing little fish ( that just swallowed Socrates ) The deduction can also be expressed in a more general form ( the "ABC" form ).

IF A is a B
AND All B is C
THEN A is C

This expression is valid for anything that can be placed into slots A, B and C.

 

Visualizing Rules with Logical Expressions - AND, OR, XOR


Frequently, expressions are in a different form than a simple construction of terms "A AND B", where both must be true for the expression to be true. There may be cases where either "A OR B" can be true for an expression to be true.

For example, a store might have a policy about their days of business with a rule that days of operation are "weekdays and Saturdays", in other words they are closed on Sundays. Note that using everyday language, the rule would be expressed as "weekdays AND Saturdays", which means that the store will never open because there will never be day which is both a weekday and a Saturday. A precise expression in a more constrained rule format would be something like "IF day = aWeekday OR day=aSaturday THEN StoreOpen = true".

In everyday language, the word "AND" usually means add the two together, as in the case of "weekdays and Saturdays". The logical definition of the word AND is saying "when the two are true together", which means that when either one is false, the two are rejected. In other words, a logical AND works more like subtraction than addition. The logical OR effectively add the two groups together.

The diagram below show the adding and subtracting behavior of logical OR and AND, with the help a new category "Things Named Socrates", including people, pets, computer applications, anything denoted by the word 'Socrates'.

 

The diagram for the OR expression shows all things in the world named Socrates ( people, pets, whatever ) plus all men in the world, and all women too ( ancient Greek philosophers must have intended to include women in their propositions as well ). This diagram demonstrates an almost visual sense of addition, as if a logical OR were merging visual layers in a drawing.

The AND expression shows the only those things in the world which are both men and named Socrates ( not pets ). In the caseo fthe AND construction, there is a sense of subtracting out anything that is not common between the two visual layers.

The third diagram shows an example of a common logical expression, the XOR ( eXclusive OR ) expression. It is saying "things which are either named Socrates or are men, but not both named Socrates and are men. In fact, it is the exact equivalent of saying "A OR B AND NOT ( A AND B ). In the sense of a visual analogy, iIf you take the OR expression on the left and subtract the AND expression in the middle, you can derive the XOR on the right.

 


Using Negation in Expressions - NOT


The use of NOT in logical expressions can complicate set of a rules very quickly. To express the behavior of the NOT operation In Venn Diagram form requires creating of new element, that is a rectangle representing a universe of all possible things.

 

Note that evaluating the expression in the middle yields 'all things named Socrates that are not men", including pets and computer applications, but not people.

The expression of the right shows a new feature of logical expression that goes under various names - bracketing, closure, etc. It says "evaluate the expression between the parenthesis first and then evaluate the outside expression". As you can see, adding the parenthesis to the expression "All Men AND Things Named Socrates" alters the meaning considerably.

In fact, the use of parenthesis to control evaluation order is discouraged in rule base design. The alternatives will be discussed in the section "Rule Base Design".

 

Tags:   


Other BBcom-related sites - Quick Links

OldPhone  

Monitor

Monitor



A  Dial-Up Friendly Site  

We Do SVGA ( mostly )

Hisssss ...