Low-level coding recipes for Fin types #
This module collects encoding/decoding bijections to represent basic type constructors of Fin
types as Fin types. These functions implement the isomorphism Option (Fin n) ≃ Fin (n+1),
Fin m ⊕ Fin n ≃ Fin (m + n), Fin m × Fin n ≃ Fin (m * n), ..., including, dependent sums,
dependent products, decidable subtypes and decidable quotients.
Only a minimal API is provided. These utility functions are intended for use in other constructions. Such constructions should avoid exposing these functions as they are not meant for public use.
Equations
- Fin.encodePUnit x✝ = 0
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Equations
Instances For
Encode Char into Fin Char.count.
Equations
- Fin.encodeChar c = if x : c.toNat < Char.minSurrogate then ⟨c.toNat, ⋯⟩ else ⟨c.toNat - (Char.maxSurrogate + 1 - Char.minSurrogate), ⋯⟩
Instances For
Decode Char from Fin Char.count.
Equations
- Fin.decodeChar i = if x : ↑i < Char.minSurrogate then Char.ofNatAux ↑i ⋯ else Char.ofNatAux (↑i + (Char.maxSurrogate + 1 - Char.minSurrogate)) ⋯
Instances For
Encode Fin n ⊕ Fin m into Fin (n + m).
Equations
- Fin.encodeSum (Sum.inl x_1) = Fin.castAdd m x_1
- Fin.encodeSum (Sum.inr x_1) = Fin.natAdd n x_1
Instances For
Decode { i : Fin n // P i } from Fin (Fin.countP P) where P is a decidable predicate.
Equations
- One or more equations did not get rendered due to their size.
- Fin.decodeSubtype x ⟨val, h⟩ = ⋯.elim
Instances For
Get representative for the equivalence class of x.
Equations
Instances For
Encode Quotient s into Fin m where s is a decidable setoid on Fin n.
Equations
- Fin.encodeQuotient s x = Fin.encodeSubtype (fun (i : Fin n) => Fin.getRepr s i = i) (x.liftOn (fun (i : Fin n) => ⟨Fin.getRepr s i, ⋯⟩) ⋯)
Instances For
Decode Quotient s from Fin m where s is a decidable setoid on Fin n.
Equations
- Fin.decodeQuotient s i = Quotient.mk s (Fin.decodeSubtype (fun (x : Fin n) => Fin.getRepr s x = x) i).val