Package edu.tufts.hrilab.fol.util
Class Utilities
java.lang.Object
edu.tufts.hrilab.fol.util.Utilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Term
Transforms action variables to prolog variablesstatic boolean
containsAllPredicates
(List<? extends Term> list1, List<? extends Term> list2) Check if list1 contains all of list2's Terms.static Predicate
createAndPredicate
(List<Predicate> predicates) Create conjunctive "and" predicate with the list of predicates as the arguments.static boolean
equalsIgnoreType
(Symbol s1, Symbol s2) Checks if s1 and s2 are equal, but ignores the type ofConvenience method forgetUnboundVariables(Symbol s, Set<Variable> vars)
.static void
getUnboundVariables
(Symbol s, List<Variable> vars) Collect all unbound Variables (i.e., with no/null value).getUnboundVariables
(List<? extends Symbol> symbols) Convenience method forgetUnboundVariables(Symbol s, Set<Variable> vars)
.static boolean
isFullyTyped
(Term term) Checks if all arguments are typed.static boolean
Checks if value's toString is an integer, long, float, or double.static boolean
predicatesMatch
(Term t1, Term t2) Determine if two Predicates match.static boolean
predicatesMatch
(List<? extends Term> list1, List<? extends Term> list2) Determine if both lists of Predicates match.static Variable
Transforms prolog variables to action variables
-
Constructor Details
-
Utilities
public Utilities()
-
-
Method Details
-
actionToProlog
Transforms action variables to prolog variables- Parameters:
t
- term- Returns:
- modified term
-
prologToAction
Transforms prolog variables to action variables- Parameters:
v
- variable- Returns:
- action variable name
-
createAndPredicate
Create conjunctive "and" predicate with the list of predicates as the arguments.- Parameters:
predicates
-- Returns:
-
isNumeric
Checks if value's toString is an integer, long, float, or double.- Parameters:
value
-- Returns:
-
isFullyTyped
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
Checks if s1 and s2 are equal, but ignores the type of- Parameters:
s1
-s2
-- Returns:
-
predicatesMatch
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
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
- Termt2
- Term- Returns:
-
containsAllPredicates
Check if list1 contains all of list2's Terms.- Parameters:
list1
-list2
-- Returns:
-
getUnboundVariables
Convenience method forgetUnboundVariables(Symbol s, Set<Variable> vars)
.- Parameters:
symbols
- List of Symbols- Returns:
- List of unbound Variables
-
getUnboundVariables
Convenience method forgetUnboundVariables(Symbol s, Set<Variable> vars)
.- Parameters:
s
- Symbol- Returns:
- Set of unbound Variables
-
getUnboundVariables
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
- Symbolvars
- non-null set of Variables
-