Class TermPartition
java.lang.Object
fr.inria.rules.integraal.model.partition.Partition<Term>
fr.inria.rules.integraal.model.partition.TermPartition
- All Implemented Interfaces:
Substitutable<TermPartition>
Partition specialized for terms, with utilities tied to substitutions and rule validity.
- Author:
- Guillaume Pérution-Kihli, Florent Tornil
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty TermPartitionTermPartition(Substitution substitution) Creates the TermPartition induced by a substitution I.e., foreach variable v mapped to a term t through the substitution, v and t are in the same class, and the partition is the finest for this propertyTermPartition(Partition<Term> toCopy) Creates a new TermPartition, copying the given oneTermPartition(Collection<Set<Term>> partition) Creates a new TermPartition with the given classesTermPartition(Set<Term> initialElements) Creates a new TermPartition with the given elements, each in its own class -
Method Summary
Modifier and TypeMethodDescriptionapplySubstitution(Substitution substitution, boolean evaluate) Applies the given substitution to this object.Applies a substitution to every class of this partition.protected voidErase the memoized valuesbooleanexistsSeparatingStickyVariables(Set<Variable> sep, Rule rule) Checks whether this partition contains a separating sticky variable.getAssociatedSubstitution(FOQuery<?> context) Compute the substitution associated with this partition.getSeparatingStickyVariables(Set<Variable> sep, Rule rule) Returns the separating sticky variables induced by this partition.Get a substitution from variables of a class to their representative, if the term partition does not contain multiple constants in the same classgetTermPartitionRestrictedToVariables(Set<Variable> variables) Get a new term partition that contains all terms of this partition except the variables that are not from the set of variables in parameter.booleanChecks whether this partition is valid for the supplied rule.booleanTakes into account answer variables of a context query, preventing them to be associated with an existential variable of the ruleMethods inherited from class Partition
addClass, equals, getClass, getClasses, getElements, getRepresentative, hashCode, isEmpty, join, toString, unionMethods inherited from interface Substitutable
applySubstitution
-
Constructor Details
-
TermPartition
public TermPartition()Creates a new empty TermPartition -
TermPartition
-
TermPartition
Creates a new TermPartition with the given classes- Parameters:
partition- the initial elements represented as multiple partitions
-
TermPartition
Creates the TermPartition induced by a substitution I.e., foreach variable v mapped to a term t through the substitution, v and t are in the same class, and the partition is the finest for this property- Parameters:
substitution- the substitution to transform into a partition
-
TermPartition
-
-
Method Details
-
isValid
Checks whether this partition is valid for the supplied rule.- Parameters:
rule- a rule- Returns:
- false iff a class of the receiving partition contains two constants, or contains two existential variable of R, or contains a constant and an existential variable of R, or contains an existential variable of R and a frontier variable of R
-
isValid
Takes into account answer variables of a context query, preventing them to be associated with an existential variable of the rule- Parameters:
rule- a rulecontext- the query in which to test the validity- Returns:
- false iff a class of the receiving partition contains two constants, or contains two existential variable of R, or contains a constant and an existential variable of R, or contains an existential variable of R and a frontier variable of R, or an existential and an answer variable of the context
-
getSeparatingStickyVariables
Returns the separating sticky variables induced by this partition.- Parameters:
sep- the set of separating variablesrule- a rule- Returns:
- the subset of sep containing variables that are in the same class as an existential variable of rule.
-
existsSeparatingStickyVariables
-
getAssociatedSubstitution
Compute the substitution associated with this partition. This method computes a substitution by choosing one representative term by class. The representative is chosen for each class as : 1. The constant (if any) 2. The answer variable of the context (if any) 3. The variables of the context (if any) 4. A random term of the class
Return an empty optional if the partition contain two constants in the same class- Parameters:
context- a query for context (answer variables)- Returns:
- the substitution associated with this partition in the given context
-
createImageWith
Applies a substitution to every class of this partition.- Parameters:
s- a substitution- Returns:
- a new partition that represents this partition on which the given substitution have been applied
-
getSubstitution
Get a substitution from variables of a class to their representative, if the term partition does not contain multiple constants in the same class- Returns:
- an optional containing a substitution that represents the partition
-
eraseMemoizedValues
protected void eraseMemoizedValues()Description copied from class:PartitionErase the memoized values- Overrides:
eraseMemoizedValuesin classPartition<Term>
-
getTermPartitionRestrictedToVariables
Get a new term partition that contains all terms of this partition except the variables that are not from the set of variables in parameter. If there are compound terms, they will be in the partition only if their nested variables are in the set.- Parameters:
variables- the variables to keep in the restricted partition- Returns:
- a new term partition that contains all terms except the variable not in the set
-
applySubstitution
Description copied from interface:SubstitutableApplies the given substitution to this object.- Specified by:
applySubstitutionin interfaceSubstitutable<TermPartition>- Parameters:
substitution- the substitution to applyevaluate- whether evaluable subterms should be forced- Returns:
- a new instance with the substitution applied
-