Sather Home Page

Section 8.1.1.3:
$IS_EQ

abstract class $IS_EQ

Formal Definitions

This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.

types

SAME = object_type ;
$IS_EQ = set of object_type

state

multi : $IS_EQ
inv multi_types ==
forall obj in set multi_types & sub_type($IS_EQ,obj)
NOTE See the important note about vdm state in the notes on vdm-sl usage in this specification.

This abstract class defines the concept of object value equality valid over the lifetime of the whole object. The exact nature of value equality is therefore defined by classes sub-typing from it.

NOTES
  • In defining this abstraction it is the intention that any inheriting class definition of equality should be for immutable equality. It is, however, possible that some reference class may have equality defined on it - equality which is not 'object equality' (ie the same object!). See the definition of text string ordering in the class REPERTOIRE for an essential example of this.
  • If a class sub-types from both this abstract class and also from $HASH then it is possible for objects to be placed in a hash table or map and then later retrieved.

This class defines the following single feature.


is_eq

any class sub-typing from this is required to have an equality feature. While the name of this feature permits its use in infix expressions, the semantics are entirely dependent on the including class and may bear absolutely no relation to the more usual value or identity predicate.

is_eq (
other : $OB
) : BOOL
Formal Signature
is_eq(self : SAME, other : $OB) res : BOOL
Pre-condition

Note that in contrast to a pre-condition written in Sather source code, in vdm-sl the type SAME is not an optional type and therefore self must exist, leading to the vacuous pre-condition - true.

Post-condition

This post-condition is defined as value equality (in the vdm-sl sense), however, an implementation class could choose to do otherwise - depending on the semantucs of the object being modelled.

post res = (self = other)

This predicate returns true if and only if self is equal to other for this element type. Note that the name of this feature enables it to be used in an infix expression.


Language Index Library Index Basic Index
Comments or enquiries should be made to Keith Hopper.
Page last modified: Tuesday, 23 May 2000.
Produced with Amaya