de.uni_tuebingen.sfb.lichtenstein.formulas
Class FirstOrderEquality

java.lang.Object
  extended by de.uni_tuebingen.sfb.lichtenstein.formulas.FormulaImpl
      extended by de.uni_tuebingen.sfb.lichtenstein.formulas.AtomicFormula
          extended by de.uni_tuebingen.sfb.lichtenstein.formulas.FirstOrderEquality
All Implemented Interfaces:
Formula, Visitable, Serializable

public class FirstOrderEquality
extends AtomicFormula

A class representing the atomic formula that says two first order variables are equal.

Author:
Hendrik Maryns
See Also:
Serialized Form

Constructor Summary
FirstOrderEquality(FirstOrderVariable first, FirstOrderVariable second)
          Initialize a new first order equality, involving two first order variables.
 
Method Summary
 void accept(FormulaVisitor visitor)
          Accept a formula visitor.
 boolean containsVariable(Variable var)
          Returns whether this formula contains the given variable.
 boolean equals(Object other)
          Indicates whether some other object is "equal to" this one.
 int getFirstIndexOf(Variable var)
          Get the first index at which the given variable occurs.
 FirstOrderVariable getFirstVariable()
          Returns the first variable.
 int getNbVariables()
          Returns the number of variables in this formula.
 Set<Predicate> getPredicates()
          Return all predicates in this formula.
 FirstOrderVariable getSecondVariable()
          Returns the second variable.
 Variable getVariableAt(int index)
          Get the indexth variable (free or bound).
 int hashCode()
          Returns a hash code value for the object.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class de.uni_tuebingen.sfb.lichtenstein.formulas.AtomicFormula
getNbBoundVariables, getNbFreeVariables, getNormalForm, isFreeVariable
 
Methods inherited from class de.uni_tuebingen.sfb.lichtenstein.formulas.FormulaImpl
and, exists, exists, forAll, forAll, getFreeVariables, getVariables, iff, implies, isClosed, not, or
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FirstOrderEquality

public FirstOrderEquality(FirstOrderVariable first,
                          FirstOrderVariable second)
Initialize a new first order equality, involving two first order variables.

Parameters:
first - The first variable.
second - The second variable.
Precondition:
Both variables have to be effective.
| first != null && second != null
Postcondition:
The first variable is given to the first given variable.
| new.getFirstVariable() == first
Postcondition:
The second variable is given to the second given variable.
| new.getSecondVariable() == second
Method Detail

getFirstVariable

public FirstOrderVariable getFirstVariable()
Returns the first variable.

Returns:
This is the first first order variable.
| result == getVariableAt(0)

getSecondVariable

public FirstOrderVariable getSecondVariable()
Returns the second variable.

Returns:
This is the second first order variable.
| result == getVariableAt(1)

getNbVariables

public int getNbVariables()
Returns the number of variables in this formula.

Returns:
Always 2.
| result == 2

getFirstIndexOf

public int getFirstIndexOf(Variable var)
Get the first index at which the given variable occurs.

Parameters:
var - The variable of which the index is wanted.

getVariableAt

public Variable getVariableAt(int index)
                       throws IndexOutOfBoundsException
Get the indexth variable (free or bound).

Parameters:
index - The index of the wanted variable

containsVariable

public boolean containsVariable(Variable var)
Returns whether this formula contains the given variable.

Parameters:
var - The variable to check.

getPredicates

public Set<Predicate> getPredicates()
Return all predicates in this formula.

Returns:
A first order equality cannot contain predicates.
| result.isEmpty()

equals

public boolean equals(Object other)
Indicates whether some other object is "equal to" this one.

Overrides:
equals in class FormulaImpl
Returns:
Two equalities are equal if they compare the same variables.
| let otherEquals = (FirstOrderEquality) other in | if ( otherEquals.getFirstVariable() != getFirstVariable() ) | then result == false | else if ( otherEquals.getSecondVariable() != getSecondVariable() ) | then result == false | else result == true

hashCode

public int hashCode()
Returns a hash code value for the object.

Specified by:
hashCode in class FormulaImpl
Returns:
The hash code is based on the hash codes of the variables and of the characteristic symbol.
| result == getFirstVariable().hashCode() + "=".hashCode() + getSecondVariable().hashCode()

toString

public String toString()
Returns a string representation of the object.

Specified by:
toString in class FormulaImpl
Returns:
The string representations of the variables are given, with the equal sign: = in between them.
| result == getFirstVariable().toString() + "=" + getSecondVariable().toString()

accept

public void accept(FormulaVisitor visitor)
            throws de.uni_tuebingen.sfb.lichtenstein.exceptions.VisitorException
Accept a formula visitor. The iteration is done by the visitor, not by the composed formulas.

Specified by:
accept in interface Visitable
Overrides:
accept in class FormulaImpl
Parameters:
visitor - The visitor that is to be accepted to do its work.
Throws:
VisitorException
A visitor can throw an exception.