Class FormulaUtil

java.lang.Object
com.articulate.sigma.FormulaUtil

public class FormulaUtil extends Object
Created by sserban on 2/17/15.
  • Constructor Details

    • FormulaUtil

      public FormulaUtil()
  • Method Details

    • antecedent

      public static String antecedent(Formula f)
      Get the antecedent of an implication. If not a rule, return null
    • consequent

      public static String consequent(Formula f)
      Get the consequent of an implication. If not a rule, return null
    • toProlog

      public static String toProlog(Formula f)
      Must check that this is a simple clause before calling!
    • formatCollection

      public static String formatCollection(Collection<Formula> c)
    • getLiteralWithPredAndRowVar

      public static String getLiteralWithPredAndRowVar(String pred, Formula f)
      Returns:
      a string consisting of a literal with the given predicate that also contains a row variable, or null otherwise
    • isDoc

      public static boolean isDoc(Formula f)
      Test whether a formula is suitable for theorem proving or if it's just a documentation statement
    • getPermutations

      public static List<int[]> getPermutations(int size, BiPredicate<Integer,Integer> validateFn)
      Generates all permutations of the given size which are valid according to the given callback function.
    • kifListToArrayList

      public static List<String> kifListToArrayList(String kifListAsString)
      Returns a new ArrayList formed by extracting in order the top-level members of kifListAsString, which is assumed to be the String representation of a SUO-KIF (LISP) list.
      Parameters:
      kifListAsString - A SUO-KIF list represented as a String
      Returns:
      ArrayList
    • treeReplace

      public static String treeReplace(String oldPattern, String newTerm, String tree)
      Performs a depth-first search of tree, replacing all terms matching oldPattern with newTerm.
      Parameters:
      oldPattern - A regular expression pattern to be matched against terms in tree
      newTerm - A String to replace terms matching oldPattern
      tree - A String representing a SUO-KIF Formula (list)
      Returns:
      A new tree (String), with all occurrences of terms matching oldPattern replaced by newTerm
    • removeAnswerClause

      public static String removeAnswerClause(Formula f)
      Factory method for the memo map
    • createFormulaMatchMemoMapKey

      public static FormulaUtil.FormulaMatchMemoMapKey createFormulaMatchMemoMapKey(String s1, String s2)
      Factory method for the memo map
    • runTest

      public static void runTest()
    • sortBySourceFile

      public static void sortBySourceFile(List<Formula> forms)
    • showHelp

      public static void showHelp()
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException