org.smtlib.IExpr - java examples

Here are the examples of the java api org.smtlib.IExpr taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

81 Examples 7

19 View Complete Implementation : TypeChecker.java
Copyright MIT License
Author : mechtaev
public /*@Nullable*/
ISort save(/*@NonNull*/
IExpr e, /*@Nullable*/
ISort s) {
    if (typemap != null)
        typemap.put(e, s);
    return s;
}

19 View Complete Implementation : ObjectToExpr.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
private static IExpr negatedNumber(IExpr numberExpression) {
    return smtlib().expression(subtraction(), numberExpression);
}

19 View Complete Implementation : LRA.java
Copyright MIT License
Author : mechtaev
public boolean isConst(IExpr expr) {
    if (expr instanceof IExpr.INumeral)
        return true;
    if (expr instanceof IExpr.IDecimal)
        return true;
    if (!(expr instanceof IExpr.IFcnExpr))
        return false;
    IExpr.IFcnExpr f = (IExpr.IFcnExpr) expr;
    if (f.head().toString().equals("-") && f.args().size() == 1) {
        expr = f.args().get(0);
        if (expr instanceof IExpr.INumeral)
            return true;
        if (expr instanceof IExpr.IDecimal)
            return true;
        return false;
    }
    if (f.head().toString().equals("/") && f.args().size() == 2) {
        expr = f.args().get(0);
        if (!isInteger(expr))
            return false;
        expr = f.args().get(1);
        if (expr instanceof IExpr.INumeral) {
            if (((IExpr.INumeral) expr).intValue() == 0)
                return false;
            return true;
        }
        return false;
    }
    return false;
}

19 View Complete Implementation : Solver_simplify.java
Copyright MIT License
Author : mechtaev
public /*@Nullable*/
String translate(IExpr expr) throws IVisitor.VisitorException {
    Translator t = new Translator(typemap, smtConfig);
    String r = expr.accept(t);
    if (t.conjuncts.isEmpty())
        return r;
    String and = "(AND ";
    for (String c : t.conjuncts) {
        and = and + c + " ";
    }
    and = and + r + " )";
    return and;
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public IFcnExpr distinctExpression(IExpr first, IExpr second) {
    return expression(distinct(), first, second);
}

19 View Complete Implementation : Logic.java
Copyright MIT License
Author : mechtaev
public boolean isFreeConstant(IExpr expr) {
    return (expr instanceof ISymbol);
// if (!(expr instanceof IExpr.IFcnExpr)) return false;
// IExpr.IFcnExpr f = (IExpr.IFcnExpr)expr;
// return f.args().size() == 0;
}

19 View Complete Implementation : Constraint.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
protected IExpr binaryOperation(IExpr firstOperand, ISymbol operation, IExpr secondOperand) {
    return smtlib().expression(operation, firstOperand, secondOperand);
}

19 View Complete Implementation : AUFLIRA.java
Copyright MIT License
Author : mechtaev
@Override
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
// if (!isLinearInteger(expression)) throw new IVisitor.VisitorException("Integer expressions must be linear in this logic",expression.pos());
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public IFcnExpr equalsExpression(IExpr first, IExpr second) {
    return expression(equality(), first, second);
}

19 View Complete Implementation : QF_AX.java
Copyright MIT License
Author : mechtaev
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
    noQuantifiers(expression);
}

