--  Arrays with static bounds read by a nested subprogram: passed to it in their own form, so
--  that it knows their bounds and its callers' queries are well formed.
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   type Matrix is array (Positive range <>, Positive range <>) of Integer;
   type Vector is array (Positive range <>) of Integer;
   subtype Small is Matrix (4 .. 5, 7 .. 8);
   B : constant Small := ((1, 2), (3, 4));
   V : constant Vector (3 .. 5) := (10, 20, 30);
   function Corner return Integer with Post => Corner'Result = B (4, 7) + V (5) is
   begin
      return B (4, 7) + V (5);
   end Corner;
   function Copy return Small with Post => Copy'Result = B is
   begin
      return B;
   end Copy;
   C : constant Matrix := Copy;
begin
   pragma Assert (Corner = 31);
   pragma Assert (C (5, 8) = 4);
   Put_Line (Integer'Image (Corner) & Integer'Image (C (5, 8)) & Integer'Image (C'First (2)));
end Main;
