Re: Can we do this with ancestral cuts or something?

Liste des GroupesRevenir à cl prolog 
Sujet : Re: Can we do this with ancestral cuts or something?
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 09. Dec 2024, 15:14:50
Autres entêtes
Message-ID : <vj6u0o$l219$1@solani.org>
References : 1
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
First create a conjunction:
    A1,...,An
Wrap each goal Aj into a soft cut:
   (Aj *-> true; !).
The cut will abort all previous goals.
Julio Di Egidio schrieb:
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