19 View Complete Implementation : SMTLibEqualVisitor.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
@Override
public Boolean visit(IFcnExpr actual) throws VisitorException {
    if (instanceOf(IFcnExpr.clreplaced, expected())) {
        IFcnExpr casted = (IFcnExpr) expected();
        replacedertEquals(casted.kind(), actual.kind());
        qualifiedIdentifierComparison(casted.head(), actual.head());
        replacedertEquals(casted.args().size(), actual.args().size());
        int index = 0;
        for (IExpr arg : casted.args()) {
            expressionComparison(arg, actual.args().get(index));
            index += 1;
        }
    }
    return true;
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public Idefine_fun functionDefinition(ISymbol identifier, List<IDeclaration> parameters, ISort outputType, IExpr definition) {
    return commandFactory().define_fun(identifier, parameters, outputType, definition);
}

19 View Complete Implementation : Logic.java
Copyright MIT License
Author : mechtaev
public boolean isLinearInteger(IExpr expr) {
    // FIXME - should use a visitor; does not check inside quantified expressions
    if (expr instanceof IExpr.IFcnExpr) {
        IExpr.IFcnExpr f = (IExpr.IFcnExpr) expr;
        if (f.args().size() == 2) {
            String fcn = f.head().toString();
            IExpr lhs = f.args().get(0);
            IExpr rhs = f.args().get(1);
            if (fcn.equals("+") || fcn.equals("-")) {
                return isLinearInteger(lhs) && isLinearInteger(rhs);
            } else if (fcn.equals("*")) {
                return (isInteger(lhs) && isFreeConstant(rhs)) || (isFreeConstant(lhs) && isInteger(rhs));
            } else if (fcn.equals("div") || fcn.equals("mod") || fcn.equals("abs")) {
                return false;
            } else {
                // Core functions
                return isLinearInteger(lhs) && isLinearInteger(rhs);
            }
        } else {
            int n = f.args().size();
            for (IExpr e : f.args()) {
                if (!isLinearInteger(e))
                    return false;
            }
            return true;
        }
    } else {
        return true;
    }
}

19 View Complete Implementation : TypeChecker.java
Copyright MIT License
Author : mechtaev
@Override
public /*@Nullable*/
ISort visit(ILet e) throws IVisitor.VisitorException {
    Map<ISymbol, Variable> newdecls = new HashMap<ISymbol, Variable>();
    Map<ISymbol, Variable> saved = new HashMap<ISymbol, Variable>();
    saved.putAll(currentScope);
    parameters.add(0, saved);
    try {
        boolean anyErrors = false;
        for (IExpr.IBinding decl : e.bindings()) {
            IExpr expr = decl.expr();
            ISort s = expr.accept(this);
            if (s == null)
                anyErrors = true;
            else {
                newdecls.put(decl.parameter(), new Variable(decl.parameter(), s, expr));
            }
        }
        if (anyErrors)
            return null;
        currentScope.putAll(newdecls);
        ISort s = e.expr().accept(this);
        return save(e, s);
    } finally {
        currentScope = parameters.remove(0);
    }
}

19 View Complete Implementation : Logic.java
Copyright MIT License
Author : mechtaev
public boolean isInteger(IExpr expr) {
    if (expr instanceof IExpr.INumeral)
        return true;
    if (!(expr instanceof IExpr.IFcnExpr))
        return false;
    IExpr.IFcnExpr f = (IExpr.IFcnExpr) expr;
    if (f.head().toString().equals("-") && f.args().size() == 1) {
        expr = f.args().get(0);
        if (expr instanceof IExpr.INumeral)
            return true;
        return false;
    }
    return false;
}

19 View Complete Implementation : ConnectivityConstraint.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
private IExpr sameLineSameVariableImplication(LocationVariable<?> firstVariable, LocationVariable<?> secondVariable) {
    IExpr sameLine = binaryOperation(expressionSymbolOf(firstVariable), equality(), secondVariable.encodedLineNumber());
    IExpr sameVariable = binaryOperation(subexpressionSymbolOf(firstVariable), equality(), subexpressionSymbolOf(secondVariable));
    return binaryOperation(sameLine, implies(), sameVariable);
}

19 View Complete Implementation : Logic.java
Copyright MIT License
Author : mechtaev
public void noQuantifiers(IExpr expression) throws IVisitor.VisitorException {
    IVisitor<Void> visitor = new IVisitor.TreeVisitor<Void>() {

        @Override
        public Void visit(IForall e) throws IVisitor.VisitorException {
            throw new IVisitor.VisitorException("A quantified expression is not allowed in the " + logicName + " logic", e.pos());
        }

        @Override
        public Void visit(IExists e) throws IVisitor.VisitorException {
            throw new IVisitor.VisitorException("A quantified expression is not allowed in the " + logicName + " logic", e.pos());
        }
    };
    expression.accept(visitor);
}

19 View Complete Implementation : LineBoundConstraint.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
private IExpr lineBoundaryFor(IExpr from, IExpr to, LocationVariable<?> variable) {
    ISymbol lessOrEqualThan = lessOrEqualThan();
    ISymbol variableExpr = expressionSymbolOf(variable);
    IExpr lowerBoundExpr = binaryOperation(from, lessOrEqualThan, variableExpr);
    IExpr upperBoundExpr = binaryOperation(variableExpr, lessOrEqualThan, to);
    return conjunctionOf(asList(lowerBoundExpr, upperBoundExpr));
}

19 View Complete Implementation : C_assert.java
Copyright MIT License
Author : mechtaev
/**
 * Implements the replacedert command
 */
public clreplaced C_replacedert extends Command implements Ireplacedert {

    /**
     * Constructs a command object given the expression to replacedert
     */
    public C_replacedert(IExpr expr) {
        formula = expr;
    }

    /**
     * Returns the replacederted formula
     */
    @Override
    public IExpr expr() {
        return formula;
    }

    /**
     * The command name
     */
    public static final String commandName = "replacedert";

    /**
     * The command name
     */
    @Override
    public String commandName() {
        return commandName;
    }

    /**
     * The formula to replacedert
     */
    protected IExpr formula;

    /**
     * Writes out the command in S-expression syntax using the given printer
     */
    public void write(Printer p) throws IOException, IVisitor.VisitorException {
        p.writer().append("(" + commandName + " ");
        formula.accept(p);
        p.writer().append(")");
    }

    /**
     * Parses the arguments of the command, producing a new command instance
     */
    static public /*@Nullable*/
    C_replacedert parse(Parser p) throws IOException, ParserException {
        IExpr expr = p.parseExpr();
        if (expr == null)
            return null;
        return new C_replacedert(expr);
    }

    @Override
    public IResponse execute(ISolver solver) {
        return solver.replacedertExpr(formula);
    }

    @Override
    public <T> T accept(IVisitor<T> v) throws IVisitor.VisitorException {
        return v.visit(this);
    }
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public IExists exists(List<IDeclaration> declarations, IExpr predicate) {
    if (!declarations.isEmpty()) {
        return expressionFactory().exists(declarations, predicate);
    }
    throw new IllegalStateException("Can not build an IExpr.IExists statement without declarations");
}

19 View Complete Implementation : QF_AUFLIA.java
Copyright MIT License
Author : mechtaev
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
    noQuantifiers(expression);
    if (!isLinearInteger(expression))
        throw new IVisitor.VisitorException("Integer expressions must be linear in this logic", expression.pos());
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public IFcnExpr disjunctionExpression(IExpr... elements) {
    return expression(or(), asList(elements));
}

19 View Complete Implementation : C_assert.java
Copyright MIT License
Author : mechtaev
/**
 * Parses the arguments of the command, producing a new command instance
 */
static public /*@Nullable*/
C_replacedert parse(Parser p) throws IOException, ParserException {
    IExpr expr = p.parseExpr();
    if (expr == null)
        return null;
    return new C_replacedert(expr);
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public Ireplacedert replacedertion(IExpr expression) {
    return commandFactory().replacedertCommand(expression);
}

19 View Complete Implementation : QF_BV.java
Copyright MIT License
Author : mechtaev
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public IForall forall(List<IDeclaration> declarations, IExpr predicate) {
    if (!declarations.isEmpty()) {
        return expressionFactory().forall(declarations, predicate);
    }
    throw new IllegalStateException("Can not build an IExpr.IForall statement without declarations");
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public IFcnExpr notExpression(IExpr subexpression) {
    return expression(not(), subexpression);
}

19 View Complete Implementation : QF_UF.java
Copyright MIT License
Author : mechtaev
@Override
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
    noQuantifiers(expression);
}

19 View Complete Implementation : SMTLibScriptSolution.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public clreplaced SMTLibScriptSolution implements Enumeration<Map<String, String>> {

    public SMTLibScriptSolution(SMTLib smtlib, IScript script, Collection<? extends IExpr> variables) {
        this.smtlib = smtlib;
        this.script = script;
        this.variables = variables.toArray(new IExpr[variables.size()]);
    }

    @Override
    public boolean hasMoreElements() {
        IResponse response = script().execute(solver());
        boolean hasMoreElements = response.isOK() && isSatisfiable();
        if (!hasMoreElements) {
            shutdownSolver();
        }
        return hasMoreElements;
    }

    @Override
    public Map<String, String> nextElement() {
        IResponse response = solver().get_value(variables());
        Map<IExpr, IExpr> solution = solutionFrom(response);
        updateScript(solution);
        shutdownSolver();
        return StringLibrary.replacedtringMap(solution);
    }

    protected Map<IExpr, IExpr> solutionFrom(IResponse response) {
        Map<IExpr, IExpr> solution = MetaMap.newHashMap();
        try {
            Seq seq = (Seq) response;
            for (ISexpr expr : seq.sexprs()) {
                Seq nestedSeq = (Seq) expr;
                IToken<?> key = (IToken<?>) nestedSeq.sexprs().get(0);
                String value = nestedSeq.sexprs().get(1).toString();
                IExpr valueExpr = smtlib().parserFor(value).parseExpr();
                solution.put((IExpr) key, valueExpr);
            }
        } catch (IndexOutOfBoundsException ioobe) {
            ioobe.printStackTrace();
        } catch (ClreplacedCastException cce) {
            cce.printStackTrace();
        } catch (ParserException pe) {
            pe.printStackTrace();
        }
        return solution;
    }

    protected boolean isSatisfiable() {
        return solver().check_sat().equals(org.smtlib.impl.Response.SAT);
    }

    protected void updateScript(Map<IExpr, IExpr> solution) {
        List<IExpr> values = variablesAndValues(solution);
        IExpr visitedSolution = smtlib().notExpression(smtlib().conjunctionExpression(values));
        ICommand skipVisitedSolution = smtlib().replacedertion(visitedSolution);
        script().commands().add(skipVisitedSolution);
    }

    protected List<IExpr> variablesAndValues(Map<IExpr, IExpr> solution) {
        List<IExpr> values = MetaList.newLinkedList();
        for (IExpr expr : solution.keySet()) {
            IExpr valueExpr = smtlib().equalsExpression(expr, solution.get(expr));
            values.add(valueExpr);
        }
        return values;
    }

    private SMTLib smtlib() {
        return smtlib;
    }

    private IScript script() {
        return script;
    }

    private IExpr[] variables() {
        return variables;
    }

    private ISolver solver() {
        if (solver == null) {
            solver = SolverFactory.instance().newSolver();
        }
        return solver;
    }

    private void shutdownSolver() {
        solver().exit();
        solver = null;
    }

    private ISolver solver;

    private SMTLib smtlib;

    private IScript script;

    private IExpr[] variables;
}

19 View Complete Implementation : AUFLIA.java
Copyright MIT License
Author : mechtaev
@Override
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
    if (!isLinearInteger(expression)) {
        throw new IVisitor.VisitorException("Integer expressions must be linear in this logic", expression.pos());
    }
}

19 View Complete Implementation : ALL.java
Copyright MIT License
Author : mechtaev
@Override
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
}

19 View Complete Implementation : Logic.java
Copyright MIT License
Author : mechtaev
public void noFunctions(IExpr.IIdentifier id, List<ISort> argSorts, ISort resultSort, /*@Nullable*/
IExpr definition) throws IVisitor.VisitorException {
    // May declare constants, but not functions without definitions
    if (argSorts.size() != 0 && definition == null)
        throw new IVisitor.VisitorException("Declarations of uninterpreted functions are not allowed in this logic", id.pos());
}

19 View Complete Implementation : QF_LRA.java
Copyright MIT License
Author : mechtaev
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
    noQuantifiers(expression);
    super.validExpression(expression);
}

