comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Thornley <phil.jpthornley@gmail.com>
Subject: Re: SPARK : third example for Roesetta - reviewers welcome
Date: Sun, 15 Aug 2010 21:29:24 -0700 (PDT)
Date: 2010-08-15T21:29:24-07:00	[thread overview]
Message-ID: <99389e3d-17da-40a4-a25f-0bcfb1e7c104@k10g2000yqa.googlegroups.com> (raw)
In-Reply-To: i49mrv$19s4$1@adenine.netfront.net

On 15 Aug, 22:40, Jeffrey Carter <spam.jrcarter....@spam.not.acm.org>
wrote:
> On 08/15/2010 01:19 PM, Yannick Duchêne (Hibou57) wrote:
>
> > --# pre
> > --# (Source'Length = 0) or else
> > --# (for all I in Index_Type range Source'First .. Source'Last - 1
> > --# => (Source (I) <= Source (I + 1)));
> > -- The array must be either empty or sorted from lower to higher.
>
> Is this correct? Consider the case where Source'Length = 1. In that case, the
> range in the "for all" is null; does that evaluate to True? If not, then it
> needs to be
>
> Source'Length < 2 or else (for all ...)

That's the correct way of saying that the array is ordered, and it
works fine for an array of Length 1 (or less).

The translation of that expression to FDL (the language SPARK uses for
all it's proof work) will be something like:
 for_all(i_ : integer, source__first <= i_ and i_ <= source__last - 1
            -> (element(source, [i_]) <= element(source, [i_ + 1]))) .
If source__first = source__last then the LHS of the implication is
False, and the implication itself is True.

> Even if it is correct as written, it may be misleading to non-Ada readers (whom
> we want to impress on Rosetta) who might think it implies an out-of-range access.

That's why I used the proof function 'Ordered' in my version of the
code.  To the casual reader it should look OK, and when you want to
get more formal then you define Ordered as exactly that expression
above.

Cheers,

Phil



  parent reply	other threads:[~2010-08-16  4:29 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-15  6:17 SPARK : third example for Roesetta - reviewers welcome Yannick Duchêne (Hibou57)
2010-08-15  6:27 ` Yannick Duchêne (Hibou57)
2010-08-15  6:35 ` Jeffrey Carter
2010-08-15  6:39   ` Yannick Duchêne (Hibou57)
2010-08-15 18:42 ` Phil Thornley
2010-08-15 19:32   ` Yannick Duchêne (Hibou57)
2010-08-15 20:12     ` Phil Thornley
2010-08-16 10:08       ` Jacob Sparre Andersen
2010-08-15 19:57   ` Yannick Duchêne (Hibou57)
2010-08-15 20:07   ` Yannick Duchêne (Hibou57)
2010-08-15 20:57   ` Yannick Duchêne (Hibou57)
2010-08-15 22:19     ` Yannick Duchêne (Hibou57)
2010-08-16  5:51       ` Phil Thornley
2010-08-16 16:42         ` Yannick Duchêne (Hibou57)
2010-08-16 17:07           ` Mark Lorenzen
2010-08-15 22:09   ` Jeffrey Carter
2010-08-15 22:27     ` Yannick Duchêne (Hibou57)
2010-08-16  4:58       ` Phil Thornley
2010-08-16  7:50       ` Stephen Leake
2010-08-16  8:37         ` Phil Thornley
2010-08-16 16:55           ` Yannick Duchêne (Hibou57)
2010-08-16 20:40             ` Peter C. Chapin
2010-08-16 22:38               ` Yannick Duchêne (Hibou57)
2010-08-16 23:43                 ` Peter C. Chapin
2010-08-17  9:15                   ` Phil Thornley
2010-08-17 10:32                     ` Peter C. Chapin
2010-08-17 19:53                     ` Phil Thornley
2010-08-17 22:15                       ` Dmitry A. Kazakov
2010-08-18 10:44                         ` Phil Thornley
2010-08-18 16:33                           ` Dmitry A. Kazakov
2010-08-19  6:19                             ` Categories for SPARK on Rosetta Code (Was: SPARK : third example for Roesetta - reviewers welcome) Jacob Sparre Andersen
2010-08-20  8:40                               ` Phil Thornley
2010-08-20  9:15                                 ` J-P. Rosen
2010-08-20  9:23                                   ` Dmitry A. Kazakov
2010-08-20  9:55                                     ` J-P. Rosen
2010-08-20 10:24                                       ` Dmitry A. Kazakov
2010-08-20 11:36                                         ` J-P. Rosen
2010-08-20 12:25                                           ` Dmitry A. Kazakov
2010-08-20 13:28                                             ` J-P. Rosen
2010-08-20 14:05                                               ` Dmitry A. Kazakov
2010-08-20 16:23                                                 ` J-P. Rosen
2010-08-20 16:41                                                   ` Dmitry A. Kazakov
2010-08-20 15:34                                 ` (see below)
2010-08-20 16:42                                   ` Dmitry A. Kazakov
2010-08-22  8:11                                     ` Categories for SPARK on Rosetta Code Jacob Sparre Andersen
2010-08-22  8:53                                       ` Dmitry A. Kazakov
2010-08-20  8:37                           ` SPARK : third example for Roesetta - reviewers welcome Phil Thornley
2010-08-17  8:16                 ` How to structure examples for Rosetta Code (Was: SPARK : third example for Roesetta - reviewers welcome) Jacob Sparre Andersen
2010-08-17 19:16                   ` How to structure examples for Rosetta Code Simon Wright
2010-08-17 20:53                     ` Peter C. Chapin
2010-08-17 21:24                       ` Simon Wright
2010-08-17  2:07           ` SPARK : third example for Roesetta - reviewers welcome Stephen Leake
2010-08-16  4:41     ` Phil Thornley
2010-08-16 17:03       ` Yannick Duchêne (Hibou57)
2010-08-15 20:04 ` Jacob Sparre Andersen
2010-08-15 20:19   ` Yannick Duchêne (Hibou57)
2010-08-15 21:40     ` Jeffrey Carter
2010-08-15 22:13       ` Yannick Duchêne (Hibou57)
2010-08-16  4:29       ` Phil Thornley [this message]
2010-08-16 17:11     ` Phil Thornley
2010-08-20  9:06   ` Phil Thornley
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox