package LBJ2.infer;
/**
* All classes for representing propositional constraints are derived from
* this base class. A propositional constraint is:
*
* <ul>
* <li> The constant <code>true</code> or the constant <code>false</code>.
* <li> A variable name, which is an assertion of that variable's truth.
* <li> The negation of a propositional constraint.
* <li> The conjunction of two propositional constraints.
* <li> The disjunction of two propositional constraints.
* <li> An implication between two propositional constraints.
* <li> A double implication between two propositional constraints.
* </ul>
**/
public abstract class PropositionalConstraint extends Constraint
implements Cloneable
{
/**
* Produces a new, logically simplified version of this constraint,
* preserving variable consolidation.
*
* @see Constraint#consolidateVariables(java.util.AbstractMap)
* @return A logically simplified version of this constraint.
**/
abstract public PropositionalConstraint simplify();
/**
* Produces a new propositional constraint equivalent to this constraint
* and that contains no negated constraints other than variables.
*
* @return A constraint representing the negation of this constraint.
**/
abstract public PropositionalConstraint negate();
/**
* Produces a new, logically simplified version of this constraint in
* conjunctive normal form (CNF).
*
* @return The conjunctive normal form of this constraint.
**/
abstract public PropositionalConstraint CNF();
/**
* Produces a new, logically simplified version of this constraint in
* disjunctive normal form (DNF).
*
* @return The disjunctive normal form of this constraint.
**/
abstract public PropositionalConstraint DNF();
/**
* Compares topology to determine if this constraint is more general than
* the given constraint; <i>note: this method is not required to be correct
* when it answers <code>false</code></i>.
*
* @param c The given constraint.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more general than the given constraint.
**/
abstract public boolean moreGeneralThan(PropositionalConstraint c);
/**
* Compares topology to determine if this constraint is more specific than
* the given implication; <i>note: this method is not required to be
* correct when it answers <code>false</code></i>.
*
* @param c The given implication.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more specific than the given implication.
**/
abstract public boolean moreSpecificThan(PropositionalImplication c);
/**
* Compares topology to determine if this constraint is more specific than
* the given double implication; <i>note: this method is not required to be
* correct when it answers <code>false</code></i>.
*
* @param c The given double implication.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more specific than the given double implication.
**/
abstract public boolean moreSpecificThan(PropositionalDoubleImplication c);
/**
* Compares topology to determine if this constraint is more specific than
* the given conjunction; <i>note: this method is not required to be
* correct when it answers <code>false</code></i>.
*
* @param c The given conjunction.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more specific than the given conjunction.
**/
abstract public boolean moreSpecificThan(PropositionalConjunction c);
/**
* Compares topology to determine if this constraint is more specific than
* the given disjunction; <i>note: this method is not required to be
* correct when it answers <code>false</code></i>.
*
* @param c The given disjunction.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more specific than the given disjunction.
**/
abstract public boolean moreSpecificThan(PropositionalDisjunction c);
/**
* Compares topology to determine if this constraint is more specific than
* the given at-least; <i>note: this method is not required to be correct
* when it answers <code>false</code></i>.
*
* @param c The given at-least.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more specific than the given disjunction.
**/
abstract public boolean moreSpecificThan(PropositionalAtLeast c);
/**
* Compares topology to determine if this constraint is more specific than
* the given negation; <i>note: this method is not required to be correct
* when it answers <code>false</code></i>.
*
* @param c The given negation.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more specific than the given negation.
**/
abstract public boolean moreSpecificThan(PropositionalNegation c);
/**
* Compares topology to determine if this constraint is more specific than
* the given variable; <i>note: this method is not required to be correct
* when it answers <code>false</code></i>.
*
* @param c The given variable.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more specific than the given variable.
**/
abstract public boolean moreSpecificThan(PropositionalVariable c);
/**
* Compares topology to determine if this constraint is more specific than
* the given constant; <i>note: this method is not required to be correct
* when it answers <code>false</code></i>.
*
* @param c The given constant.
* @return <code>true</code> if a topological analysis determined that this
* constraint is more specific than the given constant.
**/
abstract public boolean moreSpecificThan(PropositionalConstant c);
/**
* Creates a string respresentation of this constraint using the string
* representations of the objects involved. This method employs the
* <code>write(StringBuffer)</code> method to compute its output.
**/
public String toString() {
StringBuffer result = new StringBuffer();
write(result);
return result.toString();
}
/**
* Creates a string respresentation of this constraint using the string
* representations of the objects involved.
*
* @param buffer The output of this method will be appended to this buffer.
**/
abstract public void write(StringBuffer buffer);
/**
* This method returns a shallow clone.
*
* @return A shallow clone.
**/
public Object clone() {
Object clone = null;
try { clone = super.clone(); }
catch (Exception e) {
System.err.println("Error cloning " + getClass().getName() + ":");
e.printStackTrace();
System.exit(1);
}
return clone;
}
}