Protege: how to express 'not hasNext'?
I am currently developing an ontology using a protégé and would like to determine if a node is the last one in the list. So basically the list points to a node and each node has some content and may have a different node:
List startsWith some Node
Node hasContent some Content
Node hasNext some Node
Now I would like to define a subclass with a name
that does not point to another
. This is what I have tried so far, but after classification it
Node and not(hasNext some Node)
Node and (hasNext exactly 0 Node)
source to share
First, RDF has a built-in List construct that you can use like this:
ex:mylist rdf:type rdf:List . ex:myList rdf:first ex:firstElement . ex:myList rdf:rest _:sublist1 . _:sublist1 rdf:first ex:SecondElement . _:sublist1 rdf:rest rdf:nil .
Here, to know when you get to the end of the list, you need a special list called
. This plays the same role as a pointer
at the end of a linked list in programming languages.
it is used well in existing data on the Internet, it does not in any way restrict the use of predicates
therefore you can have many first items for a given list without causing inconsistencies.
So, if you really want to structure the linked list properly, you need some pretty expressive OWL features. I did this a while ago and it can be found at http://purl.org/az/List .
It's okay to have an empty class, as you specified what you
. You shouldn't force content or next element on nodes. You have to say that the cardinality is at most 1, that the domain and range
is a Node, and
a node without the next node. But this is still not enough, since it does not impose what exists
at all. You can have an endless sequence or loop.
If you want to avoid loops or an infinite sequence, you must define a transitive property
and say that
there is at least a successor in the class .
In general, the implementation of strict lists in OWL completely sucks from a performance standpoint and in most cases is completely useless, since it is
sufficient for a wide majority of situations.
source to share