Class Utilities

java.lang.Object
edu.tufts.hrilab.fol.util.Utilities

public class Utilities extends Object
  • Constructor Details

    • Utilities

      public Utilities()
  • Method Details

    • actionToProlog

      public static Term actionToProlog(Term t)
      Transforms action variables to prolog variables
      Parameters:
      t - term
      Returns:
      modified term
    • prologToAction

      public static Variable prologToAction(Variable v)
      Transforms prolog variables to action variables
      Parameters:
      v - variable
      Returns:
      action variable name
    • createAndPredicate

      public static Predicate createAndPredicate(List<Predicate> predicates)
      Create conjunctive "and" predicate with the list of predicates as the arguments.
      Parameters:
      predicates -
      Returns:
    • isNumeric

      public static boolean isNumeric(Object value)
      Checks if value's toString is an integer, long, float, or double.
      Parameters:
      value -
      Returns:
    • isFullyTyped

      public static boolean isFullyTyped(Term term)
      Checks if all arguments are typed. If there are nested Terms, only the Term's arguments need to be typed (i.e., not the Term itself).
      Parameters:
      term -
      Returns:
    • equalsIgnoreType

      public static boolean equalsIgnoreType(Symbol s1, Symbol s2)
      Checks if s1 and s2 are equal, but ignores the type of
      Parameters:
      s1 -
      s2 -
      Returns:
    • predicatesMatch

      public static boolean predicatesMatch(List<? extends Term> list1, List<? extends Term> list2)
      Determine if both lists of Predicates match. Variable names are allowed to mismatch as long as their types and values are the same (or empty/null). Order doesn't matter.
      Parameters:
      list1 -
      list2 -
      Returns:
    • predicatesMatch

      public static boolean predicatesMatch(Term t1, Term t2)
      Determine if two Predicates match. Variable names are allowed to mismatch as long as their types and values are the same (or empty/null).
      Parameters:
      t1 - Term
      t2 - Term
      Returns:
    • containsAllPredicates

      public static boolean containsAllPredicates(List<? extends Term> list1, List<? extends Term> list2)
      Check if list1 contains all of list2's Terms.
      Parameters:
      list1 -
      list2 -
      Returns:
    • getUnboundVariables

      public static List<Variable> getUnboundVariables(List<? extends Symbol> symbols)
      Convenience method for getUnboundVariables(Symbol s, Set<Variable> vars).
      Parameters:
      symbols - List of Symbols
      Returns:
      List of unbound Variables
    • getUnboundVariables

      public static List<Variable> getUnboundVariables(Symbol s)
      Convenience method for getUnboundVariables(Symbol s, Set<Variable> vars).
      Parameters:
      s - Symbol
      Returns:
      Set of unbound Variables
    • getUnboundVariables

      public static void getUnboundVariables(Symbol s, List<Variable> vars)
      Collect all unbound Variables (i.e., with no/null value). This recursively checks through nested Symbols and also through Variables bound to Variables.
      Parameters:
      s - Symbol
      vars - non-null set of Variables