4.5.8 Quantified Expressions
Syntax
quantifier ::= all |
some
Name Resolution Rules
Dynamic Semantics
If the
quantifier
is
all, the expression is True if the evaluation of the
predicate
yields True for each value of the loop parameter. It is False otherwise.
Evaluation of the
quantified_expression
stops when all values of the domain have been examined, or when the
predicate
yields False for a given value. Any exception raised by evaluation of
the
predicate
is propagated.
If the
quantifier
is
some, the expression is True if the evaluation of the
predicate
yields True for some value of the loop parameter. It is False otherwise.
Evaluation of the
quantified_expression
stops when all values of the domain have been examined, or when the
predicate
yields True for a given value. Any exception raised by evaluation of
the
predicate
is propagated.
Examples
The postcondition
for a sorting routine on an array A with an index subtype T can be written:
Post => (A'Length < 2 or else
(for all I in A'First .. T'Pred(A'Last) => A (I) <= A (T'Succ (I))))
The assertion that
a positive number is composite (as opposed to prime) can be written:
pragma Assert (for some X in 2 .. N / 2 => N mod X = 0);
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe