


image::https://specifications.openehr.org/images/openEHR_logo_RGB.svg["openEHR logo",align="center"]

# Basic Meta-Model (BMM) v3 developments





## Acknowledgements

### Primary Author

* Thomas Beale, Ars Semantica; openEHR Foundation Management Board.

### Contributors

This specification has benefited from formal and informal input from the openEHR and wider health informatics community. The openEHR Foundation would like to recognise the following people for their contributions.

* Matija Kejžar, Senior Engineer, Better, Slovenia
* Patrick Langford, NeuronSong LLC, Utah, USA
* Claude Nanjo MA African Studies, M Public Health, Cognitive Medical Systems Inc., California, USA
* Harold Solbrig, Mayo Clinic, Rochester, USA
* Erik Sundvall PhD, Linkoping University, Sweden
* Bert Verhees, ROSA Software, The Netherlands.

### Trademarks

* 'openEHR' is a registered trademark of the openEHR Foundation;
* 'Java' is a registered trademark of Oracle Corporation;
* 'C#' is a registered trademark of Microsoft;
* 'OMG' and 'UML' are registered trademarks of the Object Management Group;
* 'MagicDraw' is a registered trademark of NoMagic Inc;
* 'Rational Software Architect' is a registered trademark of IBM Corporation.




ifdef::package_qualifiers[]
endif::[]

# Preface

## Purpose

This document describes the Basic Meta-Model (BMM), a model of object models. It may be considered as an approximate replacement for the UML XMI. It is human-readable and writable, and supports generic types (open and closed), container types, and multiple inheritance. The related {openehr_bmm_persistence}[BMM Persistence specification^] defines an object model for a serialised schema form. The latter enables serialisation of a BMM into a concrete syntax such as JSON, ODIN or XML.

## Status

This specification is in the PAUSED state. The development version of this document can be found at {openehr_bmm3}[{openehr_bmm3}^].

Known omissions or questions are indicated in the text with a 'to be determined' paragraph, as follows:
*TBD*: (example To Be Determined paragraph)

NOTE: Other than for working with particular tools designed to use BMM, BMM is not a required formalism for implementing openEHR, and other methods of accessing models computably may be used, including UML and software implementations of the openEHR Reference Model.

## Feedback

Feedback may be provided on the https://discourse.openehr.org/c/specifications/bmm-el[openEHR languages specifications forum^].

Issues may be raised on the https://specifications.openehr.org/components/{component}/open_issues[specifications Problem Report tracker^].

To see changes made due to previously reported issues, see the https://specifications.openehr.org/components/{component}/history[{component} component Change Request tracker^].

## Conformance

Conformance of a data or software artifact to an openEHR specification is determined by a formal test of that artifact against the relevant {openehr_its_component}[openEHR Implementation Technology Specification(s) (ITSs)^], such as an IDL interface or an XML-schema. Since ITSs are formal derivations from underlying models, ITS conformance indicates model conformance.

## Previous Versions

IMPORTANT: This document represents the v3 development line of the Basic Meta-Model, extending it with an expression and statement meta-model. The latest stable version of BMM, which is the v2.x form implemented by current openEHR tooling, is specified in the {openehr_bmm}[BMM specification^].

### Version 3.0.0

This version made major changes to the `BMM_TYPE` hierarchy and semantics, enabling generic inheritance by generic and non-generic classes to be represented.

### Version 3.1.0

This version adds meta-classes for computational elements to BMM, including:

* routines, variables, constants;
* expressions (including assertions);
* statements.

It makes various adjustments to the existing model attributes and classes. The BMM remains compatible with P_BMM 2.x, i.e. any existing `.bmm` file can be parsed to create a v 3.1.0 BMM instance.

## A Note on Language

The elements of meta-models are sometimes named confusingly in the literature and within various programming language technologies. In this specification, we use the following terms:

class:: generally refers to a class defined in a model expressed in BMM, i.e. an instance of a BMM meta-class;
meta-class:: refers to a class in the BMM itself, such as `BMM_CLASS`, in order to clearly distinguish it from classes defined in models represented using BMM;
feature (of a class):: any stored or computed element of a class, including constants, attributes (properties) and routines (methods);
property:: a stored class feature; also known as 'attribute';
routine:: a computed class feature that may be either value-returning (a function) or work-performing (a procedure);
function:: a routine that computes and returns a value; typically causes no side-effects in the object;
procedure:: a routine that performs a computation; typically has side-effects;
generic (class or type):: a kind of class or type that has parameters of other types; known as 'template' type in some programming languages;
type:: generally refers to a type defined in a model expressed in BMM, i.e. an instance of a BMM meta-type;
meta-type:: refers to a type in the BMM itself, which is either a class (such as `BMM_CLASS`) or generically derived (meta-)type in the sense of being an instance generator, where the instances will be concrete type definitions in models represented using BMM.

## Tooling

The {openehr_archie_github}[openEHR Archie Library^] fully implements this specification in Java and may be used to build UI tools for compiling, viewing and editing BMM models.

The {openehr_awb}[openEHR ADL Workbench (AWB)] fully implements this specification, and provides a convenient way of illustrating BMM semantics. The screenshots used in this specification are all from the ADL Workbench. The tool is written in the Eiffel language, and is available as {openehr_awb_github}[open source on Github^]. The BMM libraries can be found in the {eomf_bmm}[EOMF Github repository^].

# Overview

## Introduction

One of the key needs in any open computing environment is a computable representation of its own models. This is for a number of purposes, including reasoning about them, performing validation and consistency checking, building software and generating documentation. This is particularly true of openEHR and other archetype-based frameworks, where a further need is to be able to validate archetypes and templates with respect to the reference model, and also to validate runtime instance data against operational templates and the reference model.

A number of computable representations of the openEHR published models have been available in the past. Currently models are represented in two computable forms, namely UML and BMM (i.e. the format described in this specification).

The primary use of the UML expression is for specification publishing. In this role, UML diagrams and static models are built, and then post-processed to correct signatures of class properties and functions. The post-processing corrects UML's shortcomings and errors in non-singular relations, generic (template) types, and qualified attributes. The result can be used for publishing documentation with feature signatures that are formally correct and will be understood by developers in most programming languages. It can also be serialised and used computably, e.g. in other visualisation or modelling tools. UML's own serial format, XMI is thus generally unsuitable for such uses, due to the formal errors, as well as its excessive complexity. XMI is also notoriously non-standard across UML tools.

As a result, openEHR introduced the Basic Meta-Model (BMM) in 2009 as a way of representing correct object-oriented semantics of information models for use in tools, along with a serial format by default expressed in the {openehr_odin}[openEHR ODIN syntax^]. 

The BMM provides a standalone alternative to UML/XMI which correctly represents all types, including open and closed generic types, inheritance of generic types, and various other problems with UML. As a meta-model it is adapted to the task, i.e. representing entity types that can appear in object models, rather than the over-generalised semantics of the UML meta-model. This reduced scope, and the fact that it contains no diagram semantics enables its serial form to be human-readable. 

## Features

The Basic Meta-Model supports the representation of object models in the ISO RM/ODP information and computational points of view, i.e. in programming terms:

* definition of classes, properties and methods;
* delayed routine calls as first-class objects;
* expressions.

It is designed to enable both human authoring and machine processing, including e.g. extraction of BMM textual schemas from a UML tool or programming language classes. The semantics of the model are heavily influenced by the formal approach to object-orientation described by Bertrand Meyer in Object-oriented Software Construction cite:[Meyer_OOSC2] and also the {eiffel_ecma_367}[Eiffel language^], which is significantly better basis for object modelling than the UML 2.x meta-model. The BMM consequently departs from UML in a number of significant ways, and also from the OOSC/Eiffel approach in some aspects (e.g. direct meta-type suport for container types). Its key features are as follows:

* _OO+FP_: the Basic Meta-Model is directly based on a combination of Object-oriented class model, functional programming concepts and expression language, rather than being a highly general model like the UML meta-model;
* _Proper type meta-model_: types and Classes are distinguished in the meta-model, unlike UML which has no proper formal concept of type beyond a textual name;
* _Full generic types_: types as first-order entities enables the proper representation of generic typing and inheritance from open, closed, or partially open generic types, unlike in UML;
* _Container types_: such as `List<T>` and `Hash<K,V>` have their own meta-types;
* _Enumerated types_: supported via the notion of 'range-constrained' classes and also references to external value sets;
* _Built-in Expression Language_: fully defined expression meta-model supporting literals, properties, variables, function calls and agents; includes qualifiers;
* _Design by contract (DbC)_: formally supported via class invariants and routine pre- and post-conditions;
* _Operator / function aliasing_: support for mapping symbolic operators to function definitions.

Functional elements are supported via the inclusion of meta-types representing _signatures_ and _tuples_, enabling the construction of delayed agent calls, known here as _agents_, and function applications (i.e. function calls).

Note that there is no BMM entity for graphical diagramming semantics. Thus, there is no idea of 'association' distinct from an 'attribute', as per UML, which treats lines between class boxes as formal elements.

## Current State of the Art

### UML

One would expect that the IT industry would have fully computable representations of models and diagramming solved, but it is not yet the case. {omg_uml}[UML 2.x^] and its associated serialisation format XMI 2.x should in theory mean that complete, interoperable machine expressions of object models would be available in all tools. However the evolution of UML and XMI has not been toward a clear meta-model and language for each of its sub-languages (i.e. static class model, state machine, interaction diagram etc) but rather toward a single universal model of everything in which elements of all of its needs are confusingly buried. 

The UML 2.x specifications are exceedingly complex: UML 2.1.2 was specified by two documents, 'Superstructure' (738pp) and 'Infrastructure' (224pp); the UML 2.5.1 specification is only slightly smaller at 796 pages (see the {omg_uml}[OMG UML page^] for current specifications). The XMI 2.x specification is correspondingly complex, which seems to have so far prevented reliable tool interoperability (recognised as a critical issue by OMG in 2015). Despite the complexity, there are significant limitations in the UML meta-model, including:

* the composite or association nature of a class property only being known if it is represented as an association, i.e. a line linking two classes on a UML diagram;
* the notion of _type_ is not adequately formalised;
* the meta-model of generic types and container properties is problematic and does not map well to object programming languages;
* the Design By Contract (DbC) concept (i.e. pre-, post-conditions, class invariants), crucial for proper specifications, is in theory supported via the use of OCL 2.0 constraints in class definitions, but OCL suffers from the same underlying semantic weaknesses as UML;
* there is no direct support for functional entities, i.e. routine calls as objects (aka 'lambdas').

Experience with various UML tools (up till 2015) highlighted the following problems:

* poor support for OCL and design by contract in most tools;
* variable support for generic (i.e. template) classes; even those tools that properly implement the UML 2.5 specification are still very hard to use for defining generic classes because of problems in the specification that remain unaddressed;
* problems with qualified attributes, which are used to represent identifier references to objects rather than direct references;
* variable support for XSD generation across tools, where the results are wildly wrong in some tools;
* in some tools, it is impossible to define an abstract formal model - the only option is to select a particular programming language profile such as Java or C# and thus get locked into the limitations of those languages (messy type systems, weak inheritance semantics, language-specific notion of types such as `Array<T>`, `List<T>`, etc.).

Since 2015, the quality of some UML tools has improved, and the XMI generated by some is more reliable. However, XMI generated by different tools is not the same for identical models, and some XMI importers offer numerous switches in order to process the XMI of another tool properly. XMI thus still needs to be processed with care.

Nevertheless, a small number of tools, including MagicDraw (currently used for representing openEHR models for the specifications) and Rational Software Architect (RSA), appear to implement UML 2.5 faithfully. This means that despite the limitations of UML 2.5 (as noted above), models expressed in it can be mostly correctly interpreted and corrected by post-processing for purposes such as code generation and specifications publishing.

NOTE: Other tools may perform as well or better, and in any case, all tools change over time. No endorsement of a particular tool is intended here.

### XML Schema

For some, {w3c_xml_schema}[W3C XML schema^] represents a way of expressing object models, but it is not semantically suitable for this purpose, primarily due to its problematic non-object-oriented inheritance semantics, lack of generic classes, lack of representation of non-data members, and only marginal support for design by contract. It can be and is often used (including in openEHR) as a derivative serialisation representation.

## Computational Model

The BMM is specified as a structural model representing an abstract syntax tree (AST), which is the result of either in-memory construction (such as by a model authoring tool) or by parsing of a serialised representation of a BMM model. It does not specify an abstract syntax, and indeed, more than one concrete syntax could be parsed to a BMM instance.

NOTE: for the purposes of explanation, an abstract syntax is used throughout this document that draws freely from mainstream modelling and programming languages.

