There are a loy of notions of “number” Some embed inside each other. It is interesting to see how to implement their representation in computers and how to actually evaluate their arithemtic / normalize them


Stern Brocot binary search mediant (a + c)/(b + d) is between a/b and c/d. vector addition on ration representation Is it a game? Is this dstint from continued fractions? clock making and stern brocot

class SternBrocot():
  def __init__(self,x):
    a = Fraction(0,1)
    b = Fraction(1,1)
    self.dirs = [] # stern brocot represents fraction as sequence of L/R
    while num / den != a / b:
      if x < mediant
        a = c
        b = d
      elif x > mediant:
        a = c
        b = d

continued fractins - Adding? Do I have t go down and then up? A “lens” into the whole and fractional part? lanczos algorithm is best ratinal approximatin to eigenvalues? Computational Linear algebra over infinite vectors. What can be done? Can invert triangular matrices. Can of course take increasing finite slices. increasing low rank update?

best ratinal apporxmation


Ordinals notations are lik systemaic ways of labelling ordinals. They don’t described every posible ordinal.

Ordinals are a generalizatin of numbrs

Countable ordinals. 1 …. omega is countabe. 0 -> omega, 1 -> 0, 2 -> 1 … is an enemeration. It isn’t an order repsecting enumeration though. So “infinite” numbers can be finitely represented. type omega_plus_1 = Omega | Fin of nat. We are used to this from floats for example So polynomials of omega is maybe a first place to state. Those are implementable as typical lists of coefficients. They have funky addition and mult properties (funky mult happens in matrices and quaternions, but noncommutative addition is more unusual). But then ordinals typically allow going up to new stuff (exponentiation and beyond). algorithms for ordinal arithemtic. ACL2 Ordinal arithmetic with list structures dershowitz reingold

Termination as mapping into ordinals. Measure is the map. Simple ones into integers. Lexicographic and w^n lists as foundation of mathematics. Three equivalent ordinal notation systems in cubical Agda Implementation of three types of ordinals in Coq

(* cons(a,n,b) = w^a(n + 1) + b  *)
Inductive T1 : Set :=
zero : T1
| cons : T1 -> nat -> T1 -> T1 sympy issue on ordinal arithmetic

from sympy.sets.ordinals import *
w = omega
z = ord0
print(3 + w + 2 * w)
print(2 * w) pip instal transfinite python package

# notebook
from transfinite import w, factors
print(w*w + 1)
print(1 + w)
print(dir(w)) # addend', 'coefficient', 'exponent', 'is_delta', 'is_gamma', 'is_limit', 'is_prime', 'is_successor'
print(w.is_limit()) # true
print(w.is_delta()) # mutliplicatively indecomposable
print((w + 1).is_limit()) #false
print(w ** w)
print( w <= w)
fs = factors(w*w) 
print(dir(fs)) # as_latex', 'factors', 'ordinals', 'product'

# based in cantor normal form
#          (exponent)
#         ^
#        w . (copies) + (addend)

Prime ordinals and facotring rathjen 2006 Theories and Ordinals in Proof theory Rathjen the art of ordinal analysis book chapter 3 is on ordinals in coq - hydra games. unprovable in peano arith kirby and paris Accessible Independence Results for Peano Arithmetic javascript of the game hydra is kinda remniscent of hackenbush PBS infinite series on hydra game large countable ordinal weak set theory. preciative part. Separation only works on delta_0 bounded formula. I like that wow this a a whole rabbit hole notes on constructive set theory - rathjen aczel

Γ₀ mentined that stuff generalzes this. A power series with fractional powers. a notion of series with domain that is well ordered? contains infintesimal and infinite stuff fixed points of exponential maps

