open import univTypes.Model.TarskiGrothendieck using (TG; TarskiAxiom; IsTarski; Equinumerous) module univTypes.Model.FromTarski (T : TG) where open import Data.Empty using (⊥; ⊥-elim) open import Data.Product using (Σ; _×_; proj₁; proj₂) renaming (_,_ to ⟨_,_⟩) open import Data.Sum using (_⊎_; inj₁; inj₂) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong; subst) renaming (trans to ≡-trans) open import Relation.Nullary using (¬_) open import univTypes.Model.Grothendieck using (ZFCU; ZFBase; UniverseAxiom; IsUniverse) open TG T open ZFBase base open TarskiAxiom ta -- Every Tarski universe is a Grothendieck universe, without choice: -- * power sets: the member containing all subsets, and subset closure; -- * replacement: an image of a member as big as U would give a map from -- that member onto its own power set (Cantor); -- * unions: if ⋃ x were as big as U, the images of the members of x would -- form a member Y of U with ⋃ Y = U, so Y ∈ y ∈ Y (regularity); -- * pairs: an image of the two-element set 𝒫 (𝒫 ∅). -- Hence Tarski–Grothendieck set theory gives Grothendieck's universe -- axiom (Model/Grothendieck), and with it our ZF record. private sng : V → V sng a = upair a a sng-in : ∀ {z a} → z ∈ sng a → z ≡ a sng-in p with upair-in p ... | inj₁ q = q ... | inj₂ q = q -- No 2-cycles of membership (regularity on {a, b}). cycle : ∀ {a b} → a ∈ b → b ∈ a → ⊥ cycle {a} {b} a∈b b∈a with regularity (upair a b) ⟨ a , upair-l ⟩ ... | ⟨ m , ⟨ m∈ , min ⟩ ⟩ with upair-in m∈ ... | inj₁ refl = min b b∈a upair-r ... | inj₂ refl = min a a∈b upair-l module Closure (U u₀ : V) (u₀∈ : u₀ ∈ U) (t : IsTarski base U) where open IsTarski t renaming (trans to U-trans) -- The empty set: an ∈-minimal member of the nonempty, transitive U. private minimal : Σ V λ y → y ∈ U × (∀ z → z ∈ y → z ∈ U → ⊥) minimal = regularity U ⟨ u₀ , u₀∈ ⟩ ∅ : V ∅ = proj₁ minimal ∉∅ : ∀ {z} → z ∈ ∅ → ⊥ ∉∅ {z} z∈ = proj₂ (proj₂ minimal) z z∈ (U-trans (proj₁ (proj₂ minimal)) z∈) ∅-⊆ : ∀ {x} → ∀ w → w ∈ ∅ → w ∈ x ∅-⊆ w w∈ = ⊥-elim (∉∅ w∈) -- Separation, from replacement and classical logic. private pick : (V → Set) → V → V pick P w with em (P w) ... | inj₁ _ = sng w ... | inj₂ _ = ∅ sep : (V → Set) → V → V sep P x = ⋃ (image (pick P) x) sep-in : ∀ {P z x} → z ∈ sep P x → z ∈ x × P z sep-in {P} {z} p with ⋃-in p ... | ⟨ y , ⟨ y∈ , z∈y ⟩ ⟩ with image-in y∈ ... | ⟨ w , ⟨ w∈ , refl ⟩ ⟩ = go w w∈ z∈y where go : ∀ w → w ∈ _ → z ∈ pick P w → z ∈ _ × P z go w w∈ z∈ with em (P w) ... | inj₁ pw = let e = sng-in z∈ in ⟨ subst (_∈ _) (sym e) w∈ , subst P (sym e) pw ⟩ ... | inj₂ _ = ⊥-elim (∉∅ z∈) sep-intro : ∀ {P z x} → z ∈ x → P z → z ∈ sep P x sep-intro {P} {z} {x} z∈ pz = ⋃-intro (image-intro z∈) go where go : z ∈ pick P z go with em (P z) ... | inj₁ _ = upair-l ... | inj₂ ¬p = ⊥-elim (¬p pz) -- Power sets. powerU : ∀ {x} → x ∈ U → 𝒫 x ∈ U powerU x∈ with powers x∈ ... | ⟨ p , ⟨ p∈ , all ⟩ ⟩ = subset p∈ (λ w w∈ → all w (𝒫-in w∈)) -- Cantor: no member of U maps onto U (it would map onto its power set). noSurj : ∀ {x} → x ∈ U → (s : V → V) → (∀ u → u ∈ U → Σ V λ a → a ∈ x × s a ≡ u) → ⊥ noSurj {x} x∈ s surj = diag (d∈D→ d∈D-or-not) where P = 𝒫 x -- Retract U onto P. r : V → V r u with em (u ∈ P) ... | inj₁ _ = u ... | inj₂ _ = ∅ r-P : ∀ {u} → u ∈ P → r u ≡ u r-P {u} u∈ with em (u ∈ P) ... | inj₁ _ = refl ... | inj₂ ¬p = ⊥-elim (¬p u∈) s' : V → V s' a = r (s a) D : V D = sep (λ a → a ∈ s' a → ⊥) x D∈U : D ∈ U D∈U = U-trans (powerU x∈) (𝒫-intro (λ w w∈ → proj₁ (sep-in w∈))) hit : Σ V λ d → d ∈ x × s' d ≡ D hit with surj D D∈U ... | ⟨ d , ⟨ d∈ , e ⟩ ⟩ = ⟨ d , ⟨ d∈ , ≡-trans (cong r e) (r-P (𝒫-intro (λ w w∈ → proj₁ (sep-in w∈)))) ⟩ ⟩ d = proj₁ hit d∈D-or-not : (d ∈ D) ⊎ (d ∈ D → ⊥) d∈D-or-not = em (d ∈ D) d∈D→ : (d ∈ D) ⊎ (d ∈ D → ⊥) → ⊥ d∈D→ (inj₁ d∈D) = proj₂ (sep-in d∈D) (subst (d ∈_) (sym (proj₂ (proj₂ hit))) d∈D) d∈D→ (inj₂ d∉D) = d∉D (sep-intro (proj₁ (proj₂ hit)) (λ d∈s'd → d∉D (subst (d ∈_) (proj₂ (proj₂ hit)) d∈s'd))) diag : ⊥ → ⊥ diag x = x -- Replacement. imgU : ∀ {f x} → x ∈ U → (∀ w → w ∈ x → f w ∈ U) → image f x ∈ U imgU {f} {x} x∈ f∈ with card {y = image f x} sub where sub : ∀ w → w ∈ image f x → w ∈ U sub w w∈ with image-in w∈ ... | ⟨ a , ⟨ a∈ , refl ⟩ ⟩ = f∈ a a∈ ... | inj₂ ok = ok ... | inj₁ ⟨ k , ⟨ _ , ⟨ _ , ksurj ⟩ ⟩ ⟩ = ⊥-elim (noSurj x∈ (λ a → k (f a)) surj) where surj : ∀ u → u ∈ U → Σ V λ a → a ∈ x × k (f a) ≡ u surj u u∈ with ksurj u u∈ ... | ⟨ b , ⟨ b∈ , kb ⟩ ⟩ with image-in b∈ ... | ⟨ a , ⟨ a∈ , e ⟩ ⟩ = ⟨ a , ⟨ a∈ , ≡-trans (cong k (sym e)) kb ⟩ ⟩ -- Unions. ⋃U : ∀ {x} → x ∈ U → ⋃ x ∈ U ⋃U {x} x∈ with card {y = ⋃ x} sub where sub : ∀ w → w ∈ ⋃ x → w ∈ U sub w w∈ with ⋃-in w∈ ... | ⟨ y , ⟨ y∈ , w∈y ⟩ ⟩ = U-trans (U-trans x∈ y∈) w∈y ... | inj₂ ok = ok ... | inj₁ ⟨ g , ⟨ gU , ⟨ _ , gsurj ⟩ ⟩ ⟩ = ⊥-elim (cycle Y∈y' y'∈Y) where Y : V Y = image (λ y → image g y) x Y∈ : Y ∈ U Y∈ = imgU x∈ (λ y y∈ → imgU (U-trans x∈ y∈) (λ a a∈ → gU a (⋃-intro y∈ a∈))) Y∈⋃Y : Y ∈ ⋃ Y Y∈⋃Y with gsurj Y Y∈ ... | ⟨ a , ⟨ a∈ , ga ⟩ ⟩ with ⋃-in a∈ ... | ⟨ y , ⟨ y∈ , a∈y ⟩ ⟩ = ⋃-intro (image-intro {f = λ y → image g y} y∈) (subst (_∈ image g y) ga (image-intro {f = g} a∈y)) y' = proj₁ (⋃-in Y∈⋃Y) y'∈Y = proj₁ (proj₂ (⋃-in Y∈⋃Y)) Y∈y' = proj₂ (proj₂ (⋃-in Y∈⋃Y)) -- Pairs: {x, y} is an image of the two-element set 𝒫 (𝒫 ∅). ∅U : ∅ ∈ U ∅U = subset u₀∈ ∅-⊆ pairU : ∀ {x y} → x ∈ U → y ∈ U → upair x y ∈ U pairU {x} {y} x∈ y∈ = subset (imgU {f = c} (powerU (powerU ∅U)) c∈) sub where c : V → V c w with em (w ≡ ∅) ... | inj₁ _ = x ... | inj₂ _ = y c∈ : ∀ w → w ∈ 𝒫 (𝒫 ∅) → c w ∈ U c∈ w _ with em (w ≡ ∅) ... | inj₁ _ = x∈ ... | inj₂ _ = y∈ c-∅ : c ∅ ≡ x c-∅ with em (∅ ≡ ∅) ... | inj₁ _ = refl ... | inj₂ ¬p = ⊥-elim (¬p refl) 𝒫∅≢∅ : 𝒫 ∅ ≡ ∅ → ⊥ 𝒫∅≢∅ e = ∉∅ (subst (∅ ∈_) e (𝒫-intro ∅-⊆)) c-𝒫∅ : c (𝒫 ∅) ≡ y c-𝒫∅ with em (𝒫 ∅ ≡ ∅) ... | inj₁ e = ⊥-elim (𝒫∅≢∅ e) ... | inj₂ _ = refl sub : ∀ w → w ∈ upair x y → w ∈ image c (𝒫 (𝒫 ∅)) sub w w∈ with upair-in w∈ ... | inj₁ refl = subst (_∈ image c (𝒫 (𝒫 ∅))) c-∅ (image-intro {f = c} (𝒫-intro ∅-⊆)) ... | inj₂ refl = subst (_∈ image c (𝒫 (𝒫 ∅))) c-𝒫∅ (image-intro {f = c} (𝒫-intro (λ w w∈ → w∈))) isUniverse : IsUniverse base U isUniverse = record { trans = U-trans ; pair = pairU ; power = powerU ; family = λ I∈ f∈ → ⋃U (imgU I∈ f∈) } -- Grothendieck's universe axiom from Axiom A. toZFCU : ZFCU toZFCU = record { base = base ; ua = record { 𝕌 = λ x → proj₁ (tarski x) ; 𝕌-∋ = λ x → proj₁ (proj₂ (tarski x)) ; 𝕌-is = λ x → Closure.isUniverse (proj₁ (tarski x)) x (proj₁ (proj₂ (tarski x))) (proj₂ (proj₂ (tarski x))) } }