示例#1
0
  @Override
  public IResponse check_sat() {
    IResponse res = super.check_sat();
    if (res.isError()) return res;
    try {
      //			String s = solverProcess.sendAndListen("(BG_PUSH (EQ 0 0))\r\n");
      //			s = solverProcess.sendAndListen("(EQ 0 1)\r\n");
      //			if (s.contains("Valid.")) res = smtConfig.responseFactory.unsat();
      //			else if (s.contains("Invalid.")) res = smtConfig.responseFactory.sat();
      //			else res = smtConfig.responseFactory.unknown();

      String msg = "(NOT (AND TRUE " + conjunction + "\n))\n";
      String s = solverProcess.sendAndListen(msg);
      // FIXME - what about errors in SImplify
      // smtConfig.log.logOut("HEARD: " + s);
      if (s.contains("Valid.")) res = smtConfig.responseFactory.unsat();
      else if (s.contains("Invalid.")) res = smtConfig.responseFactory.sat();
      else res = smtConfig.responseFactory.unknown();
      checkSatStatus = res;
      //			s = solverProcess.sendAndListen("(BG_POP)\r\n");

    } catch (IOException e) {
      res = smtConfig.responseFactory.error("Failed to check-sat");
    }
    return res;
  }
示例#2
0
  @Override
  public IResponse define_fun(Idefine_fun cmd) {
    IResponse res = super.define_fun(cmd);
    if (res.isError()) return res;
    try {
      if (cmd.resultSort().isBool() && cmd.parameters().size() > 0) {
        StringBuilder sb = new StringBuilder();
        sb.append("(DEFPRED (");
        sb.append(translate(cmd.symbol()));
        int n = cmd.parameters().size();
        for (int i = 0; i < n; i++) {
          sb.append(" X");
          sb.append(i);
        }
        sb.append("))\n");
        String s = solverProcess.sendAndListen(sb.toString());
        // FIXME - check for error in s -- System.out.println("HEARD " + s);
        res = smtConfig.responseFactory.success();
      } else {
        res = smtConfig.responseFactory.success();
      }
      IExpr.IFactory f = smtConfig.exprFactory;
      assertExpr(f.fcn(f.symbol("="), cmd.symbol(), cmd.expression()));

    } catch (IOException e) {
      res =
          smtConfig.responseFactory.error(
              "Failed to declare-fun: " + e.getMessage(), null); // FIXME - position?
    } catch (IVisitor.VisitorException e) {
      res = smtConfig.responseFactory.error("Failed to declare-fun: " + e.getMessage(), null);
    }
    return res;
  }
示例#3
0
 // @ requires number >= 0;
 @Override
 public IResponse push(int number) {
   IResponse status = super.push(number);
   if (!status.isOK()) return status;
   try {
     while (--number >= 0) {
       pushesStack.add(0, conjunction);
       String s = solverProcess.sendAndListen("(BG_PUSH (EQ 0 0))");
       // FIXME - check for error in s -- System.out.println("HEARD " + s);
     }
     return smtConfig.responseFactory.success();
   } catch (IOException e) {
     return smtConfig.responseFactory.error("Failed to push");
   }
 }
示例#4
0
 @Override
 public IResponse set_logic(String logicName, /*@Nullable*/ IPos pos) {
   // FIXME - discrimninate among logics
   boolean lSet = logicSet != null;
   IResponse status = super.set_logic(logicName, pos);
   if (!status.isOK()) return status;
   if (logicName.contains("BV")) {
     return smtConfig.responseFactory.error(
         "The simplify solver does not yet support the bit-vector theory", pos);
   }
   if (lSet) {
     pushesStack.clear();
     push(1);
   }
   return smtConfig.responseFactory.success();
 }
示例#5
0
 @Override
 public IResponse assertExpr(IExpr sexpr) {
   IResponse res = super.assertExpr(sexpr);
   if (!res.isOK()) return res;
   try {
     String translatedSexpr = translate(sexpr);
     if (translatedSexpr == null) {
       return smtConfig.responseFactory.error(
           "Failure in translating expression: " + smtConfig.defaultPrinter.toString(sexpr),
           sexpr.pos());
     }
     conjunction = conjunction + " \n" + translatedSexpr;
     // String s = solverProcess.sendAndListen("(BG_PUSH ",translatedSexpr," )\r\n");
     // System.out.println("HEARD: " + s);
   } catch (VisitorException e) {
     return smtConfig.responseFactory.error(e.getMessage(), e.pos);
   }
   return smtConfig.responseFactory.success();
 }