![]() |
Section 8.11.2.1 |
![]() |
This class provides the functionality of the basic Boolean logic domain. BOOL objects represent boolean values and either have the value `true' or the value `false'. The pervasive class BOOL bool defines only the three fundamental operations and, or and not. This library class defines several additional operators and conversion routines.
The following feature is required to be implemented for this class in accordance with the specification given in $IS_EQ :-
The following features are required to be implemented for this class in accordance with the specification given by inheritance in $INSTR of which $ANCHORED_FMT is a sub-type :-
The following features are required to be implemented for this class in accordance with the specifications given by inheritance in $STR of which $ANCHORED_FMT and $IMMUTABLE are both sub-types :-
The following features are required to be implemented for this class in accordance with the specifications given by inheritance in $ANCHORED_FMT :-
The following features are required to be implemented for this class in accordance with the specifications given in $BINARY of which $IMMUTABLE is a sub-type :-
This feature provides a mechanism for creating a truth value from an octet. An implementation is free to use any bit-pattern to represent the truth value, provided that it is the identical bit-pattern to that produced when the binstr feature is applied (producing a single element binary string).
Note that the selector applied to the binstr operation result is accessing the first (and only) component.
This routine returns the truth value corresponding to the bit-pattern in the argument val.
This final variant of the create operation creates a truth value from the encoding of a string representation in the executing environment repertoire and encoding. The 'word' to be converted is expected to be in the language of the local culture.
The string method is_prefix is defined in the class STR.
This routine returns the truth value corresponding to the text string argument. The actual characters required (and their encoding) are determined by the current cultural environment.
NOTE | The internationally defined default characters for 'true' and 'false' are the digits '1' and '0' respectively in the local encoding. Most cultures will define pairs of values such as 'True/False' in English speaking cultures, 'Wahr/Falsch' in German speaking cultures, etc. |
This feature provides the standard Boolean inversion operation.
not | : SAME |
The name of the formal operation corresponding to 'not' has been modified since the word 'not' is a keyword in vdm-sl.
This feature returns the logical complement of self.
This feature provides the Boolean conjunction operation.
and | ( |
other : SAME | |
) : SAME |
The name of the formal operation corresponding to 'and' has been modified since the word 'and' is a keyword in vdm-sl.
This routine returns true if and only if self and other are both true, otherwise false.
or | ( |
other : SAME | |
) : SAME |
Formal Signature
or(self : SAME, other : SAME) res : SAME
Post-condition
res = (self
or other)
This routine returns true if and only if either self or other or both are true, otherwise false.
This feature provides the logical equality operation for Boolean values. It may be used in infix logical expressions.
is_eq | ( |
other : SAME | |
) : SAME |
This routine returns true if and only if both self and other have the same value, otherwise false.
This feature provides the logical equality operation for a logical value which may be 'hidden' in an abstract type and self. It may be used in infix logical expressions. Note, however, that object equality will be used if the argument is not of this type.
The formal argument type is 'any object type', but an actual argument must, of course, be an instantiated object.
This routine returns true if and only if both self and other have the same value, otherwise false. This version is provided for use where some abstract type object happens to derive from $IS_EQ. True can only be returned if the actual object is of this type.
This feature returns a validity indicator if the string contained in the argument is a valid representation of either the value true or the value false. If empty then the corresponding indication is given, otherwise an out of range indication. The string does not have to be a complete 'word', rather it must be at least as long as needed to differentiate the two values - thus, in English where "True" and "False" are the two values, then the first character alone is all that is needed. If the rest of the word is there and does not correspond to 'rue' or 'alse' then, of course, out of range is returned.
is_bool | ( |
str : STR | |
) : CONVERSION_RESULTS |
This routine returns All_Right if str is a valid text representation of a truth value, Empty if the string was empty and Out_of_Range for any other string content.
This is the first of those routines provided to complete the possible binary operations in the logical domain. They all have their usual mathematical meaning.
xor | ( |
other : SAME | |
) : SAME |
This routine returns true if and only if only one of self and other is true, otherwise false. It is identical to a not equal predicate.
xnor | ( |
other : SAME | |
) : SAME |
This routine returns true if and only if self and other have the same logical value. It is identical to the is_eq predicate.
nand | ( |
other : SAME | |
) : SAME |
This routine returns the logical complement of the result of anding self and other.
nor | ( |
other : SAME | |
) : SAME |
This routine returns the logical complement of the result of oring self and other.
implies | ( |
other : SAME | |
) : SAME |
This routine returns if and only if self implies other. It is the same operation as nand_not.
This routine is identical to the and operation built in to the language. It is provided for possible use as a bound routine.
and_rout | ( |
other : SAME | |
) : SAME |
This routine is the same as the and operation useful when making bound routines.
This routine also corresponds to a built-in operator - or. It is provided for possible use as a bound routine.
or_rout | ( |
other : SAME | |
) : SAME |
This routine is the same as the or operation - provided for use when making bound routines.
and_not | ( |
other : SAME | |
) : SAME |
This routine returns the result of self and the complement of other.
or_not | ( |
other : SAME | |
) : SAME |
This routine returns the result of self or the complement of other.
nand_not | ( |
other : SAME | |
) : SAME |
This routine returns the result of self nanded with the complement of other. It is the same as the complement of self or other.
nor_not | ( |
other : SAME | |
) : SAME |
This routine returns the result of self nored with the complement of other. It is the same as the complement of self and other.
This operation is provided solely for backward compatibility with earlier versions of the library. It returns the value 1 when self is true and the value zero otherwise.
This routine returns the value 1 if self is true, otherwise the value zero.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Non-numeric Index |
Comments or enquiries should be made to
Keith
Hopper. Page last modified: Wednesday, 22 November 2000. |
![]() |