--  Relaxed initialisation of an array whose bounds are known only at run time (D196): its
--  components are initialised one by one in a loop, which says so, and then the whole is.
with Ada.Text_IO;
procedure Main is
   type Vector is array (Positive range <>) of Integer;

   function Triangle (N : Positive) return Integer with Pre => N < 100 is
      V : Vector (1 .. N) with Relaxed_Initialization;
      S : Integer := 0;
   begin
      for K in 1 .. N loop
         V (K) := K;
         pragma Loop_Invariant (for all J in 1 .. K => V (J)'Initialized);
         pragma Loop_Invariant (for all J in 1 .. K => V (J) = J);
      end loop;
      pragma Assert (V'Initialized);
      for K in 1 .. N loop
         S := S + V (K);
         pragma Loop_Invariant (S = K * (K + 1) / 2);
      end loop;
      return S;
   end Triangle;
begin
   Ada.Text_IO.Put_Line (Integer'Image (Triangle (10)) & Integer'Image (Triangle (1)));
end Main;
