Deutsch English Français Italiano |
<vj6uf8$l2as$1@solani.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!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: '$MARK' and '$CUT' (Was: Can we do this with ancestral cuts or something?) Date: Mon, 9 Dec 2024 15:22:33 +0100 Message-ID: <vj6uf8$l2as$1@solani.org> References: <vj6rmq$clr4$1@dont-email.me> <vj6u0o$l219$1@solani.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 9 Dec 2024 14:22:32 -0000 (UTC) Injection-Info: solani.org; logging-data="690524"; mail-complaints-to="abuse@news.solani.org" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19 Cancel-Lock: sha1:qQYRj2bNfBJFcH0H3kDxdQpzZZc= X-User-ID: eJwNxMEBwCAIA8CVQEzQcTDK/iO09zgEncpJcKLRdjPIrHQi4HYG/mW7bcikhJ/7SorNd14seNdZN0Klyf4AL8gVeQ== In-Reply-To: <vj6u0o$l219$1@solani.org> Bytes: 2780 Lines: 85 Or use Dogelog Player: /* Dogelog Player */ '$MARK'(CP) : Get a choicen point. '$CUT'(CP) : Cut to a choice point. But I don't have soft cut. But you can do ancestral cut with it. SWI-Prolog has something similar burried somewhere, they are called: /* SWI-Prolog */ prolog_current_choice(CP) : Get a choicen point prolog_cut_to(CP) : Cut to a choice point See also, the pair is used here: '$meta_call'(:Goal) https://github.com/SWI-Prolog/swipl-devel/blob/master/boot/init.pl Mild Shock schrieb: > 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 >