module Data.Power.Complemented where
Complemented subobjects🔗
A subobject of a type is called complemented if there is a subobject such that 1, and Because of lattice structure, these containments suffice to establish equality.
private variable
: Level
ℓ : Type ℓ
A : ℙ A p q r
: ∀ {ℓ} {A : Type ℓ} (p : ℙ A) → Type _
is-complemented {A = A} p = Σ[ p⁻¹ ∈ ℙ A ]
is-complemented ((p ∩ p⁻¹ ⊆ minimal) × (maximal ⊆ p ∪ p⁻¹))
More conventionally, in constructive mathematics, we may say a subobject is decidable if its associated predicate is pointwise a decidable type. It turns out that these conditions are equivalent: a subobject is decidable if, and only if, it is complemented. It’s immediate that decidable subobjects are complemented: given a decision procedure the fibres and are disjoint and their union is all of
: ∀ {ℓ} {A : Type ℓ} (p : ℙ A) → Type _
is-decidable {A = A} p = (a : A) → Dec (a ∈ p)
is-decidable
: (p : ℙ A) → is-decidable p → is-complemented p
is-decidable→is-complemented {A = A} p dec = inv , intersection , union where
is-decidable→is-complemented : ℙ A
inv = el (¬ (x ∈ p)) (hlevel 1)
inv x
: (p ∩ inv) ⊆ minimal
intersection (x∈p , x∉p) = x∉p x∈p
intersection x
: maximal ⊆ (p ∪ inv)
union with dec x
union x wit ... | yes x∈p = inc (inl x∈p)
... | no x∉p = inc (inr x∉p)
For the converse, since decidability of a proposition is itself a proposition, it suffices to assume we have an inhabitant of Assuming that we must show that But by the definition of complemented subobject, the intersection is empty.
: (p : ℙ A) → is-complemented p → is-decidable p
is-complemented→is-decidable (p⁻¹ , intersection , union) elt =
is-complemented→is-decidable p λ where
case union elt tt of (inl x∈p) → yes x∈p
(inr x∈¬p) → no λ x∈p → intersection elt (x∈p , x∈¬p)
Decidable subobject classifiers🔗
In the same way that we have a (large) type of all propositions of size the decidable (complemented) subobjects also have a classifying object: Any two-element type with decidable equality! This can be seen as a local instance of excluded middle: the complemented subobjects are precisely those satisfying and so they are classified by the “classical subobject classifier”
decidable-subobject-classifier: {A : Type ℓ} → (A → Bool) ≃ (Σ[ p ∈ ℙ A ] (is-decidable p))
{A = A} = eqv where decidable-subobject-classifier
In much the same way that the subobject represented by a map is the fibre over the subobject represented by a map is the fibre over This is a decidable subobject because has decidable equality.
to : (A → Bool) → (Σ[ p ∈ ℙ A ] (is-decidable p))
to map .fst x = el (map x ≡ true) (hlevel 1)
to map .snd p = Bool-elim (λ p → Dec (p ≡ true))
(yes refl) (no (λ p → true≠false (sym p))) (map p)
Conversely, to each decidable subobject and element we associate a boolean such that if and only if Projecting the boolean and forgetting the equivalence gives us a map associated with as desired; The characterisation of serves to smoothen the proof that this process is inverse to taking fibres over
: (pr : Σ[ p ∈ ℙ A ] (is-decidable p)) (x : A)
from → (Σ[ b ∈ Bool ] ((b ≡ true) ≃ (x ∈ pr .fst)))
(p , dec) elt = Dec-elim (λ _ → Σ Bool (λ b → (b ≡ true) ≃ (elt ∈ p)))
from (λ y → true , prop-ext! (λ _ → y) (λ _ → refl))
(λ x∉p → false , prop-ext!
(λ p → absurd (true≠false (sym p)))
(λ x → absurd (x∉p x)))
(dec elt)
= Iso→Equiv λ where
eqv .fst → to
.snd .is-iso.inv p x → from p x .fst
.snd .is-iso.rinv pred → Σ-prop-path! $ ℙ-ext
(λ x w → from pred x .snd .fst w)
(λ x p → Equiv.from (from pred x .snd) p)
.snd .is-iso.linv pred → funext λ x →
(λ p → from (to λ _ → p) x .fst ≡ p) refl refl (pred x) Bool-elim
where is regarded as the top element of its own subobject lattice↩︎