This article is from the Puzzles FAQ, by Chris Cole chris@questrel.questrel.com and Matthew Daly mwdaly@pobox.com with numerous contributions by others.
In first-order logic, find a predicate P(x) which means "x is a power of 10."
logic/hofstadter.s
Well, one summer, I decided to tackle the problem. Not having any great
knowledge of number theory, I used a more brute force approach. Note
that for greater comprehensibility, I have broken the resulting formula
up into several stages, but it would not be difficult to put it
back together into one vast formula:
{e is prime:}
PRIME(e) :=
~Eb:Ec:((b+2)*(c+2) = e)
{if e is a prime, true iff a is a power of e:}
PPOWER(a,e) :=
Ab:Ac:((b*c = a) -> ((b = 1) or (Ed: (e*d) = b)))
{if e is a prime, and a is a power of e, true iff d is the
(log_e a)th digit (counting from the right, starting with 0)
in the base-e expansion of n:}
DIG(a,e,d,n) :=
(d < e) & Eb:Ec:((c < a) & (n = (b*e*a) + (d*a) + c))
{if e is prime, and a is a power of e, true iff n has exactly
(log_e a) digits in its base-e expansion (0 is counted as having 0
digits:}
LENGTH(e,a,n):=
(n < a) & Ab:((PPOWER(b,e) & (b < a)) -> (b <= n))
POWER_OF_TEN(x):=
Ee:(PRIME(e) & (e > x) &
En:Ea:(LENGTH(e,a,n) &
DIG(1,e,1,n) &
Ai:Aj:Au:( (PPOWER(u,e) & ((e*u) < a)
& DIG(u,e,i,n) & DIG(e*u,e,j,n))
-> j = (10 * i) ) &
Eu:(PPOWER(u,e) & (e*u = a) & DIG(u,e,x,n))
) )
 
Continue to: