Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cmcl2!lanl!opus!ted From: ted@nmsu.edu (Ted Dunning) Newsgroups: comp.lang.prolog Subject: Re: non-sequential recursion Message-ID: Date: 11 Nov 89 04:25:45 GMT References: <1593@aipna.ed.ac.uk> Sender: news@nmsu.edu Distribution: comp Organization: NMSU Computer Science Lines: 50 In-reply-to: cam@aipna.ed.ac.uk's message of 8 Nov 89 17:03:02 GMT In article <1593@aipna.ed.ac.uk> cam@aipna.ed.ac.uk (Chris Malcolm) writes: Path: opus!lanl!cmcl2!nrl-cmf!think!ames!claris!apple!usc!cs.utexas.edu!uunet!mcsun!ukc!edcastle!aipna!cam From: cam@aipna.ed.ac.uk (Chris Malcolm) Newsgroups: comp.lang.prolog Date: 8 Nov 89 17:03:02 GMT References: Reply-To: cam@aipna.ed.ac.uk (Chris Malcolm) Distribution: comp Organization: Dept of AI, Edinburgh University, UK. Lines: 51 [Apologies if you've seen this before -- I suffer from whimsical network connections.] In article eiverson@nmsu.edu (Eric Iverson) writes: >This may be a baby problem, but here goes: Is there any possible way >to skip levels while backtracking? By this I mean that if I run into >a problem at level 4 and realize that level 2 is causing the problem, >is there anyway that I can go directly to level 2 without having level >3 exhaustively fail first? A very interesting question. There are lots of different ways of doing it. When I was faced with this problem (in a robot assembly planner) a crucial requirement of the implementation was that it be FAST, which unfortunately ruled out - so I concluded - any elegant solutions. ... not so firmly, if you have some special help. prolog dialects such as sicstus and nu allow a goal to be frozen pending the instantiation of a variable. this facility can be used to implement a sort of instantaneous failure on a higher level at the cost of handing the variable to be instantiated down to the descendants. for example, parent :- set_failure_point(X), first_child(X), write(didnt_backtrack),nl. parent :- write(back_tracked), nl. first_child(X) :- second_child(X). second_child(X) :- write(deep), nl, cause_failure(X), write(not_here), nl. set_failure_point(X) :- freeze(X,X=1). cause_failure(2).