Exemple #1
0
 @Override
 public IResponse start() {
   super.start();
   solverProcess.start(true);
   try {
     if (smtConfig.verbose != 0) smtConfig.log.logDiag("Started simplify");
     solverProcess.sendAndListen(
         "(BG_PUSH (FORALL (B X Y) (IMPLIES (EQ B |@true|) (EQ (" + ite_term + " B X Y) X))))\n");
     solverProcess.sendAndListen(
         "(BG_PUSH (FORALL (B X Y) (IMPLIES (NEQ B |@true|) (EQ (" + ite_term + " B X Y) Y))))\n");
   } catch (IOException e) {
     return smtConfig.responseFactory.error("Failed to assert background formulae at start");
   }
   return smtConfig.responseFactory.success();
 }
Exemple #2
0
 @Override
 public IResponse exit() {
   solverProcess.exit();
   if (smtConfig.verbose != 0) smtConfig.log.logDiag("Ended simplify ");
   // process = null;
   return super.exit();
 }
Exemple #3
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;
  }
Exemple #4
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;
  }
Exemple #5
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");
   }
 }