rule
Class Rule

java.lang.Object
  |
  +--rule.Rule

public class Rule
extends java.lang.Object

The Rule class implements a rule with multiple antecedent clauses and a single consequent clause.


Field Summary
(package private)  Clause[] antecedents
           
(package private)  Clause consequent
           
(package private)  boolean fired
           
(package private)  java.lang.String name
           
(package private)  BooleanRuleBase rb
           
(package private)  java.lang.Boolean truth
           
 
Constructor Summary
Rule(BooleanRuleBase rb, java.lang.String name, Clause[] lhsClauses, Clause rhs)
          Creates a Rule for the given rule base, with the given name, one or more antecedents and consequent.
Rule(BooleanRuleBase rb, java.lang.String name, Clause lhs, Clause rhs)
          Creates a Rule for the given rule base, with the given name, antecedent and consequent.
 
Method Summary
(package private)  java.lang.Boolean backChain()
          Determines if a rule is true by recursively trying to prove its antecedent clauses are true or by determining that any of its antecedent clauses are false.
(package private)  java.lang.Boolean check()
          Tests the antecedent clauses in this rule in a forward chaining system.
static void checkRules(java.util.Vector clauseRefs)
          Retests all clauses and rules that reference a variable in a forward chaining system.
(package private)  void display(javax.swing.JTextArea textArea)
          Displays this rule in text format in the given text area.
(package private)  void fire()
          Fires a rule in a forward chaining system by performing the consequent clause, updating all clauses where any changed variables are referenced, and updating all the rules that contain those clauses.
(package private)  long numAntecedents()
          Retrieves the number of antecedent clauses in this rule.
(package private)  void reset()
          Resets the rule, allowing it to be fired again.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rb

BooleanRuleBase rb

name

java.lang.String name

antecedents

Clause[] antecedents

consequent

Clause consequent

truth

java.lang.Boolean truth

fired

boolean fired
Constructor Detail

Rule

public Rule(BooleanRuleBase rb,
            java.lang.String name,
            Clause lhs,
            Clause rhs)
Creates a Rule for the given rule base, with the given name, antecedent and consequent.
Parameters:
rb - the BooleanRuleBase associated with this rule
name - the String that contains the name of the rule
lhs - the antecedent clause of this rule
rhs - the consequent clause of this rule

Rule

public Rule(BooleanRuleBase rb,
            java.lang.String name,
            Clause[] lhsClauses,
            Clause rhs)
Creates a Rule for the given rule base, with the given name, one or more antecedents and consequent.
Parameters:
rb - the BooleanRuleBase associated with this rule
name - the String that contains the name of the rule
antecedents - the antecedent clauses of this rule
lhsClauses - the Clause[] object
rhs - the consequent clause of this rule
Method Detail

numAntecedents

long numAntecedents()
Retrieves the number of antecedent clauses in this rule.
Returns:
the number of antecedents

checkRules

public static void checkRules(java.util.Vector clauseRefs)
Retests all clauses and rules that reference a variable in a forward chaining system.
Parameters:
clauseRefs - the Vector that contains the clauses that reference a certain variable

check

java.lang.Boolean check()
Tests the antecedent clauses in this rule in a forward chaining system.
Returns:
true if all the antecedent clauses are true, false if any of the antecedent clauses are false, or null if the truth value of any of the antecedent clauses cannot be determined

fire

void fire()
Fires a rule in a forward chaining system by performing the consequent clause, updating all clauses where any changed variables are referenced, and updating all the rules that contain those clauses.

backChain

java.lang.Boolean backChain()
Determines if a rule is true by recursively trying to prove its antecedent clauses are true or by determining that any of its antecedent clauses are false.
Returns:
true if the antecedent clauses of this rule can be proven true, or false if any of the antecedents are false.

display

void display(javax.swing.JTextArea textArea)
Displays this rule in text format in the given text area.
Parameters:
textArea - the JTextArea where the rule is displayed

reset

void reset()
Resets the rule, allowing it to be fired again.