public class PropositionalDisjunction extends PropositionalNAryConstraint
children
Constructor and Description |
---|
PropositionalDisjunction(PropositionalConstraint c1,
PropositionalConstraint c2)
If either of the arguments is itself a
PropositionalDisjunction , its contents
are flattened into this PropositionalDisjunction . |
Modifier and Type | Method and Description |
---|---|
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(Object o)
Two
PropositionalDisjunction s 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(StringBuffer buffer)
Creates a string respresentation of this constraint using the string representations of the
objects involved.
|
clone, consolidateVariables, contains, getChildren, size
toString
public PropositionalDisjunction(PropositionalConstraint c1, PropositionalConstraint c2)
PropositionalDisjunction
, its contents
are flattened into this PropositionalDisjunction
.c1
- One constraint to disjunct.c2
- Another constraint to disjunct.public boolean evaluate()
evaluate
in class Constraint
public PropositionalConstraint simplify()
simplify
in class PropositionalConstraint
Constraint.consolidateVariables(java.util.AbstractMap)
public PropositionalConstraint negate()
negate
in class PropositionalConstraint
public PropositionalConstraint CNF()
CNF
in class PropositionalConstraint
public static boolean increment(PropositionalConstraint[][] c, int[] I)
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.true
iff I
contains valid indexes for a new combination;
false
iff if there are no more combinations.public PropositionalConstraint DNF()
DNF
in class PropositionalConstraint
public boolean moreGeneralThan(PropositionalConstraint c)
false
.moreGeneralThan
in class PropositionalConstraint
c
- The given constraint.true
if a topological analysis determined that this constraint is more
general than the given constraint.public boolean moreSpecificThan(PropositionalImplication c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given implication.true
if a topological analysis determined that this constraint is more
specific than the given implication.public boolean moreSpecificThan(PropositionalDoubleImplication c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given double implication.true
if a topological analysis determined that this constraint is more
specific than the given double implication.public boolean moreSpecificThan(PropositionalConjunction c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given conjunction.true
if a topological analysis determined that this constraint is more
specific than the given conjunction.public boolean moreSpecificThan(PropositionalDisjunction c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given disjunction.true
if a topological analysis determined that this constraint is more
specific than the given disjunction.public boolean moreSpecificThan(PropositionalAtLeast c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given at-least.true
if a topological analysis determined that this constraint is more
specific than the given disjunction.public boolean moreSpecificThan(PropositionalNegation c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given negation.true
if a topological analysis determined that this constraint is more
specific than the given negation.public boolean moreSpecificThan(PropositionalVariable c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given variable.true
if a topological analysis determined that this constraint is more
specific than the given variable.public boolean moreSpecificThan(PropositionalConstant c)
false
.moreSpecificThan
in class PropositionalConstraint
c
- The given constant.true
if a topological analysis determined that this constraint is more
specific than the given constant.public void add(PropositionalConstraint c)
c
- The constraint to add.public PropositionalConstraint factor()
public PropositionalConstraint[] intersect(PropositionalConstraint c)
c
- The constraint to intersect with.null
if there are none.public PropositionalConstraint subtract(PropositionalConstraint[] terms)
terms
- The terms to remove.public PropositionalConstraint distribute(PropositionalConjunction c)
public boolean containsAll(PropositionalDisjunction d)
d
- The given disjunction.true
iff this disjunction contains all of the terms that the given
disjunction contains.public int hashCode()
PropositionalDisjunction
is the sum of the hash codes of its
children.public boolean equals(Object o)
PropositionalDisjunction
s are equivalent when they are topologically
equivalent, respecting the associativity and commutivity of disjunction.public void runVisit(Inference infer)
visit(·)
method of the given Inference
for this Constraint
, as per the visitor pattern.runVisit
in class Constraint
infer
- The inference visiting this constraint.public void write(StringBuffer buffer)
write
in class PropositionalConstraint
buffer
- The output of this method will be appended to this buffer.Copyright © 2016. All rights reserved.