;;; RDFS ans OWL Meta model ---------------------------------------------------------------- ;;; Declaring the triple template --------------------------------- (deftemplate triple "Template representing a triple" (slot predicate (default "")) (slot subject (default "")) (slot object (default "")) ) ;;; Declaring facts of the meta-model of OWL ---------------------- (deffacts OWLModel "Facts of the meta-model of RDFS and OWL" ;;; Resource is a Class (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2000/01/rdf-schema#Resource") (object "http://www.w3.org/2002/07/owl#Class") ) ;;; Class is a subtype of Resource (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#Class") (object "http://www.w3.org/2000/01/rdf-schema#Resource") ) ;;; Class is a Class (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#Class") (object "http://www.w3.org/2002/07/owl#Class") ) ;;; Thing is a Class (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#Thing") (object "http://www.w3.org/2002/07/owl#Class") ) ;;; Nothing is a Class (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#Nothing") (object "http://www.w3.org/2002/07/owl#Class") ) ;;; Property is a Class (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") (object "http://www.w3.org/2002/07/owl#Class") ) ;;; Domain is a Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2000/01/rdf-schema#domain") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; Range is a Property (triple (predicate "http://www.w3.org/2000/01/rdf-schema#range") (subject "http://www.w3.org/2000/01/rdf-schema#domain") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; 'Data Type Property' is a Class (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#DatatypeProperty") (object "http://www.w3.org/2002/07/owl#Class") ) ;;; 'Data Type Property' is a subtype of Property (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#DatatypeProperty") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; 'Object Property' is a Class (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#ObjectProperty") (object "http://www.w3.org/2002/07/owl#Class") ) ;;; 'Object Property' is a subtype of Property (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#ObjectProperty") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; Type is an 'Object Property' (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) ;;; 'Transitive Property' is a subtype of ObjectProperty (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#TransitiveProperty") (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) ;;; 'Sub Class Of' is a 'Transitive Property' (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2000/01/rdf-schema#subClassOf") (object "http://www.w3.org/2002/07/owl#TransitiveProperty") ) ;;; 'Sub Property Of' is a 'Transitive Property' (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (object "http://www.w3.org/2002/07/owl#TransitiveProperty") ) ;;; 'Symmetric Property' is a subtype of ObjectProperty (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#SymmetricProperty") (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) ;;; 'Inverse Of' is a Symmetric Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#inverseOf") (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ;;; 'Equivalent Property' is a Symmetric Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#equivalentProperty") (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ;;; 'Equivalent Class' is a Symmetric Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#equivalentClass") (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ;;; 'Same Individual' is a Symmetric Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#sameIndividualAs") (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ;;; 'Complement Of' is a Symmetric Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#complementOf") (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ;;; 'Different From' is a Symmetric Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#differentFrom") (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ;;; 'Disjoint With' is a Symmetric Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#disjointWith") (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ;;; 'Equivalent Property' is a Transitive Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#equivalentProperty") (object "http://www.w3.org/2002/07/owl#TransitiveProperty") ) ;;; 'Equivalent Class' is a Transitive Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#equivalentClass") (object "http://www.w3.org/2002/07/owl#TransitiveProperty") ) ;;; 'Same Individual' is a Transitive Property (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#sameIndividualAs") (object "http://www.w3.org/2002/07/owl#TransitiveProperty") ) ;;; 'Functional Property' is a subtype of Property (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#FunctionalProperty") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; 'Inverse Functional Property' is a subtype of Property (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#InverseFunctionalProperty") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; sameAs is equivalent to sameIndividualAs (triple (predicate "http://www.w3.org/2002/07/owl#equivalentProperty") (subject "http://www.w3.org/2002/07/owl#sameAs") (object "http://www.w3.org/2002/07/owl#sameIndividualAs") ) ) ;;; Adding rules for forward completion of the base ---------------------------- ;;; Propagate transitive properties (defrule transitivity (declare (salience 100)) (triple (predicate ?p) (subject ?x) (object ?y)) (triple (predicate ?p) (subject ?z) (object ?x)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object "http://www.w3.org/2002/07/owl#TransitiveProperty") ) => (assert (triple (predicate ?p) (subject ?z) (object ?y))) ) ;;; Complete typing of instances of objects with inherited types (defrule subClassOf_transitive_typing (declare (salience 100)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?y) (object ?z)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object ?y)) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object ?z))) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object ?z))) ) ;;; Complete typing of instances of properties with inherited types (defrule subPropertyOf_transitive_typing (declare (salience 100)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?y) (object ?z)) (triple (predicate ?y) (subject ?a) (object ?b)) (not (triple (predicate ?z) (subject ?a) (object ?b))) => (assert (triple (predicate ?z) (subject ?a) (object ?b))) ) ;;; Default behavior for signature propagation (defrule rdfs_domain_signature_transitivity (declare (salience 100)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#domain") (subject ?y) (object ?z)) (not (triple (predicate "http://www.w3.org/2000/01/rdf-schema#domain") (subject ?x) (object ?z))) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#domain") (subject ?x) (object ?z))) ) (defrule rdfs_range_signature_transitivity (declare (salience 100)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#range") (subject ?y) (object ?z)) (not (triple (predicate "http://www.w3.org/2000/01/rdf-schema#range") (subject ?x) (object ?z))) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#range") (subject ?x) (object ?z))) ) ;;; Complete with instances of symmetric properties (defrule symmetry (declare (salience 100)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) (triple (predicate ?p) (subject ?x) (object ?y)) (not (triple (predicate ?p) (subject ?y) (object ?x))) => (assert (triple (predicate ?p) (subject ?y) (object ?x))) ) ;;; Complete with instances of inverse properties (defrule inverse (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#inverseOf") (subject ?p1) (object ?p2) ) (triple (predicate ?p1) (subject ?x) (object ?y)) (not (triple (predicate ?p2) (subject ?y) (object ?x))) => (assert (triple (predicate ?p2) (subject ?y) (object ?x))) ) ;;; The inverse property of a functional property is an inverse functional property (defrule inverse-of-functional (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#inverseOf") (subject ?p1) (object ?p2) ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p1) (object "http://www.w3.org/2002/07/owl#FunctionalProperty") ) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p2) (object "http://www.w3.org/2002/07/owl#InverseFunctionalProperty") ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p2) (object "http://www.w3.org/2002/07/owl#InverseFunctionalProperty") ) ) ) ;;; The inverse property of an inverse functional property is a functional property (defrule inverse-of-inverse-functional (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#inverseOf") (subject ?p1) (object ?p2) ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p1) (object "http://www.w3.org/2002/07/owl#InverseFunctionalProperty") ) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p2) (object "http://www.w3.org/2002/07/owl#FunctionalProperty") ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p2) (object "http://www.w3.org/2002/07/owl#FunctionalProperty") ) ) ) ;;; Complete with instances of equivalent classes (defrule equivalent-class-one (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#equivalentClass") (subject ?t1) (object ?t2) ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object ?t1)) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object ?t2))) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object ?t2))) ) ;;; Complete hierarchy with equivalent classes: if t1 <=> t2 then t1 < t2 ;;; by symmetry we also get t2 < t1 (defrule equivalent-class-two (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#equivalentClass") (subject ?t1) (object ?t2) ) (not (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?t1) (object ?t2))) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?t1) (object ?t2))) ) ;;; Members of disjoint classes are different instances (defrule members-of-disjoint-classes-are-different (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#disjointWith") (subject ?c1) (object ?c2)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?o1) (object ?c1)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?o2) (object ?c2)) (test (neq ?c1 ?c2)) (not (triple (predicate "http://www.w3.org/2002/07/owl#differentFrom") (subject ?o1) (object ?o2))) => (assert (triple (predicate "http://www.w3.org/2002/07/owl#differentFrom") (subject ?o1) (object ?o2))) ) ;;; Two classes subsuming each other are equivalent (defrule two-classes-subsuming-each-other-are-equivalent (declare (salience 100)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?c1) (object ?c2)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?c2) (object ?c1)) (test (neq ?c1 ?c2)) (not (triple (predicate "http://www.w3.org/2002/07/owl#equivalentClass") (subject ?c1) (object ?c2))) => (assert (triple (predicate "http://www.w3.org/2002/07/owl#equivalentClass") (subject ?c1) (object ?c2))) ) ;;; Complete instances with properties of equivalent instances (defrule equivalent-instance-one (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#sameIndividualAs") (subject ?s1) (object ?s2) ) (triple (predicate ?p) (subject ?s1) (object ?o)) (not (triple (predicate ?p) (subject ?s2) (object ?o))) => (assert (triple (predicate ?p) (subject ?s2) (object ?o))) ) (defrule equivalent-instance-two (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#sameIndividualAs") (subject ?o1) (object ?o2) ) (triple (predicate ?p) (subject ?s) (object ?o1)) (not (triple (predicate ?p) (subject ?s) (object ?o2))) => (assert (triple (predicate ?p) (subject ?s) (object ?o2))) ) ;;; Complete instances of properties with instances of equivalent properties (defrule equivalent-property-one (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#equivalentProperty") (subject ?p1) (object ?p2) ) (triple (predicate ?p1) (subject ?s) (object ?o)) (not (triple (predicate ?p2) (subject ?s) (object ?o))) => (assert (triple (predicate ?p2) (subject ?s) (object ?o))) ) ;;; Complete hierarchy with equivalent properties: if p1 <=> p2 then p1 < p2 ;;; by symmetry we also get p2 < p1 (defrule equivalent-property-two (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#equivalentProperty") (subject ?p1) (object ?p2) ) (not (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?p1) (object ?p2))) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?p1) (object ?p2))) ) ;;; Two properties subsuming each other are equivalent (defrule two-properties-subsuming-each-other-are-equivalent (declare (salience 100)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?p1) (object ?p2)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?p2) (object ?p1)) (test (neq ?p1 ?p2)) (not (triple (predicate "http://www.w3.org/2002/07/owl#equivalentProperty") (subject ?p1) (object ?p2))) => (assert (triple (predicate "http://www.w3.org/2002/07/owl#equivalentProperty") (subject ?p1) (object ?p2))) ) ;;; Derive equivalence from multiple instantiations of a functional property with the same subject (defrule functional-property-equivalence (declare (salience 100)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object "http://www.w3.org/2002/07/owl#FunctionalProperty") ) (triple (predicate ?p) (subject ?s) (object ?o1)) (triple (predicate ?p) (subject ?s) (object ?o2)) (test (neq ?o1 ?o2)) (not (triple (predicate "http://www.w3.org/2002/07/owl#sameIndividualAs") (subject ?o1) (object ?o2))) => (assert (triple (predicate "http://www.w3.org/2002/07/owl#sameIndividualAs") (subject ?o1) (object ?o2))) ) ;;; Derive equivalence from multiple instantiations of inverse functional property with the same object (defrule inverse-functional-property-equivalence (declare (salience 100)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object "http://www.w3.org/2002/07/owl#InverseFunctionalProperty") ) (triple (predicate ?p) (subject ?s1) (object ?o)) (triple (predicate ?p) (subject ?s2) (object ?o)) (test (neq ?s1 ?s2)) (not (triple (predicate "http://www.w3.org/2002/07/owl#sameIndividualAs") (subject ?s1) (object ?s2))) => (assert (triple (predicate "http://www.w3.org/2002/07/owl#sameIndividualAs") (subject ?s1) (object ?s2))) ) ;;; Complete the extension of the Thing class with all other classes (defrule everything-is-a-thing (declare (salience 100)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?s) (object ?o)) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?s) (object "http://www.w3.org/2002/07/owl#Thing") ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?s) (object "http://www.w3.org/2002/07/owl#Thing") ) ) ) ;;; A property inverse of it-self is symmetric (defrule a-property-inverse-of-it-self-is-symmetric (declare (salience 100)) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#inverseOf") (subject ?p) (object ?p)) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) ) ) ;;; Adding rule for coherence checking ---------------------------------- ;;; Check the extension of Nothing is empty (defrule nothing-is-nothing (declare (salience 100)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?s) (object "http://www.w3.org/2002/07/owl#Nothing") ) => (printout t "Error: " ?s " was found to be of type Nothing, which is not possible." crlf) ) ;;; A resource cannot be different from it-self (defrule different-from-it-self (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#differentFrom") (subject ?o) (object ?o)) => (printout t "Error: " ?o " was found to be different from it-self, which is not possible." crlf) ) ;;; Two resources cannot be different and identical (defrule different-and-identical (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#differentFrom") (subject ?o1) (object ?o2)) (triple (predicate "http://www.w3.org/2002/07/owl#sameIndividualAs") (subject ?o1) (object ?o2)) (test (neq ?o1 ?o2)) => (printout t "Error: " ?o1 " and " ?o2 " were found to be different and the same, which is not possible." crlf) ) ;;; A class cannot be disjoint with it-self (defrule disjoint-with-it-self (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#disjointWith") (subject ?c) (object ?c)) => (printout t "Error: " ?c " was found to be disjoint with it-self, which is not possible." crlf) ) ;;; Two classes cannot be disjoint and equivalent (defrule disjoint-and-equivalent (declare (salience 100)) (triple (predicate "http://www.w3.org/2002/07/owl#disjointWith") (subject ?c1) (object ?c2)) (triple (predicate "http://www.w3.org/2002/07/owl#equivalentClass") (subject ?c1) (object ?c2)) (test (neq ?c1 ?c2)) => (printout t "Error: " ?c1 " and " ?c2 " were found to be disjoint and equivalent, which is not possible." crlf) ) ;;; EOF