Skip to content

owl2rl: literals derived through rdfs:subPropertyOf lose their language tag, and values that differ only by language merge #2273

Open

Description

@bplatz

With "reasoning": "owl2rl", a literal derived through rdfs:subPropertyOf (rule prp-spo1) loses its language tag. It comes back as rdf:langString with no language. Two derived values that differ only by language merge into one row.

Reproduced on next. main has the same code.

Reproduction

{
  "@context": {
    "ex": "http://example.org/",
    "owl": "http://www.w3.org/2002/07/owl#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#"
  },
  "@graph": [
    {"@id": "ex:altLabel", "@type": "owl:DatatypeProperty", "rdfs:subPropertyOf": {"@id": "ex:label"}},
    {"@id": "ex:otherLabel", "@type": "owl:DatatypeProperty", "rdfs:subPropertyOf": {"@id": "ex:name"}},
    {"@id": "ex:nickLabel", "@type": "owl:DatatypeProperty", "rdfs:subPropertyOf": {"@id": "ex:name"}},
    {"@id": "ex:bob",
     "ex:label": {"@value": "a", "@language": "fr"},
     "ex:altLabel": {"@value": "a", "@language": "en"},
     "ex:otherLabel": {"@value": "b", "@language": "en"},
     "ex:nickLabel": {"@value": "b", "@language": "de"}}
  ]
}

Run this query once with ex:label and once with ex:name as the property:

{
  "@context": {"ex": "http://example.org/"},
  "select": ["?l", "?lang"],
  "where": [{"@id": "ex:bob", "ex:label": "?l"}, ["bind", "?lang", "(lang ?l)"]],
  "reasoning": "owl2rl"
}

ex:label

  • Expected: "a"@fr and "a"@en.
  • Actual: "a"@fr, plus {"@value": "a", "@type": "rdf:langString"} with lang = "".

ex:name

  • Expected: "b"@en and "b"@de.
  • Actual: one row, {"@value": "b", "@type": "rdf:langString"} with lang = "".

Cause

There are two causes, and they compound:

  1. The rule drops the fact's metadata. fire_sub_property in fluree-db-reasoner/src/execute/property_rules.rs builds the derived flake with m: None. That metadata holds the language tag and the list position, so a derived literal keeps the rdf:langString datatype but loses its language.
  2. Deduplication ignores part of the object. DerivedSet in fluree-db-reasoner/src/execute/derived.rs keys facts by (s, p, hash(value)). try_add, contains and register_base all use that key, and it leaves out the datatype, the language tag and the list position. Values that differ only in those are treated as one fact.

Scope

  • Checked, not affected:
    • sameAs canonicalization (execute/util.rs) copies m;
    • the symmetric, transitive and inverse rules move IRIs only.
  • Inferred from the code, not reproduced:
    • a list position is dropped the same way;
    • values that differ only by datatype, such as 1 as xsd:int and 1 as xsd:long, would merge through the same key.
  • Not checked: datalog rule heads.

Activity

  1. added
    bug
    P1
    area:datalog
    on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1area:datalogbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions