CADiZ

Reference manual / Standard toolkit / section set_toolkit


Preliminary definitions

section set_toolkit

Relations

generic 5 rightassoc (_ \rel _)

X \rel Y == \power ( X \cross Y )

X \rel Y is the set of relations between X and Y, that is, the set of all sets of ordered pairs whose first members are members of X and whose second members are members of Y.

Total functions

generic 5 rightassoc (_ \fun _)

X \fun Y == {  f : X \rel Y | \forall x : X @ \exists1 y : Y @ (x , y) \in f  }

X \fun Y is the set of all total functions from X to Y, that is, the set of all relations between X and Y such that each x in X is related to exactly one y in Y.

Sets

Inequality relation

relation (_ \neq _)

[X]

_ \neq _ : X \rel X
\where \where \where
\forall x , y : X @ x \neq y \iff \lnot x = y

Inequality is the relation between those values of the same type that are not equal to each other.

Non-membership

relation (_ \notin _)

[X]

_ \notin _ : X \rel \power X
\where \where \where
\forall x : X ; a : \power X @ x \notin a \iff \lnot x \in a

Non-membership is the relation between those values of a type, x, and sets of values of that type, a, for which x is not a member of a.

Empty set

\emptyset [ X ] == {  x : X | false  }

The empty set of any type is the set of that type that has no members.

Subset relation

relation (_ \subseteq _)

[X]

_ \subseteq _ : \power X \rel \power X
\where \where \where
\forall a , b : \power X @ a \subseteq b \iff
( \forall x : a @ x \in b )

Subset is the relation between two sets of the same type, a and b, such that every member of a is a member of b.

Proper subset relation

relation (_ \subset _)

[X]

_ \subset _ : \power X \rel \power X
\where \where \where
\forall a , b : \power X @ a \subset b \iff
a \subseteq b \land a \neq b

Proper subset is the relation between two sets of the same type, a and b, such that a is a subset of b, and a and b are not equal.

Non-empty subsets

\power1 X == {  a : \power X | a \neq \emptyset  }

If X is a set, then \power1 X is the set of all non-empty subsets of X.

NOTE The \power symbol is established as a generic operator by the prelude.

Set union

function 30 leftassoc (_ \cup _)

[X]

_ \cup _ : \power X \cross \power X \fun \power X
\where \where \where
\forall a , b : \power X @ a \cup b = {  x : X | x \in a \lor x \in b  }

The union of two sets of the same type is the set of values that are members of either set.

Set intersection

function 40 leftassoc (_ \cap _)

[X]

_ \cap _ : \power X \cross \power X \fun \power X
\where \where \where
\forall a , b : \power X @ a \cap b = {  x : X | x \in a \land x \in b  }

The intersection of two sets of the same type is the set of values that are members of both sets.

Set difference

function 30 leftassoc (_ \ _)

[X]

_ \ _ : \power X \cross \power X \fun \power X
\where \where \where
\forall a , b : \power X @ a \ b = {  x : X | x \in a \land x \notin b  }

The difference of two sets of the same type is the set of values that are members of the first set but not members of the second set.

Set symmetric difference

function 25 leftassoc (_ \symdiff _)

[X]

_ \symdiff _ : \power X \cross \power X \fun \power X
\where \where \where
\forall a , b : \power X @ a \symdiff b = {  x : X | \lnot ( x \in a \iff x \in b)  }

The symmetric set difference of two sets of the same type is the set of values that are members of one set, or the other, but not members of both.

Generalized union

[X]

\bigcup : \power \power X \fun \power X
\where \where \where
\forall A : \power \power X @ \bigcup A = {  x : X | \exists a : A @ x \in a  }

The generalized union of a set of sets of the same type is the set of values of that type that are members of at least one of the sets.

Generalized intersection

[X]

\bigcap : \power \power X \fun \power X
\where \where \where
\forall A : \power \power X @ \bigcap A = {  x : X | \forall a : A @ x \in a  }

The generalized intersection of a set of sets of values of the same type is the set of values of that type that are members of every one of the sets.

Finite sets

Finite subsets

generic (\finset _)

\finset X == \bigcap {  A : \power \power X |
\emptyset \in A \land ( \forall a : A ; x : X @ a \cup { x } \in A )  }

If X is a set, then \finset X is the set of all finite subsets of X. The set of finite subsets of X is the smallest set that contains the empty set and is closed under the action of adding single elements of X.

Non-empty finite subsets

\finset1 X == \finset X \ { \emptyset }

If X is a set, then \finset1 X is the set of all non-empty finite subsets of X. The set of non-empty finite subsets of X is the smallest set that contains the singleton sets of X and is closed under the action of adding single elements of X.


IT 22-Jan-2002