module Data.Power where
Power setsπ
The power set of a type
is the collection of all maps from
into the universe of propositional types
. Since the universe of all
-types
is a
-type
(by n-Type-is-hlevel
), and function
types have the same h-level as their codomain (by fun-is-hlevel
), the power set of a type
is always a set
. We denote the power set of
by
.
: Type β β Type β
β = X β Ξ©
β X
: is-set (β X)
β-is-set = hlevel 2 β-is-set
The membership relation is defined by applying the predicate and projecting the underlying type of the proposition: We say that is an element of if is inhabited.
_ : β {x : X} {P : β X} β x β P β‘ β£ P x β£
_ = refl
The subset relation is defined as is done traditionally: If implies , for , then .
_ : β {X : Type β} {x : X} {P Q : β X} β (P β Q) β‘ (β x β x β P β x β Q)
_ = refl
By function and propositional extensionality, two subsets of are equal when they contain the same elements, i.e., they assign identical propositions to each inhabitant of .
: {A B : β X}
β-ext β A β B β B β A β A β‘ B
{A = A} {B = B} AβB BβA = funext Ξ» x β
β-ext (AβB x) (BβA x) Ξ©-ua
Lattice structureπ
The type
has a lattice structure, with the order given by subset inclusion
. We call
the meets intersections
and the joins
unions
.
: β X
maximal _ = β€Ξ©
maximal
: β X
minimal _ = β₯Ξ©
minimal
_β©_ : β X β β X β β X
(A β© B) x = A x β§Ξ© B x
: X β β X
singleton = elΞ© (x β‘ y) singleton x y
Note that in the definition of union
, we must truncate
the coproduct
, since there is nothing which
guarantees that A and B are disjoint subsets.
_βͺ_ : β X β β X β β X
(A βͺ B) x = A x β¨Ξ© B x
infixr 27 _β©_
infixr 26 _βͺ_
Imagesπ
image-of: β {a b} {A : Type a} {B : Type b} {@(tactic hlevel-tactic-worker) b-set : is-set B}
β (f : A β B) β β A β β B
{b-set = b-set} f s b β£ = β‘ (Ξ£[ a β _ ] ((a β s) Γ (f a β‘ b)))
β£ image-of {b-set = b-set} f s b .is-tr = squash image-of