SCHEMA ISO13584_expressions_schema; (****************** hacked by hand by rws 1999-01-04 ***************** REFERENCE FROM ISO13584_generic_expressions_schema( generic_expression, simple_generic_expression, generic_variable, generic_literal, unary_generic_expression, binary_generic_expression, multiple_arity_generic_expression); *) ENTITY generic_expression ABSTRACT SUPERTYPE OF(ONEOF(simple_generic_expression, unary_generic_expression, binary_generic_expression, multiple_arity_generic_expression)); WHERE WR1: is_acyclic(SELF); END_ENTITY; ENTITY simple_generic_expression ABSTRACT SUPERTYPE OF (ONEOF(generic_literal, generic_variable)) SUBTYPE OF (generic_expression); END_ENTITY; ENTITY generic_literal ABSTRACT SUPERTYPE SUBTYPE OF (simple_generic_expression); END_ENTITY; ENTITY generic_variable ABSTRACT SUPERTYPE SUBTYPE OF (simple_generic_expression); INVERSE interpretation : environment FOR syntactic_representation; END_ENTITY; ENTITY variable_semantics ABSTRACT SUPERTYPE; END_ENTITY; ENTITY environment; syntactic_representation: generic_variable; semantics: variable_semantics; END_ENTITY; ENTITY unary_generic_expression ABSTRACT SUPERTYPE SUBTYPE OF(generic_expression); operand: generic_expression; END_ENTITY; ENTITY binary_generic_expression ABSTRACT SUPERTYPE SUBTYPE OF(generic_expression); operands: LIST [2:2] OF generic_expression; END_ENTITY; ENTITY multiple_arity_generic_expression ABSTRACT SUPERTYPE SUBTYPE OF(generic_expression); operands: LIST [2:?] OF generic_expression; END_ENTITY; (************************************************************************) ENTITY expression ABSTRACT SUPERTYPE OF (ONEOF (numeric_expression, boolean_expression, string_expression)) SUBTYPE OF (generic_expression); END_ENTITY; (* 7.2.1.1 Variable A variable is an entity that stands for a value interpreted from some context. EXPRESS specification: *) ENTITY variable ABSTRACT SUPERTYPE OF (ONEOF (numeric_variable, boolean_variable, string_variable)) SUBTYPE OF(generic_variable); END_ENTITY; (* 7.2.1.2 Defined_function A defined_function is a (strongly typed) function intended to be subtyped in the information models that use the ISO13584_expressions_schema. EXPRESS specification: *) ENTITY defined_function ABSTRACT SUPERTYPE OF ((ONEOF (numeric_defined_function, string_defined_function, boolean_defined_function) ) ANDOR SQL_mappable_defined_function); END_ENTITY; (* 7.2.1.3 SQL_mappable_defined_function A SQL_mappable_defined_function is a function intended to be subtyped in the information models that use the ISO13584_expressions_schema to specify that some generic_expression is mappable onto SQL. EXPRESS specification: *) ENTITY SQL_mappable_defined_function ABSTRACT SUPERTYPE SUBTYPE OF (defined_function); END_ENTITY; (* 7.3 ISO13584_expressions_schema : entity definitions for numeric expressions 7.3.1 Numeric_expression A numeric_expression is an expression of which the range is the NUMBER data type defined in 8.1.1 of ISO 10303-11. EXPRESS specification: *) ENTITY numeric_expression ABSTRACT SUPERTYPE OF (ONEOF (simple_numeric_expression, unary_numeric_expression, binary_numeric_expression, multiple_arity_numeric_expression, length_function, value_function, numeric_defined_function)) SUBTYPE OF (expression); DERIVE is_int: BOOLEAN := is_int_expr (SELF); sql_mappable: BOOLEAN := is_SQL_mappable (SELF); END_ENTITY; (* Attribute definitions: is_int: a Boolean attribute that indicates if an expression evaluates to integer or not. sql_mappable: a Boolean attribute that indicates if an expression is mappable to the SQL query language. 7.3.2 Simple_numeric_expression A simple_numeric_expression is either a numeric literal or a numeric variable. EXPRESS specification: *) ENTITY simple_numeric_expression ABSTRACT SUPERTYPE OF (ONEOF (literal_number, numeric_variable)) SUBTYPE OF (numeric_expression, simple_generic_expression); END_ENTITY; (* 7.3.3 Literal_number A literal_number is an EXPRESS NUMBER literal . A literal_number may be either an integer literal or a real literal. NOTE The EXPRESS NUMBER data type has the numeric values as domain. EXPRESS specification: *) ENTITY literal_number ABSTRACT SUPERTYPE OF (ONEOF (int_literal, real_literal)) SUBTYPE OF (simple_numeric_expression, generic_literal); the_value: NUMBER; END_ENTITY; (* Attribute definitions: the_value: a NUMBER literal value. 7.3.4 Int_literal An int_literal is an EXPRESS INTEGER literal. NOTE An EXPRESS INTEGER literal represents an integer VALUE that is composed of one or more digits. EXPRESS specification: *) ENTITY int_literal SUBTYPE OF (literal_number); SELF\literal_number.the_value: INTEGER; END_ENTITY; (* Attribute definitions: the_value: an INTEGER literal value. 7.3.5 Real_literal A real_literal is an EXPRESS REAL literal. NOTE An EXPRESS REAL literal represents a real VALUE that is composed of a mantissa and an optional exponent; the mantissa shall include a decimal point. EXPRESS specification: *) ENTITY real_literal SUBTYPE OF (literal_number); SELF\literal_number.the_value: REAL; END_ENTITY; (* Attribute definitions: the_value: a REAL literal value. 7.3.6 Numeric_variable A numeric_variable is a variable that stands for a number value. EXPRESS specification: *) ENTITY numeric_variable SUPERTYPE OF (ONEOF (int_numeric_variable, real_numeric_variable)) SUBTYPE OF (simple_numeric_expression, variable); WHERE WR1: ('ISO13584_EXPRESSIONS_SCHEMA.INT_NUMERIC_VARIABLE' IN TYPEOF(SELF) ) OR ('ISO13584_EXPRESSIONS_SCHEMA.REAL_NUMERIC_VARIABLE' IN TYPEOF(SELF) ); END_ENTITY; (* Formal propositions: WR1: numeric_variable can only be a real variable or an integer variable. 7.3.7 Int_numeric_variable An int_numeric_variable is a variable that stands for an integer value. EXPRESS specification: *) ENTITY int_numeric_variable SUBTYPE OF (numeric_variable); END_ENTITY; (* 7.3.8 Real_numeric_variable A real_numeric_variable is a variable that stands for a real value. EXPRESS specification: *) ENTITY real_numeric_variable SUBTYPE OF (numeric_variable); END_ENTITY; (* 7.3.9 Unary_numeric_expression An unary_numeric_expression is an unary operator whose range is the NUMBER data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY unary_numeric_expression ABSTRACT SUPERTYPE OF (ONEOF (unary_function_call)) SUBTYPE OF (numeric_expression, unary_generic_expression); SELF\unary_generic_expression.operand : numeric_expression; END_ENTITY; (* Attribute definitions operand: a numeric expression that represents the parameter of the unary operator. 7.3.10 Binary_numeric_expression A binary_numeric_expression is a binary operator whose range is the NUMBER data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY binary_numeric_expression ABSTRACT SUPERTYPE OF (ONEOF (minus_expression, div_expression, mod_expression, slash_expression, power_expression, binary_function_call)) SUBTYPE OF (numeric_expression, binary_generic_expression); SELF\binary_generic_expression.operands : LIST [2:2] OF numeric_expression; END_ENTITY; (* Attribute definitions operands: a list containing the two parameters of the binary operator. 7.3.11 Multiple_arity_numeric_expression A multiple_arity_numeric_expression is a multiple arity operator whose range is the NUMBER data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY multiple_arity_numeric_expression ABSTRACT SUPERTYPE OF (ONEOF (plus_expression, mult_expression, multiple_arity_function_call)) SUBTYPE OF (numeric_expression, multiple_arity_generic_expression); SELF\multiple_arity_generic_expression.operands : LIST [2:?] OF numeric_expression; END_ENTITY; (* Attribute definitions operands: a list containing the parameters of the multiple arity operator. The length of this list is equal to the arity of the operator. 7.3.12 Length_function The length_function entity carries the semantics of the LENGTH function defined in ISO 10303-11. NOTE The length function returns the number of characters in a string. - Parameters: a string_expression carrying a value of the string data type. - Result: the returned value is the number of characters in the string and shall be greater than or equal to zero. EXPRESS specification: *) ENTITY length_function SUBTYPE OF (numeric_expression, unary_generic_expression); SELF\unary_generic_expression.operand: string_expression; END_ENTITY; (* Attribute definitions SELF\unary_generic_expression.operand: the string whose length is represented by the length_function. 7.3.13 Value_function The value_function entity carries the semantics of the VALUE function defined in ISO 10303-11. When the value represented in the string_expression that corresponds to the operand inherited attribute is an integer, the int_value_function subtype shall be used. NOTE The value function returns the numeric representation of a string. - Parameters: a string_expression carrying a value of the string data type. - Result: a number corresponding to the string representation. EXPRESS specification: *) ENTITY value_function SUPERTYPE OF (int_value_function) SUBTYPE OF (numeric_expression, unary_generic_expression); SELF\unary_generic_expression.operand: string_expression; END_ENTITY; (* Attribute definitions SELF\unary_generic_expression.operand: the string expression of which the value is represented by the value_function. 7.3.14 Int_value_function The int_value_function entity carries the semantics of the VALUE function defined in ISO 10303-11, and asserts that the string_expression that corresponds to the operand inherited attribute represents an integer number. NOTE The integer value function returns the integer number representation of a string. - Parameters: a string_expression carrying a value of the string data type. - Result: an integer number corresponding to the string representation. EXPRESS specification: *) ENTITY int_value_function SUBTYPE OF (value_function); END_ENTITY; (* Informal proposition IP1: the string_expression that corresponds to the operand attribute shall evaluate to a string that represents an integer number. 7.3.15 Numeric_defined_function A numeric_defined_function entity is a function whose range is the NUMBER data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY numeric_defined_function ABSTRACT SUPERTYPE OF (ONEOF (integer_defined_function, real_defined_function)) SUBTYPE OF (numeric_expression, defined_function); END_ENTITY; (* 7.3.16 Plus_expression The plus_expression entity carries the semantics of the '+' operator, defined in ISO 10303-11, on NUMBER data type. NOTE The plus_expression is an expression which evaluates to the sum of all its operands. In the ISO13584_expression_schema, all these operands shall evaluate to a number in the number data type domain. EXPRESS specification: *) ENTITY plus_expression SUBTYPE OF (multiple_arity_numeric_expression); END_ENTITY; (* 7.3.17 Minus_expression The minus_expression entity carries the semantics of the '-' operator, defined in ISO 10303-11, on NUMBER data type. NOTE The minus_expression is an expression which evaluates to the difference of its operands. In the ISO13584_expression_schema, all these operands shall evaluate to a number in the number data type domain. EXPRESS specification: *) ENTITY minus_expression SUBTYPE OF (binary_numeric_expression); END_ENTITY; (* 7.3.18 Mult_expression The mult_expression entity carries the semantics of the EXPRESS '*' operator, defined in ISO 10303-11, on NUMBER data type. NOTE The mult_expression is an expression which evaluates to the product of all its operands. In the ISO13584_expression_schema, all these operands shall evaluate to a number in the number data type domain. EXPRESS specification: *) ENTITY mult_expression SUBTYPE OF (multiple_arity_numeric_expression); END_ENTITY; (* 7.3.19 Div_expression The div_expression entity carries the semantics of the EXPRESS 'DIV' operator, defined in ISO 10303-11, on NUMBER data type. NOTE The div_expression is an expression which evaluates to the integer division of its operands. In the ISO13584_expression_schema, all these operands shall evaluate to a number in the number data type domain. The result is an integer number. If either operand is of data type REAL, it is truncated to an INTEGER before the operation, i.e. any fractional part is lost. EXPRESS specification: *) ENTITY div_expression SUBTYPE OF (binary_numeric_expression); END_ENTITY; (* Informal Proposition IP1: the SELF\binary_generic_expression.operands[2] shall not evaluate to 0. 7.3.20 Mod_expression The mod_expression entity carries the semantics of the EXPRESS 'MOD' operator, defined in ISO 10303-11, on NUMBER data type. NOTE The mod_expression is an expression which evaluates to the first argument value modulo operation of the second argument value. Its operands shall evaluate to a number in the number data type domain. The result is an integer number. If either operand is of data type REAL, it is truncated to an INTEGER before the operation, i.e. any fractional part is lost. EXPRESS specification: *) ENTITY mod_expression SUBTYPE OF (binary_numeric_expression); END_ENTITY; (* 7.3.21 Slash_expression The slash_expression entity carries the semantics of the EXPRESS '/' operator, defined in ISO 10303-11, on NUMBER data type. NOTE The slash_expression is an expression which evaluates to the real division of its first operand by the second one. Its operands shall evaluate to a number in the number data type domain. The result is a number. EXPRESS specification: *) ENTITY slash_expression SUBTYPE OF (binary_numeric_expression); END_ENTITY; (* Informal Proposition : IP1: the SELF\binary_generic_expression.operands[2] shall not evaluate to 0. 7.3.22 Power_expression The power_expression entity carries the semantics of the EXPRESS '**' operator, defined in ISO 10303-11, on NUMBER data type. NOTE The power_expression is an expression which evaluates to the exponentiation of the first operand value to the second operand value. Its operands shall evaluate to a number in the number data type domain. The result is a number. EXPRESS specification: *) ENTITY power_expression SUBTYPE OF (binary_numeric_expression); END_ENTITY; (* 7.3.23 Unary_function_call An unary_function_call is an unary operator on NUMBER data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY unary_function_call ABSTRACT SUPERTYPE OF (ONEOF (abs_function, minus_function, sin_function, cos_function, tan_function, asin_function, acos_function, exp_function, log_function, log2_function, log10_function, square_root_function)) SUBTYPE OF (unary_numeric_expression); END_ENTITY; (* 7.3.24 binary_function_call A binary_function_call is a binary operator on NUMBER data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY binary_function_call ABSTRACT SUPERTYPE OF (ONEOF (atan_function)) SUBTYPE OF (binary_numeric_expression); END_ENTITY; (* 7.3.25 Multiple_arity_function_call A multiple_arity_function_call is a multiple-arity operator on NUMBER data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY multiple_arity_function_call ABSTRACT SUPERTYPE OF (ONEOF (maximum_function, minimum_function)) SUBTYPE OF (multiple_arity_numeric_expression); END_ENTITY; (* 7.3.26 Abs_function The abs_function entity carries the semantics of the 'ABS' function, defined in ISO 10303-11, on NUMBER data type, defined in ISO 10303-11. NOTE The ABS function returns the absolute value of a number. - Parameters: a numeric_expression carrying a value of the number data type. - Result: the absolute value of the parameter. The returned data type is identical to the one of the parameter. EXPRESS specification: *) ENTITY abs_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.27 Minus_function The minus_function entity carries the semantics of the EXPRESS unary '-' operator, defined in ISO 10303-11, on NUMBER data type, defined in ISO 10303-11. NOTE The minus function returns the opposite value of a number. - Parameters: a numeric_expression carrying a value of the number data type. - Result: the opposite value of the parameter. The returned data type is identical to the one of the parameter. EXPRESS specification: *) ENTITY minus_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.28 Sin_function The sin_function entity carries the semantics of the EXPRESS 'SIN' function defined in ISO 10303-11. NOTE The SIN function returns the sine of an angle. - Parameters: a numeric_expression carrying a value of the number data type, representing an angle expressed in radians. - Result: the sine of the parameter ( -1.0 £ result £ 1.0 ). EXPRESS specification: *) ENTITY sin_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.29 Cos_function The cos_function entity carries the semantics of the EXPRESS 'COS' function defined in ISO 10303-11. NOTE The COS function returns the cosine of an angle. - Parameters: a numeric_expression carrying a value of the number data type, representing an angle expressed in radians. - Result: the cosine of the parameter ( -1.0 £ result £ 1.0 ). EXPRESS specification: *) ENTITY cos_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.30 Tan_function The tan_function entity carries the semantics of the EXPRESS 'TAN' function defined in ISO 10303-11. NOTE The TAN function returns the tangent of an angle. - Parameters: a numeric_expression carrying a value of the number data type, representing an angle expressed in radians. - Result: the tangent of the parameter. EXPRESS specification: *) ENTITY tan_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.31 Asin_function The asin_function entity carries the semantics of the EXPRESS 'ASIN' function defined in ISO 10303-11. NOTE The ASIN function returns the angle given a sine value. - Parameters: a numeric_expression carrying a value of the number data type, representing the sine of an angle expressed in radians. - Result: the angle expressed in radians (-P/2 £result £ P/2) whose sine is carried by the parameter. EXPRESS specification: *) ENTITY asin_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.32 Acos_function The acos_function entity carries the semantics of the EXPRESS 'ACOS' function defined in ISO 10303-11. NOTE The ACOS function returns the angle given a cosine value. - Parameters: a numeric_expression carrying a value of the number data type, representing the cosine of an angle expressed in radians. - Result: the angle expressed in radians (-P/2 £result £ P/2) whose cosine is carried by the parameter. EXPRESS specification: *) ENTITY acos_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.33 Exp_function The exp_function entity carries the semantics of the EXPRESS 'EXP' function defined in ISO 10303-11. NOTE The EXP function returns e (the base of the natural logarithm system) raised to the power of the value of the parameter. - Parameters: a numeric_expression carrying a value of the number data type, representing the value of the parameter. - Result: the value e raised to the power of the value of the parameter. EXPRESS specification: *) ENTITY exp_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.34 Log_function The log_function entity carries the semantics of the EXPRESS 'LOG' function defined in ISO 10303-11. NOTE The LOG function returns the natural logarithm of a number. - Parameters: a numeric_expression carrying a value of the number data type, representing the value of the parameter. It shall be greater than 0. - Result: the real number which is the natural logarithm of the value of the parameter. EXPRESS specification: *) ENTITY log_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.35 Log2_function The log2_function entity carries the semantics of the EXPRESS 'LOG2' function defined in ISO 10303-11. NOTE The LOG2 function returns the base 2 logarithm of a number. - Parameters: a numeric_expression carrying a value of the number data type, representing the value of the parameter. It shall be greater than 0. - Result: the real number which is the base 2 logarithm of the value of the parameter. EXPRESS specification: *) ENTITY log2_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.36 Log10_function The log10_function entity carries the semantics of the EXPRESS 'LOG10' function defined in ISO 10303-11. NOTE The LOG10 function returns the base 10 logarithm of a number. - Parameters: a numeric_expression carrying a value of the number data type, representing the value of the parameter. It shall be greater than 0. - Result: the real number which is the base 10 logarithm of the value of the parameter. EXPRESS specification: *) ENTITY log10_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.37 Square_root_function The square_root_function entity carries the semantics of the EXPRESS 'SQRT' function defined in ISO 10303-11. NOTE The SQRT function (square root) returns the non-negative square root of a number. - Parameters: a numeric_expression carrying a value of the number data type, representing the value of the parameter. It shall be greater than or equal to 0. - Result: the non negative real number which is the square root of the value of the parameter. EXPRESS specification: *) ENTITY square_root_function SUBTYPE OF (unary_function_call); END_ENTITY; (* 7.3.38 Atan_function The atan_function entity carries the semantics of the EXPRESS 'ATAN' function defined in ISO 10303-11. NOTE The ATAN function returns the angle given a tangent value represented by the parameters. - Parameters: two numeric_expressions representing the value SELF\binary_generic_expression[1] / SELF\binary_generic_expression[2]. - Result: the angle in radians (-P/2 £result £ P/2) whose tangent is represented by the value of the parameter. If the second expression corresponding to SELF\binary_generic_expression[2] evaluates to 0 then the result is -P/2 or P/2 depending on the sign of SELF\binary_generic_expression[1]. EXPRESS specification: *) ENTITY atan_function SUBTYPE OF (binary_function_call); END_ENTITY; (* 7.3.39 Maximum_function The maximum_function entity returns the maximum value of the list of values of its operands that shall evaluate to a number in the NUMBER data type domain. EXPRESS specification: *) ENTITY maximum_function SUBTYPE OF (multiple_arity_function_call); END_ENTITY; (* 7.3.40 Minimum_function The minimum_function entity returns the minimum value of the list of values of its operands that shall evaluate to a number in the NUMBER data type domain. EXPRESS specification: *) ENTITY minimum_function SUBTYPE OF (multiple_arity_function_call); END_ENTITY; (* 7.3.41 Integer_defined_function An integer_defined_function is any function of which the range is the INTEGER data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY integer_defined_function ABSTRACT SUPERTYPE SUBTYPE OF (numeric_defined_function); END_ENTITY ; (* Attribute definitions: IP1: if a subtype of a integer_defined_function is not also a subtype of a generic_expression, then it shall not contain any generic_variable. NOTE The integer_defined_function entity is a resource allowing to specialise this schema with any application defined function that returns a value in the integer data type domain. 7.3.42 Real_defined_function A real_defined_function is any function of which the range is the REAL data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY real_defined_function ABSTRACT SUPERTYPE SUBTYPE OF (numeric_defined_function); END_ENTITY ; (* Attribute definitions: IP1: if a subtype of a real_defined_function is not also a subtype of a generic_expression, then it shall not contain any generic_variable. NOTE The real_defined_function entity is a resource allowing to specialise this schema with any application defined function that returns a value in the real data type domain. 7.4 Boolean_expression A boolean_expression is an expression for which the range is the BOOLEAN data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY boolean_expression ABSTRACT SUPERTYPE OF (ONEOF (simple_boolean_expression, unary_boolean_expression, binary_boolean_expression, multiple_arity_Boolean_expression, comparison_expression, interval_expression, boolean_defined_function)) SUBTYPE OF (expression); END_ENTITY; (* 7.4.1 Simple_boolean_expression A simple_boolean_expression is an unary operator for which the range is BOOLEAN, such a data type being defined in ISO 10303-11. EXPRESS specification: *) ENTITY simple_boolean_expression ABSTRACT SUPERTYPE OF (ONEOF (boolean_literal, boolean_variable)) SUBTYPE OF (boolean_expression, simple_generic_expression); END_ENTITY; (* 7.4.2 Boolean_literal A boolean_literal is an EXPRESS BOOLEAN literal. NOTE The EXPRESS Boolean data type has as its domain the set containing the two literals TRUE and FALSE. EXPRESS specification: *) ENTITY boolean_literal SUBTYPE OF (simple_Boolean_expression, generic_literal); the_value: BOOLEAN; END_ENTITY; (* Attribute definitions: the_value: a BOOLEAN literal value. 7.4.3 Boolean_variable A boolean_variable is a variable that stands for a Boolean value. EXPRESS specification: *) ENTITY boolean_variable SUBTYPE OF (simple_Boolean_expression, variable); END_ENTITY; (* 7.4.4 Unary_boolean_expression An unary_boolean_expression is an unary operator for which the range is the BOOLEAN data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY unary_boolean_expression ABSTRACT SUPERTYPE OF (ONEOF (not_expression, odd_function)) SUBTYPE OF (boolean_expression, unary_generic_expression); END_ENTITY; (* 7.4.5 Not_expression The not_expression entity carries the semantics of the 'NOT' on Boolean data type operator defined in ISO 10303-11. NOTE The NOT operator requires one Boolean operand and evaluates to a Boolean value. EXPRESS specification: *) ENTITY not_expression SUBTYPE OF (unary_Boolean_expression); SELF\unary_generic_expression.operand: boolean_expression; END_ENTITY; (* Attribute definitions: SELF\unary_generic_expression.operand: the boolean_expression that represents the operand of the 'NOT' operator. 7.4.6 Odd_function The odd_function entity carries the semantics of the EXPRESS 'ODD' operator defined in ISO 10303-11. NOTE The ODD function returns TRUE or FALSE depending on whether a number is odd or even. - Parameters: a numeric expression carrying a value of the integer data type. - Result: the function returns TRUE when the value of the parameters modulo 2 equals to 1, and FALSE otherwise. EXPRESS specification: *) ENTITY odd_function SUBTYPE OF (unary_Boolean_expression); SELF\unary_generic_expression.operand: numeric_expression; WHERE WR1: is_int_expr(SELF\numeric_expression); END_ENTITY; (* Attribute definitions SELF\unary_generic_expression: the numeric_expression that represents the operand of the 'ODD' function. Formal proposition: WR1: the operand shall be a numeric_expression for which the range is the same as the EXPRESS INTEGER data type. 7.4.7 Binary_boolean_expression A binary_boolean_expression is a binary operator of which the range is the BOOLEAN data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY binary_boolean_expression ABSTRACT SUPERTYPE OF (ONEOF (xor_expression, equals_expression)) SUBTYPE OF (boolean_expression, binary_generic_expression); END_ENTITY; (* 7.4.8 Multiple_arity_boolean_expression A multiple_arity_boolean_expression is a multiple-arity operator for which the range is the same as the EXPRESS BOOLEAN data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY multiple_arity_boolean_expression ABSTRACT SUPERTYPE OF (ONEOF (and_expression, or_expression)) SUBTYPE OF (boolean_expression, multiple_arity_generic_expression); SELF\multiple_arity_generic_expression.operands : LIST [2:?] OF boolean_expression; END_ENTITY; (* Attribute definitions: operand: the occurrences of boolean_expression that represents the parameters of the m-arity operator. 7.4.9 Xor_expression The xor_expression entity carries the semantics of the 'XOR' operator defined in ISO 10303-11. NOTE The XOR operator requires two Boolean operands and evaluates to a Boolean value that is the exclusive disjunction of the two operands. EXPRESS specification: *) ENTITY xor_expression SUBTYPE OF (binary_boolean_expression); SELF\binary_generic_expression.operands: LIST [2:2] OF boolean_expression; END_ENTITY; (* Attribute definitions: operands: the two boolean_expression operands of the XOR operator that shall be boolean_expressions. 7.4.10 Equals_expression The equals_expression entity carries the semantics of the ':=:' instance equal operator defined in ISO 10303-11, the domain of which is entities of data type generic_expression. NOTE The entity instance equality operator accepts two compatible instance values that are generic_expression and evaluates to a Boolean value. In the context of the ISO13584_expression_schema the two generic_expressions instance values are compatible either if their data types are the same, or if one data type is a subtype of the other one. EXPRESS specification: *) ENTITY equals_expression SUBTYPE OF (binary_boolean_expression); END_ENTITY; (* 7.4.11 And_expression The and_expression entity carries the semantics of the 'AND' operator defined in ISO 10303-11 and uses its associativity property to handle multiple arity. NOTE The AND operator requires at least two Boolean expressions and evaluates to a Boolean value that is the conjunction of the two operands. EXPRESS specification: *) ENTITY and_expression SUBTYPE OF (multiple_arity_boolean_expression); END_ENTITY; (* 7.4.12 Or_expression The or_expression entity carries the semantics of the 'OR' operator defined in ISO 10303-11 and uses its associativity property to handle multiple arity. NOTE The OR operator requires at least two Boolean expressions and evaluates to a Boolean value that is the inclusive disjunction of the two operands. EXPRESS specification: *) ENTITY or_expression SUBTYPE OF (multiple_arity_boolean_expression); END_ENTITY; (* 7.4.13 Comparison_expression The comparison_expression expressions carry the semantics of the different value comparison operators defined in ISO 10303-11 restricted to the NUMBER, BOOLEAN and STRING EXPRESS data types. Both operands shall have the same data type. EXPRESS specification: *) ENTITY comparison_expression ABSTRACT SUPERTYPE OF (ONEOF (comparison_equal, comparison_greater, comparison_greater_equal, comparison_less, comparison_less_equal, comparison_not_equal, like_expression)) SUBTYPE OF (boolean_expression, binary_generic_expression); SELF\binary_generic_expression.operands : LIST [2:2] OF expression; WHERE WR1: (('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_EXPRESSION' IN TYPEOF(SELF\binary_generic_expression.operands[1])) AND ('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_EXPRESSION' IN TYPEOF(SELF\binary_generic_expression.operands[2]))) OR (('ISO13584_EXPRESSIONS_SCHEMA.BOOLEAN_EXPRESSION' IN TYPEOF(SELF\binary_generic_expression.operands[1])) AND ('ISO13584_EXPRESSIONS_SCHEMA.BOOLEAN_EXPRESSION' IN TYPEOF(SELF\binary_generic_expression.operands[2]))) OR (('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF(SELF\binary_generic_expression.operands[1])) AND ('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF(SELF\binary_generic_expression.operands[2]))) ; END_ENTITY; (* Attribute definitions operands: a list of generic_expressions that contains the expressions to be compared. Formal proposition WR1 : the operands of the comparison_expression shall be of compatible in type. 7.4.14 Comparison_equal A comparison_equal carries the semantics of the value equal ('=') operator defined in ISO 10303-11 restricted to the NUMBER, BOOLEAN and STRING EXPRESS data types. Both operands shall have the same data type. EXPRESS specification: *) ENTITY comparison_equal SUBTYPE OF (comparison_expression); END_ENTITY; (* NOTE The comparison_equal evaluates to TRUE if the two operands evaluate to the same value. 7.4.15 Comparison_greater A comparison_greater carries the semantics of the greater than ('>') operator defined in of ISO 10303-11 restricted to the NUMBER, BOOLEAN and STRING EXPRESS data types. Both operands shall have the same data type. NOTE The comparison_greater evaluates to TRUE if the first operand evaluates to a value greater than the second operand. The relevant orders are: - mathematical ordering of the real numbers; - FALSE < TRUE; - lexicographic order on strings. EXPRESS specification: *) ENTITY comparison_greater SUBTYPE OF (comparison_expression); END_ENTITY; (* 7.4.16 Comparison_greater_equal A comparison_greater_equal carries the semantics of the greater than or equal ('>=') operator defined in of ISO 10303-11 restricted to the NUMBER, BOOLEAN and STRING EXPRESS data types. Both operands shall have the same data type. NOTE The comparison_greater_equal evaluates to TRUE if the first operand evaluates to a value greater than or equal to the second operand. The relevant orders are: - mathematical ordering of the real numbers; - FALSE < TRUE; - lexicographic order on strings. EXPRESS specification: *) ENTITY comparison_greater_equal SUBTYPE OF (comparison_expression); END_ENTITY; (* 7.4.17 Comparison_less A comparison_less carries the semantics of the less than ('<') operator defined in ISO 10303-11 restricted to the NUMBER, BOOLEAN and STRING EXPRESS data types. Both operands shall have the same data type. NOTE The comparison_less evaluates to TRUE if the first operand evaluates to a value less than the second operand. The relevant orders are: - mathematical ordering of the real numbers; - FALSE < TRUE; - lexicographic order on strings. EXPRESS specification: *) ENTITY comparison_less SUBTYPE OF (comparison_expression); END_ENTITY; (* 7.4.18 Comparison_less_equal A comparison_less_or_equal carries the semantics of the EXPRESS less than or equal ('<=') operator defined in ISO 10303-11 restricted to the NUMBER, BOOLEAN and STRING EXPRESS data types. Both operands shall have the same data type. NOTE The comparison_less_equal evaluates to TRUE if the first operand evaluates to a value less than or equal to the second operand. The relevant orders are: - mathematical ordering of the real numbers; - FALSE < TRUE; - lexicographic order on strings. EXPRESS specification: *) ENTITY comparison_less_equal SUBTYPE OF (comparison_expression); END_ENTITY; (* 7.4.19 Comparison_not_equal A comparison_not_equal carries the semantics of the value not equal ('<>') operator defined in ISO 10303-11 restricted to the NUMBER, BOOLEAN and STRING EXPRESS data types. Both operands shall have the same data type. NOTE The comparison_not_equal evaluates to TRUE if the first operand evaluates to a value different from the second operand. The relevant orders are: - mathematical ordering of the real numbers; - FALSE < TRUE; - lexicographic order on strings. EXPRESS specification: *) ENTITY comparison_not_equal SUBTYPE OF (comparison_expression); END_ENTITY; (* 7.4.20 Like_expression A like_expression carries the semantics of the LIKE string matching operator defined in ISO 10303-11. The first operand is the target string. The second operand is the pattern string. The special characters (often called "wild cards") in the pattern string are defined in ISO 10303-11. EXPRESS specification: *) ENTITY like_expression SUBTYPE OF (comparison_expression); WHERE WR1: ('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF(SELF\comparison_expression.operands[1])) AND ('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF(SELF\comparison_expression.operands[2])); END_ENTITY; (* Formal propositions: WR1: the operand list shall contain two generic_expressions that are string_expressions. 7.4.21 Interval_expression An interval_expression carries the semantics of the interval expression defined in ISO 10303-11 restricted to the NUMBER, BOOLEAN and STRING EXPRESS data types. Both operands shall have the same data type. NOTE An interval_expression expression tests whether or not a value falls within a given interval. It evaluates to TRUE if interval_low < = interval_item < = interval_high. The relevant orders are: - mathematical ordering of the real numbers; - lexicographic order on strings. EXPRESS specification: *) ENTITY interval_expression SUBTYPE OF (boolean_expression, multiple_arity_generic_expression) ; DERIVE interval_low: generic_expression := SELF\multiple_arity_generic_expression.operands[1]; interval_item:generic_expression := SELF\multiple_arity_generic_expression.operands[2]; interval_high:generic_expression := SELF\multiple_arity_generic_expression.operands[3]; WHERE WR1:('ISO13584_EXPRESSIONS_SCHEMA.EXPRESSION' IN TYPEOF(interval_low)) AND ('ISO13584_EXPRESSIONS_SCHEMA.EXPRESSION' IN TYPEOF(interval_item) ) AND ('ISO13584_EXPRESSIONS_SCHEMA.EXPRESSION' IN TYPEOF(interval_high)); WR2:(('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF (SELF.interval_low)) AND ('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF (SELF.interval_high)) AND ('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF (SELF.interval_item))) OR (('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF(SELF.interval_low)) AND ('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_EXPRESSION' IN TYPEOF(SELF.interval_item)) AND ('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_EXPRESSION' IN TYPEOF(SELF.interval_high))); END_ENTITY; (* Attribute definitions: interval_low: the bound_1 operand of the interval expression (see 12.2.4 of ISO 10303-11). interval_high: the bound_2 operand of the interval expression (see 12.2.4 of ISO 10303-11). interval_item: the interval_item operand of the interval expression (see 12.2.4 of ISO 10303-11). Formal propositions: WR1: the data type of the operands shall be expressions. WR2: the types of the expressions to be compared in the interval_expressions shall evaluates to comparable expressions. 7.4.22 Boolean_defined_function A boolean_defined_function is any application-defined operator of which the range is the BOOLEAN data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY boolean_defined_function ABSTRACT SUPERTYPE SUBTYPE OF (defined_function, boolean_expression); END_ENTITY ; (* Informal propositions: IP1: if a subtype of a boolean_defined_function is not also a subtype of a generic_expression, then it shall not contain any generic_variable. 7.5 String_expression A string_expression is an expression whose range is the EXPRESS STRING data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY string_expression ABSTRACT SUPERTYPE OF (ONEOF (simple_string_expression, index_expression, substring_expression, concat_expression, format_function, string_defined_function)) SUBTYPE OF (expression); END_ENTITY; (* 7.5.1 Simple_string_expression A simple_string_expression is an unary operator of whose range is EXPRESS STRING data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY simple_string_expression ABSTRACT SUPERTYPE OF (ONEOF (string_literal, string_variable)) SUBTYPE OF (string_expression, simple_generic_expression); END_ENTITY; (* 7.5.2 String_literal A string_literal is an EXPRESS STRING literal. NOTE The EXPRESS STRING data type has as its domain sequences of characters. EXPRESS specification: *) ENTITY string_literal SUBTYPE OF (simple_string_expression, generic_literal); the_value: STRING; END_ENTITY; (* Attribute definitions: the value: a STRING literal value. 7.5.3 String_variable A string_variable is a variable that stands for a STRING value. EXPRESS specification: *) ENTITY string_variable SUBTYPE OF (simple_string_expression, variable); END_ENTITY; (* 7.5.4 Index_expression The index_expression carries the semantics of the string indexing operator ('[]') defined in ISO 10303-11. NOTE The index_expression string operator takes two operands, the string value (represented by the operand attribute) being indexed by the index specification (represented by the index attribute). The resulting string value is the character at position the value of the index operator. EXPRESS specification: *) ENTITY index_expression SUBTYPE OF (string_expression, binary_generic_expression); DERIVE operand:generic_expression:= SELF\binary_generic_expression.operands[1]; index:generic_expression:= SELF\binary_generic_expression.operands[2]; WHERE WR1: ('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF(operand)) AND ('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_EXPRESSION' IN TYPEOF(index)); WR2: is_int_expr (index); END_ENTITY; (* Attribute definitions: operand: the string_expression that represents the STRING. index: the integer numeric_expression that indicates the index value. Formal propositions: WR1: the first operand shall be a string_expression and the second operand shall be a numeric_expression. WR2: the position described by the index operand shall be an integer value. Informal propositions: IP1: the index shall evaluate to an INTEGER value greater than zero and less or equal to the length of the operand STRING. 7.5.5 Substring_expression The substring_expression carries the semantics of the EXPRESS substring indexing operator ('[:]') defined in ISO 10303-11. NOTE The substring_expression string operator takes three operands, the string value (represented by the operand attribute) being indexed by the index specification (represented by the index1 and index2 attributes). The substring_expression evaluates to a string value of length (index2 - index1 + 1). The resulting string value is equivalent to the sequence of characters at position index1 through index2. EXPRESS specification: *) ENTITY substring_expression SUBTYPE OF (string_expression, multiple_arity_generic_expression); DERIVE operand:generic_expression:= SELF\multiple_arity_generic_expression.operands[1]; index1:generic_expression:= SELF\multiple_arity_generic_expression.operands[2]; index2:generic_expression:= SELF\multiple_arity_generic_expression.operands[3]; WHERE WR1: ('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION' IN TYPEOF(operand)) AND ('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_EXPRESSION' IN TYPEOF(index1)) AND ('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_EXPRESSION' IN TYPEOF(index2)); WR2: SIZEOF(SELF\multiple_arity_generic_expression.operands)=3; WR3: is_int_expr (index1); WR4: is_int_expr (index2); END_ENTITY; (* Attribute definitions: operand: the string_expression from which a substring is extracted. index1: the numeric_expression that indicates the low bound of the substring in operand. index2: the numeric_expression that indicates the high bound of the substring in operand. Formal propositions: WR1: operand shall be a string_expression, index1 and index2 shall be numeric_expression . WR2: the substring_expression operands LIST shall contain three elements. WR3: index1 shall evaluate to an INTEGER value. WR4: index2 shall evaluate to an INTEGER value. Informal propositions: IP1: index1 and index2 shall evaluate to an INTEGER value greater than zero and less or equal to the length of the operand STRING. IP2: index1 value shall be less or equal to index2 value. 7.5.6 Concat_expression The concat_expression carries the semantics of the concatenation ('+') operator defined in ISO 10303-11, on the STRING data type defined in ISO 10303-11. NOTE The concat_expression operator accepts at least two string_expressions as operands and evaluates to a string value resulting from the concatenation of all the elements of the SELF\multiple_arity_generic_expression.operands list. These elements are concatenated in the list order. EXPRESS specification: *) ENTITY concat_expression SUBTYPE OF (string_expression, multiple_arity_generic_expression); SELF\multiple_arity_generic_expression.operands: LIST [2 : ?] OF string_expression; END_ENTITY; (* Attribute definitions: SELF\multiple_arity_generic_expression.operands: the string_expressions to be concatenated. 7.5.7 Format_function The format_function carries the semantics of the FORMAT function defined in ISO 10303-11. NOTE The format function returns a formatted string representation of a number. - Parameters: a numeric_expression corresponding to the value_to_format operand and which evaluates to a real or integer number and a string_expression corresponding to the format_string operand which evaluates to a string containing the formatting commands. - Result: a string representation of the value of the value_to_format operand according to the value of the format_string operand. The formatting string contains special characters to indicate the appearance of the result. The different ways to describe the formatting string are defined in ISO 10303-11 PART 11. EXPRESS specification: *) ENTITY format_function SUBTYPE OF (string_expression, binary_generic_expression); DERIVE value_to_format: generic_expression:= SELF\binary_generic_expression.operands[1]; format_string:generic_expression:= SELF\binary_generic_expression.operands[2]; WHERE WR1: (('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_EXPRESSION') IN TYPEOF(value_to_format)) AND (('ISO13584_EXPRESSIONS_SCHEMA.STRING_EXPRESSION') IN TYPEOF(format_string)); END_ENTITY; (* Attribute definitions: value_to_format: the numeric_expression that is to be formatted. format_string: the formatting commands that defines the appearance of the result. Formal proposition: WR1: the value_to_format shall be a numeric_expression and the format_string shall be a string_expression. 7.5.8 String_defined_function A string_defined_function is any application-defined operator of which the range is the STRING data type defined in ISO 10303-11. EXPRESS specification: *) ENTITY string_defined_function ABSTRACT SUPERTYPE SUBTYPE OF (defined_function, string_expression); END_ENTITY ; (* Informal proposition: IP1: if a subtype of a string_defined_function is not also a subtype of a generic_expression, then it shall not contain any generic_variable. 7.6 Functions to determine properties of the expression The following EXPRESS declarations specifies different functions that enable the properties of expressions to be determined. 7.6.1 Is_int_expr The is_int_expr function checks if a syntactically correct expression (see clause 7) evaluates to an integer value or not. EXPRESS specification: *) FUNCTION is_int_expr (arg: numeric_expression) : BOOLEAN; LOCAL i: INTEGER; END_LOCAL; IF 'ISO13584_EXPRESSIONS_SCHEMA.INT_LITERAL' IN TYPEOF(arg) THEN RETURN (TRUE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.REAL_LITERAL' IN TYPEOF(arg) THEN RETURN (FALSE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.INT_NUMERIC_VARIABLE' IN TYPEOF(arg) THEN RETURN (TRUE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.REAL_NUMERIC_VARIABLE' IN TYPEOF(arg) THEN RETURN (FALSE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.ABS_FUNCTION' IN TYPEOF(arg) THEN RETURN (is_int_expr(arg\unary_numeric_expression.operand)); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.MINUS_FUNCTION' IN TYPEOF(arg) THEN RETURN (is_int_expr(arg\unary_numeric_expression.operand)); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.SIN_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.COS_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.TAN_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.ASIN_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.ACOS_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.ATAN_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.EXP_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.LOG_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.LOG2_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.LOG10_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.SQUARE_ROOT_FUNCTION' IN TYPEOF(arg)) THEN RETURN (FALSE); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.PLUS_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.MULT_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.MAXIMUM_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.MINIMUM_FUNCTION' IN TYPEOF(arg)) THEN REPEAT i :=1 TO SIZEOF ( arg\multiple_arity_numeric_expression.operands); IF NOT is_int_expr(arg\multiple_arity_numeric_expression.operands[i]) THEN RETURN (FALSE); END_IF; END_REPEAT; RETURN (TRUE); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.MINUS_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.POWER_EXPRESSION' IN TYPEOF(arg)) THEN RETURN (is_int_expr(arg\binary_numeric_expression.operands[1]) AND is_int_expr(arg\binary_numeric_expression.operands[2])); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.DIV_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.MOD_EXPRESSION' IN TYPEOF(arg)) THEN RETURN(TRUE); (*always deliver an INTEGER result *) END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.SLASH_EXPRESSION' IN TYPEOF(arg) THEN RETURN (FALSE); (* always delivers a REAL result *) END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.LENGTH_FUNCTION' IN TYPEOF(arg) THEN RETURN (TRUE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.VALUE_FUNCTION' IN TYPEOF(arg) THEN IF 'ISO13584_EXPRESSIONS_SCHEMA.INT_VALUE_FUNCTION' IN TYPEOF(arg) THEN RETURN (TRUE); ELSE RETURN (FALSE); END_IF; END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.INTEGER_DEFINED_FUNCTION' IN TYPEOF(arg) THEN RETURN(TRUE) ; END_IF; IF'ISO13584_EXPRESSIONS_SCHEMA.REAL_DEFINED_FUNCTION' IN TYPEOF(arg) THEN RETURN(FALSE) ; END_IF ; IF 'ISO13584_EXPRESSIONS_SCHEMA.BOOLEAN_DEFINED_FUNCTION' IN TYPEOF(arg) THEN RETURN(FALSE) ; END_IF ; IF 'ISO13584_EXPRESSIONS_SCHEMA.STRING_DEFINED_FUNCTION' IN TYPEOF(arg) THEN RETURN (FALSE) ; END_IF ; (* If another generic_expression is involved that is not a subtype of integer_defined_function then its result is not integer. *) RETURN (FALSE); END_FUNCTION; -- is_int_expr (* 7.6.2 Is_SQL_mappable The is_SQL_mappable function checks if the acyclic graph that represents an expression only contains elements that are mappable to SQL (Structured Query Language). EXPRESS specification: *) FUNCTION is_SQL_mappable (arg: expression) : BOOLEAN; LOCAL i: INTEGER; END_LOCAL; IF 'ISO13584_EXPRESSIONS_SCHEMA.SIMPLE_NUMERIC_EXPRESSION' IN TYPEOF (arg) THEN RETURN (TRUE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.SQL_MAPPABLE_DEFINED_FUNCTION' IN TYPEOF (arg) THEN RETURN (TRUE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.MINUS_FUNCTION' IN TYPEOF(arg) THEN RETURN (is_SQL_mappable(arg\unary_numeric_expression.operand)); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.ABS_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.SIN_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.COS_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.TAN_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.ASIN_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.ACOS_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.ATAN_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.EXP_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.LOG_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.LOG2_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.LOG10_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.SQUARE_ROOT_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.VALUE_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.LENGTH_FUNCTION' IN TYPEOF(arg)) THEN RETURN (FALSE); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.PLUS_EXPRESSION' IN TYPEOF(arg)) OR('ISO13584_EXPRESSIONS_SCHEMA.MULT_EXPRESSION' IN TYPEOF(arg)) OR('ISO13584_EXPRESSIONS_SCHEMA.MAXIMUM_FUNCTION' IN TYPEOF(arg)) OR('ISO13584_EXPRESSIONS_SCHEMA.MINIMUM_FUNCTION' IN TYPEOF(arg)) THEN REPEAT i :=1 TO SIZEOF ( arg\multiple_arity_numeric_expression.operands); IF NOT is_SQL_mappable( arg\multiple_arity_numeric_expression.operands[i]) THEN RETURN (FALSE); END_IF; END_REPEAT; RETURN (TRUE); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.MINUS_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.SLASH_EXPRESSION' IN TYPEOF(arg)) THEN RETURN (is_SQL_mappable( arg\binary_numeric_expression.operands[1]) AND is_SQL_mappable(arg\binary_numeric_expression.operands[2])); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.DIV_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.MOD_EXPRESSION' IN TYPEOF(arg)) OR('ISO13584_EXPRESSIONS_SCHEMA.POWER_EXPRESSION' IN TYPEOF(arg)) THEN RETURN (FALSE); (* operators not supported by SQL *) END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.SIMPLE_BOOLEAN_EXPRESSION' IN TYPEOF (arg) THEN RETURN (TRUE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.NOT_EXPRESSION' IN TYPEOF (arg) THEN RETURN (is_SQL_mappable (arg\UNARY_GENERIC_EXPRESSION.OPERAND)); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.ODD_FUNCTION'IN TYPEOF (arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.XOR_EXPRESSION' IN TYPEOF (arg)) THEN RETURN (FALSE); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.AND_EXPRESSION' IN TYPEOF (arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.OR_EXPRESSION' IN TYPEOF (arg)) THEN REPEAT i:=1 TO SIZEOF ( arg\MULTIPLE_ARITY_BOOLEAN_EXPRESSION.OPERANDS); IF NOT is_SQL_mappable ( arg\MULTIPLE_ARITY_BOOLEAN_EXPRESSION.OPERANDS[i]) THEN RETURN (FALSE); END_IF; END_REPEAT; RETURN (TRUE); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.EQUALS_EXPRESSION' IN TYPEOF (arg) THEN RETURN(is_SQL_mappable ( arg\BINARY_GENERIC_EXPRESSION.OPERANDS [1]) AND is_SQL_mappable( arg\BINARY_GENERIC_EXPRESSION.OPERANDS [2])); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.COMPARISON_EQUAL' IN TYPEOF (arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.COMPARISON_GREATER' IN TYPEOF (arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.COMPARISON_GREATER_EQUAL' IN TYPEOF (arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.COMPARISON_LESS' IN TYPEOF (arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.COMPARISON_LESS_EQUAL' IN TYPEOF (arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.COMPARISON_NOT_EQUAL' IN TYPEOF (arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.LIKE_EXPRESSION' IN TYPEOF (arg)) THEN RETURN (is_SQL_mappable (arg\COMPARISON_EXPRESSION.OPERANDS[1]) AND is_SQL_mappable (arg\COMPARISON_EXPRESSION.OPERANDS[2])); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.INTERVAL_EXPRESSION' IN TYPEOF(arg) THEN RETURN (is_SQL_mappable(arg\interval_expression.interval_low) AND is_SQL_mappable(arg\interval_expression.interval_high) AND is_SQL_mappable(arg\interval_expression.interval_item)); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.NUMERIC_DEFINED_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.BOOLEAN_DEFINED_FUNCTION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.STRING_DEFINED_FUNCTION' IN TYPEOF(arg)) THEN RETURN (FALSE) ; END_IF; (* It has been assumed that all the defined functions are not mappable to the SQl language *) IF 'ISO13584_EXPRESSIONS_SCHEMA.SIMPLE_STRING_EXPRESSION' IN TYPEOF(ARG) THEN RETURN (TRUE); END_IF; IF ('ISO13584_EXPRESSIONS_SCHEMA.INDEX_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.SUBSTRING_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.CONCAT_EXPRESSION' IN TYPEOF(arg)) OR ('ISO13584_EXPRESSIONS_SCHEMA.FORMAT_FUNCTION' IN TYPEOF(arg)) THEN RETURN (FALSE); END_IF; (* If another generic_expression is involved that is not a subtype of SQL_mappable_defined_function then it is not mappable on SQL. *) RETURN (FALSE); END_FUNCTION; -- is_SQL_mappable (* 7.6.3 Used_functions The used_function function walks through the whole expression graph collecting all the application_defined functions and finally returning them. It traverses the directed acyclic graph representing an expression. NOTE This function is a resource for the schemata that use the ISO13584_expressions_schema or its possible specialisation's. As an example, it is used in several parts of ISO 13584 to write constraints on the functions occurring in expressions. EXPRESS specification: *) FUNCTION used_functions (arg : expression) : SET OF defined_function; LOCAL result : SET OF defined_function := []; END_LOCAL; IF ('ISO13584_EXPRESSIONS_SCHEMA.DEFINED_FUNCTION' IN TYPEOF(arg)) THEN RETURN ( [arg] ) ; END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.UNARY_NUMERIC_EXPRESSION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\unary_numeric_expression.operand)); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.BINARY_NUMERIC_EXPRESSION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\binary_numeric_expression.operands[1]) + used_functions (arg\binary_numeric_expression.operands[2])); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.MULTIPLE_ARITY_NUMERIC_EXPRESSION' IN TYPEOF (arg) THEN REPEAT i := 1 TO SIZEOF ( arg\multiple_arity_numeric_expression.operands); result := result + used_functions ( arg\multiple_arity_numeric_expression.operands[i]); END_REPEAT; RETURN (result); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.UNARY_NUMERIC_EXPRESSION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\unary_generic_expression.operand)); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.BINARY_BOOLEAN_EXPRESSION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\binary_generic_expression.operands[1]) + used_functions ( arg\binary_generic_expression.operands[2])); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.MULTIPLE_ARITY_BOOLEAN_EXPRESSION' IN TYPEOF (arg) THEN REPEAT i := 1 TO SIZEOF (arg\multiple_arity_Boolean_expression.operands); result := result + used_functions( arg\multiple_arity_Boolean_expression.operands[i]); END_REPEAT; RETURN (result); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.COMPARISON_EXPRESSION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\comparison_expression.operands[1]) + used_functions (arg\comparison_expression.operands[2])); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.INTERVAL_EXPRESSION' IN TYPEOF(arg) THEN RETURN (used_functions(arg\interval_expression.interval_low) + used_functions(arg\interval_expression.interval_high) + used_functions(arg\interval_expression.interval_item)); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.INDEX_EXPRESSION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\index_expression.operand) + used_functions (arg\index_expression.index)); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.SUBSTRING_EXPRESSION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\substring_expression.operand) + used_functions (arg\substring_expression.index1) + used_functions (arg\substring_expression.index2)); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.CONCAT_EXPRESSION' IN TYPEOF (arg) THEN REPEAT i := 1 TO SIZEOF (arg\concat_expression.operands); result := result + used_functions ( arg\concat_expression.operands[i]); END_REPEAT; RETURN (result); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.FORMAT_FUNCTION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\format_function.value_to_format) + used_functions (arg\format_function.format_string)); END_IF; IF 'ISO13584_EXPRESSIONS_SCHEMA.LIKE_EXPRESSION' IN TYPEOF (arg) THEN RETURN (used_functions (arg\like_expression.operands[1]) + used_functions (arg\like_expression.operands[2])); END_IF; RETURN ([ ]); END_FUNCTION; -- used_functions (*********************************************************************************************************) FUNCTION is_acyclic (arg: generic_expression): BOOLEAN; RETURN (acyclic (arg, [])); END_FUNCTION ; -- is_acyclic FUNCTION acyclic (arg1: generic_expression; arg2: SET OF generic_expression): BOOLEAN; LOCAL result: BOOLEAN; END_LOCAL; IF ('ISO13584_GENERIC_EXPRESSIONS_SCHEMA.SIMPLE_GENERIC_EXPRESSION' IN TYPEOF (arg1)) THEN RETURN (TRUE); END_IF; IF arg1 IN arg2 THEN RETURN (FALSE); END_IF; IF 'ISO13584_GENERIC_EXPRESSIONS_SCHEMA.UNARY_GENERIC_EXPRESSION' IN TYPEOF (arg1) THEN RETURN (acyclic(arg1\unary_generic_expression.operand,arg2+[arg1])); END_IF; IF 'ISO13584_GENERIC_EXPRESSIONS_SCHEMA.BINARY_GENERIC_EXPRESSION' IN TYPEOF (arg1) THEN RETURN (acyclic(arg1\binary_generic_expression.operands[1],arg2+[arg1]) AND acyclic(arg1\binary_generic_expression.operands[2],arg2+[arg1])); END_IF; IF 'ISO13584_GENERIC_EXPRESSIONS_SCHEMA.MULTIPLE_ARITY_GENERIC_EXPRESSION' IN TYPEOF (arg1) THEN result := TRUE; REPEAT i := 1 TO SIZEOF (arg1\multiple_arity_generic_expression.operands); result := result AND acyclic(arg1\multiple_arity_generic_expression.operands[i], arg2+[arg1]); END_REPEAT; RETURN (result); END_IF; END_FUNCTION; -- acyclic END_SCHEMA; -- ISO13584_expressions_schema