---
title:      Properties of the Scott topology
author:     Ayberk Tosun
start-date: 2023-10-30
---

\begin{code}

{-# OPTIONS --safe --without-K --exact-split #-}

open import MLTT.Spartan
open import UF.FunExt
open import UF.PropTrunc
open import UF.SubtypeClassifier

module DomainTheory.Topology.ScottTopologyProperties
        (pt : propositional-truncations-exist)
        (fe : Fun-Ext)
        (π“₯  : Universe) where

open import UF.Logic
open Existential pt
open Implication fe
open Universal   fe
open Conjunction

open import UF.Size
open import UF.Equiv

open import UF.Powerset-MultiUniverse
open import Slice.Family

open PropositionalTruncation pt

open import DomainTheory.Topology.ScottTopology        pt fe π“₯
open import DomainTheory.Basics.Dcpo                   pt fe π“₯
open import DomainTheory.BasesAndContinuity.Continuity pt fe π“₯
open import DomainTheory.Basics.WayBelow               pt fe π“₯

\end{code}

\begin{code}

principal-filter : (𝓓 : DCPO {𝓀} {π“₯}) β†’ ⟨ 𝓓 ⟩ β†’ π“Ÿ ⟨ 𝓓 ⟩
principal-filter 𝓓 c x = c βŠ‘βŸ¨ 𝓓 ⟩ x , prop-valuedness 𝓓 c x

infix 45 principal-filter

syntax principal-filter 𝓓 x = ↑[ 𝓓 ] x

\end{code}

Let `D` be a dcpo and consider a compact element `c : D` of it. The
upwards-closure of `c` is then a Scott open.

\begin{code}

module Properties (𝓓 : DCPO {𝓀} {π“₯}) where

 open DefnOfScottTopology 𝓓 π“₯

 principal-filter-is-upwards-closed : (x : ⟨ 𝓓 ⟩)
                                    β†’ is-upwards-closed (↑[ 𝓓 ] x) holds
 principal-filter-is-upwards-closed x y z p q =
  x βŠ‘βŸ¨ 𝓓 ⟩[ p ] y βŠ‘βŸ¨ 𝓓 ⟩[ q ] z ∎⟨ 𝓓 ⟩

 compact-implies-principal-filter-is-scott-open : (c : ⟨ 𝓓 ⟩)
                                                β†’ is-compact 𝓓 c
                                                β†’ is-scott-open (↑[ 𝓓 ] c) holds
 compact-implies-principal-filter-is-scott-open c ΞΊ = β…  , β…‘
  where
   β…  : is-upwards-closed (↑[ 𝓓 ] c) holds
   β…  = principal-filter-is-upwards-closed c

   β…‘ : is-inaccessible-by-directed-joins (↑[ 𝓓 ] c) holds
   β…‘ (S , Ξ΄) = ΞΊ (index S) (S [_]) Ξ΄

\end{code}

Conversely, if the principal filter is Scott open then `c` is a compact element.

\begin{code}

 principal-filter-scott-open-implies-compact : (c : ⟨ 𝓓 ⟩)
                                             β†’ is-scott-open (↑[ 𝓓 ] c) holds
                                             β†’ is-compact 𝓓 c
 principal-filter-scott-open-implies-compact c (Ο… , ΞΊ) I ΞΉ Ξ΄ p =
  ΞΊ ((I , ΞΉ) , Ξ΄) p

\end{code}

We can now record this as a logical equivalence.

\begin{code}

 principal-filter-scott-open-iff-compact :
  (x : ⟨ 𝓓 ⟩) β†’ is-scott-open (↑[ 𝓓 ] x) holds ↔ is-compact 𝓓 x
 principal-filter-scott-open-iff-compact x = β…  , β…‘
  where
   β…  = principal-filter-scott-open-implies-compact x
   β…‘ = compact-implies-principal-filter-is-scott-open x

\end{code}

Notation for the principal Scott open.

\begin{code}

 ↑˒[_] : (Ξ£ c κž‰ ⟨ 𝓓 ⟩ , is-compact 𝓓 c) β†’ Ξ£ S κž‰ π“Ÿ {π“₯} ⟨ 𝓓 ⟩ , is-scott-open S holds
 ↑˒[ (c , ΞΊ) ] =
  principal-filter 𝓓 c , compact-implies-principal-filter-is-scott-open c ΞΊ

\end{code}

We now prove some properties of the Scott topology on a dcpo that is algebraic.

\begin{code}

module PropertiesAlgebraic (𝓓 : DCPO {𝓀} {π“₯})
                           (𝕒 : structurally-algebraic 𝓓) where

 open DefnOfScottTopology 𝓓 π“₯

 open structurally-algebraic

 is-compactβ‚š : ⟨ 𝓓 ⟩ β†’ Ξ© (𝓀 βŠ” π“₯ ⁺)
 is-compactβ‚š x = is-compact 𝓓 x , being-compact-is-prop 𝓓 x

 join-of-compact-opens : π“Ÿ {π“₯} ⟨ 𝓓 ⟩ β†’ π“Ÿ {𝓀 βŠ” π“₯ ⁺} ⟨ 𝓓 ⟩
 join-of-compact-opens U x =
  Ǝ c κž‰ ⟨ 𝓓 ⟩ , (is-compactβ‚š c ∧ c βˆˆβ‚š U ∧ x βˆˆβ‚š (↑[ 𝓓 ] c)) holds

 characterization-of-scott-opens₁ : (U : π“Ÿ ⟨ 𝓓 ⟩)
                                  β†’ is-scott-open U holds
                                  β†’ U βŠ† join-of-compact-opens U
 characterization-of-scott-opens₁ U (Ο… , ΞΎ) x p = †
  where
   S : Fam π“₯ ⟨ 𝓓 ⟩
   S = index-of-compact-family 𝕒 x , compact-family 𝕒 x

   S↑ : Fam↑
   S↑ = S , compact-family-is-directed 𝕒 x

   q : x = ⋁ S↑
   q = compact-family-∐-= 𝕒 x ⁻¹

   ΞΊ : (i : index S) β†’ is-compactβ‚š (S [ i ]) holds
   ΞΊ = compact-family-is-compact 𝕒 x

   ψ : is-upperbound (underlying-order 𝓓) x (S [_])
   ψ i = transport (Ξ» - β†’ (S [ i ]) βŠ‘βŸ¨ 𝓓 ⟩ -) (q ⁻¹) (⋁-is-upperbound S↑ i)

   Ο† : (⋁ S↑) ∈ U
   Ο† = transport (Ξ» - β†’ - ∈ U) q p

   ‑ : Ξ£ i κž‰ index S , (S [ i ]) ∈ U
     β†’ βˆƒ cβ‚€ κž‰ ⟨ 𝓓 ⟩ , (is-compactβ‚š cβ‚€ ∧ cβ‚€ βˆˆβ‚š U ∧ x βˆˆβ‚š ↑[ 𝓓 ] cβ‚€) holds
   ‑ (i , ΞΌ) = ∣ S [ i ] , ΞΊ i , ΞΌ , ψ i ∣

   † : βˆƒ cβ‚€ κž‰ ⟨ 𝓓 ⟩ , (is-compactβ‚š cβ‚€ ∧ cβ‚€ βˆˆβ‚š U ∧ x βˆˆβ‚š ↑[ 𝓓 ] cβ‚€) holds
   † = βˆ₯βˆ₯-rec βˆƒ-is-prop ‑ (ΞΎ S↑ Ο†)

 characterization-of-scott-opensβ‚‚ : (U : π“Ÿ ⟨ 𝓓 ⟩)
                                  β†’ is-scott-open U holds
                                  β†’ join-of-compact-opens U βŠ† U
 characterization-of-scott-opensβ‚‚ U (Ο… , _) x p =
  βˆ₯βˆ₯-rec (holds-is-prop (x βˆˆβ‚š U)) † p
   where
    † : Ξ£ c κž‰ ⟨ 𝓓 ⟩ , (is-compactβ‚š c ∧ c βˆˆβ‚š U ∧ principal-filter 𝓓 c x) holds
      β†’ x βˆˆβ‚š U holds
    † (c , _ , q , r) = Ο… c x q r

 characterization-of-scott-opens
  : (U : π“Ÿ {π“₯} ⟨ 𝓓 ⟩)
  β†’ (is-scott-open U β‡’ (β±― x κž‰ ⟨ 𝓓 ⟩ , U x ⇔ join-of-compact-opens U x)) holds
 characterization-of-scott-opens U Ο‚ x = ⦅⇒⦆ , ⦅⇐⦆
  where
   ⦅⇒⦆ = characterization-of-scott-opens₁ U Ο‚ x
   ⦅⇐⦆ = characterization-of-scott-opensβ‚‚ U Ο‚ x

 resize-join-of-compact-opens : (U : π“Ÿ {π“₯} ⟨ 𝓓 ⟩) (x : ⟨ 𝓓 ⟩)
                              β†’ is-scott-open U holds
                              β†’ (join-of-compact-opens U x holds) is π“₯ small
 resize-join-of-compact-opens U x Ο‚ = x ∈ U , Ξ΅
  where
   Ξ΅ : (x ∈ U) ≃ join-of-compact-opens U x holds
   Ξ΅ = logically-equivalent-props-are-equivalent
        (holds-is-prop (U x))
        βˆƒ-is-prop
        (characterization-of-scott-opens₁ U Ο‚ x)
        (characterization-of-scott-opensβ‚‚ U Ο‚ x)

\end{code}

Addition 2023-11-22.

The principal filter on the bottom element is the top open of the Scott locale.
We write this down in a different submodule as it requires the additional
assumption of a bottom element in the algebraic dcpo in consideration.

\begin{code}

module BottomLemma (𝓓  : DCPO {𝓀} {π“₯})
                   (𝕒  : structurally-algebraic 𝓓)
                   (hl : has-least (underlying-order 𝓓)) where

 βŠ₯α΄° : ⟨ 𝓓 ⟩
 βŠ₯α΄° = pr₁ hl

 βŠ₯α΄°-is-least : is-least (underlying-order 𝓓) βŠ₯α΄°
 βŠ₯α΄°-is-least = prβ‚‚ hl

 open Properties 𝓓

 open DefnOfScottTopology 𝓓 π“₯
 open PropertiesAlgebraic 𝓓 𝕒

 bottom-principal-filter-is-top : (π”˜ : π’ͺβ‚›) β†’ π”˜ .pr₁ βŠ† ↑[ 𝓓 ] βŠ₯α΄°
 bottom-principal-filter-is-top π”˜ x _ = βŠ₯α΄°-is-least x

\end{code}

Added on 2024-03-09.

If a Scott open contains `βŠ₯` then it contains everything by upward closure.

\begin{code}

 contains-bottom-implies-is-top : (π”˜ : π’ͺβ‚›) β†’ (βŠ₯α΄° βˆˆβ‚› π”˜) holds
                                β†’ (x : ⟨ 𝓓 ⟩) β†’ (x βˆˆβ‚› π”˜) holds
 contains-bottom-implies-is-top π”˜ ΞΌ x = upward-closure π”˜ βŠ₯α΄° x ΞΌ (βŠ₯α΄°-is-least x)

\end{code}