Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some miscellaneous separated/stable type facts #1030

Merged
merged 5 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cubical/Data/Bool/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -406,3 +406,6 @@ Iso-⊤⊎⊤-Bool .leftInv (inl tt) = refl
Iso-⊤⊎⊤-Bool .leftInv (inr tt) = refl
Iso-⊤⊎⊤-Bool .rightInv true = refl
Iso-⊤⊎⊤-Bool .rightInv false = refl

separatedBool : Separated Bool
separatedBool = Discrete→Separated _≟_
24 changes: 24 additions & 0 deletions Cubical/Relation/Nullary/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ open import Cubical.Foundations.Equiv
open import Cubical.Functions.Fixpoint

open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Sigma.Base using (_×_)

open import Cubical.Relation.Nullary.Base
open import Cubical.HITs.PropositionalTruncation.Base
Expand All @@ -24,6 +25,7 @@ private
variable
ℓ : Level
A B : Type ℓ
P : A -> Type ℓ

-- Functions with a section preserve discreteness.
sectionDiscrete
Expand All @@ -48,6 +50,17 @@ Stable¬ ¬¬¬a a = ¬¬¬a ¬¬a
where
¬¬a = λ ¬a → ¬a a

StableΠ : (∀ x → Stable (P x)) -> Stable (∀ x → P x)
StableΠ Ps e x = Ps x λ k → e λ f → k (f x)

Stable→ : Stable B → Stable (A → B)
Stable→ Bs = StableΠ (λ _ → Bs)

Stable× : Stable A -> Stable B -> Stable (A × B)
Stable× As Bs e = λ where
.fst → As λ k → e (k ∘ fst)
.snd → Bs λ k → e (k ∘ snd)

fromYes : A → Dec A → A
fromYes _ (yes a) = a
fromYes a (no _) = a
Expand Down Expand Up @@ -171,6 +184,17 @@ Separated→PStable≡ st x y = Stable→PStable (st x y)
Separated→isSet : Separated A → isSet A
Separated→isSet = PStable≡→isSet ∘ Separated→PStable≡

SeparatedΠ : (∀ x → Separated (P x)) -> Separated ((x : A) -> P x)
SeparatedΠ Ps f g e i x = Ps x (f x) (g x) (λ k → e (k ∘ cong (λ f → f x))) i

Separated→ : Separated B -> Separated (A → B)
Separated→ Bs = SeparatedΠ (λ _ → Bs)

Separated× : Separated A -> Separated B -> Separated (A × B)
Separated× As Bs p q e i = λ where
.fst → As (fst p) (fst q) (λ k → e λ r → k (cong fst r)) i
.snd → Bs (snd p) (snd q) (λ k → e λ r → k (cong snd r)) i

-- Proof of Hedberg's theorem: a type with decidable equality is an h-set
Discrete→Separated : Discrete A → Separated A
Discrete→Separated d x y = Dec→Stable (d x y)
Expand Down