🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #44

What would Robert Stärk say? [Have Fun!] (Was: Is (\+)/1 enough for executable specifications?)

#44
From: Mild Shock
Date: Tue, 03 Nov 2026 14:59
82 lines
3644 bytes
Hi,

Well the interesting part of the normal_form/2
predicate, is also that negation as failure is
not called with a ground goal argument, so the
example leans out of the framework

of SLDNF, where \+ G are supposed to have G ground
at runtime. If it were ground, as a next step in
some Datalog frameworks it can then indeed be
interpreted as absence of a fact or

derived fact, due to negation stratification. But
Robert Stärk already observed that the two extra
variables _and _, in the call, make it basically
asking a not exists query,

and therefore the justifiation is not only
absence but rather the proof tree of a finite
failure. But if we look at the example it is also
not stead fast, an input 2nd argument

my divert the derivation, and last but not least
rewrite_once is left recursive, and has an infinite
answer set, i.e. all normal terms. One might wonder
whether Robert Stärk left academia back then,

because such a large number of problems is just too
much for a Human. Just joking. The resilient Prologer
might also see it as the birth place of cuts, since
an alternative formulation often

found in the wild would be:

normal_form(Term, Normal) :-
      rewrite_once(Term, Next, _), !,
      normal_form(Next, Normal).
normal_form(Term, Term).

Its even steadfast now in the 2nd argument, and
calls rewrite_once/3 not in two different places,
but only in one place, giving yet anoter inch
more performance.

Have Fun!

Bye

Mild Shock schrieb:
> 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: <11ccssl$u1mc$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-mail
References: <11cb9rh$ssq2$1@solani.org>

Show 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: What would Robert Stärk say? [Have Fun!] (Was: Is (\+)/1 enough for executable specifications?)
Date: Tue, 3 Nov 2026 15:59:33 +0100
Message-ID: <11ccssl$u1mc$1@solani.org>
References: <11cb9rh$ssq2$1@solani.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 3 Nov 2026 14:59:33 -0000 (UTC)
Injection-Info: solani.org;
	logging-data="984780"; 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:M4mk3N8lI0GKxSoyR5KEEbzqYNI=
In-Reply-To: <11cb9rh$ssq2$1@solani.org>
X-User-ID: eJwFwYEBwCAIA7CXrNCi5zCB/09YQhP0wkU5h7N4HzVgJ/AdHYtm7uNYBaVtyF953YTlWM9kR6zR7VfV/gM83xXB