debray@sbcs.UUCP (Saumya Debray) (01/13/84)
Re: Marcel Schoppers' problem: given two lamps A and B, such that: condition 1) at least one of them is on at any time; and condition 2) if A is on then B id off, we are to enumerate the possible configurations without an exhaustive generate-and-test strategy. ----- The following "pure" Prolog program that will generate the various configurations without exhaustively generating all possible combinations: ----- config(A, B) :- cond1(A, B), cond2(A, B). /* both conditions must hold */ cond1(1, _). /* at least one is on an any time ... condition 1 above */ cond1(_, 1). cond2(1, 0). /* if A is on then B is off */ cond2(0, _). /* if A is off, B's value is a don't care */ ---- executing Prolog gives: | ?- config(A, B). A = 1 B = 0 ; A = 0 B = 1 ; no | ?- halt. [ Prolog execution halted ] ---- Tracing the program shows that the configuration "A=0, B=0" is not generated. This satisfies the "no-exhaustive-listing" criterion. Note that attempting to encode the second condition above using "not" will be both (1) not pure Horn Clause, and (2) using exhaustive generation and filtering. -- Saumya Debray Dept. of Computer Science SUNY at Stony Brook {floyd, bunker, cbosgd, mcvax, cmcl2}!philabs! \ Usenet: sbcs!debray / {allegra, teklabs, hp-pcd, metheus}!ogcvax! CSNet: debray@suny-sbcs@CSNet-Relay