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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,78ad7a7a1db15587,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.193.129 with SMTP id ho1mr23502380pbc.8.1340217054018; Wed, 20 Jun 2012 11:30:54 -0700 (PDT) Path: l9ni73261pbj.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Ben Hocking Newsgroups: comp.lang.ada Subject: Need help understanding SPARK substitution rules Date: Wed, 20 Jun 2012 11:30:53 -0700 (PDT) Organization: http://groups.google.com Message-ID: <84581b9d-040b-493b-a8af-ab3499001b5d@googlegroups.com> NNTP-Posting-Host: 8.25.3.17 Mime-Version: 1.0 X-Trace: posting.google.com 1340217053 6662 127.0.0.1 (20 Jun 2012 18:30:53 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Jun 2012 18:30:53 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=8.25.3.17; posting-account=hKGsDAoAAAC9HB_9misjykjawYQeT_yf User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-06-20T11:30:53-07:00 List-Id: I have the following math.ads: ======== package Math is function IsPositive (InVal : in Integer) return Boolean; --# return (InVal > 0); function IsNegative (InVal : in Integer) return Boolean; --# return (InVal < 0); function AlwaysTrue (InVal : in Integer) return Boolean; --# return True; end Math; ======== and math.adb: ======== package body Math is function IsPositive (InVal : in Integer) return Boolean is begin return (InVal > 0); end IsPositive; function IsNegative (InVal : in Integer) return Boolean is begin return (InVal < 0); end IsNegative; function AlwaysTrue (InVal : in Integer) return Boolean is begin --# check not (InVal > 0) -> InVal <= 0; --# check not IsPositive(InVal) -> InVal <= 0; --# check not (InVal < 0) -> InVal >= 0; --# check not IsNegative(InVal) -> InVal >= 0; return (not IsPositive(InVal) or not IsNegative(InVal)); end AlwaysTrue; end Math; ======== The statement "check not (InVal > 0) -> InVal <= 0" is proven easily enough, but the next line ("check not IsPositive(InVal) -> InVal <= 0") is not, even though it's functionally equivalent. If I put the following line in math.rlu: ======== math_ispositive: ispositive(inval) may_be_replaced_by (inval > 0) ======== It now can prove it, and if I do the same thing with isnegative, the whole thing proves out (with the "return True" component being proven by ViCToR). However, this seems like a very fragile way of assuring code correctness, so it reeks from "code smell". What is a better way of achieving this? Thanks, -Ben