comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Preventing type extensions
Date: Fri, 24 Sep 2010 20:47:28 +0300
Date: 2010-09-24T20:47:28+03:00	[thread overview]
Message-ID: <8g46hgFkfqU1@mid.individual.net> (raw)
In-Reply-To: <9d1804mxit9j$.wyo5zgwjxh71.dlg@40tude.net>

Dmitry A. Kazakov wrote:
> On Fri, 24 Sep 2010 16:30:29 +0300, Niklas Holsti wrote:
> 
>> Dmitry A. Kazakov wrote:
>>> On Tue, 21 Sep 2010 19:11:33 +0200, Georg Bauhaus wrote:
>>>
>>>> On 21.09.10 18:25, Dmitry A. Kazakov wrote:
>>>>
>>>>> horse /= animal
>>>> It will help immensely, I think, at least those of us who do
>>>> not do type theory on an every day basis, if we had a glossary
>>>> of terms for interpreting expression like "horse /= animal".
>>> Gosh, it was no more than just this: if horse is an animal that does not
>>> imply they are interchangeable. Compare: "all horses have hoofs" and "all
>>> animals have hoofs."
>>>
>>> is-a /= is
>>> member /= set
>>>
>>> Moreover:
>>>
>>> is-a /= substitutable (greeting to the LSP!)
>>>
>>> Compare: "some animals have tentacles" and "some horses have tentacles."
>> Those are not properties of "horses" and "animals", but properties of 
>> the *set* of horses and the *set* of animals.
> 
> horses is set of horses.

Incomprehensible. What do you mean?

>> The property "all horses have hooves" expresses a universal property of 
>> horses: if X is a horse, then X has hooves. The statement "some horses 
>> have tentacles" says nothing about any given horse X.
> 
> Both are predicates:

No, they are formulas. "has_hooves(X)" is a predicate that can be true 
or false for a given object X.

> forall x in horses, x has hooves

That is a universally ("forall") quantified formula that uses the 
predicate has_hooves. The LSP "properties" are implicitly universally 
quantified. To quote 
http://reports-archive.adm.cs.cmu.edu/anon/1999/CMU-CS-99-156.ps, with 
implicit quantification inserted in [] by me:

"/Subtype Requirement/: Let phi(x) be a property provable about [all] 
objects x of type T. Then phi(y) should be true for [all] objects of 
type S where S is a subtype of T."

The following paragraph makes universal quantification clearer:

"We focus on two kinds of properties, /invariants/, which are properties 
true of all states, and /history properties/ which are properties true 
of all sequences of states."

> exists x in animals, x has tentacles

So far as I understand LSP, existentially quantified formulas are not 
considered. Continuing the quote above:

"We do not address other kinds of safety properties of computations, 
e.g. the existence of an object in a state,...".

> [ if you dropped existential quantification, you would not be able to
> describe functions returning values ]

I don't think the LSP model of computation tries to, or needs to, 
describe functions in that sense; it uses postconditions which simply 
assume the existence of a return value and state properties of all 
possible return values.

By the way, note the inclusion of "history properties" in the LSP, this 
is an important point that (I think) has been ignored in this 
discussion. For example, in order to show that the class of Squares is 
not an LSP subtype of the class of Rectangles one must use history 
properties and consider what happens when the program changes the width 
of a Square, seen as a Rectangle, without also changing the height to 
the same new value.

