After reading a recent post on Good Math, Bad Math concerning surreal numbers, I got to thinking about how to model these in Haskell. I came up with the following formulation:
data Surreal = Zero | Plus Surreal | Minus Surreal
… which also seems very similar to the usual construction for natural numbers:
data Nat = Zero | Succ Nat
(I noted this in a comment on the original post.)
This got me thinking about how this construction (the sign-expanded version) mapped onto the original construction of the surreal numbers, which uses a left and a right set:
data Surreal = Surreal [Surr] [Surr]
These types translate to the following (in order of appearance):

This last type is suggestive for the natural numbers as well, and of course there is a analogous construction for the naturals:

…which is a set-based construction for the naturals. (Note that in the above formulas multisets are used instead of true sets, but I don’t think this makes a difference in this context.)
Of course this raises the question of what is possible with three sets (or a 3-enum (3-num?)). More on this in another post.
Post a Comment