module univTypes.Model.SetTheory where open import Data.Nat using (ℕ; zero; suc; _≤_; _<_) open import Relation.Binary.PropositionalEquality using (_≡_) -- The set theory the model lives in, as an interface (cf. con-leche's -- `SetTheory`). It is a record, passed as a module parameter, so no -- postulate is involved; consistency is relative to the existence of an -- instance. ZFC with ω·2 inaccessible cardinals κ₀ < κ₁ < … < κ_ω < … has -- one: V the sets, U (fin k) = V_{κ_k}, U (ω+ m) = V_{κ_{ω+m}}, graphs for -- functions, Kuratowski pairs, von Neumann naturals. -- -- Functions and families are given by meta-level functions V → V (class -- functions; replacement makes their restrictions to a set into sets). -- Some operations are total but only specified on their intended -- arguments (app, fst, snd, toℕ), as in set theory. -- Universe strata: fin k for Set k, ω+ m for Setω m. data Stratum : Set where fin : ℕ → Stratum ω+ : ℕ → Stratum infix 4 _≤ˢ_ _<ˢ_ data _≤ˢ_ : Stratum → Stratum → Set where fin≤ : ∀ {j k} → j ≤ k → fin j ≤ˢ fin k finω : ∀ {j m} → fin j ≤ˢ ω+ m ω≤ : ∀ {m m'} → m ≤ m' → ω+ m ≤ˢ ω+ m' data _<ˢ_ : Stratum → Stratum → Set where fin< : ∀ {j k} → j < k → fin j <ˢ fin k finω : ∀ {j m} → fin j <ˢ ω+ m ω< : ∀ {m m'} → m < m' → ω+ m <ˢ ω+ m' record SetTheory : Set₁ where infix 4 _∈_ field V : Set _∈_ : V → V → Set -- Truth: a one-element set, and equality as a subset of it. ⋆ : V ⊤ˢ : V ⋆∈⊤ : ⋆ ∈ ⊤ˢ Id : V → V → V Id-intro : ∀ {a} → ⋆ ∈ Id a a Id-elim : ∀ {a b x} → x ∈ Id a b → a ≡ b -- Dependent functions: graphs over a domain. Pi : V → (V → V) → V lam : V → (V → V) → V app : V → V → V dom : V → V dom-lam : ∀ {A g} → dom (lam A g) ≡ A app-lam : ∀ {A g x} → x ∈ A → app (lam A g) x ≡ g x lam-∈ : ∀ {A F g} → (∀ {x} → x ∈ A → g x ∈ F x) → lam A g ∈ Pi A F app-∈ : ∀ {A F f x} → f ∈ Pi A F → x ∈ A → app f x ∈ F x Pi-dom : ∀ {A F f} → f ∈ Pi A F → dom f ≡ A lam-ext : ∀ {A g g'} → (∀ {x} → x ∈ A → g x ≡ g' x) → lam A g ≡ lam A g' Pi-ext : ∀ {A F F'} → (∀ {x} → x ∈ A → F x ≡ F' x) → Pi A F ≡ Pi A F' -- Dependent pairs. Sig : V → (V → V) → V pair : V → V → V fst : V → V snd : V → V fst-pair : ∀ {a b} → fst (pair a b) ≡ a snd-pair : ∀ {a b} → snd (pair a b) ≡ b pair-∈ : ∀ {A F a b} → a ∈ A → b ∈ F a → pair a b ∈ Sig A F fst-∈ : ∀ {A F p} → p ∈ Sig A F → fst p ∈ A snd-∈ : ∀ {A F p} → p ∈ Sig A F → snd p ∈ F (fst p) Sig-ext : ∀ {A F F'} → (∀ {x} → x ∈ A → F x ≡ F' x) → Sig A F ≡ Sig A F' -- The natural numbers. ω : V fromℕ : ℕ → V toℕ : V → ℕ fromℕ-∈ : ∀ {k} → fromℕ k ∈ ω toℕ-fromℕ : ∀ k → toℕ (fromℕ k) ≡ k ω-elim : ∀ {x} → x ∈ ω → fromℕ (toℕ x) ≡ x -- Cumulative universes, closed under the type formers. U : Stratum → V U-∈ : ∀ {β β'} → β <ˢ β' → U β ∈ U β' U-⊆ : ∀ {β β' x} → β ≤ˢ β' → x ∈ U β → x ∈ U β' ⊤-U : ⊤ˢ ∈ U (fin 0) ω-U : ω ∈ U (fin 0) Id-U : ∀ {a b} → Id a b ∈ U (fin 0) Pi-U : ∀ {β A F} → A ∈ U β → (∀ {x} → x ∈ A → F x ∈ U β) → Pi A F ∈ U β Sig-U : ∀ {β A F} → A ∈ U β → (∀ {x} → x ∈ A → F x ∈ U β) → Sig A F ∈ U β