### view generic-filter.agda @ 390:d58edc4133b0

generic filter
author Shinji KONO Sat, 25 Jul 2020 13:33:53 +0900 cb183674facf e98b5774d180
line wrap: on
line source
```
open import Level
open import Ordinals
module generic-filter {n : Level } (O : Ordinals {n})   where

import filter
open import zf
open import logic
open import partfunc {n} O
import OD

open import Relation.Nullary
open import Relation.Binary
open import Data.Empty
open import Relation.Binary
open import Relation.Binary.Core
open import Relation.Binary.PropositionalEquality
open import Data.Nat renaming ( zero to Zero ; suc to Suc ;  ℕ to Nat ; _⊔_ to _n⊔_ )
import BAlgbra

open BAlgbra O

open inOrdinal O
open OD O
open OD.OD
open ODAxiom odAxiom

import ODC

open filter O

open _∧_
open _∨_
open Bool

open HOD

-------
--    the set of finite partial functions from ω to 2
--
--

open import Data.List
open import Data.Maybe

import OPair
open OPair O

open PFunc

_f∩_ : (f g : PFunc (Lift n Nat) (Lift n Two) ) →  PFunc (Lift n Nat) (Lift n Two)
f f∩ g = record { dom = λ x → (dom f x ) ∧ (dom g x ) ∧ ((fr : dom f x ) → (gr : dom g x ) → pmap f x fr ≡ pmap g x gr)
; pmap = λ x p →  pmap f x (proj1  p) ; meq = meq f }

_↑_ :  (Nat → Two) → Nat →  PFunc (Lift n Nat) (Lift n Two)
_↑_  f i = record { dom = λ x → Lift n (lower x ≤ i) ; pmap = λ x _ → lift (f (lower x)) ; meq = λ {x} {p} {q} → refl }

record _f⊆_ (f g : PFunc (Lift n Nat) (Lift n Two)  ) : Set (suc n) where
field
extend : {x : Nat} → (fr : dom f (lift x) ) →  dom g (lift x  )
feq : {x : Nat} → {fr : dom f (lift x) } →  pmap f (lift x) fr ≡ pmap g (lift x) (extend fr)

record FiniteF (p :  PFunc (Lift n Nat) (Lift n Two) ) : Set (suc n) where
field
f-max :  Nat
f-func :  Nat → Two
f-p⊆f :  p f⊆ (f-func ↑ f-max)
f-f⊆p :  (f-func ↑ f-max) f⊆ p

open FiniteF

-- Dense-Gf : {n : Level} → F-Dense (PFunc {n}) (λ x → Lift (suc n) (One {n})) _f⊆_ _f∩_
-- Dense-Gf = record {
--        dense =  λ x → FiniteF x
--     ;  d⊆P = lift OneObj
--     ;  dense-f = λ x → record { dom = {!!} ; pmap = {!!} }
--     ;  dense-d = λ {p} d → {!!}
--     ;  dense-p = λ {p} d → {!!}
--   }

open _f⊆_
open import Data.Nat.Properties

ODSuc : (y : HOD) → infinite ∋ y → HOD
ODSuc y lt = Union (y , (y , y))

data Hω2 :  (i : Nat) ( x : Ordinal  ) → Set n where
hφ :  Hω2 0 o∅
h0 : {i : Nat} {x : Ordinal  } → Hω2 i x  →
Hω2 (Suc i) (od→ord (Union ((< nat→ω i , nat→ω 0 >) ,  ord→od x )))
h1 : {i : Nat} {x : Ordinal  } → Hω2 i x  →
Hω2 (Suc i) (od→ord (Union ((< nat→ω i , nat→ω 1 >) ,  ord→od x )))
he : {i : Nat} {x : Ordinal  } → Hω2 i x  →
Hω2 (Suc i) x

record  Hω2r (x : Ordinal) : Set n where
field
count : Nat
hω2 : Hω2 count x

open Hω2r

HODω2 :  HOD
HODω2 = record { od = record { def = λ x → Hω2r x } ; odmax = next o∅ ; <odmax = odmax0 } where
ω<next : {y : Ordinal} → infinite-d y → y o< next o∅
ω<next = ω<next-o∅ ho<
lemma : {i j : Nat} {x : Ordinal } → od→ord (Union (< nat→ω i , nat→ω j > , ord→od x)) o< next x
lemma = {!!}
odmax0 :  {y : Ordinal} → Hω2r y → y o< next o∅
odmax0 {y} r with hω2 r
... | hφ = x<nx
... | h0 {i} {x} t = next< (odmax0 record { count = i ; hω2 = t }) (lemma {i} {0} {x})
... | h1 {i} {x} t = next< (odmax0 record { count = i ; hω2 = t }) (lemma {i} {1} {x})
... | he {i} {x} t = next< (odmax0 record { count = i ; hω2 = t }) x<nx

3→Hω2 : List (Maybe Two) → HOD
3→Hω2 t = list→hod t 0 where
list→hod : List (Maybe Two) → Nat → HOD
list→hod [] _ = od∅
list→hod (just i0 ∷ t) i = Union (< nat→ω i , nat→ω 0 > , ( list→hod t (Suc i) ))
list→hod (just i1 ∷ t) i = Union (< nat→ω i , nat→ω 1 > , ( list→hod t (Suc i) ))
list→hod (nothing ∷ t) i = list→hod t (Suc i )

Hω2→3 : (x :  HOD) → HODω2 ∋ x → List (Maybe Two)
Hω2→3 x = lemma where
lemma : { y : Ordinal } →  Hω2r y → List (Maybe Two)
lemma record { count = 0 ; hω2 = hφ } = []
lemma record { count = (Suc i) ; hω2 = (h0 hω3) } = just i0 ∷ lemma record { count = i ; hω2 =  hω3 }
lemma record { count = (Suc i) ; hω2 = (h1 hω3) } = just i1 ∷ lemma record { count = i ; hω2 =  hω3 }
lemma record { count = (Suc i) ; hω2 = (he hω3) } = nothing ∷ lemma record { count = i ; hω2 =  hω3 }

ω→2 : HOD
ω→2 = Replace (Power infinite) (λ p  → Replace infinite (λ x → < x , repl p x > )) where
repl : HOD → HOD → HOD
repl p x with ODC.∋-p O p x
... | yes _  = nat→ω 1
... | no _  = nat→ω 0

ω→2f : (x : HOD) → ω→2 ∋ x → Nat → Two
ω→2f x = {!!}

↑n : (f n : HOD) → ((ω→2 ∋ f ) ∧ (infinite ∋ n)) → HOD
↑n f n lt = 3→Hω2 ( ω→2f f (proj1 lt) 3↑ (ω→nat n (proj2 lt) ))

-- the set of finite partial functions from ω to 2

Hω2f : Set (suc n)
Hω2f = (Nat → Set n) → Two

Hω2f→Hω2 : Hω2f  → HOD
Hω2f→Hω2 p = {!!} -- record { od = record { def = λ x → (p {!!} ≡ i0 ) ∨ (p {!!} ≡ i1 )}; odmax = {!!} ; <odmax = {!!} }

record CountableOrdinal : Set (suc (suc n)) where
field
ctl→ : Nat → Ordinal
ctl← : Ordinal → Nat
ctl-iso→ : { x : Ordinal } → ctl→ (ctl← x ) ≡ x
ctl-iso← : { x : Nat }  → ctl← (ctl→ x ) ≡ x

record CountableHOD : Set (suc (suc n)) where
field
mhod : HOD
mtl→ : Nat → Ordinal
mtl→∈P : (i : Nat) → odef mhod (mtl→ i)
mtl← : (x : Ordinal) → odef mhod x → Nat
mtl-iso→ : { x : Ordinal } → (lt : odef mhod x ) → mtl→ (mtl← x lt ) ≡ x
mtl-iso← : { x : Nat }  → mtl← (mtl→ x ) (mtl→∈P x) ≡ x

open CountableOrdinal
open CountableHOD

PGHOD :  (i : Nat) → (C : CountableOrdinal) → (p : Ordinal) → HOD
PGHOD i C p = record { od = record { def = λ x → odef (ord→od (ctl→ C i)) x  ∧  ( (y : Ordinal ) → odef (ord→od p) y →  odef (ord→od x) y ) }
; odmax = ctl→ C i  ; <odmax = λ {y} lt → odefo→o< (proj1 lt)}

next-p : (M : CountableHOD ) (i : Nat) → (C : CountableOrdinal) → (p : Ordinal) → Ordinal
next-p M i C p with ODC.decp O ( PGHOD i C p =h= od∅ )
next-p M i C p | yes y = p
next-p M i C p | no not = od→ord (ODC.minimal O (PGHOD i C p ) not)

data PD (M : CountableHOD ) (C : CountableOrdinal) : (x : Ordinal) (i : Nat) →  Set n where
pd0 : PD M C o∅ 0
pdsuc : {p : Ordinal } {i : Nat} → PD M C p i  → PD M C (next-p M i C p) (Suc i)

record PDN (M : CountableHOD ) (C : CountableOrdinal) (x : Ordinal) : Set n where
field
gr : Ordinal
pn<gr : (y : Ordinal) → odef (ord→od x) y → odef (ord→od gr) y
px∈ω  : odef (mhod M) x
grx∈ω : odef (mhod M) gr
pdod : PD M C x (mtl← M gr grx∈ω)

open PDN

PDHOD : (M : CountableHOD ) → (C : CountableOrdinal) → HOD
PDHOD M C = record { od = record { def = λ x →  PDN M C x }
; odmax = odmax (mhod M) ; <odmax = λ {y} lt → ordtrans (<odmax (mhod M) (px∈ω lt)) {!!}  } where

--
--  p 0 ≡ ∅
--  p (suc n) = if ∃ q ∈ ord→od ( ctl→ n ) ∧ p n ⊆ q → q
---             else p n

P-GenericFilter : {M : CountableHOD } → (C : CountableOrdinal) → GenericFilter (mhod M)
P-GenericFilter {M} C = record {
genf = record { filter = PDHOD M C ; f⊆PL = {!!} ; filter1 = {!!} ; filter2 = {!!} }
; generic = λ D → {!!}
}
```