A consequence is that LSP depends not only on the static properties of 
objects (has_hooves) but also on the set of "mutating" operations. If we 
were to define a Rectangle class that did not allow independent setting 
of width and height, but only a uniform size scaling, Squares would be 
an LSP subtype of these Rectangles.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  reply	other threads:[~2010-09-24 17:47 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-12 10:18 Preventing type extensions Florian Weimer
2010-09-12 11:59 ` Ludovic Brenta
2010-09-12 12:53   ` Florian Weimer
2010-09-12 21:23     ` Maciej Sobczak
2010-09-13  5:32       ` Florian Weimer
2010-09-13  7:13         ` Dmitry A. Kazakov
2010-09-13  9:19           ` Georg Bauhaus
2010-09-13  9:42             ` Dmitry A. Kazakov
2010-09-13 10:23               ` Niklas Holsti
2010-09-13 12:55                 ` Cyrille
2010-09-13 13:55                   ` Dmitry A. Kazakov
2010-09-13 21:13                   ` J-P. Rosen
2010-09-21 13:57                     ` Cyrille
2010-09-21 14:19                       ` Dmitry A. Kazakov
2010-09-21 14:44                         ` Cyrille
2010-09-21 16:25                           ` Dmitry A. Kazakov
2010-09-21 17:11                             ` Georg Bauhaus
2010-09-21 18:11                               ` Dmitry A. Kazakov
2010-09-23 20:00                                 ` Simon Wright
2010-09-23 20:49                                   ` Dmitry A. Kazakov
2010-09-24  9:10                                     ` Georg Bauhaus
2010-09-24 10:24                                       ` Dmitry A. Kazakov
2010-09-24 13:30                                 ` Niklas Holsti
2010-09-24 16:27                                   ` Dmitry A. Kazakov
2010-09-24 17:47                                     ` Niklas Holsti [this message]
2010-09-24 19:42                                       ` Dmitry A. Kazakov
2010-09-21 14:32                       ` J-P. Rosen
2010-09-21 15:02                         ` Cyrille
2010-09-21 15:26                           ` J-P. Rosen
2010-09-21 16:18                             ` Cyrille
2010-09-22  8:01                               ` J-P. Rosen
2010-09-22 17:28                                 ` Cyrille
2010-09-22 19:30                                   ` Ludovic Brenta
2010-09-22 19:51                                     ` Florian Weimer
2010-09-22 20:14                                       ` Dmitry A. Kazakov
2010-09-22 20:25                                         ` Florian Weimer
2010-09-22 20:38                                           ` Dmitry A. Kazakov
2010-09-22 21:25                                             ` Vinzent Hoefler
2010-09-22 21:20                                           ` Georg Bauhaus
2010-09-22 20:16                                       ` Ludovic Brenta
2010-09-22 20:34                                         ` Florian Weimer
2010-09-22 22:45                                           ` Britt Snodgrass
2010-09-23  8:02                                           ` Ludovic Brenta
2010-09-23 16:51                                     ` Pascal Obry
2010-09-23 18:37                                       ` Florian Weimer
2010-09-23 18:55                                         ` Pascal Obry
2010-09-23 20:28                                       ` Ludovic Brenta
2010-09-24  9:20                                         ` Ludovic Brenta
2010-09-24 14:49                                           ` Simon Wright
2010-09-24 15:09                                             ` Ludovic Brenta
2010-09-24 16:21                                           ` Robert A Duff
2010-09-25  7:10                                         ` Pascal Obry
2010-09-25 12:03                                           ` Brian Drummond
2010-09-24  8:16                                   ` J-P. Rosen
2010-09-24  8:39                                     ` Cyrille
2010-09-24  9:27                                       ` Cyrille
2010-09-29 16:47                                         ` J-P. Rosen
2010-09-30 10:08                                           ` Cyrille
2010-10-05 17:02                                             ` J-P. Rosen
2010-10-08  7:50                                               ` Cyrille
2010-10-08 13:58                                               ` Cyrille
2010-10-08 20:12                                                 ` Dmitry A. Kazakov
2010-10-11  7:57                                                   ` Cyrille
2010-10-11  8:24                                                     ` Dmitry A. Kazakov
2010-10-12  5:23                                                   ` Shark8
2010-10-13  9:06                                                 ` J-P. Rosen
2010-10-13 17:37                                                   ` Cyrille
2010-10-13 18:50                                                     ` Dmitry A. Kazakov
2010-09-21 14:50                       ` (see below)
2010-09-21 17:37                         ` Cyrille
2010-09-21 19:07                           ` (see below)
2010-09-13 13:05                 ` Dmitry A. Kazakov
2010-09-13 20:21                   ` Niklas Holsti
2010-09-13 21:00                     ` Dmitry A. Kazakov
2010-09-13 21:10                 ` J-P. Rosen
2010-09-14 12:16                   ` Niklas Holsti
2010-09-14 16:46                     ` Dmitry A. Kazakov
2010-09-14 18:08                       ` Niklas Holsti
2010-09-14 18:32                         ` Niklas Holsti
2010-09-15  8:18                         ` Dmitry A. Kazakov
2010-09-14 17:04                     ` J-P. Rosen
2010-09-13 15:12               ` Securing type extensions (was: Preventing type extensions) Georg Bauhaus
2010-09-13 15:29                 ` Securing type extensions Dmitry A. Kazakov
2010-09-13 17:23                 ` Simon Wright
2010-09-13 20:22                   ` Georg Bauhaus
2010-09-13 20:41                     ` Dmitry A. Kazakov
2010-09-14 10:02                       ` Georg Bauhaus
2010-09-14 12:22                         ` Dmitry A. Kazakov
2010-09-14 21:18                           ` Georg Bauhaus
2010-09-15  8:15                             ` Dmitry A. Kazakov
2010-09-15 20:47                               ` Georg Bauhaus
2010-09-16  7:47                                 ` Dmitry A. Kazakov
2010-09-16 11:52                                   ` Georg Bauhaus
2010-09-16 12:45                                     ` Dmitry A. Kazakov
2010-09-16 20:53                                       ` Georg Bauhaus
2010-09-16 21:37                                         ` Dmitry A. Kazakov
2010-09-17  8:45                                           ` Georg Bauhaus
2010-09-17  9:39                                             ` Dmitry A. Kazakov
2010-10-05  5:59                     ` Randy Brukardt
2010-09-13 18:32           ` Preventing " Florian Weimer
2010-09-13 20:30             ` Dmitry A. Kazakov
2010-09-22 19:41               ` Florian Weimer
2010-09-22 20:34                 ` Dmitry A. Kazakov
2010-09-22 21:10                   ` Georg Bauhaus
2010-09-17  0:16           ` Shark8
2010-09-17  7:04             ` AdaMagica
2010-09-17 21:05               ` Shark8
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox