Documentation

CslibFrontier.Computability.Machines.Turing.MultiTape.Encodings.ZMod

Binary encodings of residues, residue vectors and residue matrices #

A residue a : ZMod q is stored as its canonical integer representative ZMod.cast a in binary sign-magnitude form (encIntBin). For q > 0 the representative lies in [0, q); for q = 0, ZMod 0 = ℤ and the representative is the integer itself, so the encoding is injective for every q : ℕ. Vectors Fin n → ZMod q are framed lists of these representatives in index order, and matrices Matrix (Fin n) (Fin m) (ZMod q) are framed lists of framed rows. The dimensions and the modulus are not stored: they are fixed by the type.

Main definitions #

Encode an element of ZMod q via its canonical integer representative ZMod.cast in binary. This is injective for every q : ℕ, including q = 0.

Encode a vector in Fin n → ZMod q as a framed list of binary integers.

Encode a matrix in Matrix (Fin n) (Fin m) (ZMod q) as a framed list of row lists.