pub enum Universe {
SProp,
Prop,
Type(u32),
Var(String),
Succ(Box<Universe>),
Max(Box<Universe>, Box<Universe>),
IMax(Box<Universe>, Box<Universe>),
}Expand description
Universe levels in the type hierarchy — a level EXPRESSION, so the kernel can be
universe-POLYMORPHIC (R3). The concrete hierarchy is Prop : Type 1 : Type 2 : …
with Prop ≤ Type i; on top of it, a level may mention universe VARIABLES, so one
definition (id.{u} : Π(A : Sort u). A → A) is reusable at every level instead of
duplicated per level.
Propis the universe of propositions (the impredicative bottom;Prop ≤all)Type(n)is the concrete universe at level nVar(u)is a universe variable; it ranges overPropand theTypelevels (neverSProp, which is a sort and not a level), so a level that mentions one may bePropSucc(ℓ)isℓ + 1Max(ℓ₁, ℓ₂)is the least upper bound (used in Π-type formation)
The algebra (succ/max/equiv/is_subtype_of) is decided over a canonical
normal form, NOT by the derived structural equality — max(u,u) ≡ u,
max(succ u, u) ≡ succ u, etc.
Variants§
SProp
SProp — the DEFINITIONALLY-proof-irrelevant sort (S). The bottom of the hierarchy
(SProp ≤ Prop ≤ Type n): any two terms of a type in SProp are definitionally
equal, and it is impredicative (Π into SProp is SProp). It collapses out of
max/imax/succ so the Prop=0 level encoding is never disturbed.
Prop
Prop - the universe of propositions
Type(u32)
Type n - the universe of types at level n
Var(String)
A universe variable (universe polymorphism).
Succ(Box<Universe>)
The successor level ℓ + 1.
Max(Box<Universe>, Box<Universe>)
The least upper bound of two levels.
IMax(Box<Universe>, Box<Universe>)
The IMPREDICATIVE maximum, imax(a, b) = b if b is Prop, else
max(a, b). It is the sort of Π(x:A). B where A : Sort a, B : Sort b:
a Π into a proposition is a proposition (Prop is impredicative), no matter
the domain. When b is a variable this stays symbolic — the level may be
Prop or not depending on the instantiation.
Implementations§
Source§impl Universe
impl Universe
Sourcepub fn succ(&self) -> Universe
pub fn succ(&self) -> Universe
Get the successor universe: Type n → Type (n+1), Prop → Type 0, and a
symbolic Succ(ℓ) for a level that mentions variables.
Prop.succ() is Type 0, NOT Type 1. This function and level_leq must agree, and
level_leq decides everything over level_order’s ℕ-model, in which Prop ↦ 0 and
Type n ↦ n+1. In that model succ(Prop) is level 1, which is spelled Type 0. Returning
Type 1 made the successor operation and the level ORDERING disagree by one about Prop
alone — the algebra was not self-consistent, and it also put us one level off Lean, which
says Prop : Type 0.
SProp moves with it for the same reason: to_lnat puts it at 0 as well, so its successor
is Type 0 by the identical argument. The discriminator is narrow, which is why this
survived: Prop → Type agrees either way because the codomain’s level already dominates;
only Prop → Nat (Type 0 in Lean, Type 1 here) told them apart.
Sourcepub fn max(&self, other: &Universe) -> Universe
pub fn max(&self, other: &Universe) -> Universe
Get the maximum of two universes (for Pi type formation). Concrete operands
collapse immediately; otherwise a symbolic Max(…) is formed (its algebra is
resolved by normalize).
Sourcepub fn imax(&self, other: &Universe) -> Universe
pub fn imax(&self, other: &Universe) -> Universe
The impredicative maximum imax(a, b) — the sort of a Π whose codomain
lives in b. Collapses when b’s Prop-ness is known: imax(a, Prop) = Prop,
imax(a, Type n) = max(a, Type n); imax(a, a) = a. Otherwise (a variable or
other symbolic b) it stays a symbolic IMax, whose algebra equiv/
is_subtype_of decide by case-splitting on whether b is Prop.
Sourcepub fn is_subtype_of(&self, other: &Universe) -> bool
pub fn is_subtype_of(&self, other: &Universe) -> bool
Cumulative subtyping self ≤ other, decided over the level normal form. Sound
for variables: u ≤ u, Type 0 ≤ u, u ≤ succ u hold, but Type 1 ≤ u and
u ≤ v do NOT (they fail for some instantiation).
Sourcepub fn is_never_prop(&self) -> bool
pub fn is_never_prop(&self) -> bool
Whether every instantiation of this level’s variables puts it at Type 0 or above: a
family in Sort ℓ is then never a proposition. Sort u may be Prop (at u := 0);
Sort (u+1) and Sort (max 1 u) never are.
Sourcepub fn least_level(&self) -> Universe
pub fn least_level(&self) -> Universe
The least universe LEVEL at or above this one: itself, with SProp raised to Prop. SProp
is a sort and never a level, and SProp ≤ Prop, so a level variable solved from a type in
SProp takes Prop, and cumulativity carries the type into Sort Prop.
Sourcepub fn mentions_sprop(&self) -> bool
pub fn mentions_sprop(&self) -> bool
Whether SProp occurs anywhere in this level expression.