@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; }
@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; }