Introduction
This document defines a data model called Abstract Values.
All values in this data model are typed constants, which are accessed indirectly by reference.
The data model may be referenced by other documents in order to ease definition when representation of a value is not important.
Document conventions
Key words
The key words ‘MUST,’ ‘MUST NOT,’ ‘REQUIRED,’ ‘SHALL,’ ‘SHALL NOT,’ ‘SHOULD,’ ‘SHOULD NOT,’ ‘RECOMMENDED,’ ‘NOT RECOMMENDED,’ ‘MAY,’ and ‘OPTIONAL’ in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
Identifier shorthand
All words written #likeThis in this document, when the word begins with #, MUST be prefixed with urn:uuid:3686e852-fa08-4826-91eb-c6fe22376f18 in order to form the full word.
For example, #example is a shorthand notation for urn:uuid:3686e852-fa08-4826-91eb-c6fe22376f18#example.
Abstract values
Property
A property is a named entity, associated with some other entity, called its subject.
A property restriction is a condition, which is applied to a subject. If the condition is unmet, the subject is invalid.
Domain
A domain is a set of immutable entities.
Each element of a domain MUST have at least one corresponding identifier, unless the element is a sequence. Because sequences are stored directly, they do not need an identifier.
All domains are represented by their respective value type.
The identifier of a value type is used to refer to the domain it represents for brevity.
The null is an entity, which is not an element of any domain.
Subdomain
A subdomain is a domain, which is a subset of a subdomain parent, which is another domain.
A subdomain property is a property, associated with a subdomain.
A subdomain restriction is a condition, which is applied to the elements of the subdomain parent. An element is contained within the subdomain only if the condition is met.
Value
A value represents an element of a domain, as an infinite, unordered sequence of properties,
The domain of all values is #Value.
The properties of a value are:
- pointers
- a finite, ordered sequence of value pointers, or null
- An empty sequence and null are different entities.
- identifier set
- a set of identifiers
- Property restriction: If pointers is null, the set MUST NOT be empty.
- known types
- a set of value types
- Property restriction: The result of dereferencing the subject to each of the value types in known types MUST NOT be null.
A value pointer is an internal reference to a value. It is not a value itself.
Dereferencing of values
Each domain MUST define its dereference procedure, which is an algorithm that, for a given value V, returns the element represented by V, or null if no such element exists.
In order to dereference a value V to (an element of the domain represented by) value type T:
- If T is
#Value, return V. - For each identifier id
in the identifier set of V:
- Let e be the result of running the dereference procedure of the domain represented by T with V as input.
- If e is not null, return e.
- Return null.
Matching of values
A value A matches another value B if and only if: for each value type T in known types of A: the result of dereferencing A to T and the result of dereferencing B to T is the same entity.
Equivalence of values
A value A is equivalent to another value B if and only if A matches B and B matches A.
Merging of values
In order to merge two values, A and B, which MUST be equivalent, into a new value M:
- Let M be a copy of A.
- If pointers of M is null, set it to pointers of B.
- For each other property p of B:
- If p does not exist in M, insert a copy of it to M; advance to the next property.
- Let vA be the value of p in M.
- Let vB be the value of p in B.
- If the value of p is not a [sequence][], then vA must be equivalent to vB; advance to the next property.
- If the ordered flag of p is zero,
then for each element eB in vB:
- Let found be false.
- For each element eA in vA:
- If eA is equivalent to eB:
- Set found to true.
- Set eA to the merge of eA and eB.
- If eA is equivalent to eB:
- If found is false, insert eB into vA.
- If the ordered flag of p is one:
- Let i be a sequence index with value 1.
- While i is less than or equal
to sequence length of vB:
- Let eA be the element at i in vA.
- Let eB be the element at i in vB.
- Set eA to the merge of eA and eB.
- Increment i by one.
Fields
A field is a value, which represents a field property.
A field property is a property, whose name is a field and whose value is a set.
The domain of all fields is #Field, which is a subdomain of #Value.
The dereference procedure of #Field is the same as of #Value.
A field restriction is a condition, evaluated against field F, to which the restriction applies, and set SET, which is the value of the field property named by F. When the condition is unmet, it causes SET to violate F.
The properties of a field are:
- supers
- a set of fields; empty by default
- The elements are other fields, the subject is a subfield of.
- implied types
- a set of value types; (
#Value) by default- The elements are implicitly inserted into the known types of a value, which contains the property named by the subject.
- permitted types
- a set of value types; (
#Value) by default- Field restriction: Each value in SET MUST be [compatible][] with permitted types.
- minimum amount
- an unsigned integer; 0 by default
- Field restriction: The amount of elements in SET MUST NOT be less than minimum amount.
- maximum amount
- an unsigned integer; infinity by default
- Field restriction: The amount of elements in SET MUST NOT be greater than maximum amount.
A value V is compatible with a set of value types SET if and only if the following algorithm returns true:
- For each value type vt
in known types of V:
- For each value type pt in SET:
- Return true if type-testing vt against pt returns true.
- For each value type pt in SET:
- Return false.
The field #id
The field #id represents the identifier set.
Its permitted types are: (#ValueType).
The field #type
The field #type represents the known types.
Its permitted types are: (#ValueType).
The field #implies
The field #implies represents the implied types.
Its implied types are: (#Field).
Its permitted types are: (#ValueType).
The field #permits
The field #permits represents the permitted types.
Its implied types are: (#Field).
Its permitted types are: (#ValueType).
The field #minAmount
The field #minAmount represents the minimum amount.
Its implied types are: (#Field).
Its permitted types are: (#UnsignedInteger).
Its maximum amount is: 1.
The field #maxAmount
The field #maxAmount represents the maximum amount.
Its implied types are: (#Field).
Its permitted types are: (#UnsignedInteger).
Its maximum amount is: 1.
Objects
Object domain
An object entity is a finite, ordered sequence of, optionally named, entities.
An object domain is a subdomain of the domain of all [object entities][].
An object-domain property is a subdomain property of an object domain.
Object
An object is a value, whose value type is #Object.
The #Object is an object type, which is a subtype of #Value.
An object O is the subject of a field F, only if F is an element of O.
An object property P is a property associated with object O, which is named P and whose value is the [field values][] of the field, which is an element of O and whose [type of field][] is P.
The dereference procedure of #Object, for identifier ID, is to look for an object, whose object property #id is equal to ID.
Using the [field-type template][], the following field types are defined:
#id#Object#ObjectIdentifier- 0 - infinity
- An identifier of the subject.
The identifier of the value type which represents the domain of all [object entities][] is #Object.
The dereference procedure of #Object is:
- Return an empty sequence.
- Let V be the value being dereferenced.
- If T is
- Let OT be the result of
dereferencing V to
#ObjectType.
Value type
A value type is an object, whose object type is #ValueType.
It represents a domain.
If S is a subtype of P, then both P and S are value types and S represents a subdomain of the domain represented by P.
Using the [field-type template][], the following field types are defined:
#isSubtypeOf#ValueType#ValueType- 0 - infinity
- A value type the subject is a subtype of.
Object type
An object type is an object, whose object type is #ObjectType.
The #ObjectType is a subtype of #ValueType.
It represents an object domain.
If S is a subclass of P, then both S and P are object types and S is a subtype of P.
The object type is assigned to an object either explicitly by the object property #hasType or implicitly by field properties.
Using the [field-type template][], the following field types are defined:
#hasType#Object#ObjectType- 0 - infinity
- An explicit object type of the subject.
#isSubclassOf#ObjectType#ObjectType- inherited
- An object type the subject is a subclass of.
- subfield of
#isSubtypeOf
Field type
A field type is an object, whose object type is #FieldType.
It represents implicit field properties of a field.
Using the [field-type template][], the following field types are defined:
#subjectType#FieldType#ObjectType- 0 - infinity
- One element of the [subject types][].
#valueType#FieldType#ValueType- 1 - infinity
- One element of the [permitted value types][].
#minAmount#FieldType#UnsingedInteger- 0 - 1
- The minimum amount.
#maxAmount#FieldType#UnsignedInteger- 0 - 1
- The maximum amount.
#isSubfieldOf#FieldType#FieldType- inherited
- A field type the subject is a subfield of.
- subfield of
#inheritsFrom.
Numbers
Number domain
A number domain is a subdomain of the domain of real numbers as defined by mathematics, with the addition of negative and positive infinities, negative and positive zeros, a not-a-number and an infinitesimal.
A number property is a subdomain property of a number domain.
This document defines the following number properties:
- minimum value
- a number; negative infinity by default
- Subdomain restriction: The element MUST be equal to or greater than the minimum value.
- maximum value
- a number; positive infinity by default
- Subdomain restriction: The element MUST be equal to or less than the maximum value.
- smallest step
- a positive number; infinitesimal by default
- Subdomain restriction: The element MUST be divisible by the smallest step.
Number type
A number type is an object, whose object type is #NumberType.
The #NumberType is a subtype of #ValueType.
It represents a number domain.
Using the [field-type template][], the following field types are defined:
#minValue#NumberType#Number- 0 - 1
- The minimum value.
#maxValue#NumberType#Number- 0 - 1
- The maximum value.
#step#NumberType#PositiveNumber- 0 - 1
- The smallest step.
Number
A number is a value, whose value type is #Number.
The #Number is a number type, which is a subtype of #Value.
The dereference procedure of #Number, for identifier ID, is to decode a number from ID.
Unsigned number
An unsigned number is a value, whose value type is #UnsignedNumber.
The #UnsignedNumber is a number type, which is a subtype of #Number.
The minimum value is zero.
Positive number
A positive number is a value, whose value type is #PositiveNumber.
The #PositiveNumber is a number type, which is a subtype of #Number.
Its minimum value is smallest step added to zero.
Negative number
A negative number is a value, whose value type is #NegativeNumber.
The #NegativeNumber is a number type, which is a subtype of #Number.
Its maximum value is smallest step subtracted from zero.
Integer
An integer is a value, whose value type is #Integer.
The #Integer is a number type, which is a subtype of #Number.
Its smallest step is one.
Unsigned integer
An unsigned integer is a value, whose value type is #UnsignedInteger.
The #UnsignedInteger is a number type, which is a subtype of #UnsignedNumber and #Integer.
Positive integer
A positive integer is a value, whose value type is #PositiveInteger.
The #PositiveInteger is a number type, which is a subtype of #PositiveNumber and #Integer.
Negative integer
A negative integer is a value, whose value type is #NegativeInteger.
The #NegativeInteger is a number type, which is a subtype of #NegativeNumber and #Integer.
Duration
A duration is a value, whose value type is #Duration.
The #Duration is a number type, which is a subtype of #Number.
It represents an amount of seconds.
A representation format MAY encode a duration in units of seconds, minutes and hours.
One second is equal to one.
One minute is equal to sixty seconds, or sixty.
One hour is equal to sixty minutes, or three thousand six hundred.
The dereference procedure of #Duration, for identifier ID, is to decode a duration from ID.
Bit
A bit is a value, whose value type is #Bit.
The #Bit is a number type, which is a subtype of #UnsignedInteger.
Its maximum value is one.
Zero represents a cleared bit, or a boolean value of false.
One represents a set bit, or a boolean value of true.
The dereference procedure of #Bit, for identifier ID, is to decode a bit from ID.
Octet
An octet is a value, whose value type is #Octet.
The #Octet is a number type, which is a subtype of #UnsignedInteger.
Its maximum value is two hundred fifty five, i.e. 255 in base 10 and 0xFF in base 16.
Character
A character is a value, whose value type is #Character.
The #Character is a number type, which is a subtype of #UnsignedInteger.
Its maximum value is one million one hundred fourteen thousand one hundred eleven, i.e. 1114111 in base 10 and 0x10FFFF in base 16.
Each number represents the corresponding Unicode code point. [UNICODE]
The dereference procedure of #Character, for identifier ID, is to decode a character from ID.
Sequences of values
Sequence domain
A sequence domain is a subdomain of the domain of finite, ordered sequences of values.
The total amount of elements in a sequence is called sequence length.
Each element has an assigned sequence index, beginning from 1 up to sequence length, in sequence order.
A sequence property is a subdomain property of a sequence domain.
This document defines the following sequence properties:
- minimum length
- an unsigned integer; zero by default
- Subdomain restriction: The sequence length of the element MUST be equal to or greater than the minimum length.
- maximum length
- an unsigned integer; positive infinity by default
- Subdomain restriction: The sequence length of the element MUST be equal to or less than the maximum length.
- element types
- a set of value type elements; {
#Value} by default- Subdomain restriction: For each value V in the element: 1) Let VT be the value type of V. 2) At least one value type ET of element types MUST be such that type-testing VT against ET returns true.
- ordered flag
- a bit; zero by default
- If one, the sequence index is important.
- unique flag
- a bit; zero by default
- Subdomain restriction: If one, there MUST NOT be two values in the element, which are equal to each other.
Sequence type
A sequence type is an object, whose object type is #SequenceType.
The #SequenceType is a subtype of #ValueType.
It represents a sequence domain.
Using the [field-type template][], the following field types are defined:
#minLength#SequenceType#UnsignedInteger- 0 - 1
- The minimum length.
#maxLength#SequenceType#UnsignedInteger- 0 - 1
- The maximum length.
#elementType#SequenceType#ValueType- 0 - 1
- One element of element types.
#ordered#SequenceType#Bit- 0 - 1
- The ordered flag.
#unique#SequenceType#Bit- 0 - 1
- The unique flag.
Multiset
A multiset is a value, whose value type is #Multiset.
The #Multiset is a sequence type, which is a subtype of #Value.
List
A list is a value, whose value type is #List.
The #List is a sequence type, which is a subtype of #Multiset.
Its ordered flag is one.
Set
A set is a value, whose value type is #Set.
The #Set is a sequence type, which is a subtype of #Multiset.
Its unique flag is one.
Sequences of bytes
Byte-sequence domain
A byte-sequence domain is a subdomain of a sequence domain.
Its element types contains exactly one number type only, which is called the byte type.
Its ordered flag is one.
A bit-sequence property is a subdomain property of a byte-sequence domain.
This document defines the following byte-sequence properties:
- byte width
- an unsigned integer
- Subdomain restriction: The maximum value of the element's byte type MUST be equal to or greater than two to the power of the byte width minus one.
The dereference procedure of every byte-sequence domain, for identifier ID, is to decode a byte sequence from ID.
Byte-sequence type
A byte-sequence type is an object, whose object type is #ByteSequenceType.
The #ByteSequenceType is a subtype of #SequenceType.
It represents a byte-sequence domain.
Using the [field-type template][], the following field types are defined:
#byteWidth#ByteSequenceType#PositiveInteger- 1
- The byte width.
Every byte-sequence type is a subtype of #List.
Bit sequence
A bit sequence is a value, whose value type is #BitSequence.
The #BitSequence is a byte-sequence type.
Its byte type is #Bit.
Its byte width is one.
Octet sequence
An octet sequence is a value, whose value type is #OctetSequence.
The #OctetSequence is a byte-sequence type.
Its byte type is #Octet.
Its byte width is eight.
Sequences of characters
Character-sequence domain
A character-sequence domain is a subdomain of a sequence domain.
Its element types is {#Character}.
Its ordered flag is one.
A character-sequence property is a subdomain property of a character-sequence domain.
This document defines the following character-sequence properties:
- pattern
- a character sequence;
.*by default- Subdomain restriction: The element MUST match the [REGEX] expressed by pattern.
Character-sequence type
A character-sequence type is an object, whose object type is #CharSequenceType.
The #CharSequenceType is a subtype of #SequenceType.
It represents a character-sequence domain.
Using the [field-type template][], the following field types are defined:
#pattern#CharSequenceType#CharSequence- 0 - infinity
- An element in an implicit alternative, which forms the pattern.
Character sequence
A character sequence is a value, whose value type is #CharSequence.
The #CharSequence is a character-sequence type.
The dereference procedure of #CharSequence, for identifier ID, is to return ID.
Identifier
An identifier is a value, whose value type is #Identifier.
The #Identifier is a subtype of #CharSequence.
Internationalized Resource Identifier
An IRI is a value, whose value type is #IRI.
The #IRI is a subtype of #Identifier.
Its pattern is defined in [RFC3987], Section 2.
Uniform Resource Identifier
A URI is a value, whose value type is #URI.
The #URI is a subtype of #IRI.
Its pattern is defined in [RFC3986], Section 2.
Dates and times
Calendar domain
A calendar domain is a subdomain of the domain of days in a calendar.
A calendar property is a subdomain property of a calendar domain.
This document does not define any calendar properties.
Calendar type
A calendar type is an object, whose object type is #CalendarType.
The #CalendarType is a subtype of #ValueType.
It represents a calendar domain.
Date
A date is a value, whose value type is #Date.
The #Date is a calendar type.
It represents a day in the Gregorian calendar.
It has the following properties:
- year
- an integer
- month
- a positive integer; 1 is January, 12 is December
- Property restriction: The month MUST be within [1,12].
- day of month
- a positive integer
- Property restriction: The day of month MUST be within [1,31] and refer to an existing day within month.
- week
- a positive integer
- Property restriction: The week MUST be within [1,53] and be correct with regard to year, month and day of month.
- day of week
- a positive integer; 1 Monday, 7 is Sunday
- Property restriction: The day of week MUST be within [1,7] and be correct with regard to year, month and day of month.
-
The dereference procedure of
#Date, for identifier ID, is to decode a date from ID.Epoch
An epoch is a value, whose value type is
#Epoch.The
#Epochis a subtype of#Value.It represents a point in time.
Time
A time is a value, whose value type is
#Time.The
#Timeis a subtype of#Value.It represents a point in time relative to another one.
It has the following properties:
- epoch
- an epoch
- offset
- a duration
- Positive values are after epoch, negative before.
- date
- a date
- time
- a time
- The epoch is the beginning of date.
- Property restriction: The offset MUST be an unsigned number and be not greater than the amount of seconds date has.
- The epoch is the beginning of date.
- zone
- a duration
- The difference from the Universal Coordinated Time to a local time.
- If VT is TT, return true.
- Look up an object property
#isSubtypeOfin VT; for each value type ST in the result:- Type-test TT against ST; return true if the result is true.
- Return false.
- If FT is TT, return true.
- Look up an object property
#isSubfieldOfin FT; for each field type ST in the result:- Field-test TT against ST; return true if the result is true.
- Return false.
- Let values be unset.
- Look up an object property
#hasDefaultsin VT; for each object O in the result:- Let inherited be unset.
- Look up FT in O; set inherited to the result.
- If both values and inherited are not unset, return/raise an error.
- Set values to inherited.
- If values is not unset, return values.
- Look up an object property
#isSubtypeOfin VT; for each value type T in the result:- Let inherited be unset.
- Look for FT in T; set inherited to the result.
- If both values and inherited are not unset, return/raise an error.
- Set values to inherited.
- Return values.
#hasDefaults#ValueType#Object- 0 - infinity
- An object from which objects, whose object type is the subject, inherit fields.
- For each field F in O:
- Field-test FT against the [type of field][] of F; if false, advance to the next element.
- Return the [field values][] of F.
- Let values be unset.
- Look up an object property
#inheritsFromin O; for each object S in the result:- Let inherited be unset.
- Look up FT in S; set inherited to the result.
- If both values and inherited are not unset, return/raise an error.
- Set values to inherited.
- If values is not unset, return values.
- For each object type OT of O:
- Let inherited be unset.
- Look for FT in OT; set inherited to the result.
- If both values and inherited are not unset, return/raise an error.
- Set values to inherited.
- Return values.
#inheritsFrom#Object#Object- 0 - infinity
- An object from which the subject inherits fields.
- If I is
NaN, return not-a-number. - If I is
INFINITESIMAL, return infinitesimal. - Let V be the result of parsing a number expression from I.
- If I is not empty, return [invalid value][].
- Return V.
- Let op be an operation.
- Let arg1 be a number.
- Let arg2 be a number.
- According to the first characters of I:
- If
add(U+61, U+64, U+64, U+20), set op to addition. - If
sub(U+73, U+75, U+62, U+20), set op to subtraction. - If
mul(U+6D, U+75, U+6C, U+20), set op to multiplication. - If
div(U+64, U+69, U+76, U+20), set op to division. - If
pow(U+70, U+6F, U+77, U+20), set op to exponentiation. - If
ext(U+65, U+78, U+74, U+20), set op to root extraction. - If
log(U+6C, U+6F, U+67, U+20), set op to logarithm. - Otherwise, return the result of parsing a number from I.
- If
- Remove the first four characters from I.
- Set arg1 to the result of parsing a number expression from I.
- If arg1 is the [invalid value][], return [invalid value][].
- If the first character of I is not U+0020 SPACE, return [invalid value][].
- Remove the first character from I.
- Set arg2 to the result of parsing a number expression from I.
- If arg2 is the [invalid value][], return [invalid value][].
- Return the result of op with arguments arg1 and arg2. For exponentation and logarithm, arg1 is the base. For root extraction, arg1 is the exponent. If there is no defined value for the specified arguments, return not-a-number.
- Let V be the number zero.
- Let S be the bit zero.
- If the first character of I is
U+002B PLUS SIGN or U+002D MINUS SIGN:
- If the first character of I is U+002D MINUS SIGN, set S to one.
- Remove the first character from I.
- If the first character of I is
between U+0030 DIGIT ZERO and U+0039 DIGIT NINE:
- While the first character of I is between U+0030 DIGIT ZERO and U+0039 DIGIT NINE:
- If the first character of I is U+002E FULL STOP:
- Let F be the number zero.
- Remove the first character from I.
- If the first character of I is not between U+0030 DIGIT ZERO and U+0039 DIGIT NINE, I is invalid.
- While the first character of I is between U+0030 DIGIT ZERO and U+0039 DIGIT NINE:
- If the first three characters of I
are all U+002E FULL STOP:
- Remove the first three characters from I.
- Set F to the number corresponding to the just-parsed infinite decimal expansion. The specifics are out of scope of this document.
- Add F to V.
- Return [invalid value][].
- Set value to the constant number.
- Remove the corresponding-to-the-name amount of characters from I.
- If S is one, set V to the result of subtracting V from zero.
- Return V.
The dereference procedure of #Time, for identifier ID, is to decode a time from ID.
Timestamp
A timestamp is a value, whose value type is #Timestamp.
The #Timestamp is a subtype of #Date and #Time.
It represents a point in time relative to the start of a day.
It has the following properties:
The dereference procedure of #Timestamp, for identifier ID, is to decode a timestamp from ID.
Algorithms
Value-type test
In order to type-test value type TT against value type VT:
Field-type test
In order to field-test field type TT against field type FT:
Value lookup in type
In order to look for object property FT in value type VT:
Using the [field-type template][], the following field types are defined:
Value lookup in object
If object A inherits from B, then both A and B are objects, and A has an object property #inheritsFrom, which contains B as one of its elements.
In order to look up object property FT in object O:
Using the [field-type template][], the following field types are defined:
Decode a number
In order to decode a number from identifier I:
In order to parse a number expression from identifier I (passed by reference):
In order to parse a number from identifier I (passed by rerefence):
A known constant number name is one of:
| Constant name | Description |
|---|---|
INF | infinity |
PI | Pi |
E | e |
Other documents MAY define more constants.
Decode a duration
In order to decode a duration from identifier I:
Decode a bit
In order to decode a bit from identifier I:
Decode a character
In order to decode a character from identifier I:
Decode a byte sequence
In order to decode a byte sequence from identifier I:
Decode a time
In order to decode a time from identifier I:
Decode a date
In order to decode a date from identifier I:
Decode a timestamp
In order to decode a timestamp from identifier I:
Representation format
In order to transfer values, they need to be represented somehow.
A representation format maps the values to a specific representation.
Representation formats are defined by other documents.
A format MUST be able to represent at least [references][].