ARL Master Index


Processing Options Statements

ruleset <nameOfRuleSet> {

< import Statement>*
// Zero or more statements

< library Statement>* // Zero or more statements

< predicates Statement> // required when using Predicate inference engine



void main() using <inferenceMethod>( options) {

}
...
} 

Ruleset processing options statements:

These statements allow you to import external Java classes for use in rules, add domain-specific user-defined function libraries, and define a list of predicates (for use with the Predicate engine only).

Processing options statements...


These statements allow you to specify which inference engine is used to process the rules in the main ruleblock and to set associated control parameters used by the selected inference engine.


using <InferenceMethod>(options)

For rulesets containing fuzzy variables and rules, specifies the manner in which a solution variable's fuzzy representation is updated.

For rulesets with no fuzzy variables and rules, specifies the type of inferencing to be performed.

If left unspecified, the default InferenceMethod is Script.

The specified InferenceMethod applies only to the main() rule block. All other rule blocks are processed with the Script engine.

Syntax

   void main() using <inferenceMethod>( options ) 
   void main() using FuzzyAdd | MinMax  | ProductOr 1
   void main() using Script | Forward | Forward2 | Forward3 | Mixed | Predicate | Backward 2
      

Inference Methods

       FuzzyAdd
Specifies that the fuzzy solution set is updated by adding the minimum truth value of the consequent fuzzy region, bounded by 1.0. This method is generally used with CorrelationMethod(Product). See the AlphaCut, CorrelationMethod and DefuzzifyMethod options.
       MinMax
Specifies that the fuzzy solution set is updated by using the maximum of the minumum truth value of the consequent fuzzy set. This method is generally used with CorrelationMethod(Minimise). See the AlphaCut, CorrelationMethod and DefuzzifyMethod options.
       ProductOr
Specifies that the fuzzy solution set is updated by using 1 minus the product of (1 minus the truth value of the consequent fuzzy set) and (1 minus the predicate truth). This method is generally used with CorrelationMethod(Product). See the AlphaCut, CorrelationMethod and DefuzzifyMethod options.
       Backward
Specifies that the boolean solution is obtained by doing backward chaining. See the GoalVariable option.
       Forward
Specifies that the boolean solution is obtained by doing simple forward chaining. This is the lightest weight of the forward chaining algorithms and is adequate for small to medium sized rulesets.
       Forward2
Specifies that the boolean solution is obtained by doing forward chaining that makes use of working memory.
       Forward3
Specifies that the boolean solution is obtained by doing forward chaining that makes use of working memory and Rete networks. This is the heaviest duty of the forward chaining algorithms and should be used for very large rulesets.
       Mixed
Specifies that the boolean solution is obtained by doing both forward and backward chaining. (NOT IMPLEMENTED)
       Predicate
Specifies that the boolean solution is obtained by doing predicate logic inferencing. See the GoalPredicates option.
       Script
Specifies that the rules are processed sequentially with no special inferencing.

This chart shows the degree of support that each inferencing engine provides for specific Able Rule Language features. Any feature marked NS is Not Supported, meaning the inferencing engine tolerates the presence of the feature in a ruleset but will not process it. These features will produce warnings. The presence of any feature marked NO will prevent a ruleset from executing so an error will be issued when the ruleset parses.

ARL Feature All ruleblocks Main ruleblock1
Inferencing method Script Fuzzy2 Forward Forward2 Forward3 Backward3 Predicate3
Assertion rule yes yes yes yes yes yes yes
If/Then If/Then/Else If/Then{} rules4 yes yes Else clause not supported NS NS Else clause / multiple consequents not supported Else clause / multiple consequents not supported
While/Do or Until/Do loop rule yes yes NS NS NS NS NS
When/Do pattern match rule yes no NS yes yes NS NS
Predicate rule no no no no no no yes
Fuzzy variable no yes no no no no no
Processing
order5
assertions, then sequential assertions, then sequential assertions, then sequential assertions, priority, sequential assertions, priority, sequential assertions, then sequential assertions, priority, sequential

1 Some inferencing methods are used only in the main ruleblock. The Script inferencing method is used to process other ruleblocks for these inferencing engines.

2 ProductOr, MinMax and FuzzyAdd inferencing methods.

3 At runtime, Backward chaining and Predicate inferencing require a GoalVariable or GoalPredicate respectively. A warning is issued when the ruleset is parsed if no variable is provided. The variable may be set via API before the ruleset is processed.

4 If/Then conditional rules have three variants:

Simple if x == 0
then y = 1
Else if x == 0
then y = 1
else y = 2
Multiple consequents if x==0
then y=0
z=1
else y=1
z=1

5 Rule processing order is generally assertions first, then rule priority (if supported), and finally in the sequence provided by the ruleset. See the JavaDoc for the appropriate inferencing engine for more details.