19 View Complete Implementation : SMTLib.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
public IFcnExpr conjunctionExpression(IExpr... elements) {
    return expression(and(), asList(elements));
}

18 View Complete Implementation : ALL.java
Copyright MIT License
Author : mechtaev
@Override
public void checkFcnDeclaration(IExpr.IIdentifier id, List<ISort> argSorts, ISort resultSort, /*@Nullable*/
IExpr definition) throws IVisitor.VisitorException {
}

18 View Complete Implementation : LRA.java
Copyright MIT License
Author : mechtaev
@Override
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
    IVisitor<Void> visitor = new IVisitor.TreeVisitor<Void>() {

        @Override
        public Void visit(IExpr.IFcnExpr e) throws IVisitor.VisitorException {
            if (e.args().size() == 2) {
                String fcn = e.head().toString();
                if (fcn.equals("*")) {
                    if (!(isConst(e.args().get(0)) || isConst(e.args().get(1)))) {
                        // FIXME + smt.defaultPrinter.toString(e),e.pos());
                        throw new IVisitor.VisitorException("The expression must be linear: ", e.pos());
                    }
                } else if (fcn.equals("/")) {
                    if (!(isConst(e.args().get(0)) && isConst(e.args().get(1)))) {
                        // FIXME + smt.defaultPrinter.toString(e),e.pos());
                        throw new IVisitor.VisitorException("The expression must be linear: ", e.pos());
                    }
                } else {
                    // checks all the arguments
                    super.visit(e);
                }
            } else {
                // checks all the arguments
                super.visit(e);
            }
            return (Void) null;
        }
    };
    expression.accept(visitor);
}

