![]() |
Section 8.11.1.2:
|
![]() |
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 ; $ENUM_SET = set of object_type state multi : $ENUM_SET inv multi_types == forall obj in set multi_types & sub_type($ENUM_SET,obj)
NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification. |
This abstraction models an arbitrary set of an enumeration whose size is the cardinality of the enumeration when implementation class sub-typing from it is instantiated.
The purpose of this abstraction is to provide a facility for manipulating externally specified 'flag' or 'option' bits in some value read from or written to an operating system or hardware device.
The number of binary digits in such a set will in general not exceed the number of bits in a machine word. This feature, however, does not have any such restriction.
size(self : SAME) res : CARD
Since the argument is not optional, this pre-condition is vacuously true.
post res = card dom self
This feature provides the count of the number of binary digits (bits) which constitute the set.
Provided that there are no more bits in the set than will fit into a number-sized binary object, this feature provides a bit-pattern in which the bits of the set are in the least significant end of the resulting value, the remaining 'unused' bits being clearbit.
num_bits(self : SAME) res : NUM_BITS
pre size(self) <= NUM_BITS.asize
post res = self
This feature returns the set in the lowest size bits of the result - other bits being clear.
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 ; $ENUM_SET_STP_ELEM = set of object_type state multi : $ENUM_SET_STP_ELEM inv multi_types == forall obj in set multi_types & sub_type($ENUM_SET_STP_ELEM,obj)
NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification. |
This abstraction models arbitrary bit sets whose size (in bits) is determined by the element type ELEM which must be an enumeration.
This is the sole creation routine; it returns the empty set.
empty | : STP |
empty() res : T
This is a creation routine without arguments and the pre-condition is therefore vacuously true.
post is_empty(res)
This feature returns the empty set - not void.
This predicate returns true if no elements are contained in the set - ie it is the mathematical set written in vdm-sl as '{}'.
is_empty | : STP |
is_empty(self : SAME) res : BOOL
This is a predicate with self as the only (non-optional) argument; the pre-condition is therefore vacuously true.
post forall elem | elem in set dom self & elem = clearbit
This feature returns true if and only if self is the empty set.
The remaining features of this abstraction are the logical operations on sets. Except for the set membership operation (contains) they are specified in terms of the named operations which permit the use of infix notation in accordance with the following set operation equivalence -
Name | Operand | Function | Name | Operand | Function |
plus | ELEM | union | plus | STP | union |
minus | STP | difference | times | STP | intersection |
div | STP | sym difference | is_eq | STP | equality |
is_leq | STP | simple sub-set | is_lt | STP | proper sub-set |
This variant of the plus feature is required as a useful convenience to include the argument in the set.
plus | ( |
elem : ELEM | |
) : STP |
plus(self : T, elem : ELEM) res : T
Since there are no constraints on either the set or the element values for this operation, this pre=condition is vacuoculy true.
post contains(res, elem)
This feature includes the argument element into the set returned. It is needed in the absence of any other create operation but empty.
This variant of the plus feature provides the mathematical set union operation.
plus | ( |
other : STP | |
) : STP |
plus(self : T, other : T) res : T
Since there are no constraints on either set for this operation, this pre=condition os vacuously true.
post res = self union other
This feature returns the set which is the set union of the argument and self.
This feature provides the mathematical set difference operation.
minus | ( |
other : STP | |
) : STP |
minus(self : T, other : T) res : T
Since there are no constraints on either set for this operation, this pre-condition is vacuously true.
post res = self \ other
This feature returns the set which is the set difference of the argument and self.
This feature provides the mathematical set intersection operation.
times | ( |
other : STP | |
) : STP |
times(self : T, other : T) res : T
Since there are no constraints on either set for this operation, this pre=condition is vacuously true.
post res = self inter other
This feature returns the set which is the set intersection of the argument and self.
This feature provides the mathematical set symmetric difference operation.
div | ( |
other : STP | |
) : STP |
div(self : T, other : T) res : T
Since there are no constraints on either set for this operation, this pre-condition is vacuously true.
post res inter self = self and res inter other = other
This feature returns the set which is the set symmetric difference of the argument and self.
This predicate provides the mathematical set membership operation.
contains(self : T, elem : ELEM) res : BOOL
Since there are no constraints on either the set or the element values for this operation, this pre-condition is vacuously true.
post res = (elem in set self)
This feature returns true if and only if elem is in the set.
This predicate provides the mathematical set equality relation.
is_eq(self : T, other : T) res : BOOL
Since there are no constraints on either the set or the element values for this operation, this pre-condition is vacuously true.
post res = (self = other)
This feature returns true if and only if the two sets contain the same elements and no others.
This predicate provides the mathematical subset relation.
is_leq(self : T, other : T) res : BOOL
Since there are no constraints on either the set or the element values for this operation, this pre-condition is vacuously true.
post res = (self subset other)
This feature returns true if and only if self is a simple sub-set of other.
This predicate provides the mathematical proper subset relation.
is_lt(self : T, other : T) res : BOOL
Since there are no constraints on either the set or the element values for this operation, this pre-condition is vacuously true.
post res = ((self subset other) and not (self = other))
This feature returns true if and only if self is a proper sub-set of other.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Non-numeric Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Wednesday, 30 May 2001. |
![]() |