## Purpose of the BMM

### Class Model Representation

The BMM from version 3.0.0 on may be used to represent a full class model at an interface level (i.e. without code for methods) including classes, types, and class feature types including property (i.e. attribute), symbolic constant, manifest value, functions, operators, and procedures.

### Meta-Model for Expressions Language

The BMM provides a system of meta-types that act as the basis for a typed expression language. These include _references_ to static entities in scope (constants, variables, properties), literal values, construction of agents (lambda terms), and function calls (lambda applications).

### Information Model Representation

Until version 3.0.0, BMM supported only the information point of view, i.e. no computational interface, and in that form, it is often used to express models of data. Tools based on BMM can provide views of an object model expressed in BMM that are particularly useful to information modelling, such as the 'closure' view show below. This is a computed reachability graph of a fully inheritance-flattened class and all properties, including recursive references.

.BMM class - closure view
image::{doc_name}/images/awb_class_closure.png[id=awb_class_closure, align="center", width="60%"]

### Archetype Modelling

One of the uses of the BMM in the {openehr_awb}[openEHR ADL Workbench^] and other similar tools is to provide a computable form of the information model for use with domain-level content models, such as {openehr_am}[archetypes]. The following shows an archetype for which each node has its class shown (in colour), and additionally, the inclusion of non-archetyped attributes from the classes of the archetype nodes.

.ADL archetype with BMM class properties
image::{doc_name}/images/archetype_rm.png[id=archetype_rm, align="center"]

Newer tools are able to include the computational features. 

The https://specifications.openehr.org[openEHR project^] makes extensive use of BMM for representing its models for use in tools. The full set of openEHR models in BMM format may be found in the {openehr_its_bmm}[specfications-ITS-BMM repository on Github^].


# Package Structure

## Overview

The BMM packages are as follows:

* `org.openehr.lang.bmm`: the BMM
** `model_access`: the interface to most features including schema load/reload, generally used by an application as a reflection library;
** `core`: the core BMM classes used for in-memory representation of an object model. This consists of a number of sub-packages:
*** `model`: meta-types representing models and packages;
*** `entity`: meta-types representing classes and types including enumeration types, represented in the `range_constrained` sub-package;
*** `feature`: meta-types representing classes features, i.e. constants, routines, properties;
*** `literal_value`: meta-types representing literal values;
*** `expression`: an expression meta-model sufficient for expressing first-order predicate logic expressions, including class invariants and pre- and post-conditions.

Related packages are:

* the `org.openehr.lang.bmm_persistence` package, described in the {openehr_bmm_persistence}[BMM Persistence specification^], which contains the BMM Persistence classes.

These are illustrated below.

.Package Overview
image::UML/diagrams/LANG-bmm3-packages.svg[id=package_overview, align="center"]

## Class Definitions


# Model Access Package

## Overview

NOTE: This package is considered informative within this specification.

The `org.openehr.lang.bmm3.model_access` package provides an interface for the application to load BMM schemas and convert them to BMM model form, and is shown below. In this model, a _schema_ is the serial form of a _model_ or part of a model (i.e. instances of a persistence model like the `lang.bmm_persistence` model `P_XXX` classes). One or more schema files are parsed, validated and then converted to create a single `BMM_MODEL` instance.

.`org.openehr.lang.bmm3.model_access` Package
image::UML/diagrams/LANG-bmm3.model_access.svg[id=model_access_package, align="center"]

More than one format for representing serialised BMM models is possible, each having its load, validation and error-reporting logic. The common elements of the load, validate and convert logic are defined by the non format-specific classes in the package, with specific forms of the classes `BMM_SCHEMA_DESCRIPTOR` and `BMM_SCHEMA` required for each concrete format. The package above shows the relevant classes for the `P_BMM` version 2.x format, which is normally saved in `.bmm` files. Other formats may be saved in files with different extensions.

The singleton class `BMM_MODEL_ACCESS` acts as the entry point for client software to obtain access to loaded BMM models. Since the latter start as schema files which are typically nested according to an 'include' hierarchy, they must be parsed, validated and merged to create each 'top-level' _model_. The schemas are accessed via instances of the `BMM_SCHEMA_DESCRIPTOR` object, one for each schema file. The `_load()_` routine of this class loads a BMM schema file by direct deserialisation. 

If the file is structurally correct (say ODIN, JSON etc), an in-memory schema instance will result (e.g. `P_BMM_SCHEMA` in the case of the `P_BMM` format), and its `_validate_created_` method called. If this succeeds, `BMM_SCHEMA_DESCRIPTOR._bmm_schema_` will be set to this instance, of type `BMM_SCHEMA`. Subsequently, `BMM_SCHEMA._merge()_` will be called repeatedly, which results in each `_bmm_schema_` instance being the merged result of its include children and itself. After merging, `BMM_SCHEMA_DESCRIPTOR._validate_merged()_` will be called, and if successful, a call to `_create_model()_` will result in `BMM_SCHEMA_DESCRIPTOR._model_` being populated.

Each successfully loaded model is thus instantiated as a `BMM_MODEL`, and retrievable by calling `BMM_MODEL_ACCESS._bmm_model()_` with a _model key_, which is a model identifier with full, partial or no version part. In the latter cases, the most recent version model is retrieved for the key. For example, the keys `"openEHR_EHR_1.0.4"`, `"openEHR_EHR_1.0"`, `"openEHR_EHR_1"`, and `"openEHR_EHR"` will all match the `"openEHR_EHR_1.0.4"` model, assuming it is the most recent version available. This is convenient for matching models to artefacts (e.g. archetypes) that only mention the model publisher and name, but no version.

The following screenshot shows the BMM schema configuration dialog in the openEHR ADL Workbench, including some meta-data, validation status etc, and also the schema nesting structure. A single hierarchy of schemas corresponds to a single instantiated BMM model.

.BMM schema configuration
image::{doc_name}/images/awb_schemas_config.png[id=awb_schemas_config, align="center", width="60%"]

The screenshot below shows a number of merged BMM models loaded into the AWB, including some of the packages and classes for the `openehr_ehr_extract_1.0.4` model.

.BMM schemas loaded
image::{doc_name}/images/awb_loaded_bmm_schemas.png[id=awb_loaded_bmm_schemas, align="center", width="40%"]

## Class Definitions



# Model Structure

## Overview

The `core` package defines the main BMM meta-model, within which the `model` sub-package defines the top-level structure of a model which is an instance of the BMM. The UML for this package is shown below.

.`base.bmm.core.model` Package - Model structure
image::UML/diagrams/LANG-bmm3.core.model.svg[id=core_model, align="center"]

## Naming Convention

In a BMM model, names typically appear in the common case-sensitive form used by the model users, and may therefore follow one of a number of common conventions, including 'camel case', 'snake-case' and so on. When used computationally within an instantiated BMM model, it is assumed that case-insensitive matching is used. This means that the class name `"Hashable"` refers to the same class as `"HASHABLE"`. Note however that underscores are not removed during matching, so that the classes `"HashMap"` and `"HASH_MAP"` are understood as different classes.

NOTE: a future version of BMM may define an option to import schemas using differing naming styles, with transformation into a single style for the target model.

## Model Semantics

In BMM, a _model_ is understood as a set of _package_ and _module_ definitions that are developed and maintained as a unit, by some organisation, and usually having an associated hierarchical namespace. The abstract `BMM_MODULE` class is the ancestor for any kind of module, which is understood as a container for _features_ of various kinds, including the usual _properties_, _routines_, and so on. A BMM model is structured in the same general way as a UML model, i.e. with a hierarchical package containment structure and a set of module definitions, where a commonly used type of module is the _class_.  The following illustrates the structure of a typical 'class' or 'object' model.

.BMM model structure
image::{doc_name}/diagrams/bmm_structure.svg[id=bmm_structure, align="center"]

The `BMM_MODEL` class defines the single instance of each distinct BMM model that may exist within a collection of models, such as shown in the `model_access` package above. It provides an interface that enables any class definition to be retrieved, as well as various accessor functions to interrogate the model. A BMM Model has a name (the inherited `_name_` attribute) that is used to identify the model as a whole within a system using multiple models. It contains a number of other meta-data attributes describing authorship etc, and otherwise contains a list of package and class definitions.

### Packages

In BMM, packages have the same role as in UML - as non-semantic organisational logical containers of classes, usually corresponding to file system folders in software implementations. They provide an organisational convenience, and in an instantiated BMM model, contain references to class definitions. A model validity checker ensures that every class is contained within exactly one package.

Package paths are only used in BMM to specify package structures in the serialised form in an efficient way, i.e. by using paths to avoid defining a hierarchy in which only lower packages contain classes. They are not used as namespaces as in UML. Consequently, *all classes in a BMM model should be uniquely named*.

### Use of other Models

A model may _use_ another model. This is the same kind of relationship denoted by the 'import' keyword in many programming languages. In BMM, the use of other models is declared once only, in the using model, rather than on a per-class level as in some languages (e.g. Java). The use of another model makes its contents available for use in declarations (e.g. inheritance) and expressions within the using model. This is achieved by populating the `BMM_CLASS._scope_` attribute with a reference to the used model. In a serial form, a typical syntax such as `other_model_name::Class` would be used.

### Documentation

