---
title:          Properties of the locale of spectra
author:         Ayberk Tosun
date-started:   2024-03-01
dates-updated:  [2024-03-27, 2024-04-08, 2024-04-09, 2024-06-05]
---

We define the spectrum locale over a distributive lattice `L`, the defining
frame of which is the frame of ideals over `L`.

\begin{code}

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

open import UF.PropTrunc
open import UF.FunExt
open import UF.Subsingletons
open import UF.Size

module Locales.DistributiveLattice.Spectrum-Properties
        (fe : Fun-Ext)
        (pe : Prop-Ext)
        (pt : propositional-truncations-exist)
        (sr : Set-Replacement pt)
       where

open import Locales.Compactness.Definition pt fe
open import Locales.DistributiveLattice.Definition fe pt
open import Locales.DistributiveLattice.Ideal pt fe pe
open import Locales.DistributiveLattice.Ideal-Properties pt fe pe
open import Locales.DistributiveLattice.Properties fe pt
open import Locales.DistributiveLattice.Spectrum fe pe pt
open import Locales.Frame pt fe
open import Locales.SmallBasis pt fe sr
open import Locales.Spectrality.SpectralLocale pt fe
open import MLTT.List hiding ([_])
open import MLTT.Spartan
open import Slice.Family
open import UF.Classifiers
open import UF.Equiv renaming (_β–  to _𝐐𝐄𝐃)
open import UF.ImageAndSurjection pt
open import UF.Logic
open import UF.Powerset-MultiUniverse hiding (𝕋)
open import UF.SubtypeClassifier

open AllCombinators pt fe renaming (_∧_ to _βˆ§β‚š_; _∨_ to _βˆ¨β‚š_)
open Locale
open PropositionalSubsetInclusionNotation fe
open PropositionalTruncation pt hiding (_∨_)

\end{code}

We work with a fixed distributive 𝓀-lattice `L` in this module.

\begin{code}

module Spectrality (L : DistributiveLattice 𝓀) where

 open DefnOfFrameOfIdeal  L
 open DistributiveLattice L renaming (X-is-set to Οƒ)
 open IdealNotation L
 open IdealProperties L

\end{code}

We abbreviate the `spectrum` of `L` to `spec-L`.

\begin{code}

 private
  spec-L : Locale (𝓀 ⁺) 𝓀 𝓀
  spec-L = spectrum

\end{code}

The locale `spec-L` is a compact locale.

\begin{code}

 spectrum-is-compact : is-compact spec-L holds
 spectrum-is-compact S Ξ΄ p =
  βˆ₯βˆ₯-rec βˆƒ-is-prop † (p 𝟏 (𝟏ᡈ-is-top L 𝟏))
   where
    † : Ξ£ xs κž‰ List X , xs ◁ S Γ— (𝟏 = join-listᡈ L xs)
      β†’ βˆƒ i κž‰ index S , (𝟏[ π’ͺ spec-L ] βŠ†α΅’ (S [ i ])) holds
    † (xs , c , r) = βˆ₯βˆ₯-rec βˆƒ-is-prop ‑ (finite-subcover S xs Ξ΄ c)
     where
      ‑ : Ξ£ k κž‰ index S , join-listᡈ L xs ∈ⁱ (S [ k ])
        β†’ βˆƒ i κž‰ index S , (𝟏[ π’ͺ spec-L ] βŠ†α΅’ (S [ i ])) holds
      ‑ (k , p) = ∣ k , contains-𝟏-implies-above-𝟏 (S [ k ]) ΞΌ ∣
       where
        μ : 𝟏 ∈ⁱ (S [ k ])
        ΞΌ = transport (Ξ» - β†’ - ∈ⁱ (S [ k ])) (r ⁻¹) p

\end{code}

Added on 2024-03-13.

Every ideal `I` is the join of its principal ideals. We call this join the
_factorization_ of `I` into its join of principal ideals, and we denote by
`factorization` the function implementing this.

\begin{code}

 open PrincipalIdeals L
 open Joins _βŠ†α΅’_

 factorization : Ideal L β†’ Ideal L
 factorization I = ⋁[ π’ͺ spec-L ] principal-ideals-of I

 ideal-equal-to-factorization : (I : Ideal L) β†’ I = factorization I
 ideal-equal-to-factorization I =
  ⋁[ π’ͺ spec-L ]-unique (principal-ideals-of I) I († , ‑)
   where
    † : (I is-an-upper-bound-of (principal-ideals-of I)) holds
    † = ideal-is-an-upper-bound-of-its-principal-ideals I

    ‑ : ((Iα΅€ , _) : upper-bound (principal-ideals-of I)) β†’ I βŠ†α΅’ Iα΅€ holds
    ‑ (Iα΅€ , Ο…) =
     ideal-is-lowerbound-of-upperbounds-of-its-principal-ideals I Iα΅€ Ο…

