From: Phil Thornley <phil.jpthornley@googlemail.com>
Subject: Re: SPARK again : for-loop vs single loop - a strange case
Date: Fri, 28 May 2010 01:14:56 -0700 (PDT)
Date: 2010-05-28T01:14:56-07:00 [thread overview]
Message-ID: <2b6ae662-77e2-4d1a-a2b2-3df54f8ab98e@v37g2000vbv.googlegroups.com> (raw)
In-Reply-To: op.vddp3fvvxmjfy8@garhos
On 27 May, 20:36, Yannick Duchêne (Hibou57) <yannick_duch...@yahoo.fr>
wrote:
[...]
> There was a Check clause in the for-loop, which was looking like this:
>
> for L in T range 1 .. N loop
> ...
> --# assert ...;
> ...
> --# check (2 ** (T'Pos (L) + 1)) = ((2 ** T'Pos (L)) * 2);
> ...
> end loop;
>
> This Check clause was proved by the Simplifier without any trouble.
>
> I then switch to a class loop, looking like this:
>
> L := 1;
>
> loop
> ...
> --# assert ...;
> ...
> --# check (2 ** (T'Pos (L) + 1)) = ((2 ** T'Pos (L)) * 2);
> exit when L = Length;
> L := L + 1;
> ...
> end loop;
>
> Then, the Simplifier was not able anymore to prove this Check. I don't
> understand, as this Check should only depends on a basic rule, a rule by
> definition. So why the same rule is not applied when I use a classic loop
> instead of a for-loop ?
>
> Does SPARK changes its strategy depending on the structure of the
> surrounding source so that it may or may not found a match to a rule
> depending on this context ?
It is difficult to be specific about non-SPARKable code*, but one
difference at the check will be that the upper bound on L has been
lost.
You can get it back by adding L <= Length to the assertion. [You
might also need to change the test to
exit when L >= Length;]
It is put in there aotomatically for a 'for' loop but not for a simple
loop.
Cheers,
Phil
* If the code is too big to put in a message then you can send it by
email to the address on the proof tutorials and I'll be happy to have
a look at it.
next prev parent reply other threads:[~2010-05-28 8:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-27 19:36 SPARK again : for-loop vs single loop - a strange case Yannick Duchêne (Hibou57)
2010-05-27 21:50 ` Brian Drummond
2010-05-27 23:21 ` Yannick Duchêne (Hibou57)
2010-05-28 8:14 ` Phil Thornley [this message]
2010-05-28 9:00 ` Yannick Duchêne (Hibou57)
2010-05-28 11:50 ` Phil Thornley
2010-05-28 15:13 ` Phil Thornley
2010-05-28 22:46 ` Yannick Duchêne (Hibou57)
2010-05-28 22:41 ` Yannick Duchêne (Hibou57)
2010-05-28 9:04 ` Yannick Duchêne (Hibou57)
2010-05-28 12:17 ` stefan-lucks
2010-05-28 22:52 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox