0% found this document useful (0 votes)
42 views1 page

Themal Theory,: Package Import Public Class Implements Private Private Public This Null

This theory discusses rules that have a head and optional body. A rule contains a simple sentence as its head and can have a goal as its body. The rule can replace variables using a substitution set and returns a copy of itself with replaced variables. It also overrides the toString method to return the head only if there is no body, otherwise it returns the head and body separated by ":-".

Uploaded by

Vipin Tiwari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views1 page

Themal Theory,: Package Import Public Class Implements Private Private Public This Null

This theory discusses rules that have a head and optional body. A rule contains a simple sentence as its head and can have a goal as its body. The rule can replace variables using a substitution set and returns a copy of itself with replaced variables. It also overrides the toString method to return the head only if there is no body, otherwise it returns the head and body separated by ":-".

Uploaded by

Vipin Tiwari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Themal Theory,

This theory will hold true with all the element data and look for search
package inference;
import java.util.ArrayList;
public class Rule implements PCExpression {
private SimpleSentence head;
private Goal body;
public Rule(SimpleSentence head) {
this(head, null);
}
public Rule(SimpleSentence head, Goal body) {
this.head = head;
this.body = body;
}
public SimpleSentence getHead() {
return head;
}
public Goal getBody() {
return body;
}
public PCExpression replaceVariables(SubstitutionSet s) throws
CloneNotSupportedException {
ArrayList<Goal> newOperands = new ArrayList<Goal>();
for (int i = 0; i < operandCount(); i++)
newOperands.add((Goal) getOperand(i).replaceVariables(s));
AbstractOperator copy = (AbstractOperator) this.clone();
copy.setOperands(newOperands);
return copy;
}
public String toString()
{
if (body == null)
return head.toString();
return head + " :- " + body;
}
}

You might also like