Lectures onType Theory
Chapter 118
Chapter 118Optional

Sort Polymorphism and Stratified Type Theory

Prerequisites. Direct starred prerequisites: none. No later core chapter depends on this route.

A level variable ranges over positions inside a universe hierarchy. It does not range over Type, Prop, and SProp. These sorts differ operationally: a proof-irrelevant inductive cannot in general be eliminated into computational data. Duplicating one declaration at each sort loses a principal abstraction, while treating a sort variable as an ordinary level erases the elimination restriction. Sort abstraction therefore needs a judgment separate from level abstraction.

The SortPoly judgment

Convention 118.1 — SortPoly system card

The principal system is the SortPoly calculus. Its typing judgment is ΣΘΓt:A, where Σ is a global environment, Θ contains prenex sort and universe-level variables, and Γ is the term context. A universe is written Uls, with sort s and level l. The prenex context Θ carries variables: s sort and l level. Levels additionally have constraints, compared by an abstract judgment Θl=sl that conversion of universes appeals to. Sorts have no constraints in this system: a sort variable may be instantiated by any ground sort, and the source lists constraints on sorts, and eliminability constraints between sorts, as future work. Inductive elimination is instead governed entirely by the parameter judgment ΣΘelim(I,s) allowed, which is stable under sort/level substitution and admits same-sort elimination. The principal theorem is monomorphization into pCUIC under the paper’s ground-sort and elimination hypotheses. Bounded elimination constraints later in the chapter are a separate calculus.

Definition 118.2 — Sort abstraction and application

A global declaration has a prenex telescope ΘC=(s1 sort,,lk level), a type A, and a body t. An application C{p} supplies a sort and level instance p for ΘC: one ground or variable sort for each sort binder, and one level expression for each level binder, satisfying the level constraints of ΘC. There is nothing for the sort components to satisfy, which is exactly why the elimination premise of definition 118.3 cannot be discharged by the instance and must be carried by the case rule. Substitution acts simultaneously on the universe sorts, universe levels, types, and terms of the declaration. Sort variables never occur as run-time terms.

One declaration of equality can be instantiated at both computational and proof sorts: Eq@{s,l}(A:Uls)(x:A):AU0s. At s=Type it is a data-valued equality; at s=Prop it is proof-irrelevant. A duplicated pair of declarations cannot express a client abstracted over the choice of sort.

Definition 118.3 — Elimination constraints

For an inductive family I declared in sort sI, the case rule contains the premise ΣΘelim(I,sP) allowed, where sP is the sort of its motive. The always-valid rule is

Θs sort(I declared at codomain sort s)Σ
ΣΘelim(I,s) allowed
Same-Sort

Both premises are needed. Without the second, the rule would derive elim(I,s) allowed for every well-formed sort and every inductive, which is the unrestricted large elimination the judgment exists to prevent. Ground sorts may add their own rules, such as singleton elimination for a qualified inductive in Prop. No rule allows an arbitrary abstract sort to eliminate into Type.

The rejected program is immediate. Let I be an arbitrary inductive in a sort variable s, and attempt to define f:IN by cases. Its motive lives in Type. The missing premise is elim(I,Type) allowed. Instantiating s=SProp explains the rejection: such an elimination would reveal proof-irrelevant inhabitants as data.

Lemma 118.4 — Elimination stability under instantiation

Assume the allowed-elimination judgment is stable under a well-formed prenex substitution ρ:ΘΘ. If ΣΘelim(I,s) allowed, then Σ[ρ]Θelim(I[ρ],s[ρ]) allowed.

Proof of Lemma 118.4 — Elimination stability under instantiation

Proof. This is the stipulated substitution closure of the parameter judgment. For Same-Sort, substitution sends both occurrences of s to the same ground or variable sort, so the rule rebuilds directly. Every additional ground rule is required by convention 118.1 to be closed under the same substitution; otherwise it is not an admissible SortPoly elimination policy. ◻

The stability hypothesis cannot be deleted. A policy that grants an elimination only while the source sort is syntactically a variable could lose the premise when that variable is instantiated, breaking substitution in the case rule.

Exercise 118.1

★☆☆ For an inductive I in abstract sort s, classify motives in s, Prop, and Type using only Same-Sort. Give the missing premise for each rejected case.

Constraint solving and monomorphization

