Raptor.LogicParser.Formula
Class Predicate

java.lang.Object
  extended by Raptor.LogicParser.Formula.Formula
      extended by Raptor.LogicParser.Formula.Atom
          extended by Raptor.LogicParser.Formula.Predicate
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Equals

public class Predicate
extends Atom

The Predicate formula.
Extends abstract class Atom.

See Also:
Serialized Form

Constructor Summary
Predicate(java.lang.String pName, java.util.Vector<Term> pParams)
          Constructs a Predicate Formula.
 
Method Summary
 boolean check2(Term pTermX, Term pTermY, Predicate pPred)
          A helper function used by th checkSub method.
Returns true if the passed formula f can be reached by substituting th eoccurrences of Term x by Term y in this Predicate.
 boolean checkFunc(Function pFunction1, Function pFunction2)
           
 boolean checkSub(Term pTermX, Term pTermY, Formula pFormula)
          Returns true if the passed formula f can be reached by substituting th eoccurrences of Term x by Term y in this Predicate.
If no Term is passed to be substituted(a = null) it is the case that we have to check if formula f can be reached by substituting any of its Terms.
 Predicate clone()
          Returns a clone(copy) of this Predicate.
 java.lang.String display()
          Returns an String representation of the Predicate formula.
 boolean equals(Predicate pPred)
          Returns true if the passed Predicate is equal to this Predicate.
Two predicates are equal if they have the same name and the same arity.
 int getArity()
          Returns the Arity of the Predicate.
 java.lang.String getName()
          Returns the name of the Predicate.
 java.util.Vector<Term> getParams()
          Returns the list of parameters of this Predicate.
 java.util.List<Term> getTerms()
          This method returns a list of all the Terms this formula contain.
 Formula regenerate()
          Returns a copy of the Formula which can be saved as part of the copy made for the undo function.
 void setParams(java.util.Vector<Term> pParams)
          Sets the parameter list of this Predicate to the passed list.
 void setVars(Var pVar)
          This method adds Var v to the list of variables this Predicate is bound to.
 Formula subAll(Term pTermX, Term pTermY)
          Returns the Formula that is derived after substituting ALL the occurrences of Term x with Term y in this Predicate.
 boolean subVar(Predicate pPred)
           
 
Methods inherited from class Raptor.LogicParser.Formula.Atom
addToSignature, clashes, clashes, clashes, equals, getPrecedence, isIn, s, setAtoms, ST, subAll, subBoolRes
 
Methods inherited from class Raptor.LogicParser.Formula.Formula
check, concatNoDup, getAtoms, getLeft, getRight, getTuples, getVars, higher, map, setLeft, setRight, setTuples, showTuples, sub, subBool
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Predicate

public Predicate(java.lang.String pName,
                 java.util.Vector<Term> pParams)
Constructs a Predicate Formula.

Parameters:
pName - String of the name of the Predicate.
pParams - Vector the parameter list of the Predicate.
Method Detail

getName

public java.lang.String getName()
Returns the name of the Predicate.

Overrides:
getName in class Atom

getArity

public int getArity()
Returns the Arity of the Predicate.

Overrides:
getArity in class Atom

getParams

public java.util.Vector<Term> getParams()
Returns the list of parameters of this Predicate.


setParams

public void setParams(java.util.Vector<Term> pParams)
Sets the parameter list of this Predicate to the passed list.

Parameters:
pParams - Vector represents the parameter list to replace this Predicates parameter list.

display

public java.lang.String display()
Returns an String representation of the Predicate formula.

Overrides:
display in class Atom

clone

public Predicate clone()
Returns a clone(copy) of this Predicate.

Overrides:
clone in class java.lang.Object

equals

public boolean equals(Predicate pPred)
Returns true if the passed Predicate is equal to this Predicate.
Two predicates are equal if they have the same name and the same arity.

Parameters:
pPred - Predicate represents the predicate it is to be compared against.

checkSub

public boolean checkSub(Term pTermX,
                        Term pTermY,
                        Formula pFormula)
Returns true if the passed formula f can be reached by substituting th eoccurrences of Term x by Term y in this Predicate.
If no Term is passed to be substituted(a = null) it is the case that we have to check if formula f can be reached by substituting any of its Terms. which then will bind the first occurrence of Term b with its corresponding Term.
It will then call the subVar method to check if the passed formula(f) is reachable.

Overrides:
checkSub in class Atom
Parameters:
pTermX - Term represents the Term to be substituted.
pTermY - Term represents the Term to substitute Term x.
pFormula - Formula represents the Formula to check if it can be reached after substitution.

check2

public boolean check2(Term pTermX,
                      Term pTermY,
                      Predicate pPred)
A helper function used by th checkSub method.
Returns true if the passed formula f can be reached by substituting th eoccurrences of Term x by Term y in this Predicate.

Parameters:
pTermX - Term represents the Term to be substituted.
pTermY - Term represents the Term to substitute Term x.
pPred - Formula represents the Formula to check if it can be reached after substitution.

subVar

public boolean subVar(Predicate pPred)

checkFunc

public boolean checkFunc(Function pFunction1,
                         Function pFunction2)

subAll

public Formula subAll(Term pTermX,
                      Term pTermY)
Returns the Formula that is derived after substituting ALL the occurrences of Term x with Term y in this Predicate.

Overrides:
subAll in class Atom
Parameters:
pTermX - Term represents the Term to be substituted.
pTermY - Term represents the Term to substitute Term x.

setVars

public void setVars(Var pVar)
This method adds Var v to the list of variables this Predicate is bound to.

Overrides:
setVars in class Atom
Parameters:
pVar - Var represents the Var to be added to the list of this Predicate's variables.

getTerms

public java.util.List<Term> getTerms()
This method returns a list of all the Terms this formula contain.

Overrides:
getTerms in class Atom

regenerate

public Formula regenerate()
Returns a copy of the Formula which can be saved as part of the copy made for the undo function.

Overrides:
regenerate in class Atom