Examples

    RuleSet <nameOfRuleSet> (

       void main() using FuzzyAdd(alphaCut=0.1,
                                 correlationMetho=Product,
                                 defuzzifyMethod=Centroid) { 
       }  // For a ruleset with
           //   fuzzy (and other) variables.

       void main() using Forward() { }   // For a ruleset with
                                           //  NO fuzzy variables.

       void main() using Backward(goalVariable=customerType) {

       }

       void main() using Script() {  }

    
       void main() using Predicate(goalPredicate=son(X, John)) {

       }

      .
      .
      .
    )
      

1 Rulesets with fuzzy variables and rules.
2 Rulesets with no fuzzy variables or rules.

Return to top


AlphaCut

For rulesets with fuzzy clauses, specifies the threshold at which truth values become insignificant. If the truth value of any antecedent clause falls below the alphacut when the clause is evaluated, the inference engine stops evaluating the rule in which the clause appears.

If left unspecified, the default AlphaCut value is 0.1.

Syntax

   alphaCut=<numericValue>
      

Parameters

       <numericValue>
Is a number from 0.0 to 0.99. If set at 0.0, any clause that evaluates to anything greater than zero is essentially considered true to some degree. If set at 0.99, all clauses must evaluate to 1.0 (boolean true) to be considered true at all. Values between 0.05 and 0.2 may be considered typical, but of course it all depends on your fuzzy variables and their fuzzy set definitions.

Example

    ruleset <nameOfRuleSet> {

      void main() using FuzzyAdd(alphaCut=0.20) {

      }

      .
      .
      .
    }
      

Return to top


CorrelationMethod

For rulesets with fuzzy clauses, specifies the manner in which a rule's consequent fuzzy region is correlated with the rule's antecedent fuzzy truth value.

If left unspecified, the default CorrelationMethod is Product.

Syntax

   CorrelationMethod=(Product | Minimum )
      

Parameters

       Product
Specifies that the membership value of the consequent fuzzy region is the product of the fuzzy region and the truth of the premise. The effect is that the consequent fuzzy region is scaled, preserving its shape. This method is generally used with InferenceMethod(ProductOr) or InferenceMethod(FuzzyAdd).
       Minimum
Specifies that the membership value of the consequent fuzzy region is the minimum of the fuzzy region and the truth of the premise. The effect is that the consequent fuzzy region is truncated at the truth of the premise, creating a plateau. This method is generally used with InferenceMethod(MinMax).

Example

    ruleset <nameOfRuleSet> {

       void main() using FuzzyAdd(CorrelationMethod=Minimum) {

      }

      .
      .
      .
    }
      

Return to top


DefuzzifyMethod

For rulesets with fuzzy clauses, specifies the manner in which a fuzzy set is turned into a crisp numeric value.

If left unspecified, the default DefuzzifyMethod is Centroid.

Syntax

   DefuzzifyMethod=Centroid | MaxHeight 
      

Parameters

       Centroid
Specifies that a fuzzy set's crisp value is calculated as the weighted mean (center of gravity) of the fuzzy region. Also known as composite moments.
       MaxHeight
Specifies that a fuzzy set's crisp value is calculated from the point that has the highest truth value. Also known as composite maximum.

Example

    ruleset <nameOfRuleSet> {

      void main() using FuzzyAdd(DefuzzifyMethod=Centroid) {

      }

      .
      .
      .
    }
      
Return to top

Predicates

When InferenceMethod is predicate, specifies the names of predicates used in rules. All predicates referenced in rules must be pre-declared in this section.

This statement should not be used with other inference methods.

Syntax

   predicates { <predicateName>* };
      

Parameters

       predicateName
Is a list of zero or more names of predicates used in predicate rules.

Example

    ruleset <nameOfRuleSet> {

       predicates { father, mother, sister,
                      brother, aunt, uncle
                 } ;

      .
      .
      .
    }
      
Return to top

GoalVariable

Specifies the variable for which the backward chaining inference engine is to solve. GoalVariable is a required statement when using Backward is specified. For other inference methods, the statement must not be used.

Syntax

   void main() using Backward(goalVariable=<variableName>) {
        
   } 
      

Parameters

       <variableName>
Is an identifier that names a previously defined variable.

