comp.lang.ada
 help / color / mirror / Atom feed
From: JP Thornley <jpt@diphi.demon.co.uk>
Subject: Re: Newbie question: SPARK verification condition on member of private record
Date: Fri, 3 Apr 2009 14:36:40 +0100
Date: 2009-04-03T14:36:40+01:00	[thread overview]
Message-ID: <vsCQtXDoDh1JJwZV@diphi.demon.co.uk> (raw)
In-Reply-To: y7ednbO7TLaJzEjUnZ2dnUVZ8sSdnZ2d@posted.plusnet

In article <y7ednbO7TLaJzEjUnZ2dnUVZ8sSdnZ2d@posted.plusnet>, Tim Rowe
<spamtrap@tgrowe.plus.net> writes
>JP Thornley wrote:
>
>> The usual recommendation for updating records is to assign an
>>aggregate  rather than individual components (this gets rid of all the
>>upf_/update's), but the need to update an element of the array makes
>>it  more awkward in this case.
>
>Yes, an aggregate assignment followed by the update of the array makes
>for a much worse set of things to prove.

Although you get some fearsome looking expressions sometimes, it is
often the case that a rule that proves a conclusion is much simpler.
If you want to send me some sparkable code to play with then use the
email address on www.sparksure.com.

An alternative that sometimes works when updating arrays is to move the
update into a local operation (it's completely non-intuitive code but
often creates easier proofs).

If your code looks something like:
      This.Highest_Valid_Index => This.Highest_Valid_Index + 1;
      This.Events(This.Highest_Valid_Index) := Conjunction;

then add the following as a local procedure and call it in place of the
second statement above (it shouldn't cost anything in execution time as
the compiler should be able to inline it)

      procedure Set_Element
      --# global in out This;
      --#        in     Conjunction;
      --# derives This from *, Conjunction;
      --# post This.Probability = This~.Probability and
      --#      This.Highest_Valid_Index = This~.Highest_Valid_Index and
      --#      This.Events = This~.Events[New_Index => Conjunction];
      is
      begin
         This.Events(This.Highest_Valid_Index) := Conjunction;
      end Set_Element;
      pragma Inline(Set_Element);

you may find that any VCs left by the Simplifier are now easier to read.

Phil

-- 
JP Thornley



  reply	other threads:[~2009-04-03 13:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-01 19:38 Newbie question: SPARK verification condition on member of private record Tim Rowe
2009-04-01 21:04 ` JP Thornley
2009-04-01 23:50   ` Tim Rowe
2009-04-02  9:00     ` JP Thornley
2009-04-02 12:00       ` Tim Rowe
2009-04-02 15:22         ` JP Thornley
2009-04-02 18:09           ` roderick.chapman
2009-04-03 11:26             ` Tim Rowe
2009-04-02 23:58           ` Tim Rowe
2009-04-03 13:36             ` JP Thornley [this message]
2009-04-06 11:49               ` Tim Rowe
replies disabled

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