logic
Class Formula

java.lang.Object
  extended by logic.Formula
Direct Known Subclasses:
AtomicProposition, LogicalAnd, LogicalNot, LogicalOr, ProbabilisticNext, True

public abstract class Formula
extends java.lang.Object

Formula

This abstract class represents a basic formula. The binary operators AND and OR have to subformulas attaches, the unary operator NOT has one, while the True clause has none.

Copyright(c) 2005 Université Laval, LSFM research group.

Version:
1.0
Author:
Nicolas Richard

Field Summary
protected  Formula[] subFormula
           
 
Constructor Summary
Formula()
          Constructor with no subformula, for the True clause.
Formula(Formula subFormula)
          Constructor with one subformula, for logical operator NOT.
Formula(Formula subFormula1, Formula subFormula2)
          Constructor with two subformulas, for logical operators AND and NOT.
 
Method Summary
 int depth()
          Current formula's depth.
 boolean equals(java.lang.Object o)
          Determines if the provided object is a formula equal to this one
 Formula[] getSubFormula()
          Access the subformula(s) of the current fomula
abstract  java.lang.String getType()
          This function must be implemented by subclasses
 void setSubFormula(Formula[] subFormula)
          Sets the current subformulas of this logical operator
 java.lang.String toString()
          Converting this formula into a string
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

subFormula

protected Formula[] subFormula
Constructor Detail

Formula

public Formula()
Constructor with no subformula, for the True clause.


Formula

public Formula(Formula subFormula)
Constructor with one subformula, for logical operator NOT.

Parameters:
subFormula - the attached subformula

Formula

public Formula(Formula subFormula1,
               Formula subFormula2)
Constructor with two subformulas, for logical operators AND and NOT.

Parameters:
subFormula1 - the left subformula
subFormula2 - the right subformula
Method Detail

getSubFormula

public Formula[] getSubFormula()
Access the subformula(s) of the current fomula

Returns:
an array of subformulas

setSubFormula

public void setSubFormula(Formula[] subFormula)
Sets the current subformulas of this logical operator

Parameters:
subFormula - an array of subformulas to attach

depth

public int depth()
Current formula's depth. Computed from the number of subformulas under this one. The algorithm is equivalent to comptation of a tree's height.

Returns:
the number of subformulas under this formula.

equals

public boolean equals(java.lang.Object o)
Determines if the provided object is a formula equal to this one

Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare
Returns:
'True' if the object is a formula equivalent to this one, 'False' otherwise.

toString

public java.lang.String toString()
Converting this formula into a string

Overrides:
toString in class java.lang.Object
Returns:
a string representing the formula

getType

public abstract java.lang.String getType()
This function must be implemented by subclasses

Returns:
a string representing the formula