[THEA2] Asserting rdf:List?

17 views
Skip to first unread message

Jochem Liem

unread,
Mar 8, 2011, 8:05:02 AM3/8/11
to thea-owl-lib
Dear Vangelis/Chris,

I've now adopted the Thea2 library in the development of our DynaLearn
tool. It is proving very useful.

I would appreciate some help with one remaining issue. Does the
library allow the assertion of an axiom representing an rdf:List (and
the conversion to rdf/xml)? I'm trying to create a structure similar
to what the Protege people have [1]. However, they seem to mis the
rdf:rest property to rdf:nil at the end of the rdf:List.

Many thanks.

Best regards,
Jochem Liem
http://www.dynalearn.eu

[1] http://protege.stanford.edu/plugins/owl/testdata/list-example.owl

Vangelis Vassiliadis

unread,
Mar 9, 2011, 9:01:45 AM3/9/11
to thea-o...@googlegroups.com, Jochem Liem
Hi Jochem,

Currently Thea does not support having a list as an object to the ObjectPropertyAssertion axiom.
Looking at the OWL spec, the object can be a blank node, and thus it can be translated to a list.
I've committed the change to the master barnch in git but, as you say, the protege example does not
work since the rdf:nil does not exist at the end of the list.
Is this an issue perhaps for the protege team?

Also a question: can we refer in future blogs and posts that dynalearn is using Thea? I believe it is good publicity for Thea.

Regards,
Vangelis

PS. can we, in the future

Jochem Liem

unread,
Apr 2, 2011, 7:50:24 AM4/2/11
to Vangelis Vassiliadis, thea-o...@googlegroups.com
Hi Vangelis,

Please feel free to indicate that DynaLearn is using Thea. :)

I wanted to start importing OWL files from DynaLearn, but noticed that
OWL files do not load. I'm unsure whether this is because of me
running the latest master branch merged with the axiomannotation
branch, the newer versions of Prolog or for another reason. I've just
tried loading one of the Thea test files, but it says it contains 0
triples.

1 ?- load_axioms('libraries/thea2/testfiles/music_ontology.owl', owl).
% Parsed "music_ontology.owl" in 0.06 sec; 0 triples
true.

Finally, I've written the function below to generate rdf:Lists.
Perhaps it is nice to have in Thea in some form.

Best regards,
Jochem

list_assertion([Head|Tail], Resource) :-
% There should be at least one resource in the list
\+ [Head|Tail] = [],
(
% If you want to have a list as a blank node
var(Resource) ->
rdf_bnode(ListElement),
Resource = ListElement
;
% If you want to have a specified URI for the list
ListElement = Resource
),
assert_axiom( propertyAssertion('rdf:type', ListElement, 'rdf:List') ),
assert_axiom( propertyAssertion('rdf:first', ListElement, Head) ),
list_assertion2(Tail, ListElement).

list_assertion2([], LastElement) :-
assert_axiom( propertyAssertion('rdf:rest', LastElement, 'rdf:nil') ).

list_assertion2([Head|Tail], PreviousElement) :-
% Create a new list element
rdf_bnode(ListElement),
assert_axiom( propertyAssertion('rdf:type', ListElement, 'rdf:List') ),
assert_axiom( propertyAssertion('rdf:first', ListElement, Head) ),

% Connect to the rest of the list
assert_axiom( propertyAssertion('rdf:rest', PreviousElement, ListElement) ),
list_assertion2(Tail, ListElement).

:-
rdf_register_ns(qrm, 'http://www.dynalearn.eu/models/ExampleModel.owl#'),

% List as a blank node:
list_assertion(['qrm:value1','qrm:value2','qrm:value3'],
BlankNode), % 'qrm:QuantitySpace'
assert_axiom( namedIndividual('qrm:Quantity1') ),
assert_axiom( namedIndividual('qrm:QuantitySpace1') ),
assert_axiom( propertyAssertion('qrm:hasValueList',
'qrm:QuantitySpace1', BlankNode) ),
assert_axiom( propertyAssertion('qrm:hasQuantitySpace',
'qrm:Quantity1', 'qrm:QuantitySpace1') ),

% List as a resource
assert_axiom( namedIndividual('qrm:Quantity2') ),
assert_axiom( namedIndividual('qrm:QuantitySpace2') ),
list_assertion(['qrm:value1','qrm:value2','qrm:value3'],
'qrm:QuantitySpace2'), % 'qrm:QuantitySpace'
assert_axiom( propertyAssertion('qrm:hasQuantitySpace',
'qrm:Quantity2', 'qrm:QuantitySpace2') ),

save_axioms( 'theatest.owl', owl ),

retract_all_axioms,

load_axioms('theatest.owl', owl ).

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Jochem Liem, MSc.
Informatics Institute
Faculty of Science
University of Amsterdam
http://www.science.uva.nl/~jliem/

Phone:  +31 (0)20 525 6801
Mobile: +31 (0)6  4321 9992
Fax:     +31 (0)20 525 7490

Visitor address:
Science Park 904, C2.248
1098 XH Amsterdam

Mailing address:
Postbus 94323
1090 GH Amsterdam
The Netherlands
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Jochem Liem

unread,
Apr 4, 2011, 9:44:47 AM4/4/11
to Vangelis Vassiliadis, thea-o...@googlegroups.com
Dear Vangelis,

I was wrong about the loading of the files, they seem to load
perfectly. It is just the feedback that gave me the wrong impression.

I've been playing with the List representation, but think that the
current approach might result in properties being lost in the loading
process. Furthermore, there seems to be a mismatch between how the
List representation is loaded and how it can be saved.

When loading a rdf:List, Thea now automatically converts it to a
Prolog list. However, it is valid for a rdf:List to have annotations
(rdfs:label/rdfs:comment) or be a named resource. Because the list is
automatically converted, such information does not appear in the Thea
abstract syntax. Furthermore, although an RDF list becomes a list
during the loading of an OWL file, it is invalid to assert it as a
prolog list.

I've been looking at the OWL specification, and it seems that rdf:List
does not have an abstract syntax rendering [1] (nor could I find one
for OWL2). Only the rendition to triples seems specified. Perhaps it
is better to take this approach and have helper functions to assert
rdf lists as prolog lists, or convert rdf lists to prolog. The
attached prolog file has exactly those functions, and also shows how
certain properties are lost when the resulting OWL file is loaded.

For my use cases it would be better if Thea would not do the automatic
conversion.

Thanks for you time.

Best regards,
Jochem

[1] http://www.w3.org/TR/owl-semantics/semantics-all.html#index

thea-list-test.pl

Jochem Liem

unread,
Apr 4, 2011, 10:35:46 AM4/4/11
to Vangelis Vassiliadis, thea-o...@googlegroups.com
I have to get out of the habit of figuring this out immediately after
sending an email. I should query the annotationAssertions in addition
to the propertyAssertions.

The label is not lost. It is just that a resource has both the
rendering as a prolog list and as a URI. For querying purposes, this
seems suboptimal. In the triples below the prolog list and the
QuantitySpace2 are the same resource. As such, I still think that
rendering the rdf:List as a triples is the best solution.

Best regards,
Jochem

Triple: http://www.dynalearn.eu/models/ExampleModel.owl#hasQuantitySpace
http://www.dynalearn.eu/models/ExampleModel.owl#Quantity2
[http://www.dynalearn.eu/models/ExampleModel.owl#value4,http://www.dynalearn.eu/models/ExampleModel.owl#value5,http://www.dynalearn.eu/models/ExampleModel.owl#value6]

Triple: http://www.w3.org/2000/01/rdf-schema#label
http://www.dynalearn.eu/models/ExampleModel.owl#QuantitySpace2
literal(This label is lost)

Reply all
Reply to author
Forward
0 new messages