Sortal Description Language   Index

 

Sorts

Sorts are class structures, either specifying a single data type or a composition of other class structures.

We distinguish five types of sorts: primitive sorts, attribute sorts, disjunctive sorts, recursive sorts and aspect sorts.

  • A primitive sort specifies a single data type.
  • An attribute sort is a subordinate, semi-conjunctive composition of a primitive sort (its base) with any other sort (its weight) under the object-attribute relationship.
  • A disjunctive sort is a co-ordinate, disjunctive composition of any number of sorts.
  • A recursive sort is a sort that is recursively defined as a composition containing the same sort as one of the component entities.
  • An aspect sort is a primitive sort that consists of two or more aspects, defining different views of a same data type, e.g., relationships.

A sort is defined by its name and an associated expression. An aspect sort has two or more names, one for each aspect. The name of a sort may include the specification of a profile name, which is necessary if the sort is used under a different profile than the one it has been defined under. More on profiles

  • A primitive sort is expressed by its characteristic individual, possibly augmented with one or more arguments (depending on the characteristic individual).
  • An attribute sort is expressed as a composition, under the attribute operator (^), of a primitive sort and any other sort (in that order).
  • A disjunctive sort is expressed as a composition, under the operation of sum (+), of two or more sorts.

All component sorts in the definition of a sort must be defined either before, or, at the time of the specification. That is, a sort expression may contain other sort definitions.
The sort that is being defined may itself occur in its expression, thus, allowing for the definition of a recursive sort.

The definition of a sort is preceded by the keyword sort and followed by a semicolon.

sort sort-definition ;

sort-definition		    sort-name : sort-specification
			    ( aspects ) : aspects-specification

sort-name		    identifier
sort-name		    profile-name ' identifier

profile-name		    identifier

sort-specification	    [ characteristic ]
			    [ characteristic ] ( arguments )
			    sort-expression

aspects			    sort-name , sort-name

aspects-specification	    [ Property ] ( sort-name , sort-name )

sort-expression		    sort-term
			    sort-term + sort-expression

sort-term		    sort-factor
			    sort-factor ^ sort-term

sort-factor		    sort-name
			    ( sort-expression )
			    ( sort-definition )

arguments		    argument
			    argument , arguments
			    { enumeration-values } , [ rankings ]

argument		    number
			    identifier
			    "string"

enumeration-values	    identifier
			    identifier , enumeration-values

rankings		    identifier
			    identifier rankings

The terms identifier, number (floating-point number) and string follow the normal conventions.
Property is currently the only characteristic individual that specifies an aspect sort. It accepts two existing primitive sorts as arguments and defines two aspects.

Though the attribute relationship only applies to a primitive sort in conjunction with any other sort, the attribute operator (^) may be applied to any two sorts. The following two rules (associative and distributive) specify the result of the attribute operation in the case that the first operand is not a primitive sort.
(a ^ b) ^ c  →  a ^ b ^ c   (or  a ^ (b ^ c) )
(a + b) ^ c  →  a ^ c + b ^ c
These rules apply irrespective of whether (a ^ b) or (a + b) are named or not.

In the case of the operation of sum (+), the following associative rule applies if (a + b) is not named. Furthermore, any sort that appears more than once in the expression of sum is replaced by a single occurrence:
(a + b) + c  →  a + b + c
a + a  →  a

Some characteristic individuals allow for the specification of one or more arguments, one or two require this.

  • The characteristic individual Weight allows for a numeric argument that specifies the upper bound of the range of numeric values. The lower bound is always 0.0.
  • The characteristic individual Color accepts two identifier arguments that specify the color space, either RGB, HSV or HSB and the particular behavior for adding two color values, either RGB_MAX (the maximum of the respective R, G and B values), RGB_SUM (the sum of the respective R, G and B values), RGB_AVG (the average of the respective R, G and B values), or RGB_ALPHA (a function of the respective alpha values) (HSV (or HSB) color values are always converted to RGB and back when adding two color values). If no parameters are specified, the color space is RGB and the behavior for adding two color values is RGB_MAX.
  • The characteristic individual Enumerative requires two arguments that specify the enumeration values as well as their mutual rankings. The enumeration values are specified as a list of identifiers, separated with commas and enclosed in curly brackets, and their ranking as a list of identifiers corresponding the enumeration values resulting from the addition of every combination of two values (ordered as a matrix, corresponding the original enumeration ordering), separated with spaces and enclosed in square brackets. The length of the rankings list is necessarily the square value of the number of enumeration values.
  • The characteristic individual Date accepts two identifier arguments that specify the ISO language (ISO-639) and country (ISO-3166) codes for locale-sensitive formatting of a date to a string. If no parameters are specified, the date's string format equals the number of milliseconds since the standard base time 1/1/1970 00:00:00 GMT.
  • The characteristic individual Key allows for an identifier argument that specifies a prefix for all values. If no parameter is specified, four random characters preceded by an underscore will be used as prefix.
  • The characteristic individual Property requires the names of two primitivesorts as arguments, restricting all relationships to those between individuals from either sort. A sort of properties can only be an attribute weight sort to its argument sorts, or be a component in a disjunctive sort that is itself an attribute to either argument sort.

 

Examples

sort points : [Point];	    // A sort of points

sort labeledpoints : points ^ (labels : [Label]);
			    // A sort of labeled points defined from the sort of
			    // points and a sort of labels under the attribute
			    // relationship

sort (has_labels, has_points) : [Property] (points, labels);
			    // A sort of properties between points and labels. This
			    // sort defines two aspects has_labels and has_points

sort points_and_labels : points ^ has_labels + labels ^ has_points;
			    // A disjunctive sort of points and labels, each as an
			    // attribute sort with the respective properties' aspect

sort lines : [LineSegment]; // A sort of line segments, named lines

sort functions_on_lines : (functions : [Function]) ^ lines;
			    // A sort of functions with lines as attributes

sort weights : [Weight] (1.0);
			    // A sort of fractional weights

sort labeltree : (labelnode : (labels ^ ((left : labeltree) + (right : labeltree)))
				 + labels
			    // A sort of binary trees of labels recursively defined
			    // as the sum of the sort of labels and the sort of
			    // labelnodes, itself defined as the attribute
			    // operation over the sort of labels and the sum of
			    // twice the sort of binary trees of labels, resp.,
			    // denoted left and right

Two forward slashes (//) denote a comment, everything from the slashes until the end of the line is ignored.

 
 
 

Last update: 3 July 2012, webmaster @ sortal.org