Similarity-based OSF Logic for Flexible SPARQL Query Answering

Gian Carlo Milanese, Gabriella PasiarXiv 2026

TL;DR

The authors present an updated version of fosf, a reasoner that brings "fuzzy" flexibility to RDF knowledge graph queries. By integrating similarity relations into Order-Sorted Feature (OSF) logic, the system can rewrite rigid SPARQL queries into approximate ones, ensuring that users get relevant results even when their queries slightly conflict with strict ontological constraints.

What Problem Does This Paper Address?

Querying Knowledge Graphs (KGs) via SPARQL typically requires a "perfect match" mindset. If an ontology defines two classes (sorts) as disjoint—for example, a teacher cannot be a researcher—a query looking for someone who is both will return zero results. This is due to the closed-world assumption inherent in many logic frameworks, where anything not explicitly allowed is forbidden.

In the real world, knowledge is often evolving or imprecise. A user might not know the exact structure of a massive ontology, or the data itself might be slightly inconsistent. The challenge is to move away from "fail-fast" rigid logic toward a system that understands similarity, allowing for approximate answers with a calculated degree of confidence.

Methods

The researchers utilize Fuzzy Order-Sorted Feature (OSF) logic. In this framework:

  • Sorts represent classes of objects (e.g., Professor, University).
  • Features represent functional attributes (e.g., teaches_at).
  • Fuzzy Subsumption: Instead of a simple "is-a" relationship, sorts have a degree of membership.

The core innovation in this release of fosf is the integration of a similarity relation ($\sim$) between sorts. As shown in the figure below, the system can combine standard hierarchical subsumption (black arrows) with user-defined similarity (dotted green lines) to create a new "fuzzy subsumption" (dashed red lines).

Figure 1: Example of how a sort subsumption ⪯(black edges) and a sort similarity ∼(dotted green edges) are parsed in fosf, and their graphical representation (where ⊥is omitted). After parsing, the two relations are combined into a single fuzzy subsumption ⪯· (black edges and dashed red edges).

The workflow follows a specific pipeline:

  1. Normalization: The system takes an OSF term (the query) and simplifies it based on the ontology, sort definitions, and similarity relations.
  2. Constraint Relaxation: If a query is technically inconsistent (e.g., asking for a teacher who is also a researcher), the reasoner uses the similarity relation to "relax" the constraint to a similar sort (like professor) that satisfies the ontology.
  3. SPARQL Translation: The normalized, relaxed OSF term is compiled into a standard SPARQL query that can be executed against any RDF database.

Datasets

The paper does not evaluate the reasoner on a specific large-scale benchmark dataset. Instead, it uses illustrative examples, such as a university ontology (involving sorts like lecturer, researcher, and professor) and a movie database example (involving horror, slasher, and thriller genres) to demonstrate the logic.

Key Insights and Ideas

  • The Similarity Bridge: The most critical insight is the inference rule: If sort $s_0$ is a type of $s_1$, and $s_1$ is similar to $s_2$ with degree $\alpha$, then $s_0$ can be considered a type of $s_2$ with degree $\alpha$. This allows the logic to bridge gaps in the hierarchy.
  • Ontology-Aware Rewriting: Unlike simple keyword expansion, this rewriting happens at the logic level. It respects feature domains and ranges (e.g., knowing that the directed_by feature implies the subject is a movie and the object is a person).
  • User-Centric Flexibility: By returning approximate solutions, the system prevents "surprising" empty results for users who may not have mastered a complex ontology.

Key Results

The authors successfully demonstrated that fosf can take a query that would normally fail under strict OSF normalization and transform it into a valid SPARQL query.

For instance, a query for a person who teaches_at an institution and researches_at a research_center is technically inconsistent if the ontology says teachers and researchers are disjoint. fosf identifies that lecturer (similar to teacher) and researcher meet at the sort professor. It then rewrites the SPARQL query to look for professors, returning results with a similarity degree of 0.5 rather than nothing at all.

The researchers also provided a web interface to visualize these taxonomies and test the query translation in real-time.

Figure 5: The web interface of fosf, displaying the OSF ontology composed of sort subsumption and similarity declarations, sort definitions, and feature domain/range constraints (left), the target RDF KG facts (middle), and the OSF query term (right). Action buttons enable users to inspect the taxonomy, display the translated query, and execute the generated SPARQL, with options to toggle OSF query normalization and the similarity relation.

Limitations and Future Work

  • Performance: The current reasoner is written in pure Python, which limits its speed on very large taxonomies. The authors are currently developing a C++ engine to improve efficiency.
  • Expressiveness: The system does not yet support "disjunctive" sorts (e.g., "find me a teacher OR a researcher").
  • Manual Similarity: Currently, similarity degrees must be manually defined. The authors plan to explore automated similarity estimation using vector embeddings (like Word2Vec or FastText) in the future.
  • Strict Disjointness: The logic still struggles with the inherent disjointness of the closed-world assumption unless similarity is explicitly provided; they plan to allow for "non-disjoint" declarations in future versions.

Summary updated

Abstract

We present an updated version of fosf, a reasoner for fuzzy order-sorted feature (OSF) logic, with support for flexible SPARQL query answering over RDF knowledge graphs. Fuzzy OSF logic is a knowledge representation and reasoning language where feature symbols denote functions and sort symbols denote fuzzy sets. Sorts are organized in a fuzzy subsumption relation that extends to OSF terms, record-like structures representing classes of entities. The unification algorithm for these structures provides a calculus of fuzzy type subsumption. The latest release of fosf introduces support for similarity-based reasoning by extending the OSF language with a similarity relation among sorts, alongside a translation engine for compiling OSF terms into standard SPARQL. Queries expressed as OSF terms undergo fuzzy ontology-aware rewriting prior to translation. This process incorporates an OSF theory of sort definitions, feature domain and range declarations, and fuzzy subsumption and similarity relations through fuzzy OSF constraint normalization. This rewriting enables flexible query answering by returning approximate solutions, allowing queries that would otherwise be inconsistent with the underlying ontology to yield relevant results.
BibTeX
@misc{milanese2026similarity,
  author = {Gian Carlo Milanese and Gabriella Pasi},
  title = {{Similarity-based OSF Logic for Flexible SPARQL Query Answering}},
  year = {2026},
  eprint = {2611.26261},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.26261},
}
Figure