|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.deri.iris.evaluation.topdown.TopDownHelper
public class TopDownHelper
Collection of helper functions for top-down evaluation strategies
| Constructor Summary | |
|---|---|
TopDownHelper()
|
|
| Method Summary | |
|---|---|
static ITuple |
createTupleFromQueryAndVariableMap(IQuery query,
Map<IVariable,ITerm> variableMap)
Deprecated. |
static Map<IVariable,ITerm> |
createVariableMapFromTupleAndQuery(IQuery query,
ITuple branchTuple)
Given a query and a tuple, create a variable map with the corresponding variable mappings for each variable in the query. |
static String |
getDebugPrefix(int recursionDepth,
boolean inNegationAsFailureFlip)
Creates a debug prefix for nice output |
static IRelation |
getFullSubgoalRelation(IQuery query,
IQuery subQuery,
Map<IVariable,ITerm> substitution,
IRelation relationFromSubtree)
|
static IRelation |
getFullSubgoalRelation(IQuery query,
QueryWithSubstitution qws,
IRelation relationFromSubtree)
Creates a relation by combining the relation from subgoal evaluation and the variable bindings of the current query. |
static Map<IVariable,ITerm> |
getVariableMapForVariableRenaming(IRule rule,
IQuery query)
Creates a variable map that will replace variable ?X with ?X1 if the variable occurs in both tuples. |
static List<IVariable> |
getVariables(IQuery query)
Get a list of variables, with no duplicates |
static List<IVariable> |
getVariables(ITuple tuple)
Get a list of variables in the right order, with no duplicates |
static boolean |
match(ILiteral lit1,
ILiteral lit2)
Checks if two literals match |
static boolean |
match(ILiteral queryLiteral,
IPredicate factPredicate)
Wrapper. |
static boolean |
match(IPredicate pred1,
IPredicate pred2)
Checks if two predicates match |
static Map<IVariable,ITerm> |
mergeSubstitutions(Map<IVariable,ITerm> deeperMap,
Map<IVariable,ITerm> higherMap)
|
static void |
printDebug(String msg,
int recursionDepth)
|
static void |
printDebug(String msg,
int recursionDepth,
boolean inNegationAsFailureFlip)
|
static List<QueryWithSubstitution> |
processBuiltin(IQuery query,
ILiteral selectedQueryLiteral,
IAtom queryLiteralAtom)
Process a builtin atom. |
static IRule |
reMapVariablesInRule(IRule rule,
Map<IVariable,ITerm> variableMap)
Does variable re-mapping. |
static IRule |
replaceVariablesInRule(IRule rule,
Map<IVariable,ITerm> variableMap)
Replaces all variables in a rule with the mapped ones. |
static ITuple |
resolveTuple(ILiteral literal,
Map<IVariable,ITerm> variableMap)
|
static ITuple |
resolveTuple(IQuery query,
Map<IVariable,ITerm> variableMap)
If variableMap contains variable mappings of variables
that are contained in query, those mappings will be
resolved and a proper tuple will be created and returned. |
static ITuple |
resolveTuple(List<IVariable> varList,
Map<IVariable,ITerm> variableMap,
boolean partialResult)
|
static IQuery |
substituteRuleHeadWithBody(IQuery query,
ILiteral selectedLiteral,
IRule rule)
Replaces a rule head in a Query with the rule body. |
static ILiteral |
substituteVariablesInToLiteral(ILiteral literal,
Map<IVariable,ITerm> variableMap)
Replaces Variables in a Literal, and gives back the substituted Literal |
static IQuery |
substituteVariablesInToQuery(IQuery query,
Map<IVariable,ITerm> variableMap)
Replaces variables in a query. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public TopDownHelper()
| Method Detail |
|---|
public static IQuery substituteRuleHeadWithBody(IQuery query,
ILiteral selectedLiteral,
IRule rule)
throws EvaluationException
EvaluationException is thrown.
To avoid intersection, do an occur check first.
query - a query element that contains the rule headselectedLiteral - the selected literalrule - a rule element
EvaluationException
public static IQuery substituteVariablesInToQuery(IQuery query,
Map<IVariable,ITerm> variableMap)
query - a query elementvariableMap - a map of variables and terms
variableMap
public static ILiteral substituteVariablesInToLiteral(ILiteral literal,
Map<IVariable,ITerm> variableMap)
literal - a Literal elementvariableMap - a map of variables and terms
variableMap
public static boolean match(IPredicate pred1,
IPredicate pred2)
pred1 - a predicate elementpred2 - a second predicate element
true if the predicates have the same name and arity, false otherwise.
public static boolean match(ILiteral lit1,
ILiteral lit2)
lit1 - a literal elementlit2 - a second literal element
true if the predicates of the literals have the same name and arity, false otherwise.
public static boolean match(ILiteral queryLiteral,
IPredicate factPredicate)
match(IPredicate pred1, IPredicate pred2).
queryLiteral - factPredicate -
true if the predicates of the literals have the same name and arity, false otherwise.public static List<IVariable> getVariables(IQuery query)
query - the query
public static List<IVariable> getVariables(ITuple tuple)
tuple - the ITuple tuple
public static Map<IVariable,ITerm> getVariableMapForVariableRenaming(IRule rule,
IQuery query)
throws RuleUnsafeException
rule - a rulequery - a query
RuleUnsafeException - thrown if the rule contains unbound variables
public static Map<IVariable,ITerm> createVariableMapFromTupleAndQuery(IQuery query,
ITuple branchTuple)
query - the querybranchTuple - the tuple
query
@Deprecated
public static ITuple createTupleFromQueryAndVariableMap(IQuery query,
Map<IVariable,ITerm> variableMap)
query - the queryvariableMap - a map containing the variable mappings
public static ITuple resolveTuple(IQuery query,
Map<IVariable,ITerm> variableMap)
variableMap contains variable mappings of variables
that are contained in query, those mappings will be
resolved and a proper tuple will be created and returned.
e.g.
query = ?- q(?X)
variableMap = ?X = 1
return = (1)
query - a IQuery which can contain variablesvariableMap - map that stores variable mappings
public static ITuple resolveTuple(ILiteral literal,
Map<IVariable,ITerm> variableMap)
public static ITuple resolveTuple(List<IVariable> varList,
Map<IVariable,ITerm> variableMap,
boolean partialResult)
public static Map<IVariable,ITerm> mergeSubstitutions(Map<IVariable,ITerm> deeperMap,
Map<IVariable,ITerm> higherMap)
public static IRule replaceVariablesInRule(IRule rule,
Map<IVariable,ITerm> variableMap)
rule - a rulevariableMap - a variable map
public static IRule reMapVariablesInRule(IRule rule,
Map<IVariable,ITerm> variableMap)
replaceVariablesInRule(IRule, Map)
rule - a rulevariableMap - a variable map
public static String getDebugPrefix(int recursionDepth,
boolean inNegationAsFailureFlip)
recursionDepth - depth of recursion (0 = root)inNegationAsFailureFlip - true is this a NAF tree, false otherwise
public static void printDebug(String msg,
int recursionDepth)
public static void printDebug(String msg,
int recursionDepth,
boolean inNegationAsFailureFlip)
public static IRelation getFullSubgoalRelation(IQuery query,
QueryWithSubstitution qws,
IRelation relationFromSubtree)
query - a queryqws - a query with proper substitution, which is a subgoal of queryrelationFromSubtree - relation returned by evaluation the subgoal qws
query
public static IRelation getFullSubgoalRelation(IQuery query,
IQuery subQuery,
Map<IVariable,ITerm> substitution,
IRelation relationFromSubtree)
public static List<QueryWithSubstitution> processBuiltin(IQuery query,
ILiteral selectedQueryLiteral,
IAtom queryLiteralAtom)
throws EvaluationException
query - the whole queryselectedQueryLiteral - the selected literalqueryLiteralAtom -
EvaluationException - on failure
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||