# Syntax for the OWL Refsets

The [OWL Functional Syntax-Style](https://confluence.ihtsdotools.org/display/DOCGLOSS/OWL+Functional+Syntax) is the recommended default syntax. The generated OWL ontologies of SNOMED CT may be rendered in any compatible OWL syntax and transformed between syntaxes. The specification of syntax including the BNF grammar published by the W3C can be found at <https://www.w3.org/TR/owl-syntax/>.

## Specializations for SNOMED CT

For the benefits of consistent representation and detection of changes to an expression, the style and rules are recommended though they have no semantic significance. The OWL expressions should be rendered in the form specified by the OWL Functional Syntax-Style but a restricted version may be used for creating and updating the OWL refsets. The following rules should be followed.

### Whitespace

OWL Functional Syntax-Style defines that whitespace is a nonempty sequence of space (U+20), horizontal tab (U+9), line feed (U+A), or carriage return (U+D) characters.\
The whitespace should only be represented as a single space (U+20) in the OWL refsets.

### Comments

OWL Functional Syntax-Style defines that a comment is a sequence of characters that starts with the # (U+23) character and does not contain the line feed (U+A) or carriage return (U+D) characters.\
Comments could improve the readability. However, comments should not be included to minimize the size of the OWL refsets and reduce the need to maintain the alignment between an axiom and its comments.

### Sorting Order

A standard sort order is very useful to enable fast matching of identical expressions though it has no impact to semantics and is not essential for general purpose use.\
Each axiom is a serialization of a tree structure that can be traversed by nodes in the following order:

1. Node that is either a SNOMED CT concept ID or a value of type data property. These nodes are sorted in UTF-8 byte-order (as a sequence of bytes) rather than numbers or strings. The byte-order compares two bytes; one from each sequence, until the values of the bytes are different. Then, the ID or value with the lowest byte value would be sorted as first regardless the length difference of byte arrays;
2. The composite node ObjectSomeValuesFrom(), sorting order by concept id of attribute and then value;
3. The composite node DataHasValue(), sorting order by concept id of attribute and then value.

The Functional-Style Syntax determines the general order of most elements within an OWL axiom. In fact, the order can only be applied to the nodes within EquivalentClasses(), DisjointClasses(), EquivalentDataProperties(), and ObjectIntersectionsOf() for the current [SNOMED CT Logic Profile Specification](https://docs.snomed.org/snomed-ct-specifications/snomed-ct-logical-profile-specification/).

### Syntax preference for expression variants

The same semantics can be represented by a single axiom or multiple axioms. When axioms are in the same SNOMED CT module,

* Expression in the OWL refset should be presented as an Equivalent Classes axiom instead of two Subclass axioms where both apply, e.g.

EquivalentClasses(A C) is recommended. The following two Subclass axioms are not.

SubClassOf(A C)\
SubClassOf(C A)

* Expression in the OWL refset should be presented as a single Subclass axiom with intersection of Class expressions instead of multiple Subclass axioms where they apply, e.g.

SubClassOf(A ObjectIntersectionOf(C D)) is recommended. The following two Subclass axioms are not.

SubClassOf(A C)\
SubClassOf(A D)

<a href="https://docs.google.com/forms/d/e/1FAIpQLScTmbZIf0UEQwYDkY27EEWBkaiYkHSbR0_9DmFrMLXoQLyL7Q/viewform?usp=pp_url&#x26;entry.1767247133=OWL+Specification&#x26;entry.670899847=Syntax%20for%20the%20OWL%20Refsets" class="button primary">Provide Feedback</a>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.snomed.org/snomed-ct-specifications/snomed-ct-owl-reference-set-specification/design-considerations/2.2-syntax-for-the-owl-refsets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
