--  Quantified expressions over sources in step (B7005-33, D192): a range or an array of one
--  dimension beside others, each at its low bound plus the parameter's distance from its
--  own, the values ending with the shortest; with a filter, and in a loop's invariant.
pragma Extensions_Allowed (On);
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   type Vector is array (Positive range <>) of Integer;
   function Same (A, B : Vector) return Boolean
     is (for all X of A, Y of B => X = Y);
   function Shifted (A : Vector) return Boolean
     is (for some J in A'First + 1 .. A'Last, X of A when X > 0 => A (J) = X)
     with Pre => A'Length >= 2;
   procedure Copy (A : Vector; B : in out Vector)
     with Pre => A'Length = B'Length,
          Post => (for all X of A, Y of B => X = Y)
   is
   begin
      for I in B'Range loop
         B (I) := A (A'First + (I - B'First));
         pragma Loop_Invariant (for all J in B'First .. I, X of A => B (J) = X);
      end loop;
   end Copy;
   A : constant Vector := (1, 2, 3);
   B : Vector (5 .. 7) := (others => 0);
begin
   Copy (A, B);
   pragma Assert (Same (A, B));
   Put_Line (Boolean'Image (Same (A, B)) & Boolean'Image (Same ((1, 2), (1, 3, 3))) & Boolean'Image (Shifted ((2, 2, 5))) & Boolean'Image (Shifted ((1, 2, 3))));
end Main;
