# RDFox and Reasoning

May 11, 2020 · 4 min read

# RDFox

RDFox is a high performance knowledge graph and semantic reasoning engine developed by Oxford Semantic Technologies. This short article will help you understand the key concepts behind RDFox and when to use them in your applications.

# Knowledge Graphs

A knowledge graph is composed of a graph database to store the data and a reasoning layer to interpret and manipulate the data.

Relational databases store data in structured records whereas graph databases store data points as nodes which are connected with edges if they share some form of relationship.

Data stored in a graph can be accessed with a query which will “hop” along the edges to find the requested nodes.

# Reasoning

Reasoning is the process of materialising rules which apply to the data. Materialising a rule means adding new nodes or edges to the graph when it is satisfied. These new nodes and edges match the rule’s “pattern”.

A rule can be as simple as an “If… then…” statement.

For example: “If a city is located in Oxfordshire, then it is located in England”.

With this rule, RDFox will automatically establish a “Located In” edge between Oxford and England.

Materialised edges are useful because they will improve querying results by reducing the number of hops needed to find the correct nodes.

Read our article on Towards Data Science for a more detailed introduction to Knowledge Graphs and Reasoning.

# Finding Patterns with Rules

Rules help identify patterns in your data or verify that they don’t occur. RDFox offers a complete and flexible approach to modelling and materialising simple and complex rules in your data. This section lists some common rule-based patterns.

# THE TRANSITIVE RELATION PATTERN

Many relations are naturally transitive, but they are rarely explicitly described in data because they can be cumbersome to record.

Rules help materialise transitive relations effortlessly. The following rule enables RDFox to materialise all the actual “located In” relationships:

English: If ?x is located in ?y and ?y is located in ?z then ?x is located in ?z

Datalog: [?x, :locatedIn, ?z] :- [?x, :locatedIn, ?y] , [?y, :locatedIn, ?z] .

# THE TRANSITIVE CLOSURE PATTERN

Relations are not always transitive; in which case we might wish to define a different relation that “transitively” closes the relation. This is particularly useful in social networks where we might want to identify recommendations based on a user’s existing network.

For example, in the following network, a rule will suggest Diana follows Bob and that Alice and Diana follow Charlie to “close” the relation. Domain expertise can help influence how these relations are closed to improve the quality of the recommendations.

# THE SHORTCUT PATTERN

Generating direct connections between indirectly connected objects can help reduce the number of “hops” a query has to do when navigating the graph for answers. Materialising a connection with a rule can be useful for queries you might be running frequently.

For example, creating a “country Of Birth” edge in the first example would help find the country of birth of a person born in Oxford in one hop.

# THE QUERY-VIEW PATTERN

Some queries can be expressed as a rule in which case the results can be materialised and stored directly in the graph. This can help accelerate query response times because the results are materialised before the query is actually made.

For example, a query to find nodes which don’t meet a criteria will search through the nodes and then test if they don’t meet the specified criteria.

However, a rule can automatically filter the nodes which don’t meet the criteria and the query can then be simplified to only search through that pre-filtered subset.

# TYPE AND ATTRIBUTE INHERITANCE PATTERN

“Is a” or subsumption relationships can be represented in RDFox using rules. Subsumption rules are useful for identifying non-obvious relationships in your data or to assign certain properties from a class to a newly identified member.

# THE CYCLE DETECTION PATTERN

Rules can help identify cyclic relationships in graphs in particular when they shouldn’t occur.

A cyclic relation can be materialised with one line of Datalog:

English: if ?x :partOf ?x then :partOf is a :cyclic Relation

Datalog: [ :partOf a :cyclicRelation ] :- [ ?x , :partOf, ?x ] .

# SIMPLE CALCULATIONS

Rules can be used to perform computations over the data in the graph (e.g. unit conversions, missing values).

# THE AGGREGATION PATTERN

Rules can populate the graph with aggregate values derived from the graph such as sums, counts and averages.

# THE MANDATORY ATTRIBUTE PATTERN

Rules can check for incompleteness in the data and raise a warning whenever expected data is missing.

For more information, to request a demo or start a free trial, click here.

# Team and Resources

The team behind Oxford Semantic Technologies started working on RDFox in 2011 at the Computer Science Department of the University of Oxford with the conviction that flexible and high-performance reasoning was a possibility for data intensive applications without jeopardising the correctness of the results. RDFox is the first market-ready knowledge graph designed from the ground up with reasoning in mind. Oxford Semantic Technologies is a spin out of the University of Oxford and is backed by leading investors including Samsung Venture Investment Corporation (SVIC), Oxford Sciences Innovation (OSI) and Oxford University’s investment arm (OUI). The author is proud to be a member of this team.

photo credit: Robert Katzki

## Oxford Semantic Technologies

A high performance knowledge graph and semantic reasoning engine

## Oxford Semantic Technologies

Oxford Semantic Technologies develop RDFox, the first market-ready high-performance knowledge graph designed from ground up with semantic reasoning in mind. Founded in 2017 as a spin-out of the University of Oxford with a mission to bring cutting-edge research to industry.

Written by

## Felicity Mulford

Employee at Oxford Semantic Technologies and Ox Mountain. OST have developed RDFox, a high performance knowledge graph and semantic reasoning engine.

## Oxford Semantic Technologies

Oxford Semantic Technologies develop RDFox, the first market-ready high-performance knowledge graph designed from ground up with semantic reasoning in mind. Founded in 2017 as a spin-out of the University of Oxford with a mission to bring cutting-edge research to industry.