-
Notifications
You must be signed in to change notification settings - Fork 30
Description
Summary
This RFC proposes a new Ada aspect, Model_Of, intended for use by analysis tools to associate additional specification information with an existing subprogram. The aspect allows tools to link a model subprogram, declared separately in a specification package, to an original subprogram, and to treat any aspects applied to the model as if they were applied to the modeled subprogram for analysis purposes.
Suppose an existing package contains a subprogram that cannot be modified:
package Math is
function Sqrt (X : Float) return Float;
end Math;An analysis tool may require a more robust specification. A separate specification package can be written:
package Math_Models is
function Sqrt (X : Float) return Float
with
Model_Of => Math.Sqrt,
Pre => X >= 0.0,
Post => Sqrt'Result >= 0.0;
end Math_Models;Motivation
Analysis tools such as formal verifiers, abstract interpreters, or linters often require additional semantic information that cannot always be directly embedded in production source code. Reasons include:
- The original subprogram belongs to third-party or legacy code.
- The original code must remain free of tool-specific annotations.
- Alternative or abstract specifications are needed for verification or modeling purposes.
Currently, there is no standardized mechanism in Ada to express that one subprogram declaration models another, nor to propagate aspects from a model declaration to the original subprogram in a tool-recognizable way.
The Model_Of aspect addresses this gap by enabling the declaration of a subprogram that mimics an existing one and explicitly links to it. Analysis tools can then use this relationship to augment or replace the original specification without modifying the original source.
Caveats and alternatives
- Introduces a concept that is meaningful only to analysis tools.
- Requires tools to implement additional consistency checks.
- May lead to fragmented specifications if overused.
However, not introducing this feature forces tools to rely on naming conventions, external configuration files, or source rewriting.