From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: Contracts in generic formal subprogram
Date: Wed, 12 Apr 2023 13:29:50 +0100 [thread overview]
Message-ID: <87leixxozl.fsf@bsb.me.uk> (raw)
In-Reply-To: 4I=3lX6HccsqYa6JC@bongo-ra.co
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.
next prev parent reply other threads:[~2023-04-12 12:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-08 7:00 Contracts in generic formal subprogram mockturtle
2023-04-08 8:02 ` Dmitry A. Kazakov
2023-04-11 5:56 ` G.B.
2023-04-11 12:03 ` Dmitry A. Kazakov
2023-04-12 2:18 ` Spiros Bousbouras
2023-04-12 3:37 ` Spiros Bousbouras
2023-04-12 6:49 ` Niklas Holsti
2023-04-12 7:30 ` G.B.
2023-04-12 12:29 ` Ben Bacarisse [this message]
2023-04-13 6:27 ` Dmitry A. Kazakov
2023-04-08 9:09 ` Randy Brukardt
2023-04-08 16:48 ` Simon Wright
2023-04-08 17:27 ` mockturtle
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox