--  Fuel (proof-enclaves.md 8.6), in an advisory run where what does not prove is checked as
--  the program runs: an enclave body that makes its list cyclic, and a
--  function that walks the list, stop with B6013 instead of recursing until the stack runs out
package Rings
  with Annotate => (Verada, Enclave)
is
   type Ring is limited private;
   function Model (R : Ring) return Natural with Ghost;
   function Length (R : Ring) return Natural
     with Post => Length'Result = Model (R);
   procedure Push (R : in out Ring; X : Integer)
     with Post => Model (R) > 0;
private
   type Node;
   type Node_Ptr is access Node;
   type Node is record
      Value : Integer;
      Next : Node_Ptr;
   end record;
   function Length_From (N : Node_Ptr) return Natural;
   type Ring is limited record
      Head : Node_Ptr;
   end record
     with Type_Invariant => Length_From (Ring.Head) <= 1000;
   function Model (R : Ring) return Natural is (Length_From (R.Head));
   function Length (R : Ring) return Natural is (Length_From (R.Head));
end Rings;
