예제 #1
0
 @Override
 public int hashCode() {
   int hash = 1;
   hash = hash * Utils.HASH_PRIME + term.hashCode();
   hash = hash * Utils.HASH_PRIME + lookups.hashCode();
   hash = hash * Utils.HASH_PRIME + constraint.hashCode();
   return hash;
 }
예제 #2
0
  @Override
  public boolean equals(Object object) {
    if (this == object) {
      return true;
    }

    if (!(object instanceof ConstrainedTerm)) {
      return false;
    }

    ConstrainedTerm constrainedTerm = (ConstrainedTerm) object;
    return term.equals(constrainedTerm.term)
        && lookups.equals(constrainedTerm.lookups)
        && constraint.equals(constrainedTerm.constraint);
  }
예제 #3
0
  public SymbolicConstraint matchImplies(ConstrainedTerm constrainedTerm) {
    SymbolicConstraint unificationConstraint =
        new SymbolicConstraint(constrainedTerm.termContext());
    unificationConstraint.add(term, constrainedTerm.term);
    unificationConstraint.simplify();
    if (unificationConstraint.isFalse() || !unificationConstraint.isSubstitution()) {
      return null;
    }

    SymbolicConstraint implicationConstraint =
        new SymbolicConstraint(constrainedTerm.termContext());
    implicationConstraint.addAll(unificationConstraint);
    implicationConstraint.addAll(constrainedTerm.lookups);
    implicationConstraint.addAll(constrainedTerm.constraint);
    implicationConstraint.simplify();

    unificationConstraint.addAll(constraint);
    unificationConstraint.simplify();
    if (!unificationConstraint.implies(implicationConstraint)) {
      return null;
    }

    unificationConstraint.addAll(implicationConstraint);

    return unificationConstraint;
  }
예제 #4
0
  public Collection<SymbolicConstraint> unify(ConstrainedTerm constrainedTerm) {
    if (!term.kind.equals(constrainedTerm.term.kind)) {
      return Collections.emptyList();
    }

    SymbolicConstraint unificationConstraint =
        new SymbolicConstraint(constrainedTerm.termContext());
    unificationConstraint.add(term, constrainedTerm.term());
    unificationConstraint.simplify();
    if (unificationConstraint.isFalse()) {
      return Collections.emptyList();
    }

    Collection<SymbolicConstraint> constraints = new ArrayList<SymbolicConstraint>();
    for (SymbolicConstraint solution : unificationConstraint.getMultiConstraints()) {
      if (SymbolicConstraint.TruthValue.FALSE == solution.addAll(constrainedTerm.lookups)) continue;
      if (SymbolicConstraint.TruthValue.FALSE == solution.addAll(constrainedTerm.constraint))
        continue;
      if (SymbolicConstraint.TruthValue.FALSE == solution.addAll(constraint)) continue;

      solution.simplify();
      if (solution.isFalse()) {
        continue;
      }

      if (solution.checkUnsat()) {
        continue;
      }

      constraints.add(solution);
    }

    return constraints;
  }