--  A proof enclave (proof-enclaves.md): its body shares cells between Prev and Next, which
--  ownership would forbid (F7 turns it off for its access types); the body is trusted
--  until the heap engine proves it (EN15), with a warning on every build
package DLists
  with Annotate => (Verada, Enclave)
is
   type List is limited private
     with Default_Initial_Condition => Length (List) = 0;
   function Model (L : List) return Natural with Ghost;
   function Length (L : List) return Natural
     with Post => Length'Result = Model (L);
   procedure Append (L : in out List; X : Integer)
     with Pre => Length (L) < Natural'Last - 1, Post => Length (L) = Length (L)'Old + 1;
private
   type Node;
   type Node_Ptr is access Node;
   type Node is record
      Value : Integer;
      Prev, Next : Node_Ptr;
   end record;
   type List is limited record
      Head, Tail : 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 DLists;
