Canonical Form
Definition
A canonical form is the unique representative of an equivalence class of terms under the rewrite rules of the UOR framework. The CanonicalFormResolver computes canonical forms by applying the critical identity and normalization rules until no further rewrites are possible.
The Resolver
The CanonicalFormResolver is a subclass of Resolver. It reduces terms to their unique canonical representatives using the critical identity as the primary rewrite rule:
| Property | Description |
|---|---|
| inputType | The type declaration to resolve |
| outputType | The resulting partition |
| strategy | Term rewriting via critical identity |
Derivation Witness
The canonical form computation is witnessed by a Derivation, which records the full rewrite sequence:
| Property | Range | Description |
|---|---|---|
| originalTerm | Term | The term before rewriting |
| canonicalTerm | Term | The canonical form |
| result | Datum | The evaluated datum value |
| step | RewriteStep | Individual rewrite steps |
Each RewriteStep records a single rule application via hasRewriteRule:
<https://uor.foundation/instance/step-1>
a derivation:RewriteStep ;
derivation:from <term-neg-bnot-x> ;
derivation:to <term-succ-x> ;
derivation:hasRewriteRule derivation:CriticalIdentityRule .
Term Metrics
The TermMetrics class tracks the size and complexity of canonical forms:
| Property | Description |
|---|---|
| stepCount | Total rewrite steps performed |
| termSize | Nodes in the canonical term's syntax tree |
Iterative Refinement
With Amendment 11, canonical form computation can also proceed iteratively via RefinementStep. Each refinement step applies a Constraint and records how many sites it closes (sitesClosed).
Relation to Content Addressing
The canonical form is the foundation of content addressing: the Element of an object is derived from its canonical form. Two objects with the same canonical form receive the same address. See Addressing for the Braille-encoded glyph scheme that maps canonical forms to content-addressable identifiers.