Example #1
0
  /** *************************************************************** */
  public static void testParseProofStep() {

    String ps1 = "fof(c_0_5, axiom, (s__subclass(s__Artifact,s__Object)), c_0_3).";
    String ps2 =
        "fof(c_0_2, negated_conjecture,(~(?[X1]:(s__subclass(X1,s__Object)&~$answer(esk1_1(X1))))),"
            + "inference(assume_negation,[status(cth)],[inference(add_answer_literal,[status(thm)],[c_0_0, theory(answers)])])).";
    String ps3 =
        "cnf(c_0_14,negated_conjecture,($false), "
            + "inference(eval_answer_literal,[status(thm)], [inference(spm,[status(thm)],[c_0_12, c_0_13, theory(equality)]), theory(answers)]), ['proof']).";
    TPTP3ProofProcessor tpp = new TPTP3ProofProcessor();
    tpp.idTable.put("c_0_0", new Integer(0));
    tpp.idTable.put("c_0_3", new Integer(1));
    tpp.idTable.put("c_0_12", new Integer(2));
    tpp.idTable.put("c_0_13", new Integer(3));
    System.out.println(tpp.parseProofStep(ps1));
    System.out.println();
    System.out.println(tpp.parseProofStep(ps1));
    System.out.println();
    System.out.println(tpp.parseProofStep(ps3));
  }
Example #2
0
  /**
   * *************************************************************** Return a list of answers if E
   * finds bindings for wh- queries. Return "Proof Found" if E finds contradiction for boolean
   * queries.
   *
   * <p>For example, tuple_list = [[esk3_1(s__Org1_1)]|_] Output = [Org1_1]
   *
   * <p>tuple_list = [[esk3_0]|_] Output = [An instance of Human] (Human is the most specific type
   * for esk3_0 in the given proof)
   */
  public static ArrayList<String> parseAnswerTuples(String st, KB kb, FormulaPreprocessor fp) {

    ArrayList<String> answers = new ArrayList<>();
    TPTP3ProofProcessor tpp = TPTP3ProofProcessor.parseProofOutput(st, kb);
    if (tpp.bindings == null || tpp.bindings.isEmpty()) {
      if (tpp.proof != null && !tpp.proof.isEmpty()) {
        answers.add("Proof Found"); // for boolean queries
      }
      return answers;
    }
    return tpp.bindings;
  }
Example #3
0
  /**
   * *************************************************************** Compute binding and proof from
   * E's response
   */
  public static TPTP3ProofProcessor parseProofOutput(ArrayList<String> lines, KB kb) {

    TPTP3ProofProcessor tpp = new TPTP3ProofProcessor();
    try {
      boolean inProof = false;
      boolean finishAnswersTuple = false;
      String line;
      Iterator<String> it = lines.iterator();
      while (it.hasNext()) {
        line = it.next();
        if (line.indexOf("SZS output start") != -1) {
          inProof = true;
          line = it.next();
        }
        if (line.indexOf("SZS status") != -1) {
          tpp.status = line.substring(15);
        }
        if (line.indexOf("SZS answers") != -1) {
          if (!finishAnswersTuple) {
            tpp.processAnswers(line.substring(20).trim());
            finishAnswersTuple = true;
          }
        }
        if (inProof) {
          if (line.indexOf("SZS output end") != -1) {
            inProof = false;
          } else {
            ProofStep ps = tpp.parseProofStep(line);
            if (ps != null) {
              tpp.proof.add(ps);
            }
          }
        }
      }
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
    }
    // remove unnecessary steps, eg: conjectures, duplicate trues
    tpp.proof = ProofStep.removeUnnecessary(tpp.proof);
    tpp.proof = ProofStep.removeDuplicates(tpp.proof);

    // find types for skolem terms
    findTypesForSkolemTerms(tpp, kb);
    return tpp;
  }