"**Web [[Ontology Language]]**" (cutely named "OWL" for no reason) is a W3C standard which enables the [[Ontology, Semantics, and Syntax|Semantic]] Web. OWL is heavily related to [[SPARQL]], which it was developed alongside of. It is aware of [[Resource Description Framework|RDF]], and maps to it. OWL is not a [[Ontology, Semantics, and Syntax|Syntax]], but instead may use many syntaxes, such as RDF/XML (which appears to be the _preferred_ syntax by the designers of the language), and [[Turtle]]. The source uses 5 syntaxes which can be toggled, nice. OWL is a mechanism to enable [[Modeling as a Knowledge Base]], creating an [[Ontology]]. Ultimate nerd stuff. # Vocabulary Words - **Axioms** are basic statements, asserted as truth by definition - **Entities** are used to refer to real-world objects, a collective term i for: - **Individuals** - sometimes referred to as "_objects_" e.g. `Mary` - **Classes** - sometimes referred to as "_categories_" e.g. `woman` - **[[Disjoint]]** - two classes that are _disjoint_ cannot share a common individual - **Properties** - subdivide into two types: - **Object Properties** - relate individuals to other individuals - See: [[Domain and Range]] - **Inverse** - two properties that are the inverse of one another, e.g. `hasChild` and `hasParent` - **Symmetric** - properties that always go both ways, e.g. `hasSpouse` - **Asymmetric** - properties that CANNOT go both ways, e.g. `hasParent` - **Disjoint** - properties can also be disjoint, saying no two individuals can be linked via _both_, e.g. `bestFriendsWith` and `doesNotKnow` - **Reflexive** - relating to yourself, e.g. `knows` (because you know yourself) - **Irrelflexive** - CANNOT be used to relate to yourself, e.g `hasParent` - **Functional** - an individual may only have one relation of that type, e.g. `hasBiologicalMother` - **Inverse Functional** - same as functional, but inverse, e.g. `biologicalMotherOf` - **Transitive** - when A is related to B, and B is related to C, then A is related to C too, e.g. `inSameRoomAs` - **Key** - every individual has a unique value for the property, would be used for things like `hasSSN` - **Datatype Properties** - assign data values to objects - **Annotation Properties** - are for metadata about the ontology itself - **Expressions** - combine basic axioms and entities to form more complex ones # Tooling OWL can be written by hand, obviously, but there exist a number of tools. The only one I've any experience with is [[Protege]]. # Reasoners OWL tooling includes **Reasoners**, which use the rules of the language to _infer_ new knowledge as a result of the logical consequences of their context. In [[Protege]] there are many reasoners that can be toggled on and off. > [!tip] Reasoners say: > _Assert_ > - `All humans are mortal` > - `Mary is a human` > > _Reasoner infers_: > - `Mary is mortal` Reasoners are powerful. They allow for compounding returns on your knowledge representation. They do come with "gotchas", though. Example from the source - if you assert a domain and range for the Object Property `:hasAge`, and the domain is `:Person`, then later you use the `:hasAge` relation on a _cat_, then the reasoner would deduce that the cat is also a person. # Complex Classes You can state complex conditions to empower your reasoners. An example that resonated with me - any Individual that is both of class `Parent` and class `Woman` is then of class `Mother`: ```turtle :Mother owl:equivalentClass [ rdf:type owl:Class ; owl:intersectionOf ( :Woman :Parent ) ] . ``` These types of relationship implications are what's missing from systems modeling tools, IMHO. ## Restrictions Restrictions can be implemented to assert rules about [[Cardinality]], and to give reasoners the chance to infer new classes through situations like: ```turtle :JohnsChildren owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty  :hasParent ; owl:hasValue  :John ] . ``` # Misc Facts - OWL seems to use [[Case Types|camelCase]] for their relations - **Negative Property Assertion** - it's possible to explicitly say a relation does _not_ exist - **subPropertyOf** - can be used for situations like `:hasWife rdfs:subPropertyOf :hasSpouse .` - **differentFrom** - can be used to explicitly state two things are not the same - **sameAs** - also exists, the opposite of different from. An aliasing mechanism. - **Property Chains** - you can chain things together to form fancy class restrictions based on relations of relations, e.g. ` :hasFriendWithBoat owl:propertyChainAxiom ( :hasFriend  :hasBoat ) .` # Reference Ontology This is pulled directly from the source. ```turtle @prefix : <http://example.com/owl/families/> . @prefix otherOnt: <http://example.org/otherOntologies/families/> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://example.com/owl/families> rdf:type owl:Ontology ; owl:imports <http://example.org/otherOntologies/families.owl> . :hasSpouse rdf:type owl:SymmetricProperty . :hasRelative rdf:type owl:ReflexiveProperty . :parentOf rdf:type owl:IrreflexiveProperty . :hasAncestor rdf:type owl:TransitiveProperty . :hasHusband rdf:type owl:FunctionalProperty . :hasHusband rdf:type owl:InverseFunctionalProperty . :hasWife rdf:type owl:ObjectProperty . :hasWife rdfs:domain  :Man ; rdfs:range  :Woman . :hasWife rdfs:subPropertyOf :hasSpouse . :hasSon owl:propertyDisjointWith  :hasDaughter. :hasFather rdfs:subPropertyOf  :hasParent. :hasParent owl:inverseOf  :hasChild . :hasParent owl:propertyDisjointWith  :hasSpouse . :hasGrandparent owl:propertyChainAxiom ( :hasParent  :hasParent ) . :hasUncle owl:propertyChainAxiom ( :hasFather  :hasBrother ) . :hasAge owl:equivalentProperty otherOnt:age . :hasAge rdf:type owl:DatatypeProperty . :hasAge rdf:type owl:FunctionalProperty . :hasAge rdfs:domain  :Person ; rdfs:range xsd:nonNegativeInteger . :hasChild owl:equivalentProperty otherOnt:child . :hasChild rdf:type owl:AsymmetricProperty . :Woman rdfs:subClassOf :Person . :Mother rdfs:subClassOf :Woman . :Mother owl:equivalentClass [ rdf:type owl:Class ; owl:intersectionOf ( :Woman :Parent ) ] . :Person rdf:type owl:Class . :Person owl:equivalentClass :Human . :Person rdfs:comment "Represents the set of all people."^^xsd:string . :Person owl:hasKey ( :hasSSN ) . :hasSSN rdf:type owl:DataProperty . :Parent owl:equivalentClass [ rdf:type owl:Class ; owl:unionOf ( :Mother :Father ) ] . :Parent owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty  :hasChild ; owl:someValuesFrom  :Person ] . :Grandfather rdfs:subClassOf [ rdf:type owl:Class ; owl:intersectionOf ( :Man  :Parent ) ] . :HappyPerson owl:equivalentClass [ rdf:type owl:Class ; owl:intersectionOf ( [ rdf:type owl:Restriction ; owl:onProperty  :hasChild ; owl:allValuesFrom  :HappyPerson ] [ rdf:type owl:Restriction ; owl:onProperty  :hasChild ; owl:someValuesFrom  :HappyPerson ] ) ] . :JohnsChildren owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty  :hasParent ; owl:hasValue  :John ] . :NarcisticPerson owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty  :loves ; owl:hasSelf "true"^^xsd:boolean . ] . :MyBirthdayGuests owl:equivalentClass [ rdf:type owl:Class ; owl:oneOf ( :Bill  :John  :Mary ) ] . :Orphan owl:equivalentClass [ rdf:type owl:Restriction ; owl:onProperty [ owl:inverseOf  :hasChild ] ; owl:allValuesFrom  :Dead ] . :Teenager rdfs:subClassOf [ rdf:type owl:Restriction ; owl:onProperty  :hasAge ; owl:someValuesFrom [ rdf:type rdfs:Datatype ; owl:onDatatype xsd:integer ; owl:withRestrictions ( [ xsd:minExclusive "12"^^xsd:integer ] [ xsd:maxInclusive "19"^^xsd:integer ] ) ] ] . :Man rdfs:subClassOf  :Person . [] rdf:type owl:Axiom ; owl:annotatedSource  :Man ; owl:annotatedProperty rdfs:subClassOf ; owl:annotatedTarget  :Person ; rdfs:comment "States that every man is a person."^^xsd:string . :Adult owl:equivalentClass otherOnt:Grownup . :Father rdfs:subClassOf [ rdf:type owl:Class ; owl:intersectionOf ( :Man  :Parent ) ] . :ChildlessPerson owl:equivalentClass [ rdf:type owl:Class ; owl:intersectionOf ( :Person [ owl:complementOf  :Parent ] ) ] . :ChildlessPerson owl:subClassOf [ rdf:type owl:Class ; owl:intersectionOf ( :Person [ owl:complementOf [ rdf:type owl:Restriction ; owl:onProperty [ owl:inverseOf  :hasParent ] ; owl:someValuesFrom owl:Thing ] ] ) ] . [] rdf:type owl:Class ; owl:intersectionOf ( [ rdf:type owl:Class ; owl:oneOf ( :Mary  :Bill  :Meg ) ]  :Female ) ; rdfs:subClassOf [ rdf:type owl:Class ; owl:intersectionOf ( :Parent [ rdf:type owl:Restriction ; owl:maxCardinality "1"^^xsd:nonNegativeInteger ; owl:onProperty  :hasChild ] [ rdf:type owl:Restriction ; owl:onProperty  :hasChild ; owl:allValuesFrom  :Female ] ) ] . [] rdf:type owl:AllDisjointClasses ; owl:members ( :Mother  :Father  :YoungChild ) . [] rdf:type owl:AllDisjointClasses ; owl:members ( :Woman  :Man ) . :personAge owl:equivalentClass [ rdf:type rdfs:Datatype; owl:onDatatype xsd:integer; owl:withRestrictions ( [ xsd:minInclusive "0"^^xsd:integer ] [ xsd:maxInclusive "150"^^xsd:integer ] ) ] . ``` **** # More ## Source - https://www.w3.org/TR/owl2-primer/ ## Related