Typecheck / agda (push) Successful in 5m16s
Model/Mathlib states one field per lemma of Mathlib's ZFSet (Mathlib/SetTheory/ZFC/Basic.lean), with Lean names and statements in Agda syntax. Model/FromMathlib derives the base ZF axioms from it (ω as the least inductive subset of Mathlib's omega). Mathlib's ZFSet has no universes, so Model/ConsistencyZF adds Grothendieck's universe axiom on top: no-False-Mathlib, no-0≡1-Mathlib, no-∀A→A-Mathlib. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q7dfaHQ3dYSfqcxR7V5UrJ
131 lines
5.3 KiB
Agda
131 lines
5.3 KiB
Agda
open import univTypes.Model.Mathlib using (Mathlib)
|
||
|
||
module univTypes.Model.FromMathlib (M : Mathlib) 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; subst)
|
||
|
||
open import univTypes.Model.Grothendieck using (ZFBase)
|
||
|
||
open Mathlib M
|
||
|
||
-- The base ZF axioms (Model/Grothendieck) from Mathlib's ZFSet rules:
|
||
-- pairs are `insert a {b}` as in Mathlib, and ω is the least inductive
|
||
-- subset of Mathlib's omega (Mathlib states only that omega is
|
||
-- inductive; our induction principle is carved out by separation).
|
||
|
||
-- Helpers ----------------------------------------------------------------------------------------
|
||
|
||
sep-in : ∀ {P x y} → y ∈ sep P x → y ∈ x × P y
|
||
sep-in {P} = proj₁ (mem-sep {p = P})
|
||
|
||
sep-intro : ∀ {P x y} → y ∈ x → P y → y ∈ sep P x
|
||
sep-intro {P} y∈ py = proj₂ (mem-sep {p = P}) ⟨ y∈ , py ⟩
|
||
|
||
ins-l : ∀ {x z} → x ∈ insert x z
|
||
ins-l = proj₂ mem-insert-iff (inj₁ refl)
|
||
|
||
ins-r : ∀ {x y z} → x ∈ z → x ∈ insert y z
|
||
ins-r x∈ = proj₂ mem-insert-iff (inj₂ x∈)
|
||
|
||
-- {a, b} = insert a {b}, {b} = insert b ∅.
|
||
upair : ZFSet → ZFSet → ZFSet
|
||
upair a b = insert a (insert b ∅)
|
||
|
||
upair-in : ∀ {z a b} → z ∈ upair a b → z ≡ a ⊎ z ≡ b
|
||
upair-in z∈ with proj₁ mem-insert-iff z∈
|
||
... | inj₁ e = inj₁ e
|
||
... | inj₂ z∈' with proj₁ mem-insert-iff z∈'
|
||
... | inj₁ e = inj₂ e
|
||
... | inj₂ z∈∅ = ⊥-elim (notMem-empty _ z∈∅)
|
||
|
||
upair-l : ∀ {a b} → a ∈ upair a b
|
||
upair-l = ins-l
|
||
|
||
upair-r : ∀ {a b} → b ∈ upair a b
|
||
upair-r = ins-r ins-l
|
||
|
||
⋃-intro : ∀ {z x y} → y ∈ x → z ∈ y → z ∈ ⋃₀ x
|
||
⋃-intro y∈ z∈ = proj₂ mem-sUnion ⟨ _ , ⟨ y∈ , z∈ ⟩ ⟩
|
||
|
||
-- The successor of ZFBase is Mathlib's `insert n n`.
|
||
succ : ZFSet → ZFSet
|
||
succ x = ⋃₀ (upair x (upair x x))
|
||
|
||
succ-insert : ∀ x → succ x ≡ insert x x
|
||
succ-insert x = ext λ z → ⟨ to z , from z ⟩
|
||
where
|
||
to : ∀ z → z ∈ succ x → z ∈ insert x x
|
||
to z z∈ with proj₁ mem-sUnion z∈
|
||
... | ⟨ y , ⟨ y∈ , z∈y ⟩ ⟩ with upair-in y∈
|
||
... | inj₁ refl = ins-r z∈y
|
||
... | inj₂ refl with upair-in z∈y
|
||
... | inj₁ refl = ins-l
|
||
... | inj₂ refl = ins-l
|
||
from : ∀ z → z ∈ insert x x → z ∈ succ x
|
||
from z z∈ with proj₁ mem-insert-iff z∈
|
||
... | inj₁ refl = ⋃-intro upair-r upair-l
|
||
... | inj₂ z∈x = ⋃-intro upair-l z∈x
|
||
|
||
-- ω: the least inductive subset of omega -----------------------------------------------------
|
||
|
||
Inductive : ZFSet → Set
|
||
Inductive I = ∅ ∈ I × (∀ m → m ∈ I → succ m ∈ I)
|
||
|
||
omega-ind : Inductive omega
|
||
omega-ind = ⟨ omega-zero , (λ m m∈ → subst (_∈ omega) (sym (succ-insert m)) (omega-succ m∈)) ⟩
|
||
|
||
ω : ZFSet
|
||
ω = sep (λ n → ∀ I → Inductive I → n ∈ I) omega
|
||
|
||
empty-∅ : ∀ {e} → (∀ z → z ∈ e → ⊥) → e ≡ ∅
|
||
empty-∅ {e} h = ext λ z → ⟨ (λ z∈ → ⊥-elim (h z z∈)) , (λ z∈ → ⊥-elim (notMem-empty z z∈)) ⟩
|
||
|
||
∅∈ω : ∅ ∈ ω
|
||
∅∈ω = sep-intro omega-zero (λ I i → proj₁ i)
|
||
|
||
ω-zero : ∀ {e} → (∀ z → z ∈ e → ⊥) → e ∈ ω
|
||
ω-zero h = subst (_∈ ω) (sym (empty-∅ h)) ∅∈ω
|
||
|
||
ω-suc : ∀ {x} → x ∈ ω → succ x ∈ ω
|
||
ω-suc {x} x∈ with sep-in x∈
|
||
... | ⟨ x∈o , all ⟩ = sep-intro (proj₂ omega-ind x x∈o) (λ I i → proj₂ i x (all I i))
|
||
|
||
ω-ind : (P : ZFSet → Set) → (∀ e → (∀ z → z ∈ e → ⊥) → P e)
|
||
→ (∀ x → x ∈ ω → P x → P (succ x))
|
||
→ ∀ x → x ∈ ω → P x
|
||
ω-ind P base step x x∈ = proj₂ (sep-in (proj₂ (sep-in x∈) I I-ind))
|
||
where
|
||
I : ZFSet
|
||
I = sep P ω
|
||
I-ind : Inductive I
|
||
I-ind = ⟨ sep-intro ∅∈ω (base ∅ notMem-empty)
|
||
, (λ m m∈ → let ⟨ m∈ω , pm ⟩ = sep-in m∈ in sep-intro (ω-suc m∈ω) (step m m∈ω pm)) ⟩
|
||
|
||
-- Regularity ---------------------------------------------------------------------------------------
|
||
|
||
regularity' : ∀ x → Σ ZFSet (λ y → y ∈ x) → Σ ZFSet λ y → y ∈ x × (∀ z → z ∈ y → z ∈ x → ⊥)
|
||
regularity' x ⟨ y₀ , y₀∈ ⟩ with regularity x (λ e → notMem-empty y₀ (subst (y₀ ∈_) e y₀∈))
|
||
... | ⟨ y , ⟨ y∈ , e ⟩ ⟩ =
|
||
⟨ y , ⟨ y∈ , (λ z z∈y z∈x → notMem-empty z (subst (z ∈_) e (sep-intro {P = _∈ y} z∈x z∈y))) ⟩ ⟩
|
||
|
||
-- The base axioms ----------------------------------------------------------------------------------
|
||
|
||
toBase : ZFBase
|
||
toBase = record
|
||
{ V = ZFSet ; _∈_ = _∈_ ; em = em
|
||
; ext = λ to from → ext (λ z → ⟨ to z , from z ⟩)
|
||
; upair = upair ; upair-in = upair-in ; upair-l = upair-l ; upair-r = upair-r
|
||
; ⋃ = ⋃₀ ; ⋃-in = proj₁ mem-sUnion ; ⋃-intro = ⋃-intro
|
||
; 𝒫 = powerset
|
||
; 𝒫-in = λ z∈ w w∈ → proj₁ mem-powerset z∈ w∈
|
||
; 𝒫-intro = λ h → proj₂ mem-powerset (λ {w} → h w)
|
||
; image = image
|
||
; image-in = λ {f} z∈ → let ⟨ w , ⟨ w∈ , e ⟩ ⟩ = proj₁ (mem-image {f = f}) z∈ in ⟨ w , ⟨ w∈ , sym e ⟩ ⟩
|
||
; image-intro = λ {f} w∈ → proj₂ (mem-image {f = f}) ⟨ _ , ⟨ w∈ , refl ⟩ ⟩
|
||
; regularity = regularity'
|
||
; ω = ω ; ω-zero = ω-zero ; ω-suc = ω-suc ; ω-ind = ω-ind
|
||
}
|