LBJ2.infer
Class PropositionalDisjunction

java.lang.Object
  extended by LBJ2.infer.Constraint
      extended by LBJ2.infer.PropositionalConstraint
          extended by LBJ2.infer.PropositionalNAryConstraint
              extended by LBJ2.infer.PropositionalDisjunction
All Implemented Interfaces:
java.lang.Cloneable

public class PropositionalDisjunction
extends PropositionalNAryConstraint

Represents the disjunction of two propositional constraints.


Field Summary
 
Fields inherited from class LBJ2.infer.PropositionalNAryConstraint
children
 
Constructor Summary
private PropositionalDisjunction()
          Default constructor.
  PropositionalDisjunction(PropositionalConstraint c1, PropositionalConstraint c2)
          If either of the arguments is itself a PropositionalDisjunction, its contents are flattened into this PropositionalDisjunction.
 
Method Summary
 void add(PropositionalConstraint c)
          If the given constraint has the same type as this constraint, its terms are merged into this constraint; otherwise, it is added as a new term.
 PropositionalConstraint CNF()
          Produces a new, logically simplified version of this constraint in conjunctive normal form (CNF).
 boolean containsAll(PropositionalDisjunction d)
          Determines whether this disjunction contains all of the terms that the given disjunction contains.
 PropositionalConstraint distribute(PropositionalConjunction c)
          Distributes the given conjunction over this disjunction.
 PropositionalConstraint DNF()
          Produces a new, logically simplified version of this constraint in disjunctive normal form (DNF).
 boolean equals(java.lang.Object o)
          Two PropositionalDisjunctions are equivalent when they are topologically equivalent, respecting the associativity and commutivity of disjunction.
 boolean evaluate()
          Determines whether the constraint is satisfied.
 PropositionalConstraint factor()
          Factoring a disjunction is the opposite of distributing a conjunction over a disjunction.
 int hashCode()
          The hash code of a PropositionalDisjunction is the sum of the hash codes of its children.
static boolean increment(PropositionalConstraint[][] c, int[] I)
          Utility method for iterating through all combinations of constraint children.
 PropositionalConstraint[] intersect(PropositionalConstraint c)
          The intersection of two disjunctions is the set of all terms that are common to both disjunctions; the intersection of a disjunction and some other constraint c is c if c is contained in the disjunction and the empty set otherwise.
 boolean moreGeneralThan(PropositionalConstraint c)
          Compares topology to determine if this constraint is more general than the given constraint; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalAtLeast c)
          Compares topology to determine if this constraint is more specific than the given at-least; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalConjunction c)
          Compares topology to determine if this constraint is more specific than the given conjunction; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalConstant c)
          Compares topology to determine if this constraint is more specific than the given constant; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalDisjunction c)
          Compares topology to determine if this constraint is more specific than the given disjunction; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalDoubleImplication c)
          Compares topology to determine if this constraint is more specific than the given double implication; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalImplication c)
          Compares topology to determine if this constraint is more specific than the given implication; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalNegation c)
          Compares topology to determine if this constraint is more specific than the given negation; note: this method is not required to be correct when it answers false.
 boolean moreSpecificThan(PropositionalVariable c)
          Compares topology to determine if this constraint is more specific than the given variable; note: this method is not required to be correct when it answers false.
 PropositionalConstraint negate()
          Uses DeMorgan's law to compute the negation of this constraint by distributing that negation to each child.
 void runVisit(Inference infer)
          Calls the appropriate visit(·) method of the given Inference for this Constraint, as per the visitor pattern.
 PropositionalConstraint simplify()
          Produces a new, logically simplified version of this constraint, preserving variable consolidation.
 PropositionalConstraint subtract(PropositionalConstraint[] terms)
          Subtraction from a disjunction simply removes all of the specified terms from it; this method returns a new constraint representing the subtraction.
 void write(java.lang.StringBuffer buffer)
          Creates a string respresentation of this constraint using the string representations of the objects involved.
 
Methods inherited from class LBJ2.infer.PropositionalNAryConstraint
clone, consolidateVariables, contains, getChildren, size
 
Methods inherited from class LBJ2.infer.PropositionalConstraint
toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropositionalDisjunction

private PropositionalDisjunction()
Default constructor.


PropositionalDisjunction

public PropositionalDisjunction(PropositionalConstraint c1,
                                PropositionalConstraint c2)
If either of the arguments is itself a PropositionalDisjunction, its contents are flattened into this PropositionalDisjunction.

Parameters:
c1 - One constraint to disjunct.
c2 - Another constraint to disjunct.
Method Detail

evaluate

public boolean evaluate()
Determines whether the constraint is satisfied.

Specified by:
evaluate in class Constraint

simplify

public PropositionalConstraint simplify()
Produces a new, logically simplified version of this constraint, preserving variable consolidation.

Specified by:
simplify in class PropositionalConstraint
Returns:
A logically simplified version of this constraint.
See Also:
Constraint.consolidateVariables(java.util.AbstractMap)

negate

public PropositionalConstraint negate()
Uses DeMorgan's law to compute the negation of this constraint by distributing that negation to each child.

Specified by:
negate in class PropositionalConstraint
Returns:
A simplified constraint representing the negation of this constraint.

CNF

public PropositionalConstraint CNF()
Produces a new, logically simplified version of this constraint in conjunctive normal form (CNF).

Specified by:
CNF in class PropositionalConstraint
Returns:
The conjunctive normal form of this constraint.