18 View Complete Implementation : LRA.java
Copyright MIT License
Author : mechtaev
@Override
public void checkFcnDeclaration(IExpr.IIdentifier id, List<ISort> argSorts, ISort resultSort, /*@Nullable*/
IExpr definition) throws IVisitor.VisitorException {
    // May declare constants, but not functions without definitions
    noFunctions(id, argSorts, resultSort, definition);
}

18 View Complete Implementation : QF_ABV.java
Copyright MIT License
Author : mechtaev
public void checkFcnDeclaration(IExpr.IIdentifier id, List<ISort> argSorts, ISort resultSort, /*@Nullable*/
IExpr definition) throws IVisitor.VisitorException {
    // May declare constants, but not functions without definitions
    noFunctions(id, argSorts, resultSort, definition);
}

18 View Complete Implementation : QF_AUFLIA.java
Copyright MIT License
Author : mechtaev
public void checkFcnDeclaration(IExpr.IIdentifier id, List<ISort> argSorts, ISort resultSort, /*@Nullable*/
IExpr definition) throws IVisitor.VisitorException {
}

18 View Complete Implementation : QF_AX.java
Copyright MIT License
Author : mechtaev
public void checkFcnDeclaration(IExpr.IIdentifier id, List<ISort> argSorts, ISort resultSort, /*@Nullable*/
IExpr definition) throws IVisitor.VisitorException {
    noFunctions(id, argSorts, resultSort, definition);
}

