Application module: Generic expression ISO/TS 10303-1341:2014-02(E)
© ISO

Cover page
Table of contents
Copyright
Foreword
Introduction
1 Scope
2 Normative references
3 Terms, definitions and abbreviated terms
    3.1 Terms and definitions
    3.2 Abbreviated terms

4 Information requirements
   4.1 ARM entity definitions
   4.2 ARM function definitions
5 Module interpreted model
   5.1 Mapping specification
   5.2 MIM EXPRESS short listing

A MIM short names
B Information object registration
C ARM EXPRESS-G   EXPRESS-G
D MIM EXPRESS-G   EXPRESS-G
E Computer interpretable listings
F Change history
Bibliography
Index

4 Information requirements

This clause specifies the information requirements for the Generic expression application module. The information requirements are specified as the Application Reference Model (ARM) of this application module.

NOTE 1  A graphical representation of the information requirements is given in Annex C.

NOTE 2  The mapping specification is specified in 5.1. It shows how the information requirements are met by using common resources and constructs defined or imported in the MIM schema of this application module.

This clause defines the information requirements to which implementations shall conform using the EXPRESS language as defined in ISO 10303-11. The following begins the Generic expression schema.

The Generic_expression module represents all the possible expressions available.

EXPRESS specification:

*)
SCHEMA Generic_expression_arm;
(*

4.1 ARM entity definitions

This subclause specifies the ARM entities for this module. Each ARM application entity is an atomic element that embodies a unique application concept and contains attributes specifying the data elements of the entity. The ARM entities and definitions are specified below.

4.1.1 Binary_generic_expression   EXPRESS-GMapping table

A Binary_generic_expression is a type of Generic_expression and is the ABSTRACT SUPERTYPE of all the binary operators.

EXPRESS specification:

*)
ENTITY Binary_generic_expression
  ABSTRACT SUPERTYPE
  SUBTYPE OF (Generic_expression);
  operands : LIST[2:2] OF Generic_expression;
END_ENTITY;
(*

Attribute definitions:

operands: a list of two generic expressions that represent the two operands of the binary operator.

4.1.2 Environment   EXPRESS-GMapping table

An Environment is an association between syntax and semantics.

NOTE    In the context of this part of ISO 10303-1341, the Environment entity associates to a Generic_expression (syntax) its corresponding meaning (semantics) represented by the Variable_semantics entity.

EXPRESS specification:

*)
ENTITY Environment;
  syntactic_representation : Generic_variable;
  semantics : Variable_semantics;
END_ENTITY;
(*

Attribute definitions:

syntactic_representation: the Generic_variable that stands for the value of the variable.

semantics: the meaning of the variable that includes the mechanism to access its value.

4.1.3 Generic_expression   EXPRESS-GMapping table

A Generic_expression is the information model of a Generic_expression. It is the ABSTRACT SUPERTYPE of all the possible expressions. In order to be able to assert the acyclicity of expressions, it is subtyped according to its arity. When a subtype of a Generic_expression is not a subtype of either a Simple_generic_expression, or an Unary_generic_expression, or a Binary_generic_expression, or a Multiple_arity_generic_expression it shall not contain any variable.

EXPRESS specification:

*)
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;
(*

Formal propositions:

WR1: the graph associated with the described expression shall be acyclic.

4.1.4 Generic_literal   EXPRESS-GMapping table

A Generic_literal is a type of Simple_generic_expression. A Generic_literal is an abstract constant that can be involved in a generic expression.

EXPRESS specification:

*)
ENTITY Generic_literal
  ABSTRACT SUPERTYPE
  SUBTYPE OF (Simple_generic_expression);
END_ENTITY;
(*

4.1.5 Generic_variable   EXPRESS-GMapping table

A Generic_variable is a type of Simple_generic_expression and is an abstract variable that can be involved in a generic expression. A Generic_variable shall be subtyped to specify the data type of its permitted values. It shall be referenced by an environment that represents the interpretation function that associates a value with this variable.

NOTE    The Real_numeric_variable, Numeric_variable, Boolean_variable and String_variable are examples of subtypes of Generic_variable.

EXPRESS specification:

*)
ENTITY Generic_variable
  ABSTRACT SUPERTYPE OF (Variable)
  SUBTYPE OF (Simple_generic_expression);
INVERSE
  interpretation : Environment FOR syntactic_representation;
END_ENTITY;
(*

Attribute definitions:

interpretation: the Environment that enables to associate a value with the variable.

4.1.6 Multiple_arity_generic_expression   EXPRESS-GMapping table

A Multiple_arity_generic_expression is a type of Generic_expression and is the ABSTRACT SUPERTYPE of all the multiple-arity operators.

EXPRESS specification:

*)
ENTITY Multiple_arity_generic_expression
  ABSTRACT SUPERTYPE
  SUBTYPE OF (Generic_expression);
  operands : LIST[2:?] OF Generic_expression;
END_ENTITY;
(*

Attribute definitions:

operands: a list of generic expressions that represent the operands of the multiple-arity operator.

4.1.7 Simple_generic_expression   EXPRESS-GMapping table

A Simple_generic_expression is a type of Generic_expression that a represents the connection. A Simple_generic_expression is either a Generic_variable or a Generic_literal.

EXPRESS specification:

*)
ENTITY Simple_generic_expression
  ABSTRACT SUPERTYPE OF (ONEOF (Generic_literal,
                                Generic_variable))
  SUBTYPE OF (Generic_expression);
