--  FP4: an object's footprint takes only its own cells and new ones
with Verada.Footprints;
package Stacks
  with Annotate => (Verada, Enclave)
is
   type Stack is limited private
     with Default_Initial_Condition => Size (Stack) = 0;
   function Model (S : Stack) return Natural with Ghost;
   function Size (S : Stack) return Natural
     with Post => Size'Result = Model (S);
   procedure Take (S : in out Stack; Other : Stack);
private
   type Node;
   type Node_Ptr is access Node;
   type Node is record
      Value : Integer;
      Next : Node_Ptr;
   end record;
   package Node_Cells is new Verada.Footprints (Node_Ptr);
   type Stack is limited record
      Top : Node_Ptr;
      Count : Natural := 0;
      Repr : Node_Cells.Cells := Node_Cells.Empty;
   end record
     with Type_Invariant => Stack.Top = null or else Node_Cells.Contains (Stack.Repr, Stack.Top);
   function Model (S : Stack) return Natural is (S.Count);
   function Size (S : Stack) return Natural is (S.Count);
end Stacks;
