🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #2710

Prolog riddle - (nf)

#2710
From: noekel
Date: Thu, 09 Jul 1987 15:50
30 lines
1644 bytes
Hi,

does anyone out there in netland know whether it is possible to write a Prolog
program that 

(1) *generates* natural numbers in ascending order,
(2) does not make use of side effects (assert, retract etc.),
(3) generates the first n numbers in time O(n).

The toplevel predicate should be nat(X), which is of course invoked with X
uninstantiated. Any number of additional predicates are admitted. Note that
the program should be self-contained, i.e. I'm not interested in programs
like

	next_nat(X,Y) :- Y is X+1.

which leave it to the responsibiliy of the calling program to "conserve" the
last number generated until the time the next number is needed.

Be warned that complexity can creep in through your backdoor - especially if
you use many auxiliary predicates. The number of exits and redos and the number
of variable renamings needed to get at the next number deep within a recursion
also take time and count therefore!

Alternatively I would very much appreciate a negative result - preferably in
the form of a proof.

Please, post your contributions to this notes group or mail to:

UUCP: ...!mcvax!unido!uklirb!noekel
Technical Details
Message-ID: <29400001@uklirb.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!mcvax!unido!uklirb!noekel

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!mcvax!unido!uklirb!noekel
From: noekel@uklirb.UUCP
Newsgroups: comp.lang.prolog
Subject: Prolog riddle - (nf)
Message-ID: <29400001@uklirb.UUCP>
Date: Thu, 9-Jul-87 11:50:00 EDT
Article-I.D.: uklirb.29400001
Posted: Thu Jul  9 11:50:00 1987
Date-Received: Sun, 12-Jul-87 14:02:02 EDT
Lines: 30
Nf-ID: #N:uklirb:29400001:000:1139
Nf-From: uklirb!noekel    Jul  9 16:50:00 1987