Class SubstitutionImpl
java.lang.Object
fr.inria.rules.integraal.model.logicalElements.impl.SubstitutionImpl
- All Implemented Interfaces:
fr.inria.rules.dlgpemodel.api.elems.ISubstitution<Variable,Term>, fr.inria.rules.dlgpemodel.api.sentences.IPrintable, Substitution, Serializable
Default implementation of Substitution using a map
- Author:
- Florent Tornil, Guillaume Perution-Kihli
- See Also:
-
Field Summary
Fields inherited from interface fr.inria.rules.dlgpemodel.api.sentences.IPrintable
WRITERFields inherited from interface Substitution
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor using a HashMapCopy contructorSubstitutionImpl(Map<Variable, Term> associations) Constructor using a user-given map -
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.booleangetImageOfVariable(Variable variable) //////////////////////////////////////////////inthashCode()//////////////////////////////////////////////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.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 substitutiontoMap()Convert the substitution to a maptoString()Methods inherited from interface fr.inria.rules.dlgpemodel.api.sentences.IPrintable
toDLGPEMethods inherited from interface Substitution
createImageOf, createImageOf, mapsToConstantsOnly, mapsToConstantsOnly, removeIdentity
-
Constructor Details
-
SubstitutionImpl
public SubstitutionImpl()Default constructor using a HashMap -
SubstitutionImpl
-
SubstitutionImpl
-
-
Method Details
-
getImageOfVariable
//////////////////////////////////////////////- Specified by:
getImageOfVariablein interfacefr.inria.rules.dlgpemodel.api.elems.ISubstitution<Variable,Term> - Specified by:
getImageOfVariablein interfaceSubstitution- Parameters:
variable- the variable to substitute- Returns:
- the image of the variable
-
keys
Description copied from interface:SubstitutionGet the domain of this substitution.- Specified by:
keysin interfacefr.inria.rules.dlgpemodel.api.elems.ISubstitution<Variable,Term> - Specified by:
keysin interfaceSubstitution- Returns:
- the domain of this substitution.
-
add
Description copied from interface:SubstitutionAdds a mapping from the specified variable into the specified image to this substitution.- Specified by:
addin interfaceSubstitution- Parameters:
v- the keyt- the image
-
remove
Description copied from interface:SubstitutionRemove the given variable affectation from this substitution- Specified by:
removein interfaceSubstitution- Parameters:
v- a variable
-
isEmpty
public boolean isEmpty()Description copied from interface:SubstitutionIndicates whether this substitution contains no mappings.- Specified by:
isEmptyin interfaceSubstitution- Returns:
- true iff this substitution is empty
-
merged
Description copied from interface:SubstitutionTwo substitutions can be merged iff for each key in common, the image is the same- Specified by:
mergedin interfaceSubstitution- 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
Description copied from interface:SubstitutionAttempts 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.- Specified by:
mergeInPlacein interfaceSubstitution- Parameters:
other- a substitution to merge- Returns:
trueon success,falseif a conflict is detected
-
aggregated
Description copied from interface:SubstitutionThe 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}.- Specified by:
aggregatedin interfaceSubstitution- Parameters:
s- the substitution to aggregate with- Returns:
- the aggregated substitution or an empty optional if it is not possible
-
limitedTo
Description copied from interface:SubstitutionReturns a copy of this substitution restricted to the supplied variables.- Specified by:
limitedToin interfaceSubstitution- Parameters:
vars- variables to limit to- Returns:
- a new substitution identical to this one but limited to a subset of variables
-
isExtensionOf
Description copied from interface:SubstitutionChecks whether another substitution is included in this one.- Specified by:
isExtensionOfin interfaceSubstitution- Parameters:
other- a substitution- Returns:
- true iff the other substitution is included into this one
-
isInjective
public boolean isInjective()Description copied from interface:SubstitutionIndicates whether this substitution is injective.- Specified by:
isInjectivein interfaceSubstitution- Returns:
- true iff this substitution is injective
-
isInvertible
public boolean isInvertible()Description copied from interface:SubstitutionIndicates whether this substitution can be inverted as a substitution.- Specified by:
isInvertiblein interfaceSubstitution- Returns:
- true iff the inverse of this substitution is a substitution
-
rangeTerms
Description copied from interface:SubstitutionReturns the range terms of this substitution.- Specified by:
rangeTermsin interfaceSubstitution- Returns:
- all range term of the substitution
-
toMap
Description copied from interface:SubstitutionConvert the substitution to a map- Specified by:
toMapin interfaceSubstitution- Returns:
- A map that represents the substitution
-
hashCode
-
equals
-
toString
-