with Ada.Text_IO; use Ada.Text_IO;

--  Array aggregates of more than 1024 components (D185): a named range, an iterated range,
--  one with `others`, and one within bounds known only at run time, each built by a loop the
--  prover follows by its invariant
procedure Main is
   type Vector is array (1 .. 2000) of Integer;
   V : constant Vector := (1 .. 1500 => 1, 1700 => 5, others => 0);
   W : constant Vector := [for K in 1 .. 2000 => K];
   X : constant Vector := [for K in 11 .. 1990 => K * 2, others => -1];
   S : Integer := 0;

   procedure Fill (N : Positive) with Pre => N in 1500 .. 5000 is
      type Row is array (Positive range <>) of Integer;
      R : constant Row (1 .. N) := [for K in 1 .. 1500 => K, others => 7];
   begin
      pragma Assert (R (1500) = 1500);
      Put_Line (Integer'Image (R (N)));
   end Fill;
begin
   pragma Assert (V (1) = 1 and V (1500) = 1 and V (1501) = 0 and V (1700) = 5);
   pragma Assert (W (1234) = 1234);
   pragma Assert (X (11) = 22 and X (10) = -1 and X (1991) = -1);
   for I in V'Range loop
      pragma Loop_Invariant (S in 0 .. 10 * (I - 1));
      S := S + V (I) + W (I) mod 3 + X (I) mod 5;
   end loop;
   Put_Line (Integer'Image (S));
   Fill (1500);
   Fill (3000);
end Main;
