Chapter 9
- In knowledge representation,
inheritance is primarily applied
to describe taxonomic structures
in a declarative way.
Employing exceptions in inheritance
networks leads to non-monotony.
Non-monotonic inheritance networks
may give rise to inconsistencies.
See slide
[9-knowledge].
- The meaning of an inheritance lattice
may be expressed as a first order logic
formula.
An example is given in
slide
[9-logic]
- A type denotes a set of individuals.
The subtyping relation is essentially
the set inclusion relation,
with some additional constraints.
However, the subtype relation is best
defined by means of subtype refinement
rules.
- See slide
[9-subtypes].
- The contravariant nature of the
function subtype refinement rule
may be explained by relying on the
business service metaphor:
refining a service means better work
for less money.
Or, put differently,
refining a function means imposing
less constraints on the client,
yet delivering a result that is
more tightly defined.
See slide
[9-functions].
- The notion of objects as records
is introduced simply to justify
the interpretation of objects as records or
tuples of values and functions.
Again employing a business metaphor,
regarding an object as a collection
of services, improving such a collection
means offering more, and possibly
better, services.
See slide
[9-objects].
- Typed formalisms provide protection
against errors.
Yet, untyped formalisms are generally more
flexible.
In the practice of computer science
and mathematics, untyped formalisms
are surprisingly popular.
- A first distinction may be made between
universal polymorphism and ad hoc polymorphism,
which accounts for overloading and
coercion.
Universal polymorphism may be subdivided
into parametric polymorphism,
which covers template classes,
and inclusion polymorphism,
that results from derivation by inheritance.
See slide
[9-flavors].
- Inheritance allows for
the incremental development of object descriptions.
A child class may be regarded as
modifying the parent base class,
as it may include additional attributes
and methods and may refine inherited
attributes or methods.
- See slides
[sli-9-c-subtypes],
[sli-9-c-intersection]
and [sli-9-c-bounded].
- (a) ,
(b) ,
(c) .
- (a) No, since .
(b) No, since
,
because .
(c) Yes, since
.
- To give an example,
if you have a record x of
type
then you do not need to know the precise
nature of the (hidden) type
to be able to type the expression
as Int.
See slide
[9-ADT].
- A possible realization is given by the
record
,
for .
The corresponding package is given
by the expression
.
Another realization is given by the record
type
where R stands for
.
- The proof involves unrolling.
Let
and
.
Now suppose that then,
by unrolling, we would have
that
,
and hence, by the function subtyping rule,
that and .
This would only hold if ,
which is obviously not the case.
- Let
and assume that ,
then by unrolling
we have that
which clearly holds since
.
And, by applying the refinement rule
for recursive types
(given in slide
[9-recursion]),
we indeed have that .