SortPoly itself carries no sort constraints, so the residual information an elaborator must keep is not part of convention 118.1. The following constraint language is defined here, for this chapter, to name that information; the bounded system at the end of the chapter is the published calculus that adds constraints of this shape to the theory itself.

Definition 118.5 — Finite sort constraints

Fix a finite set G of ground sorts and a ground elimination table: a subset EG×G with (s,s)E for every sG, where (s,t)E means that an inductive declared at s may be eliminated into a motive at t. A constraint problem is a finite set of sort variables together with equations s=t and elimination atoms elim(sI,sP) allowed between sort variables and ground sorts. A solution is a map θ from the variables to G such that θ(s)=θ(t) for each equation and (θ(sI),θ(sP))E for each atom. Principal inference returns the residual problem rather than choosing a ground sort before a client supplies one.

Proposition 118.6 — Solutions are checkable and finitely many

For a constraint problem with n variables over a table E on G, whether a given θ is a solution is decidable, the set of solutions is computable, and a problem all of whose atoms have the form elim(s,s) allowed has every θ satisfying its equations as a solution.

Proof of Proposition 118.6 — Solutions are checkable and finitely many

Proof. Checking θ tests finitely many equalities in G and finitely many memberships in E, each decidable because G and E are finite. The candidate maps form the finite set Gn, so the solutions are obtained by filtering it. For the last clause, reflexivity of E discharges every atom elim(s,s) allowed at any θ, so only the equations constrain the map. ◻

The last clause is the constraint-side reading of Same-Sort: a declaration that eliminates each inductive only at its own sort places no demand on the table, and stays sort polymorphic.

For a polymorphic identity, the residual problem is empty and the sort remains general. For the failed eliminator I@sN, it contains the single atom elim(s,Type) allowed. If the table E contains (Type,Type) and no other pair with second component Type, then by proposition 118.6 the unique solution is s=Type; choosing Prop would place a pair outside E and is rejected before monomorphization.

Definition 118.7 — Monomorphization

Let G be the finite set of ground sorts occurring in a closed-sort judgment. Write L(Θ) for the prenex context Θ with its sort binders deleted and its level binders and level constraints retained. The operation mG duplicates every global declaration once for each ground instantiation of its prenex sort variables by elements of G that keeps the declaration well formed, removes the sort binders from the copied declaration, and replaces each application C{p} by the copy indexed by the sort components of p, keeping the level components. Term constructors and local binders are traversed homomorphically.

Theorem 118.8 — Monomorphization theorem

Suppose ΣΘΓt:A, no sort variables remain in Θ, and G contains every ground sort occurring in Σ,Γ,t,A. Then mG(Σ)L(Θ)mG(Γ)mG(t):mG(A).

Proof of Theorem 118.8 — Monomorphization theorem

Proof. Four inductions establish the result. First, sort substitution preserves sort formation, level formation, contexts, typing, and conversion. For a ground sort substitution the ground-sort rule is unchanged; a substituted sort variable becomes either a ground sort or a variable still declared in the target context. The level cases are structural. In the mutual judgment induction, context extension, universe formation, and universe conversion use these two facts. Global lookup composes its sort-and-level substitution with the one being applied. Case and iota also use stability of the allowed- elimination premise. Product, application, abstraction, fixpoint, beta, eta, and conversion rebuild their original rule from the induction hypotheses.

Second, mG(Σ) is exhaustive. If (ΘCC:A)Σ and s is a well-formed ground assignment from G for the sort binders of ΘC, then (L(ΘC)Cs:mG(A[s]))mG(Σ). For a definition this is the copy inserted by the definition of mG. For an inductive declaration it is either the copied type former or one of its copied constructors. Those are the only forms of global declaration.

Third, assume mG(Σ) is well formed and the local sort context has no sort variables. Mutual induction on context formation, typing, and conversion proves that mG preserves each judgment. Since mG traverses local syntax homomorphically, every rule except empty-context and global lookup is rebuilt from the same rule and its induction hypotheses. The empty-context case uses well-formedness of mG(Σ). In a lookup C{p}, split p into ground sort arguments s and level arguments u. Absence of local sort variables puts s in the finite enumeration used by mG; exhaustivity gives Cs, and global lookup at u has type mG(A[s])[u]=mG(A[s,u]).

