com.agentfactory.logic.lang
Class FOS

java.lang.Object
  extended by com.agentfactory.logic.lang.FOS
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
BeliefSentence

public class FOS
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

This class represents First Order Structures (FOS)

See Also:
Serialized Form

Constructor Summary
FOS()
          creates a new empty FOS
FOS(java.lang.String inString)
          A nasty but necessarly constructor TODO - RR - Solve bug which allows for FOSs to be created badly out of invalid strings.
 
Method Summary
 void addArgument(FOS f)
          adds FOS to arguments
 FOS apply(SubstitutionSet sub)
          applies a SubstitutionSet to this
 FOS argAt(int i)
          gets argument at specified position
 void atArgPut(int i, FOS f)
          puts specified argument at specified position
 java.lang.Object clone()
          Clone the current object
 FOS copy()
          get copy of this
 boolean equals(java.lang.Object object)
           
 java.util.ArrayList getArguments()
          gets arguments
 java.util.ArrayList getConstants()
           
 java.lang.String getFunctor()
          get functor name
 java.util.ArrayList getVariables()
           
 boolean isCompatibleFunction(FOS f)
          formulae are compatible if they have the same functor and same number of arguments
 boolean isComposite()
          checks to see if this is Composite (has arguments)
 boolean isDifferentTo(FOS f)
          checks to see if specified formula is composite while this is a constant or vice versa
 boolean isDistinctConstant(FOS f)
          checks to see if specified formula is distinct to this
 boolean isDistinctFunction(FOS f)
          checks to see if specified formula has a distinct function to this
 boolean isFalse()
          checks to see if this is a false ("false")
 boolean isNot()
           
 boolean isNotFunctional(FOS f)
          formulae are not functional if one is a variable contained by the other
 boolean isRule()
          checks to see if this is a rule
 boolean isSameAs(FOS f)
          compares this with another FOS to see if they are exactly the same
 boolean isTrue()
          checks to see if this is a true ("true")
 boolean isVariable()
          checks to see if this is a variable (starts with a '?')
 boolean matches(FOS f)
          Sees if another FOS matches this.
 int numArguments()
          gets the number of arguments
protected  FOS privateReplaceConstants()
          Need this function below for recursion - the first time the replaceConstants() method is invoked, we do not want to make any modifications to the actual FOS - the top level must always remain the same.
 void putArguments(java.util.ArrayList arg)
          replace arguments with other arguments
 void putArguments(java.util.Vector arg)
          replace arguments with other arguments
 void putFunctor(java.lang.String s)
          set functor name
 FOS realCopy()
          Make a real copy of the FOS
 FOS replaceConstants()
           
 void replaceVariableWith(FOS f, FOS f1)
          replaces formula f with formula f1 in this
 java.lang.String toString()
          gets a String representation of this
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FOS

public FOS()
creates a new empty FOS


FOS

public FOS(java.lang.String inString)
A nasty but necessarly constructor TODO - RR - Solve bug which allows for FOSs to be created badly out of invalid strings.

Method Detail

isNot

public boolean isNot()

getArguments

public java.util.ArrayList getArguments()
gets arguments

Returns:
FOS arguments

numArguments

public int numArguments()
gets the number of arguments

Returns:
number of arguments

addArgument

public void addArgument(FOS f)
adds FOS to arguments

Parameters:
f - FOS to be added

putArguments

public void putArguments(java.util.ArrayList arg)
replace arguments with other arguments

Parameters:
arg - different arguments for FOS

putArguments

public void putArguments(java.util.Vector arg)
replace arguments with other arguments

Parameters:
arg - different arguments for FOS

argAt

public FOS argAt(int i)
gets argument at specified position

Parameters:
i - position of argument
Returns:
argument at specified position

atArgPut

public void atArgPut(int i,
                     FOS f)
puts specified argument at specified position

Parameters:
i - position of argument
f - different argument

getFunctor

public java.lang.String getFunctor()
get functor name

Returns:
name of functor

putFunctor

public void putFunctor(java.lang.String s)
set functor name

Parameters:
s - name of functor

copy

public FOS copy()
get copy of this

Returns:
copy of this

isRule

public boolean isRule()
checks to see if this is a rule

Returns:
false

isComposite

public boolean isComposite()
checks to see if this is Composite (has arguments)

Returns:
true if composite

isVariable

public boolean isVariable()
checks to see if this is a variable (starts with a '?')

Returns:
true if variable

isFalse

public boolean isFalse()
checks to see if this is a false ("false")

Returns:
true if false

isTrue

public boolean isTrue()
checks to see if this is a true ("true")

Returns:
true if true

isSameAs

public boolean isSameAs(FOS f)
compares this with another FOS to see if they are exactly the same

Parameters:
f - the formula to be compared
Returns:
true if exactly the same

matches

public boolean matches(FOS f)
Sees if another FOS matches this. They match if they have the same functor and same number of arguments.

Parameters:
f - formula to be matched
Returns:
true if they match

isDistinctConstant

public boolean isDistinctConstant(FOS f)
checks to see if specified formula is distinct to this

Parameters:
f - formula to check
Returns:
true if distinct constants

isDistinctFunction

public boolean isDistinctFunction(FOS f)
checks to see if specified formula has a distinct function to this

Parameters:
f - formula to check
Returns:
true if distinct functions

isDifferentTo

public boolean isDifferentTo(FOS f)
checks to see if specified formula is composite while this is a constant or vice versa

Parameters:
f - formula to check
Returns:
true if different fomulae

isCompatibleFunction

public boolean isCompatibleFunction(FOS f)
formulae are compatible if they have the same functor and same number of arguments

Parameters:
f - formula to check
Returns:
true if compatible functions

isNotFunctional

public boolean isNotFunctional(FOS f)
formulae are not functional if one is a variable contained by the other

Parameters:
f - formula to check
Returns:
true if not functional

replaceVariableWith

public void replaceVariableWith(FOS f,
                                FOS f1)
replaces formula f with formula f1 in this

Parameters:
f - a formula within this
f1 - replacement formula

apply

public FOS apply(SubstitutionSet sub)
applies a SubstitutionSet to this

Parameters:
sub - the SubstitutionSet to be used
Returns:
a formula that has had the SubstitutionSet applied to it

toString

public java.lang.String toString()
gets a String representation of this

Overrides:
toString in class java.lang.Object
Returns:
this as a String

realCopy

public FOS realCopy()
Make a real copy of the FOS

Returns:
the copy

clone

public java.lang.Object clone()
Clone the current object

Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object object)
Overrides:
equals in class java.lang.Object

getVariables

public java.util.ArrayList getVariables()

getConstants

public java.util.ArrayList getConstants()

replaceConstants

public FOS replaceConstants()

privateReplaceConstants

protected FOS privateReplaceConstants()
Need this function below for recursion - the first time the replaceConstants() method is invoked, we do not want to make any modifications to the actual FOS - the top level must always remain the same. Instead, we replace the constants on all the arguments of the top level FOS...