Class TypeHelper
java.lang.Object
tools.refinery.interpreter.matchers.planning.helpers.TypeHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic Set
<TypeJudgement> getDirectJudgements
(Set<PConstraint> constraints, IQueryMetaContext context) Gets direct judgements reported by constraints.static Map
<PVariable, Set<TypeJudgement>> inferUnaryTypes
(Set<PConstraint> constraints, IQueryMetaContext context) Infers unary type information for variables, based on the given constraints.inferUnaryTypesFor
(Iterable<PVariable> variables, Map<PVariable, Set<TypeJudgement>> typeMap) Collects the type constraints for the specified collection of variables.inferUnaryTypesFor
(Iterable<PVariable> variables, Set<PConstraint> constraints, IQueryMetaContext context) Collects the type constraints for the specified collection of variables.static Set
<TypeJudgement> subsumeTypes
(Set<TypeJudgement> subsumableTypes, Set<TypeJudgement> subsumingTypes, IQueryMetaContext context) Calculates a remainder set of types from a larger set, that are not subsumed by a given set of subsuming types.static Set
<TypeJudgement> typeClosure
(Set<TypeJudgement> preclosedBaseSet, Set<TypeJudgement> delta, IQueryMetaContext context) Calculates the closure of a set of type judgements (with respect to supertyping), where the closure has been calculated before for a given base set, but not for a separate delta set.static Set
<TypeJudgement> typeClosure
(Set<TypeJudgement> typesToClose, IQueryMetaContext context) Calculates the closure of a set of type judgements, with respect to supertyping.
-
Method Details
-
inferUnaryTypesFor
public static Map<PVariable,Set<IInputKey>> inferUnaryTypesFor(Iterable<PVariable> variables, Set<PConstraint> constraints, IQueryMetaContext context) Collects the type constraints for the specified collection of variables. The type constraints consist of the constraints directly enforced on the variable itself, plus all of those that the given variable is unified with through equalities.- Parameters:
variables
- the variables in questionconstraints
- the constraints in the pattern bodycontext
- the query meta context- Returns:
- the mapping from variable to set of type constraints
- Since:
- 1.6
-
inferUnaryTypesFor
public static Map<PVariable,Set<IInputKey>> inferUnaryTypesFor(Iterable<PVariable> variables, Map<PVariable, Set<TypeJudgement>> typeMap) Collects the type constraints for the specified collection of variables. The type constraints consist of the constraints directly enforced on the variable itself, plus all of those that the given variable is unified with through equalities. The method accepts a type map which is the result of the basic type inference from theinvalid reference
TypeHelper.inferUnaryTypes
- Parameters:
variables
- the variables in questiontypeMap
- the type map of inference results- Returns:
- the mapping from variable to set of type constraints
- Since:
- 1.6
-
inferUnaryTypes
public static Map<PVariable,Set<TypeJudgement>> inferUnaryTypes(Set<PConstraint> constraints, IQueryMetaContext context) Infers unary type information for variables, based on the given constraints. Subsumptions are not taken into account.- Parameters:
constraints
- the set of constraints to extract type info from
-
getDirectJudgements
public static Set<TypeJudgement> getDirectJudgements(Set<PConstraint> constraints, IQueryMetaContext context) Gets direct judgements reported by constraints. No closure is applied yet. -
typeClosure
public static Set<TypeJudgement> typeClosure(Set<TypeJudgement> typesToClose, IQueryMetaContext context) Calculates the closure of a set of type judgements, with respect to supertyping.- Returns:
- the set of all type judgements in typesToClose and all their direct and indirect supertypes
-
typeClosure
public static Set<TypeJudgement> typeClosure(Set<TypeJudgement> preclosedBaseSet, Set<TypeJudgement> delta, IQueryMetaContext context) Calculates the closure of a set of type judgements (with respect to supertyping), where the closure has been calculated before for a given base set, but not for a separate delta set.Precondition: the set (typesToClose MINUS delta) is already closed w.r.t. supertyping.
- Returns:
- the set of all type judgements in typesToClose and all their direct and indirect supertypes
- Since:
- 1.6
-
subsumeTypes
public static Set<TypeJudgement> subsumeTypes(Set<TypeJudgement> subsumableTypes, Set<TypeJudgement> subsumingTypes, IQueryMetaContext context) Calculates a remainder set of types from a larger set, that are not subsumed by a given set of subsuming types.- Parameters:
subsumableTypes
- a set of types from which some may be implied by the subsuming typessubsumingTypes
- a set of types that may imply some of the subsuming types- Returns:
- the collection of types in subsumableTypes that are NOT identical to or supertypes of any type in subsumingTypes.
-