Encodings into Data #
This file defines the class that is used to encode arbitrary data structures into Data,
so that RTMs (rose tree machines) can operate on them.
Instances are provided for convenience for Data itself, Bool, List α, Option α, α × β,
and ℕ (binary encoding via List Bool)
Every DataEncode instance also yields a bitstring encoding DataEncode.bitstringEncode, by
serializing the target Data value with Data.toBits. Since both the DataEncode instance and
Data.toBits are injective, bitstringEncode is injective too
(DataEncode.bitstringEncode_injective).
Encoding of types into Data.
- encode : α → Data
Encode a value of
αasData. - h_inj : Function.Injective encode
The encoding is injective, so distinct values never collide.
Instances
Equations
- Complexity.instDataEncodeData = { encode := fun (b : Complexity.Data) => b, h_inj := Complexity.instDataEncodeData._proof_2 }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Complexity.instDataEncodeList α = { encode := fun (xs : List α) => Complexity.Data.l (List.map Complexity.DataEncode.encode xs), h_inj := ⋯ }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Complexity.instDataEncodeNat = { encode := fun (x : ℕ) => Complexity.DataEncode.encode x.bits, h_inj := Complexity.instDataEncodeNat._proof_1 }
Encode a value into a bitstring (List Bool) by first encoding it into Data and then
serializing that with the parenthesized Data.toBits. This is the class-inferrable bitstring
encoding available for any type with a DataEncode instance.
Equations
Instances For
The bitstring encoding is injective: distinct values yield distinct bitstrings. This composes
the injectivity of the DataEncode instance with that of Data.toBits.