/**
   * Executes a CycL instruction represented by a String.
   *
   * @param instruction a String who represents the CyL formula.
   * @return the result of the conversation with Cyc in a String format. Converse directly Cyt term
   *     for false in "FALSE" and Cyc term for true in "TRUE".
   */
  public String executeCycL(String instruction) throws CycSupportError {
    String result = null;

    createAccess();

    try {
      // Execute the CycL formula and convert its result into a String.
      result = (myAccess.converseObject(instruction)).toString();
      if (result.equals(CYC_FALSE)) {
        result = FALSE;
      } else if (trimBracketAndQuote(result).equals(CYC_FALSE)) {
        // converseObject, al posto di TRUE, ritorna una CycList con NIL
        // all'interno, come (NIL)
        result = TRUE;
      }
      checkAndStore(instruction, result);
      return result;
    } catch (CycApiException ce) {
      checkAndStore(instruction, "Cyc communication error!");
      throw new CycSupportError("Cyc communication error!");
    } catch (UnknownHostException oe) {
      checkAndStore(instruction, "Unable to find OpenCyc!");
      throw new CycSupportError("Unable to find OpenCyc!");
    } catch (IOException ioe) {
      checkAndStore(instruction, "I/O error!");
      throw new CycSupportError("I/O error!");
    } catch (Exception e) {
      checkAndStore(instruction, "Unknow error!");
      throw new CycSupportError("Unknow error!");
    }
  }
  @SuppressWarnings("unchecked")
  public String executeRandomCycL(String formula) throws CycSupportError {

    createAccess();

    try {
      Object res = myAccess.converseObject(formula);

      // This will store the result
      String result = res.toString();

      if (result.equals(CYC_FALSE)) {
        result = FALSE;
        checkAndStore(formula, result);
      } else if (trimBracketAndQuote(result).equals(CYC_FALSE)) {
        result = TRUE;
        checkAndStore(formula, result);
      } else if (res instanceof CycList) {
        checkAndStore(formula, result);
        CycList cl = ((CycList) res).randomPermutation();

        ArrayList results = getVariables(cl);
        if (results.size() > 0) {
          result = getContentVariable(results.get(0).toString());
        } else result = UNKNOWN;
      }
      return result;
    } catch (CycApiException ce) {
      ce.printStackTrace();
      checkAndStore(formula, "Cyc communication error!");
      throw new CycSupportError("Cyc communication error!");
    } catch (UnknownHostException oe) {
      checkAndStore(formula, "Unable to find OpenCyc!");
      throw new CycSupportError("Unable to find OpenCyc!");
    } catch (IOException ioe) {
      checkAndStore(formula, "I/O error!");
      throw new CycSupportError("I/O error!");
    } catch (Exception e) {
      checkAndStore(formula, "Unknow error!");
      throw new CycSupportError("Unknow error!");
    }
  }