--  The library's doubly linked list (Verada.Containers.Linked_Lists, a proof enclave, E2d): its
--  operations proved whole, the library's own file proved with the program, and a list that
--  ends cleared, so that no cell leaks
with Ada.Text_IO; use Ada.Text_IO;
with Verada.Containers.Linked_Lists;
procedure Main is
   package Int_Lists is new Verada.Containers.Linked_Lists (Integer);
   use Int_Lists;
   L : List;
   X : Integer;
begin
   Append (L, 1);
   Append (L, 2);
   Append (L, 3);
   pragma Assert (Length (L) = 3 and then Last_Element (L) = 3 and then First_Element (L) = 1);
   Remove_Last (L, X);
   pragma Assert (X = 3 and then Length (L) = 2);
   Prepend (L, 0);
   declare
      --  (the steps from the contracts to the new first element: the list before is the
      --  list after with X in front)
      Before : constant Element_Sequences.Sequence := Model (L) with Ghost;
   begin
      pragma Assert (Element_Sequences.Get (Before, 1) = 0 and then Element_Sequences.Get (Before, 2) = 1);
      Remove_First (L, X);
      pragma Assert (Element_Sequences.Get (Model (L), 1) = Element_Sequences.Get (Before, 2));
   end;
   pragma Assert (X = 0 and then First_Element (L) = 1);
   Put_Line (Integer'Image (X) & Natural'Image (Length (L)) & Integer'Image (Last_Element (L)));
end Main;
