All, Based on the frequency of these questions, here are two posts that shed light on the matter.
Virtuoso 7.x and lower: Inference Rules aren't customizable. Thus, you have in-built support for RDF, RDFS, and OWL entity relationship type semantics i.e., we built implementation of inference rules for relationship types such as: rdf:type, rdfs:subClassOf, rdfs:subPropertyOf, owl:sameAs, owl:equivalentClass, owl:equivalentProperty, owl:InverseFunctionalProperty, owl:inverseOf, and owl:SymmetricProperty . Naturally, you could build your own magic predicates, but this would require you write such using Virtuoso PL which most don't want to do. Virtuoso 8.0 and higher (Commercial Edition Only): In this release we add Custom Inference rules using two domain specific languages: [1] Virtuoso Macro Language [2] SPIN SPIN is the highest level, while Virtuoso Macro Language [2] can be written by hand or generated from SPIN. Complete SPIN example which I'll publish in a blog post in the coming days: -- Load Raw Data about Royals SPARQL PREFIX wdrs: <http://www.w3.org/2007/05/powder-s#> WITH <urn:spin:nanotation:demo:royal:family> INSERT { ## Custom Entity Relationship Types (Relations) ## <#hasRelative> a rdf:Property ; rdfs:label "hasRelative" ; rdfs:comment """Generic Family Relationship""" ; rdfs:domain foaf:Person ; rdfs:range <#MalePerson>, <#FemalePerson>, <#RoyalPerson>, foaf:Person, schema:Person ; wdrs:describedby <#> . <#hasUncle> a rdf:Property ; rdfs:subPropertyOf <#hasRelative> ; rdfs:label "hasUncle" ; rdfs:comment """Relationship Type that's derived from a SPARQL-based Custom Inference Rule that associates a Person with a Male Person that's a sibling of one of their Parents. """ ; rdfs:domain foaf:Person ; rdfs:range <#MalePerson> ; wdrs:describedby <#> . <#hasAuntie> a rdf:Property ; rdfs:subPropertyOf <#hasRelative> ; rdfs:label "hasAuntie" ; rdfs:comment """Relationship Type that's derived from a SPARQL-based Custom Inference Rule that associates a Person with a Female Person that's a sibling of one of their Parents. """ ; rdfs:domain foaf:Person ; rdfs:range <#FemalePerson> ; wdrs:describedby <#> . <#hasCousin> a rdf:Property ; rdfs:subPropertyOf <#hasRelative> ; rdfs:label "hasCousin" ; rdfs:comment """Relationship Type that's derived from a SPARQL-based Custom Inference Rule that associates a Person with another Person; that's a child of the sibling of one of their Parents. """ ; rdfs:domain foaf:Person ; rdfs:range <#FemalePerson>, <#MalePerson> ; wdrs:describedby <#> . ## Custom Entity Types (Classes) ## <#FemalePerson> rdfs:subClassOf foaf:Person ; rdfs:label "Female Person Class" ; rdfs:comment """ A female person that inherits properties of the Person class identified by relative URI: foaf:Person. The properties of this class are defined using custom inference rules using SPARQL via . """ ; wdrs:describedby <#> . <#MalePerson> rdfs:subClassOf foaf:Person ; rdfs:label "Male Person Class" ; rdfs:comment """ A male person that inherits properties of the Person class identified by relative URI: foaf:Person. The properties of this class are defined using custom inference rules using SPARQL via . """ ; wdrs:describedby <#> . ## Entity Relationships ## <http://dbpedia.org/resource/Prince_William_of_Wales> a foaf:Person, <#MalePerson> ; schema:name "Prince William" ; rel:siblingOf <http://dbpedia.org/resource/Prince_Harry_of_Wales> . <http://dbpedia.org/resource/Elizabeth_Bowes-Lyon> a foaf:Person, <#FemalePerson> ; schema:name "Queen Mother" ; rel:parentOf <http://dbpedia.org/resource/Elizabeth_II_of_the_United_Kingdom> . <http://dbpedia.org/resource/Elizabeth_II_of_the_United_Kingdom> a foaf:Person, <#FemalePerson> ; schema:name "Queen Elizabeth II" ; rel:parentOf <http://dbpedia.org/resource/Charles,_Prince_of_Wales>, <http://dbpedia.org/resource/Anne,_Princess_Royal>, <http://dbpedia.org/resource/Prince_Andrew,_Duke_of_York>, <http://dbpedia.org/resource/Prince_Edward,_Earl_of_Wessex> ; rel:siblingOf <http://dbpedia.org/resource/Princess_Margaret,_Countess_of_Snowdon> . <http://dbpedia.org/resource/Charles,_Prince_of_Wales> a foaf:Person, <#MalePerson> ; schema:name "Prince Charles" ; rel:parentOf <http://dbpedia.org/resource/Prince_William_of_Wales> , <http://dbpedia.org/resource/Prince_Harry_of_Wales> . <http://dbpedia.org/resource/Princess_Margaret,_Countess_of_Snowdon> a foaf:Person, <#FemalePerson> ; schema:name "Princess Margaret" . <http://dbpedia.org/resource/Anne,_Princess_Royal> a foaf:Person, <#FemalePerson> ; schema:name "Princess Anne" ; rel:parentOf <http://dbpedia.org/resource/Peter_Phillips>, <http://dbpedia.org/resource/Zara_Phillips> . <http://dbpedia.org/resource/Zara_Phillips> a foaf:Person, <#FemalePerson> ; schema:name "Princess Zara Phillips" . <http://dbpedia.org/resource/Princess_Beatrice_of_York> a foaf:Person, <#FemalePerson> ; schema:name "Princess Beatrice" . <http://dbpedia.org/resource/Princess_Eugenie_of_York> a foaf:Person, <#FemalePerson> ; schema:name "Princess Eugenie" . <http://dbpedia.org/resource/Prince_Andrew,_Duke_of_York> a foaf:Person, <#MalePerson> ; schema:name "Prince Andrew" ; rel:parentOf <http://dbpedia.org/resource/Princess_Eugenie_of_York>, <http://dbpedia.org/resource/Princess_Beatrice_of_York> . <http://dbpedia.org/resource/Prince_Edward,_Earl_of_Wessex> a foaf:Person, <#MalePerson> ; schema:name "Prince Edward" . <http://dbpedia.org/resource/Prince_Harry_of_Wales> a foaf:Person, <#MalePerson> ; schema:name "Prince Harry" . <http://dbpedia.org/resource/Peter_Phillips> a foaf:Person, <#MalePerson> ; schema:name "Prince Peter Phillips" . } ; -- Class Definition that includes SPIN Rules SPARQL CLEAR GRAPH <urn:spin:nanotation:demo:royal:family:lib2> ; SPARQL PREFIX rel: <http://purl.org/vocab/relationship/> PREFIX wdrs: <http://www.w3.org/2007/05/powder-s#> prefix spin: <http://spinrdf.org/spin#> PREFIX sp: <http://spinrdf.org/sp#> PREFIX spl: <http://spinrdf.org/spl#> WITH <urn:spin:nanotation:demo:royal:family:lib2> INSERT { <#RoyalPerson> a rdfs:Class ; rdfs:label "A Royal Person"^^xsd:string ; rdfs:subClassOf foaf:Person, schema:Person ; spin:rule [ a sp:Construct ; sp:text """ # must be related to Queen Elizabeth II CONSTRUCT { ?n a ?this . } WHERE { { ?n rel:descendantOf+|rel:ancestorOf+|rel:siblingOf|^rel:siblingOf <http://dbpedia.org/resource/Elizabeth_II_of_the_United_Kingdom>. } # ?n <#hasRelative> | ^<#hasRelative> <http://dbpedia.org/resource/Elizabeth_II_of_the_United_Kingdom> . } """ ] ; spin:rule [ a sp:Construct ; sp:text """ CONSTRUCT { ?this <http://purl.org/vocab/relationship/grandParent> ?x } WHERE { { ?this <http://purl.org/vocab/relationship/parentOf> ?parent . ?parent <http://purl.org/vocab/relationship/parentOf> ?x . } } """ ] ; spin:rule [ a sp:Construct ; sp:text """ CONSTRUCT { ?this rel:ancestorOf ?n } WHERE { { ?this rel:parentOf+|^rel:descendantOf ?n . } } """ ] ; spin:rule [ a sp:Construct ; sp:text """ CONSTRUCT { ?this rel:descendantOf ?n } WHERE { { ?this ^rel:parentOf+ ?n . } } """ ] ; spin:rule [ a sp:Construct ; sp:text """ CONSTRUCT { ?this rel:siblingOf ?n } WHERE { { [] rel:parentOf ?this, ?n. FILTER (?n != ?this) . } } """ ] ; spin:rule [ a sp:Construct ; sp:text """ CONSTRUCT { ?this <#hasAuntie> ?n } WHERE { { [] rel:parentOf ?this ; # rel:siblingOf | ^rel:sinblingOf ?n . rel:siblingOf ?n . ?n a <#FemalePerson> . } } """ ] ; spin:rule [ a sp:Construct ; sp:text """ CONSTRUCT { ?this <#hasUncle> ?n } WHERE { { [] rel:parentOf ?this ; # rel:siblingOf | ^rel:sinblingOf ?n . rel:siblingOf ?n . ?n a <#MalePerson> . } } """ ] ; spin:rule [ a sp:Construct ; sp:text """ CONSTRUCT { ?this <#hasCousin> ?n } WHERE { { [] rel:parentOf ?n ; rel:siblingOf [ rel:parentOf ?this ] . } } """ ]. } ; -- Macro Generation SELECT SPARQL_SPIN_GRAPH_TO_DEFSPIN('urn:spin:nanotation:demo:royal:family:lib2'); exec ('sparql ' || SPARQL_SPIN_GRAPH_TO_DEFSPIN('urn:spin:nanotation:demo:royal:family:lib2')); -- Test Queries SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT * WHERE { ?s a <#RoyalPerson> ; rel:siblingOf ?sibling . }; -- Test 0 SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT * WHERE { ?s a <#RoyalPerson> ; rel:grandParent ?gp . }; -- Test 1 SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT ?person rel:ancestorOf as ?relation ?descendant WHERE { ?person a <#RoyalPerson> ; rel:ancestorOf ?descendant } ; -- Test 2 SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT DISTINCT ?person rel:siblingOf as ?relation ?siblingOf WHERE { ?person a <#RoyalPerson> ; rel:siblingOf ?siblingOf } ; -- Test 3 SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT ?person <#hasAuntie> as ?relation ?hasAuntie WHERE { ?person a <#RoyalPerson> ; <#hasAuntie> ?hasAuntie } ; -- Test 4 SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT ?person <#hasUncle> as ?relation ?hasUncle WHERE { ?person a <#RoyalPerson> ; <#hasUncle> ?hasUncle } ; -- Test 5 SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT ?person <#hasCousin> as ?relation ?hasCousin WHERE { ?person a <#RoyalPerson> ; <#hasCousin> ?hasCousin } ; -- Test 6 SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT ?s as ?ancestor ?descendant WHERE { ?s a <#RoyalPerson> ; rel:ancestorOf ?descendant }; -- Test 7 SPARQL DEFINE input:macro-lib <urn:spin:nanotation:demo:royal:family:lib2> PREFIX rel: <http://purl.org/vocab/relationship/> WITH <urn:spin:nanotation:demo:royal:family> SELECT DISTINCT * WHERE { { ?parent a <#RoyalPerson> ; rel:parentOf ?parentOf .} UNION { ?person a foaf:Person; <#hasAuntie> ?hasAuntie .} UNION { ?person a foaf:Person; <#hasUncle> ?hasUncle .} UNION { ?person a foaf:Person; <#hasCousin> ?hasCousin .} UNION { ?person a foaf:Person; rel:siblingOf ?hasSibling . } UNION { ?person a foaf:Person; rel:ancestorOf ?hasDescendant . } } ; COMMIT WORK ; Links: [1] https://medium.com/virtuoso-blog/using-british-royal-family-data-snippets-to-demonstrate-sparql-query-language-based-reasoning-56626a152419 [2] https://www.linkedin.com/pulse/reasoning-inference-using-british-royal-family-part-idehen -- Regards, Kingsley Idehen Founder & CEO OpenLink Software (Home Page: http://www.openlinksw.com) Medium Blog: https://medium.com/@kidehen Blogspot Blog: http://kidehen.blogspot.com Twitter Profile: https://twitter.com/kidehen Google+ Profile: https://plus.google.com/+KingsleyIdehen/about LinkedIn Profile: http://www.linkedin.com/in/kidehen Personal WebID: http://kingsley.idehen.net/dataspace/person/kidehen#this
smime.p7s
Description: S/MIME Cryptographic Signature
------------------------------------------------------------------------------
_______________________________________________ Virtuoso-users mailing list Virtuoso-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/virtuoso-users