\end{code}

The family of principal ideals in an ideal is a directed family.

\begin{code}

 factorization-is-directed : (I : Ideal L)
                           β†’ is-directed (π’ͺ spec-L) (principal-ideals-of I) holds
 factorization-is-directed = principal-ideals-of-ideal-form-a-directed-family

\end{code}

Added on 2024-03-27

For every `x : L`, the principal ideal `↓x` is a compact open of the locale of
spectra.

\begin{code}

 principal-ideal-is-compact : (x : ∣ L ∣ᡈ) β†’ is-compact-open spec-L (↓ x) holds
 principal-ideal-is-compact x S Ξ΄ p = βˆ₯βˆ₯-rec βˆƒ-is-prop † ΞΌ
  where
   ΞΌ : x ∈ᡒ (⋁[ π’ͺ spec-L ] S) holds
   ΞΌ = p x (β‰€α΅ˆ-is-reflexive L x)

   † : Ξ£ xs κž‰ List X , xs ◁ S Γ— (x = join-listᡈ L xs)
     β†’ βˆƒ i  κž‰ index S , ↓ x βŠ†α΅’ (S [ i ]) holds
   † (xs , q , rβ€²) = βˆ₯βˆ₯-rec βˆƒ-is-prop ‑ Ξ²
    where
     Ξ² : βˆƒ i κž‰ index S , join-listᡈ L xs ∈ᡒ (S [ i ]) holds
     Ξ² = finite-subcover S xs Ξ΄ q

     ‑ : Ξ£ i κž‰ index S , join-listᡈ L xs ∈ᡒ (S [ i ]) holds
       β†’ βˆƒ i  κž‰ index S , ↓ x βŠ†α΅’ (S [ i ]) holds
     ‑ (i , r) = ∣ i , Ξ³ ∣
      where
       open Ideal (S [ i ]) renaming (I-is-downward-closed
                                      to Sα΅’-is-downward-closed)

       Ξ³ : (↓ x βŠ†α΅’ (S [ i ])) holds
       Ξ³ y Ο† = Sα΅’-is-downward-closed y (join-listᡈ L xs) Ο΅ r
        where
         Ο΅ : (y β‰€α΅ˆ[ L ] join-listᡈ L xs) holds
         Ο΅ = transport (Ξ» - β†’ (y β‰€α΅ˆ[ L ] -) holds) rβ€² Ο†

\end{code}

Added on 2024-06-05.

\begin{code}

 ↓ₖ_ : ∣ L ∣ᡈ β†’ Ξ£ I κž‰ Ideal L , (is-compact-open spec-L I holds)
 ↓ₖ_ x = ↓ x , principal-ideal-is-compact x

\end{code}

End of addition.

Added on 2024-03-13.

Every ideal has a directed covering family consisting of compact opens.

\begin{code}

 ideal-has-directed-cover-of-compact-opens
  : (I : Ideal L)
  β†’ has-a-directed-cover-of-compact-opens spec-L I holds
 ideal-has-directed-cover-of-compact-opens I =
  ∣ principal-ideals-of I , κ , δ , eq ∣
   where
    ΞΊ : consists-of-compact-opens spec-L (principal-ideals-of I) holds
    ΞΊ (x , _) =  principal-ideal-is-compact x

    Ξ΄ : is-directed (π’ͺ spec-L) (principal-ideals-of I) holds
    Ξ΄ = principal-ideals-of-ideal-form-a-directed-family I

    eq : I = ⋁[ π’ͺ spec-L ] principal-ideals-of I
    eq = ideal-equal-to-factorization I

\end{code}

Added on 2024-04-08.

We have already proved that every principal ideal is compact. We now prove
the converse of this: every compact ideal is the principal ideal on some
element `x` of the distributive lattice `L`.

