示例#1
0
文件: KILtoSMTLib.java 项目: kszr/k
 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();
 }
示例#2
0
文件: KILtoSMTLib.java 项目: kszr/k
 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
       + ")";
 }