comp.lang.ada
 help / color / mirror / Atom feed
From: Phil Thornley <phil.jpthornley@gmail.com>
Subject: Re: SPARK - Bubble Sort on Rosetta Code
Date: Fri, 27 Aug 2010 00:57:33 -0700 (PDT)
Date: 2010-08-27T00:57:33-07:00	[thread overview]
Message-ID: <eefb617d-9b91-4569-9baf-9697ca455752@z28g2000yqh.googlegroups.com> (raw)
In-Reply-To: m2r5hlatuf.fsf@pushface.org

On 26 Aug, 23:32, Simon Wright <si...@pushface.org> wrote:
> Phil Thornley <phil.jpthorn...@gmail.com> writes:
> > I've put some SPARK code for the Bubble Sort task on Rosetta Code and
> > I would welcome opinions on whether they make a good showcase for
> > SPARK
>
> It took me a while to find them -- at http://rosettacode.org/wiki/Sorting_algorithms/Bubble_sort#SPARK.
Ooops, sorry about not including that.

> > The first is simply shown to be type-safe.
>
> Is this the same as "guaranteed free of any run-time error"?
Yes - the Wikipedia page on type safety (http://en.wikipedia.org/wiki/
Type_safety) says "In the context of static (compile-time) type
systems, type safety usually involves (among other things) a guarantee
that the eventual value of any expression will be a legitimate member
of that expression's static type."

I've always wanted a shorter phrase than "proof of absence of run-time
error" and Rod used the phrase type-safe in his recent announcement
about SPARKSkein.

> What would non-SPARK code do to make it fail?
Get one of the bounds on the inner loop wrong?  Get the termination
condition wrong for the outer loop and increment the pointer past the
end?

> > The second, with identical Ada code, proves that the output array is
> > sorted.
>
> Are zero-length arrays forbidden in SPARK?
Yes - any array must use a named index subtype, and null subtype
ranges are forbidden (which can be checked by the Examiner because the
bounds of subtype ranges must be static).

>                                        ... I ask because of
>
>       --# check A'Last <= A'First -> A'Last = A'First;
That's an example of a 'tactical' check annotation that helps with
proing some of the VCs. (It converts a potential path into an
infeasible one, which makes it a lot easier to prove the post-
condition.)

> (what's that -> ? I understood that the syntax was
>    'check <boolean expression>').
That's the SPARK implication operater.

Cheers,

Phil



  parent reply	other threads:[~2010-08-27  7:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26  9:18 SPARK - Bubble Sort on Rosetta Code Phil Thornley
2010-08-26 21:40 ` Yannick Duchêne (Hibou57)
2010-08-27  4:28   ` Yannick Duchêne (Hibou57)
2010-08-27  7:35   ` Phil Thornley
2010-08-27  8:04     ` Yannick Duchêne (Hibou57)
2010-08-26 22:32 ` Simon Wright
2010-08-27  0:38   ` Yannick Duchêne (Hibou57)
2010-08-27  7:57   ` Phil Thornley [this message]
2010-08-27  9:02     ` Phil Thornley
2010-08-27 11:03     ` sjw
2010-08-27 12:03       ` 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