18 View Complete Implementation : QF_IDL.java
Copyright MIT License
Author : mechtaev
public void validExpression(IExpr expression) throws IVisitor.VisitorException {
    noQuantifiers(expression);
    IVisitor<Void> visitor = new IVisitor.TreeVisitor<Void>() {

        public Void visit(IExpr.IFcnExpr e) throws IVisitor.VisitorException {
            String fcn = e.head().toString();
            if (fcn.equals("and") || fcn.equals("or") || fcn.equals("not") || fcn.equals("=>"))
                return (Void) null;
            if (fcn.equals("=") || fcn.equals("distinct"))
                return (Void) null;
            // FIXME - need to restrict = and distinct for Int
            if (e.args().size() == 2 && (fcn.equals(">=") || fcn.equals(">") || fcn.equals("<") || fcn.equals("<="))) {
                IExpr lhs = e.args().get(0);
                IExpr rhs = e.args().get(1);
                if (lhs instanceof ISymbol) {
                    if (rhs instanceof ISymbol) {
                        return (Void) null;
                    } else {
                        // FIXME + smt.defaultPrinter.toString(e),e.pos());
                        throw new IVisitor.VisitorException("rhs must be a symbol if the lhs is a symbol", e.pos());
                    }
                }
                IExpr.IFcnExpr f = (IExpr.IFcnExpr) lhs;
                if (!(lhs instanceof IExpr.IFcnExpr)) {
                    // FIXME + smt.defaultPrinter.toString(e),e.pos());
                    throw new IVisitor.VisitorException("lhs must be a symbol or a difference", e.pos());
                }
                fcn = f.head().toString();
                if (!fcn.equals("-")) {
                    // FIXME + smt.defaultPrinter.toString(e),e.pos());
                    throw new IVisitor.VisitorException("lhs must be a symbol or a difference", e.pos());
                }
                if (f.args().get(0) instanceof ISymbol && f.args().get(1) instanceof ISymbol) {
                // OK
                } else {
                    // FIXME + smt.defaultPrinter.toString(e),e.pos());
                    throw new IVisitor.VisitorException("differences must be difference of symbols", e.pos());
                }
                if (rhs instanceof INumeral) {
                // OK
                } else if (!(rhs instanceof IExpr.IFcnExpr)) {
                    // FIXME + smt.defaultPrinter.toString(e),e.pos());
                    throw new IVisitor.VisitorException("The rhs must be an integer", e.pos());
                } else {
                    f = (IExpr.IFcnExpr) rhs;
                    if (f.args().size() != 1 || f.head().toString().equals("-")) {
                        // FIXME + smt.defaultPrinter.toString(e),e.pos());
                        throw new IVisitor.VisitorException("The rhs must be an integer", e.pos());
                    } else if (f.args().get(0) instanceof INumeral) {
                    // OK
                    } else {
                        // FIXME + smt.defaultPrinter.toString(e),e.pos());
                        throw new IVisitor.VisitorException("The rhs must be an integer", e.pos());
                    }
                }
            // } else {
            // throw new IVisitor.VisitorException("Invalid operation in IDL logic", e.pos()); // FIXME + smt.defaultPrinter.toString(e),e.pos());
            }
            return (Void) null;
        }
    };
    expression.accept(visitor);
}

