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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,39579ad87542da0e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.230.161 with SMTP id sz1mr5296662pac.18.1368583924025; Tue, 14 May 2013 19:12:04 -0700 (PDT) Path: bp1ni2341pbd.1!nntp.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.news.ucla.edu!nrc-news.nrc.ca!News.Dal.Ca!citadel.nobulus.com!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Seeking for papers about tagged types vs access to subprograms Date: Sun, 12 May 2013 08:02:16 +0200 Organization: cbb software GmbH Message-ID: References: <1vrhb7oc4qbob$.q02vuouyovp5$.dlg@40tude.net> <19lrzzbgm77v6.1dzpgqckptaj6.dlg@40tude.net> <1bfhq7jo34xpi.p8n2vq6yjsea.dlg@40tude.net> <12gn9wvv1gwfk.10ikfju4rzmnj.dlg@40tude.net> <1oy5rmprgawqs.1jz36okze0xju$.dlg@40tude.net> <1q2ql1e4rcgko.diszzq1mhaq8$.dlg@40tude.net> <1msoad3apbkf.1optea1ujjydv.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 15waz9CoS+eMakbyhTPyFQ.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Received-Bytes: 3323 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2013-05-12T08:02:16+02:00 List-Id: On Sat, 11 May 2013 18:51:27 -0400, Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >> The condition is moved to the post-condition. E.g. >> >> # require X >= 0.0 >> function sqrt (X : Float) return Float; >> # ensure sqrt (X)**2 = X >> >> is replaced with >> >> # require true >> function sqrt (X : Float) return Float; >> # ensure sqrt (X)**2 = X or else Constraint_Error raised > > It seems to me that this replacement loses information (the info that > X is "supposed to be nonnegative"). # ensure (X >= 0.0 and then sqrt (X)**2 = X) or else (X < 0.0 and then Constraint_Error raised) > For example, a body of sqrt that says "return X / 0.0;" obeys the second > contract but not the first above. But that's obviously wrong to anyone > who thinks that "sqrt" means "approximate square root of X". As "approximate square root" any implementation is OK. A more realistic contract that defines accuracy of the result could be like: sqrt (X)**2 in Float'Max (0.0, X'Pred)..Float'Min (Float'Last, X'Succ) [It was just an illustration of the idea how preconditions of operations are relaxed.] > (Never mind the accuracy issues -- sqrt(X) might not be representable as > a Float. ;-) ) No, because sqrt(X) < X, if X > 0. But considering mathematical sqrt, yes, it is not even complex-valued. sqrt is a multi-valued complex function. If we are lucky one value of sqrt(X) might have zero imaginary part. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de