Example #1
0
 public InvariantStatus check_modified(long value, int count) {
   if (modulus == 1) {
     // We shouldn't ever get to this case; the invariant should have been
     // destroyed instead.
     throw new Error("Modulus = 1");
   } else if (no_samples_seen) {
     return InvariantStatus.NO_CHANGE;
   } else if (value == value1) {
     // no new information, so nothing to do
     return InvariantStatus.NO_CHANGE;
   } else if (modulus == 0) {
     // only one value seen so far
     // REACHABLE?
     if (modulus == 1) {
       return InvariantStatus.FALSIFIED;
     }
   } else {
     long new_modulus_long = Math.abs(MathMDE.gcd(modulus, value1 - value));
     int new_modulus;
     if (new_modulus_long > Integer.MAX_VALUE || (new_modulus_long < Integer.MIN_VALUE)) {
       new_modulus = 1;
     } else {
       new_modulus = (int) new_modulus_long;
       assert new_modulus > 0;
     }
     if (new_modulus != modulus) {
       if (new_modulus == 1) {
         return InvariantStatus.FALSIFIED;
       }
     }
   }
   assert modulus != 1;
   return InvariantStatus.NO_CHANGE;
 }
Example #2
0
  public InvariantStatus add_modified(long value, int count) {
    if (modulus == 1) {
      // We shouldn't ever get to this case; the invariant should have been
      // destroyed instead.
      throw new Error("Modulus = 1");
      // assert falsified;
      // // We already know this confidence fails
      // return;
    } else if (no_samples_seen) {
      value1 = value;
      no_samples_seen = false;
      return InvariantStatus.NO_CHANGE;
    } else if (value == value1) {
      // no new information, so nothing to do
      return InvariantStatus.NO_CHANGE;
    } else if (modulus == 0) {
      // only one value seen so far
      long new_modulus = Math.abs(value1 - value);

      if (new_modulus == 1) {
        return InvariantStatus.FALSIFIED;
      }
      modulus = new_modulus;
      remainder = MathMDE.mod_positive(value, modulus);
    } else {
      long new_modulus_long = Math.abs(MathMDE.gcd(modulus, value1 - value));
      int new_modulus;
      if (new_modulus_long > Integer.MAX_VALUE || (new_modulus_long < Integer.MIN_VALUE)) {
        new_modulus = 1;
      } else {
        new_modulus = (int) new_modulus_long;
        assert new_modulus > 0;
      }
      if (new_modulus != modulus) {
        if (new_modulus == 1) {
          return InvariantStatus.FALSIFIED;
        } else {
          remainder = remainder % new_modulus;
          modulus = new_modulus;
        }
      }
    }
    assert modulus != 1;
    return InvariantStatus.NO_CHANGE;
  }
Example #3
0
 protected double computeConfidence() {
   if (modulus == 1) return Invariant.CONFIDENCE_NEVER;
   if (modulus == 0) {
     return Invariant.CONFIDENCE_UNJUSTIFIED;
   }
   double probability_one_elt_modulus = 1 - 1.0 / modulus;
   // return 1 - Math.pow(probability_one_elt_modulus, ppt.num_mod_samples());
   return 1 - Math.pow(probability_one_elt_modulus, ppt.num_samples());
 }
  protected double computeConfidence() {
    // num_elt_values() would be more appropriate
    // int num_values = ((PptSlice2) ppt).num_elt_values();
    int num_values = ppt.num_samples();
    if (num_values == 0) {
      return Invariant.CONFIDENCE_UNJUSTIFIED;
    } else {

      return 1 - Math.pow(.5, num_values);
    }
  }
  protected double computeConfidence() {

    return 1 - Math.pow(.5, ppt.num_samples());
  }
 protected double computeConfidence() {
   return 1 - Math.pow(.9, elts);
 }