Finally, induct on well-formation of Σ. The empty environment maps to itself. For a definition, apply sort substitution to each finite ground assignment, then the third induction to its body; extend the monomorphized environment once for each copy, weakening earlier derivations across later copies. For an inductive declaration, do the same simultaneously for its parameter telescope, index telescope, constructor telescopes, and constructor indices; the instantiated declared sort is in G, and level constraints are unchanged. Thus mG(Σ) is well formed. Applying the third induction to the assumed typing derivation yields the displayed judgment. The argument uses the elimination policy fixed in convention 118.1; it says nothing about an arbitrary table or about definition 118.5. ◻

Corollary 118.9 — Equiconsistency

Assume the elimination policy for Prop that the source requires: that Prop is a ground sort, and that an inductive declared at Prop may be eliminated into a sort s exactly when s is Prop, or s is Type and the inductive satisfies the singleton elimination rule. If pCUIC is consistent, then for every prenex context Θ, every sort s that is a variable of Θ or is Type, and every well-formed global signature Σ containing the empty declaration (s sort:U0s where )Σ, there is no term t such that ΣΘt:s.

Proof of Corollary 118.9 — Equiconsistency

Proof. Suppose such a term exists in a signature Σ containing the displayed empty declaration. Substitute Type for every remaining sort variable of Θ, so that the judgment has no sort variables; apply theorem 118.8. It remains to construct the pCUIC embedding rather than assume it. Mutual induction on the ground SortPoly context, typing, and conversion derivations keeps variables and the Π, application, abstraction, fixpoint, beta, eta, and conversion rules unchanged. A universe is either Prop or Type, so the corresponding pCUIC universe rule applies. In a global lookup, the monomorphized signature contains the same ground declaration. In case and iota, an inductive in Prop eliminates only into Prop or, under the stated premise, by singleton elimination; these are precisely the pCUIC cases. Induction on the global environment applies this translation to each definition and to every inductive and constructor declaration, showing that the monomorphized global environment is a pCUIC environment. Hence the translated judgment is a closed pCUIC inhabitant of its empty type, contradicting pCUIC consistency. The Prop-elimination hypothesis is used exactly in the case and iota cases and is not implied by definition 118.3 alone. ◻

Stratification and bounded sort variables

A sort restricts how an inductive may be eliminated. It does not restrict which types a type may depend on. The following exact boundary isolates that different failure.

Theorem 118.10 — Imported λ * inconsistency

Consider the pure type system with one sort , the axiom :, and the product rule (,,): whenever ΓA: and Γ,x:AB:, it derives Γx:AB:. For every closed F:, there is a closed term f:F.

Proof of Theorem 118.10 — Imported λ * inconsistency

Proof. This is the consequence of Hurkens’s construction [Hur95]. Its large and small product interfaces are both interpreted by the single product rule; the universe code and its decoding are interpreted by and the identity; and the source’s arbitrary small code is interpreted by F. The construction then returns an element of its decoding, namely f:F. The import uses only products, application, abstraction, and their beta equations; it uses no inductive elimination. Hence changing allowed-elimination constraints cannot invalidate the construction while : and (,,) remain. ◻

The forbidden move inside that construction is self-instantiation: a type formed at the same stratum as its quantifier is passed as that quantifier’s argument. subStraTT blocks the move with a strict inequality.

Convention 118.11 — Stratified comparison boundary

The comparison system StraTT is a cumulative extrinsic theory with types à la Russell in which a dependent function type carries a level annotation on its domain, and subStraTT is its subsystem containing only stratified dependent functions and displacement, with the floating nondependent functions of the full system removed. Consistency of subStraTT — that no closed term inhabits the empty type — is proved by an inductive–recursive logical relation a[[A]]k stratified by level, whose only additional hypothesis is function extensionality; it is not a translation into another theory. The source also proves type safety for full StraTT. Consistency of full StraTT remains open, and the source proves neither normalization nor decidability of checking for it. A well-typed example in full StraTT therefore fills none of those cells.

The three subStraTT rules that expose the obstruction are

ΔΓ
Δ;Γ:k
DT-Type
Δ;ΓA:jΔ;Γ,x:jAB:kj<k
Δ;Γx:jA:B:k
DT-Pi
Δ;Γb:kx:jABΔ;Γa:jAj<k
Δ;Γba:kB[a/x]
DT-AppTy

Variables declared at stratum j may be used at any kj, but no rule lowers a derivation. Suppose a self-applicable type U is formed at stratum k and the binder X: of the product containing it is placed at stratum j. DT-Pi requires j<k. Using U as the argument to that binder in DT-AppTy requires a derivation of U:j. Since the available derivation has stratum k and cumulativity only raises strata, this would require kj. The pair j<kj is impossible. This is the exact formation/application obstruction; the axiom-like DT-Type alone does not recreate λ.

