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
Is (\+)/1 enough for executable specifications?
- From
- Mild Shock <janb…@fastmail.fm>
- Message-ID
- <11cb…@solani.org>
- Date
- Newsgroups
- comp.lang.prolog