Can we do this with ancestral cuts or something?

Liste des GroupesRevenir à cl prolog 
Sujet : Can we do this with ancestral cuts or something?
De : julio (at) *nospam* diegidio.name (Julio Di Egidio)
Groupes : comp.lang.prolog
Date : 09. Dec 2024, 14:35:20
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vj6rmq$clr4$1@dont-email.me>
User-Agent : Mozilla Thunderbird
Given a list of goals representing a conjunction, I would like it to fail as soon as any goal fails, but I would like *not* to cut on the search space otherwise.
Here is my actual test case, only considering ground goals (otherwise too many ways to play with it that seem immaterial to the problem):
```
red(1).
red(1).
and([]) :- !.  % with Xs ground!
and([H:B|Xs]) :-
red(B), writeln(H:B),
and(Xs).
/*
Actual:
-------
?- and([x:1,y:1]), fail.  % ok: full search space
x:1
y:1
y:1
x:1
y:1
y:1
false.
?- and([x:1,y:0]), fail.  % KO: could fail earlier
x:1
x:1
false.
Expected:
---------
?- and([x:1,y:0]), fail.  % ok: fails early!
x:1
false.
*/
```
Am I just missing something obvious?  I am trying with "ancestral cuts" (SWI-Prolog has these), but I have not yet found a solution.
-Julio

Date Sujet#  Auteur
9 Dec 24 * Can we do this with ancestral cuts or something?11Julio Di Egidio
9 Dec 24 `* Re: Can we do this with ancestral cuts or something?10Mild Shock
9 Dec 24  +* '$MARK' and '$CUT' (Was: Can we do this with ancestral cuts or something?)2Mild Shock
9 Dec 24  i`- Re: '$MARK' and '$CUT' (Was: Can we do this with ancestral cuts or something?)1Julio Di Egidio
9 Dec 24  `* Re: Can we do this with ancestral cuts or something?7Julio Di Egidio
9 Dec 24   +* Re: Can we do this with ancestral cuts or something?2Julio Di Egidio
9 Dec 24   i`- Re: Can we do this with ancestral cuts or something?1Julio Di Egidio
9 Dec 24   `* Re: Can we do this with ancestral cuts or something?4Julio Di Egidio
9 Dec 24    `* A Timeless Confluence [Term Rewriting] (Was: Can we do this with ancestral cuts or something?)3Mild Shock
9 Dec 24     `* Re: A Timeless Confluence [Term Rewriting] (Was: Can we do this with ancestral cuts or something?)2Mild Shock
9 Dec 24      `- Re: A Timeless Confluence [Term Rewriting] (Was: Can we do this with ancestral cuts or something?)1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal