Blog
Books
Talks
Follow
Me
Search

Larsblog

PSIs for Topic Maps constructs

<< 2006-05-29 10:45 >>

One thing that's lacking in the current set of Topic Maps standards is defined identifiers for the Topic Maps constructs, like subject, topic, association, etc. The TMDM doesn't really need this for its own purposes, but it does mean that there are some semantics that aren't described as fully as they could be. There are also other standards (TMCL and TMQL) which could make use of such identifiers (with additional semantics).

Notation

How to define the identifiers is dead easy, but how would we define the semantics? In this blog entry I use a rather ad-hoc solution: a set of tolog update statements which add to the topic map the information that is implied by these topic map constructs. The syntax is INSERT ... FROM ... where the first part contains an LTM template using variables whose values are defined by the tolog query in the FROM. This syntax is not defined anywhere, and not necessarily beautiful, but it gets the job done.

You can (informally) interpret this in several ways:

I'll use the PSI prefix tm: here, but I won't define what it stands for, since these PSIs don't actually exist. I'm just trying out ideas here, not defining anything for real.

Identifiers and semantics

tm:subject

The term "subject" is defined very clearly in the standard as being absolutely anything at all. This is clearly a class, and it's equally clear that there isn't anything that isn't an instance of this class (including tm:subject itself).

INSERT
  [$topic : tm:subject]
FROM
  topic($topic)

In other words, every topic is an instance of tm:subject.

INSERT
  tmdm:supertype-subtype(tm:subject : tmdm:supertype, $type : tmdm:subtype)
FROM
  instance-of($type, tmdm:type)

In other words, every type is a subtype of tm:subject.

tm:topic

This is an interesting term, because none of the topics in the topic map actually represent topics. This may sound like it's wrong, but stop for a moment to consider the following:

[lmg : person = "Lars Marius Garshol"]

Clearly, lmg is a subject (because everything is). But is lmg a topic? Yes. But lmg does not represent a topic; it represents a person, and persons are not topics.

So does topic have any semantics? Well, in a sense it does: every topic is a topic map construct. But we will specify this when we get to that term.

tm:topic-map-construct

This is the common supertype for topics, associations, and all the other constructs that can appear in a topic map. The semantics are easily defined as given below.

[tm:topic-map-construct = "Topic map construct"]
tmdm:supertype-subtype(tm:topic-map-construct : tm:supertype, tm:topic : tm:subtype)
tmdm:supertype-subtype(tm:topic-map-construct : tm:supertype, tm:association : tm:subtype)
tmdm:supertype-subtype(tm:topic-map-construct : tm:supertype, tm:association-role : tm:subtype)
tmdm:supertype-subtype(tm:topic-map-construct : tm:supertype, tm:occurrence : tm:subtype)
tmdm:supertype-subtype(tm:topic-map-construct : tm:supertype, tm:topic-name : tm:subtype)
tmdm:supertype-subtype(tm:topic-map-construct : tm:supertype, tm:topic-map : tm:subtype)
tmdm:supertype-subtype(tm:topic-map-construct : tm:supertype, tm:variant-name : tm:subtype)

Subtypes of tm:topic-map-construct

There is not really a whole lot unsaid about these from the formal point of view, so we say no more here.

tm:type

This term doesn't actually exist, but we need it for the semantics defined above, so we define it. The definition can easily be done in LTM alone.

[tm:type = "Type"]
tmdm:supertype-subtype(tm:type : tm:supertype, tm:topic-type : tm:subtype)
tmdm:supertype-subtype(tm:type : tm:supertype, tm:association-type : tm:subtype)
tmdm:supertype-subtype(tm:type : tm:supertype, tm:association-role-type : tm:subtype)
tmdm:supertype-subtype(tm:type : tm:supertype, tm:occurrence-type : tm:subtype)
tmdm:supertype-subtype(tm:type : tm:supertype, tm:name-type : tm:subtype)

Given this definition, we also know what it means to be a type. Once we've defined the semantics of the subtypes we should be OK. There is one more thing, though. Anything that is a supertype or subtype of something else must itself be a type. We specify this formally as follows.

INSERT
  [$type : tm:type]
FROM
  { tmdm:supertype-subtype($type : tmdm:supertype, $stype : tmdm:subtype) |
    tmdm:supertype-subtype($stype : tmdm:supertype, $type : tmdm:subtype) }

tm:topic-type

A topic type is something that's either declared to be a topic type (by this being stated explicitly), or that's used as a topic type. The former case needs no handling, and the latter is handled below.

INSERT
  [$type : tm:topic-type]
FROM
  instance-of($instance, $type)

tm:association-type

The same logic goes for association types, so we provide similar semantics:

INSERT
  [$type : tm:association-type]
FROM
  type($assoc, $type), association($assoc)

tm:association-role-type

Same here.

INSERT
  [$type : tm:association-role-type]
FROM
  type($ar, $type), association-role($assoc, $type)

tm:occurrence-type

INSERT
  [$type : tm:occurrence-type]
FROM
  type($occ, $type), occurrence($occ, $type)

tm:name-type

INSERT
  [$type : tm:name-type]
FROM
  type($name, $type), topic-name($name, $type)

tm:information-resource

Now this is an interesting term, since it allows us to spell out one part of the meaning of the subject locator construct, which is that any topic which has a subject locator must necessarily represent an information resource.

INSERT
  [$res : tm:information-resource]
FROM
  subject-locator($res, $uri)

tm:statement

This is another interesting term. Every association, topic name, variant, and occurrence is a statement in Topic Maps.

[tm:statement = "Statement"]
tmdm:supertype-subtype(tm:statement : tm:supertype, tm:association : tm:subtype)
tmdm:supertype-subtype(tm:statement : tm:supertype, tm:occurrence : tm:subtype)
tmdm:supertype-subtype(tm:statement : tm:supertype, tm:topic-name : tm:subtype)
tmdm:supertype-subtype(tm:statement : tm:supertype, tm:variant-name : tm:subtype)

tm:supertype-subtype

The semantics that need to be defined here are only the transitivity of this association type, which are easily defined:

subtype-of($SUP, $SUB) :- {
  tmdm:supertype-subtype($SUP : tm:supertype, $SUB : tm:subtype) |
  tmdm:supertype-subtype($SUP : tm:supertype, $MID : tm:subtype),
  subtype-of($MID, $SUB)
}.

INSERT
  tmdm:supertype-subtype($SUPER : tm:supertype, $SUB : tm:subtype)
FROM
  subtype-of($SUPER, $SUB)

tm:type-instance

The type-instance relationship is trivial, once the above is taken care of.

/* using subtype-of from above */
INSERT
  [$instance : $supertype]
FROM
  direct-instance-of($instance, $type),
  subtype-of($supertype, $type)

Similar posts

A TMCL tutorial

The TMCL standard now seems more or less stable, and so now it is finally possible to explain to outsiders what the language looks like and how it works

Read | 2008-10-03 17:33

Subtyping statements

Subtyping topic types has been supported in Topic Maps ever since the beginning, but support for subtyping statement types is much spottier, and, it turns out, trickier

Read | 2007-07-13 18:50

An XTM conformance test suite

One thing that's really needed is a conformance test suite for XTM 2.0, which can be used by implementors to verify that they've actually gotten their implementations right

Read | 2006-08-02 19:24

Comments

No comments.

Add a comment

Name required
Email optional, not published
URL optional, published
Comment
Spam don't check this if you want to be posted
Not spam do check this if you want to be posted