END_ENTITY;
(*

4.1.8 Unary_generic_expression   EXPRESS-GMapping table

An Unary_generic_expression is a type of Generic_expression and is the ABSTRACT SUPERTYPE of all the unary operators.

EXPRESS specification:

*)
ENTITY Unary_generic_expression
  ABSTRACT SUPERTYPE
  SUBTYPE OF (Generic_expression);
  operand : Generic_expression;
END_ENTITY;
(*

Attribute definitions:

operand: the operand is a generic expression that represents the operand of the unary operator.

4.1.9 Variable   EXPRESS-GMapping table

A Variable is a type of a Generic_variable and stands for a value interpreted from some context. A Variable is either a Numeric_variable, a Boolean_variable or a String_variable.

EXPRESS specification:

*)
ENTITY Variable
  ABSTRACT SUPERTYPE
  SUBTYPE OF (Generic_variable);
END_ENTITY;
(*

4.1.10 Variable_semantics   EXPRESS-GMapping table

A Variable_semantics is used to represent the meaning of a Generic_variable. It is an ABSTRACT SUPERTYPE that shall be subtyped wherever a Variable_semantics is used. A Variable_semantics shall specify the context within which the variable shall be used together with the interpretation function that associates a value with this variable.

EXAMPLE    When modelling a class of components to which properties "a" and "b", with integer values apply. The constraint, stating that for every instance of this class, its value for "a" shall be greater than its value for "b", may be modelled through:

EXPRESS specification:

*)
ENTITY Variable_semantics
  ABSTRACT SUPERTYPE ;
END_ENTITY;
(*

4.2 ARM function definitions

This subclause specifies the ARM functions for this module. The ARM functions and definitions are specified below.

4.2.1 Acyclic

The Acyclic function is called by Is_Acyclic function. It has two arguments: the Generic_expression and an empty set where this set will be updated such that it contains the set of all the nodes already visited in the chain of recursive calls down to this node.

EXPRESS specification:

*)
FUNCTION Acyclic (arg1 : Generic_expression; arg2 : SET[0:?] OF Generic_expression) : BOOLEAN;
LOCAL
	result: BOOLEAN;
END_LOCAL;

IF ('GENERIC_EXPRESSION_ARM.SIMPLE_GENERIC_EXPRESSION'
	IN TYPEOF (arg1)) 
THEN
	RETURN (TRUE);
END_IF;

IF arg1 IN arg2 
THEN 
	RETURN (FALSE);
END_IF;

IF 'GENERIC_EXPRESSION_ARM.UNARY_GENERIC_EXPRESSION' 
	IN TYPEOF (arg1) 
THEN 
	RETURN 
	(Acyclic(arg1\Unary_generic_expression.operand,arg2+[arg1]));
END_IF;

IF 'GENERIC_EXPRESSION_ARM.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 
'GENERIC_EXPRESSION_ARM.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;
(*

Argument definitions:

arg1: a Generic_expression.

arg2: a set of Generic_expression.

4.2.2 Is_Acyclic

The Is_Acyclic function checks that there is no cycle in the reference graph of the expression.

Two functions are defined. The first one (named Is_Acyclic) has as argument the Generic_expression that shall be checked. The function then calls the second one (Acyclic) with two arguments: the Generic_expression and an empty set.

Is_Acyclic returns TRUE if the underlying structure of arg is a directed acyclic graph, if not, it returns FALSE.

NOTE    The informative annex F discusses the role of such a structure for the static analysis (e.g. type control, variable collection and so on) and dynamic analysis (e.g. evaluation) of an expression.

EXPRESS specification:

*)
FUNCTION Is_Acyclic (arg : Generic_expression) : BOOLEAN;
RETURN (Acyclic (arg, []));
END_FUNCTION;
(*

Argument definitions:

arg: a Generic_expression.

4.2.3 Used_variables

The Used_variables function walks through the whole generic expression graph collecting all the variables used and finally returning them. It traverses the directed acyclic graph representing a Generic_expression.

EXPRESS specification:

*)
FUNCTION Used_variables (arg : Generic_expression) : SET[0:?] OF Generic_variable;
LOCAL
	result : SET OF Generic_variable := [];
END_LOCAL;

IF 'GENERIC_EXPRESSION_ARM.GENERIC_VARIABLE' 
	IN TYPEOF (arg) 
THEN 
	RETURN ([arg]);
END_IF;

IF 'GENERIC_EXPRESSION_ARM.UNARY_GENERIC_EXPRESSION' 
	IN TYPEOF (arg)
THEN 
	RETURN (Used_variables (arg\Unary_generic_expression.operand));
END_IF;

IF 'GENERIC_EXPRESSION_ARM.BINARY_GENERIC_EXPRESSION'
	IN TYPEOF (arg)
THEN 
	RETURN(Used_variables(arg\Binary_generic_expression.operands[1])
		+ Used_variables (arg\Binary_generic_expression.operands[2]));
END_IF;

IF
'GENERIC_EXPRESSION_ARM.MULTIPLE_ARITY_GENERIC_EXPRESSION' 
	IN TYPEOF (arg)
THEN
	REPEAT i := 1 TO 
		SIZEOF(arg\Multiple_arity_generic_expression.operands);
		result := result + Used_variables(
			arg\Multiple_arity_generic_expression.operands[i]);
	END_REPEAT;
	
	RETURN (result);
END_IF;
RETURN ([ ]);
END_FUNCTION;
(*

Argument definitions:

arg: a Generic_expression.



*)
END_SCHEMA;  -- Generic_expression_arm
(*


© ISO 2014 — All rights reserved