18 View Complete Implementation : QF_UFBV.java
Copyright MIT License
Author : mechtaev
public void checkFcnDeclaration(IExpr.IIdentifier id, List<ISort> argSorts, ISort resultSort, /*@Nullable*/
IExpr definition) throws IVisitor.VisitorException {
// May declare constants and functions
}

18 View Complete Implementation : QF_UFLIA.java
Copyright MIT License
Author : mechtaev
public void checkFcnDeclaration(IExpr.IIdentifier id, List<ISort> argSorts, ISort resultSort, /*@Nullable*/
IExpr definition) throws IVisitor.VisitorException {
// May declare constants or functions
}

18 View Complete Implementation : Solver_simplify.java
Copyright MIT License
Author : mechtaev
// Pure overrides are redundant
// @Override
// public IResponse declare_sort(Ideclare_sort cmd) {
// return super.declare_sort(cmd);
// }
// 
// @Override
// public IResponse define_fun(Idefine_fun cmd){
// return super.define_fun(cmd);
// }
// 
// @Override
// public IResponse define_sort(Idefine_sort cmd){
// return super.define_sort(cmd);
// }
// These are all currently unsupported
// @Override
// public IResponse get_proof() {
// return smtConfig.responseFactory.error("The get-proof command is not implemented for simplify"); // FIXME - get-proof for simplify
// }
// 
// @Override
// public IResponse get_value(IExpr ... terms) {
// return smtConfig.responseFactory.error("The get-value command is not implemented for simplify"); // FIXME - get-value for simplify
// }
// 
// @Override
// public IResponse get_replacedignment() {
// return smtConfig.responseFactory.error("The get-replacedignment command is not implemented for simplify"); // FIXME - get-replacedignment for simplify
// }
// 
// @Override
// public IResponse get_unsat_core() {
// return smtConfig.responseFactory.error("The get-proof command is not implemented for simplify"); // FIXME - get-proof for simplify
// }
@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 {
        // FIXME - report all errors?
        if (!tc.result.isEmpty())
            return tc.result.get(0);
    }
    // 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();
}

