public class Rule extends Object implements PCExpression, Cloneable
| Modifier and Type | Field and Description |
|---|---|
private Clause |
body |
private SimpleSentence |
head |
| Constructor and Description |
|---|
Rule(SimpleSentence head)
Constructor of the class in case of a simple fact.
|
Rule(SimpleSentence head,
Clause body)
Constructor of the class in case of a backtracking rule.
|
| Modifier and Type | Method and Description |
|---|---|
Clause |
getBody()
Gets the body of the rule.
|
SimpleSentence |
getHead()
Gets the head of the rule.
|
Rule |
replaceVariables(SubstitutionSet s)
Replaces all the variables in the rule according to the specified
bindings.
|
Rule |
standardizeVariablesApart(Hashtable<Variable,Variable> newVars)
Standardizes the variables in order to be sure that there won't be any
variable clashes.
|
String |
toString()
Returns the rule in the form of:
"head :- body".
|
private SimpleSentence head
private Clause body
public Rule(SimpleSentence head)
head - the fact that is declared true.public Rule(SimpleSentence head, Clause body)
head - the element that is defined by the rule.body - the definition of the element.public SimpleSentence getHead()
SimpleSentence object which is the head of the rule.public Clause getBody()
null for a fact or
a clause for a complete rule.Clause object representing the body.public Rule replaceVariables(SubstitutionSet s)
This method is recursive over all PCExpression implementations.
replaceVariables in interface PCExpressions - the SubstitutionSet that contains the bindings of the
variables so far.Rule object representing the bound rule.PCExpression.replaceVariables(model.SubstitutionSet)public Rule standardizeVariablesApart(Hashtable<Variable,Variable> newVars)
This method is recursive over all PCExpression implementations.
standardizeVariablesApart in interface PCExpressionnewVars - is a parameter to save over the recursion all the variable
replacements done so far.Rule object representing the standardized rule.PCExpression.standardizeVariablesApart(java.util.Hashtable)public String toString()
toString in class ObjectObject.toString()