S  H  O  E :  Simple HTML Ontology Extensions

Inferences in SHOE Ontologies

Sean Luke
PLUS Group, U Maryland at College Park



Ontologies don't just declare hierarchical categories and valid relationships. They may also declare things that may be inferred from existant claims. Let's say we wanted to add to our cs-dept-ontology the inference that if someone claims to be a member of an organization, and that organization is a suborganization of a second organization, then the person is also a member of that second organization. This would save people from claiming that they're both a member of a research group and its department, for example.

To do this, we should first lay this inference out in a logical format called a Horn Clause. A Horn clause consists of a head and a body, separated with a ":-". In the head and body are claims; the body can have more than one claim, joined with a "^", which means "and". Claims in a Horn clause usually contain variables, which are wildcards that can be matched against anything, so long as variables of the same name are matched to the same thing. Here's our inference in a Horn Clause (we'll put question marks in front of variables):

member(?org2,?person) :- member(?org1,?person) ^ subOrganizationOf(?org1,?org2)

This is read as: "?person is a member of ?org2 if ?person is a member of ?org1 and ?org1 is a suborganization of ?org2". In the cs-dept-ontology, this would be written as follows:


<DEF-INFERENCE DESCRIPTION="member(?org2,?person) if member(?org1,?person) and subOrganizationOf(?org1,?org2)"> <INF-IF> <RELATION NAME="member"> <ARG POS=1 VALUE="org1" USAGE=VAR> <ARG POS=2 VALUE="per" USAGE=VAR> </RELATION> <RELATION NAME="subOrganizationOf"> <ARG POS=1 VALUE="org1" USAGE=VAR> <ARG POS=2 VALUE="org2" USAGE=VAR> </RELATION> </INF-IF> <INF-THEN> <RELATION NAME="member"> <ARG POS=1 VALUE="org2" USAGE=VAR> <ARG POS=2 VALUE="per" USAGE=VAR> </RELATION> </INF-THEN> </DEF-INFERENCE>

Note the 1 and 2 syntax, not the TO and FROM syntax. TO and FROM are only a convenience for SHOE authors to annotate their web page: the advantage of TO and FROM over 1, 2, 3, ... etc. is that either TO or FROM may be omitted. Inside an inference, this is not permitted; if an inference uses TO or FROM in a binary relation(which it may, but it's bad style), both must be declared. It's strongly suggested to use the numeric syntax at all times for inferences.

As you might guess, you can also use categories in addition to rules. We can also include constant data, not just variables. We might say that if someone is an undergraduate student, and he is a member of the U Maryland CS Department, then his advisor is always Professor John Doe:


<DEF-INFERENCE DESCRIPTION="advisor(?per,http://www.cs.umd.edu/users/johndoe.html) if member(http://www.cs.umd.edu,?per) and UnderGraduateStudent(?per)"> <INF-IF> <RELATION NAME="member"> <ARG POS=1 VALUE="http://www.cs.umd.edu/"> <ARG POS=2 VALUE="per" USAGE=VAR> </RELATION> <CATEGORY NAME="UndergraduateStudent" FOR="per" USAGE=VAR> </INF-IF> <INF-THEN> <RELATION NAME="advisor"> <ARG POS=1 VALUE="per" USAGE=VAR> <ARG POS=2 VALUE="http://www.cs.umd.edu/users/johndoe.html"> </RELATION> </INF-THEN> </DEF-INFERENCE>

As you can see, constant data is differentiated from variables by omitting the "USAGE=VAR". In fact, you're free to describe constant data with "USAGE=CONST". However, CONST is the default assumption when the USAGE attribute is ommitted, so it's unneccessary. There are a variety of variable rules for valid inferences; you should check with the SHOE spec to make sure your inferences are correct.

Lastly, inferences contain a set of "special" comparisons that can only be used within the bounds of an inference. These special comparisons are used to compare variables with constants, and include "equal", "notEqual", "greaterThan", and "lessThan". For example, suppose we had a special "canEnter" relation, and wanted to say (for some reason) that if an person is over 18, that he may enter the university, but if his age is under 18, then he may not enter the university. We could say it as follows:


<DEF-INFERENCE> <INF-IF> <RELATION NAME="age"> <ARG POS=1 VALUE="per" USAGE=VAR> <ARG POS=2 VALUE="a" USAGE=VAR> </RELATION> <COMPARISON OP="greaterThanOrEqual"> <ARG POS=1 VALUE="a" USAGE=VAR> <ARG POS=2 VALUE="18"> </COMPARISON> </INF-IF> <INF-THEN> <RELATION NAME="canEnter"> <ARG POS=1 VALUE="per" USAGE=VAR> <ARG POS=2 VALUE="YES"> </RELATION> </INF-THEN> </DEF-INFERENCE> <DEF-INFERENCE> <INF-IF> <RELATION NAME="age"> <ARG POS=1 VALUE="per" USAGE=VAR> <ARG POS=2 VALUE="a" USAGE=VAR> </RELATION> <COMPARISON OP="lessThan"> <ARG POS=1 VALUE="a" USAGE=VAR> <ARG POS=2 VALUE="18"> </COMPARISON> </INF-IF> <INF-THEN> <RELATION NAME="canEnter"> <ARG POS=1 VALUE="per" USAGE=VAR> <ARG POS=2 VALUE="NO"> </RELATION> </INF-THEN> </DEF-INFERENCE>