by defen · 17y ago · 0 comments
Some finite examples of addition (again, wiki has a better explanation of the rules than I could give b/c they can use math symbols http://en.wikipedia.org/wiki/Surreal_numbers#Addition):
{|} + {|} = {|} == 0 + 0 = 0 (zero has the empty set on both sides; everything is built from this)
{|} + {{ | } | } = {{ | } | } == 0 + 1 = 1
{{ | } | } + {|} = {{ | } | } == 1 + 0 = 1
{{ | } | } + {{ | } | } = {{{ | } | }, {{ | } | } | } == 1 + 1 = 2
{{{ | } | }, {{ | } | } | } + {{ | } | } = {{{{ | } | }, {{ | } | } | }, {{{ | } | }, {{ | } | } | }, {{{ | } | }, {{ | } | } | } | } == 2 + 1 = 3
As you can see, the "long" forms of surreal numbers quickly become unwieldy, which is why people use roman numerals to describe surreal numbers with the same properties as the corresponding real. When dealing with transfinite numbers it's not possible to use the long form. (And yes, I wrote a program to generate those sums for me. No way I'm doing that by hand!)
It's part of a game (in the Conway sense) framework I wrote up when I was learning about surreal numbers. Games are an even more general construct, where the left side is not required to be 'less than' the right side. Anyway, to use it, fire up GHCi and `:l game`. I've pre-defined -1, 0, and 1, but you can theoretically create any number with a finite representation (of course, the data structure and algorithms used are deliberately naive and incredibly inefficient and slow, so don't try anything crazy). For example, 5+3 requires 1156 characters to display, 5+4 requires 2556, and 5+5 requires 5118. This is because my code doesn't attempt to "reduce" any of the numbers - numbers can have multiple representations, and with finite representations you can just take the largest element of the left set and the smallest element of the right set and get the same number. My code doesn't do that. Anyway, there's also a fromInteger definition so you can mix Numbers and integers in computations.
Examples:
Prelude> :l game
[1 of 1] Compiling Game ( game.hs, interpreted )
Ok, modules loaded: Game.
*Game> zero
{ | }
*Game> 5 :: Game
{{{{{{ | } | } | } | } | } | }
*Game> let half = Game [zero] [one]
*Game> half
{{ | } | {{ | } | }}
*Game> half < one
True
*Game> half > 1
False
*Game> half + half == 1
True
*Game> half * 1 == half
True
*Game> half * (one + one) > 1
False
The best resources for learning are both by Conway: "Winning Ways for your Mathematical Plays" (WW) and "On Numbers and Games" (ONAG). WW is more accessible and introduces you to numbers via games, whereas ONAG is more of a hard-core math book that explains games via numbers. WW is probably better if you don't have a strong math background, ONAG if you do.