Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

A Linux machine! because a 486 is a terrible thing to waste! (By jjs@wintermute.ucr.edu, Joe Sloan)


devel / comp.lang.ada / Contracts in generic formal subprogram

SubjectAuthor
* Contracts in generic formal subprogrammockturtle
+* Re: Contracts in generic formal subprogramDmitry A. Kazakov
|`* Re: Contracts in generic formal subprogramG.B.
| `* Re: Contracts in generic formal subprogramDmitry A. Kazakov
|  `* Re: Contracts in generic formal subprogramSpiros Bousbouras
|   +* Re: Contracts in generic formal subprogramSpiros Bousbouras
|   |+- Re: Contracts in generic formal subprogramNiklas Holsti
|   |+- Re: Contracts in generic formal subprogramG.B.
|   |`- Re: Contracts in generic formal subprogramBen Bacarisse
|   `- Re: Contracts in generic formal subprogramDmitry A. Kazakov
+- Re: Contracts in generic formal subprogramRandy Brukardt
`* Re: Contracts in generic formal subprogramSimon Wright
 `- Re: Contracts in generic formal subprogrammockturtle

1
Contracts in generic formal subprogram

<0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9481&group=comp.lang.ada#9481

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a0c:c78b:0:b0:5df:47b4:a977 with SMTP id k11-20020a0cc78b000000b005df47b4a977mr1788797qvj.5.1680937238671;
Sat, 08 Apr 2023 00:00:38 -0700 (PDT)
X-Received: by 2002:a25:d0c6:0:b0:b8e:c88b:23ec with SMTP id
h189-20020a25d0c6000000b00b8ec88b23ecmr1320721ybg.10.1680937238418; Sat, 08
Apr 2023 00:00:38 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 8 Apr 2023 00:00:38 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=54.36.30.212; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99
NNTP-Posting-Host: 54.36.30.212
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
Subject: Contracts in generic formal subprogram
From: framefritti@gmail.com (mockturtle)
Injection-Date: Sat, 08 Apr 2023 07:00:38 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3293
 by: mockturtle - Sat, 8 Apr 2023 07:00 UTC

Dear.all,
this is something that looked like a natural and nice idea to me, but the compiler disagree :-): specifying contracts in formal subprograms in generic declarations. Actually, RM 12.6 does not prohibit this on a syntactic level (a aspect_specification part is included), but the compiler complains.

To understand what I mean, please check the following real code toy-zed (can you hear the grammar screaming?)
-----------------------
generic
type Ring is private;

with function Divides (Num, Den : Ring) return Boolean;
with function Is_Invertible (X : Ring) return Boolean;
with function Inv (X : Ring) return Ring
with
Pre => Is_Invertible (X);

with function Gcd (X, Y : Ring) return Ring
with
Post => Divides (X, Gcd'Result) and Divides (Y, Gcd'Result);
package Pippo is
-- stuff
end Pippo;
----------------------------------
The meaning I have in mind is something like

* For "Pre" aspect: who writes function Inv can assume that X is invertible since Inv will never be called (by the package code, at least) with X not invertible. Also Inv cannot have a stricter pre-condition. In a sense, the package expects Inv to work correctly if and only if the pre-condition is true.

* For "Post" aspect: I expect that the result of GCD satisfies the post condition. Post conditions for the actual subprogram can be stricter, as long as the post condition of the formal parameter is satisfied. For example, if Ring is Integer, GCD could always return a positive value that divides both X and Y. The fact that the result is positive does not hurt.

Should the actual subprogram specify the same contract? I am not sure (and I guess this could be a stumbling block for the adoption of this idea). One could say that the actual subprogram gets a contract that is the AND of the actual subprogram and the contract specified in the generic declaration, it is up to the programmer to check that they are compatible. I guess the compatibility could be verified by the compiler itself in simple cases, but I expect that this could not be feasible in some cases (maybe of academic interest?).

Riccardo

Re: Contracts in generic formal subprogram

<u0r72o$16jtj$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9482&group=comp.lang.ada#9482

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Sat, 8 Apr 2023 10:02:31 +0200
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <u0r72o$16jtj$1@dont-email.me>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 8 Apr 2023 08:02:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="40020dac18733774fce221bdc9fdcf93";
logging-data="1265587"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Iv/Qn5r7Tq0F262+LG4t55MwaF7xm71Q="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.1
Cancel-Lock: sha1:/LA26BjMvcFGC+1vCWA1SivVzuM=
In-Reply-To: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
Content-Language: en-US
 by: Dmitry A. Kazakov - Sat, 8 Apr 2023 08:02 UTC

On 2023-04-08 09:00, mockturtle wrote:

> Should the actual subprogram specify the same contract? I am not sure (and I guess this could be a stumbling block for the adoption of this idea).

The general principle of substitutability is that the preconditions can
be weakened, the postoconditions can be strengthened.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Contracts in generic formal subprogram

<u0rb0j$177oc$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9484&group=comp.lang.ada#9484

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: randy@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Sat, 8 Apr 2023 04:09:38 -0500
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <u0rb0j$177oc$1@dont-email.me>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
Injection-Date: Sat, 8 Apr 2023 09:09:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8cffde185656e4854c99d85efea8bf85";
logging-data="1285900"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19t3ycVfOnWkqOp/owAM8KkeVpAHZ+xTzo="
Cancel-Lock: sha1:v1Umh4OMpm/owYCnEIAMdViXBIQ=
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
X-RFC2646: Format=Flowed; Original
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
 by: Randy Brukardt - Sat, 8 Apr 2023 09:09 UTC

Ada 2022 allows such contracts; Ada 2012 did not. (See 6.1.1, and
specifically 6.1.1(1/5)). Whether your compiler has caught up, who knows.

Logically the contracts should "match" (with the weakening/strengthing that
Dmitry mentioned), but that was too hard for Ada, so they're just additive.
(A proper matching mechanism is more the sort of thing that SPARK does, Ada
only enforces these contracts at runtime) That is, when you call through a
generic formal subprogram, you enforce the preconditions of both the formal
and the actual subprogram, and similarly for the postconditions. If they
mismatch, you might not be able to make a successful call. If it hurts,
don't do that. ;-)

Randy.

"mockturtle" <framefritti@gmail.com> wrote in message
news:0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com...
Dear.all,
this is something that looked like a natural and nice idea to me, but the
compiler disagree :-): specifying contracts in formal subprograms in generic
declarations. Actually, RM 12.6 does not prohibit this on a syntactic
level (a aspect_specification part is included), but the compiler complains.

To understand what I mean, please check the following real code toy-zed (can
you hear the grammar screaming?)
-----------------------
generic
type Ring is private;

with function Divides (Num, Den : Ring) return Boolean;
with function Is_Invertible (X : Ring) return Boolean;
with function Inv (X : Ring) return Ring
with
Pre => Is_Invertible (X);

with function Gcd (X, Y : Ring) return Ring
with
Post => Divides (X, Gcd'Result) and Divides (Y, Gcd'Result);
package Pippo is
-- stuff
end Pippo;
----------------------------------
The meaning I have in mind is something like

* For "Pre" aspect: who writes function Inv can assume that X is invertible
since Inv will never be called (by the package code, at least) with X not
invertible. Also Inv cannot have a stricter pre-condition. In a sense,
the package expects Inv to work correctly if and only if the pre-condition
is true.

* For "Post" aspect: I expect that the result of GCD satisfies the post
condition. Post conditions for the actual subprogram can be stricter, as
long as the post condition of the formal parameter is satisfied. For
example, if Ring is Integer, GCD could always return a positive value that
divides both X and Y. The fact that the result is positive does not hurt.

Should the actual subprogram specify the same contract? I am not sure
(and I guess this could be a stumbling block for the adoption of this idea).
One could say that the actual subprogram gets a contract that is the AND of
the actual subprogram and the contract specified in the generic declaration,
it is up to the programmer to check that they are compatible. I guess the
compatibility could be verified by the compiler itself in simple cases, but
I expect that this could not be feasible in some cases (maybe of academic
interest?).

Riccardo

Re: Contracts in generic formal subprogram

<ly7cumpbg4.fsf@pushface.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9486&group=comp.lang.ada#9486

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: simon@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Sat, 08 Apr 2023 17:48:11 +0100
Organization: A noiseless patient Spider
Lines: 1
Message-ID: <ly7cumpbg4.fsf@pushface.org>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="802f40d036772e673f7be6fa54232cfa";
logging-data="1408772"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gHO82obJx1WGz45jIDW+LH/xF5jAF5tY="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (darwin)
Cancel-Lock: sha1:hQlppBZXuOAU7fMOO1wMbydZIs8=
sha1:OE2J+X4rX59jfFFGh39F1/IqamU=
 by: Simon Wright - Sat, 8 Apr 2023 16:48 UTC

GCC 12.2.0 accepts this code with -gnat2022.

Re: Contracts in generic formal subprogram

<9c75e0f1-d977-40a3-b8c4-64751c6e0a39n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9487&group=comp.lang.ada#9487

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5c85:0:b0:3de:b5fa:dbad with SMTP id r5-20020ac85c85000000b003deb5fadbadmr1877071qta.5.1680974836856;
Sat, 08 Apr 2023 10:27:16 -0700 (PDT)
X-Received: by 2002:a05:690c:31b:b0:54c:15ad:11e4 with SMTP id
bg27-20020a05690c031b00b0054c15ad11e4mr3879043ywb.0.1680974836635; Sat, 08
Apr 2023 10:27:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 8 Apr 2023 10:27:16 -0700 (PDT)
In-Reply-To: <ly7cumpbg4.fsf@pushface.org>
Injection-Info: google-groups.googlegroups.com; posting-host=80.117.9.16; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99
NNTP-Posting-Host: 80.117.9.16
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com> <ly7cumpbg4.fsf@pushface.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9c75e0f1-d977-40a3-b8c4-64751c6e0a39n@googlegroups.com>
Subject: Re: Contracts in generic formal subprogram
From: framefritti@gmail.com (mockturtle)
Injection-Date: Sat, 08 Apr 2023 17:27:16 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1408
 by: mockturtle - Sat, 8 Apr 2023 17:27 UTC

On Saturday, April 8, 2023 at 6:48:14 PM UTC+2, Simon Wright wrote:
> GCC 12.2.0 accepts this code with -gnat2022.

True! Cool... In my opinion, contracts are among the coolest (and maybe more exclusive) features of Ada

Re: Contracts in generic formal subprogram

<u12squ$2j3h0$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9490&group=comp.lang.ada#9490

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: bauhaus@notmyhomepage.invalid (G.B.)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Tue, 11 Apr 2023 07:56:45 +0200
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <u12squ$2j3h0$1@dont-email.me>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
<u0r72o$16jtj$1@dont-email.me>
Reply-To: nonlegitur@notmyhomepage.de
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 11 Apr 2023 05:56:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="77848faf56a99f3292bb4fbbfcbf873c";
logging-data="2723360"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yo2UZ66HtpJIUi8Vx27duHCgMnuz/kG0="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.9.1
Cancel-Lock: sha1:p9OwrvRO61gqGR/UQoVdSOFr0RE=
In-Reply-To: <u0r72o$16jtj$1@dont-email.me>
Content-Language: en-US
 by: G.B. - Tue, 11 Apr 2023 05:56 UTC

On 08.04.23 10:02, Dmitry A. Kazakov wrote:
> On 2023-04-08 09:00, mockturtle wrote:
>
>> Should the actual subprogram specify the same contract? I am not sure (and I guess this could be a stumbling block for the adoption of this idea).
>
> The general principle of substitutability is that the preconditions can be weakened, the postoconditions can be strengthened.

Side track: "weak" and "strong" alone sounding like a valuation to the
uninitiated, but neither technical nor precise; and the "objects" of
comparison of sets of conditions being implicit; and the ARM not
defining a technical term for these adjectives unless weak ordering
helps.

If these adjectives induce confusion, can they be avoided? E.g., by
instead mentioning the sets of Pre- and Post-conditions of those
actual/formal/overriding subprograms. I guess that super- and subset
relations will permit helpfully defining an ordering to be understood
(in general, if not in the ARM).

Re: Contracts in generic formal subprogram

<u13iae$2kj2n$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9491&group=comp.lang.ada#9491

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Tue, 11 Apr 2023 14:03:27 +0200
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <u13iae$2kj2n$1@dont-email.me>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
<u0r72o$16jtj$1@dont-email.me> <u12squ$2j3h0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 11 Apr 2023 12:03:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="dcee31fe3801779a0057231ac5470c96";
logging-data="2772055"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19vaBi0OaZfkOlevsJUMNeWtDW5hHXE5T8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.9.1
Cancel-Lock: sha1:SRShcFSwfE+j2VXsbmBevQpYk2Y=
In-Reply-To: <u12squ$2j3h0$1@dont-email.me>
Content-Language: en-US
 by: Dmitry A. Kazakov - Tue, 11 Apr 2023 12:03 UTC

On 2023-04-11 07:56, G.B. wrote:
> On 08.04.23 10:02, Dmitry A. Kazakov wrote:
>> On 2023-04-08 09:00, mockturtle wrote:
>>
>>> Should the actual subprogram specify the same contract? I am not sure
>>> (and I guess this could be a stumbling block for the adoption of this
>>> idea).
>>
>> The general principle of substitutability is that the preconditions
>> can be weakened, the postoconditions can be strengthened.
>
> Side track: "weak" and "strong" alone sounding like a valuation to the
> uninitiated, but neither technical nor precise; and the "objects" of
> comparison of sets of conditions being implicit; and the ARM not
> defining a technical term for these adjectives unless weak ordering
> helps.

The formal meaning of weaker/stronger relation on predicates P and Q:

weaker P => Q
stronger Q => P

The formal rationale is that if you have a proof

P1 => P2 => P3

Then weakening P1 to P1' => P1 and strengthening P3 => P3' keeps it:

P1' => P2 => P3'

--------------------------------------------------------
As for ARM.

Regarding dynamic checks all the above is irrelevant because dynamic
checks are no contracts. Furthermore since the proper contracts include
Constraint_Error or Storage_Error raised, do you really care how are you
going to bomb your program while keeping proper contracts? (:-)) Sincere
advise: forget about this mess.

For static checks a proof of implication is rather straightforward since
we assume that all static predicates must be decidable anyway.

Of course, with generics you might run into troubles as you would have
both proper contracts, i.e. the instantiated ones, and the generic ones
expressed in generic terms. Instantiated contracts are easy to check,
but what one would actually wish is checking generic contracts, which
might turn impossible. The glimpse of the problem is what any Ada
programmer knows: generic instantiations may fail to compile even if the
actual parameters match...

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Contracts in generic formal subprogram

<wTNwzuVC4pvpqJ=Iw@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9492&group=comp.lang.ada#9492

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Wed, 12 Apr 2023 02:18:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <wTNwzuVC4pvpqJ=Iw@bongo-ra.co>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com> <u0r72o$16jtj$1@dont-email.me> <u12squ$2j3h0$1@dont-email.me>
<u13iae$2kj2n$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Apr 2023 02:18:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f0ed070b7d9e24617b35795fae11bca2";
logging-data="3028736"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BbUax/kkZgSHndNO6DGMQ"
Cancel-Lock: sha1:542VGjn2FE9+Pa7hz+NN7kLTsBc=
In-Reply-To: <u13iae$2kj2n$1@dont-email.me>
X-Server-Commands: nowebcancel
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Wed, 12 Apr 2023 02:18 UTC

On Tue, 11 Apr 2023 14:03:27 +0200
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
> The formal meaning of weaker/stronger relation on predicates P and Q:
>
> weaker P => Q
> stronger Q => P
>
> The formal rationale is that if you have a proof
>
> P1 => P2 => P3
>
> Then weakening P1 to P1' => P1 and strengthening P3 => P3' keeps it:
>
> P1' => P2 => P3'

You have it backwards ; if P1' implies P1 then P1' is stronger
than P1 .

Re: Contracts in generic formal subprogram

<4I=3lX6HccsqYa6JC@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9493&group=comp.lang.ada#9493

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Wed, 12 Apr 2023 03:37:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <4I=3lX6HccsqYa6JC@bongo-ra.co>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com> <u0r72o$16jtj$1@dont-email.me> <u12squ$2j3h0$1@dont-email.me>
<u13iae$2kj2n$1@dont-email.me> <wTNwzuVC4pvpqJ=Iw@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Apr 2023 03:37:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f0ed070b7d9e24617b35795fae11bca2";
logging-data="3046705"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HHqJkr6pZJZ1Gy922RnDO"
Cancel-Lock: sha1:q0U8oZeQIyS1AzZaXF8fv7AiLXc=
In-Reply-To: <wTNwzuVC4pvpqJ=Iw@bongo-ra.co>
X-Server-Commands: nowebcancel
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Wed, 12 Apr 2023 03:37 UTC

On Wed, 12 Apr 2023 02:18:45 -0000 (UTC)
Spiros Bousbouras <spibou@gmail.com> wrote:
> On Tue, 11 Apr 2023 14:03:27 +0200
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
> > The formal meaning of weaker/stronger relation on predicates P and Q:
> >
> > weaker P => Q
> > stronger Q => P
> >
> > The formal rationale is that if you have a proof
> >
> > P1 => P2 => P3
> >
> > Then weakening P1 to P1' => P1 and strengthening P3 => P3' keeps it:
> >
> > P1' => P2 => P3'
>
> You have it backwards ; if P1' implies P1 then P1' is stronger
> than P1 .

Apologies ; it was me who got it backwards.

Re: Contracts in generic formal subprogram

<k9n2jvFark6U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9494&group=comp.lang.ada#9494

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Wed, 12 Apr 2023 09:49:35 +0300
Organization: Tidorum Ltd
Lines: 35
Message-ID: <k9n2jvFark6U1@mid.individual.net>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
<u0r72o$16jtj$1@dont-email.me> <u12squ$2j3h0$1@dont-email.me>
<u13iae$2kj2n$1@dont-email.me> <wTNwzuVC4pvpqJ=Iw@bongo-ra.co>
<4I=3lX6HccsqYa6JC@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net wpzrt4emyV12Pp/74xsDsQpYi7jPUnOImoSnjUOJ/P890pdb/i
Cancel-Lock: sha1:NTHEiCYdbNZxJAQBIpqlcuBvf8k=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0)
Gecko/20100101 Thunderbird/102.6.1
Content-Language: en-US
In-Reply-To: <4I=3lX6HccsqYa6JC@bongo-ra.co>
 by: Niklas Holsti - Wed, 12 Apr 2023 06:49 UTC

On 2023-04-12 6:37, Spiros Bousbouras wrote:
> On Wed, 12 Apr 2023 02:18:45 -0000 (UTC)
> Spiros Bousbouras <spibou@gmail.com> wrote:
>> On Tue, 11 Apr 2023 14:03:27 +0200
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
>>> The formal meaning of weaker/stronger relation on predicates P and Q:
>>>
>>> weaker P => Q
>>> stronger Q => P
>>>
>>> The formal rationale is that if you have a proof
>>>
>>> P1 => P2 => P3
>>>
>>> Then weakening P1 to P1' => P1 and strengthening P3 => P3' keeps it:
>>>
>>> P1' => P2 => P3'
>>
>> You have it backwards ; if P1' implies P1 then P1' is stronger
>> than P1 .
>
> Apologies ; it was me who got it backwards.

Speaking of logic in general, rather than Ada contracts in particular, I
would say that you got it right, and Dmitry did not.

Suppose we have a theorem about geometrical figures F, and at first we
can prove the theorem only if we assume (precondition) that the figure F
is a square. Later we manage to improve the proof so that it holds also
for rectangles. I would say, and I think mathematicians would say, that
we /weakened/ the assumptions from "F is a square" to "F is a
rectangle", and indeed the former (stronger) implies the latter
(weaker), which is not as Dmitry defined "stronger".

Re: Contracts in generic formal subprogram

<u15mng$2uq94$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9495&group=comp.lang.ada#9495

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: bauhaus@notmyhomepage.invalid (G.B.)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Wed, 12 Apr 2023 09:30:55 +0200
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <u15mng$2uq94$1@dont-email.me>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
<u0r72o$16jtj$1@dont-email.me> <u12squ$2j3h0$1@dont-email.me>
<u13iae$2kj2n$1@dont-email.me> <wTNwzuVC4pvpqJ=Iw@bongo-ra.co>
<4I=3lX6HccsqYa6JC@bongo-ra.co>
Reply-To: nonlegitur@notmyhomepage.de
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 12 Apr 2023 07:30:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0741b94302a501f99b01e7df1e85ead4";
logging-data="3107108"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1f3+DrtAqQqesDMp1soIoii6SGDhycDE="
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0)
Gecko/20100101 Thunderbird/102.9.1
Cancel-Lock: sha1:GtUu/tvmr0xMy2HeiaEeN+/zCQY=
In-Reply-To: <4I=3lX6HccsqYa6JC@bongo-ra.co>
Content-Language: en-US
 by: G.B. - Wed, 12 Apr 2023 07:30 UTC

On 12.04.23 05:37, Spiros Bousbouras wrote:
> On Wed, 12 Apr 2023 02:18:45 -0000 (UTC)
> Spiros Bousbouras <spibou@gmail.com> wrote:
>> On Tue, 11 Apr 2023 14:03:27 +0200
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
>>> The formal meaning of weaker/stronger relation on predicates P and Q:
>>>
>>> weaker P => Q
>>> stronger Q => P
>>>
>>> The formal rationale is that if you have a proof
>>>
>>> P1 => P2 => P3
>>>
>>> Then weakening P1 to P1' => P1 and strengthening P3 => P3' keeps it:
>>>
>>> P1' => P2 => P3'
>>
>> You have it backwards ; if P1' implies P1 then P1' is stronger
>> than P1 .
>
> Apologies ; it was me who got it backwards.

Thanks for pointing out the issue: When P_n or Q_m don't
mention the thing to which they "belong",
then how does just mentioning names of predicates clarify
to what end of the substitution the comparatives "weaker"
or "stronger" will apply? It's variance of meaning.

"The LSP paper" uses "weak" more generally.

OK, condition P is generally considered stronger than Q
if P implies Q, right? I.e., Q not without P.
Is there a commonly accepted definition of the words "weak"
and "strong", in mathematics perhaps, that justifies the
usual contextual _omissions_ from speech?

LSP uses "pre" and "post" for an object's value in a state.
There are phrases such as "stronger requirements that constrain".

Consider a different choice of adjectives:

Given a primitive operation f of a type T,
then a precondition of any overridden f of
a type D descended from T must be sexier.

Does "sexy" carry more or less meaning than "weak" WRT assertions?

Re: Contracts in generic formal subprogram

<87leixxozl.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9496&group=comp.lang.ada#9496

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Wed, 12 Apr 2023 13:29:50 +0100
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <87leixxozl.fsf@bsb.me.uk>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
<u0r72o$16jtj$1@dont-email.me> <u12squ$2j3h0$1@dont-email.me>
<u13iae$2kj2n$1@dont-email.me> <wTNwzuVC4pvpqJ=Iw@bongo-ra.co>
<4I=3lX6HccsqYa6JC@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="45580961277d0defc186a0e296bb7772";
logging-data="3188366"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ATGrEMaR5RCKtP2Z8KDdmyClFS1XEk4M="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:gTztkUtt0ccWfk8Pbm/eJfvxivU=
sha1:ezRmSjGIQGTm0CDnCm/6u9NFqgQ=
X-BSB-Auth: 1.912a3296252d1014ecda.20230412132950BST.87leixxozl.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 12 Apr 2023 12:29 UTC

Spiros Bousbouras <spibou@gmail.com> writes:

> On Wed, 12 Apr 2023 02:18:45 -0000 (UTC)
> Spiros Bousbouras <spibou@gmail.com> wrote:
>> On Tue, 11 Apr 2023 14:03:27 +0200
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
>> > The formal meaning of weaker/stronger relation on predicates P and Q:
>> >
>> > weaker P => Q
>> > stronger Q => P
>> >
>> > The formal rationale is that if you have a proof
>> >
>> > P1 => P2 => P3
>> >
>> > Then weakening P1 to P1' => P1 and strengthening P3 => P3' keeps it:
>> >
>> > P1' => P2 => P3'
>>
>> You have it backwards ; if P1' implies P1 then P1' is stronger
>> than P1 .
>
> Apologies ; it was me who got it backwards.

No, you are correct. If P1' => P1 then P1' /is/ stronger (or at least
no weaker) than P1.

Using upper and lower case to suggest stronger and weaker then if we
have a proof p |- Q, then we can also assert that P |- q for all
stronger premises P and weaker conclusions q. Formally

{p, P=>p, Q=>q} |- q

Or, written out using the deduction theorem, if we have p=>Q then we can
assert P=>q for any stronger P (so P=>p) and any weaker q (so Q=>q).

In Floyd-Hoare logic, this is embodied in the consequence rule:

P=>p, {p}S{Q}, Q=>q
-------------------
{P}S{q}

which says that we can always strengthen a pre-condition and weaken a
post-condition.

However (if I've got the context right), in terms of substitution and/or
inheritance, Dmitry-Kazakov was correct to say that "The general
principle of substitutability is that the preconditions can be weakened,
the postoconditions can be strengthened". It's just the definition that
was backwards.

--
Ben.

Re: Contracts in generic formal subprogram

<u187ci$9mpm$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9497&group=comp.lang.ada#9497

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: mailbox@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Contracts in generic formal subprogram
Date: Thu, 13 Apr 2023 08:27:30 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <u187ci$9mpm$1@dont-email.me>
References: <0c555ce7-0b2e-49f1-8930-c4f4796793e4n@googlegroups.com>
<u0r72o$16jtj$1@dont-email.me> <u12squ$2j3h0$1@dont-email.me>
<u13iae$2kj2n$1@dont-email.me> <wTNwzuVC4pvpqJ=Iw@bongo-ra.co>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 13 Apr 2023 06:27:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4960f866889f146161272c329b054297";
logging-data="318262"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+m/UkfvTBqFG9QkCN/GC29IX8XP3BpH4E="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Cancel-Lock: sha1:wAfNzUMZtZaJHc3RZ+0qQGmPPn0=
Content-Language: en-US
In-Reply-To: <wTNwzuVC4pvpqJ=Iw@bongo-ra.co>
 by: Dmitry A. Kazakov - Thu, 13 Apr 2023 06:27 UTC

On 2023-04-12 04:18, Spiros Bousbouras wrote:
> On Tue, 11 Apr 2023 14:03:27 +0200
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote:
>> The formal meaning of weaker/stronger relation on predicates P and Q:
>>
>> weaker P => Q
>> stronger Q => P
>>
>> The formal rationale is that if you have a proof
>>
>> P1 => P2 => P3
>>
>> Then weakening P1 to P1' => P1 and strengthening P3 => P3' keeps it:
>>
>> P1' => P2 => P3'
>
> You have it backwards ; if P1' implies P1 then P1' is stronger
> than P1 .

Yes, you are right. Inclusion is an inverse of implication.

A weaker predicate is true on a set that contains the set where the
stronger predicate is.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor