Beispiel #1
0
 public static String translateImplication(
     SymbolicConstraint leftHandSide, SymbolicConstraint rightHandSide) {
   KILtoSMTLib leftTransformer = new KILtoSMTLib(true);
   KILtoSMTLib rightTransformer = new KILtoSMTLib(false);
   String leftExpression = ((SMTLibTerm) leftHandSide.accept(leftTransformer)).expression();
   String rightExpression = ((SMTLibTerm) rightHandSide.accept(rightTransformer)).expression();
   StringBuilder sb = new StringBuilder();
   sb.append(
       getSortAndFunctionDeclarations(
           leftHandSide.termContext().definition(),
           Sets.union(leftTransformer.variables(), rightTransformer.variables())));
   sb.append(getAxioms(leftHandSide.termContext().definition()));
   sb.append(getConstantDeclarations(leftTransformer.variables()));
   sb.append("(assert (and ");
   sb.append(leftExpression);
   sb.append(" (not ");
   Set<Variable> rightHandSideOnlyVariables =
       Sets.difference(rightTransformer.variables(), leftTransformer.variables());
   if (!rightHandSideOnlyVariables.isEmpty()) {
     sb.append("(exists (");
     sb.append(getQuantifiedVariables(rightHandSideOnlyVariables));
     sb.append(") ");
   }
   sb.append(rightExpression);
   if (!rightHandSideOnlyVariables.isEmpty()) {
     sb.append(")");
   }
   sb.append(")))");
   return sb.toString();
 }
Beispiel #2
0
 public static String translateConstraint(SymbolicConstraint constraint) {
   KILtoSMTLib transformer = new KILtoSMTLib(true);
   String expression = ((SMTLibTerm) constraint.accept(transformer)).expression();
   return getSortAndFunctionDeclarations(
           constraint.termContext().definition(), transformer.variables())
       + getAxioms(constraint.termContext().definition())
       + getConstantDeclarations(transformer.variables())
       + "(assert "
       + expression
       + ")";
 }