Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site munnari.SUN Path: utzoo!linus!decvax!mulga!munnari!lee From: lee@munnari.SUN (Lee Naish) Newsgroups: net.lang.prolog Subject: Re: Marcel's Dilemma Message-ID: <120@munnari.SUN> Date: Mon, 30-Jan-84 16:14:13 EST Article-I.D.: munnari.120 Posted: Mon Jan 30 16:14:13 1984 Date-Received: Sun, 5-Feb-84 04:30:06 EST References: <15320@sri-arpa.UUCP>, <149@csd1.UUCP> Organization: Comp Sci, Melbourne Uni, Australia Lines: 54 I'm sure everyone is as tired of this problem as I am, but I wont be able to sleep until the REAL solution is given. Remember the axioms were (1) a is on or b is on (2) if a is on then b is off (3) a and b are both on or off The mistake has been to formalize this in terms of a predicate on(X), as Michael Condict (and others) did: (1) on(a) or on(b) (2) on(a) implies not on(b) (3) for all x, on(x) or not on(x) There are two solution to these axioms: {on(a)} and {on(b)}. These are two different predicates, not two solutions to the same predicate ({on(a), on(b)}. Therefore we cant use first order logic for this statement of the problem. Later in Micheal's follow up, he stated that there is one relation which satisfies the axioms: "the relation R such that xRy iff x is the logical negation of y." Note that this relation has two arguments, each having the domain {on, off}. This is the right way to do it. My original solution (in MU-Prolog) follows: % Here's my first (logical, rather than efficient) switches program. % To find the valid configurations, use the goal ?- config(A, B). % The logic should be quite clear - the only possibly confusing bit is % the if construct. This is available in MU-PROLOG, and is implemented % soundly. The DEC-10 counterpart, ->, would work if cond2 was executed % last (the evaluation of MU-PROLOG's if is delayed until the condition is % ground, but this does not occur in DEC-10). % % Lee Naish % (decvax!mulga!lee) config(A, B) :- cond1(A, B), cond2(A, B), cond3(A, B). cond1(on, _). cond1(_, on). cond2(A, B) :- if A = on then B = off. cond3(A, B) :- on_or_off(A), on_or_off(B). on_or_off(on). on_or_off(off).