Class InferenceSystem<T extends InferredValue<T>>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<F>
-
- it.unive.lisa.analysis.FunctionalLattice<M,Identifier,T>
-
- it.unive.lisa.analysis.nonrelational.Environment<InferenceSystem<T>,ValueExpression,T>
-
- it.unive.lisa.analysis.nonrelational.inference.InferenceSystem<T>
-
- Type Parameters:
T- the type ofInferredValuein this inference system
- All Implemented Interfaces:
Lattice<InferenceSystem<T>>,SemanticDomain<InferenceSystem<T>,ValueExpression,Identifier>,ValueDomain<InferenceSystem<T>>,java.lang.Iterable<java.util.Map.Entry<Identifier,T>>
public class InferenceSystem<T extends InferredValue<T>> extends Environment<InferenceSystem<T>,ValueExpression,T> implements ValueDomain<InferenceSystem<T>>
An inference system that model standard derivation systems (e.g., types systems, small step semantics, big step semantics, ...). An inference system is anEnvironmentthat work onInferredValues, and that exposes the last inferred value (getInferredValue()) and the execution state (getExecutionState()).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface it.unive.lisa.analysis.SemanticDomain
SemanticDomain.Satisfiability
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.analysis.FunctionalLattice
function, lattice
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description InferenceSystem(T domain)Builds an empty inference system.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected InferenceSystem<T>assignAux(Identifier id, ValueExpression value, java.util.Map<Identifier,T> function, T eval, ProgramPoint pp)Auxiliary function ofEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)that is invoked after the evaluation of the expression.InferenceSystem<T>bottom()Yields the bottom element of this lattice.protected InferenceSystem<T>copy()Copies this environment.TgetExecutionState()Yields the execution state (also called program counter), that might change when evaluating an expression.TgetInferredValue()Yields the inferred value of the lastSymbolicExpressionhandled by this domain, either throughEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)orsmallStepSemantics(ValueExpression, ProgramPoint).booleanlessOrEqualAux(InferenceSystem<T> other)Yieldstrueif 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.java.lang.Stringrepresentation()Yields a textual representation of the content of this domain's instance.InferenceSystem<T>smallStepSemantics(ValueExpression expression, ProgramPoint pp)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.Environment
assign, assume, assumeAux, forgetIdentifier, isBottom, isTop, satisfies, toString
-
Methods inherited from class it.unive.lisa.analysis.FunctionalLattice
equals, getKeys, getState, hashCode, iterator, mkNewFunction
-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lub, widening
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.Lattice
isBottom, isTop, lessOrEqual, lub, widening
-
Methods inherited from interface it.unive.lisa.analysis.SemanticDomain
assign, assume, forgetIdentifier, forgetIdentifiers, satisfies
-
Methods inherited from interface it.unive.lisa.analysis.ValueDomain
applySubstitution
-
-
-
-
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
-
-
Method Detail
-
getExecutionState
public T getExecutionState()
Yields the execution state (also called program counter), that might change when evaluating an expression.- Returns:
- the execution state
-
getInferredValue
public T getInferredValue()
Yields the inferred value of the lastSymbolicExpressionhandled by this domain, either throughEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)orsmallStepSemantics(ValueExpression, ProgramPoint).- Returns:
- the value inferred for the last expression
-
copy
protected InferenceSystem<T> copy()
Description copied from class:EnvironmentCopies this environment. The function of the returned environment must be a (shallow) copy of the one of the given environment.- Specified by:
copyin classEnvironment<InferenceSystem<T extends InferredValue<T>>,ValueExpression,T extends InferredValue<T>>- Returns:
- a copy of the given environment
-
assignAux
protected InferenceSystem<T> assignAux(Identifier id, ValueExpression value, java.util.Map<Identifier,T> function, T eval, ProgramPoint pp)
Description copied from class:EnvironmentAuxiliary function ofEnvironment.assign(Identifier, SymbolicExpression, ProgramPoint)that is invoked after the evaluation of the expression.- Specified by:
assignAuxin classEnvironment<InferenceSystem<T extends InferredValue<T>>,ValueExpression,T extends InferredValue<T>>- Parameters:
id- the identifier that has been assignedvalue- the expression that has been evaluated and assignedfunction- a copy of the current function, where theidhas been assigned toevaleval- the abstract value that is the result of the evaluation ofvaluepp- the program point that where this operation is being evaluated- Returns:
- a new instance of this environment containing the given function,
obtained by assigning
idtoeval
-
smallStepSemantics
public InferenceSystem<T> smallStepSemantics(ValueExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression.- Specified by:
smallStepSemanticsin 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 evaluated- Returns:
- a copy of this domain, modified accordingly to the semantics of
expression - Throws:
SemanticException- if an error occurs during the computation
-
top
public InferenceSystem<T> top()
Description copied from interface:LatticeYields 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:
topin interfaceLattice<T extends InferredValue<T>>- Returns:
- the top element
-
bottom
public InferenceSystem<T> bottom()
Description copied from interface:LatticeYields 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:
bottomin interfaceLattice<T extends InferredValue<T>>- Returns:
- the bottom element
-
lubAux
public InferenceSystem<T> lubAux(InferenceSystem<T> other) throws SemanticException
Description copied from class:BaseLatticePerforms 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:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Overrides:
lubAuxin 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
-
wideningAux
public InferenceSystem<T> wideningAux(InferenceSystem<T> other) throws SemanticException
Description copied from class:BaseLatticePerforms 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:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Overrides:
wideningAuxin classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>- Parameters:
other- the other lattice element- Returns:
- the least upper bound
- Throws:
SemanticException- if an error occurs during the computation
-
lessOrEqualAux
public boolean lessOrEqualAux(InferenceSystem<T> other) throws SemanticException
Description copied from class:BaseLatticeYieldstrueif 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:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Overrides:
lessOrEqualAuxin classFunctionalLattice<InferenceSystem<T extends InferredValue<T>>,Identifier,T extends InferredValue<T>>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
representation
public java.lang.String representation()
Description copied from interface:SemanticDomainYields a textual representation of the content of this domain's instance.- Specified by:
representationin interfaceSemanticDomain<InferenceSystem<T extends InferredValue<T>>,ValueExpression,Identifier>- Overrides:
representationin classEnvironment<InferenceSystem<T extends InferredValue<T>>,ValueExpression,T extends InferredValue<T>>- Returns:
- the textual representation
-
-