B2018: an enclave type without a ghost Model or a Type_Invariant
Catalog status: active. Default severity: error. Stable name: enclave-model-missing. Family: Types and constraints.
Clients of a proof enclave reason about its objects through their models, never through their cells. Each limited private type that holds the enclave's pointers has a ghost function Model in the visible part, returning a value of a functional type (a number, a sequence, a map or a set), and a Type_Invariant on its full view, which every operation assumes of its parameters on entry and must keep.
Example (Vada)
package Lists
with Annotate => (Verada, Enclave)
is
type List is limited private; -- no Model, no invariant
function Length (L : List) return Natural;
private
...
type List is limited record
Head : Node_Ptr;
Count : Natural := 0;
end record;
end Lists;What to do (Vada)
Declare the model in the visible part and state the operations' postconditions on it, then give the full declaration an invariant:
function Model (L : List) return Natural with Ghost;
function Length (L : List) return Natural
with Post => Length'Result = Model (L);
private
...
type List is limited record
Head : Node_Ptr;
Count : Natural := 0;
end record
with Type_Invariant => List.Count < Natural'Last;Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See types and constraints, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.