\begin{code}

 compact-ideal-is-principal : (I : Ideal L)
                            β†’ is-compact-open spec-L I holds
                            β†’ βˆƒ x κž‰ ∣ L ∣ᡈ , I = principal-ideal x
 compact-ideal-is-principal I ΞΊ =
  βˆ₯βˆ₯-rec βˆƒ-is-prop Ξ³ (ΞΊ (principal-ideals-of I) Ξ΄ cβ‚€)
   where
    c : I = factorization I
    c = ideal-equal-to-factorization I

    cβ‚€ : (I βŠ†α΅’ factorization I) holds
    cβ‚€ = reflexivity+ (poset-of (π’ͺ spec-L)) c

    c₁ : (factorization I βŠ†α΅’ I) holds
    c₁ = reflexivity+ (poset-of (π’ͺ spec-L)) (c ⁻¹)

    Ξ΄ : is-directed (π’ͺ spec-L) (principal-ideals-of I) holds
    Ξ΄ = factorization-is-directed I

    Ξ³ : (Ξ£ (x , _) κž‰ index (principal-ideals-of I) , (I βŠ†α΅’ ↓ x) holds)
      β†’ βˆƒ x κž‰ ∣ L ∣ᡈ , I = ↓ x
    Ξ³ ((x , p) , Ο†) = ∣ x , ≀-is-antisymmetric (poset-of (π’ͺ spec-L)) q₁ qβ‚‚ ∣
     where
      open Ideal I using (I-is-downward-closed)

      q₁ : I βŠ†α΅’ ↓ x holds
      q₁ = Ο†

      qβ‚‚ : ↓ x βŠ†α΅’ I holds
      qβ‚‚ y ΞΌ = I-is-downward-closed y x ΞΌ p

\end{code}

Added on 2024-04-08.

The map `↓(-) : L β†’ Idl(L)` preserves meets.

\begin{code}

 principal-ideal-preserves-meets : (x y : ∣ L ∣ᡈ)
                                 β†’ ↓ (x ∧ y) = ↓ x ∧[ π’ͺ spec-L ] ↓ y
 principal-ideal-preserves-meets x y =
  ≀-is-antisymmetric (poset-of (π’ͺ spec-L)) † ‑
   where
    open PosetReasoning (poset-ofᡈ L)

    † : (↓ (x ∧ y) βŠ†α΅’ (↓ x ∧[ π’ͺ spec-L ] ↓ y)) holds
    † z p = †₁ , †₂
     where
      †₁ : (z β‰€α΅ˆ[ L ] x) holds
      †₁ = z β‰€βŸ¨ p ⟩ x ∧ y β‰€βŸ¨ ∧-is-a-lower-bound₁ L x y ⟩ x β– 

      †₂ : (z β‰€α΅ˆ[ L ] y) holds
      †₂ = z β‰€βŸ¨ p ⟩ x ∧ y β‰€βŸ¨ ∧-is-a-lower-boundβ‚‚ L x y ⟩ y β– 

    ‑ : ((↓ x ∧[ π’ͺ spec-L ] ↓ y) βŠ†α΅’ ↓ (x ∧ y)) holds
    ‑ = ∧-is-greatest L x y

\end{code}

Added on 2024-06-05.

This has probably been written down somewhere else before.

\begin{code}

 principal-ideal-preserves-top : ↓ 𝟏 = 𝟏[ π’ͺ spec-L ]
 principal-ideal-preserves-top = only-𝟏-is-above-𝟏 (π’ͺ spec-L) (↓ 𝟏) (Ξ» _ β†’ id)

 principal-ideal-preserves-bottom : ↓ 𝟎 = 𝟎[ π’ͺ spec-L ]
 principal-ideal-preserves-bottom = only-𝟎-is-below-𝟎 (π’ͺ spec-L) (↓ 𝟎) †
  where
   † : (↓ 𝟎 ≀[ poset-of (π’ͺ spec-L) ] 𝟎[ π’ͺ spectrum ]) holds
   † x ΞΌ = transport (Ξ» - β†’ - ∈ⁱ 𝟎[ π’ͺ spectrum ]) (p ⁻¹) ideal-𝟎-contains-𝟎
    where
     open Ideal 𝟎[ π’ͺ spectrum ] renaming (I-contains-𝟎 to ideal-𝟎-contains-𝟎)

     p : x = 𝟎
     p = only-𝟎-is-below-𝟎ᡈ L x μ

\end{code}

End of addition

Added on 2024-04-08.

The binary meet of two compact ideals is compact.

