# Msg#6 - Archetypes for mathematicians? **Category:** [Technical (archive)](https://discourse.openehr.org/c/technical-archive/156) **Created:** 2006-04-10 17:52 UTC **Views:** 1 **Replies:** 1 **URL:** https://discourse.openehr.org/t/msg-6-archetypes-for-mathematicians/14161 --- ## Post #1 by @Bill_Walton > Forgive the cross\-post, but the topic of archetypes has come up > Hardhats, and once again, I find the language used to describe the > concept vague and \(at times\) mysterious\. If you'll forgive me for the > use of some mathematical jargon here, I'd like to revisit the concept > of abstracting measurements away from a particular choice of units\. A > familiar mathematical structure used to discuss the concept of distance > is the metric space, defined as follows: > > A metric space \(X, d\) consists of a set X and map d: X x X \-\-> R > satisfying > > 1\) d\(x, y\) >= 0 > 2\) d\(x, y\) = 0 if and only if x = y > 3\) d\(x, y\) = d\(y, x\) > 4\) d\(x, z\) <= d\(x, y\) \+ d\(y, z\) \(triangle inequality\) > > Now, there are many metrics, not all of them arrising from Euclidean > geometry, but certainly if X = R^2, the normal Euclidean metric > provides a metric that we want to think of as independent of any > particular scaling transformation\. In particular, if alpha > 0, then > > d2\(x, y\) = alpha \* d\(x, y\) > > is a perfectly good metric giving rise to a geometry that is > essentially the same\. In fact, a useful interpretation of the > difference between d and d2 is that each represents a different set of > units for the \*same\* metric space\. But note that we "cheated" by > introducing \*two\* metric spaces and then declared them to be the same, > only having different units of measurement\. > > Is there any other way to capture this sameness? Well, in truth, if you > change the function d, then you have defined an entrirely new metric > space, but the are not unrelated\! > > Given spaces \(X, d\) and \(Y, d\) we say a function f: X \-\-> Y is an > isometry if > > 1\) it is one to one and onto > 2\) for all x1, x2 in X, f\(d\(x1, x2\) = d\(f\(x1\), f\(x2\)\) > > If there exists an isometry \(any isometry\) between two spaces, we say > they are \*isometric\*\. It turns out that isometry is an equivalence > relationship; i\.e\., it satisfies > > a\) a \~ a > b\) if a \~ b then b \~ a > c\) if a \~ b and b \~ c, then a \~ c > > \(where = is just a name for the relation in question\)\. > > Mathematically, it seems natural to abstract distance away from a > particular choice of units by passing to the equivalance class of > spaces equivalent under isometry \(written X/\~\)\. But there is a problem: > The map pi : X \-\-> X/\~ associating earch metric space with its > equivalence class destroys any privileged status a metric space in the > equivalence class might have\. If you like, for x in X/\~ the fiber over > x \(pi^\-1\(x\)\) is just a set with no distinguished elements\. > > So, what can be done? How can we hold onto the idea that there are > parti cular units of measurement in which we might be interested > \(inches, centimeters, cubits\) without sacrificing the idea that no > particular system of units is privileged above the others? > > It seems a little formal, but one possibility is to define 1 as "the" > set with one element\. In fact, there are many, many such sets, but all > of what follows can be shown to be independent of that choice\. A > "pointed" set is just a nondegenerate map 1 \-\-> X, that is a function > that picks out a distinguished element of the category of sets\.By > fixing a map 1 \-\-> X, you are essenrially selecting units for your > metric space\. Now, if 1 in R is the number 1, then you can actually > draw a communtative diagram > > X x X \-\-\-\-> R >   > > >   v v > 1 x 1 \-\-\-\-> R > > Now, given an isometry X \-\-> Y, is it possible to choose units in a > natural way, so that change of units will give you a new isometry? The > answer is yes and, in fact if f : X \-\-> X is a change of unit, what is > required is a \*functor\* T tranforming f to T\(f\) \(making the above into > a commutative cube\!\) in such a way that an isometry between metric > spaces can be naturally viewed as an isometry between pointed spaces > \(spaces with units\)\. Such a thing is called a natural transformation > and it gives content to the vague assertion that the choice of 1 really > doesn't matter\. > > Intuitively, what this all means is that it's not enough to just choose > units of meansurement, you need to be able to describe how that choice > fits into the rest of your system\. In practice, you need to fix a > representation for storage, but that representation must not be > privileged, and that can be avoided by describing in mathematical terms > how a concrete model is transormed when the choice of representation > changes\. > > I do not know if I've missed the point of archetypes, but it does seem > to me that functorial language can at least clarify what it means to > get a value "through an archetype"\. To an outsider, this makes little > sense because it seems to be mixing categories, and because an > archetype should not really depend up on particular choice of > represntation \(units\)\. > > === > Gregory Woodhouse <gregory\.woodhouse@sbcglobal\.net> > > "It is foolish to answer a question that > you do not understand\." > \-\-G\. Polya \("How to Solve It"\) > > \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- > This SF\.Net email is sponsored by xPML, a groundbreaking scripting language > that extends applications into web and mobile media\. Attend the live webcast > and join the prime developer group breaking into this new coding territory\! --- ## Post #2 by @thomas.beale This is the response I sent to one list on this topic\.\.\. I don't feel so bad with this large size post, since I already have to compete with Greg;\-\) The following looks technical, but if you have the patience to follow the links, most people should get it \(having 2 screens like I do nowdays helps\!\)\. I'll have to go through the maths below when I have a little more time, but it isn't the basis for archetypes as such \(there might be congruencies\)\. The formal basis \(as it turns out\) for the constraint part of an archetype is Frame logic queries\. These are passingly described in Michael Kifer's Frame Logic paper of 1995\. However, we also combine an ontology and interpolation of coded terms into the archetype nodes to give them meanings beyond the meanings possible purely from the underlying class model\. If you have a look at an example archetype like a simple goal archetype: human readable HTML expression: http://oceaninformatics.biz/archetypes/openEHR-EHR-EVALUATION.goal.v1.html ADL computable expression: http://oceaninformatics.biz/archetypes/ADL/openEHR-EHR-EVALUATION.goal.v1.adl You can see that in the ADL expression in the "definition" section a lot of statements of the form TYPE\_NAME matches \{\} and attribute\_name matches \{\}\. These define the instance spaces of objects \(conforming to TYPE\_NAME\) in terms of the instance spaces of their attributes, recursively\. All the TYPE\_NAMEs and attributes names are from the reference model \(in this case, the underlying model is the openEHR reference model, see http://svn.openehr.org/specification/TRUNK/publishing/architecture/computable/UML/uml_start_view.html) <http://svn.openehr.org/specification/TRUNK/publishing/architecture/computable/UML/uml_start_view.html%29> The whole definition section is a constraint statement, defining a boundary in the instance space of the outermost type, in the case of this example, EVALUATION \(see http://www.openehr.org/uml/Browsable/_9_0_76d0249_1109249648736_872559_12384Report.html). <http://www.openehr.org/uml/Browsable/_9_0_76d0249_1109249648736_872559_12384Report.html%29.> Now, since there is a lot of optionality in archetypes \(0\.\.1, 0\.\.\* etc\), an archetype actually defines a family of boundaries in instance space\. This is similar to an F\-logic query, because it acts like a filter \- you apply it to a database, and if you find instances "inside" the boundaries, you have found something that "matches" the query\. Note that the use of coded terms to give nodes domain\-level meaning multiplies up the possibilities vastly\. \(What I mean by this can fairly easily be understood by looking at http://my.openehr.org/wsvn/knowledge/archetypes/dev/adl/openehr/ehr/entry/observation/openEHR-EHR-OBSERVATION.blood_gases.v1.html?op=file&rev=0&sc=0 \- in this archetype, if you get down into the middle of it, you will see the type name ELEMENT and CLUSTER a lot; just after each reference, you see a code in \[\]; the corresponding meaning of the code in English is given in teh comment at the end of the same line\. So you can see that the "meaning" of the ELEMENT with \[at0004\] is "PaO2", whereas the ELEMENT with \[at0005\] is "PaCO2"\.\) Now, given this, what can be said about a detail like units in quantities is the same that can be said about any detail: it depends on what is in the reference model\. In the openEHR reference model, the part that models Quantity is here: http://www.openehr.org/uml/Browsable/_9_0_76d0249_1109599337877_94556_1510Report.html You can see that in this model it is the class DV\_MEASURABLE that adds units\. The most common type of thing with units is a DV\_QUANTITY\. Now here is a test archetype constraint QUANTITYs \(we don't bother with the DV\_ in archetypes \- this is just a cosmetic thing\): http://my.openehr.org/wsvn/knowledge/archetypes/dev/adl/test/clinical_types/adl-test-entry.c_quantity.draft.html?op=file&rev=0&sc=0 You can see that the first attribute of SOME\_TYPE, called standard\_quantity\_attr, constrains a QUANTITY to be either >= 4oC or >=40oF\. There are other alternatives as well, as you can see below that\. he explanation of how this works is too long to go into here, but is in the ADL manual \(http://svn.openehr.org/specification/TRUNK/publishing/architecture/am/adl.pdf). <http://svn.openehr.org/specification/TRUNK/publishing/architecture/am/adl.pdf%29.> A real archetype full of quantities was the blood gases one from just above\. Now if anyone is still with me, the next thing to say is that archetypes are completely generic with respect to object models, so constraining things like units is no different from constraining anything else; it depends on what you put in the object model to be constrained\. As far as units go, you can see in archetypes like http://my.openehr.org/wsvn/knowledge/archetypes/dev/adl/openehr/ehr/entry/observation/openEHR-EHR-OBSERVATION.cbc.v1.html?op=file&rev=0&sc=0 that a "en\-us" translation would most likely add in a few unit additions, to allow for SI and non SI, e\.g\. for concentrations etc \(actually, I don't think this is cleanly a US/non\-US thing, most of these kinds of analytes are measured in a metric fashion everywhere, but there are different variants like mks and cgs, and other details like moles versus g/l etc\)\. Following are some starting links for archetypes: \- mind map entry: http://oceaninformatics.biz/archetypes/MindMap/ArchetypeMap.html \- search engine: http://www.dualitysystems.com.au/archetypefinder/archetypefinder \- static page with human readable HTML and ADL archetypes: http://oceaninformatics.biz/archetypes/ hope this demystifies a few things\.\.\.\. \- thomas beale --- **Canonical:** https://discourse.openehr.org/t/msg-6-archetypes-for-mathematicians/14161 **Original content:** https://discourse.openehr.org/t/msg-6-archetypes-for-mathematicians/14161