--  An enclave within its fence (proof-enclaves.md 4): its pointers in the private part, a
--  limited private type with a ghost model and an invariant, its variable an Abstract_State,
--  and calls out of it that reach none of its objects and are given them only as `in`
package Counted
  with Annotate => (Verada, Enclave), Abstract_State => State
is
   type List is limited private
     with Default_Initial_Condition => Length (List) = 0;
   type Reader is access function (L : List) return Natural;
   function Model (L : List) return Natural with Ghost;
   function Length (L : List) return Natural
     with Post => Length'Result = Model (L);
   procedure Push (L : in out List; X : Integer)
     with Global => (In_Out => State), Pre => Length (L) < Natural'Last - 1, Post => Length (L) = Length (L)'Old + 1;
   procedure Show (L : List; R : not null Reader);
   function Pushes return Natural with Global => State;
private
   type Node;
   type Node_Ptr is access Node;
   type Node is record
      Value : Integer;
      Next : Node_Ptr;
   end record;
   type List is limited record
      Head : Node_Ptr;
      Count : Natural := 0;
   end record
     with Type_Invariant => List.Count < Natural'Last;
   function Model (L : List) return Natural is (L.Count);
   function Length (L : List) return Natural is (L.Count);
end Counted;
