Surreal numbers do not have many practical applications but they are fun.
Donald Knuth's light novel Surreal Numbers is probably the most recreative introduction. Here's the definition carved on the black stone:
In the beginning, everything was void, and J.H.W.H. Conway began to create numbers. Conway said, "Let there be two rules which bring forth all numbers large and small. This shall be the first rule: Every number corresponds to two sets of previously created numbers, such that no member of the left set is greater than or equal to any member of the right set. And the second rule shall be this: One number is less than or equal to another number if and only if no member of the first number's left set is greater than or equal to the second number, and no member of the second number's right set is less than or equal to the first number." And Conway examined these two rules he had made, and behold! They were very good.
And the first number was created from the void left set and void right set. Conway called this number "zero," and said that it shall be a sign to separate positive numbers from negative numbers. Conway proved that zero was less than or equal to zero, and he saw that it was good. And the evening and the morning were the day of zero.
On the next day, two more numbers were created, one with zero as its left set and one with zero as is right set. And Conway called the former number "one," and the latter he called "minus one." And he proved that minus one is less than but not equal to zero and zero is less than but not equal to one. And the evening ...
>>2
The book is here but don't tell anyone (Surreal numbers: how two ex-students turned on to pure mathematics and found total happiness : a mathematical novelette)
http://gen.lib.rus.ec/book/index.php?md5=17D4C2A750FF8076C62BC96AB1E30202
For a more formal introduction, read this pdf: https://web.archive.org/web/20151121050005/http://www.tondering.dk/download/sur16.pdf
;;; Surreal Numbers Datatype
;;; This code is written by Joshua Herman and placed in the Public
;;; Domain. All warranties are disclaimed.
;;; Requires SRFI-9
;;;Some Helper functions
(define (nullset? x)
(equal? x '(0)))
(define (set? lat)
(letrec
((S (cond
((null? lat) #t)
((member? (car lat) (cdr lat)) #f)
(else (set? (cdr lat)))))
(member? (cond
((null? lat) #f)
(else (or (equal? (car lat) a)
(member? a (cdr lat)))))))))
(define (setcmp-f? test? lat1 lat2)
(cond
((or (null? lat1)
(null? lat2)) #t)
((or (not (null? (car lat1)))
(not (null? (car lat1))))
(test? (car lat1)
(car lat2)))
(else (set-cmp-f? test? (cdr lat1) (cdr lat2)))))
(define (member>=? xl xr)
(setcmp-f? >= xl xr))
(define (union set1 set2)
(cond
((null? set1) set2)
((member? (car set1)
set2)
(union (cdr set1)
set2)
(else (cons (car set1)
(union (cdr set1)
set2))))))
(define first$ car)
(define (build s1 s2)
(cons s1
(cons s2 '())))
(define second$ (lambda (str) ((second str))))
(define str-maker
(lambda (next n)
(build n (lambda ()
(str-maker next (next n))))))
(define frontier
(lambda (str n)
(cond
((zero? n) '())
(else (cons (first$ str)
(frontier (second$ str)
(- n 1)))))))
;;;Surreal Number Code Starts Here
;Surreal numbers are defined as follows.
;Given a Surreal Number X = (xl, xr)
;where XL and XR are sets.
;∀ xl ∈ L ∀ xr ∈ R : ¬(xl ≤ xr).
;For exlample {(0) |(0)} == 0 == { | } |#
(define-record-type :surreal-number
(make-surreal l r)
surreal-number?
(l left-side)
(r right-side))
(define (well-formed? surreal-number)
(and
(set? (l surreal-number))
(set? (x surreal-number))
(not (member=>? (l surreal-number)
(r surreal-number)))))
(define (create-surreal-number l r)
(if (well-formed? l r)
(make-surreal l r)
(display "Error in XL/XR Check Input")))
(define zero (create-surreal-number '(0) '(0)))
(define (pretty-print-surreal surreal-number)
(display "(") (display (l surreal-number))
(display ",") (display (r surreal-number)) (display ")"))
(define (display x)
(if (surreal? x)
(pretty-print-surreal x)
(display x)))
(define (surreal-dydactic-function a b)
(/ a (expt 2 b)))
(define (Surreal+1 surreal-number)
(make-surreal
(surreal-dydactic-function (xl surreal-number)
(xr surreal-number))))
(define (+/-one? side)
(and (nullset? (car side)) (nullset? (cadr side))))
(define (value surreal-number)
(+ (addvec (xl surreal-number))
(addvec (xr surreal-number))))
(define (add-surreal surreal-number1 surreal-number2)
(make-surreal
(union (xl surreal-number1)
(xl surreal-number2))
(union (xr surreal-number1)
(xr surreal-number 2))))
;;;Finite enumeration is done by streams
(define surreal-number-set+
(str-maker surreal+1 zero))
(define surreal-number-set-
(str-maker surreal-1 zero))
(define surreal+1)
;;Stream Definitions
;;Example
;;(define int (str-maker add1 0))
;; (define (add1 n)
;; (+ 1 n))
;; (define odd
;; (str-maker (lambda (n)
;; (+ 2 n)) -1))
;; (define Q
;; (lambda (str n)
;; (cond
;; ((zero? (remainder (first$ str) n))
;; (Q (second$ str) n))
;; (else (build
;; (first$ str)
;; (lambda ()
;; (Q (second$ str) n)))))))
;; (define P
;; (lambda (str)
;; (build (first$ str)
;; (lambda ()
;; P (Q str (first$ str))))))