CDLE and Cedille: Lambda-Encoded Induction, Recursion, and Zero-Cost Reuse
Prerequisites. Direct starred prerequisites: Chapter 37. No later core chapter depends on this route.
The Church numeral 𝑛 is an iterator: 𝑛:∀𝑋:⋆.𝑋→(𝑋→𝑋)→𝑋. It can compute 𝑛 applications of a step, but its result type cannot state a property of the numeral 𝑛 itself. Replacing 𝑋 by a motive 𝑃:𝖭𝖺𝗍→⋆ is ill typed: 𝑋 has kind ⋆, while 𝑃 has kind 𝖭𝖺𝗍→⋆. The missing information is not another iterator but evidence that the same erased numeral satisfies its own induction principle.
The working calculus is the Cedille Core of Stump and Jenkins, not the earlier 2017 lifting calculus. It is an extrinsic Calculus of Constructions with retained products Π𝑥:𝑇.𝑇′, erased products ∀𝑥:𝑇.𝑇′ and ∀𝑋:𝜅.𝑇, dependent intersections, untyped equality {𝑡≃𝑡′}, type ascription, equality rewriting, direct computation, and the separation axiom 𝛿. It has one kind ⋆ of types and dependent kind products. Conversion of types uses call-by-name weak-head reduction followed by beta conversion of types and beta-eta conversion of erased terms. The semantic metatheorems below apply to this exact core.
The annotated terms and their erasures are 𝑡::=𝑥∣𝜆𝑥.𝑡∣𝑡𝑢∣Λ𝑋.𝑡∣𝑡⋅𝑇∣Λ𝑥.𝑡∣𝑡−𝑢∣[𝑡,𝑢]∣𝑡.1∣𝑡.2∣𝛽{𝑢}∣𝛿−𝑡∣𝜌𝑝@𝑥⟨𝑢⟩.𝑇−𝑡∣𝜙𝑝−𝑡{𝑢}∣𝜒𝑇−𝑡, with erase(Λ𝑋.𝑡)=erase(𝑡),erase(𝑡⋅𝑇)=erase(𝑡),erase(Λ𝑥.𝑡)=erase(𝑡),erase(𝑡−𝑢)=erase(𝑡),erase([𝑡,𝑢])=erase(𝑡),erase(𝑡.1)=erase(𝑡.2)=erase(𝑡),erase(𝛽{𝑢})=erase(𝑢),erase(𝛿−𝑡)=𝜆𝑥.𝑥,erase(𝜌𝑝@𝑥⟨𝑢⟩.𝑇−𝑡)=erase(𝑡),erase(𝜙𝑝−𝑡{𝑢})=erase(𝑢),erase(𝜒𝑇−𝑡)=erase(𝑡). Here 𝑡−𝑢 is application to an erased term argument; it is not subtraction. The two terms on either side of ≃ need only have their free variables declared; equality is heterogeneous and untyped.
The proof 𝛽{𝑢} may erase to an unrelated term 𝑢. This Kleene trick classifies every closed untyped term at a true equality type. Rule CDLE-𝜙 instead changes the erased program to 𝑢 after an equality proof. Neither rule is an MLTT identity eliminator.
For a neutral intersection variable 𝑛, the projections 𝑛.1 and 𝑛.2 do not reduce. Both erase to 𝑛, and their types provide the two views needed below.
Inductive naturals as an intersection
Put 𝖭𝖺𝗍𝖢:=∀𝑋:⋆.𝑋→(𝑋→𝑋)→𝑋,𝗓𝖾𝗋𝗈𝖢:=Λ𝑋.𝜆𝑧.𝜆𝑠.𝑧,𝗌𝗎𝖼𝖢(𝑛):=Λ𝑋.𝜆𝑧.𝜆𝑠.𝑠(𝑛⋅𝑋𝑧𝑠). The type 𝖭𝖺𝗍𝖢 supports iteration. It does not derive, for an arbitrary 𝑃:𝖭𝖺𝗍𝖢→⋆, a term of 𝑃(𝑛) from a base and step; the iterator quantifies over a single result type 𝑋. This nonderivability in second-order dependent type theory is the obstruction, not a missing clever choice of 𝑋.
Define the inductivity predicate 𝖨𝗇𝖽𝖭𝖺𝗍(𝑛):=∀𝑃:𝖭𝖺𝗍𝖢→⋆.𝑃(𝗓𝖾𝗋𝗈𝖢)→(∀𝑚:𝖭𝖺𝗍𝖢.𝑃(𝑚)→𝑃(𝗌𝗎𝖼𝖢(𝑚)))→𝑃(𝑛). and the inductive type 𝖭𝖺𝗍:=𝜄𝑛:𝖭𝖺𝗍𝖢.𝖨𝗇𝖽𝖭𝖺𝗍(𝑛).
The zero inductivity term is 𝗓𝖾𝗋𝗈𝖨:=Λ𝑃.𝜆𝑧.𝜆𝑠.𝑧. Its erasure is 𝜆𝑧.𝜆𝑠.𝑧, exactly the erasure of 𝗓𝖾𝗋𝗈𝖢. Therefore 𝗓𝖾𝗋𝗈:=[𝗓𝖾𝗋𝗈𝖢,𝗓𝖾𝗋𝗈𝖨]:𝖭𝖺𝗍 by CDLE-Isect-I.
Assume 𝑛:𝖭𝖺𝗍. Its second projection gives induction for 𝑛.1. Define 𝗌𝗎𝖼𝖨(𝑛):=Λ𝑃.𝜆𝑧.𝜆𝑠.𝑠−𝑛.1(𝑛.2−𝑃𝑧𝑠). The argument 𝑛.1 to the step is erased. Hence erase(𝗌𝗎𝖼𝖨(𝑛))=𝜆𝑧.𝜆𝑠.𝑠(erase(𝑛)𝑧𝑠)=erase(𝗌𝗎𝖼𝖢(𝑛.1)). The dependent intersection 𝗌𝗎𝖼(𝑛):=[𝗌𝗎𝖼𝖢(𝑛.1),𝗌𝗎𝖼𝖨(𝑛)] therefore inhabits 𝖭𝖺𝗍.
Proof. Let 𝑛:𝖭𝖺𝗍. Projection 𝑛.2 synthesizes 𝖨𝗇𝖽𝖭𝖺𝗍(𝑛.1). Instantiate that witness with 𝑃, then supply the zero and step premises. Its result is exactly 𝑃(𝑛.1). Abstract over 𝑛, 𝑠, 𝑧, and the erased motive 𝑃. A predicate on represented naturals is obtained only by composition with the first projection. This domain is deliberate: the stored witness proves induction for the Church subject of an intersection inhabitant, not an unrestricted eliminator for arbitrary host-language values. ◻
The computation claims have three different strengths. Untyped beta reduction gives erase(𝗂𝗇𝖽𝖭𝖺𝗍−𝑃𝑧𝑠𝗓𝖾𝗋𝗈)⟶∗erase(𝑧). Internal equality after rewriting gives 𝗂𝗇𝖽𝖭𝖺𝗍−𝑃𝑧𝑠𝗓𝖾𝗋𝗈=𝑃(𝗓𝖾𝗋𝗈𝖢)𝑧. For neutral 𝑛, the term 𝗂𝗇𝖽𝖭𝖺𝗍−𝑃𝑧𝑠𝑛 has no native eliminator redex.
★★☆ Expand 𝗌𝗎𝖼𝖨(𝑛) and 𝗌𝗎𝖼𝖢(𝑛.1) and give the full beta-eta chain proving that CDLE-Isect-I applies. Then calculate the erasure of two successive constructors.
Let R be the complete lattice of beta-eta-closed sets of closed untyped lambda terms. A retained product is interpreted as the set of lambdas mapping each argument candidate to the codomain candidate. An erased product is the intersection of all codomain candidates. The two clauses that do the new work are [[𝜄𝑥:𝑇.𝑇′]]𝜎,𝜌={𝐸∈[[𝑇]]𝜎,𝜌∣𝐸∈[[𝑇′]]𝜎[𝑥↦𝜁(𝐸)],𝜌},[[{𝑡≃𝑢}]]𝜎,𝜌={[L]𝛽𝜂,𝜎erase(𝑡)=𝛽𝜂𝜎erase(𝑢),∅,otherwise, where 𝜁(𝐸) chooses a representative of the nonempty equivalence class 𝐸 and L is the set of closed untyped terms.
Proof of Theorem 96.5 — Cedille Core soundness and consistency
Proof. The four semantic clauses are imported as Theorem 1 of Stump and Jenkins for the exact Cedille Core syntax and classification rules frozen in convention 96.1. Its hypotheses and conclusions are, respectively, an environment (𝜎,𝜌)∈[[Γ]] and the four clauses displayed here. Lemmas 9–14 on page 10 establish nonemptiness, representative selection, term and type substitution, and invariance under type reduction; Appendix A, pages 10–15, proves every kinding, synthesis, and checking case by mutual induction. We import that complete proof rather than infer soundness from only the two clauses displayed above.
Theorem 2 of the same source has the exact closed consistency conclusion. Its local final step is the empty-candidate calculation: if a closed 𝑡 had type ∀𝑋:⋆.𝑋, soundness would put its erasure in every candidate in R, including the empty candidate. No term belongs to the empty set, yielding a contradiction [SJ18]. ◻
Global normalization is false. If 𝖳𝗈𝗉:={𝜆𝑥.𝑥≃𝜆𝑥.𝑥}, then 𝛽{Ω}:𝖳𝗈𝗉 for Ω=(𝜆𝑥.𝑥𝑥)(𝜆𝑥.𝑥𝑥). Its erasure is Ω, which does not normalize. This does not contradict theorem 96.5: the greatest equality candidate contains non-normalizing terms. Closed functions retyped by an identity-erasing cast to a retained function type do satisfy the source’s qualified call-by-name normalization theorem; no stronger claim is used here.
Four encodings perform four operations
Encoding
stored behavior
representative operation
cost boundary
Church
fold
iteration
predecessor is linear
Parigot
constructor plus recursive value
primitive recursion
larger constructor
Scott
one-step case
predecessor
fold needs recursion
Mendler
abstract recursive carrier
structurally controlled fold
algebra cannot inspect carrier
CDLE does not make these encodings definitionally equal. Dependent intersection can attach induction to each, and zero-cost casts can relate representations only when the two coercions erase to identity.
Monotone recursion and constant-time boundaries
Define a zero-cost cast𝖢𝖺𝗌𝗍(𝐴,𝐵):=𝜄𝑓:(𝐴→𝐵).{𝑓≃𝜆𝑥.𝑥}. If 𝑐:𝖢𝖺𝗌𝗍(𝐴,𝐵), then 𝑐.1:𝐴→𝐵 and erase(𝑐.1)=𝛽𝜂𝜆𝑥.𝑥. Casts form a preorder by identity and composition. A type scheme 𝐹:⋆→⋆ is monotone when it has 𝗆𝗈𝗇𝗈𝐹:∀𝐴:⋆.∀𝐵:⋆.∀𝑐:𝖢𝖺𝗌𝗍(𝐴,𝐵).𝖢𝖺𝗌𝗍(𝐹(𝐴),𝐹(𝐵)). Write 𝖢𝗅𝗈𝗌𝖾𝖽𝐹(𝑋):=𝖢𝖺𝗌𝗍(𝐹(𝑋),𝑋). Define the Tarski meet and its two universal casts by 𝖱𝖾𝖼(𝐹):=∀𝑋:⋆.∀𝑐:𝖢𝗅𝗈𝗌𝖾𝖽𝐹(𝑋).𝑋,𝗋𝖾𝖼𝖫𝖡𝐹:∀𝑋:⋆.∀𝑐:𝖢𝗅𝗈𝗌𝖾𝖽𝐹(𝑋).𝖢𝖺𝗌𝗍(𝖱𝖾𝖼(𝐹),𝑋),𝗋𝖾𝖼𝖦𝖫𝖡𝐹:∀𝑌:⋆.∀ℎ:(∀𝑋:⋆.∀𝑐:𝖢𝗅𝗈𝗌𝖾𝖽𝐹(𝑋).𝖢𝖺𝗌𝗍(𝑌,𝑋)).𝖢𝖺𝗌𝗍(𝑌,𝖱𝖾𝖼(𝐹)). Both quantifiers in the definition of 𝖱𝖾𝖼 are erased. Thus a term of 𝖱𝖾𝖼(𝐹) is in every 𝐹-closed type without receiving a runtime dictionary.
For every 𝐹 and 𝗆𝗈𝗇𝗈𝐹 in Cedille Core, the Tarski construction defines 𝖱𝖾𝖼(𝐹):⋆ and casts 𝗋𝖾𝖼𝖱𝗈𝗅𝗅(𝗆𝗈𝗇𝗈𝐹):𝖢𝖺𝗌𝗍(𝐹(𝖱𝖾𝖼(𝐹)),𝖱𝖾𝖼(𝐹)),𝗋𝖾𝖼𝖴𝗇𝗋𝗈𝗅𝗅(𝗆𝗈𝗇𝗈𝐹):𝖢𝖺𝗌𝗍(𝖱𝖾𝖼(𝐹),𝐹(𝖱𝖾𝖼(𝐹))). Let 𝗋𝗈𝗅𝗅:=𝗋𝖾𝖼𝖱𝗈𝗅𝗅(𝗆𝗈𝗇𝗈𝐹).1 and 𝗎𝗇𝗋𝗈𝗅𝗅:=𝗋𝖾𝖼𝖴𝗇𝗋𝗈𝗅𝗅(𝗆𝗈𝗇𝗈𝐹).1. These retained functions erase to 𝜆𝑥.𝑥 and are mutually inverse by internal equality. Under a cost model that counts erased beta steps and does not charge type checking, roll and unroll take constant time.
Proof of Theorem 96.6 — Derived monotone recursive type
Proof. For 𝑚:𝗆𝗈𝗇𝗈𝐹, the two casts are constructed by 𝗋𝖾𝖼𝖱𝗈𝗅𝗅(𝑚):=𝗋𝖾𝖼𝖦𝖫𝖡𝐹(Λ𝑋.Λ𝑐.𝑐∘𝖢𝖺𝗌𝗍𝑚(𝗋𝖾𝖼𝖫𝖡𝐹(𝑐))),𝗋𝖾𝖼𝖴𝗇𝗋𝗈𝗅𝗅(𝑚):=𝗋𝖾𝖼𝖫𝖡𝐹(𝑚(𝗋𝖾𝖼𝖱𝗈𝗅𝗅(𝑚))). Indeed, 𝗋𝖾𝖼𝖫𝖡𝐹(𝑐) casts 𝖱𝖾𝖼(𝐹) to 𝑋; monotonicity casts 𝐹(𝖱𝖾𝖼(𝐹)) to 𝐹(𝑋); composition with 𝑐:𝖢𝖺𝗌𝗍(𝐹(𝑋),𝑋) supplies the lower-bound family consumed by 𝗋𝖾𝖼𝖦𝖫𝖡𝐹. For unrolling, monotonicity sends the rolling cast to 𝖢𝖺𝗌𝗍(𝐹(𝐹(𝖱𝖾𝖼(𝐹))),𝐹(𝖱𝖾𝖼(𝐹))), so the latter type is 𝐹-closed and 𝗋𝖾𝖼𝖫𝖡𝐹 applies.
These definitions, including the identity-erasure proofs inside 𝗋𝖾𝖼𝖫𝖡 and 𝗋𝖾𝖼𝖦𝖫𝖡, are the exact derived terms in Figure 12 of Jenkins and Stump; their greatest-lower-bound property is Theorem 8 on page 24. Figure 13 on page 25 defines retained 𝗋𝗈𝗅𝗅 and 𝗎𝗇𝗋𝗈𝗅𝗅 by eliminating the two casts and proves both inverse equalities. Importing those derivations supplies the internal typing and equality premises omitted by the displayed mathematical notation. The erasure calculation is then (𝜆𝑥.𝑥)∘(𝜆𝑥.𝑥)𝛽⟶𝜆𝑥.𝑥. At runtime a roll or unroll is the identity function, so a constant number of beta steps exposes its argument independently of the recursive value’s size [JS21]. ◻
Without 𝗆𝗈𝗇𝗈𝐹, the 𝐹-image of a cast is unavailable and the two Tarski inequalities cannot be constructed. Positivity is one sufficient way to derive monotonicity; it is not built into 𝖱𝖾𝖼 as a syntactic oracle.
★★☆ Given 𝑐:𝖢𝖺𝗌𝗍(𝐴,𝐵) and 𝑑:𝖢𝖺𝗌𝗍(𝐵,𝐶), construct 𝑑∘𝑐:𝖢𝖺𝗌𝗍(𝐴,𝐶). Type its function view and give the complete beta-eta calculation showing that its erasure is identity.
Large elimination asks a datatype value to compute a type. Cedille Core has no native type-level case reduction on an encoded value. It can instead produce an extensional equivalence of the desired types.
Define 𝖳𝗉𝖤𝗊(𝐴,𝐵):=𝜄𝑐:𝖢𝖺𝗌𝗍(𝐴,𝐵).𝖢𝖺𝗌𝗍(𝐵,𝐴). The outer dependent intersection is nondependent in 𝑐, but its introduction rule forces the two cast witnesses to have the same identity erasure. If 𝑒:𝖳𝗉𝖤𝗊(𝐴,𝐵), the two coercions are the function views of 𝑒.1 and 𝑒.2, and both erase to 𝜆𝑥.𝑥.
The source’s first concrete simulation is the family of 𝑛-ary function types over a fixed 𝑇. Native large elimination would postulate 𝖭𝖺𝗋𝗒(0)≡𝑇,𝖭𝖺𝗋𝗒(𝑆𝑛)≡𝑇→𝖭𝖺𝗋𝗒(𝑛), but Cedille Core has no such type-level equations. Instead define a GADT-like relation by constructors 𝗇𝖺𝗋𝗒𝖱𝖹:∀𝑋:⋆.∀𝑒:𝖳𝗉𝖤𝗊(𝑋,𝑇).𝖭𝖺𝗋𝗒𝖱(0,𝑋),𝗇𝖺𝗋𝗒𝖱𝖲:∀𝐼:⋆.∀𝑛:𝖭.𝖭𝖺𝗋𝗒𝖱(𝑛,𝐼)→∀𝑋:⋆.∀𝑒:𝖳𝗉𝖤𝗊(𝑋,𝑇→𝐼).𝖭𝖺𝗋𝗒𝖱(𝑆𝑛,𝑋), and take 𝖭𝖺𝗋𝗒(𝑛):=∀𝑋:⋆.∀𝑟:𝖭𝖺𝗋𝗒𝖱(𝑛,𝑋).𝑋.
There are derived witnesses 𝗇𝖺𝗋𝗒𝖹𝖤𝗊:𝖳𝗉𝖤𝗊(𝖭𝖺𝗋𝗒(0),𝑇) and 𝗇𝖺𝗋𝗒𝖲𝖤𝗊:∀𝑛:𝖭.𝖭𝖺𝗋𝗒𝖱(𝑛,𝖭𝖺𝗋𝗒(𝑛))→𝖳𝗉𝖤𝗊(𝖭𝖺𝗋𝗒(𝑆𝑛),𝑇→𝖭𝖺𝗋𝗒(𝑛)). Their two coercion directions erase to identity; neither conclusion is a judgmental type equation.
Proof of Theorem 96.7 — Simulated Nary computation
Proof. Figure 4 on page 5 of Jenkins, Marmaduke, and Stump defines 𝖭𝖺𝗋𝗒𝖱. Figure 5 and Propositions 1–4 on pages 7–8 give the exact signatures of 𝗇𝖺𝗋𝗒𝖹𝖤𝗊 and 𝗇𝖺𝗋𝗒𝖲𝖤𝗊, prove respect and uniqueness of the type index, and construct 𝗇𝖺𝗋𝗒𝖱𝖤𝗑(𝑛):𝖭𝖺𝗋𝗒𝖱(𝑛,𝖭𝖺𝗋𝗒(𝑛)). Their linked Cedille source supplies the mechanically checked derivations behind those signatures; we import them for the frozen CDLE calculus. Figure 6 on page 8 eliminates the witnesses to identity-erasing coercions. Thus either 𝖳𝗉𝖤𝗊 projection is zero cost, but no native case reduction is added [JMS22]. ◻
The generic construction extends this simulation to signatures with codes and interpretation, but its equation is extensional type equivalence, not an unrestricted equality of types. Some recursive examples expose only one simulated computation step before another explicit witness is required.
Zero-cost reuse
Assume an indexed vector encoding 𝖵𝖾𝖼(𝐴,𝑛) and a list encoding 𝖫𝗂𝗌𝗍(𝐴) whose erased constructors are identical. The forgetful cast 𝖿𝗈𝗋𝗀𝖾𝗍𝑛:𝖢𝖺𝗌𝗍(𝖵𝖾𝖼(𝐴,𝑛),𝖫𝗂𝗌𝗍(𝐴)) has function view 𝜆𝑥.𝑥. Suppose list map has type 𝗆𝖺𝗉𝖫:(𝐴→𝐵)→𝖫𝗂𝗌𝗍(𝐴)→𝖫𝗂𝗌𝗍(𝐵) and its output length theorem permits the reverse cast into 𝖵𝖾𝖼(𝐵,𝑛). Define vector map by the two casts around list map. Its erasure is erase(𝗆𝖺𝗉𝖵)=𝜆𝑓.𝜆𝑥𝑠.(𝜆𝑥.𝑥)(𝗆𝖺𝗉𝖫𝑓((𝜆𝑥.𝑥)𝑥𝑠))⟶∗𝜆𝑓.𝜆𝑥𝑠.𝗆𝖺𝗉𝖫𝑓𝑥𝑠. Typing uses the length theorem; runtime uses exactly the list implementation. This is zero-cost reuse: the conversion functions erase to identity, not merely to linear traversals that happen to return equal data.
If vector and list constructors have different erasures, the cast equality premise is false and the reuse proof fails. Extensional isomorphism alone does not establish zero cost.
★★☆ Compare an identity-erasing vector-to-list cast with a structurally recursive conversion that copies every constructor. Type both functions, compute their erasures on a two-element input, and identify the failed premise preventing the second function from inhabiting 𝖢𝖺𝗌𝗍.
The v1.1.2 Cedille checker and pinned developments check concrete induction, recursive-representation, large-elimination, and reuse files. Surface constructs map to the core as follows: erased braces map to ∀ and 𝑡−𝑢; intersection introductions map to [𝑡,𝑢]; equality proofs map to 𝛽, 𝜌, and 𝜙; and casts map to dependent intersections whose function view erases to identity. The developments do not check an unprinted global normalization theorem, automatic large-elimination computation, or the consistency proof itself. The implementation bounds conversion search, so acceptance is relative to the configured budget.
The 𝖼2 redesign. The experimental 𝖼2 calculus replaces CDLE’s untyped equality interface with typed proof rules while retaining erasure, intersections, and casts. Its proved results include confluence and preservation, normalization of proof reduction by translation to 𝐹𝜔, a partial consistency translation to CDLE, and normalization of a strict cast-free erased fragment. For the full object language, normalization is conditional on an external 𝜙-safety or contextual-equivalence hypothesis. The proposed characterization is conjectural, so checking is relative to an oracle for that hypothesis. Full object normalization is false. The later Lean repository contains hundreds of admitted declarations and is a proof roadmap, not mechanized evidence for these theorems.
★★☆ Reconstruct the zero and successor intersection introductions. Write each erasure. Use 𝑃(𝑛):=𝑛+0=𝑛 and distinguish erased computation from the equality rewrites in its result type.
★★★ Write the intersection and equality cases of theorem 96.5. Instantiate ∀𝑋:⋆.𝑋 with the empty candidate. Then type 𝛽{Ω}:𝖳𝗈𝗉 and explain why it does not affect that argument.
★★★Practical project.cdle-zero-cost-runtime Implement in Kappa a finite model of Church observations, same-erasure admission, identity roll/unroll, and list-map reuse. Construct two successors, observe 2, preserve it through roll/unroll, and obtain [2,3]. Reject a copying/identity pair. Unconditional admission must make the test fail.
Sources. The later Cedille Core rules and erasure are Figures 1–6 on pages 2–4 of the syntax-and-semantics paper; the semantic clauses and exact consistency and normalization boundaries are on pages 5–8. The natural-number construction uses the realizability-to-induction development. The Tarski construction, constant-time roll/unroll, and recursive representations are from the monotone-recursive-types source; simulated large eliminations use 𝖳𝗉𝖤𝗊 from the TYPES development. The pinned Cedille Cast and development repositories check examples, not a stronger metatheory [Stu17, SJ18, JS21, JMS22, Ced25].