Example #1
0
 /**
  * Gets the string representation of this variable, providing the string representation of the
  * linked term in the case of bound variable
  */
 public String toStringFlattened() {
   Term tt = getTerm();
   if (name != null) {
     if (tt == this) {
       return completeName;
     } else {
       return tt.toString();
     }
   } else {
     if (tt == this) {
       return ANY + hashCode();
     } else {
       return tt.toString();
     }
   }
 }
  private static MultiList<Object, Set<Constant>> partitionExchangeable_impl(
      Iterable<DefaultRule> rules) {
    MultiMap<Term, Term> partitioning = new MultiMap<Term, Term>();

    List<Term> constants = Sugar.arrayListFromCollections(constants(rules));
    Set<Term> closed = new HashSet<Term>();

    // checking interchangeability pairwise
    for (int i = 0; i < constants.size(); i++) {
      if (!closed.contains(constants.get(i))) {
        partitioning.put(constants.get(i), constants.get(i));
        for (int j = i + 1; j < constants.size(); j++) {
          if (areExchangeable(constants.get(i), constants.get(j), rules)) {
            partitioning.put(constants.get(i), constants.get(j));
            closed.add(constants.get(j));
          }
        }
      }
    }
    Map<Constant, Constant> map = new HashMap<Constant, Constant>();
    for (Map.Entry<Term, Set<Term>> entry : partitioning.entrySet()) {
      Constant lexmin = null;
      for (Term t : entry.getValue()) {
        if (t instanceof Constant) {
          if (lexmin == null || t.toString().compareTo(lexmin.toString()) < 0) {
            lexmin = (Constant) t;
          }
        }
      }
      for (Term t : entry.getValue()) {
        if (t instanceof Constant) {
          map.put((Constant) t, lexmin);
        }
      }
    }

    MultiMap<Pair<Object, Constant>, Constant> mm =
        new MultiMap<Pair<Object, Constant>, Constant>();
    for (Map.Entry<Constant, Constant> entry : map.entrySet()) {
      mm.put(
          new Pair<Object, Constant>(
              entry.getValue().type() == null ? Sugar.NIL : entry.getValue().type(),
              entry.getValue()),
          entry.getKey());
    }

    MultiList<Object, Set<Constant>> retVal = new MultiList<Object, Set<Constant>>();
    for (Map.Entry<Pair<Object, Constant>, Set<Constant>> entry : mm.entrySet()) {
      retVal.put(entry.getKey().r, entry.getValue());
    }
    return retVal;
  }
Example #3
0
 public static Term defaultTerm(Term v, org.kframework.kil.loader.Context context) {
   String sort = v.getSort();
   KSort ksort = KSort.getKSort(sort).mainSort();
   if (ksort.isDefaultable()) return new Empty(ksort.toString());
   GlobalSettings.kem.register(
       new KException(
           ExceptionType.WARNING,
           KExceptionGroup.COMPILER,
           "Don't know the default value for term " + v.toString() + ". Assuming .K",
           v.getFilename(),
           v.getLocation()));
   return KSequence.EMPTY;
 }