Direct compilation of finite case analysis #
The pinned core defines Fin.cases using induction. Strict evaluation may
compute discarded induction hypotheses, which compounds for nested vector
constructors: compiled code reads entry i of a chain of Fin.cons in time
exponential in i. A proved compiler simplification selects the case
directly, so the read takes time linear in i. The logical definition and its
computation equations remain those of core.
A compiler simplification applies to the definitions compiled in the modules
that import it. A library that compiles finite case analysis, Fin.cons or
vector notation imports this module, as ToCslib.Data.Fin.MOfFn does.
Compile finite case analysis without evaluating unused induction hypotheses.
Dependent tuple construction using direct case selection.
Equations
- Fin.consDirect x xs = Fin.casesDirect x xs
Instances For
Rewriting the wrapper is necessary when its imported implementation is inlined later.
Nondependent vector construction with direct case selection.
Equations
- Matrix.vecConsDirect x xs = Fin.casesDirect x xs
Instances For
Compile vector notation without the imported induction-based wrapper.