;;; Declaring the triple template --------------------------------- (deftemplate triple "Template representing a triple" (slot predicate (default "")) (slot subject (default "")) (slot object (default "")) ) ;;; ---------------- copy and paste from rdfmt.clp ------------------ ;;; ------------------- RDF axiomatic triples ----------------------- ;;; ------------------- RDF semantic conditions --------------------- ;;; ------------------- RDFS semantic conditions -------------------- ;;; ------------------- RDFS axiomatic triples ---------------------- ;;; ----------- end of predefined RDF(S) facts and rules ------------ ;;; ---------- OWL model theoretic semantics (RDF-compatible) ---------- ;;; Conditions concerning the parts of the OWL universe and syntactic categories (deffacts OWL_universe ;;; This defines IOC owl:Class as the set of OWL classes. (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/2000/01/rdf-schema#Class") ) (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#Class") ) ;;; This defines IDC as the set of OWL datatypes. ;;; referring to rdfmt.clp --- rdfs:Datatype rdfs:subClassOf rdfs:Class . ;;; This defines IOR owl:Restriction as the set of OWL restrictions. (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#Restriction") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#Restriction") (object "http://www.w3.org/2002/07/owl#Class") ) ;;; This defines IOT owl:Thing as the set of OWL individuals. (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") ) ;;; This defines owl:Nothing. (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") ) ;;; This defines rdfs:Literal. ;;; referring to rdfmt.clp --- rdfs:Literal rdf:type rdfs:Class . ;;; interesting OWL!!! rdfs:Literal rdf:type rdfs:Datatype. ;;; referring to rdfmt.clp --- RDFS_semantic_conditions_datatype ;;; This defines IOOP owl:ObjectProperty as the set of OWL individual-valued properties. (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/2000/01/rdf-schema#Class") ) (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") ) ;;; This defines IODP owl:DatatypeProperty as the set of OWL datatype properties. (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/2000/01/rdf-schema#Class") ) (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") ) ;;; This defines IOAP owl:AnnotationProperty as the set of OWL annotation properties. (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#AnnotationProperty") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#AnnotationProperty") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; This defines IOXP owl:OntologyProperty as the set of OWL ontology properties. (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#OntologyProperty") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject "http://www.w3.org/2002/07/owl#OntologyProperty") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; This defines IX owl:Ontology as the set of OWL ontologies. (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#Ontology") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) ;;; This defines IAD owl:AllDifferent. (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#AllDifferent") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) ) ;;; OWL built-in syntactic classes and properties (deffacts OWL_built_in_syntax ;;; I(owl:FunctionalProperty), I(owl:InverseFunctionalProperty), I(owl:SymmetricProperty), ;;; I(owl:TransitiveProperty), I(owl:DeprecatedClass), and I(owl:DeprecatedProperty) are in CI. (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#FunctionalProperty") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#InverseFunctionalProperty") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#SymmetricProperty") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#TransitiveProperty") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#DeprecatedClass") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#DeprecatedProperty") (object "http://www.w3.org/2000/01/rdf-schema#Class") ) ;;; I(owl:equivalentClass), I(owl:disjointWith), I(owl:equivalentProperty), ;;; I(owl:inverseOf), I(owl:sameAs), I(owl:differentFrom), I(owl:complementOf), ;;; I(owl:unionOf), I(owl:intersectionOf), I(owl:oneOf), I(owl:allValuesFrom), ;;; I(owl:onProperty), I(owl:someValuesFrom), I(owl:hasValue), I(owl:minCardinality), ;;; I(owl:maxCardinality), I(owl:cardinality), and I(owl:distinctMembers) are all in PI. (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/1999/02/22-rdf-syntax-ns#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/1999/02/22-rdf-syntax-ns#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/1999/02/22-rdf-syntax-ns#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/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#sameAs") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#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/1999/02/22-rdf-syntax-ns#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/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#unionOf") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#intersectionOf") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#oneOf") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#allValuesFrom") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#onProperty") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#someValuesFrom") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#hasValue") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#minCardinality") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#maxCardinality") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#cardinality") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#distinctMembers") (object "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property") ) ;;; I(owl:versionInfo), I(rdfs:label), I(rdfs:comment), I(rdfs:seeAlso), I(rdfs:isDefinedBy) in IOAP. (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#versionInfo") (object "http://www.w3.org/2002/07/owl#AnnotationProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2000/01/rdf-schema#label") (object "http://www.w3.org/2002/07/owl#AnnotationProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2000/01/rdf-schema#comment") (object "http://www.w3.org/2002/07/owl#AnnotationProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2000/01/rdf-schema#seeAlso") (object "http://www.w3.org/2002/07/owl#AnnotationProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2000/01/rdf-schema#isDefinedBy") (object "http://www.w3.org/2002/07/owl#AnnotationProperty") ) ;;; I(owl:imports), I(owl:priorVersion), I(owl:backwardCompatibleWith), I(owl:incompatibleWith) in IOXP. (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#imports") (object "http://www.w3.org/2002/07/owl#OntologyProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#priorVersion") (object "http://www.w3.org/2002/07/owl#OntologyProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#backwardCompatibleWith") (object "http://www.w3.org/2002/07/owl#OntologyProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject "http://www.w3.org/2002/07/owl#incompatibleWith") (object "http://www.w3.org/2002/07/owl#OntologyProperty") ) ;;; This defines IL as the set of OWL lists. ;;; referring to rdfmt.clp --- rdf:List rdf:type rdfs:Class . ;;; This defines rdf:nil. ;;; referring to rdfmt.clp --- rdf:nil rdf:type rdf:List . ) ;;; Characteristics of OWL classes, datatypes, and properties ;;; Instances of OWL classes are OWL individuals. (defrule OWL_characteristics_Class (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?e) (object "http://www.w3.org/2002/07/owl#Class") ) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?e) (object "http://www.w3.org/2002/07/owl#Thing") ) ) ) ;;; OWL datatype are special kinds of rdfs:Literal. ;;; referring to rdfmt.clp --- defrule RDFS_semantic_conditions_datatype ;;; OWL dataranges are special kinds of datatypes. (defrule OWL_characteristics_DataRange (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?e) (object "http://www.w3.org/2002/07/owl#DataRange") ) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?e) (object "http://www.w3.org/2000/01/rdf-schema#Literal") ) ) ) ;;; Values for individual-valued properties are OWL individuals. (defrule OWL_characteristics_ObjectProperty (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?e) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) (triple (predicate ?e) (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Thing") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Thing") ) ) ) ;;; Values for datatype properties are literal values. (defrule OWL_characteristics_DatatypeProperty (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?e) (object "http://www.w3.org/2002/07/owl#DatatypeProperty") ) (triple (predicate ?e) (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Thing") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2000/01/rdf-schema#Literal") ) ) ) ;;; Values for annotation properties are less unconstrained. ;;; two rules dealing with (?y rdf:type owl:Thing | rdfs:Literal) (defrule OWL_characteristics_AnnotationProperty_subject (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?e) (object "http://www.w3.org/2002/07/owl#AnnotationProperty") ) (triple (predicate ?e) (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Thing") ) ) ) ;;; By default, values-range for annotation properties are owl:Thing (defrule OWL_characteristics_AnnotationProperty_object (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?e) (object "http://www.w3.org/2002/07/owl#AnnotationProperty") ) (triple (predicate ?e) (subject ?x) (object ?y)) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2000/01/rdf-schema#Literal") ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Thing") ) ) ) ;;; Ontology properties relate ontologies to other ontologies. (defrule OWL_characteristics_OntologyProperty (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?e) (object "http://www.w3.org/2002/07/owl#OntologyProperty") ) (triple (predicate ?e) (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Ontology") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Ontology") ) ) ) ;;; interesting OWL!!! thinking about OWA!!! ;;; interesting OWL!!! By default, both individual-valued and datatype properties are functional properties! ;;; interesting OWL!!! By default, individual-valued are inverse functional,symmetric,transitive properties! ;;; Both individual-valued and datatype properties can be functional properties. ;;; --- if --- (defrule OWL_characteristics_FunctionalProperty_if (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#FunctionalProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#ObjectProperty"|"http://www.w3.org/2002/07/owl#DatatypeProperty") ) (triple (predicate ?c) (subject ?x) (object ?y1)) (triple (predicate ?c) (subject ?x) (object ?y2)) => (assert (triple (predicate "http://www.w3.org/2002/07/owl#sameAs") (subject ?y1) (object ?y2) ) ) ) ;;; --- only if --- (defrule OWL_characteristics_FunctionalProperty_only_if (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#ObjectProperty"|"http://www.w3.org/2002/07/owl#DatatypeProperty") ) (not (and (triple (predicate ?c) (subject ?x) (object ?y1)) (triple (predicate ?c) (subject ?x) (object ?y2)) (not (triple (predicate "http://www.w3.org/2002/07/owl#sameAs") (subject ?y1) (object ?y2))) ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#FunctionalProperty") ) ) ) ;;; Only individual-valued properties can be inverse functional properties. ;;; --- if --- (defrule OWL_characteristics_InverseFunctionalProperty_if (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#InverseFunctionalProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) (triple (predicate ?c) (subject ?x1) (object ?y)) (triple (predicate ?c) (subject ?x2) (object ?y)) => (assert (triple (predicate "http://www.w3.org/2002/07/owl#sameAs") (subject ?x1) (object ?x2) ) ) ) ;;; --- only if --- (defrule OWL_characteristics_InverseFunctionalProperty_only_if (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) (not (and (triple (predicate ?c) (subject ?x1) (object ?y)) (triple (predicate ?c) (subject ?x2) (object ?y)) (not (triple (predicate "http://www.w3.org/2002/07/owl#sameAs") (subject ?x1) (object ?x2))) ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#InverseFunctionalProperty") ) ) ) ;;; Only individual-valued properties can be symmetric properties. ;;; --- if --- (defrule OWL_characteristics_SymmetricProperty_if (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#SymmetricProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) (triple (predicate ?c) (subject ?x) (object ?y)) => (assert (triple (predicate ?c) (subject ?y) (object ?x))) ) ;;; --- only if --- (defrule OWL_characteristics_SymmetricProperty_only_if (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) (not (and (triple (predicate ?c) (subject ?x) (object ?y)) (not (triple (predicate ?c) (subject ?y) (object ?x))) ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#SxmmetricProperty") ) ) ) ;;; Only individual-valued properties can be transitive properties. ;;; --- if --- (defrule OWL_characteristics_TransitiveProperty_if (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#TransitiveProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) (triple (predicate ?c) (subject ?x) (object ?y)) (triple (predicate ?c) (subject ?y) (object ?z)) => (assert (triple (predicate ?c) (subject ?x) (object ?z))) ) ;;; --- only if --- (defrule OWL_characteristics_TransitiveProperty_only_if (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) (not (and (triple (predicate ?c) (subject ?x) (object ?y)) (triple (predicate ?c) (subject ?y) (object ?z)) (not (triple (predicate ?c) (subject ?x) (object ?z))) ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?c) (object "http://www.w3.org/2002/07/owl#TransitiveProperty") ) ) ) ;;; If-and-only-if conditions for rdfs:subClassOf, rdfs:subPropertyOf, rdfs:domain, and rdfs:range ;;; --- if --- ;;; referring to rdfmt.clp --- RDFS_semantic_conditions_subClassOf,subPropertyOf,domain,range ;;; --- only if --- ;;; interesting OWL!!! empty set is subclass of all others! ;;; too strong semantics to be impossible!!! ;;; Characteristics of OWL vocabulary related to equivalence ;;; --- if --- (defrule OWL_characteristics_equivalentClass_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#equivalentClass") (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Class") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Class") ) ) ) (defrule OWL_characteristics_equivalentClass_relationship (triple (predicate "http://www.w3.org/2002/07/owl#equivalentClass") (subject ?x) (object ?y)) (test (neq 0 (str-compare ?x ?y))) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?x) (object ?y))) (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subClassOf") (subject ?y) (object ?x))) ) (defrule OWL_characteristics_disjointWith_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#disjointWith") (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Class") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Class") ) ) ) (defrule OWL_characteristics_disjointWith_relationship (triple (predicate "http://www.w3.org/2002/07/owl#disjointWith") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?o1) (object ?x)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?o2) (object ?y)) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#differentFrom") (subject ?o1) (object ?o2))) ) ;;; By default, values-domain-range for equivalentProperty are DatatypeProperty (defrule OWL_characteristics_equivalentProperty_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#equivalentProperty") (subject ?x) (object ?y)) (not (and (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#DatatypeProperty") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#DatatypeProperty") ) ) ) (defrule OWL_characteristics_equivalentProperty_relationship (triple (predicate "http://www.w3.org/2002/07/owl#equivalentProperty") (subject ?x) (object ?y)) (test (neq 0 (str-compare ?x ?y))) => (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?x) (object ?y))) (assert (triple (predicate "http://www.w3.org/2000/01/rdf-schema#subPropertyOf") (subject ?y) (object ?x))) ) (defrule OWL_characteristics_inverseOf_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#inverseOf") (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#ObjectProperty") ) ) ) (defrule OWL_characteristics_inverseOf_relationship (triple (predicate "http://www.w3.org/2002/07/owl#inverseOf") (subject ?x) (object ?y)) (triple (predicate ?x) (subject ?u) (object ?v)) => (assert (triple (predicate ?y) (subject ?v) (object ?u))) ) (defrule OWL_characteristics_sameAs (triple (predicate "http://www.w3.org/2002/07/owl#sameAs") (subject ?x) (object ?y)) (test (neq 0 (str-compare ?x ?y))) => (printout t "Error---sameAs!!! " ?x " is not same as " ?y crlf) ) (defrule OWL_characteristics_differentFrom (triple (predicate "http://www.w3.org/2002/07/owl#differrentFrom") (subject ?x) (object ?y)) (test (eq 0 (str-compare ?x ?y))) => (printout t "Error---differentFrom!!! " ?x " is not different from " ?y crlf) ) ;;; --- only if --- ;;; intereting OWL!!! ignore all the only-if strong semantics! ;;; Conditions on OWL vocabulary related to boolean combinations and sets ;;; ignore the rdfs:List ;;; --- owl:complementOf --- (defrule OWL_complementOf_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#complementOf") (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Class") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Class") ) ) ) ;;; considering---there is no classical negation in Jess, hence only error messages! (defrule OWL_complementOf_if (triple (predicate "http://www.w3.org/2002/07/owl#complementOf") (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/2002/07/owl#disjointWith") (subject ?x) (object ?y))) ) (defrule OWL_complementOf_only_if (triple (predicate "http://www.w3.org/2002/07/owl#complementOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object "http://www.w3.org/2002/07/owl#Thing") ) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?y))) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) ) ;;; --- owl:unionOf --- (defrule OWL_unionOf_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#unionOf") (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Class") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Class") ) ) ) ;;; considering---there is no instance of unionOf, hence assign one arbitrarily! (defrule OWL_unionOf_subset (triple (predicate "http://www.w3.org/2002/07/owl#unionOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) (not (and (triple (predicate "http://www.w3.org/2002/07/owl#unionOf") (subject ?x) (object ?v)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?v)) ) ) => (printout t "Attention---unionOf " ?x " !!! arbitrarily assign " ?u " belonging to " ?y crlf) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?y))) (halt) ) (defrule OWL_unionOf_supset (triple (predicate "http://www.w3.org/2002/07/owl#unionOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) (halt) ) ;;; --- owl:intersectionOf --- (defrule OWL_intersectionOf_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#intersectionOf") (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Class") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Class") ) ) ) (defrule OWL_intersectionOf_subset (triple (predicate "http://www.w3.org/2002/07/owl#intersectionOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?y))) ) (defrule OWL_intersectionOf_supset (triple (predicate "http://www.w3.org/2002/07/owl#intersectionOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?y)) (not (and (triple (predicate "http://www.w3.org/2002/07/owl#intersectionOf") (subject ?x) (object ?v)) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?v))) ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) (halt) ) ;;; --- owl:oneOf --- (defrule OWL_oneOf_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#oneOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object ?s)) => (if (eq 0 (str-compare ?s "http://www.w3.org/2002/07/owl#Thing")) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Class") ) ) else (if (eq 0 (str-compare ?s "http://www.w3.org/2000/01/rdf-schema#Literal")) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2000/01/rdf-schema#Datatype") ) ) eles (printout t "Error---oneOf!" ?y "should be OWL Thing/RDFS Literal!" crlf) ) ) ) ;;; considering---there is no instance of oneOf, hence assign one arbitrarily! (defrule OWL_oneOf_subset (triple (predicate "http://www.w3.org/2002/07/owl#oneOf") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) (not (and (triple (predicate "http://www.w3.org/2002/07/owl#oneOf") (subject ?x) (object ?v)) (or (test (eq 0 (str-compare ?u ?v))) (not (triple (predicate "http://www.w3.org/2002/07/owl#sameAs") (subject ?u) (object ?v)))) ) ) => (printout t "Attention---oneOf " ?x " !!! arbitrarily assign " ?u " same as " ?y crlf) (assert (triple (predicate "http://www.w3.org/2002/07/owl#sameAs") (subject ?u) (object ?y))) (halt) ) (defrule OWL_oneOf_supset (triple (predicate "http://www.w3.org/2002/07/owl#oneOf") (subject ?x) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object ?x))) ) ;;; Conditions on OWL restrictions ;;; --- owl:allValuesFrom --- (defrule OWL_allValuesFrom_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#allValuesFrom") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object ?s)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Restriction") ) ) (if (eq 0 (str-compare ?s "http://www.w3.org/2002/07/owl#ObjectProperty")) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Class") ) ) else (if (eq 0 (str-compare ?s "http://www.w3.org/2002/07/owl#DatatypeProperty")) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2000/01/rdf-schema#Datatype") ) ) eles (printout t "Error---allValuesFrom!" ?p "should be Object/Datatype Property!" crlf) ) ) ) (defrule OWL_allValuesFrom_subset (triple (predicate "http://www.w3.org/2002/07/owl#allValuesFrom") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) (triple (predicate ?p) (subject ?u) (object ?v)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?v) (object ?y))) ) (defrule OWL_allValuesFrom_supset (triple (predicate "http://www.w3.org/2002/07/owl#allValuesFrom") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate ?p) (subject ?u) (object ?v)) (not (and (triple (predicate ?p) (subject ?o) (object ?v)) (not (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?v) (object ?y))) ) ) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) ) ;;; --- owl:someValuesFrom --- (defrule OWL_someValuesFrom_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#someValuesFrom") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object ?s)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Restriction") ) ) (if (eq 0 (str-compare ?s "http://www.w3.org/2002/07/owl#ObjectProperty")) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Class") ) ) else (if (eq 0 (str-compare ?s "http://www.w3.org/2002/07/owl#DatatypeProperty")) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2000/01/rdf-schema#Datatype") ) ) eles (printout t "Error---someValuesFrom!" ?p "should be Object/Datatype Property!" crlf) ) ) ) ;;; considering---there is no instance of someValuesFrom, hence assign one arbitrarily! (defrule OWL_someValuesFrom_subset (triple (predicate "http://www.w3.org/2002/07/owl#someValuesFrom") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) (triple (predicate ?p) (subject ?u) (object ?v)) (not (and (triple (predicate ?p) (subject ?u) (object ?o)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?o) (object ?s)) (test (eq 0 (str-compare ?s ?y))) ) ) => (printout t "Attention---someValuesFrom " ?x " !!! arbitrarily assign " ?v " belonging to " ?y crlf) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?v) (object ?y))) (halt) ) (defrule OWL_someValuesFrom_subset_append (triple (predicate "http://www.w3.org/2002/07/owl#someValuesFrom") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) (not (triple (predicate ?p) (subject ?u) (object ?v))) => ;;; caution (printout mf "Caution! --- owl:someValuesFrom " ?x " *sub* " crlf "there is nothing related to " ?p crlf) ) (defrule OWL_someValuesFrom_supset (triple (predicate "http://www.w3.org/2002/07/owl#someValuesFrom") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate ?p) (subject ?u) (object ?v)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?v) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) (halt) ) ;;; --- owl:hasValue --- (defrule OWL_hasValue_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#hasValue") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?p) (object ?s)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Restriction") ) ) (if (eq 0 (str-compare ?s "http://www.w3.org/2002/07/owl#ObjectProperty")) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2002/07/owl#Thing") ) ) else (if (eq 0 (str-compare ?s "http://www.w3.org/2002/07/owl#DatatypeProperty")) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2000/01/rdf-schema#Literal") ) ) eles (printout t "Error---allValuesFrom!" ?p "should be Object/Datatype Property!" crlf) ) ) ) (defrule OWL_hasValue_subset (triple (predicate "http://www.w3.org/2002/07/owl#hasValue") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) => (assert (triple (predicate ?p) (subject ?u) (object ?y))) ) (defrule OWL_hasValue_supset (triple (predicate "http://www.w3.org/2002/07/owl#hasValue") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate ?p) (subject ?u) (object ?y)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) ) ;;; define a query to count the cardinalty (defquery OWL_cardinality_query (declare (variables ?P ?S)) (triple (predicate ?P) (subject ?S) (object ?O) ) ) ;;; --- owl:minCardinality --- (defrule OWL_minCardinality_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#minCardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Restriction") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2000/01/rdf-schema#Literal") ) ) (if (> 0 ?y) then (printout t "Error---minCardinality!!! " ?x " the number of " ?y " is negative! " crlf)) ) (defrule OWL_minCardinality_subset (triple (predicate "http://www.w3.org/2002/07/owl#minCardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) (test (> ?y (count-query-results OWL_cardinality_query ?p ?u))) => (printout t "Error---maxCardinality!!! " ?x " its property " ?p " cardinality is " much less than " ?y crlf) ) (defrule OWL_minCardinality_supset (triple (predicate "http://www.w3.org/2002/07/owl#minCardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate ?p) (subject ?u) (object ?v)) => (if (<= ?y (count-query-results OWL_cardinality_query ?p ?u)) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) ) (halt) ) ;;; --- owl:maxCardinality --- (defrule OWL_maxCardinality_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#maxCardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Restriction") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2000/01/rdf-schema#Literal") ) ) (if (> 0 ?y) then (printout t "Error---maxCardinality!!! " ?x " the number of " ?y " is negative! " crlf)) ) (defrule OWL_maxCardinality_subset (triple (predicate "http://www.w3.org/2002/07/owl#maxCardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) (test (< ?y (count-query-results OWL_cardinality_query ?p ?u))) => (printout t "Error---maxCardinality!!! " ?x " its property " ?p " cardinality is " much more than " ?y crlf) ) (defrule OWL_maxCardinality_supset (triple (predicate "http://www.w3.org/2002/07/owl#maxCardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate ?p) (subject ?u) (object ?v)) => (if (>= ?y (count-query-results OWL_cardinality_query ?p ?u)) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) ) (halt) ) ;;; --- owl:cardinality --- (defrule OWL_cardinality_domainrange (triple (predicate "http://www.w3.org/2002/07/owl#cardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) => (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?x) (object "http://www.w3.org/2002/07/owl#Restriction") ) ) (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?y) (object "http://www.w3.org/2000/01/rdf-schema#Literal") ) ) (if (> 0 ?y) then (printout t "Error---cardinality!!! " ?x " the number of " ?y " is negative! " crlf)) ) (defrule OWL_cardinality_subset (triple (predicate "http://www.w3.org/2002/07/owl#cardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x)) (test (<> ?y (count-query-results OWL_cardinality_query ?p ?u))) => (printout t "Error---minCardinality!!! " ?x " its property " ?p " cardinality is not equal " ?y crlf) ) (defrule OWL_cardinality_supset (triple (predicate "http://www.w3.org/2002/07/owl#cardinality") (subject ?x) (object ?y)) (triple (predicate "http://www.w3.org/2002/07/owl#onProperty") (subject ?x) (object ?p)) (triple (predicate ?p) (subject ?u) (object ?v)) => (if (= ?y (count-query-results OWL_cardinality_query ?p ?u)) then (assert (triple (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") (subject ?u) (object ?x))) ) (halt) ) ;;; ------------- end of OWL predefined facts and rules ------------- (reset) ;;; ------ adding Jess assertions transformed from OWL2Jess --------- ;;; ------------------- Run Jess Rule Engine ------------------------ (run) (save-facts "owlfacts.txt")