@Override
  public Result solve(Expression<Boolean> f, Valuation result) {
    CoralExpressionGenerator root = new CoralExpressionGenerator();
    final Env[] sol = new Env[1];
    try {
      final PC pc = root.generateAssertion(f);
      logger.fine("Coral solving...");
      sol[0] = coralSolver.getCallable(pc).call();
    } catch (Exception e) {
      logger.severe("Coral threw exception. Returning DONT_KNOW");
      return Result.DONT_KNOW;
    }
    // TODO: not sure why the solution is found as the first element in the Env[]...
    Env coralSol = sol[0];
    Result coralRes = convertCoralRes(coralSol.getResult());

    if (result != null
        && coralRes == Result.SAT) { // result is requested besides satisfiability check
      HashMap<Variable<?>, SymLiteral> varMap = root.getVariables();
      for (Variable<?> v : varMap.keySet()) {
        SymNumber value = coralSol.getValue(varMap.get(v));

        // These checks make my eyes bleed
        if ((v.getType() instanceof FloatType)
            && !(value instanceof SymFloat)) { // TODO: ensure this is sound. It seems like a patch
          Float floatVal = value.evalNumber().floatValue();
          result.setParsedValue(v, floatVal.toString());
        } else if ((v.getType() instanceof DoubleType) && !(value instanceof SymDouble)) {
          Double dVal = value.evalNumber().doubleValue();
          result.setParsedValue(v, dVal.toString());
        } else if ((v.getType() instanceof SInt32Type) && !(value instanceof SymInt)) {
          Integer iVal = value.evalNumber().intValue();
          result.setParsedValue(v, iVal.toString());
        } else if ((v.getType() instanceof SInt64Type) && !(value instanceof SymLong)) {
          Long lVal = value.evalNumber().longValue();
          result.setParsedValue(v, lVal.toString());
        } else // This is the default case which should be the most frequent one
        result.setParsedValue(v, value.toString());
      }
      logger.finer("Satisfiable, valuation " + result);
    }
    return coralRes;
  }
 @Override
 public <E> String visit(Variable<E> v, HashMap<Class, String> data) {
   String name = v.getName();
   String type = data.get(v.getType().getClass());
   return TransitionEncoding.variable + ":" + name + ":" + type + ";";
 }