This allows you to extract large church numbers from abstract's algorithm. It is just a very efficient implementation of natToBinary : Nat -> Bits
.
U= x.(x x)
8= s.z.(s (s (s (s (s (s (s (s z))))))))
19= s.z.(s (s (s (s (s (s (s (s (s (s (s (s (s (s (s (s (s (s (s z)))))))))))))))))))
succ=
(U r.x.a.b.(x b x.(a (r r x))))
zero=
(U r.a.b.(a (r r)))
peek= n.x.(n
t.(t x.(x
x.r.t.(t x a.b.c.(r a b (a c)))
x.r.t.(t x a.b.c.(r a b (b c)))))
t.(t x a.b.c.c)
x.r.r)
extract= bitCount. nat. (peek bitCount (nat succ zero))
(extract 8 (19 19))
Here, (extract bitCount nat)
gets the bitCount
first bits of nat
, which can be a large number. On this example I extracted the first 8 bits of 19^19
(which is about 2^24, so obviously way too large). This costs about 1m rewrites.
It works:
Thanks!