# OpenLogicProject/OpenLogic

fixing issue #107, replacing \Nat with \Int^+ when discussing enumara…

…tions and formulating everything with total functions
 @@ -10,108 +10,180 @@ \olsection{\printtoken{S}{enumerable} Sets} +One way of specifying a finite set is by listing its !!{element}s. But +conversely, since there are only finitely many !!{element}s in a set, +every finite set can be enumerated. By this we mean: its elements can +be put into a list (a list with a beginning, where each !!{element} of +the list other than the first has a unique predecessor). Some +infinite sets can also be enumerated, such as the set of positive +integers. + \begin{defn}[Enumeration] -Informally, an \emph{enumeration} of a set $X$ is a list (possibly -infinite) such that every !!{element} of $X$ appears some finite -number of places into the list. If $X$ has an enumeration, then $X$ is -said to be \emph{!!{enumerable}}. If $X$ is !!{enumerable} and -infinite, we say $X$ is !!{denumerable}. +Informally, an \emph{enumeration} of a set~$X$ is a list (possibly +infinite) of !!{element}s of~$X$ such that every !!{element} of $X$ +appears on the list at some finite position. If $X$ has an +enumeration, then $X$ is said to be \emph{!!{enumerable}}. If $X$ is +!!{enumerable} and infinite, we say $X$ is !!{denumerable}. \end{defn} \begin{explain} A couple of points about enumerations: \begin{enumerate} -\item The order of !!{element}s of $X$ in the enumeration does not - matter, as long as every !!{element} appears: $4$, $1$, $2$5, - $16$,~$9$ enumerates the (set of the) first five square numbers just - as well as $1$, $4$, $9$, $16$,~$25$ does. +\item We count as enumerations only lists which have a beginning and + in which every !!{element} other than the first has a single + !!{element} immediately preceding it. In other words, there are + only finitely many elements between the first !!{element} of the + list and any other !!{element}. +\item We can have different enumerations of the same set~$X$ which + differ by the order in which the !!{element}s appear: $4$, $1$, + $25$, $16$,~$9$ enumerates the (set of the) first five square + numbers just as well as $1$, $4$, $9$, $16$,~$25$ does. \item Redundant enumerations are still enumerations: $1$, $1$, $2$, $2$, $3$, $3$,~\dots{} enumerates the same set as $1$, $2$, $3$,~\dots{} does. \item Order and redundancy \emph{do} matter when we specify an - enumeration: we can enumerate the natural numbers beginning with + enumeration: we can enumerate the positive integers beginning with $1$, $2$, $3$, $1$, \dots{}, but the pattern is easier to see when enumerated in the standard way as $1$, $2$, $3$, $4$,~\dots \item Enumerations must have a beginning: \dots, $3$, $2$, $1$ is not an enumeration of the natural numbers because it has no first !!{element}. To see how this follows from the informal definition, - ask yourself, at what place in the list does the number 76 + ask yourself, at what position in the list does the number 76 appear?'' -\item The following is not an enumeration of the natural numbers: $1$, - $3$, $5$, \dots, $2$, $4$, $6$, \dots\@ The problem is that the even - numbers occur at places $\infty + 1$, $\infty + 2$, $\infty + 3$, - rather than at finite positions. +\item The following is not an enumeration of the positive integers: + $1$, $3$, $5$, \dots, $2$, $4$, $6$, \dots\@ The problem is that the + even numbers occur at places $\infty + 1$, $\infty + 2$, $\infty + + 3$, rather than at finite positions. \item Lists may be gappy: $2$, $-$, $4$, $-$, $6$, $-$, \dots{} - enumerates the even natural numbers. -\item The empty set is enumerable: it is enumerated by the empty list! + enumerates the even positive integers. +\item The empty set is enumerable: it is enumerated by the empty list!{} \end{enumerate} \end{explain} -The following provides a more formal definition of an -enumeration: +\begin{prop} + If $X$ has an enumeration, it has an enumeration without gaps or + repetitions. +\end{prop} + +\begin{proof} + Suppose $X$ has an enumeration $x_1$, $x_2$, \dots{} in which each + $x_i$ is an !!{element} of~$X$ or a gap. We can remove repetitions + from an enumeration by replacing repeated !!{element}s by gaps. For + instance, we can turn the enumeration into a new one in which $x_i'$ + is $x_i$ if $x_i$ is !!a{element} of~$X$ that is not among $x_1$, + \dots, $x_{i-1}$ or is $-$ if it is. We can remove gaps by closing up + the elements in the list. To make precise what closing up'' + amounts to is a bit difficult to describe. For instance, we can + generate a new enumeration $x_1''$, $x_2''$, \dots, where each + $x_i''$ is the first !!{element} in the enumeration $x_1'$, $x_2'$, + \dots{} after $x_{i-1}''$. +\end{proof} + +The last proof shows that in order to give precise definitions and +proofs about enumerations and !!{enumerable} sets, we need a more +precise definition. The following provides it. \begin{defn}[Enumeration] An \emph{enumeration} of a set $X$ is any !!{surjective} function $f: -\Nat \rightarrow X$. +\Int^+ \to X$. \end{defn} \begin{explain} Let's convince ourselves that the formal definition and the informal definition using a possibly gappy, possibly infinite list are -equivalent. !!^a{surjective} function (partial or total) from$\Nat$to -a set$X$enumerates~$X$. Such a function determines an enumeration as -defined informally above. Then an enumeration for$X$is the list -$f(0)$,$f(1)$,$f(2)$, \dots. Since$f$is !!{surjective}, every -!!{element} of$X$is guaranteed to be the value of$f(n)$for some~$n -\in \Nat$. Hence, every !!{element} of$X$appears at some finite -place in the list. Since the function may be partial or not !!{injective}, -the list may be gappy or redundant, but that is acceptable (as noted -above). On the other hand, given a list that enumerates all -!!{element}s of~$X$, we can define !!a{surjective} function$f\colon -\Nat \to X$by letting$f(n)$be the$(n+1)$st member of the list, or -undefined if the list has a gap in the$(n+1)$st spot. +equivalent. !!^a{surjective} function (partial or total) from$\Int^+$+to a set$X$enumerates~$X$. Such a function determines an enumeration +as defined informally above: the list$f(1)$,$f(2)$,$f(3)$, +\dots. Since$f$is !!{surjective}, every !!{element} of$X$is +guaranteed to be the value of$f(n)$for some~$n \in \Int^+$. Hence, +every !!{element} of$X$appears at some finite position in the +list. Since the function may not be !!{injective}, the list may be +redundant, but that is acceptable (as noted above). + +On the other hand, given a list that enumerates all !!{element}s +of~$X$, we can define !!a{surjective} function$f\colon \Int \to X$by +letting$f(n)$be the$n$th !!{element} of the list that is not a gap, +or the last !!{element} of the list if there is no$n$th !!{element}. +There is one case in which this does not produce !!a{surjective} +function: if$X$is empty, and hence the lsit is empty. So, every +non-empty list determines !!a{surjective} function$f\colon \Int^+ \to +X$. \end{explain} +\begin{defn} + \ollabel{defn:enumerable} + A set~$X$is !!{enumerable} iff it is empty or has an enumeration. +\end{defn} + \begin{ex} -A function enumerating the natural numbers ($\Nat$) is -simply the identity function given by$f(n) = n$. +A function enumerating the positive integers ($\Int^+$) is simply the +identity function given by$f(n) = n$. A function enumerating the +natural numbers$\Nat$is the function$g(n) = n - 1$. \end{ex} +\begin{prob} + According to \olref{defn:enumerable}, a set$X$is enumerable iff$X + = \emptyset$or there is !!a{surjective}$f\colon \Int^+ \to X$. It + is also possible to define !!{enumerable} set'' precisely by: a + set is enumerable iff there is !!a{injective} function$g\colon X + \to \Int^+$. Show that the definitions are equivalent, i.e., show + that there is !!a{injective} function$g\colon X \to \Int^+$iff + either$X = \emptyset$or there is !!a{surjective}$f\colon \Int^+ + \to X$. +\end{prob} + \begin{ex} -The functions$f\colon \Nat \to \Nat$and$g \colon \Nat \to \Nat$given by +The functions$f\colon \Int^+ \to \Int^+$and$g \colon \Int^+ \to +\Int^+given by \begin{align} f(n) & = 2n \text{ and}\\ g(n) & = 2n+1 \end{align} -enumerate the even natural numbers and the odd natural numbers, +enumerate the even natural numbers and the odd positive integers, respectively. However, neither function is an enumeration of -\Nat$, since neither is !!{surjective}. +$\Int^+$, since neither is !!{surjective}. \end{ex} \begin{ex} -The function$f(n) = \lceil \frac{(-1)^n n}{2}\rceil$(where$\lceil x -\rceil$denotes the \emph{ceiling} function, which rounds$x$up to -the nearest integer) enumerates the set of integers~$\Int$. Notice -how$f$generates the values of$\Int$by hopping'' back and forth -between positive and negative integers: +The function$f(n) = (-1)^{n} \lceil \frac{(n-1)}{2}\rceil$(where +$\lceil x \rceil$denotes the \emph{ceiling} function, which rounds +$x$up to the nearest integer) enumerates the set of +integers~$\Int$. Notice how$f$generates the values of$\Int$by +hopping'' back and forth between positive and negative integers: $-\begin{array}{c c c c c c c} -f(1) & f(2) & f(3) & f(4) & f(5) & f(6) & \dots \\ \\ -\lceil - \tfrac{1}{2}\rceil & \lceil \tfrac{2}{2} \rceil & \lceil - -\tfrac{3}{2} \rceil & \lceil \tfrac{4}{2} \rceil & \lceil -\tfrac{5}{2} -\rceil & \lceil \tfrac{6}{2} \rceil & \dots \\ \\ +\begin{array}{c c c c c c c c} +f(1) & f(2) & f(3) & f(4) & f(5) & f(6) & f(7) & \dots \\ \\ +- \lceil \tfrac{0}{2} \rceil & \lceil \tfrac{1}{2}\rceil & - \lceil \tfrac{2}{2} \rceil & \lceil \tfrac{3}{2} \rceil & - \lceil \tfrac{4}{2} \rceil & \lceil \tfrac{5}{2} +\rceil & - \lceil \tfrac{6}{2} \rceil & \dots \\ \\ 0 & 1 & -1 & 2 & -2 & 3 & \dots \end{array}$ +You can also think of$f$as defined by cases as follows: +$+f(n) = \begin{cases} + 0 & \text{if n = 1}\\ + n/2 & \text{if n is even}\\ + -(n-1)/2 & \text{if n is odd and >1} + \end{cases} +$ \end{ex} +\begin{prob} + Show that if$X$and$Y$are !!{enumerable}, so is$X \cup Y$. +\end{prob} + +\begin{prob} + Show by induction on$n$that if$X_1$,$X_2$, \dots,$X_n$are all + !!{enumerable}, so is$X_1 \cup \dots \cup X_n$. +\end{prob} + \begin{explain} That is fine for easy'' sets. What about the set of, say, pairs of natural numbers?{} $-\Nat^2 = \Nat \times \Nat = \Setabs{\tuple{n,m}}{n,m \in \Nat} +\Int^+ \times \Int^+ = \Setabs{\tuple{n,m}}{n,m \in \Int^+}$ -Another method we can use to enumerate sets is to organize them +We can organize the pairs of positive integers in an \emph{array}, such as the following: $\begin{array}{ c | c | c | c | c | c} @@ -129,11 +201,11 @@ \end{array}$ -Clearly, every ordered pair in$\Nat^2$will appear at least -once in the array. In particular,$\tuple{n,m}$will appear in the$n$th -column and$m$th row. But how do we organize the elements of an -array into a list? The pattern in the array below demonstrates one -way to do this: +Clearly, every ordered pair in$\Int^+ \times \Int^+$will appear +exactly once in the array. In particular,$\tuple{n,m}$will appear in +the$n$th column and$m$th row. But how do we organize the elements of +such an array into a one-way list? The pattern in the array below +demonstrates one way to do this: $\begin{array}{ c | c | c | c | c | c } & & & & & \\ @@ -149,29 +221,30 @@ & \vdots & \vdots & \vdots & \vdots & \ddots\\ \end{array}$ -This pattern is called \emph{Cantor's zig-zag method}. Other -patterns are perfectly permissible, as long as they zig-zag'' -through every cell of the array. By Cantor's zig-zag method, the -enumeration for$\Nat^2$according to this scheme would be: +This pattern is called \emph{Cantor's zig-zag method}. Other patterns +are perfectly permissible, as long as they zig-zag'' through every +cell of the array. By Cantor's zig-zag method, the enumeration for +$\Int^+ \times \Int^+$according to this scheme would be: $\tuple{1,1}, \tuple{1,2}, \tuple{2,1}, \tuple{1,3}, \tuple{2,2}, \tuple{3,1}, \tuple{1,4}, \tuple{2,3}, \tuple{3,2}, \tuple{4,1}, \dots$ What ought we do about enumerating, say, the set of ordered triples -of natural numbers? +of positive integers? $-\Nat^3 = \Nat \times \Nat \times \Nat = \Setabs{\tuple{n,m,k}}{n,m,k \in \Nat} +\Int^+ \times \Int^+ \times \Int^+ = \Setabs{\tuple{n,m,k}}{n,m,k \in \Int^+}$ -We can think of$\Nat^3$as the Cartesian product of -$\Nat^2$and$\Nat$, that is, +We can think of$\Int^+ \times \Int^+ \times \Int^+$as the Cartesian +product of$\Int^+ \times \Int^+$and$\Int^+$, that is, $-\Nat^3 = \Nat^2 \times \Nat = -\Setabs{\tuple{\tuple{n,m},k}}{\tuple{n,m} \in \Nat^2, k \in \Nat } +(\Int^+)^3 = (\Int^+ \times \Int^+) \times \Int^+ = +\Setabs{\tuple{\tuple{n,m},k}}{\tuple{n,m} \in \Int^+ \times \Int^+, k + \in \Int^+ }$ -and thus we can enumerate$\Nat^3$with an array by -labelling one axis with the enumeration of$\Nat$, and the -other axis with the enumeration of$\Nat^2$: +and thus we can enumerate$(\Int^+)^3$with an array by labelling one +axis with the enumeration of$\Int^+$, and the other axis with the +enumeration of$(\Int^+)^2$: $\begin{array}{ c | c | c | c | c | c} & \textbf 1 & \textbf 2 & \textbf 3 & \textbf 4 & \dots \\ @@ -188,12 +261,18 @@ \end{array}$ Thus, by using a method like Cantor's zig-zag method, we may -similarly obtain an enumeration of~$\Nat^3$. +similarly obtain an enumeration of~$(\Int^+)^3$. \end{explain} \begin{prob} -Give an enumeration of the set of all ordered pairs of positive -rational numbers. +Give an enumeration of the set of all positive rational numbers. (A +positive rational number is one that can be written as a fraction +$n/m$with$n, m \in \Int^+$). +\end{prob} + +\begin{prob} +Show that$\Rat$is !!{enumerable}. (A rational number is one that can +be written as a fraction$z/m$with$z \in \Int$,$m \in \Int^+$). \end{prob} \begin{prob} @@ -208,10 +287,6 @@ enumerable set is enumerable. \end{prob} -\begin{prob} -Show that if$X$and$Y$are !!{enumerable}, so is$X \cup Y\$. -\end{prob} - \begin{prob} A set of positive integers is said to be \emph{cofinite} iff it is the complement of a finite set of positive integers. Let