import math
class Rational():
  def __init__(self, numb, den):
    gcd = math.gcd(num,den)
    self.num = num / gcd
    self.den = den / gcd
  def __add__(self, other):
    return Rational(self.num * other.den + other.num * self.den, self.den * other.den)
  def __mul__(self, other):
    return Rational(self.num * other.num, self.den * other.den)
  def __sub__(self, other):
    return Rational(self.num * other.den - other.num * self.den, self.den * other.den)
  def __truediv__(self, other):
    return Rational(self.num * other.den, self.den * other.num)
  def __repr__(self):
    return f"{self.num}/{self.den}"
  def __eq__(self, other):
    # or self.num * other.den == other.num * self.den
    return self.num == other.num and self.den == other.den
  def __lt__(self, other):
    return self.num * other.den < other.num * self.den

def Complex():
    def __init_(self, real, imag):
        self.real = real
        self.imag = imag
    def __add__(self, other):
        return Complex(self.real + other.real, self.imag + other.imag)

def BigNum():
  self __init__(self,n):
    self.digits = []
    while n > 0:
      self.digits.append(n % 10)
      n = n // 10
    def value(self):
      return sum([d * 10 ** i for i, d in enumerate(self.digits)])
  def __add__(self, other):
    # cheating: return BigNum(self.value() + other.value())
    res = []
    carry = 0
    for i in range(max(len(self.digits), len(other.digits))):
      s = self.digits[i] if i < len(self.digits) else 0
      o = other.digits[i] if i < len(other.digits) else 0
      res.append((s + o + carry) % 10)
      carry = (s + o + carry) // 10
  #def __mul__(self,other):
  #  res = BigNum(0)
  #  for i in range(len(self.digits)):
  #    for j in range(len(other.digits)):
  #     res += BigNum(self.digits[i] * other.digits[j]) * BigNum(10 ** (i + j))
  #  return res

class Quaternion():
  def __init__(self, c,i,j,k):
    self.c = c
    self.i = i
    self.j = j
    self.k = k
  def __add__(self, other):
    return Quaternion(self.c + other.c, self.i + other.i, self.j + other.j, self.k + other.k)
  def __mul__(self, other):
    return Quaternion(self.c * other.c - self.i * other.i - self.j * other.j - self.k * other.k,
                      self.c * other.i + self.i * other.c + self.j * other.k - self.k * other.j,
                      self.c * other.j - self.i * other.k + self.j * other.c + self.k * other.i,
                      self.c * other.k + self.i * other.j - self.j * other.i + self.k * other.c)