\begin{code}

 compacts-of-the-spectrum-are-closed-under-∧
  : compacts-of-[ spec-L ]-are-closed-under-binary-meets holds
 compacts-of-the-spectrum-are-closed-under-∧ K₁ Kβ‚‚ κ₁ ΞΊβ‚‚ = ΞΊ
  where
   ι₁ : βˆƒ x₁ κž‰ ∣ L ∣ᡈ , K₁ = ↓ x₁
   ι₁ = compact-ideal-is-principal K₁ κ₁

   ΞΉβ‚‚ : βˆƒ xβ‚‚ κž‰ ∣ L ∣ᡈ , Kβ‚‚ = ↓ xβ‚‚
   ΞΉβ‚‚ = compact-ideal-is-principal Kβ‚‚ ΞΊβ‚‚

   ΞΊ : is-compact-open spec-L (K₁ ∧[ π’ͺ spec-L ] Kβ‚‚) holds
   ΞΊ =
    βˆ₯βˆ₯-recβ‚‚ (holds-is-prop (is-compact-open spec-L (K₁ ∧[ π’ͺ spec-L ] Kβ‚‚))) † ι₁ ΞΉβ‚‚
     where
      † : Ξ£ x₁ κž‰ ∣ L ∣ᡈ , K₁ = ↓ x₁
        β†’ Ξ£ xβ‚‚ κž‰ ∣ L ∣ᡈ , Kβ‚‚ = ↓ xβ‚‚
        β†’ is-compact-open spec-L (K₁ ∧[ π’ͺ spec-L ] Kβ‚‚) holds
      † (x₁ , p₁) (xβ‚‚ , pβ‚‚) =
       transport (Ξ» - β†’ is-compact-open spec-L - holds) (q ⁻¹) ‑
        where
         q : K₁ ∧[ π’ͺ spec-L ] Kβ‚‚ = ↓ (x₁ ∧ xβ‚‚)
         q = K₁ ∧[ π’ͺ spec-L ] Kβ‚‚       =⟨ β…  ⟩
             ↓ x₁ ∧[ π’ͺ spec-L ] Kβ‚‚     =⟨ β…‘ ⟩
             ↓ x₁ ∧[ π’ͺ spec-L ] ↓ xβ‚‚   =⟨ β…’ ⟩
             ↓ (x₁ ∧ xβ‚‚)               ∎
              where
               β…  = ap (Ξ» - β†’ - ∧[ π’ͺ spec-L ] Kβ‚‚) p₁
               β…‘ = ap (Ξ» - β†’ ↓ x₁ ∧[ π’ͺ spec-L ] -) pβ‚‚
               β…’ = principal-ideal-preserves-meets x₁ xβ‚‚ ⁻¹

         ‑ : is-compact-open spec-L (↓ (x₁ ∧ xβ‚‚)) holds
         ‑ = principal-ideal-is-compact (x₁ ∧ xβ‚‚)

\end{code}

Added on 2024-04-08.

Finally, we package everything up into a proof that the spectrum locale is
spectral.

\begin{code}

 spec-L-is-spectral : is-spectral spec-L holds
 spec-L-is-spectral = (ΞΊ , Ξ½) , ideal-has-directed-cover-of-compact-opens
  where
   ΞΊ : is-compact spec-L holds
   ΞΊ = spectrum-is-compact

   Ξ½ : compacts-of-[ spec-L ]-are-closed-under-binary-meets holds
   ν = compacts-of-the-spectrum-are-closed-under-∧

\end{code}

Everything after this line has been added on 2024-04-09.

To show that the type of compact ideals is small, we directly construct the
intensional specified basis for `Idl(L)` given by the family `↓(-) : L β†’ Idl(L)`.

