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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a37:aa04:: with SMTP id t4mr77736810qke.359.1564504553353; Tue, 30 Jul 2019 09:35:53 -0700 (PDT) X-Received: by 2002:a05:6808:b02:: with SMTP id s2mr55765355oij.155.1564504553047; Tue, 30 Jul 2019 09:35:53 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!b26no6983330qtq.0!news-out.google.com!a5ni567qtd.0!nntp.google.com!b26no6983324qtq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 30 Jul 2019 09:35:52 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=146.5.2.29; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.29 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <28e4ac2e-311b-40c4-ad81-42f55129ccd1@googlegroups.com> Subject: SPARK prooving an array of Positives. From: Shark8 Injection-Date: Tue, 30 Jul 2019 16:35:53 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 3055 X-Received-Body-CRC: 1933741248 Xref: reader01.eternal-september.org comp.lang.ada:56983 Date: 2019-07-30T09:35:52-07:00 List-Id: I have a bit of a problem getting the SPARK provers to accept that a postcondition cannot fail. Given the following in a spec file: Type Axis_Count is range 0..999 with Size => 10; Type Axis_Dimensions is Array (Axis_Count range <>) of Positive with Default_Component_Value => 1; Subtype Primary_Data_Array is Axis_Dimensions(1..999); Subtype Random_Groups_Data is Axis_Dimensions(1..998); Function EF( Item : FITS.Axis_Dimensions ) return Interfaces.Unsigned_64; and the following in the implementation: Function EF( Item : FITS.Axis_Dimensions ) return Interfaces.Unsigned_64 is Max : Constant := Positive'Last; Function First return Interfaces.Unsigned_64 is ( Interfaces.Unsigned_64( Item( Item'First ) ) ) with Inline, Pre => Item'Length > 0, Post => First'Result <= Max; Function Last return Interfaces.Unsigned_64 is ( Interfaces.Unsigned_64( Item( Item'Last ) ) ) with Inline, Pre => Item'Length > 0, Post => Last'Result <= Max; use all type Interfaces.Unsigned_64; Begin case Item'Length is when 0 => return 1; when 1 => return First; when 2 => return First * Last; when others => Declare Middle : Constant Axis_Count := Item'Length/2 + Item'First; Subtype Head is Axis_Count range Item'First..Middle; Subtype Tail is Axis_Count range Axis_Count'Succ(Middle)..Item'Last; Begin Return EF(Item(Head)) * EF(Item(Tail)); End; end case; End EF; the SPARK prover is issuing warnings that the postconditions might fail. "medium: postcondition might fail, cannot prove First'Result <= Max (e.g. when First'Result = 0)" But this is impossible given that the element-type is Positive and the precondition states there is at least one element. Does anyone know why this is happening? (And how to fix it?)