Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!zodiac!joyce!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: Need style advice Message-ID: <170@quintus.UUCP> Date: 15 Jul 88 22:53:51 GMT References: <1988Jul14.231619.22145@cs.rochester.edu> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 40 In article <1988Jul14.231619.22145@cs.rochester.edu> stuart writes: > foo_value(X, value_1) :- forced_to_be_1(X), !. > > foo_value(X, value_2) :- relation_one(X, Y), not(forced_to_be_1(Y)), !. > foo_value(X, value_2) :- relation_two(X, Y), foo_value(Y, value_2), !. > > foo_value(X, value_1) :- relation_one(X, Y), forced_to_be_1(Y), !. > foo_value(X, value_1) :- relation_two(X, Y), foo_value(Y, value_1), !. > > foo_value(X, value_3). > forced_to_be_1/1 is a collection of ground literals. > relation_two/2 contains no cycles. > relation_one/2 and relation_two/2 can satisfy multiple second > arguments for a fully instantiated first argument. Note that the code as written is not steadfast: ?- foo_value(X, value_3). will succeed for ANY value of X, even when forced_to_be_1(X). Remember: a cut at the end of a clause is almost always in the wrong place. Would it be possible for you to tell us what the relation is supposed to _mean_, rather than showing us the current version of the code? For example, the following values for forced_to_be_1/1 and relation_one/2 forced_to_be_1(jim). % "male" forced_to_be_1(tom). relation_one(tom, jim). % "sibling" relation_one(jim, tom). relation_one(tom, mary). ... relation_two(_, _) :- fail. % "parent" appears to satisfy the description given, yet both relation_one(tom, mary), \+forced_to_be_1(mary) and relation_one(tom, jim), forced_to_be_1(jim) are true, so should foo_value(tom, value_2) or foo_value(tom, value_1)? Presumably there is some finite number of Xs which you intend to assign foo_values to. If that number is not too big, why not just write a program to generate the table and write the results to a file, then compile that file?