public DiscardInfo isObviousStatically(VarInfo[] vis) {
    VarInfo var1 = vis[0];
    VarInfo var2 = vis[1];

    Object[] obv1 = SubSequence.isObviousSubSequence(var1, var2);
    Object[] obv2 = SubSequence.isObviousSubSequence(var2, var1);
    if (obv1[1] != null) {
      Global.implied_noninstantiated_invariants++;
      return new DiscardInfo(this, (DiscardCode) obv1[0], (String) obv1[1]);
    } else if (obv2[1] != null) {
      Global.implied_noninstantiated_invariants++;
      return new DiscardInfo(this, (DiscardCode) obv1[0], (String) obv1[1]);
    }

    // Don't instantiate if the variables can't have order
    if (!var1.aux.getFlag(VarInfoAux.HAS_ORDER) || !var2.aux.getFlag(VarInfoAux.HAS_ORDER)) {
      if (debug.isLoggable(Level.FINE)) {
        debug.fine(
            "Not instantitating for because order has no meaning: "
                + var1.name()
                + " and "
                + var2.name());
      }
      return new DiscardInfo(
          this, DiscardCode.obvious, "Obvious statically since order has no meaning");
    }

    return super.isObviousStatically(vis);
  }
Пример #2
0
  public DiscardInfo isObviousStatically(VarInfo[] vis) {

    VarInfo subvar = var1(vis);
    VarInfo supervar = var2(vis);

    // check for x[i..j] subsequence of x[]
    VarInfo subvar_super = subvar.isDerivedSubSequenceOf();
    if (subvar_super == supervar) {
      debug.fine("  returning true because subvar_super == supervar");
      return new DiscardInfo(this, DiscardCode.obvious, "x[i..j] subsequence of x[] is obvious");
    }

    Object[] obv1 = SubSequence.isObviousSubSequence(subvar, supervar);
    if (obv1[1] != null) {
      return new DiscardInfo(this, (DiscardCode) obv1[0], (String) obv1[1]);
    }

    // JHP: This is not a valid obvious check, since it  doesn't imply that
    // the invariant is true.
    if (!subvar.aux.getFlag(VarInfoAux.HAS_ORDER) || !supervar.aux.getFlag(VarInfoAux.HAS_ORDER)) {
      // Doesn't make sense to consider subsequence if order doens't matter
      return new DiscardInfo(
          this, DiscardCode.obvious, "Order doesn't matter, so subsequence is meaningless");
    }

    return super.isObviousStatically(vis);
  }