# IsarMathLib

## A library of formalized mathematics for Isabelle/ZF theorem proving environment

theory ZF1 imports ZF.equalities
begin

The standard Isabelle distribution contains lots of facts about basic set theory. This theory file adds some more.

### Lemmas in Zermelo-Fraenkel set theory

Here we put lemmas from the set theory that we could not find in the standard Isabelle distribution.

If one collection is contained in another, then we can say the same about their unions.

lemma collection_contain:

assumes $$A\subseteq B$$

shows $$\bigcup A \subseteq \bigcup B$$proof
fix $$x$$
assume $$x \in \bigcup A$$
then obtain $$X$$ where $$x\in X$$ and $$X\in A$$
with assms show $$x \in \bigcup B$$
qed

If all sets of a nonempty collection are the same, then its union is the same.

lemma ZF1_1_L1:

assumes $$C\neq 0$$ and $$\forall y\in C.\ b(y) = A$$

shows $$(\bigcup y\in C.\ b(y)) = A$$ using assms

The union af all values of a constant meta-function belongs to the same set as the constant.

lemma ZF1_1_L2:

assumes A1: $$C\neq 0$$ and A2: $$\forall x\in C.\ b(x) \in A$$ and A3: $$\forall x y.\ x\in C \wedge y\in C \longrightarrow b(x) = b(y)$$

shows $$(\bigcup x\in C.\ b(x))\in A$$proof
from A1 obtain $$x$$ where D1: $$x\in C$$
with A3 have $$\forall y\in C.\ b(y) = b(x)$$
with A1 have $$(\bigcup y\in C.\ b(y)) = b(x)$$ using ZF1_1_L1
with D1, A2 show $$thesis$$
qed

If two meta-functions are the same on a cartesian product, then the subsets defined by them are the same. I am surprised Isabelle can not handle this automatically.

lemma ZF1_1_L4:

assumes A1: $$\forall x\in X.\ \forall y\in Y.\ a(x,y) = b(x,y)$$

shows $$\{a(x,y).\ \langle x,y\rangle \in X\times Y\} = \{b(x,y).\ \langle x,y\rangle \in X\times Y\}$$proof
show $$\{a(x, y).\ \langle x,y\rangle \in X \times Y\} \subseteq \{b(x, y).\ \langle x,y\rangle \in X \times Y\}$$proof
fix $$z$$
assume $$z \in \{a(x, y) .\ \langle x,y\rangle \in X \times Y\}$$
with A1 show $$z \in \{b(x,y).\ \langle x,y\rangle \in X\times Y\}$$
qed
show $$\{b(x, y).\ \langle x,y\rangle \in X \times Y\} \subseteq \{a(x, y).\ \langle x,y\rangle \in X \times Y\}$$proof
fix $$z$$
assume $$z \in \{b(x, y).\ \langle x,y\rangle \in X \times Y\}$$
with A1 show $$z \in \{a(x,y).\ \langle x,y\rangle \in X\times Y\}$$
qed
qed

If two meta-functions are the same on a cartesian product, then the subsets defined by them are the same. This is similar to ZF1_1_L4, except that the set definition varies over $$p\in X\times Y$$ rather than $$\langle x,y\rangle \in X\times Y$$.

lemma ZF1_1_L4A:

assumes A1: $$\forall x\in X.\ \forall y\in Y.\ a(\langle x,y\rangle ) = b(x,y)$$

shows $$\{a(p).\ p \in X\times Y\} = \{b(x,y).\ \langle x,y\rangle \in X\times Y\}$$proof
{
fix $$z$$
assume $$z \in \{a(p).\ p\in X\times Y\}$$
then obtain $$p$$ where D1: $$z=a(p)$$, $$p\in X\times Y$$
let $$x = \text{fst}(p)$$
let $$y = \text{snd}(p)$$
from A1, D1 have $$z \in \{b(x,y).\ \langle x,y\rangle \in X\times Y\}$$
}
then show $$\{a(p).\ p \in X\times Y\} \subseteq \{b(x,y).\ \langle x,y\rangle \in X\times Y\}$$
next
{
fix $$z$$
assume $$z \in \{b(x,y).\ \langle x,y\rangle \in X\times Y\}$$
then obtain $$x$$ $$y$$ where D1: $$\langle x,y\rangle \in X\times Y$$, $$z=b(x,y)$$
let $$p = \langle x,y\rangle$$
from A1, D1 have $$p\in X\times Y$$, $$z = a(p)$$
then have $$z \in \{a(p).\ p \in X\times Y\}$$
}
then show $$\{b(x,y).\ \langle x,y\rangle \in X\times Y\} \subseteq \{a(p).\ p \in X\times Y\}$$
qed

A lemma about inclusion in cartesian products. Included here to remember that we need the $$U\times V \neq \emptyset$$ assumption.

lemma prod_subset:

assumes $$U\times V\neq 0$$, $$U\times V \subseteq X\times Y$$

shows $$U\subseteq X$$ and $$V\subseteq Y$$ using assms

A technical lemma about sections in cartesian products.

lemma section_proj:

assumes $$A \subseteq X\times Y$$ and $$U\times V \subseteq A$$ and $$x \in U$$, $$y \in V$$

shows $$U \subseteq \{t\in X.\ \langle t,y\rangle \in A\}$$ and $$V \subseteq \{t\in Y.\ \langle x,t\rangle \in A\}$$ using assms

If two meta-functions are the same on a set, then they define the same set by separation.

lemma ZF1_1_L4B:

assumes $$\forall x\in X.\ a(x) = b(x)$$

shows $$\{a(x).\ x\in X\} = \{b(x).\ x\in X\}$$ using assms

A set defined by a constant meta-function is a singleton.

lemma ZF1_1_L5:

assumes $$X\neq 0$$ and $$\forall x\in X.\ b(x) = c$$

shows $$\{b(x).\ x\in X\} = \{c\}$$ using assms

Most of the time, auto does this job, but there are strange cases when the next lemma is needed.

lemma subset_with_property:

assumes $$Y = \{x\in X.\ b(x)\}$$

shows $$Y \subseteq X$$ using assms

We can choose an element from a nonempty set.

lemma nonempty_has_element:

assumes $$X\neq 0$$

shows $$\exists x.\ x\in X$$ using assms

In Isabelle/ZF the intersection of an empty family is empty. This is exactly lemma Inter_0 from Isabelle's equalities theory. We repeat this lemma here as it is very difficult to find. This is one reason we need comments before every theorem: so that we can search for keywords.

lemma inter_empty_empty:

shows $$\bigcap 0 = 0$$ by (rule Inter_0 )

If an intersection of a collection is not empty, then the collection is not empty. We are (ab)using the fact the the intersection of empty collection is defined to be empty.

lemma inter_nempty_nempty:

assumes $$\bigcap A \neq 0$$

shows $$A\neq 0$$ using assms

For two collections $$S,T$$ of sets we define the product collection as the collections of cartesian products $$A\times B$$, where $$A\in S, B\in T$$.

Definition

$$\text{ProductCollection}(T,S) \equiv \bigcup U\in T.\ \{U\times V.\ V\in S\}$$

The union of the product collection of collections $$S,T$$ is the cartesian product of $$\bigcup S$$ and $$\bigcup T$$.

lemma ZF1_1_L6:

shows $$\bigcup \text{ProductCollection}(S,T) = \bigcup S \times \bigcup T$$ using ProductCollection_def

An intersection of subsets is a subset.

lemma ZF1_1_L7:

assumes A1: $$I\neq 0$$ and A2: $$\forall i\in I.\ P(i) \subseteq X$$

shows $$( \bigcap i\in I.\ P(i) ) \subseteq X$$proof
from A1 obtain $$i_0$$ where $$i_0 \in I$$
with A2 have $$( \bigcap i\in I.\ P(i) ) \subseteq P(i_0)$$ and $$P(i_0) \subseteq X$$
thus $$( \bigcap i\in I.\ P(i) ) \subseteq X$$
qed

Isabelle/ZF has a "THE" construct that allows to define an element if there is only one such that is satisfies given predicate. In pure ZF we can express something similar using the indentity proven below.

lemma ZF1_1_L8:

shows $$\bigcup \{x\} = x$$

Some properties of singletons.

lemma ZF1_1_L9:

assumes A1: $$\exists ! x.\ x\in A \wedge \phi (x)$$

shows $$\exists a.\ \{x\in A.\ \phi (x)\} = \{a\}$$, $$\bigcup \{x\in A.\ \phi (x)\} \in A$$, $$\phi (\bigcup \{x\in A.\ \phi (x)\})$$proof
from A1 show $$\exists a.\ \{x\in A.\ \phi (x)\} = \{a\}$$
then obtain $$a$$ where I: $$\{x\in A.\ \phi (x)\} = \{a\}$$
then have $$\bigcup \{x\in A.\ \phi (x)\} = a$$
moreover
from I have $$a \in \{x\in A.\ \phi (x)\}$$
hence $$a\in A$$ and $$\phi (a)$$
ultimately show $$\bigcup \{x\in A.\ \phi (x)\} \in A$$ and $$\phi (\bigcup \{x\in A.\ \phi (x)\})$$
qed

A simple version of ZF1_1_L9.

corollary sigleton_extract:

assumes $$\exists ! x.\ x\in A$$

shows $$(\bigcup A) \in A$$proof
from assms have $$\exists ! x.\ x\in A \wedge True$$
then have $$\bigcup \{x\in A.\ True\} \in A$$ by (rule ZF1_1_L9 )
thus $$(\bigcup A) \in A$$
qed

A criterion for when a set defined by comprehension is a singleton.

lemma singleton_comprehension:

assumes A1: $$y\in X$$ and A2: $$\forall x\in X.\ \forall y\in X.\ P(x) = P(y)$$

shows $$(\bigcup \{P(x).\ x\in X\}) = P(y)$$proof
let $$A = \{P(x).\ x\in X\}$$
have $$\exists ! c.\ c \in A$$proof
from A1 show $$\exists c.\ c \in A$$
next
fix $$a$$ $$b$$
assume $$a \in A$$ and $$b \in A$$
then obtain $$x$$ $$t$$ where $$x \in X$$, $$a = P(x)$$ and $$t \in X$$, $$b = P(t)$$
with A2 show $$a=b$$
qed
then have $$(\bigcup A) \in A$$ by (rule sigleton_extract )
then obtain $$x$$ where $$x \in X$$ and $$(\bigcup A) = P(x)$$
from A1, A2, $$x \in X$$ have $$P(x) = P(y)$$
with $$(\bigcup A) = P(x)$$ show $$(\bigcup A) = P(y)$$
qed

Adding an element of a set to that set does not change the set.

assumes $$x\in X$$

shows $$X \cup \{x\} = X$$ using assms

Here we define a restriction of a collection of sets to a given set. In romantic math this is typically denoted $$X\cap M$$ and means $$\{X\cap A : A\in M \}$$. Note there is also restrict$$(f,A)$$ defined for relations in ZF.thy.

Definition

$$M \text{ restricted to } X \equiv \{X \cap A .\ A \in M\}$$

A lemma on a union of a restriction of a collection to a set.

lemma union_restrict:

shows $$\bigcup (M \text{ restricted to } X) = (\bigcup M) \cap X$$ using RestrictedTo_def

Next we show a technical identity that is used to prove sufficiency of some condition for a collection of sets to be a base for a topology.

lemma ZF1_1_L10:

assumes A1: $$\forall U\in C.\ \exists A\in B.\ U = \bigcup A$$

shows $$\bigcup \bigcup \{\bigcup \{A\in B.\ U = \bigcup A\}.\ U\in C\} = \bigcup C$$proof
show $$\bigcup (\bigcup U\in C.\ \bigcup \{A \in B .\ U = \bigcup A\}) \subseteq \bigcup C$$
show $$\bigcup C \subseteq \bigcup (\bigcup U\in C.\ \bigcup \{A \in B .\ U = \bigcup A\})$$proof
fix $$x$$
assume $$x \in \bigcup C$$
show $$x \in \bigcup (\bigcup U\in C.\ \bigcup \{A \in B .\ U = \bigcup A\})$$proof
from $$x \in \bigcup C$$ obtain $$U$$ where $$U\in C \wedge x\in U$$
with A1 obtain $$A$$ where $$A\in B \wedge U = \bigcup A$$
from $$U\in C \wedge x\in U$$, $$A\in B \wedge U = \bigcup A$$ show $$x\in \bigcup (\bigcup U\in C.\ \bigcup \{A \in B .\ U = \bigcup A\})$$
qed
qed
qed

Standard Isabelle uses a notion of $$cons(A,a)$$ that can be thought of as $$A\cup \{a\}$$.

lemma consdef:

shows $$cons(a,A) = A \cup \{a\}$$ using cons_def

If a difference between a set and a sigleton is empty, then the set is empty or it is equal to the sigleton.

lemma singl_diff_empty:

assumes $$A - \{x\} = 0$$

shows $$A = 0 \vee A = \{x\}$$ using assms

If a difference between a set and a sigleton is the set, then the only element of the singleton is not in the set.

lemma singl_diff_eq:

assumes A1: $$A - \{x\} = A$$

shows $$x \notin A$$proof
have $$x \notin A - \{x\}$$
with A1 show $$x \notin A$$
qed

A basic property of sets defined by comprehension.

lemma comprehension:

assumes $$a \in \{x\in X.\ p(x)\}$$

shows $$a\in X$$ and $$p(a)$$ using assms
end
lemma ZF1_1_L1:

assumes $$C\neq 0$$ and $$\forall y\in C.\ b(y) = A$$

shows $$(\bigcup y\in C.\ b(y)) = A$$
Definition of ProductCollection: $$\text{ProductCollection}(T,S) \equiv \bigcup U\in T.\ \{U\times V.\ V\in S\}$$
lemma ZF1_1_L9:

assumes $$\exists ! x.\ x\in A \wedge \phi (x)$$

shows $$\exists a.\ \{x\in A.\ \phi (x)\} = \{a\}$$, $$\bigcup \{x\in A.\ \phi (x)\} \in A$$, $$\phi (\bigcup \{x\in A.\ \phi (x)\})$$
corollary sigleton_extract:

assumes $$\exists ! x.\ x\in A$$

shows $$(\bigcup A) \in A$$
Definition of RestrictedTo: $$M \text{ restricted to } X \equiv \{X \cap A .\ A \in M\}$$
65
5
17
17