W3C home > Mailing lists > Public > semantic-web@w3.org > September 2012

Re: Enhancing object-oriented programming with OWL

From: Timothy Armstrong <tim.armstrong@gmx.com>
Date: Sat, 15 Sep 2012 11:30:22 -0400
Message-ID: <50549F0E.6070202@gmx.com>
To: semantic-web@w3.org
Hi,

Thank you very much for the replies.  I appreciate them very much. Oh, I 
think it's very simple: we can just make object-oriented programming 
better than it currently is.  We let people use property reasoning for 
any of their object-oriented attributes.  We let them run SPARQL queries 
on all of main memory.  We let them use rules (I explain a bit below how 
that will work).  I have in mind to let people write Semantic Web 
Services entirely as Java annotations on Java methods without having 
anything to do with WSDL.  Do you think that would work?  Java 
annotations would have to support having arbitrary datatypes as values, 
but they should anyway, and we could try to get it added to Java (it 
would be useful for everyone who uses Java).

My understanding implementing the code in Java was always that we would 
be somewhat limited with what we can do with classes because of 
multiple-inheritance issues, but that it would be easy to copy my code 
to other object-oriented languages that do have multiple-inheritance.  
My view now – though I could be wrong here – is that we can implement 
OWL defined classes in Java and use them just for the purpose of testing 
if a Java object belongs to a class, and for finding all members of a 
class, without issues of multiple inheritance arising.  I thought it 
would be very useful to have methods for defined classes, but we would 
not need to have them.

> I agree your approach is useful when semantifying the OO world. But if 
> I can achieve the same end result in plain Java (using Jena and our 
> own platform), why should I use an extra layer of software (given the 
> above points)?
>

Well yes, that really is my main purpose: letting people use the 
Semantic Web in object-oriented programming – well, with object 
databases, object-relational databases, and object-relational mapping 
too.  I'm sure your points are very valid.  Just what I was trying to 
get at in my last post is that my software, or software like it, should 
offer certain performance advantages over Semantic Web software that 
stores its data as whole triples.  All my software needs to do when 
making a triple statement is add a Java object to a Java Collection 
instead of creating and storing a whole triple.  I'm very confident in 
my benchmarks now: http://www.semanticoop.org/benchmarks.html.  It takes 
Jena 10,894 milliseconds to make 50 owl:topObjectProperty statements 
each for 20,000 subjects, Sesame 20,953 milliseconds, and my software 41 
milliseconds.  The numbers come out extremely similarly for each run of 
the program.  Well, as I said, I like Jena and Sesame very much, and 
I'll probably want to integrate them with my software.

> However, you need further reasoning capabilities (e.g., you will want 
> to obtain that a is a cousin of b if you have that c is a parent of a, 
> d is a parent of b, and c and d are brothers.) And you cannot add this 
> through ad hoc functions in your classes, or you will soon have an 
> undebugable spaghetti mess of contradictions. You need something like 
> a rete network. And then, either you add it to the innards of java, or 
> you duplicate your code (and its implicit logic) in the network.
>

Well, cousins was my example for owl:propertyChainAxiom.  Here is the 
hasCousin property/attribute:

@ObjectProperty
@label("hasCousin")
@comment("The cousins of a person.  It is a subproperty of hasRelative.  
It is symmetric and irreflexive.  It has a property chain axiom: a 
person's parents' siblings' children are the person's cousins.")

@domain(Person.class)
@range(Person.class)
@Symmetric
@Irreflexive
@propertyChainAxiom({hasParent.class, hasSibling.class, hasChild.class})
@subPropertyOf(hasRelative.class)
public @interface hasCousin {}

My tests pass with the current version of the family ontology, but there 
was a problem with a previous version.  So we can do that form of 
reasoning in Java, it just has to be debugged.

Here is how I have in mind to do rules.  For each rule that is active in 
the system, a certain number of subject-predicate pairs will show up in 
the consequent when the rule is fired.  So when we are trying to find 
all the objects of a given subject-predicate pair, which is a Java 
Collection that is an attribute, and the pair is in the consequent, we 
fire the rule.

Again, thank you very much for your replies.

Tim
http://www.semanticoop.org
Received on Saturday, 15 September 2012 15:30:51 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 21:45:51 GMT