daikon.inv.binary.twoSequence
Class TwoSequence

Object
  extended by Invariant
      extended by BinaryInvariant
          extended by TwoSequence
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
PairwiseIntEqual, PairwiseIntGreaterEqual, PairwiseIntGreaterThan, PairwiseIntLessEqual, PairwiseIntLessThan, PairwiseLinearBinary, PairwiseNumericInt, Reverse, SeqSeqIntEqual, SeqSeqIntGreaterEqual, SeqSeqIntGreaterThan, SeqSeqIntLessEqual, SeqSeqIntLessThan, SubSequence, SubSet, SuperSequence, SuperSet

public abstract class TwoSequence
extends BinaryInvariant

Base class for two variable long[] invariants. Provides a simpler mechanism for non-symmetric invariants to function over both permutations of their variables. Non-symmetric invariants must instantiate two objects (one for each argument order). This is tracked by the variable swap. They must always access their variables via the methods var1() and var2() which return the correct variable (based on the swap setting). No other work is necessary, all permuations and resurrection is handled here. Symmetric invariants should define symmetric() to return true or override resurrect_done_swapped to do nothing. Non-symmetric invariants that use converse operations (eg, less than and greater than) rather than argument swapping should override resurrect_done_swapped to return the correct class.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class Invariant
Invariant.ClassVarnameComparator, Invariant.ClassVarnameFormulaComparator, Invariant.InvariantComparatorForPrinting, Invariant.Match
 
Field Summary
protected  boolean swap
           
 
Fields inherited from class Invariant
CONFIDENCE_JUSTIFIED, CONFIDENCE_NEVER, CONFIDENCE_UNJUSTIFIED, debug, 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
protected TwoSequence(PptSlice ppt)
          Pass-through.
 
Method Summary
 InvariantStatus add_modified(long[] v1, long[] v2, int count)
          Default implementation simply calls check.
 InvariantStatus add_unmodified(long[] v1, long[] v2, int count)
          By default, do nothing if the value hasn't been seen yet.
 InvariantStatus add(Object val1, Object val2, int mod_index, int count)
           
abstract  InvariantStatus check_modified(long[] v1, long[] v2, int count)
           
 InvariantStatus check_unmodified(long[] v1, long[] v2, int count)
           
 InvariantStatus check(Object val1, Object val2, int mod_index, int count)
           
protected  double computeConfidence()
          This method computes the confidence that this invariant occurred by chance.
 boolean get_swap()
          Returns whether or not the variable order is currently swapped for this invariant.
 boolean isSameFormula(Invariant other)
          Return true if both invariants are the same class and the order of the variables (swap) is the same.
 String repr()
          Returns a representation of the class.
protected  Invariant resurrect_done_swapped()
          Swaps the variables by inverting the state of swap.
protected  Invariant resurrect_done_unswapped()
          Subclasses can override in the rare cases they need to fix things even when not swapped.
protected  Invariant resurrect_done(int[] permutation)
          Checks to see if the variable order was swapped and calls the correct routine to handle it.
 boolean valid_types(VarInfo[] vis)
          Returns whether or not the specified types are valid
 VarInfo var1()
          Returns the first variable.
 VarInfo var1(VarInfo[] vis)
          Returns the first variable from the specified vis.
 VarInfo var2()
          Returns the first variable.
 VarInfo var2(VarInfo[] vis)
          Returns the first variable in the specified vis.
 
Methods inherited from class BinaryInvariant
add_unordered, check_unordered, find, is_symmetric
 
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_using, 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, repCheck, repr_prob, resurrect, simplify_format_double, simplify_format_long, simplify_format_string, state_match, toString, toString, transfer, usesVar, usesVar, usesVarDerived, varNames
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

swap

protected boolean swap
Constructor Detail

TwoSequence

protected TwoSequence(PptSlice ppt)
Pass-through.

Method Detail

valid_types

public final boolean valid_types(VarInfo[] vis)
Returns whether or not the specified types are valid

Overrides:
valid_types in class Invariant
See Also:
Invariant.instantiate_ok(VarInfo[])

get_swap

public boolean get_swap()
Returns whether or not the variable order is currently swapped for this invariant.

Overrides:
get_swap in class BinaryInvariant

resurrect_done

protected Invariant resurrect_done(int[] permutation)
Checks to see if the variable order was swapped and calls the correct routine to handle it.

Specified by:
resurrect_done in class Invariant

resurrect_done_swapped

protected Invariant resurrect_done_swapped()
Swaps the variables by inverting the state of swap.


resurrect_done_unswapped

protected Invariant resurrect_done_unswapped()
Subclasses can override in the rare cases they need to fix things even when not swapped.


var1

public VarInfo var1()
Returns the first variable. This is the only mechanism by which subclasses should access variables.


var2

public VarInfo var2()
Returns the first variable. This is the only mechanism by which subclasses should access variables.


var1

public VarInfo var1(VarInfo[] vis)
Returns the first variable from the specified vis. This is the only mechanism by which subclasses should access variables.


var2

public VarInfo var2(VarInfo[] vis)
Returns the first variable in the specified vis. This is the only mechanism by which subclasses should access variables.


check

public InvariantStatus check(Object val1,
                             Object val2,
                             int mod_index,
                             int count)
Specified by:
check in class BinaryInvariant

add

public InvariantStatus add(Object val1,
                           Object val2,
                           int mod_index,
                           int count)
Specified by:
add in class BinaryInvariant

check_modified

public abstract InvariantStatus check_modified(long[] v1,
                                               long[] v2,
                                               int count)

check_unmodified

public InvariantStatus check_unmodified(long[] v1,
                                        long[] v2,
                                        int count)

add_modified

public InvariantStatus add_modified(long[] v1,
                                    long[] v2,
                                    int count)
Default implementation simply calls check. Subclasses can override.


add_unmodified

public InvariantStatus add_unmodified(long[] v1,
                                      long[] v2,
                                      int count)
By default, do nothing if the value hasn't been seen yet. Subclasses can override this.


repr

public String repr()
Returns a representation of the class. This includes the classname, variables, and swap state.

Overrides:
repr in class Invariant

isSameFormula

public boolean isSameFormula(Invariant other)
Return true if both invariants are the same class and the order of the variables (swap) is the same.

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.

computeConfidence

protected double computeConfidence()
Description copied from class: Invariant
This method computes the confidence that this invariant occurred by chance. Users should use getConfidence() instead.

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