\begin{code}

 ℬ-spec : Fam 𝓀 ⟨ π’ͺ spec-L ⟩
 ℬ-spec = ∣ L ∣ᡈ , principal-ideal

 open classifier-single-universe

 ℬ-spec-is-directed-basis : directed-basis-forα΄° (π’ͺ spec-L) ℬ-spec
 ℬ-spec-is-directed-basis ℐ = 𝕋 𝓀 ∣ L ∣ᡈ (_∈ⁱ ℐ) , † , 𝒹
  where
   c : ℐ = ⋁[ π’ͺ spec-L ] ⁅ ↓ x ∣ x Ξ΅ 𝕋 𝓀 ∣ L ∣ᡈ (_∈ⁱ ℐ) ⁆
   c = ideal-equal-to-factorization ℐ

   † : (ℐ is-lub-of ⁅ ↓ x ∣ x Ξ΅ 𝕋 𝓀 ∣ L ∣ᡈ (_∈ⁱ ℐ) ⁆) holds
   † = transport
        (Ξ» - β†’ (- is-lub-of ⁅ ↓ x ∣ x Ξ΅ 𝕋 𝓀 ∣ L ∣ᡈ (_∈ⁱ ℐ) ⁆) holds)
        (c ⁻¹)
        (⋁[ π’ͺ spec-L ]-upper _ , ⋁[ π’ͺ spec-L ]-least _)

   𝒹 : is-directed (π’ͺ spec-L) ⁅ ↓ x ∣ x Ξ΅ (𝕋 𝓀 ∣ L ∣ᡈ (_∈ⁱ ℐ)) ⁆ holds
   𝒹 = factorization-is-directed ℐ

 ℬ-spec-is-basis : basis-forα΄° (π’ͺ spec-L) ℬ-spec
 ℬ-spec-is-basis =
  directed-basis-is-basis (π’ͺ spec-L) ℬ-spec ℬ-spec-is-directed-basis

\end{code}

We denote by `𝒦-fam` the family corresponding to the subset of compact opens.

\begin{code}

 𝒦-fam : Fam (𝓀 ⁺) ⟨ π’ͺ spec-L ⟩
 𝒦-fam = 𝕋 (𝓀 ⁺) ⟨ π’ͺ spec-L ⟩ (_holds ∘ is-compact-open spec-L)

\end{code}

We know that the image of `↓(-) : L β†’ Idl(L)` is equivalent to type of compact
opens of `spec-L`.

\begin{code}

 image-↓-equiv-to-𝒦 : image principal-ideal ≃ 𝒦 spec-L
 image-↓-equiv-to-𝒦 = basic-iso-to-𝒦
                       spec-L
                       (ℬ-spec , ℬ-spec-is-directed-basis)
                       principal-ideal-is-compact

\end{code}

We also know that the image of `↓(-)` is a 𝓀-small type.

\begin{code}

 image-of-↓-is-small : (image principal-ideal) is 𝓀 small
 image-of-↓-is-small =
  basic-is-small spec-L (ℬ-spec , ℬ-spec-is-directed-basis) Ξ³
   where
    open PosetNotation (poset-of (π’ͺ spec-L))

    Ξ³ : ⟨ π’ͺ spec-L ⟩ is-locally 𝓀 small
    Ξ³ I J = (I ≣ J) holds , s , (r , †) , (r , ‑)
     where
      s : (I ≣ J) holds β†’ I = J
      s (p₁ , pβ‚‚) = ≀-is-antisymmetric (poset-of (π’ͺ spec-L)) p₁ pβ‚‚

      r : I = J β†’ (I ≣ J) holds
      r p = transport (Ξ» - β†’ (- ≣ J) holds) (p ⁻¹) (≣-is-reflexive poset-of-ideals J)

      † : s ∘ r ∼ id
      † p = carrier-of-[ poset-of-ideals ]-is-set (s (r p)) p

      ‑ : r ∘ s ∼ id
      ‑ p = holds-is-prop (I ≣ J) (r (s p)) p

\end{code}

We use the superscript `(-)⁻` to denote the small copy of the type `image ↓(-)`.

\begin{code}

 image-↓⁻ : 𝓀  Μ‡
 image-↓⁻ = resized (image principal-ideal) image-of-↓-is-small

\end{code}

From the previous two equivalences, we can conclude that the type of compact
opens of `spec-L` is equivalent to `image-↓⁻`.

\begin{code}

 image-↓⁻-equiv-to-𝒦 : image-↓⁻ ≃ 𝒦 spec-L
 image-↓⁻-equiv-to-𝒦 = image-↓⁻               β‰ƒβŸ¨ β…  ⟩
                       image principal-ideal  β‰ƒβŸ¨ β…‘ ⟩
                       𝒦 spec-L               𝐐𝐄𝐃
                        where
                         β…  = resizing-condition image-of-↓-is-small
                         β…‘ = image-↓-equiv-to-𝒦

\end{code}

This means that `𝒦(spec-L)` is 𝓀-small.

\begin{code}

 spec-L-has-small-𝒦 : has-small-𝒦 spec-L
 spec-L-has-small-𝒦 = image-↓⁻ , image-↓⁻-equiv-to-𝒦

\end{code}