Sort and stratum answer different questions. A sort controls relevance and elimination; a stratum controls permitted dependency. A level locates a universe within a hierarchy; a grade counts or bounds use; a mode selects a context discipline. None can be substituted for another without a formal translation.

Definition 118.12 — Valid bounded-sort constraints

The bounded SortPoly calculus places elimination edges edgeΘ(s,t) in the sort context Θ. Let ΘG be its ground-to-ground edges and let Θ+ denote transitive closure. The context is valid when all three conditions hold.

  1. If edgeΘ+(g,g) holds for ground sorts, then edgeΘG+(g,g) already holds.

  2. There is a reflexive initial ground sort gi below every ground sort g incident with a nonground edge: whenever edgeΘΘG(s,g) or edgeΘΘG(g,s), one has edgeΘG+(gi,g).

  3. Every variable s dominated by a ground sort has a reflexive dominant ground sort gs: edgeΘ(gs,s), and every ground g with edgeΘ(g,s) also satisfies edgeΘG+(g,gs).

The dominant ground substitution sends a dominated s to gs and every other variable to gi.

Theorem 118.13 — Bounded-sort package

At the syntax and typing rules of bounded SortPoly, the following statements hold.

  1. For valid Θ, the dominant ground substitution is valid and preserves typing (Lemma 3.5 and Corollary 3.6).

  2. Figure 7’s elaborator introduces a fresh sort variable for every anonymous universe, threads field constraints through records, and adds exactly the source-to-motive edge for cases and the source-to-codomain edge for fixpoints. Suppose Σ,Θ,Γ,t,A are the elaborations from the initial data Σ0,Θ0,Γ0,t0,A0. For every level-and-sort context Θ and every sort substitution σ:ΘΘ that fixes the initial context, s[σ]=s whenever sΘ0, the exact premise and conclusion of Theorem 4.2 are ΣΘΓ[σ]t[σ]:A[σ]Θσ:Θ. Lemma 4.1 supplies the required σ for any alternative raw sort assignment; the displayed implication proves that a well-typed alternative is a valid instance of the inferred constraints.

  3. Write U(Θ) for the context retaining only ground elimination edges. If Θ=U(Θ), then ΣΘΓt:AmG(Σ)U(Θ)mG(Γ)mG(t):mG(A). This is Theorem 3.8; it does not apply before nonground edges have been discharged by a valid ground substitution.

  4. If Θ is valid, SortPoly is consistent, and s is bounded by a consistent ground sort, no closed bounded-SortPoly term inhabits the empty type in s (Corollary 3.9).

  5. Conversely, the inclusion ι sends a SortPoly judgment to bounded SortPoly by leaving its signature, context, term, and type unchanged and adding no nonground bound edges. Every SortPoly rule is then the corresponding bounded rule, so ΣΘΓt:A implies ι(Σ)ι(Θ)ι(Γ)ι(t):ι(A). Together with clause 4, this proves equiconsistency at the stated consistent sorts.

Proof of Theorem 118.13 — Bounded-sort package

Proof. For clause 1, let δ send a dominated variable s to its dominant ground sort gs, and every undominated variable to gi. A ground edge is fixed. If an edge ends at an undominated variable, validity clause 2 puts its incident ground endpoint above gi; if it ends at a dominated variable, clause 3 puts its ground endpoint below gs. Edges between variables reduce to these two cases through transitive closure. Validity clause 1 prevents a path through variables from creating a new ground edge. Thus every edge of Θ maps to an edge of ΘG+, so δ is a valid sort substitution. Structural induction on typing, with the case and fixpoint rules using the mapped elimination edge, proves substitution preservation.

For clause 2, induct first on raw syntax to show that the generated context contains one fresh sort variable for every anonymous universe and exactly the edges printed by the generating clause. Variables, applications, products, and ordinary constructors take unions of their recursive constraints. Record formation threads the constraints field by field. A case adds the edge from the scrutinee sort to the motive sort, and a fixpoint adds the edge from its recursive source to its codomain; no other clause adds an edge. Now induct on a typing derivation of an alternative assignment. The induction hypotheses validate all recursively generated edges. The record case composes the field substitutions, while case and fixpoint validate their single new edge from the corresponding typing premise. Therefore the alternative assignment is a substitution into the inferred context. Since the initial variables were never freshened, it fixes Θ0, proving the displayed implication.

