| Deutsch English Français Italiano |
|
<vj6rmq$clr4$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Julio Di Egidio <julio@diegidio.name> Newsgroups: comp.lang.prolog Subject: Can we do this with ancestral cuts or something? Date: Mon, 9 Dec 2024 14:35:20 +0100 Organization: A noiseless patient Spider Lines: 49 Message-ID: <vj6rmq$clr4$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 09 Dec 2024 14:35:22 +0100 (CET) Injection-Info: dont-email.me; posting-host="7790aa2e18bcf5e7788978594a704952"; logging-data="415588"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX195rqyY8Uje+6HqDtwDtlM/weojfNvDwKA=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:eedCfCDRVU06/DzpC3Gjc4BNvC4= Content-Language: en-GB Bytes: 1769 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