Interface Substitution
- All Superinterfaces:
fr.inria.rules.dlgpemodel.api.sentences.IPrintable, fr.inria.rules.dlgpemodel.api.elems.ISubstitution<Variable,Term>
- All Known Implementing Classes:
SubstitutionImpl
-
Field Summary
FieldsFields inherited from interface fr.inria.rules.dlgpemodel.api.sentences.IPrintable
WRITER -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a mapping from the specified variable into the specified image to this substitution.The aggregation of a substitution is more complex that just add a new mapping for a new variable.default <R> RcreateImageOf(Substitutable<R> substitutable) Applies this substitution to a Substitutable object.default <R> RcreateImageOf(Substitutable<R> substitutable, boolean evaluate) Applies this substitution to a Substitutable object.getImageOfVariable(Variable variable) Retrieves the term mapped to a specific variable in this substitution.booleanisEmpty()Indicates whether this substitution contains no mappings.booleanisExtensionOf(Substitution other) Checks whether another substitution is included in this one.booleanIndicates whether this substitution is injective.booleanIndicates whether this substitution can be inverted as a substitution.keys()Get the domain of this substitution.limitedTo(Collection<Variable> vars) Returns a copy of this substitution restricted to the supplied variables.default booleanChecks whether all mapped variables resolve to constants.default booleanmapsToConstantsOnly(Collection<Variable> variableSet) Checks whether the selected variables resolve to constants.merged(Substitution other) Two substitutions can be merged iff for each key in common, the image is the samebooleanmergeInPlace(Substitution other) Attempts to mergeotherinto this substitution in-place.Returns the range terms of this substitution.voidRemove the given variable affectation from this substitutiondefault voidRemove the variables that are sent into themselvestoMap()Convert the substitution to a mapMethods inherited from interface fr.inria.rules.dlgpemodel.api.sentences.IPrintable
toDLGPE
-
Field Details
-
EMPTY
Shared empty substitution instance.
-
-
Method Details
-
createImageOf
Applies this substitution to a Substitutable object.- Type Parameters:
R- the type of the substitutable object- Parameters:
substitutable- the object to apply the substitution onevaluate- if true forces the evaluation of terms that are evaluable functions- Returns:
- the substituted object of type R
-
createImageOf
Applies this substitution to a Substitutable object.- Type Parameters:
R- the type of the substitutable object- Parameters:
substitutable- the object to apply the substitution on- Returns:
- the substituted object of type R
-
getImageOfVariable
Retrieves the term mapped to a specific variable in this substitution. -
keys
Collection<Variable> keys()Get the domain of this substitution. -
add
-
merged
Two substitutions can be merged iff for each key in common, the image is the same- Parameters:
other- a substitution- Returns:
- a new substitution being the merge of this one and the other one or an empty optional if the substitutions are not compatible
-
mergeInPlace
Attempts to mergeotherinto this substitution in-place.A merge succeeds iff, for every variable appearing in both substitutions, the two images are equal. – On success : the new (compatible) bindings from
otherare copied insidethisand the method returnstrue. – On failure :thisis left exactly in its original state and the method returnsfalse.Side effects : the operation mutates
thisonly when it succeeds.- Parameters:
other- a substitution to merge- Returns:
trueon success,falseif a conflict is detected
-
limitedTo
Returns a copy of this substitution restricted to the supplied variables.- Parameters:
vars- variables to limit to- Returns:
- a new substitution identical to this one but limited to a subset of variables
-
isExtensionOf
Checks whether another substitution is included in this one.- Parameters:
other- a substitution- Returns:
- true iff the other substitution is included into this one
-
aggregated
The aggregation of a substitution is more complex that just add a new mapping for a new variable. Especially, it does not conserve the domain and codomain. It chooses a representative term for each connected component by successive application of the mapping. For example, if the current substitution is {X -> Y, Z -> U} and you add a mapping {Y -> 'a', Z -> V}, the result is {Y -> 'a', X -> 'a', Z -> V, U -> V} or {Y -> 'a', X -> 'a', U -> Z, V -> Z} or {Y -> 'a', X -> 'a', Z -> U, V -> U}.- Parameters:
s- the substitution to aggregate with- Returns:
- the aggregated substitution or an empty optional if it is not possible
-
remove
Remove the given variable affectation from this substitution- Parameters:
v- a variable
-
isEmpty
boolean isEmpty()Indicates whether this substitution contains no mappings.- Returns:
- true iff this substitution is empty
-
mapsToConstantsOnly
default boolean mapsToConstantsOnly()Checks whether all mapped variables resolve to constants.- Returns:
- true if the image of variables in this substitution are constants
-
mapsToConstantsOnly
Checks whether the selected variables resolve to constants.- Parameters:
variableSet- of variables which must map to constants only- Returns:
- true if the image of variables in this substitution are constants
-
isInjective
boolean isInjective()Indicates whether this substitution is injective.- Returns:
- true iff this substitution is injective
-
isInvertible
boolean isInvertible()Indicates whether this substitution can be inverted as a substitution.- Returns:
- true iff the inverse of this substitution is a substitution
-
rangeTerms
-
removeIdentity
default void removeIdentity()Remove the variables that are sent into themselves -
toMap
-