/** If this solution is solved and satisfiable, evaluates the given expression and returns an A4TupleSet, a java Integer, or a java Boolean. */
public Object eval(Expr expr) throws Err {
try {
if (expr instanceof Sig) return eval((Sig)expr);
if (expr instanceof Field) return eval((Field)expr);
if (!solved) throw new ErrorAPI("This solution is not yet solved, so eval() is not allowed.");
if (eval==null) throw new ErrorAPI("This solution is unsatisfiable, so eval() is not allowed.");
if (expr.ambiguous && !expr.errors.isEmpty()) expr = expr.resolve(expr.type(), null);
if (!expr.errors.isEmpty()) throw expr.errors.pick();
Object result = TranslateAlloyToKodkod.alloy2kodkod(this, expr);
if (result instanceof IntExpression) return eval.evaluate((IntExpression)result);
if (result instanceof Formula) return eval.evaluate((Formula)result);