blog
Class NegFormula

java.lang.Object
  extended by blog.ArgSpec
      extended by blog.Formula
          extended by blog.NegFormula

public class NegFormula
extends Formula

Represents a logical negation of an expression of type Formula.

See Also:
Formula

Field Summary
 
Fields inherited from class blog.Formula
ALL_OBJECTS, NOT_EXPLICIT
 
Fields inherited from class blog.ArgSpec
location
 
Constructor Summary
NegFormula(Formula neg)
           
 
Method Summary
 boolean checkTypesAndScope(Model model, java.util.Map scope)
          Returns true if, within the given scope, all the variables used in this ArgSpec are in scope and all type constraints are satisfied.
 boolean equals(java.lang.Object o)
          Two NegFormulas are equal if they have the same subformula.
 java.lang.Object evaluate(EvalContext context)
          Returns the value of this argument specification in the given context.
protected  Formula getEquivToNegationInternal()
          A formula equivalent to the negation of !psi is psi itself.
 Formula getNeg()
           
 java.util.Set getNonSatisfiersIfExplicit(EvalContext context, LogicalVar subject, GenericObject genericObj)
          Returns the set of values for the logical variable subject that are consistent with the generating function values of genericObj and that make this formula false in the given context, if this set can be determined without enumerating possible values for subject.
 ConjFormula getPropCNF()
          If this is a literal, then its CNF form is just a conjunction consisting of one disjunction, whose sole disjunct is this formula.
 DisjFormula getPropDNF()
          If this is a literal, then its DNF form is just a disjunction consisting of one conjunction, whose sole conjunct is this formula.
 java.util.Set getSatisfiersIfExplicit(EvalContext context, LogicalVar subject, GenericObject genericObj)
          Returns the set of values for the logical variable subject that are consistent with the generating function values of genericObj and that make this formula true in the given context, if this set can be determined without enumerating possible values for subject.
 Formula getStandardForm()
          The standard form of a negation formula !psi is determined as follows.
 java.util.List getSubformulas()
          Returns the proper subformulas of this formula.
 ArgSpec getSubstResult(Substitution subst, java.util.Set<LogicalVar> boundVars)
          Returns the result of applying the substitution subst to this expression, excluding the logical variables in boundVars.
 int hashCode()
           
 boolean isLiteral()
          Returns true if the negated formula is an atomic formula or an equality formula.
 java.lang.String toString()
          Returns a string of the form !psi where psi is the negated formula.
 
Methods inherited from class blog.Formula
compile, containsAnyTerm, containsRandomSymbol, containsTerm, getEquivToNegation, getGenFuncsApplied, getSubExprs, getTopLevelTerms, isElementary, isQuantified, isTrue
 
Methods inherited from class blog.ArgSpec
evaluate, evaluate, getFreeVars, getLocation, getSubstResult, getValueIfNonRandom, getVariable, isDetermined, isNumeric, setLocation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NegFormula

public NegFormula(Formula neg)
Method Detail

getNeg

public Formula getNeg()

evaluate

public java.lang.Object evaluate(EvalContext context)
Description copied from class: ArgSpec
Returns the value of this argument specification in the given context. Returns null if the partial world in this context is not complete enough to evaluate this ArgSpec, or if this ArgSpec contains a free variable that is not assigned a value in the given context.

Specified by:
evaluate in class ArgSpec

getStandardForm

public Formula getStandardForm()
The standard form of a negation formula !psi is determined as follows. If there is a formula equivalent to !psi that is not a negation formula, we return the standard form of that formula. Otherwise, we just return !psi', where psi' is the standard form of psi.

Overrides:
getStandardForm in class Formula

getEquivToNegationInternal

protected Formula getEquivToNegationInternal()
A formula equivalent to the negation of !psi is psi itself.

Overrides:
getEquivToNegationInternal in class Formula

getSubformulas

public java.util.List getSubformulas()
Description copied from class: Formula
Returns the proper subformulas of this formula. The default implementation returns an empty list.

