Is this a proper recursive definition?

182 Views Asked by At

I am trying to recursively define the set of all nonempty finite subsets of even numbers and all nonempty finite subsets of odd numbers which I will define as S.

Base Step

Let {1} $\in$ S and {2} $\in$ S

Recursive Step

$\forall$ a $\in Z$+ , $\forall$ b $\in$ S

If c $\in$ b, then b $\cup$ {c + 2a} $\in$ S

2

There are 2 best solutions below

1
On

... going off the comments ...

You indeed need to define the base case as having each number be a set by themselves.

That is:

Base:

For every $n \in Z^+$: $\{ n \} \in S$

Step:

For every $A \in S$ and $B \in S$ where $\exists n \in A : \exists k \in Z^+ : n = 2k$ and $\exists n \in B : \exists k \in Z^+ : n = 2k$: $A \cup B \in S$ (in other words, if $A$ and $B$ are sets containing even numbers, put their union in $S$)

For every $A \in S$ and $B \in S$ where $\exists n \in A : \exists k \in Z^+ : n = 2k + 1$ and $\exists n \in B : \exists k \in Z^+ : n = 2k + 1$: $A \cup B \in S$ (similar for odd numbers)

Personally, though, I would say that $S = S_{Even} \cup S_{Odd}$, and then define each of $S_{Even}$ and $S_{Odd}$ recursively:

Base:

For every even $n \in Z^+$: $\{ n \} \in S_{Even}$

For every odd $n \in Z^+$: $\{ n \} \in S_{Odd}$

Step:

For every $A \in S_{Even}$ and $B \in S_{Even}$: $A \cup B \in S_{Even}$

For every $A \in S_{Odd}$ and $B \in S_{Odd}$: $A \cup B \in S_{Odd}$

I don't know if you are allowed to break $S$ into two this way ... but it sure looks a little nicer!

0
On

Idea 1 : Bijecting with $\mathcal P(\mathbb Z)$

What you can do is find all subsets of $\mathbb Z$.

Then thanks to the bijections between integers and odd and even numbers the found subsets can be transformed into subsets of odd and even numbers without missing some.

So for $X\in\mathcal P(\mathbb Z)$ let's define then $E_X=\{2x|x\in X\}$ and $O_X=\{2x+1|x\in X\}$

Idea 2 : Splitting from $\mathcal P(\mathbb Z)$

Another idea is to split $\mathbb Z$ subsets into two subsets of odd and even elements and then add these two to the collection. There will be duplicates though while using this method but it doesn't matter when unioning them all.

So for $X\in\mathcal P(\mathbb Z)$ let's define then $E_X=\{x\ \mathrm{even}|x\in X\}$ and $O_X=\{x\ \mathrm {odd}|x\in X\}$

In both cases the union of these $E_X$ and $O_X$ over all subsets of $\mathbb Z$ does actually give all the subsets of even and odd numbers.

Recurrence for building $\mathcal P(\mathbb Z)$

To enumerate all finite subsets of any inifinite set, you need to decompose the problem into finite tasks. For instance for $\mathcal P(\mathbb N)$ you could find all finite subsets whose larger element is a given $N\in\mathbb N$.

Note that since you work in $\mathbb Z$ you need to adapt this $N$ to interpose negative number as well.

Thus you'll start with $\varnothing$, then progressively add

$[N=0] : \varnothing$

$[N=1]\to 0 : \{0\}$

$[N=2]\to 1 : \{1\},\{0,1\}$

$[N=3]\to -1 : \{-1\},\{-1,0\},\{-1,1\},\{-1,0,1\}$

$[N=4]\to 2 : \{2\},\{0,2\},\{1,2\},\{0,1,2\},\{-1,2\},\{-1,0,2\},\{-1,1,2\}\{-1,0,1,2\}$

...

I bet you see the recurrence coming :p

Starting with $A_0=\{\varnothing\}$ you add $0$ by operation $0\oplus\varnothing=\{0\}$ then you do $A_1=A_0\cup\{\{0\}\}$

Starting with $A_1=\{\varnothing,\{0\}\}$ you add $1$ by adding all elements in $1\times\{\varnothing,\{0\}\}=\{1\oplus\varnothing,1\oplus\{0\}\}=\{\{1\},\{0,1\}\}$ then you do $A_2=A_1\cup\{\{1\},\{0,1\}\}$

You get $A_2=\{\varnothing,\{0\},\{1\},\{0,1\}\}$.

The recurrence is then $\begin{cases} A_0=\varnothing\\ A_N=A_{N-1}\,\cup\{n\times A_{N-1}\}=A_{N-1}\,\cup\{n\oplus a\,|\,a\in A_{N-1}\}\\ \end{cases}$

The $n$ in question would be the $N^{th}$ element in this $\mathbb N\leftrightarrow\mathbb Z$ mapping and the $\oplus$ operation defined by adding an element to a set.

Note: I have ordered the elements in the subsets, but this is only for presentation purpose and ease of reading, in reality sets are unordered.