latte-sets.set
Set-theoretic notions based on the subset approach of type theory.
The main idea is to consider a typed variant of a mathematical set as a predicate over a given type.
What is called a set will be technically-speaking a subset of a type, hence a predicate over a given type. This means that the set theory developed here is typed and thus quite different than the standard axiomatic set theories (e.g. ZF and ZFC), which are essentially untyped.
But many set-theoretic constructions and results have a natural translation to the typed setting.
elem
(elem x s)
means x
is an element of set s
, cf. elem-def.
elem-def
(elem-def [T :type] [x T] [s (set T)])
(s x)
Definition: Set membership.
(elem x s)
means that x
(of implicit type T
) is an element of set s
. The standard mathematical notation is: x
∊s
.
element-type-of
Replaces sterm
by its element type (if it is a set type).
emptyset
(emptyset [T :type])
(set-of [x T] p/absurd)
Definition: The empty set of a type.
emptyset-prop
(emptyset-prop [T :type])
(forall [x T] (not (elem x (emptyset T))))
Theorem: The main property of the empty set.
fetch-set-type
(fetch-set-type def-env ctx s-type)
fullset
(fullset [T :type])
(set-of [x T] p/truth)
Definition: The full set of a type (all the inhabitants of the type are element of the full set).
fullset-intro
(fullset-intro [T :type])
(forall [x T] (elem x (fullset T)))
Theorem: Introduction rule for the full set.
psubset
(psubset [s1 (set T)] [s2 (set T)])
(and (subset s1 s2) (not (seteq s1 s2)))
Definition: The anti-reflexive variant of the subset relation.
The expression (psubset T s1 s2)
means that the set s1
is a subset of s2
, but that the two sets are distinct, i.e. s1
⊂s2
(or more explicitely s1
⊊s2
).
psubset-antirefl
(psubset-antirefl [s (set T)])
(not (psubset s s))
Theorem:
psubset-antisym
(psubset-antisym [s1 (set T)] [s2 (set T)])
(not (and (psubset s1 s2) (psubset s2 s1)))
Theorem:
psubset-emptyset
(psubset-emptyset [s (set T)])
(==> (psubset (emptyset T) s) (not (seteq s (emptyset T))))
Theorem:
psubset-emptyset-conv
(psubset-emptyset-conv [s (set T)])
(==> (not (seteq s (emptyset T))) (psubset (emptyset T) s))
Theorem:
psubset-emptyset-equiv
(psubset-emptyset-equiv [s (set T)])
(<=> (psubset (emptyset T) s) (not (seteq s (emptyset T))))
Theorem:
psubset-trans
(psubset-trans [s1 (set T)] [s2 (set T)] [s3 (set T)])
(==> (psubset s1 s2) (psubset s2 s3) (psubset s1 s3))
Theorem: The proper subset relation is transitive.
set
(set [T :type])
(==> T :type)
Definition: The type of sets whose elements are of type T
.
set-equal
(set-equal [s1 (set T)] [s2 (set T)])
(forall [P (==> (set T) :type)] (<=> (P s1) (P s2)))
Definition: A Leibniz-style equality for sets.
It says that two sets s1
and s2
are equal iff for any predicate P
then (P s1)
if and only if (P s2)
.
Note that the identification with seteq is non-trivial, and requires an axiom.
set-equal-implies-seteq
(set-equal-implies-seteq [s1 (set T)] [s2 (set T)])
(==> (set-equal s1 s2) (seteq s1 s2))
Theorem: Subset-based equality implies Leibniz-style equality on sets.
set-equal-implies-subset
(set-equal-implies-subset [s1 (set T)] [s2 (set T)])
(==> (set-equal s1 s2) (subset s1 s2))
Theorem: Going from Leibniz equality on sets to the subset relation is easy.
set-equal-prop
(set-equal-prop [s1 (set T)] [s2 (set T)] [P (==> (set T) :type)])
(==> (set-equal s1 s2) (P s1) (P s2))
Theorem:
set-equal-refl
(set-equal-refl [s (set T)])
(set-equal s s)
Theorem: Reflexivity of set equality.
set-equal-seteq
(set-equal-seteq [s1 (set T)] [s2 (set T)])
(<=> (seteq s1 s2) (set-equal s1 s2))
Theorem: Set equality and subset-based equality (should) coincide (axiomatically).
set-equal-sym
(set-equal-sym [s1 (set T)] [s2 (set T)])
(==> (set-equal s1 s2) (set-equal s2 s1))
Theorem: Symmetry of set equality.
set-equal-trans
(set-equal-trans [s1 (set T)] [s2 (set T)] [s3 (set T)])
(==> (set-equal s1 s2) (set-equal s2 s3) (set-equal s1 s3))
Theorem: Transitivity of set equality.
set-of
Definition of a set by comprehension.
(set-of [x T] (P x))
is the set of all x
’s of type T
such that (P x)
. This is similar to the notation {x : T | P(x) }
in classical mathematics.
Note that it is exactly the same as (lambda [x T] (P x))
seteq
(seteq [s1 (set T)] [s2 (set T)])
(and (subset s1 s2) (subset s2 s1))
Definition: Set equivalence. Set s1
is equal to s2
This is a natural notion of “equal sets” based on the subset relation.
seteq-implies-set-equal
(seteq-implies-set-equal [s1 (set T)] [s2 (set T)])
(==> (seteq s1 s2) (set-equal s1 s2))
Axiom: Going from subset-based equality to Leibniz-style equality requires this axiom. This is because we cannot lift membership to an arbitrary predicate.
seteq-refl
(seteq-refl [s (set T)])
(seteq s s)
Theorem: Set equality is reflexive.
seteq-sym
(seteq-sym [s1 (set T)] [s2 (set T)])
(==> (seteq s1 s2) (seteq s2 s1))
Theorem: Set equality is symmetric.
seteq-trans
(seteq-trans [s1 (set T)] [s2 (set T)] [s3 (set T)])
(==> (seteq s1 s2) (seteq s2 s3) (seteq s1 s3))
Theorem: Set equality is transitive.
subset
(subset [s1 (set T)] [s2 (set T)])
(forall [x T] (==> (elem x s1) (elem x s2)))
Definition: The subset relation for type T
. The expression (subset-def T s1 s2)
means that the set s1
is a subset of s2
, i.e. s1
⊆s2
.
subset-elim
(subset-elim [s1 (set T)] [s2 (set T)] [x T])
(==> (elem x s1) (subset s1 s2) (elem x s2))
Theorem: Elimination rule for subset relation.
subset-emptyset-lower-bound
(subset-emptyset-lower-bound [s (set T)])
(subset (emptyset T) s)
Theorem: The emptyset is a subset of every other sets.
subset-fullset-upper-bound
(subset-fullset-upper-bound [s (set T)])
(subset s (fullset T))
Theorem: The fullset is a superset of every other sets.
subset-intro
(subset-intro [s1 (set T)] [s2 (set T)])
(==> (forall [x T] (==> (elem x s1) (elem x s2))) (subset s1 s2))
Theorem: Introduction rule for subset relation.
subset-prop
(subset-prop [P (==> T :type)] [s1 (set T)] [s2 (set T)])
(==>
(forall [x T] (==> (elem x s2) (P x)))
(subset s1 s2)
(forall [x T] (==> (elem x s1) (P x))))
Theorem: Preservation of properties on subsets.
subset-refl
(subset-refl [s (set T)])
(subset s s)
Theorem: The subset relation is reflexive.
subset-trans
(subset-trans [s1 (set T)] [s2 (set T)] [s3 (set T)])
(==> (subset s1 s2) (subset s2 s3) (subset s1 s3))
Theorem: The subset relation is transitive.