# ML Wiki

## Inferencing in Semantic Web

In Semantic Web, using RDFS and OWL many things can be inferred based on facts that are stored in the RDF triple store

Inferencing - a systematic process of adding new tuples to an RDF graph based on some patterns (rules)

• asserted triples - RDF triples provided by some data source
• inferred triples - new triples added by inference rules
• inference rules - systematic patterns that define how and what to infer
• inference engine - engine that does the inference

### Motivating Example

Suppose you have a SPARQL query on your RDF graph

• you look for :RedDelicious apples
• you are doing it in the :Fruit section
• but the result is empty, because :RedDelicious is an :Apple, not a :Fruit
• i.e. :RedDelicious a :Apple
• and :Apple :subClassOf :Fruit

Possible solution:

SELECT ?item
WHERE {
?class :subClassOf* :Fruit .
?item a ?class .
}


But users will have to do it each time

• alternatives?
• can have rules if $X$ subclass of $Y$, then $\forall x \in X: x \in Y$
• inferencing - given some information we can determine related information - and consider that it's also stored in our database
• so here we'd infer that if :RedDelicious is an :Apple, it's also a :Fruit
• :Fruit is broader than :Apple, so :Fruit is a subclass of :Apple

### Inferencing

The motivating example illustrates the type propagation rule

• this is a part of the RDFS language: rdfs:subClassOf relation
• rule: $X$ rdfs:subClassOf $Y \Rightarrow$ every member of $X$ is also a member of $Y$

Reference rules of RDFS/OWL can be expressed using SPARQL Construct queries:

• this is a good way of describing rules
CONSTRUCT { ?r rdf:type ?B }
WHERE {
?A rdfs:subClassOf ?B
?r rdf:type ?A
}


## Implementation Details

When the inference happens?

• Cached Inference:
• inferred triples are stored along with asserted
• risk an explosion of the triple store
• also, change management is important - how to propagate changes and deletes
• for deletes - same inferred tuple can be due to several facts, so need to be careful when deleting
• Just-In-Time Inference
• To respond to queries only
• no inferred triples retained