For clause 3, prove mutually that mG preserves global environments, contexts, typing, and conversion. Empty contexts and local structural rules are homomorphic. A global declaration has only finitely many sort variables and G is finite, so the monomorphized environment contains every ground instance required by lookup. Products, conversion, inductives, constructors, case, and fixpoint rebuild the same rule at the selected copies. The premise Θ=U(Θ) is used in case and fixpoint: their elimination edges are already ground and hence remain in the target. This proves the displayed judgment.

For clause 4, apply clause 1 to replace every sort variable by a ground sort, then clause 3 to monomorphize. The bound on s selects a consistent ground copy of the empty declaration. A closed inhabitant would therefore give a closed SortPoly inhabitant of that copy, contradicting the assumed consistency.

For clause 5, induct simultaneously on SortPoly environment formation, context formation, typing, and conversion. Copy every premise unchanged and use the corresponding bounded rule with no nonground edge. The universe, product, conversion, inductive, and elimination cases keep their existing ground policy; variable and structural cases add no edge. All three clauses of definition 118.12 are therefore satisfied. This gives the inclusion ι. An inconsistency of SortPoly transfers along ι; clause 4 transfers a bounded inconsistency at a consistent ground bound back to SortPoly. Hence the theories are equiconsistent at those sorts. Validity and the consistent-sort premise are used at the indicated steps; the proof does not cover arbitrary graphs or first-class level terms. ◻

Sources and scope

The SortPoly system card, monomorphization, and pCUIC comparison above use Poiret et al. [PGM^+25]. The stratified comparison uses Chan and Weirich [CW23]. The numbered bounded-sort definitions and results refer to the anonymous draft dated 16 September 2025 [RDM^+25]; the published citation [RDM^+26] has different pagination. The thirteen-page construction behind theorem 118.10 is Hurkens’s [Hur95]; it remains an exact import rather than a shortened reconstruction.

Suggested first pass.

None of these problems is a prerequisite for a later chapter. Begin with exercise 118.2, then complete exercise 118.7.

Exercise 118.2

★★☆ Give a complete failed derivation for eliminating an arbitrary I:SProp into N:Type. Identify the one missing allowed-elimination judgment and explain why same-sort elimination does not derive it.

Exercise 118.3

★★★ Let U:k be a type intended as the argument to its own binder X:j. Use the displayed DT-Pi and DT-AppTy rules to derive the inequalities j<k and kj, then conclude that the self-instantiation has no stratum assignment. State separately which results in convention 118.11 are proved for subStraTT and for full StraTT; do not transfer the consistency result to the full calculus.

Exercise 118.4

★☆☆ Suppose ΔΓ, Δ;ΓA:0, and Δ;Γ,x:0AB:1. Translate the unannotated product formation problem for Πx:A.B into one subStraTT judgment, giving the complete DT-Pi derivation and its strict-inequality premise. Then explain why assigning both A and B stratum 0 does not give a second derivation by the same rule.

Exercise 118.5

★★☆ Classify each of the following four uses as a sort, a level, a grade, or a mode, and name the judgment that each one indexes: the s in Uls; the l in Uls; an annotation counting how often a variable may be used at run time; and the selection of a context discipline such as linear or affine use. For each pair among your four answers, say whether this book supplies a formal translation between them, and where it does not, say what would have to be proved to supply one.

Exercise 118.6

★★☆ In the bounded-sort calculus, derive the accepted quality assignment @{Type SProp; 0} for the natural-number large eliminator. Replace it by @{SProp Type; 0}, keeping the term otherwise unchanged. Derive rejection of the modified declaration, and identify the missing bounded-sort edge from SProp to Type. Explain why that edge is absent from the ground graph in definition 118.12.

Exercise 118.7

★★★ Practical project.bounded-sort-constraint-solver Implement in Agda or Kappa the three ground sorts Type, Prop, and SProp, equality constraints, and a finite table of permitted eliminations. Maintain the invariant that every reported assignment satisfies every edge after substitution. On same-sort and singleton-prop, print accepted. On sprop-to-type, print rejected: elimination. A mutation that treats the graph as complete must fail the last oracle. The program checks this finite table; it does not implement or prove the metatheory of SortPoly or bounded SortPoly.

Search the book

Type to search the local edition.