All Downloads are FREE. Search and download functionalities are using the official Maven repository.

TPTPWorld.ProofSummary Maven / Gradle / Ivy

Go to download

Sigma knowledge engineering system is an system for developing, viewing and debugging theories in first order logic. It works with Knowledge Interchange Format (KIF) and is optimized for the Suggested Upper Merged Ontology (SUMO) www.ontologyportal.org.

The newest version!
package TPTPWorld;

import java.util.*;
import java.io.*;
import tptp_parser.*;

public class ProofSummary {

  private static ArrayList extractLemmas (TPTPFormula formula, ArrayList conjectures, ArrayList lemmas) {
    for (TPTPFormula parent : formula.parent) {
      if (!lemmas.contains(parent) && !conjectures.contains(parent)) {
        lemmas.add(parent);
      }
    }
    for (TPTPFormula child : formula.child) {
      lemmas = extractLemmas(child, conjectures, lemmas);
    }
    return lemmas;
  }

  // identify all conjectures on the vine
  // future: store in a sorted set for faster search in extractLemmas
  private static ArrayList identifyConjectures (TPTPFormula formula, ArrayList conjectures) {
    conjectures.add(formula);
    for (TPTPFormula child : formula.child) {
      conjectures = identifyConjectures(child, conjectures);
    }
    return conjectures;
  }

  // given a conjecture: return the immediate lemmas in the vine
  public static ArrayList getLemmaVine (TPTPFormula conjecture) {
    ArrayList lemmas = new ArrayList();
    ArrayList conjectures = new ArrayList();

    if (conjecture == null) {
      return lemmas;
    }

    conjectures = identifyConjectures(conjecture, conjectures);
    for (TPTPFormula child : conjecture.child) {
      lemmas = extractLemmas(child, conjectures, lemmas);
    }
    return lemmas;    
  }

  public static void main (String args[]) throws Exception {
    TPTPParser.checkArguments(args);
    BufferedReader reader = TPTPParser.createReader(args[0]);
    TPTPParser parser = TPTPParser.parse(reader);   
    TPTPFormula conjecture = AnswerExtractor.extractVine(parser.ftable);
    if (conjecture == null) {
      System.out.println("% ERROR: No fof conjecture in proof -> no lemmas -> proof summary failed");
    }
    ArrayList lemmas = getLemmaVine(conjecture);
    if (lemmas.isEmpty()) {
      System.out.println("% Given a proof with a valid fof conjecture, no lemmas found in ProofSummary");
    }
    for (TPTPFormula lemma : lemmas) {
      System.out.println(lemma.fofify() + "\n");
    }    
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy