Class InferenceSystem<T extends InferredValue<T>>
- java.lang.Object
-
- it.unive.lisa.analysis.lattices.FunctionalLattice<M,Identifier,T>
-
- it.unive.lisa.analysis.nonrelational.VariableLift<InferenceSystem<T>,ValueExpression,T>
-
- it.unive.lisa.analysis.nonrelational.inference.InferenceSystem<T>
-
- Type Parameters:
T
- the type ofInferredValue
in this inference system
- All Implemented Interfaces:
BaseLattice<InferenceSystem<T>>
,Lattice<InferenceSystem<T>>
,ScopedObject<InferenceSystem<T>>
,SemanticDomain<InferenceSystem<T>,ValueExpression,Identifier>
,ValueDomain<InferenceSystem<T>>
,ValueOracle
,StructuredObject
,java.lang.Iterable<java.util.Map.Entry<Identifier,T>>
public class InferenceSystem<T extends InferredValue<T>> extends VariableLift<InferenceSystem<T>,ValueExpression,T> implements ValueDomain<InferenceSystem<T>>
An inference system that model standard derivation systems. An inference system is aVariableLift
that works onInferredValue
s, and that exposes an execution state (getExecutionState()
).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
FunctionalLattice.FunctionalLift<V extends Lattice<V>>, FunctionalLattice.KeyFunctionalLift<K>
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
function, lattice
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description InferenceSystem(InferenceSystem<T> other, T state)
Builds an inference system identical to the given one, except for the execution state that will be set to the given one.InferenceSystem(T domain)
Builds an empty inference system.InferenceSystem(T domain, java.util.Map<Identifier,T> function, T state)
Builds an environment containing the given mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InferenceSystem<T>
assign(Identifier id, ValueExpression expression, ProgramPoint pp, SemanticOracle oracle)
Yields a copy of this domain, whereid
has been assigned tovalue
.InferenceSystem<T>
assume(ValueExpression expression, ProgramPoint src, ProgramPoint dest, SemanticOracle oracle)
Yields a copy of this domain, modified by assuming that the given expression holds.InferenceSystem<T>
bottom()
Yields the bottom element of this lattice.boolean
equals(java.lang.Object obj)
T
eval(ValueExpression expression, ProgramPoint pp, SemanticOracle oracle)
Evaluates the given expression to an abstract value.T
getExecutionState()
Yields the execution state (also called program counter), that might change when evaluating an expression.InferenceSystem<T>
glbAux(InferenceSystem<T> other)
Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled.int
hashCode()
boolean
isBottom()
Yieldstrue
if and only if this object represents the bottom of the lattice.boolean
isTop()
Yieldstrue
if and only if this object represents the top of the lattice.boolean
lessOrEqualAux(InferenceSystem<T> other)
Yieldstrue
if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.InferenceSystem<T>
lubAux(InferenceSystem<T> other)
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.InferenceSystem<T>
mk(T lattice, java.util.Map<Identifier,T> function)
Builds a instance of this class from the given lattice instance and the given mapping.InferenceSystem<T>
narrowingAux(InferenceSystem<T> other)
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled.StructuredRepresentation
representation()
Yields aStructuredRepresentation
of the information contained in this object's instance.InferenceSystem<T>
smallStepSemantics(ValueExpression expression, ProgramPoint pp, SemanticOracle oracle)
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.InferenceSystem<T>
top()
Yields the top element of this lattice.InferenceSystem<T>
wideningAux(InferenceSystem<T> other)
Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class it.unive.lisa.analysis.nonrelational.VariableLift
forgetIdentifier, forgetIdentifiersIf, knowsIdentifier, lubKeys, popScope, pushScope, satisfies, stateOfUnknown
-
Methods inherited from class it.unive.lisa.analysis.lattices.FunctionalLattice
functionalLift, getKeys, getMap, getOtDefault, getState, getValues, glbKeys, iterator, mkNewFunction, putState, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.BaseLattice
glb, lessOrEqual, lub, narrowing, widening
-
Methods inherited from interface it.unive.lisa.analysis.ScopedObject
popScope, pushScope
-
Methods inherited from interface it.unive.lisa.analysis.SemanticDomain
forgetIdentifier, forgetIdentifiers, forgetIdentifiersIf, getAllDomainInstances, getDomainInstance, knowsIdentifier, satisfies
-
Methods inherited from interface it.unive.lisa.analysis.value.ValueDomain
applyReplacement
-
-
-
-
Constructor Detail
-
InferenceSystem
public InferenceSystem(T domain)
Builds an empty inference system.- Parameters:
domain
- a singleton instance to be used during semantic operations to retrieve top and bottom values
-
InferenceSystem
public InferenceSystem(InferenceSystem<T> other, T state)
Builds an inference system identical to the given one, except for the execution state that will be set to the given one.- Parameters:
other
- the inference system to copystate
- the new execution state
-
InferenceSystem
public InferenceSystem(T domain, java.util.Map<Identifier,T> function, T state)
Builds an environment containing the given mapping. If function isnull
, the new environment is the top environment iflattice.isTop()
holds, and it is the bottom environment iflattice.isBottom()
holds.- Parameters:
domain
- a singleton instance to be used during semantic operations to retrieve top and bottom valuesfunction
- the function representing the mapping contained in the new environment; can benull
state
- the execution state after the last computed expression
-
-
Method Detail
-
mk
public InferenceSystem<T> mk(T lattice, java.util.Map<Identifier,T> function)
Description copied from class:FunctionalLattice
Builds a instance of this class from the given lattice instance and the given mapping.- Specified by:
mk
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Parameters:
lattice
- an instance of lattice to be used during semantic operations to retrieve top and bottom valuesfunction
- the function representing the mapping contained in the new environment; can benull
- Returns:
- a new instance of this class
-
assign
public InferenceSystem<T> assign(Identifier id, ValueExpression expression, ProgramPoint pp, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, whereid
has been assigned tovalue
.- Specified by:
assign
in interfaceSemanticDomain<InferenceSystem<T extends InferredValue<T>>,ValueExpression,Identifier>
- Parameters:
id
- the identifier to assign the value toexpression
- the expression to assignpp
- the program point that where this operation is being evaluatedoracle
- the oracle for inter-domain communication- Returns:
- a copy of this domain, modified by the assignment
- Throws:
SemanticException
- if an error occurs during the computation
-
getExecutionState
public T getExecutionState()
Yields the execution state (also called program counter), that might change when evaluating an expression.- Returns:
- the execution state
-
smallStepSemantics
public InferenceSystem<T> smallStepSemantics(ValueExpression expression, ProgramPoint pp, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.- Specified by:
smallStepSemantics
in interfaceSemanticDomain<InferenceSystem<T extends InferredValue<T>>,ValueExpression,Identifier>
- Parameters:
expression
- the expression whose semantics need to be computedpp
- the program point that where this operation is being evaluatedoracle
- the oracle for inter-domain communication- Returns:
- a copy of this domain, modified accordingly to the semantics of
expression
- Throws:
SemanticException
- if an error occurs during the computation
-
assume
public InferenceSystem<T> assume(ValueExpression expression, ProgramPoint src, ProgramPoint dest, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, modified by assuming that the given expression holds. It is required that the returned domain is in relation with this one. A safe (but imprecise) implementation of this method can always returnthis
.- Specified by:
assume
in interfaceSemanticDomain<InferenceSystem<T extends InferredValue<T>>,ValueExpression,Identifier>
- Parameters:
expression
- the expression to assume to hold.src
- the program point that where this operation is being evaluated, corresponding to the one that generated the given expressiondest
- the program point where the execution will move after the expression has been assumedoracle
- the oracle for inter-domain communication- Returns:
- the (optionally) modified copy of this domain
- Throws:
SemanticException
- if an error occurs during the computation
-
eval
public T eval(ValueExpression expression, ProgramPoint pp, SemanticOracle oracle) throws SemanticException
Evaluates the given expression to an abstract value.- Parameters:
expression
- the expression to evaluatepp
- the program point where the evaluation happensoracle
- the oracle for inter-domain communication- Returns:
- the abstract result of the evaluation
- Throws:
SemanticException
- if an error happens during the evaluation
-
top
public InferenceSystem<T> top()
Description copied from interface:Lattice
Yields the top element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isTop()
uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isTop()
accordingly to provide a coherent test.- Specified by:
top
in interfaceLattice<T extends InferredValue<T>>
- Returns:
- the top element
-
bottom
public InferenceSystem<T> bottom()
Description copied from interface:Lattice
Yields the bottom element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isBottom()
uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isBottom()
accordingly to provide a coherent test.- Specified by:
bottom
in interfaceLattice<T extends InferredValue<T>>
- Returns:
- the bottom element
-
isTop
public boolean isTop()
Description copied from class:FunctionalLattice
Yieldstrue
if and only if this object represents the top of the lattice. The default implementation of this method uses reference equality betweenthis
and the value returned byLattice.top()
, thus assuming that the top element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.
By default, a functional lattice is the top lattice if the underlying lattice'sisTop()
holds and its function isnull
.- Specified by:
isTop
in interfaceLattice<T extends InferredValue<T>>
- Overrides:
isTop
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Returns:
true
if this is the top of the lattice
-
isBottom
public boolean isBottom()
Description copied from class:FunctionalLattice
Yieldstrue
if and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality betweenthis
and the value returned byLattice.bottom()
, thus assuming that the bottom element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.
By default, a functional lattice is the top lattice if the underlying lattice'sisBottom()
holds and its function isnull
.- Specified by:
isBottom
in interfaceLattice<T extends InferredValue<T>>
- Overrides:
isBottom
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Returns:
true
if this is the bottom of the lattice
-
lubAux
public InferenceSystem<T> lubAux(InferenceSystem<T> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
lubAux
in interfaceBaseLattice<T extends InferredValue<T>>
- Overrides:
lubAux
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Parameters:
other
- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
wideningAux
public InferenceSystem<T> wideningAux(InferenceSystem<T> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
BaseLattice.lubAux(BaseLattice)
, and is thus safe for finite lattices and ACC ones.- Specified by:
wideningAux
in interfaceBaseLattice<T extends InferredValue<T>>
- Overrides:
wideningAux
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Parameters:
other
- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
glbAux
public InferenceSystem<T> glbAux(InferenceSystem<T> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
glbAux
in interfaceBaseLattice<T extends InferredValue<T>>
- Overrides:
glbAux
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Parameters:
other
- the other lattice element- Returns:
- the greatest lower bound between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
narrowingAux
public InferenceSystem<T> narrowingAux(InferenceSystem<T> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
BaseLattice.glbAux(BaseLattice)
, and is thus safe for finite lattices and DCC ones.- Specified by:
narrowingAux
in interfaceBaseLattice<T extends InferredValue<T>>
- Overrides:
narrowingAux
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Parameters:
other
- the other lattice element- Returns:
- the narrowing between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
lessOrEqualAux
public boolean lessOrEqualAux(InferenceSystem<T> other) throws SemanticException
Description copied from interface:BaseLattice
Yieldstrue
if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
lessOrEqualAux
in interfaceBaseLattice<T extends InferredValue<T>>
- Overrides:
lessOrEqualAux
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Parameters:
other
- the other lattice element- Returns:
true
if and only if that condition holds- Throws:
SemanticException
- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceBaseLattice<T extends InferredValue<T>>
- Overrides:
hashCode
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceBaseLattice<T extends InferredValue<T>>
- Overrides:
equals
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
-
representation
public StructuredRepresentation representation()
Description copied from interface:StructuredObject
Yields aStructuredRepresentation
of the information contained in this object's instance.- Specified by:
representation
in interfaceStructuredObject
- Overrides:
representation
in classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>
- Returns:
- the representation
-
-