module 1Lab.Type whereUniversesπ
A universe is a type whose inhabitants are types. In
Agda, there is a family of universes, which, by default, is called
Set. Rather recently, Agda gained a flag to make
Set not act like a keyword, and allow renaming it in an
import declaration from the Agda.Primitive module.
open import Prim.Type hiding (Prop) publicType is a type itself, so itβs a
natural question to ask: does it belong to a universe? The answer is
yes. However, Type can not belong to itself, or we could
reproduce Russellβs paradox.
To prevent this, the universes are parametrised by a Level, where the collection of all
β-sized types is Type (lsuc β):
_ : (β : Level) β Type (lsuc β)
_ = Ξ» β β Type β
level-of : {β : Level} β Type β β Level
level-of {β} _ = βBuilt-in typesπ
We re-export the following very important types:
open import Prim.Data.Sigma public
open import Prim.Data.Bool public
open import Prim.Data.Nat hiding (_<_) publicAdditionally, we define the empty type:
data β₯ : Type where
absurd : β {β} {A : Type β} β .β₯ β A
absurd ()
Β¬_ : β {β} β Type β β Type β
Β¬ A = A β β₯
infix 6 Β¬_The non-dependent product type _Γ_
can be defined in terms of the dependent sum type:
_Γ_ : β {a b} β Type a β Type b β Type _
A Γ B = Ξ£[ _ β A ] B
infixr 5 _Γ_Liftingπ
There is a function which lifts a type to a higher universe:
record Lift {a} β (A : Type a) : Type (a β β) where
constructor lift
field
lower : AFunction compositionπ
Since the following definitions are fundamental, they deserve a place in this module:
_β_ : β {ββ ββ ββ} {A : Type ββ} {B : A β Type ββ} {C : (x : A) β B x β Type ββ}
β (β {x} β (y : B x) β C x y)
β (f : β x β B x)
β β x β C x (f x)
f β g = Ξ» z β f (g z)
infixr 40 _β_
id : β {β} {A : Type β} β A β A
id x = x
{-# INLINE id #-}
infixr -1 _$_ _$α΅’_ _$β_
_$_ : β {ββ ββ} {A : Type ββ} {B : A β Type ββ} β ((x : A) β B x) β ((x : A) β B x)
f $ x = f x
{-# INLINE _$_ #-}
_$α΅’_ : β {ββ ββ} {A : Type ββ} {B : .A β Type ββ} β (.(x : A) β B x) β (.(x : A) β B x)
f $α΅’ x = f x
{-# INLINE _$α΅’_ #-}
_$β_ : β {ββ ββ} {A : Type ββ} {B : A β SSet ββ} β ((x : A) β B x) β ((x : A) β B x)
f $β x = f x
{-# INLINE _$β_ #-}open import Prim.Literals public
β-closed
: (β {β β'} {A : Type β} {B : Type β'} β (A β B) β Type (β β β')) β TypeΟ
β-closed P =
β {β β' β''} {A : Type β} {B : Type β'} {C : Type β''}
{f : B β C} {g : A β B}
β P f β P g β P (f β g)
auto : β {β} {A : Type β} β β¦ A β¦ β A
auto β¦ a β¦ = a
case_of_ : β {β β'} {A : Type β} {B : Type β'} β A β (A β B) β B
case x of f = f x
case_return_of_ : β {β β'} {A : Type β} (x : A) (B : A β Type β') (f : (x : A) β B x) β B x
case x return P of f = f x
{-# INLINE case_of_ #-}
{-# INLINE case_return_of_ #-}
instance
Number-Lift : β {β β'} {A : Type β} β β¦ Number A β¦ β Number (Lift β' A)
Number-Lift {β' = β'} β¦ a β¦ .Number.Constraint n = Lift β' (a .Number.Constraint n)
Number-Lift β¦ a β¦ .Number.fromNat n β¦ lift c β¦ = lift (a .Number.fromNat n β¦ c β¦)
absurdΟ : {A : TypeΟ} β .β₯ β A
absurdΟ ()
infixr -1 primForce
primitive
primForce : β {a b} {A : Type a} {B : A β Type b} (x : A) (f : β x β B x) β B x
syntax primForce x f = f $! x