Overrides:
getSubformulas in class Formula
Returns:
unmodifiable List of Formula objects

getPropCNF

public ConjFormula getPropCNF()
If this is a literal, then its CNF form is just a conjunction consisting of one disjunction, whose sole disjunct is this formula. Otherwise, its CNF form is the CNF form of the equivalent formula that is not a NegFormula.

Overrides:
getPropCNF in class Formula

getPropDNF

public DisjFormula getPropDNF()
If this is a literal, then its DNF form is just a disjunction consisting of one conjunction, whose sole conjunct is this formula. Otherwise, its DNF form is the DNF form of the equivalent formula that is not a NegFormula.

Overrides:
getPropDNF in class Formula

isLiteral

public boolean isLiteral()
Returns true if the negated formula is an atomic formula or an equality formula.

Overrides:
isLiteral in class Formula

getSatisfiersIfExplicit

public java.util.Set getSatisfiersIfExplicit(EvalContext context,
                                             LogicalVar subject,
                                             GenericObject genericObj)
Description copied from class: Formula
Returns the set of values for the logical variable subject that are consistent with the generating function values of genericObj and that make this formula true in the given context, if this set can be determined without enumerating possible values for subject. Returns the special value Formula.NOT_EXPLICIT if determining the desired set would requiring enumerating possible values for subject. Also, returns the special value Formula.ALL_OBJECTS if this formula is true in the given context for all objects consistent with genericObj. Finally, returns null if it tries to access an uninstantiated random variable.

Specified by:
getSatisfiersIfExplicit in class Formula
Parameters:
context - an evaluation context that does not assign a value to the logical variable subject
subject - a logical variable
genericObj - a GenericObject instance, which can stand for any object of a given type or include values for certain generating functions

getNonSatisfiersIfExplicit

public java.util.Set getNonSatisfiersIfExplicit(EvalContext context,
                                                LogicalVar subject,
                                                GenericObject genericObj)
Description copied from class: Formula
Returns the set of values for the logical variable subject that are consistent with the generating function values of genericObj and that make this formula false in the given context, if this set can be determined without enumerating possible values for subject. Returns the special value Formula.NOT_EXPLICIT if determining the desired set would requiring enumerating possible values for subject. Also, returns the special value Formula.ALL_OBJECTS if this formula is false in the given context for all objects consistent with genericObj. Finally, returns null if it tries to access an uninstantiated random variable.

This default implementation calls getEquivToNegation, then calls getSatisfiersIfExplicit on the resulting formula. Warning: subclasses must override either this method or getEquivToNegationInternal to avoid an UnsupportedOperationException.

Overrides:
getNonSatisfiersIfExplicit in class Formula
Parameters:
context - an evaluation context that does not assign a value to the logical variable subject
subject - a logical variable
genericObj - a GenericObject instance, which can stand for any object of a given type or include values for certain generating functions

equals

public boolean equals(java.lang.Object o)
Two NegFormulas are equal if they have the same subformula.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string of the form !psi where psi is the negated formula.

Overrides:
toString in class java.lang.Object

checkTypesAndScope

public boolean checkTypesAndScope(Model model,
                                  java.util.Map scope)
Description copied from class: ArgSpec
Returns true if, within the given scope, all the variables used in this ArgSpec are in scope and all type constraints are satisfied. If there is a type or scope error, prints an appropriate message to standard error and returns false.

Specified by:
checkTypesAndScope in class ArgSpec
scope - a Map from variable names (Strings) to LogicalVar objects

getSubstResult

public ArgSpec getSubstResult(Substitution subst,
                              java.util.Set<LogicalVar> boundVars)
Description copied from class: ArgSpec
Returns the result of applying the substitution subst to this expression, excluding the logical variables in boundVars. This method is used for recursive calls. The set boundVars should contain those variables that are bound in the syntax tree between this sub-expression and the top-level expression to which the substitution is being applied.

Specified by:
getSubstResult in class ArgSpec