A `_documentation_` attribute is inherited from `BMM_MODEL_ELEMENT` into `BMM_MODULE`, `BMM_FEATURE` and `BMM_PACKAGE_CONTAINER, enabling packages, classes, routines and properties to be individually documented using a keyed table (i.e. Hash) of values.

It is strongly recommended to use the following key /type combinations for the relevant purposes:

* `"purpose": String`
* `"keywords": List<String>`
* `"use": String`
* `"misuse": String`
* `"references": String`

Other keys and value types may be freely added.

### Other Meta-data

The `BMM_MODEL_ELEMENT` meta-class also defines the attribute `_extensions_` of type `Hash<String, Any>`, to enable representation of meta-data of any type on any model node. This provides a means of extending BMM.

## The Any Class and Type

While a BMM model defines a model in terms of class declarations, it must always have a top class named `Any` from which all others inherit. Similar to the root class in a typical OOPL type systems (sometimes called 'Object'), the `Any` class defines semantics true for all objects such as equality (i.e. semantics for an '=' operator) and copying.

A BMM model may define its own `Any` class, but if it does not, the `BMM_MODEL` instance representing the model will produce a standard 'Any' class via the `_any_class_definition()_` method. This will create the following structure, including a default package structure, and an `Any` type.

.Default `Any` class
image::UML/diagrams/LANG-bmm3-any_class.svg[id=bmm_any_class, align="center"]

The `Any` type defined by the model's `Any` class, or else the default one above, will be used as the inheritance parent for every class in the model that doesn't have any other inheritance parent. As a result, the inheritance graph will always have the `Any` type as its top node.

## Class Definitions



# Types

## Overview

One of the foundational distinctions in the BMM is between _class_ and _type_, in common with the type systems of the modern forms of most object-oriented languages, but in contrast to the UML meta-model. This division is reflected in the two top-level meta-classes `BMM_CLASS` and `BMM_TYPE`, and their respective descendants, as shown in the following UML diagram.

.`base.bmm.core.entity` Package - Types
image::UML/diagrams/LANG-bmm3.core.entity.svg[id=core_entity, align="center"]

Classes are _definitional_ entities, while types are understood in BMM as the _formal generators_ of instances (where non-abstract). Types are the the basis of static typing in a formal model, and dynamic conformance at execution time, when polymorphic attachment is possible. Most types are specified via the definitions of classes and their constituent parts within a 'model'. Types are used for the following purposes in a BMM model:

* to define the _types of properties_;
* to defined the _types of routine parameters and return values_;
* to define _formal type parameters_ in a generic class;
* to define type(s) of _inheritance ancestors of class definitions_;
* to formalise concepts relating to functional programming, including _tuples_ and routine _signatures_;
* to determine _conformance_, which is a relation between types (not classes).

A simple example of typing of properties is shown in the instance diagram below.

.BMM Typing
image::{doc_name}/diagrams/bmm_entities.svg[id=bmm_entities, align="center"]

Most types are based on one or more _defining_ class(es), which provide the formal definition for the type. The exceptions are formal generic parameters (e.g. the `T` in `List<T>`) and the special built-in types for tuples and routine signatures. The BMM meta-type `BMM_TYPE` and its descendants define the kinds of types available in a BMM model. The design of the types part of the BMM is based on a taxonomy that makes various distinctions convenient to a formalism intended for modelling rather than pure programming. This leads in particular to the top-level distinction between _unitary_ and _container_ meta-types. The taxonomy is illustrated below, including differentiae.

.BMM meta-type taxonomy
image::{doc_name}/diagrams/bmm_metatype_taxonomy.svg[id=bmm_metatype_taxonomy, align="center"]

`BMM_TYPE` includes features common to all meta-types:

* `_is_abstract_`: indicates a type based on an abstract class - i.e. one that cannot be directly instantiated;
* `_is_primitive_`: indicates that a type is derived from a primitive class; primitive status has no effect on BMM model semantics, and is provided as a convenience for visualisation and type-system mapping;
* `_type_name_`: the effective type name of an entity; for simple classes, this will just be the class name (`BMM_CLASS._name_`); for generic and container classes it will be generic name such as `List<T>`, `Interval<T>` etc; for feature types it will be the declared type, i.e. a simple name, an open type name (e.g. `T`) or a generic type name (e.g. `Interval<Time>`);
* `_type_signature_`: a form of the type name that can be used as a fully-defined type signature, which for generic classes includes generic constrainer types, giving a signature such as `Interval<T:Ordered>`.

Below `BMM_TYPE` are the abstract meta-type `BMM_UNITARY_TYPE` and the concrete meta-type `BMM_CONTAINER_TYPE` and its specialisation `BMM_INDEXED_CONTAINER_TYPE`. `BMM_UNITARY_TYPE` is a meta-type for types whose _instances are unitary_ i.e. singular, while the container meta-types correspond to _collections of instances_. The latter are further described below. This distinction is made to enable BMM to directly represent the notion of collections in the type system rather than treating them in the same way as any other type, which would force modellers (i.e. authors of actual BMM models) to state concrete containment types such as `ArrayedList<Packet>`, where `ArrayedList` would have to be defined in the model as well as `Packet`. 

Unitary meta-types are further distinguished as formal generic parameters (`BMM_PARAMETER TYPE`) and _effective_ types, i.e. concrete unitary types. The former meta-type is used to represent replaceable formal generic parameters (typically 'T', 'U' within types such as `List<T>` etc) within generic type declarations.

Effective types have as their meta-type `BMM_EFFECTIVE_TYPE`. Its subtypes are `BMM_MODEL_TYPE`, a meta-type for types defined by classes in the model (thus characterised by the property `_base_class_: BMM_CLASS`), `BMM_TUPLE_TYPE`, a meta-type for tuples (a list of objects of varying types), and `BMM_SIGNATURE`, a meta-type representing signatures of routines and typed model elements (properties, variables etc).

`BMM_MODEL_TYPE` divides into `BMM_SIMPLE_TYPE` and `BMM_GENERIC_TYPE`, corresponding to the standard notions of types familiar in modern programming languages. The class definitions of instances (i.e. BMM model class definitions) of these meta-types are available via the property `_base_class_`, of meta-type `BMM_CLASS` for a BMM simple type, and `BMM_GENERIC_CLASS` for BMM generic type.

These various concrete meta-types are described in more detail below.

## Simple Type

A _simple type_ is a type based only on a _simple class_, which is a class with no formal generic parameters. An instance of a simple type is fully described by the class on which it is based, with the only difference being the usual object-oriented possibility of polymorphic attachments of sub-objects whose dynamic types conform to their static type counterparts in the original simple type. Thus, for example, a class `Organisation` may have a property `_manager_` of static type `Employee`. An instance of the simple type `Organisation` might have its `_manager_` property attached to an instance of `Manager`, which is legal as long as `Manager` conforms to `Employee`, which it will do if `Manager` is defined as a subtype of `Employee`.

### Conformance

Conformance of Simple types follows the inheritance hierarchy via which they are defined, according to the rules:

* _meta-rule_: A Simple type can only conform to a Model type, i.e. either another Simple type or a Generic type;
* _concrete rule_: A Simple type A conforms to Simple type B iff for `_base_class_` of A, `_all_ancestors()_` contains B.

## Generic Type

A _generic type_ is a type based on a _generic class_, which has one or more formal type parameters that are substituted by actual types in its declaration. For example, the generic type `Interval<Quantity>` can be used in a model that contains the generic class `Interval<T:Ordered>` and `Quantity`. The general case is that the generic parameter substitution type (`BMM_GENERIC_TYPE._generic_parameters_`) for any formal parameter (`BMM_GENERIC_CLASS._generic_parameters_`) is of meta-type `BMM_UNITARY_TYPE`.

A typical programmatic usage of such a type, and its instantiated BMM model structure is shown below.

.Generic type - closed simple
image::{doc_name}/diagrams/bmm_structure-generic_1.svg[id=bmm_structure_generic_1, align="center"]

The parameters of a generic type may be:

* a substitution of a formal parameter from the generic class with a concrete type, including other generic types and container types;
* an unsubstituted formal parameter, if used as the type of a feature, routine argument etc, whose context has an open generic type to which this parameter conforms.

Consequently, a generic type may be:

* _closed_: all formal parameters substituted e.g. `Interval<Quantity>`;
* _partially closed_: at least one formal parameter is substituted e.g. `Document<ClinicalContent, U>`;
* _open_: no formal parameters substituted, e.g. `Document<T, U>`.

The first case is detected via the function `_is_closed_` defined on `BMM_GENERIC_TYPE`, while the function `_is_partially_closed_` distinguishes the latter two cases. 

The following shows the BMM instance structure of a generic type that is open.

.Generic type - open
image::{doc_name}/diagrams/bmm_structure-generic_3.svg[id=bmm_structure_generic_3, align="center"]

Since the meta-type of `BMM_GENERIC_TYPE._generic_parameters_` in the BMM is `BMM_UNITARY_TYPE`, constructions such as `MyGenericType<List<OtherType>>` are prevented, due to the concrete parameter type `List<OtherType>` being an instance of `BMM_CONTAINER_TYPE` rather than of `BMM_UNITARY_TYPE`. Such constructions are nearly always wrong, and not needed in a model expressed in BMM, because containment can be expressed _where the formal generic parameter is used_, not where the concrete parameter is declared. The following diagram shows the BMM concrete model structure created for a generic type whose formal parameter type is used in this way, i.e. within a container type.

.Generic type - closed container
image::{doc_name}/diagrams/bmm_structure-generic_2.svg[id=bmm_structure_generic_2, align="center"]

### Conformance

Conformance of Generic types is according to the rules:

* _meta-rule_: A Generic type can only conform to another Generic type;
* _concrete rules_: A Generic type `Ga<Ta~i~, ...>` conforms to Generic type `Gb<Tb~i~, ...>` iff:
** for `_base_class_` of `Ga`, `_all_ancestors()_` contains Gb; and
** the number of generic parameters is equal;
** for each `Ta~i~`, either
*** `Tb~i~` is an open formal parameter, and `Tai` conforms to any generic constraint type, or;
*** `Ta~i~` conforms to `Tb~i~`.

## Container Meta-types

In object-oriented type theory, 'container' types are generic types whose outer class happens to have the semantics of a container object, such as a list, set etc. Container types such as `List<T>`, `Set<T>` and `Hash<K,V>` are used ubiquitously in object models. In the BMM, containers and non-container generic types are distinguished via the meta-classes `BMM_CONTAINER_TYPE` and `BMM_GENERIC_TYPE` respectively. This allows the BMM to treat container types in a special way. A `BMM_CONTAINER_TYPE` can be thought of as a 1:N counterpart to a `BMM_UNITARY_TYPE`, such as the type `List<Paragraph>` with respect to `Paragraph`. `BMM_GENERIC_TYPE` is thus used for objects considered to be singular, but whose types are a product of the base class and one or more parameter types, e.g. `Interval<Quantity>`. 

The explicit provision of `BMM_CONTAINER_TYPE` enables BMM models to mention logical linear container types such as `List<T>` and `Set<T>`, on the assumption of their standard semantics in computer science , without worrying about providing concrete types which may be numerous and also variable across programming languages, e.g. `ArrayedList<T>`, `LinkedSet<T>`, `ArrayedStack<T>` and so on.

List and Set semantics are achieved via the `BMM_CONTAINER_TYPE` attributes `_is_ordered_` and `_is_unique_`, used in the standard combinations i.e.:

* `_is_ordered_ and not _is_unique_`: `List<T>`;
* `_is_unique_`: `Set<T>` (ordered or not);
* `not _is_ordered_ and not _is_unique_`: `Bag<T>`.

The following diagram shows how the container type `List<Paragraph>`, declared as the type of an attribute `_paragraphs_` in a class `Document`, is represented in a BMM model.

.Container Type
image::{doc_name}/diagrams/bmm_structure-container.svg[id=bmm_structure_container, align="center"]

The semantics of indexed containers, commonly known under the type names `Hash<K,V>`, `HashMap<K,V>`, `HashTable<K,V>`, `Dictionary<K,V>` and so on, are represented by the meta-type `BMM_INDEXED_CONTAINER_TYPE`, which inherits from `BMM_CONTAINER_TYPE`, and adds the property `_index_type_`. The latter type represents the key type, which must be such that hash values can be generated, and may be any type, but practically speaking, is almost always a `String`, `Integer`, or a Date/Time type.

The following diagram shows how the container type `Hash<String, Person>` is represented in a BMM model.

.Indexed Container Type
image::{doc_name}/diagrams/bmm_structure-indexed_container.svg[id=bmm_structure_indexed_container, align="center"]

### Conformance

Conformance of Container types is according to the rules:

* _meta-rule_: A Container type can only conform to another Container type;
* _concrete rules_: 
** A Container type `C~a~<V~a~>` conforms to Container type `C~b~<V~b~>` conforms to iff:
*** for `_base_class_` of `C~a~`, `_all_ancestors()_` contains `C~b~`; and `V~a~` conforms to `V~b~`.
** An indexed Container type `C~a~<K~a~, V~a~>` conforms to indexed Container type `G~b~<K~b~, V~b~>` iff:
*** for `_base_class_` of `C~a~`, `_all_ancestors()_` contains `C~b~`; `K~b~` conforms to `K~b~` and `V~a~` conforms to `V~b~`.

## Bult-in Meta-types

BMM includes a small number of built-in meta-types that do not have corresponding model-source classes. These are shown in the following UML and described in the following sub-sections.

.Built-in meta-types
image::UML/diagrams/LANG-bmm3.core.entity-builtin.svg[id=core_entity_builtin, align="center"]

### Tuple Meta-type

The meta-type `BMM_TUPLE_TYPE` enables the _type_ of a tuple i.e. an array of objects each of which may be of any type, to be stated in terms of other types. This is mostly used to state the type of a set of arguments in the `BMM_SIGNATURE` class, but standalone tuple types may also be used in a model, providing roughly the effect of an anonymous class (or a `struct` in C/C++).The notional type `Tuple` defined by `BMM_TUPLE_TYPE` is treadted as a BMM built-in, and is therefore not stated in any BMM model.

#### Conformance

Conformance of Tuple types is according to the rules:

* _meta-rule_: A Tuple type can only conform to another Tuple type;
* _concrete rules_: A Tuple type `Tuple[Ta~i~, ...]` conforms to Tuple type `Tuple[Tb~i~, ...]` iff:
** for each `Ta~i~`, `Ta~i~` conforms to `Tb~i~`.

The practical effect of this is that longer tuples may conform to shorter tuples. For example, the tuple type `[Document, String, Integer]` conforms to the tuple type `[Document]`.

### Signature Meta-type

Within any typed formalism, any entity declared as having a type also has a _signature_. In BMM, this is is the case for any kind of feature of a class, including constants, properties, and routines. The signature of a feature is a formal construct capturing the type structure of the feature. The simplest type of signature is that of properties and constants, which may be expressed formally in a typical abstract syntax as follows:

```
    T_result
```

This indicates that both have a return type, being the type of the value they are attached to at execution time.

The general form of routine signatures is as follows:

```
    Function <[T_arg1, T_arg2, ...], T_result>    -- Function type
    Procedure <[T_arg1, T_arg2, ...]>             -- Procedure type
```

In the above, the construction `[Type, ...]` represents a type-tuple. Strictly speaking, the 'Function' and 'Procedure' are unnecessary, since they can be inferred from just the pure signature. However, for readability they are recommended.

Typical examples of function signatures are as follows:

```
    Function <[], Date>                          -- a 0-order function like current_date
    Function <[Real, Real], Real>                -- a 2nd-order function like '*' for the domain R
    Function <[Integer, Integer], Integer>       -- a 2nd-order function like 'add' for the domain I
```

Typical procedure signatures include the following:

```
    Procedure <[]>                               -- a 0-order (argumentless) procedure
    Procedure <[Real]>                           -- a 1st-order procedure for the domain R
    Procedure <[String, Integer]>                -- a procedure taking a String and an Integer argument
