From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d4e6b104ff087788 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: SPARK : surprising failure with implication Date: Thu, 03 Jun 2010 11:06:55 +0200 Organization: Ada At Home Message-ID: References: NNTP-Posting-Host: o1huFJB2ANcHlWoNFASSiA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.53 (Win32) Xref: g2news1.google.com comp.lang.ada:11249 Date: 2010-06-03T11:06:55+02:00 List-Id: Le Thu, 03 Jun 2010 10:54:51 +0200, Yannick Duch=C3=AAne (Hibou57) = a =C3=A9crit: > I suspect it to see Result - 1, standing for the value of Result in th= e = > Assert clause (and thus as the actual expression standing for Result),= = > as a monolithic subexpression. If this is really what happens, then it= = > would not see (Result + 1 + 1) as (Result - 1 + 1 + 1), and instead as= = > ((Result - 1) + 1 + 1), then see 1 + 1 as an expression, which is = > simplifies to 2, getting ((Result - 1) + 2), which it could not simpli= fy = > any more, as it could not see -1 + 2 as a simplifiable expression, = > because -1 belongs to a subexpression. Note for readers : if you are not aware of how SPARK and Simplifier work= s, = reading =E2=80=9Csee (Result + 1 + 1) as (Result - 1 + 1 + 1)=E2=80=9D, = you may believe = I'm crazy ;) So here is how you should understand it : in the first = expression, Result stands for its actual value, in the line starting wit= h = =E2=80=9C--# check=E2=80=9D. If you read carefully, you may notice betwe= en the line = starting with =E2=80=9C--# assert=E2=80=9D and the one starting with =E2= =80=9C--# check=E2=80=9D, the is a = line =E2=80=9CResult :=3D Result + 1=E2=80=9D. So, the previous value of= Result, in terms of = its actual one, is =E2=80=9CResult - 1=E2=80=9D. In the proofs, SPARK se= es Result as an = expression which is equivalent to its actual value. This expression is = relative the value of Result in the line starting with =E2=80=9C--# asse= rt=E2=80=9D. So = (Result + 1 + 1) is an expression in the terms of the actual value of = Result, as the program see it would see, and (Result - 1 + 1 + 1) is the= = same expression as SPARK see it. You may also, for better understanding,= = read it as (previous-value-of-Result - 1 + 1 + 1). Hope this note helped readers to understand the likely strange things th= ey = may feel to have read here ;) -- = There is even better than a pragma Assert: a SPARK --# check. --# check C and WhoKnowWhat and YouKnowWho; --# assert Ada; -- i.e. forget about previous premises which leads to conclusion -- and start with new conclusion as premise.