Manuscript Offprint
arXiv:2611.26261Similarity-based OSF Logic for Flexible SPARQL Query Answering
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
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.
keywords
RDF knowledge graphs ,SPARQL ,Similarity-based reasoning ,Order-sorted feature logic ,Query rewriting
Background
OSF logic is a knowledge representation and reasoning language introduced by Aït-Kaci Aït-Kaci (1984); Aït-Kaci and Podelski (1993). It is based on sorts, which represent classes of objects, and features, which represent functional attributes. Sorts are organized in a subsumption relation that extends to OSF terms, record-like structures representing classes of entities and their constraints. Reasoning with OSF logic is based on the normalization (or unification) of OSF terms, a procedure that aims to combine the constraints expressed by one or more terms while taking the sort hierarchy into account. OSF logic is at the basis of CEDAR Amir and Aït-Kaci (2017), a Semantic Web reasoner that normalizes and optimizes queries expressed as OSF terms before translating them into SPARQL, possibly leading to more efficient retrieval.
Fuzzy OSF logic Milanese and Pasi (2024a) extends OSF logic by interpreting sorts and OSF terms as fuzzy sets, and by generalizing the sort subsumption to a fuzzy subsumption relation among sorts, which is then extended to OSF terms. The core reasoning algorithms of fuzzy OSF logic are implemented in the fosf Python library Milanese and Pasi (2026), which supports fuzzy taxonomic reasoning, subsumption degree computation, and fuzzy normalization and unification of OSF terms.
Contributions.
The new release of fosf introduces the following features: (i) support for a similarity relation between sorts, which is integrated into the main reasoning algorithms of fuzzy OSF logic, enabling similarity-based reasoning with OSF logic Milanese and Pasi (2024b); (ii) support for feature domain and range declarations during OSF term normalization; (iii) querying RDF KGs through the translation of normalized OSF queries into standard SPARQL. The normalization exploits fuzzy sort subsumption and sort similarity relations to relax incompatible constraints and retrieve approximate solutions.
Related work.
Implementations of (crisp) OSF logic include the constraint logic programming language LIFE Aït-Kaci (1993) and the CEDAR Semantic Web reasoner Amir and Aït-Kaci (2017). Closely related formalisms include description logics (DLs) and fuzzy DLs, which are supported by several reasoners (e.g., Tsarkov and Horrocks (2006); Shearer et al. (2008); Sirin et al. (2007); Stoilos et al. (2006); Bobillo and Straccia (2016)). The similarities and differences between OSF logic and DLs have been studied extensively Nebel and Smolka (1990); Nebel and Smolka (1991); Aït-Kaci (2007); Krieger and Schäfer (2010). Similarity-based OSF logic is inspired by fuzzy unification in fuzzy logic programming, where unification is guided by similarity or proximity relations (e.g., Gerla and Sessa (1999); Sessa (2002); Julián-Iranzo and Sáenz-Pérez (2021); Kutsia and Pau (2020); Aït-Kaci and Pasi (2020)); implementations include BousiProlog Julián-Iranzo and Sáenz-Pérez (2023) and FASILL Julián-Iranzo et al. (2020). In the Semantic Web community, various approaches handle imprecise or flexible querying over RDF data, including fuzzy SPARQL extensions (e.g., Cheng et al. (2010); Almendros-Jiménez et al. (2024)) and query relaxation techniques (e.g., Fakih and Serrano-Alvarado (2024)). In this context, fosf applies similarity-based normalization at the OSF logic level before compiling the resulting query terms into standard SPARQL.
2 Similarity-based OSF Taxonomic Reasoning
⬇
from fosf.parsers import parse_taxonomy
sim_tax_str = """
#␣Subsumption␣declarations
institution,␣person␣<␣top␣.
research_center␣<␣institution␣.
university␣<␣research_center␣.
researcher,␣lecturer,␣teacher␣<␣person␣.
professor␣<␣researcher,␣lecturer␣.
#␣Similarity␣declarations
teacher␣~␣lecturer␣=␣0.5␣."""
sim_tax = parse_taxonomy(sim_tax_str)
(a) Parsing subsumption and similarity relations.
{\color[rgb]{0.06,0.22,0.61}\top}$${\color[rgb]{0.06,0.22,0.61}university}$${\color[rgb]{0.06,0.22,0.61}research\_center}$${\color[rgb]{0.06,0.22,0.61}institution}$${\color[rgb]{0.06,0.22,0.61}professor}$${\color[rgb]{0.06,0.22,0.61}researcher}$${\color[rgb]{0.06,0.22,0.61}lecturer}$${\color[rgb]{0.06,0.22,0.61}teacher}$${\color[rgb]{0.06,0.22,0.61}person}$${\color[rgb]{0,0.65,0.2}0.5}$${\color[rgb]{1,0,0}0.5}
(b) Graphical representation.
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 {\color[rgb]{0.06,0.22,0.61}\bot} is omitted). After parsing, the two relations are combined into a single fuzzy subsumption \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.9106pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.9106pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.71881pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.43593pt}{\scriptscriptstyle\cdot}}}}} (black edges and dashed red edges).
At the core of OSF logic is a sort taxonomy, a finite set of sort symbols {\color[rgb]{0.06,0.22,0.61}\mathcal{S}} that is ordered in a lattice ({\color[rgb]{0.06,0.22,0.61}\mathcal{S}},\preceq,\curlywedge) with top element {\color[rgb]{0.06,0.22,0.61}\top} and bottom element {\color[rgb]{0.06,0.22,0.61}\bot}. Similarity-based OSF logic Milanese and Pasi (2024b) extends the sort taxonomy with a similarity relation on sort symbols, that is, a fuzzy binary relation \sim:{\color[rgb]{0.06,0.22,0.61}\mathcal{S}}\times{\color[rgb]{0.06,0.22,0.61}\mathcal{S}}\to[0,1] which satisfies reflexivity, symmetry and transitivity. As described in Milanese and Pasi (2024b), the information provided by the sort subsumption and the similarity can be combined into a single fuzzy subsumption relation \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}}:{\color[rgb]{0.06,0.22,0.61}\mathcal{S}}\times{\color[rgb]{0.06,0.22,0.61}\mathcal{S}}\to[0,1], according to the following informal inference, inspired by the similarity-based approaches to logic programming (e.g., Sessa (2002)):
| if the sort {\color[rgb]{0.06,0.22,0.61}{s_{0}}} is subsumed by the sort {\color[rgb]{0.06,0.22,0.61}{s_{1}}} | (i.e., {\color[rgb]{0.06,0.22,0.61}{s_{0}}}\preceq{\color[rgb]{0.06,0.22,0.61}{s_{1}}}) |
|---|---|
| and {\color[rgb]{0.06,0.22,0.61}{s_{1}}} is similar to the sort {\color[rgb]{0.06,0.22,0.61}{s_{2}}} with degree | (i.e., \mathop{\sim}({\color[rgb]{0.06,0.22,0.61}{s_{1}}},{\color[rgb]{0.06,0.22,0.61}{s_{2}}})=\alpha) |
| then {\color[rgb]{0.06,0.22,0.61}{s_{0}}} is subsumed by {\color[rgb]{0.06,0.22,0.61}{s_{2}}} with degree | (i.e., \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}}({\color[rgb]{0.06,0.22,0.61}{s_{0}}},{\color[rgb]{0.06,0.22,0.61}{s_{2}}})=\alpha). |
For example, if {\color[rgb]{0.06,0.22,0.61}professor}s are {\color[rgb]{0.06,0.22,0.61}lecturer}s, and {\color[rgb]{0.06,0.22,0.61}lecturer}s are similar to {\color[rgb]{0.06,0.22,0.61}teacher}s with degree , then we can conclude that {\color[rgb]{0.06,0.22,0.61}professor}s are also {\color[rgb]{0.06,0.22,0.61}teacher}s with subsumption degree . As shown in Milanese and Pasi (2024b), the resulting fuzzy subsumption relation is a fuzzy lattice ({\color[rgb]{0.06,0.22,0.61}\mathcal{S}},\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}},\curlywedgedot), a fuzzy binary relation that satisfies reflexivity, transitivity and strong antisymmetry, and such that a GLB {\color[rgb]{0.06,0.22,0.61}{s_{0}}}\curlywedgedot{\color[rgb]{0.06,0.22,0.61}{s_{1}}} exists for every {\color[rgb]{0.06,0.22,0.61}{s_{0}}},{\color[rgb]{0.06,0.22,0.61}{s_{1}}}\in{\color[rgb]{0.06,0.22,0.61}\mathcal{S}}.
As shown in Fig. 1, fosf supports parsing a sort subsumption relation and a sort similarity relation and combining them in a single fuzzy subsumption relation \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}}. Cycle detection is performed to ensure that the resulting fuzzy subsumption \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}} is antisymmetric, possibly merging each sort cycle into a single disjunctive set of sorts, according to Milanese and Pasi (2024b). When the resulting fuzzy relation \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}} is not a (fuzzy) lattice, but simply a partial order, fosf works on a completion of \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}} that does not need to be explicitly computed. By employing the graph encoding technique of Aït-Kaci et al. (1989) and optimized weighted graph traversal of Milanese and Pasi (2021), it is possible to efficiently compute the GLB {\color[rgb]{0.06,0.22,0.61}{s_{0}}}\curlywedgedot{\color[rgb]{0.06,0.22,0.61}{s_{1}}} and the subsumption degree \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}}({\color[rgb]{0.06,0.22,0.61}{s_{0}}},{\color[rgb]{0.06,0.22,0.61}{s_{1}}}) of two sorts {\color[rgb]{0.06,0.22,0.61}{s_{0}}} and {\color[rgb]{0.06,0.22,0.61}{s_{1}}} Milanese and Pasi (2026). For instance, {\color[rgb]{0.06,0.22,0.61}teacher}\curlywedgedot{\color[rgb]{0.06,0.22,0.61}researcher}={\color[rgb]{0.06,0.22,0.61}professor} and \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}}({\color[rgb]{0.06,0.22,0.61}professor},{\color[rgb]{0.06,0.22,0.61}teacher})=0.5.
3 Similarity-based OSF Term Normalization
⬇
from fosf.parsers import parse_term
from fosf.reasoning import normalize_term
Normalizing an OSF term according to subsumption + similarity only
t_str = "X0:person(teach_at␣->␣X1:institution,␣research_at␣->␣X1:research_center)"
t = parse_term(t_str)
print(normalize_term(t, sim_tax))
Output: X0 : person(teach_at -> X1 : research_center, research_at -> X1)
Figure 2: Normalizing an OSF term in fosf.
⬇
from fosf.parsers import parse_theory
theory_str = sim_tax_str + """
professor␣␣␣␣␣␣␣␣␣␣␣:=␣Yp:professor(research_at␣->␣Y1:university)␣.
domain(teach_at)␣␣␣␣:=␣teacher␣.
domain(research_at)␣:=␣researcher␣."""
theory = parse_theory(theory_str, ensure_closed=True)
Normalizing an OSF term also according to the theory
nt, degree = normalize_term(t, sim_tax, theory, return_degree=True)
print(degree, nt)
Output: 0.5 X0 : professor(teach_at -> X1 : university, research_at -> X1)
Figure 3: Normalizing an OSF term modulo an OSF theory in fosf.
Sort symbols may be used with variables (also called tags) {\color[rgb]{0.72,0.1,0.26}X_{0}},{\color[rgb]{0.72,0.1,0.26}X_{1}}\ldots\in{\color[rgb]{0.72,0.1,0.26}\mathcal{V}} and features symbols {\color[rgb]{0,0.45,0}f_{0}},\ldots,{\color[rgb]{0,0.45,0}f_{n}}\in{\color[rgb]{0,0.45,0}\mathcal{F}} to build OSF terms. These are record-like representations of (fuzzy) sets of objects, such as t={\color[rgb]{0.72,0.1,0.26}X_{0}}:{\color[rgb]{0.06,0.22,0.61}person}({\color[rgb]{0,0.45,0}teach\_at}\to{\color[rgb]{0.72,0.1,0.26}X_{1}}:{\color[rgb]{0.06,0.22,0.61}institution},{\color[rgb]{0,0.45,0}research\_at}\to{\color[rgb]{0.72,0.1,0.26}X_{1}}:{\color[rgb]{0.06,0.22,0.61}research\_center}), which denotes the class of people that teach at some institution {\color[rgb]{0.72,0.1,0.26}X_{1}} and carry out research at the same {\color[rgb]{0.72,0.1,0.26}X_{1}}, which is also a research center. In general, OSF terms may include redundant, or even contradictory, information (e.g., the sort of {\color[rgb]{0.72,0.1,0.26}X_{1}} is specified twice in ). OSF terms that are well-behaved to this regard are called normal OSF terms or -terms Aït-Kaci and Podelski (1993), and they are also denoted , , and so on. The fosf reasoner supports normalizing OSF terms according to a sort subsumption relation and similarity : as shown in Fig. 2, the term can be normalized to {\color[rgb]{0.06,0.22,0.61}person}({\color[rgb]{0,0.45,0}teach\_at}\to{\color[rgb]{0.72,0.1,0.26}X_{1}}:{\color[rgb]{0.06,0.22,0.61}research\_center},{\color[rgb]{0,0.45,0}research\_at}\to{\color[rgb]{0.72,0.1,0.26}X_{1}}), where the sort of {\color[rgb]{0.72,0.1,0.26}X_{1}} is simplified to {\color[rgb]{0.06,0.22,0.61}research\_center}={\color[rgb]{0.06,0.22,0.61}research\_center}.
The fosf reasoner also supports the normalization of OSF terms modulo an OSF theory of sort definitions and feature domain and range declarations. Sort definitions associate each sort {\color[rgb]{0.06,0.22,0.61}s} with a normal term \Theta({\color[rgb]{0.06,0.22,0.61}s})=\psi such that \Theta({\color[rgb]{0.06,0.22,0.61}\bot})={\color[rgb]{0.06,0.22,0.61}\bot}, \Theta({\color[rgb]{0.06,0.22,0.61}\top})={\color[rgb]{0.06,0.22,0.61}\top}, and the root sort of \Theta({\color[rgb]{0.06,0.22,0.61}s}) is {\color[rgb]{0.06,0.22,0.61}s} for all {\color[rgb]{0.06,0.22,0.61}s}\in{\color[rgb]{0.06,0.22,0.61}\mathcal{S}} Aït-Kaci et al. (1997). Intuitively, the sort definition \Theta({\color[rgb]{0.06,0.22,0.61}s}) specifies structural constraints that each OSF term of type {\color[rgb]{0.06,0.22,0.61}s} should satisfy. Feature domain and range declarations have shape \mathop{\mathit{domain}}({\color[rgb]{0,0.45,0}f})={\color[rgb]{0.06,0.22,0.61}{s_{0}}} and \mathop{\mathit{range}}({\color[rgb]{0,0.45,0}f})={\color[rgb]{0.06,0.22,0.61}{s_{1}}}, and they ensure that, whenever t^{\prime}={\color[rgb]{0.72,0.1,0.26}X}:{\color[rgb]{0.06,0.22,0.61}\top}({\color[rgb]{0,0.45,0}f}\to{\color[rgb]{0.72,0.1,0.26}Y}:{\color[rgb]{0.06,0.22,0.61}\top}) is an OSF term, then {\color[rgb]{0.72,0.1,0.26}X} must be of sort {\color[rgb]{0.06,0.22,0.61}{s_{0}}} and {\color[rgb]{0.72,0.1,0.26}Y} must be of sort {\color[rgb]{0.06,0.22,0.61}{s_{1}}}. Overall, the (fuzzy) sort subsumption and similarity relations, the sort definitions, and the feature domain and range declarations constitute the ontological component according to which an OSF term can be normalized. Fig. 3 shows an example of parsing an OSF theory in fosf and normalizing the OSF term according to the theory. In the example, the domain declarations for the features {\color[rgb]{0,0.45,0}teach\_at} and {\color[rgb]{0,0.45,0}research\_at} enforce the tag {\color[rgb]{0.72,0.1,0.26}X_{0}} to be of sort {\color[rgb]{0.06,0.22,0.61}teacher}\curlywedgedot{\color[rgb]{0.06,0.22,0.61}researcher}={\color[rgb]{0.06,0.22,0.61}professor}, and the sort definition for {\color[rgb]{0.06,0.22,0.61}professor} thus enforces {\color[rgb]{0.72,0.1,0.26}X_{1}} to be a {\color[rgb]{0.06,0.22,0.61}university}. The constraints imposed by an OSF theory may be satisfied up to a degree . For instance, in the term nt of Fig. 3, {\color[rgb]{0.72,0.1,0.26}X_{0}} is of sort {\color[rgb]{0.06,0.22,0.61}professor} rather than {\color[rgb]{0.06,0.22,0.61}teacher} (as required by the domain of {\color[rgb]{0,0.45,0}teach\_at}) so that nt satisfies the OSF theory with degree \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}}({\color[rgb]{0.06,0.22,0.61}professor},{\color[rgb]{0.06,0.22,0.61}teacher})=0.5. Note that, without the fuzzy subsumption \mathop{\mathbin{\mathrel{\mathchoice{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\displaystyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.96873pt}{\textstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.76855pt}{\scriptstyle\cdot}}{{\preceq}\mkern-5.0mu\raisebox{0.59201pt}{\scriptscriptstyle\cdot}}}}}({\color[rgb]{0.06,0.22,0.61}professor},{\color[rgb]{0.06,0.22,0.61}teacher}) induced by {\color[rgb]{0.06,0.22,0.61}professor}\preceq{\color[rgb]{0.06,0.22,0.61}lecturer} and \mathop{\sim}({\color[rgb]{0.06,0.22,0.61}lecturer},{\color[rgb]{0.06,0.22,0.61}teacher}), the GLB of {\color[rgb]{0.06,0.22,0.61}teacher} and {\color[rgb]{0.06,0.22,0.61}researcher} would instead be {\color[rgb]{0.06,0.22,0.61}\bot}, and the normalization of would fail.
4 Similarity-based OSF for SPARQL Query Answering
The fosf reasoner supports translating a (normalized) OSF term into SPARQL for instance retrieval over an RDF KG. This translation is inspired by the query rewriting pipeline of CEDAR Amir and Aït-Kaci (2017), in which an OSF term query is preprocessed to ensure consistency and to potentially reduce the retrieval search space before generating a SPARQL query. The fosf library extends this framework by integrating sort definitions and the sort similarity relation into the normalization, enabling similarity-based query rewriting. Without the sort similarity, queries violating ontological constraints would be declared inconsistent and return no results. Instead, fosf can rewrite OSF terms into queries that approximately satisfy the OSF theory to some degree, thus enabling the retrieval of approximate solutions.
SELECT ?X0 WHERE { ?X0 rdf:type :person . ?X0 :teach_at ?X1 . ?X0 :research_at ?X1 . ?X1 rdf:type :institution . ?X1 rdf:type :research_center . }
(a) SPARQL query before fuzzy OSF normalization.
SELECT ?X0 WHERE { ?X0 rdf:type :professor . ?X0 :teach_at ?X1 . ?X0 :research_at ?X1 . ?X1 rdf:type :university . }
(b) SPARQL query after fuzzy OSF normalization.
Figure 4: SPARQL queries corresponding to the OSF term , before and after normalization.
Consider again the query term t={\color[rgb]{0.72,0.1,0.26}?X_{0}}:{\color[rgb]{0.06,0.22,0.61}person}({\color[rgb]{0,0.45,0}teach\_at}\to{\color[rgb]{0.72,0.1,0.26}X_{1}}:{\color[rgb]{0.06,0.22,0.61}institution},{\color[rgb]{0,0.45,0}research\_at}\to{\color[rgb]{0.72,0.1,0.26}X_{1}}:{\color[rgb]{0.06,0.22,0.61}research\_center}), where {\color[rgb]{0.72,0.1,0.26}X_{0}} is marked with a question mark to denote instance retrieval. Under standard OSF normalization, is inconsistent because {\color[rgb]{0.06,0.22,0.61}teacher}\curlywedge{\color[rgb]{0.06,0.22,0.61}researcher}={\color[rgb]{0.06,0.22,0.61}\bot}, as discussed in Section 3. Translating directly to SPARQL without normalizing ignores the ontology entirely, yielding the query in Fig. 4(a), which fails to enforce domain/range semantics and sort definitions. In contrast, by taking into account fosf normalizes to {\color[rgb]{0.72,0.1,0.26}X_{0}}:{\color[rgb]{0.06,0.22,0.61}professor}({\color[rgb]{0,0.45,0}teach\_at}\to{\color[rgb]{0.72,0.1,0.26}X_{1}}:{\color[rgb]{0.06,0.22,0.61}university},{\color[rgb]{0,0.45,0}research\_at}\to{\color[rgb]{0.72,0.1,0.26}X_{1}}), deriving an approximate solution that satisfies the OSF theory with a degree of (Fig. 3). Fig. 4(b) shows the resulting SPARQL translation. Providing approximate solutions for otherwise inconsistent queries can be desirable in many scenarios. For example, users often do not possess full knowledge of extensive ontologies, making an inconsistent result potentially surprising. Moreover, the inconsistency of arises from the closed-world assumption of OSF logic, where {\color[rgb]{0.06,0.22,0.61}teacher}\curlywedge{\color[rgb]{0.06,0.22,0.61}researcher}={\color[rgb]{0.06,0.22,0.61}\bot} forces disjointness of the two sorts. Relaxing this requirement can be valuable in contexts where this assumption does not hold, such as settings where domain knowledge can evolve.
From a practical standpoint, fosf handles OSF query parsing, normalization, and translation to SPARQL. Base IRIs and prefixes can be specified prior to an OSF theory or query using Turtle-like syntax (e.g., @base<IRI> . @prefix : <IRI> .). The syntax for OSF theories (including subsumption and similarity declarations) and OSF terms supports base sorts like {\color[rgb]{0.06,0.22,0.61}person} (resolved via the base IRI), as well as absolute IRIs (e.g., http://example.org/person) and prefixed names (e.g., ex:person). The query generated by fosf can be executed over in-memory RDF graphs or remote SPARQL endpoints using the rdflib and SPARQLWrapper libraries, or sent to any standard SPARQL query engine.
5 Demo Interface

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.
We provide an interactive Web interface designed to demonstrate the query normalization and execution pipeline of fosf. As shown in Fig. 5, users can specify custom OSF theories, target RDF KGs, and OSF queries directly in the browser, or select from a list of pre-defined examples. The interface can visually render the sort subsumption hierarchy, the sort similarity relation, and the resulting fuzzy subsumption relation. Users can inspect the generated SPARQL queries and execute them directly against the RDF KG to view retrieved instances alongside the approximation degree of the normalized query. Two global toggles, for OSF query normalization and sort similarity, allow users to compare OSF terms, generated SPARQL queries, and retrieval results with or without normalization and similarity-based reasoning.
6 Conclusion and Future Work
We have presented an updated release of fosf, extending fuzzy OSF logic with similarity-based reasoning and ontology-aware SPARQL query generation. By integrating a sort similarity relation into constraint normalization, fosf enables flexible query rewriting, deriving approximate solutions for queries that would otherwise be declared inconsistent under strict ontological constraints.
While the current release of fosf provides a functional prototype, several limitations present avenues for future development. Regarding performance, we are replacing the pure-Python reasoning core with a C++ engine to improve execution speed and memory efficiency. To address the closed-world assumption of OSF logic, where two sorts {\color[rgb]{0.06,0.22,0.61}{s_{0}}} and {\color[rgb]{0.06,0.22,0.61}{s_{1}}} are treated as disjoint whenever {\color[rgb]{0.06,0.22,0.61}{s_{0}}}\curlywedgedot{\color[rgb]{0.06,0.22,0.61}{s_{1}}}={\color[rgb]{0.06,0.22,0.61}\bot}, we plan to allow declarations of non-disjoint sorts within sort taxonomies, without the need to explicitly name their GLB. Furthermore, we intend to improve the expressiveness of fosf by extending support for disjunctive sorts and terms in both theories and queries, as well as enabling sort instances in OSF query expressions. Finally, in addition to manually defined similarity relations, we plan to support automated similarity estimation using techniques such as vector embeddings.
Acknowledgements.
The authors express their gratitude and a fond thought to Hassan Aït-Kaci, who with Gabriella Pasi set out to define a fuzzy version of OSF logic. Our development of fuzzy OSF logic originates from their work on the definition of similarity-based unification for OSF terms, extending the approach of Aït-Kaci and Pasi (2020). We also wish to thank Marco Braga and Stefano Molari for their help in setting up the online demonstration system.
Declaration on Generative AI
During the preparation of this work, the author(s) used ChatGPT, Gemini in order to: Grammar and spelling check. After using these tools, the authors reviewed and edited the content as needed and take full responsibility for the publication’s content.
References
H. Aït-Kaci and S. Amir Classifying and querying very large taxonomies. Technical report LIRIS, Département d’Informatique, Université Claude Bernard Lyon 1, Villeurbanne, France. Note: CEDAR Technical Report Number 2, CEDAR Project External Links: Link Cited by: footnote 4.
H. Aït-Kaci, R. Boyer, P. Lincoln, and R. Nasr Efficient implementation of lattice operations. ACM Trans. Program. Lang. Syst. 11 (1), pp. 115–146. External Links: ISSN 0164-0925, Document Cited by: §2.
H. Aït-Kaci and G. Pasi Fuzzy lattice operations on first-order terms over signatures with similar constructors: a constraint-based approach. Fuzzy Sets and Systems 391, pp. 1–46. External Links: ISSN 0165-0114, Document Cited by: §1, §6.
H. Aït-Kaci, A. Podelski, and S. C. Goldstein Order-sorted feature theory unification. The Journal of Logic Programming 30 (2), pp. 99–124. External Links: ISSN 0743-1066, Document Cited by: §3.
H. Aït-Kaci and A. Podelski Towards a meaning of life. The Journal of Logic Programming 16 (3), pp. 195–234. External Links: ISSN 0743-1066, Document Cited by: §1, §3.
H. Aït-Kaci A lattice theoretic approach to computation based on a calculus of partially ordered type structures. Ph.D. Thesis, University of Pennsylvania. External Links: Link Cited by: §1.
H. Aït-Kaci An introduction to LIFE-programming with logic, inheritance, functions, and equations. In Proceedings of the 1993 International Symposium on Logic Programming, ILPS ’93, Cambridge, MA, USA, pp. 52–68. External Links: ISBN 0262631520, Link Cited by: §1.
H. Aït-Kaci Data models as constraint systems: a key to the semantic web. Constraint Processing Letters 1. External Links: Link Cited by: §1.
J. M. Almendros-Jiménez, A. Becerra-Terón, G. Moreno, and J. A. Riaza Tuning fuzzy sparql queries. International Journal of Approximate Reasoning 170, pp. 109209. External Links: ISSN 0888-613X, Document Cited by: §1.
S. Amir and H. Aït-Kaci An efficient and large-scale reasoning method for the semantic web. J. Intell. Inf. Syst. 48 (3), pp. 653–674. External Links: ISSN 0925-9902, Document Cited by: §1, §1, §4.
F. Bobillo and U. Straccia Optimising fuzzy description logic reasoners with general concept inclusion absorption. Fuzzy Sets and Systems 292, pp. 98–129. Note: Special Issue in Honor of Francesc Esteva on the Occasion of his 70th Birthday External Links: ISSN 0165-0114, Document Cited by: §1.
J. Cheng, Z. M. Ma, and L. Yan F-sparql: a flexible extension of sparql. In Database and Expert Systems Applications, P. G. Bringas, A. Hameurlain, and G. Quirchmayr (Eds.), Berlin, Heidelberg, pp. 487–494. External Links: Document, ISBN 978-3-642-15364-8 Cited by: §1.
G. Fakih and P. Serrano-Alvarado A survey on sparql query relaxation under the lens of rdf reification. Semantic Web 15 (6), pp. 2507–2554. External Links: Document Cited by: §1.
G. Gerla and M. I. Sessa Similarity in logic programming. In Fuzzy Logic and Soft Computing, G. Chen, M. Ying, and K. Cai (Eds.), pp. 19–31. External Links: ISBN 978-1-4615-5261-1, Document Cited by: §1.
P. Julián-Iranzo, G. Moreno, and J. A. Riaza The Fuzzy Logic Programming language FASILL: Design and implementation. International Journal of Approximate Reasoning 125, pp. 139–168. External Links: ISSN 0888-613X, Document Cited by: §1.
P. Julián-Iranzo and F. Sáenz-Pérez Proximity-Based Unification: An Efficient Implementation Method. IEEE Transactions on Fuzzy Systems 29 (5), pp. 1238–1251. External Links: Document Cited by: §1.
P. Julián-Iranzo and F. Sáenz-Pérez BousiProlog: Design and implementation of a proximity-based fuzzy logic programming language. Expert Systems with Applications 213, pp. 118858. External Links: ISSN 0957-4174, Document Cited by: §1.
H. Krieger and U. Schäfer DL Meet FL: A Bidirectional Mapping between Ontologies and Linguistic Knowledge. In Coling 2010: Posters, C. Huang and D. Jurafsky (Eds.), Beijing, China, pp. 588–596. External Links: Link Cited by: §1.
T. Kutsia and C. Pau Solving Proximity Constraints. In Logic-Based Program Synthesis and Transformation, M. Gabbrielli (Ed.), Cham, pp. 107–122. External Links: ISBN 978-3-030-45260-5, Document Cited by: §1.
G. C. Milanese and G. Pasi Conjunctive Reasoning on Fuzzy Taxonomies with Order-Sorted Feature Logic. In 2021 IEEE International Conference on Fuzzy Systems (FUZZ-IEEE), Vol. , pp. 1–7. External Links: Document Cited by: §2.
G. C. Milanese and G. Pasi Fuzzy order-sorted feature logic. Fuzzy Sets and Systems 477, pp. 108800. External Links: ISSN 0165-0114, Document Cited by: §1.
G. C. Milanese and G. Pasi Similarity-Based Reasoning with Order-Sorted Feature Logic. IEEE Transactions on Fuzzy Systems 32 (5), pp. 2797–2810. External Links: Document Cited by: §1, §2, §2, §2, footnote 2, footnote 4.
G. C. Milanese and G. Pasi Implementing fuzzy osf logic unification and normalization (short paper). In Automated Reasoning, A. Biere, C. Lutz, and S. Negri (Eds.), Cham, pp. 368–377. External Links: ISBN 978-3-032-32592-1, Document, Link Cited by: §1, §2.
B. Nebel and G. Smolka Representation and reasoning with attributive descriptions. In Sorts and Types in Artificial Intelligence, K. H. Bläsius, U. Hedtstück, and C. Rollinger (Eds.), Berlin, Heidelberg, pp. 111–139. External Links: ISBN 978-3-540-46965-0, Document Cited by: §1.
B. Nebel and G. Smolka Attributive description formalisms… and the rest of the world. In Text Understanding in LILOG: Integrating Computational Linguistics and Artificial Intelligence Final Report on the IBM Germany LILOG-Project, O. Herzog and C. Rollinger (Eds.), pp. 439–452. External Links: ISBN 978-3-540-38493-9, Document Cited by: §1.
M. I. Sessa Approximate reasoning by similarity-based SLD resolution. Theoretical Computer Science 275 (1), pp. 389–426. External Links: ISSN 0304-3975, Document, Link Cited by: §1, §2.
R. Shearer, B. Motik, and I. Horrocks HermiT: A Highly-Efficient OWL Reasoner. In OWL: Experiences and Directions, External Links: Link Cited by: §1.
E. Sirin, B. Parsia, B. C. Grau, A. Kalyanpur, and Y. Katz Pellet: A practical OWL-DL reasoner. Journal of Web Semantics 5 (2), pp. 51–53. External Links: ISSN 1570-8268, Document Cited by: §1.
G. Stoilos, N. Simou, G. Stamou, and S. Kollias Uncertainty and the Semantic Web. IEEE Intelligent Systems 21 (5), pp. 84–87. External Links: Document Cited by: §1.
D. Tsarkov and I. Horrocks FaCT++ Description Logic Reasoner: System Description. In Automated Reasoning, U. Furbach and N. Shankar (Eds.), Berlin, Heidelberg, pp. 292–297. External Links: ISBN 978-3-540-37188-5, Document Cited by: §1.