# Another way of representing fractions that has nice properties.
def ContFrac():
  # this is the euclidean algorithm
  def __init__(self, num,den):
    self.coeff = []
    while num != 0:
      self.coeff.append(num // den)
      num, den = den, num % den

def golden_ratio(): # an irratinal number with infinite expansion 
  while True:
    return 1

# using built in complex and fraction
from fractions import Fraction
print(Fraction(1,10) )
print(1 + 1.j)

# another method, embedding into matrices
import numpy
def complex(r,i):
  return np.array([[r,-i],[i,r]]) abstract based classes for numbers

Large Numbers

name the smallest numnber.

tree(3) graham’s number

Surreal Numbers

HACKENBUSH: a window to a new world of math Owen Maitzen rip.

zero = (None,None)
one = (zero,None)
two = (one,None)
three = (two,None)
neg_one = (None,zero)
neg_two = (None,neg_one)
neg_three = (None,neg_two)

Von Neumann

_univ = 

def internset(x):
  x = frozenset(x)
  if x in _univ:
    return _univ[x]
    _univ[x] = x
    return x
# von neumann
zero = internset([])
def succ()
def univ():
  return internset(_univ)

def pair(a,b):
  return frozenset([a,b])
def order_pair(a,b):
  return frozenset(frozenset({a}), frozenset({a,b}))

# separation axiom
def separate(A, P):
  return frozenset({x for x in A if P(x)})

from itertools import chain, combinations

def powerset(iterable):
  powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
  s = list(iterable)
  return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

# NBG class? == P, just a indicator function.

def surreal(a,b):
  if (a,b) in univ:
    return univ[(a,b)]
    univ[(a,b)] = (a,b)
    return (a,b)
empty = frozenset()
zero = surreal(empty,empty)
one = surreal(frozenset(zero),empty)

class Surreal():
  def __init__(self, a, b):
    self.a = a
    self.b = b
  def __le__(self, other):
    #return self.a <= other.b
  #def __add__(self)

# surreal as pair of game trees
tictactoe = [[],[],[]]

Is there a normal form? That helped ordinals a lot

Hackenbusch Nimbers Combinatorial Game theory Aaron N. Siegel’s “Combinatorial Game Theory

Fraise games. Ehrenfeucht-Fraïssé

{|} sets of available moves. Tic tac toe as a number (“ontinutatons”) So programming languages have game semantics. Could one make a PL game? *, uparrow, double up, eps, omega. * is like a cloud

The game of quantifiers is how we discuss reals. Connection? We are reifying

on off dud oof hi lo These are non well founded? Or just berlekamp videos



Compactness is important here? Huh.


Trying to make infinitesimals rigorous

Rings can have things like eps^2 = 0 by taking quotient rings. Something with R as a subfield.

Constructing a model of hyperreals. Infinite sequences of reals. Quotient by equivlanec e relation of agreeing on cofinite set.

A finite list of disagreement points

equiv(a,b,l) = forall n, a[n] = b[n] | n in l 

More equational than classical presentation?

R is unique complete ordered field. So R*

Transfer principle

Ultrafilter. What is a “large” set?

Ultrafilter as a notion of truth. Relation to topos? Modal logic? Intuitionstic logic?


Internal set theory

Adding a “standard” predicate to set theory. There is a notion of standard elements vs nonstandard elements. This has a connection to standard models of constructions like the reals or naturals, which by the weakness of power of description of first order logic, the axims often allow other models besides the standard one.

This has some flavor of the method of “junk” elements used to model partial functions using total functions as I’ve played around with in category theory.

Nonstandard elements are hard to grasp because whenever you get concrete hold f somthing, it tends (is always?) standard.

I think I’ve seen it mentioned that maybe “standard” is somehow talking about a fluid boundary of described or construct elements. If I keep around an eps smaller than any number I’ve considered so far, and maybe go back and fix it up as I go should I ever bring in anything smaller? I do kind of feel like an approximate equality of finite difference is sufficient

Nonstandard models of peano We can keep adding x > n for any n to the axiom set and stay consistent. The forall n is in the metalogic. By compactness, we can add the forall n into the object logic and stay consistet?

Hypernaturals - a construction of the hypernatural is sequences of naturals identified under a ultrafilter (a “large set”). It’s weird that allowing just a little disagreement helps


Naive Infinitesimals The reals are a subfield of the hyperreals. There exist infinittesimals which are smaller than

The “standard” function behaves like a kind of rounding.

Distincting between equality and approximation equality. a ~ b == st(a) = st(b)

st pushes through regular operations (+, -, …). So it is a homomorphsim of sorts. st(eps) = 0

lim = x ~ c /\ x != c -> lim(t(x)) = t(c) continuity is x ~ y -> f(x) ~ f(y)

Eudoxus Reals

One can imagine nearly linear functions. f(x) = Ax + r(x) where the remainder r(x) is small in some sense. This is a linear approximation done all the time as an expansion. Asymptotically, if r(x) stays bounded, it matters realtively less and less. If there was some cutoff of size in the universe of numbers, some quantum, it doesn’t matter.

In the proof of the irrationality of sqrt 2, one has to somehow refer to “irrationality” and “sqrt 2”. To posit sqrt 2 as an enttity means you’ve already defined the reals. “irrationality” naively means you’ve already defined the rationals.

To cut the knot, you can define the question as the diophantine equation 2n^2 = m^2 does not have natural solutions. We’ve mangled the statement of the theorem to smething recognizable. So we’ve done some metalevel reasoning. This is problematic.

Likewise, there is a way to discuss reals without talking about rationals. IN the Bishop book, a constructive real is a sequence that is converging faster than 1/n more or less. |f(i) - f(j)| <= 1/i + 1/j. Multiplying out, i(f(j)) - f(i)j <= 2(i + j)

Stern Brocot trees and diophantine approximation?