increment

public static boolean increment(PropositionalConstraint[][] c,
                                int[] I)
Utility method for iterating through all combinations of constraint children.

Parameters:
c - Each element of this array is an array of children, exactly one child of which appears in each combination.
I - The indexes of the children in the current combination.
Returns:
true iff I contains valid indexes for a new combination; false iff if there are no more combinations.

DNF

public PropositionalConstraint DNF()
Produces a new, logically simplified version of this constraint in disjunctive normal form (DNF).

Specified by:
DNF in class PropositionalConstraint
Returns:
The disjunctive normal form of this constraint.

moreGeneralThan

public boolean moreGeneralThan(PropositionalConstraint c)
Compares topology to determine if this constraint is more general than the given constraint; note: this method is not required to be correct when it answers false.

Specified by:
moreGeneralThan in class PropositionalConstraint
Parameters:
c - The given constraint.
Returns:
true if a topological analysis determined that this constraint is more general than the given constraint.

moreSpecificThan

public boolean moreSpecificThan(PropositionalImplication c)
Compares topology to determine if this constraint is more specific than the given implication; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given implication.
Returns:
true if a topological analysis determined that this constraint is more specific than the given implication.

moreSpecificThan

public boolean moreSpecificThan(PropositionalDoubleImplication c)
Compares topology to determine if this constraint is more specific than the given double implication; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given double implication.
Returns:
true if a topological analysis determined that this constraint is more specific than the given double implication.

moreSpecificThan

public boolean moreSpecificThan(PropositionalConjunction c)
Compares topology to determine if this constraint is more specific than the given conjunction; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given conjunction.
Returns:
true if a topological analysis determined that this constraint is more specific than the given conjunction.

moreSpecificThan

public boolean moreSpecificThan(PropositionalDisjunction c)
Compares topology to determine if this constraint is more specific than the given disjunction; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given disjunction.
Returns:
true if a topological analysis determined that this constraint is more specific than the given disjunction.

moreSpecificThan

public boolean moreSpecificThan(PropositionalAtLeast c)
Compares topology to determine if this constraint is more specific than the given at-least; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given at-least.
Returns:
true if a topological analysis determined that this constraint is more specific than the given disjunction.

moreSpecificThan

public boolean moreSpecificThan(PropositionalNegation c)
Compares topology to determine if this constraint is more specific than the given negation; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given negation.
Returns:
true if a topological analysis determined that this constraint is more specific than the given negation.

moreSpecificThan

public boolean moreSpecificThan(PropositionalVariable c)
Compares topology to determine if this constraint is more specific than the given variable; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given variable.
Returns:
true if a topological analysis determined that this constraint is more specific than the given variable.

moreSpecificThan

public boolean moreSpecificThan(PropositionalConstant c)
Compares topology to determine if this constraint is more specific than the given constant; note: this method is not required to be correct when it answers false.

Specified by:
moreSpecificThan in class PropositionalConstraint
Parameters:
c - The given constant.
Returns:
true if a topological analysis determined that this constraint is more specific than the given constant.

add

public void add(PropositionalConstraint c)
If the given constraint has the same type as this constraint, its terms are merged into this constraint; otherwise, it is added as a new term.

Parameters:
c - The constraint to add.

factor

public PropositionalConstraint factor()
Factoring a disjunction is the opposite of distributing a conjunction over a disjunction.

Returns:
A constraint that represents a factoring of this disjunction.

intersect

public PropositionalConstraint[] intersect(PropositionalConstraint c)
The intersection of two disjunctions is the set of all terms that are common to both disjunctions; the intersection of a disjunction and some other constraint c is c if c is contained in the disjunction and the empty set otherwise.

Parameters:
c - The constraint to intersect with.
Returns:
The set of common terms in array form or null if there are none.

subtract

public PropositionalConstraint subtract(PropositionalConstraint[] terms)
Subtraction from a disjunction simply removes all of the specified terms from it; this method returns a new constraint representing the subtraction.

Parameters:
terms - The terms to remove.
Returns:
A new representation of this n-ary constraint with the specified terms removed.

distribute

public PropositionalConstraint distribute(PropositionalConjunction c)
Distributes the given conjunction over this disjunction.

Returns:
A simplified constraint representing the distribution of the given conjunction over this disjunction.

containsAll

public boolean containsAll(PropositionalDisjunction d)
Determines whether this disjunction contains all of the terms that the given disjunction contains.

Parameters:
d - The given disjunction.
Returns:
true iff this disjunction contains all of the terms that the given disjunction contains.

hashCode

public int hashCode()
The hash code of a PropositionalDisjunction is the sum of the hash codes of its children.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this PropositionalDisjunction.

equals

public boolean equals(java.lang.Object o)
Two PropositionalDisjunctions are equivalent when they are topologically equivalent, respecting the associativity and commutivity of disjunction.

Overrides:
equals in class java.lang.Object
Returns:
true iff the argument is an equivalent PropositionalDisjunction.

runVisit

public void runVisit(Inference infer)
Calls the appropriate visit(·) method of the given Inference for this Constraint, as per the visitor pattern.

Specified by:
runVisit in class Constraint
Parameters:
infer - The inference visiting this constraint.

write

public void write(java.lang.StringBuffer buffer)
Creates a string respresentation of this constraint using the string representations of the objects involved.

Specified by:
write in class PropositionalConstraint
Parameters:
buffer - The output of this method will be appended to this buffer.