Repository navigation
Conversation
jdsika
force-pushed
the
fix/owlgen-any-of-property-kind
branch
from
November 25, 2026 15:54
dec9b7e to
e8a6622
Compare
gen-owl took the kind of a property from the range of its slot, or from the default range for a slot without one, and not from any_of or exactly_one_of. With a type as the default range, a slot whose any_of lists classes, or enums that are classes, was a data property with a union of classes as its range. A slot whose any_of lists a type and a class was a data property too, and its range and restrictions mixed a datatype and a class. The values of an object property are individuals and those of a data property are literals, and in OWL 2 DL an IRI is not both, so the OWL API reads such a property as both kinds and the datatype as a class. The kind of a property now comes from all ranges of its slot, those that gen-owl already collects for enums of literals: the ranges of its range, range_expression, any_of, all_of, exactly_one_of, none_of and all_members, or else the default range, and those of its has_member. A branch of any_of or exactly_one_of without a range, such as one with only a pattern, has the range of the expression it is in, or else that of the slot, or else the default range. Operands of all_of and none_of only narrow a slot and add no kind, and linkml:Any adds none beside other ranges, as the documentation of unions as ranges gives a slot the range Any and lists its ranges in any_of. A role that the slot declares with implements comes first; otherwise, if the values of each range are literals, the slot is a data property, and if they are IRIs or blank nodes, an object property. A slot without ranges, in a schema without a default range, keeps the kind that the classes that narrow it give it, and an enum that is a class, or a type under type_objects, now counts as nodes there, as a class does. Where OWL cannot state what the schema says, gen-owl now leaves it out and logs a warning. No OWL property has both literals and individuals as values, so a slot that ranges over both is an object property, as a slot of linkml:Any is, without a range, and classes do not restrict its values. A class that narrows a slot to values that its property cannot have, such as a slot of strings to a class, does not restrict it there. A slot whose range_expression, or that of its has_member or of an expression in it, has a condition that OWL cannot state has no range either. Of a class, an any_of or exactly_one_of with an operand that has such a condition is left out, as is a rule or classification rule with one, since leaving out only the condition could make the axiom stronger; of all_of and none_of, only the operand is left out. A class that refined a slot without giving a range restricted it to owl:Thing if the range of the slot is a class, and else to the default range, so to a datatype for a slot whose any_of lists classes or whose range is an enum that is a class. Such a slot now gets owl:Thing too. The expressions of exactly_one_of were given the types of the slot, which gen-owl records differently from those of their operands, so over data ranges they were untyped and their complements were complements of classes. They now take the types of their operands, as unions do, and complements and intersections pass their types on to the expressions that have them as operands, so over data ranges these are data ranges, with owl:datatypeComplementOf. An expression over an enum that is a class has the types of a class expression, as one over a class has, so its intersection with the data range of a constraint, such as equals_string_in, is no longer typed as a datatype. Refs linkml#1483 Signed-off-by: jdsika <carlo.van-driesten@vdl.digital>
jdsika
force-pushed
the
fix/owlgen-literal-enums
branch
from
November 25, 2026 16:48
bae0af3 to
d14debb
Compare
jdsika
force-pushed
the
fix/owlgen-any-of-property-kind
branch
from
November 25, 2026 16:48
e8a6622 to
0d80ae8
Compare
jdsika
force-pushed
the
fix/owlgen-any-of-property-kind
branch
from
November 26, 2026 10:42
0d80ae8 to
9d50bde
Compare
A slot without a range of its own took the kind of its property from the default range, so owner with is_a ref, where ref ranges over a class, became a data property that is a sub-property of an object property, which OWL 2 DL does not allow (OWL 2 9.2.1, 9.3.1). It now has the range it inherits through is_a and its mixins, as SchemaView.induced_slot gives it: of the metaslots that give ranges only range is inherited, from the first ancestor in slot_ancestors order that has one, and not by an attribute. A class's restriction of such a slot is filled with that range too, not with the default range, unless its values are IRIs or blank nodes, as those of uriorcurie, which no datatype has. In the snapshots of the metamodel and of biolink, the slots that inherit boolean or integer get these as fillers, not string. The OWL snapshots of kitchen_sink and of the metamodel were written anew, so their blank nodes were renumbered and nearly every line changed. They are now their previous version with only the triples that this change adds or removes; the snapshot tests compare them as graphs, up to blank-node renaming. Shorten the description of the ranges of a slot in owl.rst. Signed-off-by: jdsika <carlo.van-driesten@vdl.digital>
jdsika
force-pushed
the
fix/owlgen-any-of-property-kind
branch
from
November 26, 2026 11:04
9d50bde to
e1cb9e7
Compare
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#4280, same head. Review there; this PR tracks the fork stack.
Fork base is
fix/owlgen-literal-enums(linkml#4279), so this diff shows only this PR's two commits.Summary
gen-owl decides whether a slot is a data property or an object property from its
rangealone, or from the default range when it has none. It ignoresany_ofandexactly_one_of, so with the usual default rangestring:any_oflists classes is a data property, with a union of classes as its range;any_oflists a type and a class is a data property too, and its range mixes a datatype and a class.In OWL 2 DL, a data property has literal values, an object property has individuals, and no IRI is both kinds. ROBOT and Protégé therefore report such ontologies as outside OWL 2 DL. kitchen_sink has one class for each case:
AnyOfClasses,AnyOfEnumsandAnyOfMix.This PR decides the kind from all ranges of a slot. Where OWL cannot express what the schema says, gen-owl leaves it out with a warning instead of writing invalid OWL.
In plain words: A vehicle's
partsare wheels or doors, and itsspeedis a number or a quantity with a unit. gen-owl only looked at the default range,string, and declared both as text-valued properties, while the same file says their values are wheels, doors and quantities. Nowpartslinks to things.speedcan hold a number or a thing, and no OWL property can hold both. So it becomes a property that links to things without saying which, and gen-owl warns about it.Refs linkml#1483: the default range "should not be applied if there is a any_of with ranges".
Reproduce
vehicles.yaml:gen-owl vehicles.yaml > vehicles.owl.ttl robot validate-profile --profile DL --input vehicles.owl.ttl --output report.txtWith ROBOT 1.9.11;
main(eff06809d) and linkml#4279 give the same:mainpartsowl:DatatypeProperty, range the union ofWheelandDoorowl:ObjectProperty, the same rangespeedowl:DatatypeProperty, range the union ofxsd:floatandQuantityowl:ObjectPropertywithout a range, and the warning "Slot 'speed' ranges over both literals and nodes, which neither an object nor a data property can have, so it has no range and its values are not restricted"seatsexactly_one_ofgives untyped unions, intersections andowl:complementOfa rdfs:Datatype, withowl:datatypeComplementOfEach data file below is concatenated with the ontology and then checked:
main→ this PRex:car a ex:Vehicle ; ex:parts ex:wheel1 ; ex:seats 4 .ex:wheel1 a ex:Wheel .ex:bus a ex:Vehicle ; ex:seats 15 .ex:car a ex:Vehicle ; ex:speed ex:q1 .ex:q1 a ex:Quantity ; ex:value "120.0"^^xsd:float ; ex:unit "km/h" .ex:car a ex:Vehicle ; ex:speed "120.0"^^xsd:float .The 5 remaining violations in the last row are on
speed: an object property cannot have a literal value (see Areas of uncertainty).Why this is wrong
rdfs:Datatypeand its complement isowl:datatypeComplementOf(Mapping to RDF, Table 1).any_ofgives ranges. Withrange: Any,any_oflists the ranges of a slot (Unions as ranges).The change
range(or else the one it inherits throughis_aand its mixins), and those inany_of,all_of,exactly_one_of,none_of,all_membersandhas_member, or else the default range. Arange_expressionwith slot conditions counts as a class. A branch ofany_ofwithout a range, such as one with only apattern, has the range around it.Anyadds nothing beside other ranges. A role declared withimplementscomes first.linkml:Anydoes, without a range, with a warning.stringslot to a class;any_oforexactly_one_ofof a class, a rule or a classification rule, when it has a condition on such a slot, because leaving out only the condition could make the axiom stronger;all_ofandnone_of, only the affected operand.exactly_one_ofand nested boolean expressions take their types from their operands, so over data ranges they are data ranges. An expression over an enum that is a class is no longer typedrdfs:Datatype.owl:Thing, not to the default datatype.is_aand its mixins, asSchemaView.induced_slotgives it, and a class's restriction of it is filled with that range. Onmainand before,owner: {is_a: ref}withrefranging over a class was a data property under an object property, andwidth: {is_a: size}withsizeranging overintegerwas restricted toxsd:string. The metamodel and biolink snapshots change accordingly (12 and 14 lines).owl.rstis shorter.No public signatures change.
Other generators
sh:orofsh:datatypeandsh:class), gen-json-schema (anyOf) andlinkml-validateexpress a slot that mixes literals and objects, and so accept both values ofspeed. OWL 2 DL cannot, so gen-owl leaves the restriction out rather than state something false; the ontology then admits more.none_of, it leaves out the whole expression, where this PR leaves out only the operand. Both are sound, and whichever merges second can share one mechanism.How was this tested?
test_owlgen.py: 14 new tests with 27 cases.any_of,exactly_one_ofandhas_member; branches without a range; class expressions that OWL cannot state; narrowings to the other kind; attributes that several classes define;Anywithany_of; slots narrowed only by classes; and the typing of unions, intersections and complements, with and without a default range andtype_objects.test_owl_annotation_properties.py: a condition on an annotation property is still an error inside anany_ofthat is left out.*.yamlin the repository (527 files, gen-owl generates 401), fix(owlgen): make an enum of literals a datatype linkml/linkml#4279 against this PR, up to blank-node renaming:--default-permissible-value-type rdfs:Literal.opposite_ofbecomes an object property like its parentrelated_to, and its use as an annotation key now shows as 24 "undeclared annotation property" in place of "cannot pun".type_objectsin uncertainty 4.main, fix(owlgen): make an enum of literals a datatype linkml/linkml#4279 and this PR with ROBOT 1.9.11.tests/linkmlandtests/linkml_runtimein full on this head. Locally, the 612 tests that exercise gen-owl and the 66 slow tests pass on it, andruffpasses.Areas of uncertainty
FamilialRelationship SubClassOf type only FamilialRelationshipTypein personinfo, and 32 qualifiers in Biolink. None of them was OWL 2 DL; giving the slot a range in the schema fixes them.any_ofis left out for one operand, what its other operands say goes too. A rewrite to the strongest expression OWL can state would keep more; this PR only ever says less.type_objects. Types are classes, so expressions over them are no longer typedrdfs:Datatype. Their facets are still restrictions of datatypes intersected with the type's class, which is not OWL 2 DL with or without this PR. Some files show a few more OWL API violations under the API defaults.transform_class_expressionand its fallback, and with fix(generators): translate patterns for OWL and SHACL, list allowed strings linkml/linkml#4276 in the omission logic and the snapshots. Whichever merges later regenerates its snapshots.Checklist