Canonical Form for Binary Syntax
When two Value
s are written down in canonical form, comparing
their syntax for equivalence gives the same result as comparing them
semantically according to the equivalence defined in the
Preserves specification.^{1}
That is, canonical forms are equal if and only if the encoded Value
s
are equal.
This document specifies canonical form for the Preserves machineoriented binary syntax.
Annotations. Annotations MUST NOT be present.
Sets.
The elements of a Set
MUST be serialized sorted in ascending order
by comparing their canonical encoded binary representations.
Dictionaries.
The keyvalue pairs in a Dictionary
MUST be serialized sorted in
ascending order by comparing the canonical encoded binary
representations of their keys.^{2}
Other kinds of Value
.
There are no special canonicalization restrictions on
SignedInteger
s, String
s, ByteString
s, Symbol
s, Boolean
s,
Double
s, Record
s, Sequence
s, or Embedded
s. The
constraints given for these Value
s in the specification
suffice to ensure canonicity.
Notes

However, canonical form does not induce a match between lexicographic ordering on syntax and semantic ordering as specified. It only induces a connection between equivalences. ↩

There is no need to order by (key, value) pair, since a
Dictionary
has no duplicate keys. ↩