コード例 #1
0
ファイル: Solver_simplify.java プロジェクト: smtlib/jSMTLIB
  @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;
  }
コード例 #2
0
ファイル: Solver_simplify.java プロジェクト: smtlib/jSMTLIB
 @Override
 public IResponse get_value(IExpr... terms) {
   TypeChecker tc = new TypeChecker(symTable);
   try {
     for (IExpr term : terms) {
       term.accept(tc);
     }
   } catch (IVisitor.VisitorException e) {
     tc.result.add(smtConfig.responseFactory.error(e.getMessage()));
   } finally {
     if (!tc.result.isEmpty()) return tc.result.get(0); // FIXME - report all errors?
   }
   // FIXME - do we really want to call get-option here? it involves going to the solver?
   if (!Utils.TRUE.equals(get_option(smtConfig.exprFactory.keyword(Utils.PRODUCE_MODELS)))) {
     return smtConfig.responseFactory.error(
         "The get-value command is only valid if :produce-models has been enabled");
   }
   if (!smtConfig.responseFactory.sat().equals(checkSatStatus)
       && !smtConfig.responseFactory.unknown().equals(checkSatStatus)) {
     return smtConfig.responseFactory.error(
         "A get-value command is valid only after check-sat has returned sat or unknown");
   }
   return smtConfig.responseFactory.unsupported();
 }