2

I have loaded the pizza ontology into Stardog and Blazegraph, along with some triples I authored, including a pizza with four toppings. I have tried to make the toppings distinct, as @AKSW suggested.

The pizza ontology defines an interesting pizza as a pizza with at least three toppings. I'm pretty sure I have OWL reasoning enabled, but neither triplestore says that my pizza is interesting.

Can anybody show me settings that enable this inference in any freely available triplestore or point out what I've done wrong with my triples? Especially, should I be able to infer that pizza instances, pizza classes, or both are "interesting"?

Interesting pizza definition:

pizza:InterestingPizza rdf:type owl:Class ;
    owl:equivalentClass [ owl:intersectionOf ( pizza:Pizza
            [ rdf:type owl:Restriction ;
                owl:onProperty pizza:hasTopping ;
                owl:minCardinality "3"^^xsd:nonNegativeInteger
            ]
        ) ;
        rdf:type owl:Class
    ] ;
        rdfs:label "PizzaInteressante"@pt .

My additional triples:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> .

<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClass>
  a owl:Class ;
  owl:equivalentClass [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#CaperTopping>
  ], [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#JalapenoPepperTopping>
  ], [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#LeekTopping>
  ], [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#MozzarellaTopping>
  ], [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#PineKernels>
  ] ;
  rdfs:subClassOf <http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza> ;
  rdfs:label "mark's pizza class" .

<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClassMember>
  a owl:NamedIndividual, <http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClass> ;
  rdfs:label "a member of the mark's pizza class" .

<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaInstance>
  a owl:NamedIndividual, <http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza> ;
  pizza:hasTopping pizza:marksPeppers, pizza:topping1, pizza:topping2, pizza:topping3, pizza:topping4 ;
  rdfs:label "mark's pizza instance" .

pizza:marksPeppers
  a owl:NamedIndividual, pizza:JalapenoPepperTopping ;
  rdfs:label "mark's special spicy jalapenos" .

pizza:topping1
  a owl:NamedIndividual, pizza:MozzarellaTopping ;
  rdfs:label "mark's semi secret topping one" .

pizza:topping2
  a owl:NamedIndividual, pizza:PineKernels ;
  rdfs:label "mark's semi secret topping two" .

pizza:topping3
  a owl:NamedIndividual, pizza:CaperTopping ;
  rdfs:label "mark's semi secret topping three" .

pizza:topping4
  a owl:NamedIndividual, pizza:LeekTopping ;
  rdfs:label "mark's semi secret topping four" .

[]
  a owl:AllDifferent ;
  owl:distinctMembers (
   pizza:marksPeppers
   pizza:topping1
   pizza:topping2
   pizza:topping3
   pizza:topping4
 ) .

Query for any knowledge about a pizza instance with five distinct toppings:

prefix pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
select *
where
{ pizza:marksPizzaInstance ?p ?o }

Result from Stardog (I have manually replaced full URIs with prefixed URIs):

+---------------------+----------------------------+
|          p          |             o              |
+---------------------+----------------------------+
| pizza:hasIngredient | pizza:topping1             |
| pizza:hasIngredient | pizza:topping2             |
| pizza:hasIngredient | pizza:topping3             |
| pizza:hasIngredient | pizza:topping4             |
| pizza:hasIngredient | pizza:marksPeppers         |
| pizza:hasTopping    | pizza:topping1             |
| pizza:hasTopping    | pizza:topping2             |
| pizza:hasTopping    | pizza:topping3             |
| pizza:hasTopping    | pizza:topping4             |
| pizza:hasTopping    | pizza:marksPeppers         |
| rdfs:label          | mark's pizza instance      |
| rdf:type            | owl:Thing                  |
| rdf:type            | pizza:DomainConcept        |
| rdf:type            | pizza:Food                 |
| rdf:type            | pizza:Pizza                |
| rdf:type            | pizza:SpicyPizza           |
| rdf:type            | pizza:SpicyPizzaEquivalent |
| rdf:type            | pizza:CheeseyPizza         |
| rdf:type            | pizza:marksPizzaClass      |
+---------------------+----------------------------+

