{-# OPTIONS --allow-unsolved-metas #-} open import Level open import Ordinals module OD {n : Level } (O : Ordinals {n} ) where open import zf open import Data.Nat renaming ( zero to Zero ; suc to Suc ; ℕ to Nat ; _⊔_ to _n⊔_ ) open import Relation.Binary.PropositionalEquality open import Data.Nat.Properties open import Data.Empty open import Relation.Nullary open import Relation.Binary open import Relation.Binary.Core open import logic open import nat open inOrdinal O -- Ordinal Definable Set record OD : Set (suc n ) where field def : (x : Ordinal ) → Set n open OD open _∧_ open _∨_ open Bool record _==_ ( a b : OD ) : Set n where field eq→ : ∀ { x : Ordinal } → def a x → def b x eq← : ∀ { x : Ordinal } → def b x → def a x id : {A : Set n} → A → A id x = x ==-refl : { x : OD } → x == x ==-refl {x} = record { eq→ = id ; eq← = id } open _==_ ==-trans : { x y z : OD } → x == y → y == z → x == z ==-trans x=y y=z = record { eq→ = λ {m} t → eq→ y=z (eq→ x=y t) ; eq← = λ {m} t → eq← x=y (eq← y=z t) } ==-sym : { x y : OD } → x == y → y == x ==-sym x=y = record { eq→ = λ {m} t → eq← x=y t ; eq← = λ {m} t → eq→ x=y t } ⇔→== : { x y : OD } → ( {z : Ordinal } → def x z ⇔ def y z) → x == y eq→ ( ⇔→== {x} {y} eq ) {z} m = proj1 eq m eq← ( ⇔→== {x} {y} eq ) {z} m = proj2 eq m -- next assumptions are our axiom -- -- OD is an equation on Ordinals, so it contains Ordinals. If these Ordinals have one-to-one -- correspondence to the OD then the OD looks like a ZF Set. -- -- If all ZF Set have supreme upper bound, the solutions of OD have to be bounded, i.e. -- bbounded ODs are ZF Set. Unbounded ODs are classes. -- -- In classical Set Theory, HOD is used, as a subset of OD, -- HOD = { x | TC x ⊆ OD } -- where TC x is a transitive clusure of x, i.e. Union of all elemnts of all subset of x. -- This is not possible because we don't have V yet. So we assumes HODs are bounded OD. -- -- We also assumes HODs are isomorphic to Ordinals, which is ususally proved by Goedel number tricks. -- There two contraints on the HOD order, one is ∋, the other one is ⊂. -- ODs have an ovbious maximum, but Ordinals are not, but HOD has no maximum because there is an aribtrary -- bound on each HOD. -- -- In classical Set Theory, sup is defined by Uion, since we are working on constructive logic, -- we need explict assumption on sup. -- -- ==→o≡ is necessary to prove axiom of extensionality. -- Ordinals in OD , the maximum Ords : OD Ords = record { def = λ x → One } record HOD : Set (suc n) where field od : OD odmax : Ordinal <-osuc (sup-o< next-ord (sup-o next-ord)) where next-ord : Ordinal → Ordinal next-ord x = osuc x -- Ordinal in OD ( and ZFSet ) Transitive Set Ord : ( a : Ordinal ) → HOD Ord a = record { od = record { def = λ y → y o< a } ; odmax = a ; ¬a ¬b c = no ¬b -- the pair _,_ : HOD → HOD → HOD x , y = record { od = record { def = λ t → (t ≡ od→ord x ) ∨ ( t ≡ od→ord y ) } ; odmax = omax (od→ord x) (od→ord y) ; ¬a ¬b c | record { eq = eq1 } = next< (subst (λ k → k o< next o ) (sym eq1) (osucz → subst (λ k → def (od y) k ) diso (incl lt (d→∋ x x>z))) -- if we have od→ord (x , x) ≡ osuc (od→ord x), ⊆→o≤ → c<→o< ⊆→o≤→c<→o< : ({x : HOD} → od→ord (x , x) ≡ osuc (od→ord x) ) → ({y z : HOD } → ({x : Ordinal} → def (od y) x → def (od z) x ) → od→ord y o< osuc (od→ord z) ) → {x y : HOD } → def (od y) ( od→ord x ) → od→ord x o< od→ord y ⊆→o≤→c<→o< peq ⊆→o≤ {x} {y} y∋x with trio< (od→ord x) (od→ord y) ⊆→o≤→c<→o< peq ⊆→o≤ {x} {y} y∋x | tri< a ¬b ¬c = a ⊆→o≤→c<→o< peq ⊆→o≤ {x} {y} y∋x | tri≈ ¬a b ¬c = ⊥-elim ( o<¬≡ (peq {x}) (pair ¬a ¬b c = ⊥-elim ( o<> (⊆→o≤ {x , x} {y} y⊆x,x ) lemma1 ) where lemma : {z : Ordinal} → (z ≡ od→ord x) ∨ (z ≡ od→ord x) → od→ord x ≡ z lemma (case1 refl) = refl lemma (case2 refl) = refl y⊆x,x : {z : Ordinals.ord O} → def (od (x , x)) z → def (od y) z y⊆x,x {z} lt = subst (λ k → def (od y) k ) (lemma lt) y∋x lemma1 : osuc (od→ord y) o< od→ord (x , x) lemma1 = subst (λ k → osuc (od→ord y) o< k ) (sym (peq {x})) (osucc c ) subset-lemma : {A x : HOD } → ( {y : HOD } → x ∋ y → (A ∩ x ) ∋ y ) ⇔ ( x ⊆ A ) subset-lemma {A} {x} = record { proj1 = λ lt → record { incl = λ x∋z → proj1 (lt x∋z) } ; proj2 = λ x⊆A lt → record { proj1 = incl x⊆A lt ; proj2 = lt } } power< : {A x : HOD } → x ⊆ A → Ord (osuc (od→ord A)) ∋ x power< {A} {x} x⊆A = ⊆→o≤ (λ {y} x∋y → subst (λ k → def (od A) k) diso (lemma y x∋y ) ) where lemma : (y : Ordinal) → def (od x) y → def (od A) (od→ord (ord→od y)) lemma y x∋y = incl x⊆A (d→∋ x x∋y) open import Data.Unit ε-induction : { ψ : HOD → Set n} → ( {x : HOD } → ({ y : HOD } → x ∋ y → ψ y ) → ψ x ) → (x : HOD ) → ψ x ε-induction {ψ} ind x = subst (λ k → ψ k ) oiso (ε-induction-ord (osuc (od→ord x)) <-osuc ) where induction : (ox : Ordinal) → ((oy : Ordinal) → oy o< ox → ψ (ord→od oy)) → ψ (ord→od ox) induction ox prev = ind ( λ {y} lt → subst (λ k → ψ k ) oiso (prev (od→ord y) (o<-subst (c<→o< lt) refl diso ))) ε-induction-ord : (ox : Ordinal) { oy : Ordinal } → oy o< ox → ψ (ord→od oy) ε-induction-ord ox {oy} lt = TransFinite {λ oy → ψ (ord→od oy)} induction oy -- level trick (what'a shame) for LEM / minimal ε-induction1 : { ψ : HOD → Set (suc n)} → ( {x : HOD } → ({ y : HOD } → x ∋ y → ψ y ) → ψ x ) → (x : HOD ) → ψ x ε-induction1 {ψ} ind x = subst (λ k → ψ k ) oiso (ε-induction-ord (osuc (od→ord x)) <-osuc ) where induction : (ox : Ordinal) → ((oy : Ordinal) → oy o< ox → ψ (ord→od oy)) → ψ (ord→od ox) induction ox prev = ind ( λ {y} lt → subst (λ k → ψ k ) oiso (prev (od→ord y) (o<-subst (c<→o< lt) refl diso ))) ε-induction-ord : (ox : Ordinal) { oy : Ordinal } → oy o< ox → ψ (ord→od oy) ε-induction-ord ox {oy} lt = TransFinite1 {λ oy → ψ (ord→od oy)} induction oy Select : (X : HOD ) → ((x : HOD ) → Set n ) → HOD Select X ψ = record { od = record { def = λ x → ( odef X x ∧ ψ ( ord→od x )) } ; odmax = odmax X ; u ¬a ¬b c = ⊥-elim (not c) _∈_ : ( A B : HOD ) → Set n A ∈ B = B ∋ A OPwr : (A : HOD ) → HOD OPwr A = Ord ( sup-o (Ord (osuc (od→ord A))) ( λ x A∋x → od→ord ( A ∩ (ord→od x)) ) ) Power : HOD → HOD Power A = Replace (OPwr (Ord (od→ord A))) ( λ x → A ∩ x ) -- ｛_｝ : ZFSet → ZFSet -- ｛ x ｝ = ( x , x ) -- better to use (x , x) directly union→ : (X z u : HOD) → (X ∋ u) ∧ (u ∋ z) → Union X ∋ z union→ X z u xx not = ⊥-elim ( not (od→ord u) ( record { proj1 = proj1 xx ; proj2 = subst ( λ k → odef k (od→ord z)) (sym oiso) (proj2 xx) } )) union← : (X z : HOD) (X∋z : Union X ∋ z) → ¬ ( (u : HOD ) → ¬ ((X ∋ u) ∧ (u ∋ z ))) union← X z UX∋z = FExists _ lemma UX∋z where lemma : {y : Ordinal} → odef X y ∧ odef (ord→od y) (od→ord z) → ¬ ((u : HOD) → ¬ (X ∋ u) ∧ (u ∋ z)) lemma {y} xx not = not (ord→od y) record { proj1 = d→∋ X (proj1 xx) ; proj2 = proj2 xx } data infinite-d : ( x : Ordinal ) → Set n where iφ : infinite-d o∅ isuc : {x : Ordinal } → infinite-d x → infinite-d (od→ord ( Union (ord→od x , (ord→od x , ord→od x ) ) )) -- ω can be diverged in our case, since we have no restriction on the corresponding ordinal of a pair. -- We simply assumes infinite-d y has a maximum. -- -- This means that many of OD may not be HODs because of the od→ord mapping divergence. -- We should have some axioms to prevent this such as od→ord x o< next (odmax x). -- -- postulate -- ωmax : Ordinal -- <ωmax : {y : Ordinal} → infinite-d y → y o< ωmax -- -- infinite : HOD -- infinite = record { od = record { def = λ x → infinite-d x } ; odmax = ωmax ; ¬a ¬b c with (incl lt) (o<-subst c (sym diso) refl ) ... | ttt = ⊥-elim ( o<¬≡ refl (o<-subst ttt diso refl )) open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ ) -- postulate f-extensionality : { n m : Level} → HE.Extensionality n m nat→ω-iso : {i : HOD} → (lt : infinite ∋ i ) → nat→ω ( ω→nat i lt ) ≡ i nat→ω-iso {i} = ε-induction1 {λ i → (lt : infinite ∋ i ) → nat→ω ( ω→nat i lt ) ≡ i } ind i where ind : {x : HOD} → ({y : HOD} → x ∋ y → (lt : infinite ∋ y) → nat→ω (ω→nat y lt) ≡ y) → (lt : infinite ∋ x) → nat→ω (ω→nat x lt) ≡ x ind {x} prev lt = ind1 lt oiso where ind1 : {ox : Ordinal } → (ltd : infinite-d ox ) → ord→od ox ≡ x → nat→ω (ω→nato ltd) ≡ x ind1 {o∅} iφ refl = sym o∅≡od∅ ind1 (isuc {x₁} ltd) ox=x = begin nat→ω (ω→nato (isuc ltd) ) ≡⟨⟩ Union (nat→ω (ω→nato ltd) , (nat→ω (ω→nato ltd) , nat→ω (ω→nato ltd))) ≡⟨ cong (λ k → Union (k , (k , k ))) lemma ⟩ Union (ord→od x₁ , (ord→od x₁ , ord→od x₁)) ≡⟨ trans ( sym oiso) ox=x ⟩ x ∎ where open ≡-Reasoning lemma0 : x ∋ ord→od x₁ lemma0 = subst (λ k → odef k (od→ord (ord→od x₁))) (trans (sym oiso) ox=x) (λ not → not (od→ord (ord→od x₁ , ord→od x₁)) record {proj1 = pair2 ; proj2 = subst (λ k → odef k (od→ord (ord→od x₁))) (sym oiso) pair1 } ) lemma1 : infinite ∋ ord→od x₁ lemma1 = subst (λ k → odef infinite k) (sym diso) ltd lemma5 : {x y : Ordinal} → od→ord (Union (ord→od y , (ord→od y , ord→od y))) ≡ od→ord (Union (ord→od x , (ord→od x , ord→od x))) → x ≡ y lemma5 {x} {y} eq = {!!} lemma3 : {x y : Ordinal} → (ltd : infinite-d x ) (ltd1 : infinite-d y ) → y ≡ x → ltd ≅ ltd1 lemma3 iφ iφ refl = HE.refl lemma3 iφ (isuc ltd1) eq = {!!} lemma3 (isuc ltd) iφ eq = {!!} lemma3 (isuc {x} ltd) (isuc {y} ltd1) eq with lemma3 ltd ltd1 (lemma5 (sym eq)) ... | t = HE.cong₂ (λ j k → isuc {j} k ) (HE.≡-to-≅ (lemma5 eq)) t lemma2 : {x y : Ordinal} → (ltd : infinite-d x ) (ltd1 : infinite-d y ) → y ≡ x → ω→nato ltd ≡ ω→nato ltd1 lemma2 {x} {y} ltd ltd1 eq = lemma6 eq (lemma3 {x} {y} ltd ltd1 eq) where lemma6 : {x y : Ordinal} → {ltd : infinite-d x } {ltd1 : infinite-d y } → y ≡ x → ltd ≅ ltd1 → ω→nato ltd ≡ ω→nato ltd1 lemma6 refl HE.refl = refl lemma : nat→ω (ω→nato ltd) ≡ ord→od x₁ lemma = trans (cong (λ k → nat→ω k) (lemma2 {x₁} {_} ltd (subst (λ k → infinite-d k ) (sym diso) ltd) diso ) ) ( prev {ord→od x₁} lemma0 lemma1 ) ω→nat-iso : {i : Nat} → ω→nat ( nat→ω i ) (ω∋nat→ω {i}) ≡ i ω→nat-iso {Zero} = {!!} ω→nat-iso {Suc i} = {!!} ψiso : {ψ : HOD → Set n} {x y : HOD } → ψ x → x ≡ y → ψ y ψiso {ψ} t refl = t selection : {ψ : HOD → Set n} {X y : HOD} → ((X ∋ y) ∧ ψ y) ⇔ (Select X ψ ∋ y) selection {ψ} {X} {y} = record { proj1 = λ cond → record { proj1 = proj1 cond ; proj2 = ψiso {ψ} (proj2 cond) (sym oiso) } ; proj2 = λ select → record { proj1 = proj1 select ; proj2 = ψiso {ψ} (proj2 select) oiso } } selection-in-domain : {ψ : HOD → Set n} {X y : HOD} → Select X ψ ∋ y → X ∋ y selection-in-domain {ψ} {X} {y} lt = proj1 ((proj2 (selection {ψ} {X} )) lt) sup-c< : (ψ : HOD → HOD) → {X x : HOD} → X ∋ x → od→ord (ψ x) o< (sup-o X (λ y X∋y → od→ord (ψ (ord→od y)))) sup-c< ψ {X} {x} lt = subst (λ k → od→ord (ψ k) o< _ ) oiso (sup-o< X lt ) replacement← : {ψ : HOD → HOD} (X x : HOD) → X ∋ x → Replace X ψ ∋ ψ x replacement← {ψ} X x lt = record { proj1 = sup-c< ψ {X} {x} lt ; proj2 = lemma } where lemma : def (in-codomain X ψ) (od→ord (ψ x)) lemma not = ⊥-elim ( not ( od→ord x ) (record { proj1 = lt ; proj2 = cong (λ k → od→ord (ψ k)) (sym oiso)} )) replacement→ : {ψ : HOD → HOD} (X x : HOD) → (lt : Replace X ψ ∋ x) → ¬ ( (y : HOD) → ¬ (x =h= ψ y)) replacement→ {ψ} X x lt = contra-position lemma (lemma2 (proj2 lt)) where lemma2 : ¬ ((y : Ordinal) → ¬ odef X y ∧ ((od→ord x) ≡ od→ord (ψ (ord→od y)))) → ¬ ((y : Ordinal) → ¬ odef X y ∧ (ord→od (od→ord x) =h= ψ (ord→od y))) lemma2 not not2 = not ( λ y d → not2 y (record { proj1 = proj1 d ; proj2 = lemma3 (proj2 d)})) where lemma3 : {y : Ordinal } → (od→ord x ≡ od→ord (ψ (ord→od y))) → (ord→od (od→ord x) =h= ψ (ord→od y)) lemma3 {y} eq = subst (λ k → ord→od (od→ord x) =h= k ) oiso (o≡→== eq ) lemma : ( (y : HOD) → ¬ (x =h= ψ y)) → ( (y : Ordinal) → ¬ odef X y ∧ (ord→od (od→ord x) =h= ψ (ord→od y)) ) lemma not y not2 = not (ord→od y) (subst (λ k → k =h= ψ (ord→od y)) oiso ( proj2 not2 )) --- --- Power Set --- --- First consider ordinals in HOD --- --- A ∩ x = record { def = λ y → odef A y ∧ odef x y } subset of A -- -- ∩-≡ : { a b : HOD } → ({x : HOD } → (a ∋ x → b ∋ x)) → a =h= ( b ∩ a ) ∩-≡ {a} {b} inc = record { eq→ = λ {x} x