18 View Complete Implementation : TypeChecker.java
Copyright MIT License
Author : mechtaev
public static List<IResponse> check(SymbolTable symTable, IExpr expr, Map<IExpr, ISort> typemap, List<IExpr.IDeclaration> decls) {
    TypeChecker f = new TypeChecker(symTable, typemap);
    try {
        for (IExpr.IDeclaration d : decls) {
            f.currentScope.put(d.parameter(), new Variable(d.parameter(), d.sort(), null));
        }
        ISort topsort = expr.accept(f);
        if (topsort != null && !topsort.isBool()) {
            f.error("Expected an expression with Bool sort, not " + topsort, expr.pos());
        }
        try {
            symTable.logicInUse.validExpression(expr);
        } catch (IVisitor.VisitorException e) {
            f.error(e.getMessage(), e.pos());
        }
    } catch (IVisitor.VisitorException e) {
        f.error("Visitor Exception: " + e.getMessage(), e.pos());
    } catch (Exception e) {
        f.error("INTERNAL ERROR: Exception while checking sort abbreviation: " + e.getMessage(), expr.pos());
    }
    return f.result;
}

18 View Complete Implementation : TypeChecker.java
Copyright MIT License
Author : mechtaev
/**
 * The main entry point for type-checking an IExpr (expected to be a Bool)
 */
public static List<IResponse> check(SymbolTable symTable, IExpr expr) {
    TypeChecker f = new TypeChecker(symTable, null);
    try {
        ISort topsort = expr.accept(f);
        if (topsort != null && !topsort.isBool()) {
            f.error("Expected an expression with Bool sort, not " + topsort, expr.pos());
        }
        try {
            symTable.logicInUse.validExpression(expr);
        } catch (IVisitor.VisitorException e) {
            f.error(e.getMessage(), e.pos());
        }
    } catch (IVisitor.VisitorException e) {
        f.error("Visitor Exception: " + e.getMessage(), e.pos());
    } catch (Exception e) {
        f.error("INTERNAL ERROR: Exception while checking sort abbreviation: " + e.getMessage(), expr.pos());
    }
    return f.result;
}

18 View Complete Implementation : TypeChecker.java
Copyright MIT License
Author : mechtaev
/**
 * Utility method for printing an expression, using the default printer
 */
protected String pr(IExpr e) {
    return smtConfig.defaultPrinter.toString(e);
}

18 View Complete Implementation : TypeChecker.java
Copyright MIT License
Author : mechtaev
/**
 * The main entry point for type-checking an IExpr (expected to be a Bool)
 */
public static List<IResponse> check(SymbolTable symTable, IExpr expr, Map<IExpr, ISort> typemap) {
    TypeChecker f = new TypeChecker(symTable, typemap);
    symTable.push();
    try {
        ISort topsort = expr.accept(f);
        if (topsort != null && !topsort.isBool()) {
            f.error("Expected an expression with Bool sort, not " + topsort, expr.pos());
        }
        try {
            symTable.logicInUse.validExpression(expr);
        } catch (IVisitor.VisitorException e) {
            f.error(e.getMessage(), e.pos());
        }
        if (f.result.isEmpty())
            symTable.merge();
    } catch (IVisitor.VisitorException e) {
        f.error("Visitor Exception: " + e.getMessage(), e.pos());
    } catch (Exception e) {
        f.error("INTERNAL ERROR: Exception while checking sort abbreviation: " + e.getMessage(), expr.pos());
    } finally {
        if (!f.result.isEmpty())
            symTable.pop();
    }
    return f.result;
}

18 View Complete Implementation : ExpressionConverter.java
Copyright MIT License
Author : mechtaev
public static Expression convert(IExpr expr) {
    Expression expression = null;
    try {
        expression = expr.accept(new RepairableTranslator());
    } catch (IVisitor.VisitorException e) {
        e.printStackTrace();
    }
    return expression;
}

18 View Complete Implementation : LibraryConstraint.java
Copyright GNU General Public License v2.0
Author : SpoonLabs
private IExpr specificationOf(OperatorLocationVariable<?> operator) {
    List<ISymbol> parameters = subexpressionSymbolsOf((List) operator.parameterLocationVariables());
    IExpr specification = smtlib().expression(operator.objectTemplate().smtlibIdentifier(), parameters);
    return binaryOperation(subexpressionSymbolOf(operator), equality(), specification);
}