Article View: comp.lang.prolog
Article #39Is (\+)/1 enough for executable specifications?
From: Mild Shock
Date: Tue, 03 Nov 2026 00:28
Date: Tue, 03 Nov 2026 00:28
32 lines
1924 bytes
1924 bytes
Hi,
Using the EyeProlog example code, I get this
result in a ISO compliant Prolog processor.
The predicate turns out to be non-deterministic
operational:
?- normal_form(append(append(append(a,b),c),d), X).
X = append(a, append(b, append(c, d))) ;
X = append(a, append(b, append(c, d))) ;
false.
So normal form has spurious choice points. And
would explode in practice, when deployed as a
normal form routine and when supplied larger terms.
A fix would be:
normal_form(Term, Term) :-
\+ rewrite_once(Term, _, _).
normal_form(Term, Normal) :-
once(rewrite_once(Term, Next, _)),
normal_form(Next, Normal).
But once/1 is not among your list of "by" justifications?
Lean 4 does solve this problem in that already match/with
is deterministic. But Lean 4 can make it declarative
by a recursor / motive translation.
Bye
Technical Details
Message-ID:
<11cb9rh$ssq2$1@solani.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!weretis.net!feeder8.news.weretis.net!reader5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Mild Shock <janburse@fastmail.fm> Newsgroups: comp.lang.prolog Subject: Is (\+)/1 enough for executable specifications? Date: Tue, 3 Nov 2026 01:28:33 +0100 Message-ID: <11cb9rh$ssq2$1@solani.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 3 Nov 2026 00:28:33 -0000 (UTC) Injection-Info: solani.org; logging-data="947010"; mail-complaints-to="abuse@news.solani.org" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0 SeaMonkey/2.53.24 Cancel-Lock: sha1:8tCf48VeLmmePEGaFv74HZcOV5E= X-User-ID: eJwFwYcBwDAIA7CXGoaJz2GE/0+o5IqDDoPDfH1DRqT7ZjWWwMPl4oSxLetMvkR38JYydEikz6cpS63H+QFk4hYW X-Mozilla-News-Host: news://news.solani.org:119