Pandora.LogicParser.Formula
Class Predicate

java.lang.Object
  extended by Pandora.LogicParser.Formula.Formula
      extended by Pandora.LogicParser.Formula.Atom
          extended by Pandora.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 name, java.util.Vector<Term> params)
          Constructs a Predicate Formula.
 
Method Summary
 boolean check2(Term a, Term b, Predicate p)
          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 f1, Function f2)
           
 boolean checkSub(Term a, Term b, Formula f)
          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 p)
          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> params)
          Sets the parameter list of this Predicate to the passed list
 void setVars(Var v)
          This method adds Var v to the list of variables this Predicate is bound to.
 Formula subAll(Term a, Term b)
          Returns the Formula that is derived after substituting ALL the occurrences of Term x with Term y in this Predicate.
 boolean subVar(Predicate p)
           
 
Methods inherited from class Pandora.LogicParser.Formula.Atom
addToSignature, clashes, clashes, clashes, equals, getPrecedence, isIn, s, setAtoms
 
Methods inherited from class Pandora.LogicParser.Formula.Formula
check, concatNoDup, getAtoms, getLeft, getRight, getTuples, getVars, higher, isBracketed, map, setLeft, setRight, setTuples, showTuples, sub
 
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 name,
                 java.util.Vector<Term> params)
Constructs a Predicate Formula.

Parameters:
name - String of the name of the Predicate.
params - 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> params)
Sets the parameter list of this Predicate to the passed list

Parameters:
params - 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 p)
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:
p - Predicate represents the predicate it is to be compared against.

checkSub

public boolean checkSub(Term a,
                        Term b,
                        Formula f)
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:
x - Term represents the Term to be substituted.
y - Term represents the Term to substitute Term x.
f - Formula represents the Formula to check if it can be reached after substitution.

check2

public boolean check2(Term a,
                      Term b,
                      Predicate p)
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:
x - Term represents the Term to be substituted.
y - Term represents the Term to substitute Term x.
f - Formula represents the Formula to check if it can be reached after substitution.

subVar

public boolean subVar(Predicate p)

checkFunc

public boolean checkFunc(Function f1,
                         Function f2)

subAll

public Formula subAll(Term a,
                      Term b)
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:
x - Term represents the Term to be substituted.
y - Term represents the Term to substitute Term x.

setVars

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

Overrides:
setVars in class Atom
Parameters:
v - 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