Pandora.LogicParser.Formula
Class Atom

java.lang.Object
  extended by Pandora.LogicParser.Formula.Formula
      extended by Pandora.LogicParser.Formula.Atom
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
False, Predicate, Sk, True

public class Atom
extends Formula

The Atom formula.
Extends abstract class Formula.

See Also:
Serialized Form

Constructor Summary
Atom(java.lang.String id)
          Constructs an Atom Formula.
 
Method Summary
 void addToSignature(PanSignature signature)
          This method adds this Atom to the passed PanSignature's Predicate list IF it is not already in the signature
If this Atom is an instance of Predicate, its Parameters will be added to the signature as well.
 boolean checkSub(Term x, Term y, Formula f)
          Returns true if the passed formula f can be reached by substituting th eoccurrences of Term x by Term y in this Atom
 boolean clashes(Atom a)
          Returns true if this Atom clashes with the passed Atom
An Atom clashes with another Atom if they have the same name but different arities.
 java.lang.String clashes(PanSignature signature)
          Returns a String containing an Error character if this Atom clashes with the passed PanSignature, Otherwise it will return an Empty String ""
An Atom clashes with a signature if it clashes with any of its Predicates/Functions/Constants/Variables
 boolean clashes(Term t)
          Returns true if this Atom clashes with the passed Term
An Atom clashes with a Term if they have the same name.
 java.lang.String display()
          Returns the a String to display the Atom formula.
 boolean equals(Atom a)
          Returns true if this Atom is equal with the passes Atom
Two Atoms are equal if they have the same name and the same arity
 int getArity()
           
 java.lang.String getName()
          Returns the name of the atom.
 int getPrecedence()
          Returns an integer representing the precedence of this formula according to binding conventions
 java.util.List<Term> getTerms()
          This method returns a list of all the Terms this formula contain.
i.e.
 boolean isIn(PanSignature signature)
          Returns true if this Atom is in the passed PanSignature's Predicate list.
 Formula regenerate()
          Returns a copy of the Formula which can be saved as part of the copy made for the undo function.
 Formula s()
          Creates SVar to replace PVar in the formula where necessary.
 void setAtoms()
          Adds this atom to the list of atoms for the formula.
 void setVars(Var v)
          This method adds Var v to the list of variables this Atom is bound to.
 Formula subAll(Term x, Term y)
          Returns the Formula that is derived after substituting ALL the occurrences of Term x with Term y in this Atom.
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Atom

public Atom(java.lang.String id)
Constructs an Atom Formula.

Parameters:
id - String of the name fo the atom
Method Detail

getName

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


getArity

public int getArity()

display

public java.lang.String display()
Returns the a String to display the Atom formula.

Specified by:
display in class Formula

setAtoms

public void setAtoms()
Adds this atom to the list of atoms for the formula.
The list of atoms is found in Formula class.

Specified by:
setAtoms in class Formula

clashes

public boolean clashes(Atom a)
Returns true if this Atom clashes with the passed Atom
An Atom clashes with another Atom if they have the same name but different arities.

Parameters:
a - Atom represents the Atom to be checked if this Atom clashes with.

clashes

public boolean clashes(Term t)
Returns true if this Atom clashes with the passed Term
An Atom clashes with a Term if they have the same name.

Parameters:
t - Term represents the Term to be checked if this Atom clashes with.

clashes

public java.lang.String clashes(PanSignature signature)
Returns a String containing an Error character if this Atom clashes with the passed PanSignature, Otherwise it will return an Empty String ""
An Atom clashes with a signature if it clashes with any of its Predicates/Functions/Constants/Variables

Specified by:
clashes in class Formula
Parameters:
signature - PanSignature represents the PanSignature to be checked if this Atom clashes with.

equals

public boolean equals(Atom a)
Returns true if this Atom is equal with the passes Atom
Two Atoms are equal if they have the same name and the same arity

Parameters:
a - Atom represents the Atom to be checked if this Atom is equal with.

isIn

public boolean isIn(PanSignature signature)
Returns true if this Atom is in the passed PanSignature's Predicate list.

Parameters:
signature - PanSignature represents the signature to search within.

checkSub

public boolean checkSub(Term x,
                        Term y,
                        Formula f)
Returns true if the passed formula f can be reached by substituting th eoccurrences of Term x by Term y in this Atom

Specified by:
checkSub in class Formula
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.

subAll

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

Specified by:
subAll in class Formula
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 Atom is bound to.

Specified by:
setVars in class Formula
Parameters:
v - Var represents the Var to be added to the list of this Atom's variables.

addToSignature

public void addToSignature(PanSignature signature)
This method adds this Atom to the passed PanSignature's Predicate list IF it is not already in the signature
If this Atom is an instance of Predicate, its Parameters will be added to the signature as well.

Specified by:
addToSignature in class Formula
Parameters:
signature - PanSignature represents the signature to add this Atom to.

getTerms

public java.util.List<Term> getTerms()
This method returns a list of all the Terms this formula contain.
i.e. it returns an empty list as an Atom does not contain any Terms.

Specified by:
getTerms in class Formula

s

public Formula s()
Creates SVar to replace PVar in the formula where necessary. Used in Raptor.

Specified by:
s in class Formula

regenerate

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

Specified by:
regenerate in class Formula

getPrecedence

public int getPrecedence()
Returns an integer representing the precedence of this formula according to binding conventions

Specified by:
getPrecedence in class Formula