Repository navigation
Conversation
With --no-use-native-uris gen-owl declares a slot's property under its slot_uri, but it stated the restrictions that come from a slot_usage or slot_conditions entry on an IRI derived from the slot's name. Such an entry names a slot and holds only what it adds, so it carries no slot_uri. The restrictions of class-level boolean expressions, of rule and classification-rule conditions, of range expressions, and of slot_usage on an inherited slot were therefore on properties the ontology does not declare, such as ex:note where the slot is skos:note, which OWL 2 DL does not allow (Structural Specification 5.8.1). The restriction now takes the slot_uri of the slot that the entry names in the class the condition is about: the class that states the expression, the class a rule's expression names with is_a, or, for a range expression, the class the slot ranges over. Two classes with an attribute of the same name each get their own property, and a name may be written in its underscored form. Only the slot_uri is taken from the named slot; the IRI derived from a slot's name is computed as before, so with native URIs, the default, the output is unchanged. The annotation-property check in the same loop reads the slot of the same class, so a like-named slot elsewhere no longer decides whether a condition is refused. Signed-off-by: jdsika <[email protected]>
jdsika
force-pushed
the
fix/owlgen-class-expression-slot-uri
branch
from
November 19, 2026 09:43
c054169 to
6db5772
Compare
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirror of linkml#4260, same head. Review there; this PR tracks the fork stack.
Summary
With
--no-use-native-uris, gen-owl declares a slot's property under itsslot_uribut states some restrictions on a different IRI, one derived from the slot's name. The ontology then restricts properties it never declares. With native URIs, the default, nothing changes.In plain words: a slot is declared once (
noteisskos:note). A class may later say something more about it: "in this classnoteis required", or "eithernoteis present or …". That later mention only names the slot. gen-owl looked for the IRI on the mention itself, found none, and made one up from the name. It now looks the slot up and uses the IRI it was declared with.Reproduce
restrict.yaml:main(e5ba58b4c)1 skos:note a owl:DatatypeProperty ;1 skos:note a owl:DatatypeProperty ;3 owl:onProperty skos:note .1 owl:onProperty ex:note .4 owl:onProperty skos:note .The one restriction on
ex:noteis the one from theany_of;ex:noteis declared nowhere in the output. Without--no-use-native-urisboth writeex:notethroughout, declaration included, and the output of this PR is byte-identical to that ofmain.Affected are all places where the generator handles a
slot_usageorslot_conditionsentry, which names a slot and holds only what it adds:slot_conditionsin a class'sany_of,all_of,none_of,exactly_one_of;rules, andclassification_rules;slot_conditionsin arange_expression;slot_usageon a slot the class inherits, also from a mixin.It is in the metamodel's own ontology too. On
main,gen-owl --no-use-native-uris packages/linkml_runtime/src/linkml_runtime/linkml_model/model/schema/meta.yamlrestrictslinkml:ucum_code,linkml:symbol,linkml:iec61360codeandlinkml:exact_mappings, while it declaresqudt:ucumCode,qudt:symbol,qudt:iec61360Codeandskos:exactMatch. With this PR no restriction there is on an undeclared property.Why this is wrong, not only untidy
owl:onProperty ex:noteis an object or a data restriction. Without it the restriction's triples match no pattern of the reverse mapping, which ends with "At the end of this process, the graph G MUST be empty" (OWL 2 Mapping to RDF Graphs §3.2).skos:note, the axiom is aboutex:note. Nothing relates the two, since IRIs are compared as strings (RDF 1.1 Concepts §3.2).The change
transform_class_expressionandtransform_class_slot_expressiontake the class whose slots the conditions name (owner): the class that states the expression, the class a rule's or classification rule's expression names withis_a(its axiom is about the instances of that class), or, for a range expression, the class the slot ranges over (the expression's ownrange, else the slot's range in its owner).slot_uriof the slot the entry names in that class. Two classes with an attribute of the same name each get their own property. A name may be written in its underscored form (exact_mappingsfor the slotexact mappings), asSchemaView.induced_slotaccepts it.slot_uriis taken from the named slot; the IRI derived from a slot's name is computed as before, and with native URIs the entry is used as it is.owner, which the generator passes on every recursive call. A subclass that overrides either with the previous signature must accept it; nothing in this repository does.SchemaView, becauseget_urireceives the bareslot_usageentry without its class; only the generator knows the class.How was this tested?
test_owlgen.py, 57 new tests:owl:onPropertyis a property the ontology declares; with--no-use-native-uriseach class's restrictions are on exactly the expectedslot_uris. The schemas cover boolean expressions (any_of,all_of,none_of,exactly_one_of, nested four operators deep),slot_usageof an inherited slot, of a mixin slot and of an inherited attribute, rule conditions, classification rules (also withis_anaming another class), range expressions (plain, over a class with a like-named attribute, inside a condition on a slot whose range the owner refines, onany_ofbranches with their own range, in nested slot expressions andall_members), same-named attributes in two classes, and a slot named in its underscored form.default_prefix, refined inslot_usageand named inslot_conditions: its restrictions stay on the property of the defining schema, in both modes.kitchen_sink.yaml, both modes: every restricted property is declared.rdfs:label, not refused where only another class's is.mainin both modes. They guard that default output and the restrictions on imported slots stay as they are.*.yamlin the repository (549 files; gen-owl generates from 409, the other 140 fail identically before and after), compared up to blank-node renaming:--no-use-native-uris: 401 identical, 8 differ (meta.yamlandunits.yaml, each in two places,biolink-model.yaml,container_test.yaml,validation_datamodel.yaml,__snapshots__/multi_usages_2.yaml). In all 8 the set of declared properties is unchanged, every difference moves a restriction from an undeclared property to a declared one, and none is left on an undeclared one; e.g. 504 in biolink frombiolink:subject/object/predicate/typetordf:subject/rdf:object/rdf:predicate/rdf:type.tests/linkmlas CI runs it: 12879 passed, no snapshot changed.Areas of uncertainty
any_of/all_ofoperand withis_a(any_of: [{is_a: A, slot_conditions: …}]) keeps the stating class as owner, since gen-owl does not emit thatis_a. With same-named attributes in the stating class and inA, the condition names the stating class's. Where the stating class has no such slot and several classes have an attribute of that name, the restriction stays on the name-derived IRI, which is not declared.slot_usagethat sets its ownslot_uriis restricted on that IRI, which the ontology does not declare. Unchanged for that class; a subclass that refines the slot further now follows it to the same IRI.unique_keysand the type designator still resolve their slots by name alone. Unchanged.Checklist