Re: A question about substitution principle
- From: "Tony Johansson" <johansson.andersson@xxxxxxxxx>
- Date: Sun, 25 Sep 2005 12:13:17 GMT
Hello!
I did a typo I meant that the precondition for the operation Figure 2 should
be not empty
of course.
You say the following
The postcondition of figure 1 is: A V B, where
A = (result = top element...)
B = (exception thrown)
I assume that your writing A V B must be understand that the
preconditionn is A or B. I'm right?
So to right A V B when you have the above for A and B is just equivalent of
writing
then result = top element from stack
else throw EmptyException
I'm right here also?
You say that the postcondition of figure 2 is A.
and then you say this
Clearly A => A V B
I'm not familar of this kind of writing
what actually does this A => A V B mean?
Finaly do you mean that operation Figur1 is a subtype of the operation for
Figure 2?
//Tony
"Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx> skrev i meddelandet
news:9s6nkuhjyvp1.1h6d9iitsw4a3$.dlg@xxxxxxxxxxxxx
> On Sun, 25 Sep 2005 10:09:40 GMT, Tony Johansson wrote:
>
>> Figure 1: operation top element from a stack using weak contract
>> Precondition: true
>> Postcondition: If not empy
>> then result = top element from stack
>> else throw EmptyException
>>
>> Figure 2: operation top element from a stack using strong contract
>> Precondition: not empty
>> Postcondition: result = top element from stack
>>
>> The substitution principle and Bartrand Mayer say that in particular it
>> does
>> not make Figure 1 define a subtype of figure 2.
>> Cerainly, the precondition of Figure 1 is weaker than that of Figure 2.
>
> It is not weaker, it is equal: true <=> true
>
>> The
>> postcondition of Figure 1, however, is not stronger than that of Figure
>> 2,
>> since a thrown exception satisfies the former but not the latter.
>
> No, it is. The postcondition of figure 1 is: A V B, where
>
> A = (result = top element...)
> B = (exception thrown)
>
> The postcondition of figure 2 is A.
>
> Clearly A => A V B
>
>> Now to my question: I don't understand what it means with "The
>> postcondition
>> of Figure 1, however, is not stronger than that of Figure 2, since a
>> thrown
>> exception satisfies the former but not the latter."?
>
> "Stronger or equal" on conditions is logical implication =>. The equality
> relation is logical equivalence <=>.
>
> --
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: A question about substitution principle
- From: Dmitry A. Kazakov
- Re: A question about substitution principle
- References:
- A question about substitution principle
- From: Tony Johansson
- Re: A question about substitution principle
- From: Dmitry A. Kazakov
- A question about substitution principle
- Prev by Date: Re: A question about substitution principle
- Next by Date: substitution principle and contract
- Previous by thread: Re: A question about substitution principle
- Next by thread: Re: A question about substitution principle
- Index(es):
Relevant Pages
|