daikon.inv
Class Equality

Object
  extended by Invariant
      extended by Equality
All Implemented Interfaces:
Serializable, Cloneable

public final class Equality
extends Invariant

Keeps track of sets of variables that are equal. Other invariants are instantiated for only one member of the Equality set, the leader. If variables x, y, and z are members of the Equality set and x is chosen as the leader, then the Equality will internally convert into binary comparison invariants that print as x == y and x == z.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class Invariant
Invariant.ClassVarnameComparator, Invariant.ClassVarnameFormulaComparator, Invariant.InvariantComparatorForPrinting, Invariant.Match
 
Field Summary
static Logger debug
           
static Logger debugPostProcess
           
 
Fields inherited from class Invariant
CONFIDENCE_JUSTIFIED, CONFIDENCE_NEVER, CONFIDENCE_UNJUSTIFIED, debugFlow, debugGuarding, debugIsObvious, debugIsWorthPrinting, debugPrint, debugPrintEquality, dkconfig_confidence_limit, dkconfig_fuzzy_ratio, dkconfig_simplify_define_predicates, falsified, isGuardingPredicate, min_mod_non_missing_samples, ppt, PROBABILITY_JUSTIFIED, PROBABILITY_NEVER, PROBABILITY_UNJUSTIFIED
 
Constructor Summary
Equality(Collection<VarInfo> variables, PptSlice ppt)
           
 
Method Summary
 List<VarInfo> add(ValueTuple vt, int count)
           
 double computeConfidence()
          Always return JUSTIFIED because we aggregate Comparison invariants that are all justified to the confidence_limit threshold.
 String format_daikon()
           
 String format_esc()
           
 String format_java_family(OutputFormat format)
           
 String format_java()
           
 String format_simplify()
           
 String format_using(OutputFormat format)
           
 Set<VarInfo> getVars()
          Returns the variables in their index order.
 boolean hasNonCanonicalVariable()
           
 boolean isSameFormula(Invariant other)
           
 VarInfo leader()
          Return the canonical VarInfo of this.
 int numSamples()
           
 void pivot()
          Switch the leader of this invariant, if possible, to a more canonical VarInfo: a VarInfo that is not isDerived() is better than one that is; one that is not isDerivedParamAndUninteresting() is better than one that is; and other things being equal, choose the least complex name.
 void postProcess()
          Convert Equality invariants into normal IntEqual type for filtering, printing, etc.
 void repCheck()
          Check the rep invariants of this.
 String repr()
          For printing invariants, there are two interfaces: repr gives a low-level representation (repr_prop also prints the confidence), and format gives a high-level representation for user output.
protected  Invariant resurrect_done(int[] permutation)
          Called on the new invariant just before resurrect() returns it to allow subclasses to fix any information they might have cached from the old Ppt and VarInfos.
 void setSamples(int sample_cnt)
           
 String shortString()
           
 int size()
          Returns the number of variables in the set.
 String toString()
           
 
Methods inherited from class Invariant
add_sample, asInvClass, clear_falsified, clone_and_permute, clone, conf_is_ge, confidence_and, confidence_and, confidence_or, createGuardedInvariant, createGuardingPredicate, enabled, enoughSamples, falsify, find, format_too_few_samples, format_unimplemented, format, formatFuzzy, get_comparability, get_ni_suppressions, getConfidence, getGuardingList, getGuardingList, hasUninterestingConstant, instantiate_dyn, instantiate_ok, instantiate, is_false, is_ni_suppressed, isActive, isAllPrestate, isExact, isExclusiveFormula, isInteresting, isObvious, isObviousDynamically_SomeInEquality, isObviousDynamically_SomeInEqualityHelper, isObviousDynamically, isObviousDynamically, isObviousStatically_AllInEquality, isObviousStatically_SomeInEquality, isObviousStatically_SomeInEqualityHelper, isObviousStatically, isObviousStatically, isReflexive, isSameInvariant, isValidEscExpression, isValidExpression, isWorthPrinting, justified, log, log, logDetail, logOn, match, merge, mergeFormulasOk, permute, prob_and, prob_and, prob_is_ge, prob_or, repr_prob, resurrect, simplify_format_double, simplify_format_long, simplify_format_string, state_match, toString, transfer, usesVar, usesVar, usesVarDerived, valid_types, varNames
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static final Logger debug

debugPostProcess

public static final Logger debugPostProcess
Constructor Detail

Equality

public Equality(Collection<VarInfo> variables,
                PptSlice ppt)
Parameters:
variables - Variables which are equivalent, with the canonical one first. Elements must be of type VarInfo.
Method Detail

setSamples

public void setSamples(int sample_cnt)

numSamples

public int numSamples()

size

public int size()
Returns the number of variables in the set.


getVars

public Set<VarInfo> getVars()
Returns the variables in their index order. Unmodifiable.


leader

public VarInfo leader()
Return the canonical VarInfo of this. Note that the leader never changes.

Returns:
the canonical VarInfo of this

hasNonCanonicalVariable

public boolean hasNonCanonicalVariable()

computeConfidence

public double computeConfidence()
Always return JUSTIFIED because we aggregate Comparison invariants that are all justified to the confidence_limit threshold.

Specified by:
computeConfidence in class Invariant
See Also:
Invariant.getConfidence()

repr

public String repr()
Description copied from class: Invariant
For printing invariants, there are two interfaces: repr gives a low-level representation (repr_prop also prints the confidence), and format gives a high-level representation for user output.

Overrides:
repr in class Invariant

format_using

public String format_using(OutputFormat format)
Specified by:
format_using in class Invariant

format_daikon

public String format_daikon()

format_java

public String format_java()

format_esc

public String format_esc()

format_simplify

public String format_simplify()

shortString

public String shortString()

format_java_family

public String format_java_family(OutputFormat format)

toString

public String toString()
Overrides:
toString in class Invariant

add

public List<VarInfo> add(ValueTuple vt,
                         int count)
Returns:
a List of VarInfos that do not fit into this set anymore Originally (8/14/2003), this did not check for the modified bits. It seems however, quite wrong to leave variables in the same equality set when one is missing and the other is not. Its possible we should go farther and break out of the equality set any variable that is missingOutOfBounds (JHP)

resurrect_done

protected Invariant resurrect_done(int[] permutation)
Description copied from class: Invariant
Called on the new invariant just before resurrect() returns it to allow subclasses to fix any information they might have cached from the old Ppt and VarInfos.

Specified by:
resurrect_done in class Invariant

isSameFormula

public boolean isSameFormula(Invariant other)
Overrides:
isSameFormula in class Invariant
Returns:
true iff the two invariants represent the same mathematical formula. Does not consider the context such as variable names, confidences, sample counts, value counts, or related quantities. As a rule of thumb, if two invariants format the same, this method returns true. Furthermore, in many cases, if an invariant does not involve computed constants (as "x>c" and "y=ax+b" do for constants a, b, and c), then this method vacuously returns true.

postProcess

public void postProcess()
Convert Equality invariants into normal IntEqual type for filtering, printing, etc. Add these to parent. If the leader was changed to not be the first member of the group adds leader == leader invariant as well since that invariant is used in suppressions and obvious tests.


pivot

public void pivot()
Switch the leader of this invariant, if possible, to a more canonical VarInfo: a VarInfo that is not isDerived() is better than one that is; one that is not isDerivedParamAndUninteresting() is better than one that is; and other things being equal, choose the least complex name. Call this only after postProcess has been called. We do a pivot so that anything that's interesting to be printed gets printed and not filtered out. For example, if a == b and a is the leader, but not interesting, we still want to print f(b) as an invariant. Thus we pivot b to be the leader. Later on, each relevant PptSlice gets pivoted. But not here.


repCheck

public void repCheck()
Description copied from class: Invariant
Check the rep invariants of this.

Overrides:
repCheck in class Invariant