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:

PropertyDescription
inputTypeThe type declaration to resolve
outputTypeThe resulting partition
strategyTerm rewriting via critical identity

Derivation Witness

The canonical form computation is witnessed by a Derivation, which records the full rewrite sequence:

PropertyRangeDescription
originalTermTermThe term before rewriting
canonicalTermTermThe canonical form
resultDatumThe evaluated datum value
stepRewriteStepIndividual 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:

PropertyDescription
stepCountTotal rewrite steps performed
termSizeNodes 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.