Path: utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!cmcl2!nrl-cmf!ames!joyce!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Random Clause Selection (was: re:probabilstic or) Keywords: meta interpreter, random, probabilistic, completeness, loops Message-ID: <308@quintus.UUCP> Date: 24 Aug 88 08:53:47 GMT References: <1171@tuhold> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 22 In article <1171@tuhold> thom@tuhold (Thom Fruehwirth) writes: >In <256@quintus.uucp> Richard O'Keefe sketched how to try clauses >in random order: >> >> p(~Args~):- >> random_permutation([1,2,3,4,5,6,7], Perm), >> member(Index, Perm), >> p(Index, ~Args~). > >As Jamie Andrews in <628@etive.ed.ac.uk> pointed out, O'Keefe probably >intended to have a cut between random_permutation/2 and member/2. NO WAY! What would it do? random_permutation/2 generates *ONE* random permutation between its two arguments. This is the only clause of p(~Args~), and random_permutation/2 doesn't leave any choice points, so there is nothing for a cut to do. What this code fragment does is to try the (original) clauses of p in a random order; for that we want *ONE* random permutation. random(-X) generates *ONE* pseudo-random float uniformly distributed between 0.0 and 1.0. You wouldn't expect it to generate another if you backtrack into it. Why should random_permutation/2 be any different?