Example

 ruleset <nameOfRuleSet> {
  
  variables { 
   Diagnosis string("unknown");
   ...
  } 

  void main() using Backward(goalVariable=Diagnosis) {
                          // The backward chaining inference engine 
                             //   tries to determine the diagnosis. 
      .
      .
      . 
  } 

GoalPredicates

When InferenceMethod is Predicate, specifies the goal(s) of the predicate inference engine.

This option must immediately follow the using Predicates clause.

Syntax

   GoalPredicates= <predicateClause>* 
      

Parameters

       predicateClause
Is a list, separated by either commas or ampersands, of zero or more predicate clauses. These clauses represent goals to be solved by the inference engine.

Example

    ruleset <nameOfRuleSet> {
      
       predicates { male, female, father, mother, parent, 
                    son, daughter, brother }

      // Who is the brother of Milcah?
      void main() using Predicate(goalPredicate=brother(milcah,X)) {

      }  

      .
      .
      .
      void main() using Predicates(goalPredicate=brother(X, John)) {
      }

    }
      
Return to top

Library

Allows you to import all the public methods in the specified classes (or libraries) as user-defined functions without having to declare each method explicitly. Imported methods then become available to be called from rules. Note that if two or more imported classes contain duplicate method names with an identical number of arguments, the last method imported is the method that is available to your rules. Also, when using imported methods in rules, you must use the number and types of arguments expected by the method. No checking is done, and improper use will result in runtime errors during ruleset processing. Remember that all numbers used in the rules package are implemented as doubles.

See also the functions statement.

See also the general section on interacting with functions. Among other things, the section describes some built-in method libraries that are available.

Note that built-in functions always take precedence over imported functions of the same name and arity.

Syntax

   library package.class;
      

Parameters

       package.class
Specifies a single fully qualified class name, whose public methods are to be made available as user-defined functions. These methods can then be called from rule statements.

Examples

    ruleset <nameOfRuleSet> {

       library com.binford.Hammers;
       library com.binford.Saws;
       library com.tooltime.FirstAid;

      .
      .
      .
    }
      

The first two statements loads and defines all the public methods in both Hammers and Saws as user-defined functions. The third statement additionally loads all the public methods in FirstAid. If the Hammers library contains the public method driveNail(), for example, then a rule such as the following can be coded:


    rule: if (nail_length == 6) then rc = driveNail();
 
      
Return to top

Import

Allows you to define (import) your own data types so that you can declare and manipulate variables of those types. Each type you declare must be equated to a public Java class. Note: One import statement can define only a single Java class. Asterisks ("*") are not allowed in the import specification.

Syntax

   import package.class; 
 
   import com.yourCo.ClassName ;

   import com.yourCo.PackageName.* ; // NOT ALLOWED!
      

Parameters

      package.class
Is the fully qualified name of the Java class that you want to import into the ruleset. Instances of the named class must be fully serializable if you want to save your ruleset as a serialized AbleRuleSet object. The named class must also have a constructor method that matches the number of parameters that you will use when declaring variables of the specified type. If the named class has public members, or if it has public "get" and "set" methods for its members, those members can also be referenced in your rules. See the example below.

The class name is an Identifier that names a new data type. Variables of this type can then be declared and used throughout your ruleset. You must not redefine the built-in data types.

Example

    RuleSet <nameOfRuleSet> (

       import hanoi.Puzzle; 
       import hanoi.Ring;
       import hanoi.Logger;

      .
      .
      .
    )
      

The first statement imports the "hanoi.Puzzle" class, mapping the data type Puzzle to instances of objects of type "hanoi.Puzzle" and the data type Ring to instances of objects of type "hanoi.Ring." The second statement additionally equates the data type DataLog to instances of objects of type "hanoi.Logger".

These statements then allow the ruleset author to define variables such as shown below. Note that for each variable declaration an instance of the specified class is created and the constructor is passed the arguments in parentheses.

    ruleset <nameOfRuleSet> {

      .
      .
      .

      variables {
        Puzzle easyPuzzle = new Puzzle("Puzzle1"); // Name
        Puzzle hardPuzzle = new Puzzle("Puzzle2"); // Name

        Ring smallRing = new Ring("RingA", 2); // Name, diameter
        Ring mediumRing = new Ring("RingB", 4); // Name, diameter
        Ring largeRing = new Ring("RingC", 6); // Name, diameter
      }

      .
      .
      .
    }
      

In the example above, Puzzle (the hanoi.Puzzle class) must have a constructor that takes a string as a parameter. Ring (the hanoi.Ring class) must have a constructor that takes a string and a number as parameters. Variables as declared above will create an instance of the respective class.

Furthermore, depending on whether the Ring class has public members, or at least public getter and setter methods for internal members, rules such as the following might be allowed, where diameter is a publicly accessible member of class Ring.

    ruleset <nameOfRuleSet> {

      .
      .
      .

        void main() using Script() {
          r1: 
            if   (smallRing.diameter >= mediumRing.diameter)
            then result = someAction();
        }

      .
      .
      .
    }
      
Return to top
Able Rule Language master index.
Able RuleSet Editor master index.
Rules package table of contents.

Last modified: Fri Sep 21 14:23:28 Central Daylight Time 2001