```

In order to support functional semantics such as function-as-object, the notion of signature is defined in BMM as a first order meta-type, `BMM_SIGNATURE` and descendants. Instances of `BMM_SIGNATURE` represent any kind of signature and reference the meta-type of the evaluated form via `_result_type_`, which may be of any BMM meta-type.

`BMM_ROUTINE_TYPE` is the meta-type of any kind of agent (i.e. lambda) and provides `_argument_types_`, whose meta-type is `BMM_TUPLE_TYPE` (See <<Tuple Type>>). The descendant `BMM_PROCEDURE_TYPE` specialises the return type to the built-in type `BMM_STATUS_TYPE` (see below), used to represent the status of a procedure call.

The following signatures state the types 'any function' and 'any procedure':

```
    Function <>                                  -- any function
    Procedure <>                                 -- any procedure
```

As for the Tuple meta-type, the notional `Signature` meta-type is a BMM built-in, and is not itself defined in any BMM model.

#### Conformance

Conformance of Signature types is as follows:

* _meta-rule_: A Signature type can only conform to another Signature type;
* _concrete rules_: 
** all specific Function signatures conform to the signature `Function`;
** all specific Procedure signatures conform to the signature `Procedure`;
** the conformance of specific Function or Procedure signatures to another Function or Procedure signature is such that:
*** the number of argument types accord and;
*** the type conformance of each corresponding argument and result type (for functions) follows the rules for conformance given by the meta-types of those types.

### Status Meta-type

The meta-type `BMM_STATUS_TYPE` is provided to represent the return type of procedure calls, i.e. of which the pure formal type is often denoted `Void` or `None` in programming languages. Using a special return type simplifies the meta-model of routines, since without it, procedures create an anomaly within a system in which all other class features have a result type. Within BMM, procedures are considered to be _state-changing actions_, and the Status return type enables call and/or execution status information to be returned. Usually this can be ignored, and procedures can be called without assignment. This approach is similar to that of Haskell, in which procedure calls return the 'unit' type.

## Type Conformance

An algorithm to determine conformance of two type-names (e.g. to implement `BMM_MODEL._type_conforms_to()_`) is as follows:

```java
Boolean type_conforms_to (String a_type, anc_type)
{
    BMM_TYPE_NAME a_type_name, anc_type_name;

    if attached create_type_name_from_string (a_a_type) as a_type_name and
        attached create_type_name_from_string (anc_type) as anc_type_name
    {
        base_class = a_type_name.name;
        anc_base_class = anc_type_name.name;
        
        if (base_class.is_case_insensitive_equal (anc_base_class) or else 
            class_definition (base_class).has_ancestor_class (anc_base_class)) 
        {
            BMM_CLASS bmm_def_class = class_definition (base_class);
            
            
            
            if (valid_generic_type_name (a_type) and bmm_def_class instanceOf (BMM_GENERIC_CLASS) {

                BMM_CLASS anc_bmm_def_class = class_definition (anc_base_class);
                if (valid_generic_type_name (anc_type) and anc_bmm_def_class instanceOf (BMM_GENERIC_CLASS)) {
                    ArrayedList<String> a_type_gen_params = a_type_name.generic_parameters_type_list;
                    ArrayedList<String> anc_type_gen_params = anc_type_name.generic_parameters_type_list;
                    
                    if (a_type_gen_params.count = anc_type_gen_params.count) {
                    
                        Iterator<String> this_gen_parms_it = a_type_gen_params.iterator();
                        Iterator<String> other_gen_parms_it = anc_type_gen_params.iterator();

                        Boolean result = True;
                        String a_type_gen_type, anc_type_gen_type;
                        
                        while (this_gen_parms_it.hasNext() && other_gen_parms_it.hasNext() || !result) {
                            String this_gen_parm = this_gen_parms_it.next();
                            String other_gen_parm = other_gen_parms_it.next();
                            if (formal_generic_parameter_name (this_gen_parm))
                                a_type_gen_type = this_bmm_gen_class.generic_parameter_conformance_type (this_gen_parm);
                            else
                                a_type_gen_type = this_gen_parm;
    
                            if (formal_generic_parameter_name (other_gen_parm))
                                anc_type_gen_type = other_bmm_gen_class.generic_parameter_conformance_type (other_gen_parm);
                            else
                                anc_type_gen_type = other_gen_parm;

                            -- now do the test
                            result = type_conforms_to (a_type_gen_type, anc_type_gen_type);
                        }
                        
                        return result;
                    }

                }
                else
                    return True;
            }
            else
                return not valid_generic_type_name (anc_type);
        }
    }
}

```

## Model Theoretic Questions

The above model produces a number of outcomes that are not necessarily immediately obvious or expected, including:

* Inheritance is from classes to types rather than classes;
* A Generic type parameter can only be a unitary type, i.e. not a container type;
* Tuple and Signature types are pure types, i.e. not defined in generating model other than by implication due to use as routine argument lists;
* In theory, a Signature type could be a `BMM_GENERIC_TYPE` descendant but the specialisation restriction would make the meta-model more complex for no obvious benefit.

## Class Definitions





# Classes

## Overview

This section describes the semantics of the `BMM_CLASS` meta-class, its sub-types, constituent parts and relationships. Classes in BMM are _generators of types_, and are what is authored (i.e. 'programmed') in order to create a model or program text.

The formally typed parts of a class are collectively known as _features_, and consist of functions, procedures, constants and properties, which appear in _feature groups_. Within a class, all features are contained in the `_features_` attribute (inherited from `BMM_MODULE`), with features of each specific type being referenced in a dedicated map (`BMM_CLASS._properties_` etc). The following UML illustrates classes and relationships to constituent feature meta-types. Features are described in detail in the following section.

.`base.bmm.core` Package - Classes
image::UML/diagrams/LANG-bmm3.core-class.svg[id=core_class, align="center"]

Class definitions are the _definitional_ basis of a BMM model, i.e. they are the means of defining the types that are statically used in the model, and the dynamic types generated at runtime. Types are thus _derived_ entities.

The top meta-class `BMM_CLASS` defines two properties inherent in classes defined in a model, and derived in resulting types: `_is_abstract_` and `_is_primitive_`. The Boolean attribute `_is_abstract_` indicates a class that cannot be directly instantiated. The attribute `_is_primitive_` indicates that a class is considered to be part of a primitive type set (typically corresponding to primitive types in another type system). Primitive status has no effect on BMM model semantics, and is provided as a convenience for visualisation and type-system mapping.

BMM distinguishes between simple and generic class definitions via two descendants of `BMM_CLASS`, i.e. `BMM_SIMPLE_CLASS` and `BMM_GENERIC_CLASS`, with the first providing a concrete form of `BMM_CLASS` that applies to non-generic classes, and the latter defining the additional semantics of generic classes. The meta-type `BMM_ENUMERATION` is a specialisation of `BMM_SIMPLE_CLASS` used to represent enumeration classes in BMM models. The meta-types are further described below.

## Simple Classes

The simplest type of class definition in a model is an instance of the meta-type `BMM_SIMPLE_CLASS`, and has a 1:1 relationship with its type. Such classes might be specified in the following abstract syntax:

```kotlin
class DvQuantity
{
    feature
}

class Observation
{
    feature
}    
```

## Generic Classes

The generic class meta-type `BMM_GENERIC_CLASS` adds generic parameters to `BMM_CLASS`, enabling formal generic parameters to be represented. Each such parameter is expressed using an instance of `BMM_PARAMETER_TYPE` which names the parameter and optionally allows a type constraint to be associated with it, in the usual object-oriented fashion. In BMM, formal parameters have single-letter names, such as 'T', 'U' etc, following typical usage in programming languages. A generic class may also be primitive. Generic classes can be defined in a syntax similar to the following.

```kotlin
primitive class List <T>

feature


class DvInterval <T:DvOrdered>

feature

primitive class HashMap <K:Ordered, V> 

feature
```

The following example shows a generic class `Interval<T:Ordered>`, which is a class `Interval` with one formal parameter `T` constrained to be of type `Ordered` or any descendant.

.BMM class - generic class
image::{doc_name}/images/awb_generic_class.png[id=awb_generic_class, align="center", width="50%"]

## Range-Constrained Classes

The value range of any defined type is by default open, meaning that its instances may take any value allowed by the type definition. For primitive types such as `String` and `Integer`, this means that any String or Integer value is a valid instance of their respective types. For complex types, instances are composed of hierarchies of values which are similarly unconstrained with respect to their types. 

A useful derived form of any concrete type definition (i.e. instance of `BMM_EFFECTIVE_TYPE` in a model) is one that constrains the legal values of its instances to a particular set of values. The Pascal language provided a well-known precedent, 'sub-range types' that could restrict primitive type value ranges. BMM supports two kinds of range constraint: enumeration and 'value sets'. The additional meta-classes are shown below.

.`bmm.core.range_constrained` Package - Constrained-range Meta-Types, including Enumeration
image::UML/diagrams/LANG-bmm3.core.range_constrained.svg[id=core_range_constrained, align="center"]

### Enumerated Types

In modern programming languages, the _enumerated type_ is the most common kind of range constraint mechanism. In Java for example, an enumeration is a finite set of labels each associated with a singleton value object - either automatically assigned integers, or else programmatically associated instances of any other kind. Enumerated types are supported in BMM via the `BMM_ENUMERATION` meta-type and descendants.

An enumerated type could in theory be based on any BMM defined type, i.e. any simple or generic type, since instances of either could be constrained. BMM makes the simplification that an enumerated type can only be based on a BMM simple type, which means that in the defined model, an enumeration of a closed generic type `Gen<T_subst>` is achieved by first defining a simple type based on the closed generic type via inheritance, e.g. a type `Gen_T_subst` that inherits from `Gen<T_subst>` can be used as the ancestor of a BMM enumeration type.

For this reason, the `BMM_ENUMERATION` meta-type is defined as a descendant of `BMM_SIMPLE_CLASS`, and may have only one ancestor. The value enumeration is represented via a set of enumeration labels (`_item_names_`) and constant values (`_item_values_`), the latter of which must be of the type represented in the concrete model by the instance of the ancestor class.

Since `String` and `Integer` valued enumerations are by far the most common in real models, two descendant classes `BMM_ENUMERATION_STRING` and `BMM_ENUMERATION_INTEGER` are provided, which fix the values and types to `String` and `Integer` respectively.

The following diagram shows the BMM instance structure corresponding to an attribute declaration `_lifecycle_: TaskLifecycle` in a class `Order`.

.Integer-based Enumeration Type
image::{doc_name}/diagrams/bmm_structure-enumeration.svg[id=bmm_structure_enumeration, align="center"]

The following shows the same class in an abstract syntax.

```kotlin
enumeration class TASK_LIFECYCLE

feature -- Enumeration Literals

    planned   = 0;
    available = 1;
    cancelled = 2;
    aborted   = 3;
    abandoned = 4;
    underway  = 5;
    suspended = 6;
    resumed   = 7;
    completed = 8;
```

The following screenshot shows how this enumeration class appears within a BMM model.

.Enumeration Example
image::{doc_name}/images/awb_enumeration.png[id=awb_enumeration, align="center", width="65%"]

The following shows another enumeration class, this time based on the `String` type. 

```kotlin
enumeration class ContractStatus

feature -- Enumeration Literals
    initial   = "Initial";
    cancelled = "Cancelled";
    active    = "Active";
    completed = "Completed";
```

The types `String` and `Integer` are assumed to be defined via primitive classes of the same names.

### Value-set Types

Another form of range constraint that occurs in many models is the use of 'coded terms' that represent codes from e.g. ISO or IANA value sets such as ISO 639 (languages) and IANA media types. These are particularly prevalent in type systems used in the biosciences where object models routinely include attributes of a Coded Term type that refer to terminologies such as {snomed_ct}[SNOMED CT^], {who_icd}[WHO ICD10^] etc. In such models, it is typical to want to define an attribute being not just of a Coded Term type, but also limited to a particular terminology (such as a coded attribute representing 'language'), or even a specific 'value set' from such a terminology.

The same kind of constraint may be applied to any kind of model type, for example a type representing Medication may be constrained to be instantiated only as instances defined by a medications database. This kind of constraint is known here as a _value set_, following the common usage in the biomedical sciences, and is supported in a different way than enumerations. The latter is a common programming concept which always involves a dedicated type representing the enumeration. Since the required value-sets are represented explicitly in the model but in an external database or other resource, the constraint is limited to a reference to the relevant resource, and is applied directly to _the use of a type within a feature definition_, rather than requiring the definition of a new type.

Accordingly, BMM provides the attribute `_value_constraint_: BMM_VALUE_SET_SPEC` defined on `BMM_MODEL_TYPE`. The `BMM_VALUE_SET_SPEC` meta-type contains two `String` attributes `_resource_id_` and `_value_set_id_` which may be used to define a resource (equivalently a namespace) and an identifier of a value set within that resource. BMM does not impose any particular format or resolution algorithm on these identifiers - it is assumed that they can be correctly defined and used within the context of the concrete model usage.

Consequently, an attribute within a standard concrete model such as `_language_: CodedTerm` could now be expressed notionally as `_language_: CodedTerm \<<iso::639-*>>` or `_language_: CodedTerm \<<iso::languages>>`. The construction within the `<<>>` is parsed into two pieces around the `::` separator, which are then used to populate the `BMM_VALUE_SET_SPEC` for a type.

The following diagram shows the meta-model structure corresponding to an attribute declaration `_language_: CodedText` whose instances are constrained to be from a value-set `iso_639-2` within the resource namespace `iso`.

.Value-set Constrained Type
image::{doc_name}/diagrams/bmm_structure-value_set.svg[id=bmm_structure_value_set, align="center"]

The following shows a possible abstract syntax value-set type definition.

```kotlin
class Document

feature
    property language: CodedText <<"iso::iso_639-2">> [1];
```

## Class Qualifiers

The following sub-sections describe qualifiers that may be used on any class definition to achieve a specific status within the model system. BMM qualifiers are designed to map to typical features in programming languages.

### Abstract Classes

Any class definition in a BMM model may be marked as 'abstract', to indicate that it cannot be directly instantiated. This qualifier generally maps to the concept of abstract classes in most OOPLs. It may be specified in an abstract syntax as follows.

```kotlin
abstract class ENTRY

feature
```

### Primitive Type Classes

Class definitions within a BMM model may be marked as 'primitive', enabling them to be visualised and queried as a separate group without otherwise changing the semantics of the entity in the BMM meta-type system. This is normally done to distinguish 'built-in' types used by a model from the classes for which the model was created. An abstract syntax definition may look as follows:

```kotlin
primitive class Integer 

feature


primitive class String

feature
```

The following shows part of a BMM model in which a number of classes are classified as primitive (shown in light and dark grey).

.Primitive classes
image::{doc_name}/images/awb_primitive_types.png[id=awb_primitive_types, align="center", width="45%"]

Primitive classes are normal BMM classes, other than being marked primitive for convenience, and do not have different semantics.

## Class Invariants

A class defined within a model may include _invariants_, i.e. assertions relating to its state that hold true before and after all _public_ routine calls. Assertions are instances of the class `BMM_ASSERTION`, which is a tagged Boolean-valued Expression.

The following shows classes with invariants. 

```kotlin
class COMPOSITION

feature

invariant
    Is_archetype_root: is_archetype_root
    Content_valid: content /= Void implies not content.is_empty


class VERSIONED_COMPOSITION

feature

invariant
    Archetype_node_id_valid: all_versions.for_all (
        agent (v: VERSION) {
            v.archetype_node_id.is_equal (all_versions.first.archetype_node_id);
        }
    )

    Persistent_validity: all_versions.for_all (
        agent (v: VERSION) {            
            v.is_persistent = all_versions.first.data.is_persistent;
        }
    )
```

## Inheritance

Inheritance in BMM is a relation between a class and one or more types, rather than classes, as in many class-based formalisms. This is primarily to allow classes to be based on specific generic types, rather than just the 'open' type represented by the underlying classes. Multiple inheritance is permitted, with same-named features from different types being treated as clashes needing resolution. See <<inheritance_semantics>> for a detailed description.

## Model Theoretic Questions

The class meta-model as defined here entails certain choices that have consequences, including:

* All Enumeration types are based on literal values (i.e. not only names), which may be of any concrete type, including constructed types.

## Class Definitions



# Class Features

## Overview

Within the definition of each class in a BMM model are found the declarations of its _features_. _Variables_ are declared within routines. Features and variables are kinds of _formal elements_, i.e. _typed_ entities having a _signature_ (`BMM_FORMAL_ELEMENT`). This section describes class features, their parts, and their semantics.

### Feature Taxonomy

_Features_ are understood in BMM as typed entities referenceable within a module context. Class features consist of the formal sub-parts of a class, namely:

* _routines_: _procedures_ and _functions_;
* _properties_: mutable static definitions, described in detail in previous sections;
* _constants_: immutable static values.

The taxonomy of feature declarations is shown below in the simplified view of the BMM feature meta-model.

.Feature taxonomy
image::UML/diagrams/LANG-bmm3.core.feature-taxonomy.svg[id=feature-taxonomy, align="center"]

### Class Model

The full feature meta-model is shown below.

.`base.bmm.core.feature` package
image::UML/diagrams/LANG-bmm3.core.feature.svg[id=core_feature, align="center"]

### Feature Groups and Visibility

Features are arranged within a class in _feature groups_, each represented by an instance of a meta-type `BMM_FEATURE_GROUP`, shown in the following UML view.

.Feature Groups
image::UML/diagrams/LANG-bmm3.core.feature-group.svg[id=core_feature_group, align="center"]

By default there is at least one feature group called `"feature"`. Feature groups may be given any name, and are usually used to group features on the basis of things like:

* meta-type, e.g. a group called `"rules"` limited to publicly visible functions only;
* logical feature type, e.g. commands, queries, factory methods etc.

The primary purpose of feature groups is to represent specific meta-data that naturally applies to more than one feature in general, and is thus convenient to represent on a logical container rather than repeat individually. Feature group meta-data is recorded in the `_properties_` attribute. A feature group may also set default visibility for all features in the group.

Selective _visibility_ of features to external clients is expressed in the attributes `BMM_FEATURE_GROUP._visibility_` with potential overrides achieved using `BMM_FEATURE._visibility_`, i.e. at an individual feature level. Visibility is defined using sub-types of the abstract meta-class `BMM_VISIBILITY`.

### Differential and Flat Form

In modelling or programming terms, the features defined on a particular class within a model constitute the features it _introduces with respect to its inheritance parent(s)_. We can think of this list of features as the _differential_ set. A 'top-level' class with no declared inheritance ancestor is considered to inherit by default from the `Any` class, and its feature set is relationally differential to the top class.

In contrast, the _effective_ set of features for an instance at runtime is the result of evaluating these lists of features down the inheritance hierarchy to obtain the _flat_ set of features. The features _properties_ and _flat_properties_ defined on `BMM_CLASS` provide access to these two lists for any class.

### Signatures

All features are formal computational entities, and therefore have formal signatures (described in <<Signature Meta-type>>), represented by `BMM_FORMAL_ELEMENT._signature_`. A standard taxonomy of feature signature types is illustrated below, in which properties have signatures with no arguments (this is also true for argument-less functions), and procedures have the special built-in Status result type (`BMM_STATUS_TYPE`), following the meta-model of various functional languages, e.g. Haskell (in which procedure invocations return the special 'unit' type).

.Signature taxonomy
image::{doc_name}/diagrams/signature_taxonomy.svg[id=signature_taxonomy, align="center", width="40%"]

### Synthesis due to Generic Parameter Substitution

Due to the possibility of generating concrete types via substitution of concrete generic parameters for formal parameters of generic classes, new concrete types of features may routinely result anywhere in a fully computed in-memory BMM model. BMM allows such features to be synthesised with their resulting concrete types rather than their 'source-defined' open parameter types, and provides the Boolean flag `_is_synthesised_generic_` on `BMM_FEATURE` to mark any such synthesised feature. An example of the use of this is described below in <<_generic_inheritance>>.

## Properties

Properties are features whose values are stored rather than computed on each reference, and are represented by the meta-type `BMM_INSTANTIABLE_FEATURE`. They are distinguished from routines by having no arguments (signature of degree zero).

### Static Properties

Static properties are properties whose values are pre-defined by some means, and read-only during execution (`_is_nullable_` is False).

#### Constants

Constant class features (meta-type `BMM_CONSTANT`) correspond to classic constants in most computer languages, and are defined with a literal value.

The following abstract syntax illustrates how constants may be defined in a BMM model.

```kotlin
class BASIC_DEFINITIONS

feature
    constant CR: Character = '\015';
    constant LF: Character = '\012';

    constant SafeSpeed: Interval<Quantity> = |0.0 km/h .. 60.0 km/h|;
```

#### Singletons

The other kind of static property is computed once during execution (meta-type `BMM_SINGLETON`) via an argumentless function-body. Like a value-based constant, it has the same value for all instances of the containing type, including descendant and generically derived types.

The following illustrates how singletons may be defined in a BMM model.

```kotlin
feature
    singleton criticalPressure: ProxyVar<Quantity>
        Result := {ProxyVar<Quantity>}({Quantity}(0.0, "kPa"), {Quantity}(150.0, "kPa"));
```

### Writable Properties

Writable class properties are defined via the meta-class `BMM_PROPERTY`, and its subtypes which distinguish _unitary properties_ (single-valued attributes in a class) from _container properties_ (multiply-valued attributes).

The `BMM_PROPERTY` meta-type defines semantics common to all properties, including `_is_composition_`, which indicates whether the property reference instantiates a part-of relationship or an association.

#### Unitary versus Container Properties

Single-valued properties in a BMM model are instances of the type `BMM_UNITARY_PROPERTY`, and have as their `_type_` the meta-type `BMM_UNITARY_TYPE`. Container properties are instances of the meta-type `BMM_CONTAINER_PROPERTY`, which adds the attribute `_cardinality_`, enabling the possible number of container elements to be constrained (this corresponds to the multiplicities used at the end of UML associations). The meta-type `BMM_INDEXED_CONTAINER_PROPERTY` adds the attribute `_index_type_`, enabling representation of indexed concrete container types such as `Hash<K,V>` etc.

A typical example of properties of class is shown below, in which the flattened property view of a class `OBSERVATION` includes the inherited properties `_other_participations_` and `_links_` properties exemplifying the container property meta-type:

.BMM class - properties view
image::{doc_name}/images/awb_class_properties.png[id=awb_class_properties, align="center", width="50%"]

The following illustrates how various kinds of properties may appear in a BMM model. The first two properties are associations, used to represent references to shared objects (including singletons), while the remainder are normal compositional sub-parts, i.e. owned sub-instances that will cease to exist when the parent object is destroyed. All of the properties are single-valued, other than `other_participations`, which is defined as a container property with cardinality `[\*]` (i.e. `0..*`) and 'set' semantics.

```kotlin
abstract class ENTRY extend CARE_ENTRY

feature -- Locale
    association property language: CODE_PHRASE <<"iso::iso_639-2">> [0..1];
    association property encoding: CODE_PHRASE <<"iana::character-sets">> [0..1];

feature -- Access
    composition property protocol: ITEM_STRUCTURE[1];
    composition property guideline_id: OBJECT_REF[0..1];
    composition property subject: PARTY_PROXY[0..1];
    composition property other_participations: PARTICIPATION[*]{set};
```

### Semantic Level

Properties also include two other Boolean meta-data items, `_is_im_runtime_` and `_is_im_infrastructure_`, which can be used to classify property values in a model according to a 'semantic level', which roughly corresponds to the continuum from domain-specific to infrastructure. These may be individually set, or both may be False. The three meaningful value settings are as follows:

* _both False_: the value of the property is considered to be design-time constrainable;
* _is IM runtime_: True if the property value is only knowable at runtime, as is typically the case for identifiers, dates etc;
* _is infrastructure_: True if the property is not a user- or business-oriented property, but something required by software design, e.g instance identifier, meta-data etc.

The above screenshot also includes properties have different settings of the `_is_im_runtime_` and `_is_im_infrastructure_` meta-data flags: property names in black are neither; those in grey are IM runtime (`_guideline_id_`, `_workflow_id_`), and those in light grey are infrastructure properties (`_language_`, `_encoding_`, `_uid_`, etc).

## Functions and Procedures

Functions and procedures are kinds of _routine_, which are computational features of a class. The classes `BMM_FUNCTION`, `BMM_PROCEDURE` and `BMM_ROUTINE` respectively provide the meta-model for _definitions_ of the two types of routine.

The formal parameter definitions of both kinds of routines are represented by an ordered list of instances of the meta-class `BMM_PARAMETER`, which is defined as a kind of _variable_. A formal parameter may optionally have the read/write direction defined, which indicates whether the variable contains an input value, should only be written to, or both, i.e. read then written to. The `_is_nullable_` meta-attribute inherited from `BMM_FEATURE` indicates whether each parameter is mandatory or not.

An additional feature of the meta-model for functions is the notion of _operator_, which supports the representation of a function call in a formal expression as an operator symbol with one or two operands, in the typical form found in programming languages and first order logics. The BMM approach considers an operator as an optional addition to any function of `_arity_` 1 or 2 that may reasonably be represented in an abstract syntax using operator syntax. Operators thus support the use of expressions like `weight > 90` to mean `weight.gt (90)`, where `weight` is of type `Real`, and the function `gt(other: Real)` is defined.

Any routine may have pre- and/or post-conditions defined for it, represented in BMM by `BMM_ASSERTIONs` populating the `_pre_conditions_` and `_post_conditions_` attributes of `BMM_ROUINE`. An Assertion is a [tagged Boolean Expression](#_bmm_assertion_class).

The following abstract syntax illustrates the various elements of function definitions.

```kotlin
abstract class DV_AMOUNT
    inherit
        DV_QUANTIFIED

feature -- Arithmetic Operations

    function equal (other: DV_AMOUNT[1]): Boolean[1] 
        alias {infix '='};

    function less_than (other: DV_AMOUNT[1]): Boolean[1] 
        alias {infix '<'};

feature -- Arithmetic Operations

    function add (other: DV_AMOUNT[1]): DV_AMOUNT[1] 
        alias {infix '+'};

    function subtract (other: DV_AMOUNT[1]): DV_AMOUNT[1] 
        alias {infix '-'};

    function multiply (val: Real[1]): DV_AMOUNT[1] 
        alias {infix '*'};

    function divide (val: Real[1]): DV_AMOUNT[1] 
        alias {infix '/', infix '÷'};
```

### Pre- and Post-conditions

All BMM routine definitions may include pre- and/or post-conditions, with the semantics of Djikstra's weakest pre-condition logic (citenp:[Djikstra_DOP_1976]), Object-Z (citenp:[Object_Z]) and the Eiffel language (citenp:[Meyer_OOSC2]).

The essential semantics are as follows:

* _pre-conditions_ specify truth conditions on public object state and/or parameters that must hold for the routine to execute correctly;
** if a pre-condition is not met at the moment of routine call, the client (caller) is at fault;
* _post-conditions_ specify truth conditions on public object state and/or result (in the case of functions) that will hold at the end of routine execution;
** if a post-condition is not met at the moment of routine completion, the routine is at fault, i.e. contains bugs.

The use of pre- and post-conditions is also known as _design by contract (DbC)_, a term introduced by Meyer, and is widely used in general IT, particularly in specification languages such as {omg_idl}[OMG Interface Definition Language (IDL)^].

The following shows how a routine contract may be specified in an abstract syntax.

```kotlin
class I_EHR_SERVICE

feature -- Creation

    create_ehr_with_id (
        an_ehr_id: UUID[1];
        an_ehr_status: EHR_STATUS[0..1]
    ): UUID[1]
        pre_condition
            No_duplicate: not has_ehr (an_ehr_id)
        post_condition
            Has_ehr: has_ehr (Result)
```

### Creators and Converters

In common with may OOPLs, BMM classes may specify _creators_, i.e. instance-creating procedures, known as 'constructors' in some OOPLs. These are just a subset of all procedures known in `BMM_CLASS._procedures_` that when executed will satisfy the class invariants. A further subset of the creators are single-argument _converters_ which can initialise a new instance from an instance of another type. Converter routines are typically used to support type conversion in expressions, e.g. `String` to `Date` etc. These two subsets are formally defined as the `_creators_` and `_converters_` reference lists of procedures on `BMM_CLASS`, as shown in the following UML view.

.Class creators and converters
image::UML/diagrams/LANG-bmm3.core.class-creators.svg[id=core_class_creators, align="center"]

Creators and converters might be distinguished among other procedures in an abstract syntax as follows.

```kotlin
class Date

inherit
    Temporal
    
convert
    create_from_string

feature -- Creators

    procedure create_from_string (a_date_str: String[1])

    procedure create (a_day, a_month, a_year: Integer[1])

feature -- Modification

    procedure set_day (a_day: Integer[1])
```

### Routine Body

BMM supports the definition of statements, i.e. implementation within a `ROUTINE` as well as 'external' routines, which are represented by an instance of the meta-class `BMM_ROUTINE_EXTERNAL`. These classes are shown in the following UML view.

.Routine body
image::UML/diagrams/LANG-bmm3.core.feature-routine.svg[id=core_feature_routine, align="center"]

The meta-model of statements is described in detail in <<_statements>>.

## Variables

At the finest level of detail of a model definition are what are typically thought of as _variables_ within a routine scope. These may be either writable (`BMM_WRITABLE_VARIABLE`) or read-only (`BMM_READONlY_VARIABLE`) variables.

Writable variables include _local variables_ (variables declared locally within a routine) and the special pre-defined variable `Result`, which is automatically available within any function. Read-only variables include _parameters_ (declared in the arguments part of a routine declaration), and the special variable `Self`, which represents the current instance.

## Model Theoretic Questions

The features meta-model as defined here entails certain choices that have consequences. One question is how to treat procedures. In a mathematical sense, procedures have no return type, and therefore should not be allowed within 'normal' expressions. However in a computational sense, a procedure call normally performs some state-changing action (for example, authenticating to a database), and it is potentially useful to obtain an execution status and use it in further logic. The choice made in BMM is to treat _procedures as typed entities_, with a result meta-type and concrete type of `Status` (represented by `BMM_STATUS_TYPE`). This is similar to the approach in various languages such as Haskell and {kotlin}[Kotlin^], which both have a 'unit' type for the same purpose. This approach allows procedures to fit within the typed framework without complicating the meta-model.

Procedure calls are prevented from appearing in expressions by the [expressions](#_expressions) part of the meta-model, and can only appear on their own (the usual case) or in an assignment statement in which a result status value may be obtained from the Status object. This value may then be used in normal expressions, e.g. a case statement.

## Class Definitions








# Literal Values

## Overview

With a typical formal model, there is a need for formal representation of literal values. This is needed to support constant declarations, 'default values' (a UML concept), enumeration literals and literal routine calls (see next section). In BMM, all such values have as their meta-type the type `BMM_LITERAL_VALUE<T>` or a descendant. The type hierarchy mostly mimicks parts of the `BMM_TYPE` meta-type hierarchy, allowing for literal values of any of the meta-types in that part of the model. The UML model is shown below.

.`base.bmm.core.literal_value` package - Literal Values
image::UML/diagrams/LANG-bmm3.core.literal_value.svg[id=core_literal_value, align="center"]

## General Model

When a BMM model is instantiated in its in-memory form, e.g. in a BMM modelling tool, any literal values in the model such as constant values (e.g. `Real Pi = 3.1415926`), default values (e.g. `Person.name: String = "(unknown)"`) etc are instances of 'two types':

* their declared types withing the model, e.g. `Real`, `String`, `Observation`;
* the meta-type `BMM_LITERAL_VALUE<T>` (or a matching descendant if there is one), which is instantiated to represent the value object within the model.

The value of any such instance is represented by the `_value_literal_` field within its `BMM_LITERAL_VALUE` object. This is assumed to carry a serialised form of the value expressed in a syntax known to the model processing environment within which the BMM model is being used. This may be a programming language syntax, JSON, or any other serialisable format, and is specified by `BMM_LITERAL_VALUE._syntax_`.

## Container Literals

Literals representing Lists or Sets of values of objects of other types have as their BMM meta-type `BMM_CONTAINER_VALUE<T>`. For example, if the serialised value `["Feyerabend", "Lakatos", "Popper"]` (which happens to be a JSON Array of Strings) were parsed as a `List<String>` instance, its meta-type would be a `BMM_CONTAINER_VALUE` instance whose `_value_literal_` was the same string, assuming JSON were used as the syntax, and whose `_type_` will be `BMM_CONTAINER_TYPE`. Similarly a syntax that supported literal Sets using braces, e.g. `{"Feyerabend", "Lakatos", "Popper"}` may be parsed to a `Set<String>` instance, with the same meta-type as for the List.

In a similar way, a Hash table (aka 'map', 'dictionary' etc) with a formal type of `Hash<K, V>` has as its meta-type `BMM_INDEXED_CONTAINER_VALUE`.

## Literal Tuples

Literal tuples may be expressed in BMM, but are not instances of `BMM_LITERAL_VALUE`; instead they are instances (at the meta level) of `EL_TUPLE`, an expression-related meta-type. This is a consequence of the fact that `Tuple` is considered a BMM built-in meta-type rather than a model-provided type, and also that a Tuple instance may contain items of any meta-type, not just literal values. Tuple instances are used in BMM expressions and described in <<_tuples>>.

## Type Extensions

If it were desired to create a full set of 'native' types for BMM, in the way supplied for UML in the UML Standard Profile, specific descendants would be added to the meta-type classes `BMM_SIMPLE_TYPE` and `BMM_GENERIC_TYPE`, as well as `BMM_LITERAL_VALUE`, which would allow such instances to be directly representable in the internal BMM type system. This would still need to be ultimately mapped to the types actually available in any language in which BMM is implemented.

## Class Definitions






# Expressions

## Overview

Expressions in BMM are used to specify class invariants, routine pre- and post-conditions, and may be used more generally in other contexts requiring expressions. They are defined by a set of classes prefixed by 'EL', indicating 'expression language'. The BMM expression meta-model is based on the following taxonomy of expression entities:

.Expression Taxonomy
image::UML/diagrams/LANG-bmm3.expression-type_hierarchy.svg[id=bmm_expression_type_hierarchy, align="center"]

The meta-types defined in this part of the BMM model may be understood as the types of entities in an abstract syntax tree (AST) generated from expression parsing. Conversely, one or more expression syntaxes may be parsed into a tree based on the model described here. Note however, that whatever the variation in surface syntax, all such syntaxes parsed this way ultimately have the semantics defined by the BMM EL meta-model. This is true even for expressions written in a syntax whose published semantics are in fact different, e.g. a well-known programming language.

The UML model of the BMM `expression` package, consisting of mostly direct equivalents of the taxonomy classes above, is shown below. 

.`bmm.expression` Package
image::UML/diagrams/LANG-bmm3.expression.svg[id=bmm_expression, align="center"]

`EL` classes are descendants of the class `EL_EXPRESSION`, which is characterised by the feature `_eval_type()_`. This is the BMM meta-type of the _result type_ of the expression entity when used in an expression; for literals, this is the inferred type; for object references (including function calls), this is the same as the declared type, and for agents it is the meta-type `BMM_SIGNATURE`.

Most `EL_EXPRESSIONs` are either value generating constructs (`EL_VALUE_GENERATOR`) or operator expressions. The special sub-type `E_TUPLE` represents tuple objects which are created on the fly by inline expressions of the form `[expr, expr, ...]`.

## Terminal Entities

Terminal entities are atomic with respect to operator expressions, and are either _simple_ entities of familiar kinds (function calls, variable references etc) or else complex logic structures that when evaluated generate a value.

### Simple Terminal Entities

The simple terminal meta-types in EL are as follows:

* _literal values_: inline-generated values created without reference to a model instance, but which must be instances of types defined by the model (`EL_LITERAL`);
* _value generators_ (`EL_VALUE_GENERATOR`) based on formal model elements that may be called to (potentially) obtain an instance at runtime;
* _predicates_: Boolean-generating expression elements formed by predicates applied to any of the other value-generating expression elements.

#### Literals

A literal value may appear as a separate entity within an operator expression, as well as a functional call or agent parameter. The literal values that may be used are either instances of the {openehr_foundation_types}[openEHR Foundation Types^] or a complex object instance in a structured serial format (such as JSON, a JSON derivative, {openehr_odin}#_leaf_data[ODIN format^] etc), specified by `BMM_LITERAL_VALUE.syntax`.

#### Value Generators

Value generators are categorised as follows:

* _feature references_: (`EL_FEATURE_REF`)
** _references to instantiable features_: symbolic references to properties and constants (`EL_PROPERTY_REF`, `EL_CONSTANT_REF`);
** _calls to functions_: appropriately constructed calls to functions of the types that define instances (`EL_FUNCTION_CALL`);
** _generation of agents_: a special kind of reference to any routine of a model type that generates a _delayed routine call object_ (`EL_AGENT`);
* _variable reference_: references to variables within the scope of the current routine, including local variables, parameters, the current object (`Self`), or the current function result (`Result`) (`EL_VARIABLE`);
* _a type reference_: (`EL_TYPE_REF`) a reference representing a type object assumed to be available at runtime, on which argumentless function calls and constants may be accessed.

The arguments of function calls and delayed routine calls may be complex expressions, but will eventually resolved to literal values and instance references. Consequently, the value generated by any expression is ultimately founded upon literal values and instance references.

To be valid, any model-based feature reference must have a scoping object (represented via the attribute `_scope_` in `EL_SCOPED`), which is one of:

* the current object - implied;
* another object, which may be designated via:
** a specified scoping object, achieved through 'dot-notation' in most languages;
** a type reference.

##### Feature References

In BMM, a _feature reference_ is any symbolic reference to a class feature that resolves to an object at evaluation time. This includes all referenceable entities within classes except procedures, which have no return value. Concretely, a feature reference takes the form of one of:

* a property name, e.g. `_name_`;
* a constant name, e.g. `_pi_`;
* a variable or parameter name, e.g. `_a_name_`, `_call_name_`;
* a function call.

Function calls are described in detail in the following section.

##### Type Reference

A special meta-type, `EL_TYPE_REF` is provided to refer to a type as an object. This is exclusively used as a convenient way (common in many programming languages) of accessing _class features_ that do not depend on instance properties (i.e. 'constant', 'enum', and 'static' members in C-based languages) without having to explicitly create an instance. As an expression, a type reference will normally only appear as a qualifier of a feature reference, using syntax such as `{TypeName}._feature_`, or with arguments, `{TypeName}._function (args...)_`.

A class feature is defined as one that is:

* a constant;
* an enumeration literal;
* a function that does not reference any class property or make any call that does, in its `_body_`, `_pre_conditions_` or `_post_conditions_`.

The last category typically includes 'external' functions that are wrappers for calls to the operating system or other external resource that maintains its own state independently.

Since a type reference can be made without instantiation, it may be made to an abstract class as well as a concrete one. This facilitates the use of so-called 'utility' classes containing groups of useful functions e.g. for handling specific kinds of strings.

Examples of type references as qualifiers of class features include the following:

* `{Env}._current_time_` to access the class function `_current_time_` defined on the class (or interface) `Env`;
* `{Colours}.red`, to access an enumeration literal;
* `{Version_utils}.version_higher ("1.5.40", "11.5.4")`.

A type reference may also be used on its own, such as in the following type test, which is the EL equivalent of programming language operators like `type_of()`.

* `admission_dates.type = {Interval<Iso8601_date_time>}`.

##### Agents

An agent is the BMM term for a delayed routine call, and has the meta-type `EL_AGENT`, which in turn has as its formal evaluation type (`_eval_type_`) is the meta-type `BMM_SIGNATURE`. It usually appears as a standalone expression, or else a parameter within another agent or function call. Agents are described in detail in the following section.

#### Variables

Symbolic variables (meta-type `EL_VARIABLE`) are one of the following:

* variables declared locally in a routine  (`EL_VARIABLE.definition` = `BMM_LOCAL`);
* named arguments of a routine (`EL_VARIABLE.definition` = `BMM_PARAMETER`);
* a special variable called 'Result' representing the result object of a function (`EL_VARIABLE.definition` = `BMM_RESULT`);
* a special variable (often called 'this' or 'self' in object-oriented programming languages) to refer to the object acting as the context for enclosed statements (`EL_VARIABLE.definition` = `BMM_SELF`).

#### Predicates

Predicates in BMM are Boolean-returning terminal expressions taking one feature reference operand, and are represented by the meta-type `EL_PREDICATE`. Predicates conceptually apply to data instance structures and may be understood as queries on data. Any number of specific predicates might be added as extensions via inheritance. In particular, Xpath-style predicates could be supported by addition of meta-types descending from `EL_PREDICATE`. The following UML shows the predicate meta-types.

.Predicates
image::UML/diagrams/LANG-bmm3.expression-predicate.svg[id=bmm_expression_predicate, align="center"]

The following predicates are pre-defined.

##### Attached (x)

The `attached` predicate is used to test for an instance reference (including a function call result) being `Void`. It may be used in expressions such as the following class invariant.

```kotlin
class SmartRef

feature

    property url: Url;
    property value: Base64String;
    
    invariant
        Validity: attached(url) or attached(value)
```

##### Defined (x)

The `defined` predicate is used to test whether an instance that is mapped to an external data access method exists in the data context (regardless of its value there).

### Decision Tables

The BMM `expression` package contains the meta-class `EL_DECISION_TABLE` that defines an abstract _decision table_ construct, consisting of an ordered set of `_items_`, each of type `EL_DECISION_BRANCH`, and having a `_result_` of any expression type (including another decision table). Two concrete subtypes of each of these abstract meta-types are used to represent two common kinds of decision structure found in procedural and most object-oriented programming languages: 

* an if/then/elseif/else condition chain (meta-classes `EL_CONDITION_CHAIN` and `EL_CONDITIONAL_EXPRESSION`); and
* a case statement style table (meta-classes `EL_CASE_TABLE` and `EL_CASE`), whose conditions are value intervals against which the table's `_input_` value expression is evaluated to determine the result.

The `_else_` branch will be used to provide the result expression in the case that all other branches fail, guaranteeing a result. 

`EL_DECISION_TABLE` and its descendants are also kind of expression, enabling them to be used as value-returning entities in certain other expression contexts, including inside other decision tables.

The following UML illustrates. 

.Decision Tables
image::UML/diagrams/LANG-bmm3.expression-decision_table.svg[id=bmm_expression_decision_table, align="center"]

The logic of a `EL_CONDITION_CHAIN` is the same as an if/then/elseif/else chain in procedural programming, except that instead of assignment statements on each branch, pure result expressions are used. This enables a more sophisticated syntactic rendering, resembling a table, such as the following:

```kotlin
    molecular_subtype: Terminology_term
        Result := choice in
            =======================================================
            er_positive and 
            her2_negative and 
            not ki67.in_range (#high):    #luminal_A,
            -------------------------------------------------------
            er_positive and 
            her2_negative and 
            ki67.in_range (#high):        #luminal_B_HER2_negative,
            -------------------------------------------------------
            er_positive and 
            her2_positive:                #luminal_B_HER2_positive,
            -------------------------------------------------------
            er_negative and 
            pr_negative and 
            her2_positive and 
            ki67.in_range (#high):        #HER2,
            -------------------------------------------------------
            er_negative and
            pr_negative and 
            her2_negative and 
            ki67.in_range (#high):        #triple_negative,
            -------------------------------------------------------
            *:                            #none
            =======================================================
        ;
```

The above is a function that computes the molecular subtype of breast cancer using a decision table whose branches are based on a number of input variables that appear in expressions down the left-hand side and which returns a `Terminology_code` instance (the notation `#identifier` represents a literal `Terminology_code` instance).

An example of `EL_CASE_TABLE` is shown below. Here, two case tables are used, with each generating a numeric result based on the values of the `platelets` and `gfr` variables respectively.

```kotlin
    cyclophosphamide_dose: Quantity
        Result := cyclophosphamide_dose_per_m2 * BSA.bsa_m2
            * case platelets.range in 
                ===================
                #normal:      1,
                #low:         0.75
                ===================
            * case gfr.range in
                ===================
                #normal:      1,
                #low:         0.75,
                #very_low:    0.5
                ===================
            ;
```

## Operator Expressions

BMM contains meta-types representing operators, but assumes that all operators are surface aliases for functions defined on some class. For this reason, an occurrence of an operator within an expression, represented an instance of a descendant of `EL_OPERATOR`, contains the attribute `_definition_` to refer to the corresponding function definition. This has to be inferred from the types of its operands. Consequently, 'operator expressions' as commonly understood are simply function calls (often nested) in BMM. The following UML shows the relevant meta-types.

.Operator meta-types
image::UML/diagrams/LANG-bmm3.expression-operator.svg[id=bmm_expression_operator, align="center"]

The following example illustrates the general meta-model of expressions, using a typical use of expression, the class invariant.

```kotlin
class Account

feature
    balance: Decimal
    overdraft_limit: Decimal

invariant
    balance + overdraft_limit > 0
```

The expression `balance + overdraft_limit > 0` makes use of two operators `+` and `>`, which are really functions defined on the type `Decimal`, as follows.

```kotlin
class Decimal

feature
    greater_than (other: Decimal): Boolean
        alias '>'

    addition: (other: Decimal): Decimal
        alias '+'
```

A parser processing this expression would produce the result shown below, assuming that the BMM model containing these classes had already been instantiated.

.Instantiated Operator Expression
image::{doc_name}/diagrams/bmm_expression_property_ref.svg[id=bmm_expression_property_ref, align="center"]

Below, we consider a number of examples illustrating expressions containing the various kinds of terminal reference, based on the following assumed declarations.

```kotlin
    feature -- Definitions
    
        Fast_resting_heart_rate: Real = 100;
        Atrial_fibrillation_heart_rate: Real = 120;
        Erratic: Terminology_code = {
            "terminology_id": "snomed_ct",
            "code_string": "286761003"
        }
        Blood_pressure_units: String = "mm[Hg]";
    
    feature -- Accessors
    
        heart_rate: Real;
        heart_rhythm: Terminology_code;    
        bp_samples: List<Quantity>;
        patient: Patient;
```

The first example is a comparison of a property value to a value, where the `>=` operator maps to the function `Real._greater_than_or_equal_()`

```kotlin
    heart_rate >= 80
```

The following shows the comparison of a property value with a constant, where the `>=` operator maps to the function `Real._greater_than_or_equal_()`

```kotlin
    heart_rate >= Fast_resting_heart_rate
```

The following is a logical condition, where the `=` operator maps to a function such as `Terminology_code._equal_()`; `and` maps to `Boolean._and_()`; and `>=` maps to `Real._greater_than_or_equal_()`.

```kotlin
    heart_rhythm = Erratic and heart_rate >= Atrial_fibrillation_heart_rate
```

The following is the same logical condition, but with the use of object scope specified with 'dot notation', here `'patient.'`.

```kotlin
    patient.heart_rhythm = Erratic and patient.heart_rate >= Atrial_fibrillation_heart_rate
```

The following shows a function call whose argument is an expression.

```kotlin
    date_of_birth.earlier ({Env}.current_date - P10Y)
```

The following shows the use of an inline agent as an argument to the function `List._for_all_()`.

```kotlin
    bp_samples.for_all (
        agent (a_quantity: Quantity) {
            a_quantity.units.is_equal (Blood_pressure_units);
        }
    );
```

## Tuples

Although rarely useful in class definitions, a Tuple of any degree may be formed from any combination of other EL expressions and used on its own as an expression terminal element. The main use for this construct is to express a literal tuple, i.e. one whose constituents consist only of proper literal values.

For more general uses of BMM Expressions, tuple instances are the basis of representing ad hoc query results which have a formal type such as `List<[T~a~, T~b~, T~c~]>`, where `[T~a~, T~b~, T~c~]` represents a tuple of three types.

## Usage in BMM Models

Expressions as used in BMM models to express class invariants and routine pre- and post-conditions are always in the form of an `BMM_ASSERTION`, i.e. a tagged Boolean-returning `EL_EXPRESSION`.

### Simple Assertions

Simple assertions may be formed from common operators and operands, including the usual logical arithmetic and comparison operators, as well as any operators relating to specific data types. Normally the top-level operator in the Expression graph is a logical or relational operator. Since all operators are mapped to functions defined on types, there are no 'floating' or 'built-in' operators as such.

### Existential and Universal Quantifier Invariants

A common kind of expression used in class invariants operates over collections and uses the existential and universal quantifier operators, i.e. ∃ and ∀, from predicate logic. A typical expression to use within a class invariant is shown below in an abstract syntax.

```kotlin
class PersonName
property items: String[1..*];

invariant
    ∀ nameItem: items | not nameItem.isEmpty()
```

A different syntax might express it as follows.

```kotlin
    invariant
        for nameItem in items all 
            not nameItem.isEmpty() 
        end
```

A similar invariant, this time using ∃, is shown below.

```kotlin
    invariant
        for nameItem in items 
            ∃ not nameItem.isEmpty()
```

Regardless of the surface syntax, expressions such as the above map to functions such as `_for_all_` and `there_exists` defined on relevant linear container types. These functions have the following signatures in which the 'test' expression appears as a Function agent type.

```kotlin
class Container<T>

feature

    for_all (test: Function<[T], Boolean>): Boolean;
            -- True if for every v in container, test (v) is True    

    there_exists (test: Function<[T], Boolean>): Boolean;
            -- True if there is any v in container for which test (v) is True
```

## Class Definitions

















# Functional Elements

## Overview

BMM provides support for representing functional entities, often known as {wikipedia_lambda_calculus}[lambdas^]. The two key functional entities are known in the calculus as a _lambda term_ and an _application_. The first is more commonly understood by programmers as a _delayed routine call_, here denoted by the term _agent_. The latter is what programmers understand as a 'call', i.e. an application of a lambda term.

An agent is formed by reference to a function or procedure in an expression context, potentially with provision of some or all arguments. This creates an entity whose type is an instance of the meta-type `BMM_SIGNATURE`. There are three variations as follows:

* _no arguments supplied_: this is just a reference to a function or procedure by name, and is typically used to pass it as an argument to some other routine;
* _some arguments supplied_: this generates a new delayed function or procedure call whose formal signature is the projection of the remaining open arguments with respect to the original signature;
* _all arguments supplied_: this generates a new fully closed delayed call that may be invoked.

A call is thus an invocation of a _closed agent_. The _evaluation type_ of a function call is the result type of the original function definition, thus its meta-type is just `BMM_TYPE`. A procedure call has no evaluation type.

Both calls and agents are special kinds of _references_ to their original routines, and both can appear within an expression context, including as arguments passed to routine invocations. The following UML view of the `bmm.expression` package illustrates these details.

.`bmm.expression` package - Functional Elements
image::UML/diagrams/LANG-bmm3.expression-functional.svg[id=bmm_expression_functional, align="center"]

## Agents

In the model the three classes `EL_AGENT`, `EL_FUNCTION_AGENT`, and `EL_PROCEDURE_AGENT` (centre) define respectively, Agent and its Function and Procedure forms. An Agent is understood as one kind of terminal expression, since it is concretely a _reference_ that generates a value, in this case, to a routine that generates a delayed call object. It potentially has `_closed_args_`, in the form of an `EL_TUPLE` which is a meta-type for tuple instances, which instantiate an instance `BMM_TUPLE_TYPE` (such as `[String, Integer]`). The items of the tuple are each in the form of an `EL_TUPLE_ITEM` consisting of the argument name (optional) and an `_item_`, which is an `EL_EXPRESSION`, having an `_eval_type_` of `BMM_TYPE`. By this means, the actual arguments to a routine call may be any expression, including operators, and (as shown), terminal expressions. This includes other agent expressions, and also function calls (but not procedure calls, since they are not value-generating entities).

An example of a delayed function call in syntax form is `nodeCount (struct=?, depth=3)` (the exact syntax will vary according to programming language). Here, the `_struct_` argument is left open, while the `_depth_` argument is closed with the supplied value `3`. This expression generates an agent whose signature is `[StructType]:Integer` (assuming the concrete type of the `struct` argument is `StructType`). This capability is known as {wikipedia_currying}[function currying^] and is the basis for enabling delayed routine calls to have their arguments progressively filled before final execution, each time generating a new agent with a reduced signature.

## Calls

On the left of the UML diagram is the meta-class `EL_FUNCTION_CALL`, which represents a call to a function Agent, and which is also an `EL_SIMPLE`. For such a call to be possible, all arguments must be supplied (which may be none, in the case of a parameterless function).

An example of a Function Call is `_calculateAge_ ('1982-03-22', '2019-06-01')`, which calculates a person's age from his date of birth and a given date. In normal programming languages, any of the parameters may be any referenceable value-returning entity, i.e. any in-scope variable, other function call, or a valid operator expression, e.g. `_calculateAge_ ('1982-03-22', _today_())`, where `_today_()` is a function returning the date of today.

Such calls are direct equivalents for expressions using basic mathematical operators and functions, on the usual basis that any operator (such as 'plus', i.e. `+`) is formally defined as a function such as `add (arg1, arg2: Numeric): Numeric`.

The instance structure for a typical expression such as the Body Mass Index (BMI), i.e. `weight / height^2`, is shown below.

.Function call example - Body Mass index (BMI)
image::UML/diagrams/LANG-bmm3-nested_call.svg[id=bmm_nested_call, align="center"]


# Statements

## Overview

BMM provides meta-model elements for defining the _body_ of a routine, consisting of _statements_. This facility is not needed for achieving the original purpose of BMM, i.e. a computable in-memory representation of a model at the interface level (classes, types and signatures), rather it provides a basis for representing program logic, such as function definitions. 

BMM statements are formalised using the classes `BMM_STATEMENT_ITEM`, `BMM_STATEMENT_BLOCK` and `BMM_STATEMENT` and various descendant types, as shown in the UML view below.

.Features for routine definition
image::UML/diagrams/LANG-bmm3.statement.svg[id=LANG-statement, align="center"]

The use of the three-class hierarchy pattern allows a Routine `_body_` to be a simple statement or a _block_, containing statements and/or more blocks. The class `BMM_STATEMENT` is abstract, allowing specific statement meta-models to be developed whose 'statement' meta-types inherit from this class. A number of common types are included by default, and are described below.

This facility is primarily provided to support the definition of higher-level languages by embedding them in the outer BMM meta-model.

## Variable Declaration

Writable variables are declared using a variable declaration (`BMM_DECLARATION`). This may be understood as the creation of an instance of the relevant meta-type, i.e. of `EL_WRITABLE_VARIABLE`, that will represent the variable for all subsequent uses in the program text.

## Assignment

A BMM assignment is the same concept as found in most frame-based programming languages, and provides a meta-model entity to represent a writable target (variable or property) being assigned to from a source, which is any expression of the same evaluation type. Type checking is thus based on a comparison of `_definition.type_` of the target and `_eval_type_()` of the source.

The following example shows a simple assignment in the definition of the function `_position_`.

```typescript
class Simple_bank_account

feature -- Definitions

    overdraft_limit: Decimal = 250;

feature -- State

    balance: Decimal;

feature -- Interface

    position: Decimal {
        Result := balance + overdraft_limit
    }

invariant
    Solvent: position >= 0.0
```

The BMM meta-model for this statement is shown below.

.Assignment to function Result
image::{doc_name}/diagrams/bmm_assignment.svg[id=bmm_assignment, align="center"]

## Procedure Call

A procedure call is represented in BMM by the meta-type `BMM_PROCEDURE_CALL`, which refers to an instance of `EL_PROCEDURE_AGENT`, the same way that a function call is represented in terms of an `EL_FUNCTION_AGENT`. The effect of a procedure call is to cause an external action to be performed, such as display something on the screen, write to a database etc.

In the following example, the procedure `_put_()` is called from the `_deposit_()` and `_withdraw_()` functions in the class `Account_access`.

```typescript
class Simple_bank_account

feature -- Modification

    put (val: Decimal)
        precondition
            valid_amount: val + overdraft_limit >= 0.0
    {
        balance := balance + val
    }

class Account_access

feature -- Command

    deposit (v: Decimal; ac: Simple_bank_account)
        pre_condition
            valid_amount: v > 0.0
    {
        ac.put (v);
    }

    withdraw (v: Decimal; ac: Simple_bank_account)
        pre_condition
            valid_amount: ac.overdraft_limit - v >= 0.0
    {
        ac.put (-v);
    }

```

The BMM meta-model instance structure for the call is shown below.

.Procedure call
image::{doc_name}/diagrams/bmm_procedure_call.svg[id=bmm_procedure_call, align="center"]

## Action Tables

The BMM `statement` package includes the meta-classes `BMM_ACTION_TABLE` and `BMM_CONDITIONAL_ACTION`, which together provide a way of representing a decision table whose outputs are statements (rather than values, as in the case of the related Expression meta-classes `EL_DECISION_TABLE` and `EL_CONDITIONAL_EXPRESSION`). An action table corresponds closely to the standard constructs 'if/then/elseif' and the case statement.

The following example shows the logic of a BMM Action table meta-type, within a procedure that generates appropriate alerts or alarms based on patient vital signs, using the standard if/then/else constrol structure.

```typescript
    check_vital_signs
        if systolic_pressure.in_range ([critical_high])
            raise_alarm ([emergency])

        elseif systolic_pressure.in_range ([high]) and oxygen_sat.in_range([low])
            call_staff
        end
    end
```

In a functional style syntax that directly mirrors the Action table meta-model, this may be written as:

```typescript
    check_vital_signs
        ============================================================================
        systolic_pressure.in_range ([critical_high]):     raise_alarm ([emergency]),
        ----------------------------------------------------------------------------
        systolic_pressure.in_range ([high]) and 
        oxygen_sat.in_range([low]):                       call_staff
        ============================================================================
    end
```

## Assertions

The BMM `statement` model includes a statement meta-type to represent the notion of an _assertion_ as a statement, typically expressed in syntax such as `assert (<boolean expression>)`. This kind of statement is understood as an executable instruction to check that the condition is true, and if not, to generate an exception of the appropriate type, assuming exceptions are available.

## Class Definitions





# Model Semantics

This section describes various semantics that apply at a whole-of-model level rather than within single entities such as a class, type or property.

## Inheritance

### Simple Inheritance

The BMM supports single and multiple inheritance, although it does not distinguish between different types of inheritance relation as some programming languages do. Inheritance is formally defined to be between a class definition (an instance of `BMM_CLASS`) and a defined type, i.e. a `BMM_SIMPLE_TYPE` or `BMM_GENERIC_TYPE`. This is because the inheritance parents of a class may be any of:

* a simple class;
* a generic class;
* a _class type_, i.e. the effective class definition corresponding to an effective generic type, which has one or more formal parameters substituted.

The general case for all three is represented by the corresponding _type_, i.e., a simple type or generic type.

The evaluation of inheritance relations defined in a BMM model results in an acyclic graph such that ancestors and descendants can be visualised for any class. The following screen shot shows the ancestors view of a class `OBSERVATION`.

.BMM class - ancestors view
image::{doc_name}/images/awb_class_ancestors.png[id=awb_class_ancestors, align="center", width="45%"]

The next screenshot shows the descendants view of one of the ancestor classes of the same class.

.BMM class - descendants view
image::{doc_name}/images/awb_class_descendants.png[id=awb_class_descendants, align="center", width="45%"]

### Generic Inheritance

Inheritance between generic classes works in the same way as for simple classes, with the additional semantics of formal parameter inheritance, which are as follows:

* each unsubstituted formal parameter of the parent type must have a same-named counterpart in the formal parameters of the inheriting class;
* the formal parameters of the inheriting class may further constrain any of the ancestor type's formal parameters.

The following example shows the class `DV_INTERVAL<T:DV_ORDERED>` inheriting from `Interval<T:Ordered>`. Here the number of open generic parameters remains unchanged, while the type constraint `Ordered` is covariantly narrowed to `DV_ORDERED`, which inherits from the `Ordered` type.

.Generic inheritance, constraint-narrowing
image::{doc_name}/images/awb_generic_class.png[id=awb_generic_inheritance_constraint_narrowing, align="center", width="55%"]

The resulting types of `_lower_` and `_upper_` are now `T:DV_ORDERED` rather than `T:Ordered` from the parent. In the fully computed model shown above, these two properties are synthesised within `DV_INTERVAL<T>` with their new concrete types. Their BMM meta-type objects (type `BMM_UNITARY_PROPERTY`) will both have the meta-attribute `_is_synthesised_generic_` set to `True` and are marked with an asterisk within the property view to indicate this.

A simple class may also inherit from a closed generic type, with the parameters of the latter fixed to specific type(s), as shown in the following example.

.Generic inheritance, closed
image::{doc_name}/images/awb_generic_inheritance_closed.png[id=awb_generic_inheritance_closed, align="center", width="85%"]

In this case, The resulting type of `_event_` is `TIMER_EVENT` rather than `T:EVENT` from the parent. As in the previous example, this property has been synthesised new within `TIMER_WAIT`, with the meta-attribute `_is_synthesised_generic_` set `True` and is marked accordingly within the tool.

The general case is that any number of formal generic parameters may be substituted or left open down the inheritance lineage, as shown by the variant descendants of the class `GENERIC_PARENT<T:SUPPLIER, U:SUPPLIER>` in the following example.

.Generic inheritance, mixed open and closed
image::{doc_name}/images/awb_generic_inheritance_mixed.png[id=awb_generic_inheritance_mixed, align="center", width="90%"]

Generic substitution may be with other open, closed or partly-closed generic types. The following example illustrates the inheritance by `X_VERSIONED_COMPOSITION` of `X_VERSIONED_COMPOSITION<ORIGINAL_VERSION<COMPOSITION>>`.

.Generic inheritance, open parameter
image::{doc_name}/images/awb_generic_inheritance.png[id=awb_generic_inheritance, align="center", width="70%"]

### Multiple Inheritance

Multiple inheritance is typically used in the definition of classes that have a Liskov substitution inheritance relation as well as a re-use inheritance relation. The following shows a class `DV_INTERVAL<T>` multiply inheriting from `Interval<T>` and `DATA_VALUE`, where the latter is considered the substitutable type, and the former an interface re-use.

.Multiple inheritance
image::{doc_name}/images/awb_multiple_inheritance.png[id=awb_multiple_inheritance, align="center", width="45%"]

# BMM Extensions

## Overview

## General Extensions


## Feature Extensions





:sectnums!:
## References

bibliography::[]