Stardog has inferred that my pizza has ingredients (because it has toppings), that my pizza is a food, and even that my pizza is spicy because it has Mark's jalapeno peppers as a topping. But it hasn't inferred membership in the interesting pizza class.

Here are my Stardog reasoning settings:

Reasoning type: SL
Reasoning approximate: ON 
SameAs reasoning: FULL
TBox named graph: *
honk
  • 9,137
  • 11
  • 75
  • 83
Mark Miller
  • 3,011
  • 1
  • 14
  • 34
  • 1
    Hi Mark. I guess you now run into the fact that in OWL there is no Unique Names Assumption (UNA). That means a reasoner cannot assume from different names that individuals are different. Thus, you have to make the individuals explicitly different from each other (using `owl:differentFrom` pairwise or more convenient using `owl:allDifferent` with a list of individuals). In your case the toppings. – UninformedUser Jul 02 '17 at 15:48
  • Something like that in turtle: `_:x rdf:type owl:AllDifferent . _:x owl:members (:topping1 :topping2 :topping3 :topping4) ` – UninformedUser Jul 02 '17 at 15:51
  • I'm wondering why those guys didn't mention that - those are all real OWL experts. Maybe they overlooked the `minCardinality` which is mostly leading to those problems when using standard OWL reasoning. – UninformedUser Jul 02 '17 at 15:53
  • No worries. One important thing to know: You should be aware of the different reasoning profiles - not sure which one you used in the triple store but as far as I know only Stardog supports full OWL reasoning. See https://www.w3.org/TR/owl2-profiles . For example, OWL QL does only support `owl:someValuesFrom` with `owl:Thing` as filler in SubClassOf axioms. This usally also affects Equivalence axioms which are just syntactic sugar. And it doesn't support `ObjectMinCardinality` in general. – UninformedUser Jul 02 '17 at 16:00
  • @AKSW I think I did the AllDifferent like you suggested (see updated question), but I'm still not getting the desired inference. I'm also loosing confidence that I know whether I should expect to see the inference for **1.** a pizza *class* that is equivalent to classes that have four different toppings **2.** an member of that class **or 3.** an instance of the generic class *pizza* that is directly asserted to have four different toppings. – Mark Miller Jul 02 '17 at 17:14
  • Let me check Stardog - will take some time to setup the new version 5.0. In the meantime, can you try to use the `DL` profile? I'm wondering whether this will work. If so, we know that your desired inference is outside of the `SL` profile. – UninformedUser Jul 02 '17 at 17:46
  • Mark, I checked your ontology in Protege. The axioms are enough to infer the your desired axiom, see https://pasteboard.co/Gz6yszu.png That means there might be a problem with the used reasoning profile. – UninformedUser Jul 02 '17 at 17:58
  • An alternative - as you used `SL` profile - might be to add an SWRL rule, thus, please check my [modified ontology](http://txt.do/dkrh8) – UninformedUser Jul 02 '17 at 18:14
  • You read my mind... SWRL is the next thing I was going to ask about. I've never used it before. How do I invoke your rule or query with it? Either with the SWRL tab, or in a SAPRQL query? I loaded your SWRL-ified version of the ontology and turned Hermit on, but didn't automagically see mark's pizza instance = interesting. – Mark Miller Jul 02 '17 at 18:21
  • You mean in Protege? There you don't need the rule, just the class equivalence axiom. And then start the reasoner. Inference will work out of the box - click on the class `InterestingPizza`. Regarding triple stores, in particular, Stardog, my idea was to use the power of the Stardog `SL` profile which also includes support for SWRL rules. (or alternatively, Stardog rules which in fact are light-weight SPARQL BGPs) – UninformedUser Jul 02 '17 at 18:59
  • In addition, SWRL rules are OWL axioms, i.e. you don't have to invoke them explicitly if the OWL reasoner supports them (Pellet and HermiT support a fragment of SWRL to ensure decidability) – UninformedUser Jul 02 '17 at 19:02
  • Thanks so much. It's a long holiday weekend for many of us in the US. I'll be experimenting with this case and some related cases sporadically. PS when do you sleep? Is the @AKSW SO account for one person or your whole department? – Mark Miller Jul 02 '17 at 19:05
  • 1
    Ok, good luck and let me know which way worked (best) for you :D I'll play around with Stardog inferencing support tomorrow, but I'm pretty sure that the `SL` profile doesn't contain some of the necessary axioms. They documentation states that it's a combination of the other profiles, but details are missing. PS: in Germany, most people will go to bed probably in an hour, but I prefer to "work" until midnight or beyond. No, this is my private account, but I know, the name is a bit misleading - maybe I should share the credentials accross our research group. Cheers – UninformedUser Jul 02 '17 at 19:13

1 Answers1

4

I played a bit with Stardog 5.0 and got some more insights:

  1. From an OWL DL view, the ontology is expressive enough to infer that

    pizza:marksPizzaInstance rdf:type pizza:InterestingPizza .
    

    This can be evaluated with Protege for example. A sample explanation that can be computed with the pretty cool Protege feature would be: enter image description here

    I could achieve the same in Stardog by enabling DL reasoning:

    bin/stardog-admin db offline pizzaDB
    bin/stardog-admin metadata set -o reasoning.type=DL pizzaDB
    bin/stardog-admin db online pizzaDB
    

    Result:

    +-------------------+-------------------------+
    |         p         |            o            |
    +-------------------+-------------------------+
    |  pizza:hasTopping |  pizza:topping1         |
    |  pizza:hasTopping |  pizza:topping2         |
    |  pizza:hasTopping |  pizza:marksPeppers     |
    |  pizza:hasTopping |  pizza:topping3         |
    |  pizza:hasTopping |  pizza:topping4         |
    |  rdf:type         |  pizza:Pizza            |
    |  rdf:type         |  owl:Thing              |
    |  rdf:type         |  pizza:InterestingPizza |
    +-------------------+-------------------------+
    
  2. For the Stardog profile SL it doesn't work because the axiom is not in the profile. This can be recognized when looking into the Stardog log file which reports all ignored axioms:

    WARN  2017-07-03 09:54:51,219 [XNIO-1 task-6] com.clarkparsia.blackout.ProfileFilterBase:apply(39): 
    Not a valid SL axiom: 
    EquivalentClasses(pizza:InterestingPizza, and(pizza:Pizza, min(pizza:hasTopping,3,owl:Thing))) 
    

    What I tried then is to add an SWRL rule since it's supported by the SL profile:

    Pizza(?x), hasTopping(?x, ?y1), hasTopping(?x, ?y2), hasTopping(?x, ?y3),  
    DifferentFrom (?y1, ?y2),  DifferentFrom (?y1, ?y3),  DifferentFrom (?y2, ?y3) 
    -> InterestingPizza(?x)
    

    Surprisingly, this did not work either. I guess I missed some important thing and I'm still investigating why this doesn't work.

    Lastly, I tried a Stardog rule instead of SWRL which has a pretty neat syntax close to SPARQL (BGPs are basically used):

    [] a rule:SPARQLRule ;
     rule:content """
        PREFIX :<http://www.co-ode.org/ontologies/pizza/pizza.owl#>
          IF {
                ?p a :Pizza ;
                   :hasTopping ?t1 , ?t2, ?t3
                FILTER(?t1 != ?t2 && ?t1 != ?t3 && ?t2 != ?t3)
             }
          THEN {
                ?p a :InterestingPizza
              }""" .
    

    This works as expected and the SPARQL query returns the desired inferred triple.

UninformedUser
  • 8,397
  • 1
  • 14
  • 23
  • OK, using your input I can see my expected inference in Protege and Stardog (DL) now. When I have some more free time, I'm going to experiment more with the different topics you covered. (Especially trying in Blazegraph again.) Thanks. – Mark Miller Jul 03 '17 at 12:04
  • 1
    Note, the `DL` profile is more expensive, but with the Stardog rule you can use the `SL` profile. Indeed, this doesn't work for other triple stores. I never used Blazegraph, but I guess they support OWL QL (mostly used for query rewriting) which won't work with the equivalence axiom in your ontology. – UninformedUser Jul 03 '17 at 18:01