Data as a primcodable type #
Data is denumerable through Cantor pairing (Data.encodeNat/Data.decodeNat), hence
Primcodable, with primitive recursive constructor, projections, a tree-recursion
principle (Data.primrec_recD), unary numerals, list indexing and the decoders of bit
strings. This is the interface between the ambient model and Mathlib's computability
(Cost/Partrec.lean): everything the model manipulates is Data — programs included,
through Prog.toData — so no separate encoding of Prog is needed.
Data ≃ ℕ #
Data ≃ ℕ.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Primitive recursive constructor and projections #
The head of a pair (nil on nil).
Equations
- MIPRE.Cost.Data.nil.left = MIPRE.Cost.Data.nil
- (a.cons b).left = a
Instances For
The tail of a pair (nil on nil).
Equations
Instances For
Case analysis on Data, primitive recursively.
Tree recursion #
Structural recursion on Data with a first-order result.
Equations
- MIPRE.Cost.Data.recD base step MIPRE.Cost.Data.nil = base
- MIPRE.Cost.Data.recD base step (a.cons b) = step a b (MIPRE.Cost.Data.recD base step a) (MIPRE.Cost.Data.recD base step b)
Instances For
Tree recursion is primitive recursive (through the pairing encoding, structural
recursion on Data is strong recursion on ℕ).
Unary numerals and list indexing #
The length of the right spine: reads a unary numeral (unaryToNat (ofNat n) = n).
Equations
- MIPRE.Cost.Data.unaryToNat = MIPRE.Cost.Data.recD 0 fun (x x_1 : MIPRE.Cost.Data) (x_2 rb : ℕ) => rb + 1
Instances For
Decoding bit strings #
Decoding bit strings from Data is primitive recursive.