>>19Okay so the solution for it to be 1-1 is to use 0 as a delimiter.
What I'm doing here is this:
Sets are basically things of this sort:
{{{},{{}}, {{},{{}}}}, {}}
Because the comma can be deduced, it runs down to this:
{{{}{{}}{{}{{}}}}{}}
Now what this really is, is just a tree without labels (hence the Set type definition looks exactly like a Tree). I will depict the above set in an ASCII tree diagram:
2 / \
1 /
3 / / \
1,2 / /\
1 \
At the left side is the number of branches. At the right side is the tree (so for example
/ / \
means there are 3 branches). The idea to give a unique integer to this tree is this: Sort out lists (the only list here is
1,2
), and concatenate integers, with 0 as a delimiter. So what we'd get is this:
20103020101
The reason 0 is used as a delimiter is because I figured that it's not clear whether 21 means 2 and then 1 or really 21 nodes. It may be possible to deduce which of the two is true if you keep scanning the integer code to find the "only" legit set, but it may be that two different sets map to the same integer. I haven't figured out which of the two is true, but if you use 0 as a delimiter you are good to go.
Anyhow, that's the injection. Anybody up for the bijection? I tried lexicographical order on the
{{{}{{}}{{}{{}}}}{}}
representation, but it turns out it's not good enough: You run into infinity because of expressions like
{{{{...}}}, X}
and it doesn't matter what X is.