Adding Formulas to Ontologies:

This is a small tutorial on how to add formulas to ontologies. It uses Protégé 4 (please, after registration, download build 60 or later here).

Our running example is a small ontology about geometric shapes, bi-dimensional polygons in particular. The starting ontology can be downloaded here.

We want to enrich our starting ontology adding formulas to compute the perimeter and the area of some polygons. Please notice that there is a further complication in our model. Every value cannot be directly added to an instance of the element of the hierarchy below the Polygon, but it is rather the filler of the property hasValue of the instances of the Feature class. For example a Polygon instance aTriangle has the length of its sides in the ontologies asserted as fillers of the hasFeature object property. Their specific class is SideLengthFeature, whereas the possible perimeter and areas will be different feature categorised under the respective sub-class of Feature.

Whenever we want to create a new formula we need to select the formula view (if it is not already displayed in the current layout). It is possible to add formulas exclusively for data properties, therefore the appropriate view is amongst the Data Property Views as in the picture below.

Property Formula View activation

The formula property view allows to create new formulas for existing data properties. In order to do that just click on the plus button besides the Formulas section heading

add new formula button

Once clicked on the plus button the formula editor appears. Such editor allows to set all the aspects of a formula, for their meanings please look at the Syntax overview.

Below we show the formula editor displaying the formula:

$OVERRIDING$ APPLIESTO <Polygon>
STORETO <http://www.cs.manchester.ac.uk/~iannone/owlcalculations/examples/geometry.owl#hasFeature[PerimeterFeature]>
{sideLength=http://www.cs.manchester.ac.uk/~iannone/owlcalculations/examples/geometry.owl#hasFeature[SideLengthFeature] o
http://www.cs.manchester.ac.uk/~iannone/owlcalculations/examples/geometry.owl#hasValue}-> SUM(sideLength);

formula editor
formula editor
formula editor

Once the editing is finished, click on the OK button in order to add the formula to the ontology