[net.lang.prolog] PROLOG Digest V4 #3

PROLOG-REQUEST@SU-SCORE.ARPA (Chuck Restivo, The Moderator) (01/14/86)

PROLOG Digest           Wednesday, 15 Jan 1986      Volume 4 : Issue 3

Today's Topics:
                       Puzzles - NL & Shoppers
----------------------------------------------------------------------

Date: 16 Dec 1985 1833-PST (Monday)
From: Kathy Morris <Morris@su-aimvax.arpa>
Subject: ``natural'' language and prolog

Subject: Re: Boodle Phil moiven?

This appears to be a programming exercise in Prolog.

> Lucy sod'n pho Abner, kips Abner sod'n pho Lucy.

person(lucy).
person(abner).
sodn_pho(X,Y) :- simple_sodn_pho(X,Y).
sodn_pho(X,Y) :- simple_sodn_pho(Y,X).
simple_sodn_pho(lucy,abner).

> Hubert bink ptui Phil, kips Hubert bink ptui Abner.

person(hubert).
person(phil).
bink_ptui(X,Y) :- person(X), person(Y), test_bink_ptui(X,Y).
test_bink_ptui(hubert,phil) :- !.
test_bink_ptui(X,Y) :- nonvar(Y), test_bink_ptui(X,_), !.

> Leonard sod'n pho Phil.

person(leonard).
simple_sodn_pho(leonard,phil).

> Lucy pock matoo Leonard myt Leonard pock matoo Myrtle, kips
> Myrtle moiven  Lucy.  Lucy sod'n pho Hubert myt Myrtle sod'n
> pho Hubert, kips Lucy pock matoo Myrtle.  Leonard moiven
> Hubert myt Hubert bink ptui Phil, kips Leonard moiven Phil.

person(myrtle).
simple_sodn_pho(lucy,hubert).
simple_sodn_pho(myrtle,hubert).

pock_matoo(X,Y) :- person(X), person(Y), test_pock_matoo(X,Y).
test_pock_matoo(lucy,leonard) :- !.
test_pock_matoo(leonard,myrtle) :- !.
test_pock_matoo(X,Y) :- sodn_pho(X,Z), sodn_pho(Y,Z), !.

moiven(X,Y) :- person(X), person(Y), test_moiven(X,Y,[Y]).
test_moiven(leonard,hubert,_) :- !.
test_moiven(X,Y,_) :- pock_matoo(Y,Z), pock_matoo(Z,X), !.
test_moiven(X,Y,P) :- bink_ptui(Z,Y),
                      not(member(Z,P)),
                      test_moiven(X,Z,[Z|P]),
                      !.

member(X,[X|_]).
member(X,[_|Y]) :- member(X,Y).

> Kips, boodle Phil moiven?

?- moiven(phil,X).

X = phil ;

no

--------------------------------------------------------------

Kips, Phil moiven nar Phil.  [The answer.]

"When I use a word," Humpty Dumpty said, in a rather scornful
tone, "it means just what I choose it to mean -- neither more
nor less."

The database, in somewhat cleaner form:
--------------------------------------------------------------

person(lucy).
person(abner).
person(hubert).
person(phil).
person(leonard).
person(myrtle).

sodn_pho(X,Y) :- simple_sodn_pho(X,Y).
sodn_pho(X,Y) :- simple_sodn_pho(Y,X).

simple_sodn_pho(lucy,abner).
simple_sodn_pho(leonard,phil).
simple_sodn_pho(lucy,hubert).
simple_sodn_pho(myrtle,hubert).

bink_ptui(X,Y) :- person(X), person(Y), test_bink_ptui(X,Y).
test_bink_ptui(hubert,phil) :- !.
test_bink_ptui(X,Y) :- nonvar(Y), test_bink_ptui(X,_), !.

pock_matoo(X,Y) :- person(X), person(Y), test_pock_matoo(X,Y).
test_pock_matoo(lucy,leonard) :- !.
test_pock_matoo(leonard,myrtle) :- !.
test_pock_matoo(X,Y) :- sodn_pho(X,Z), sodn_pho(Y,Z), !.

moiven(X,Y) :- person(X), person(Y), test_moiven(X,Y,[Y]).
test_moiven(leonard,hubert,_) :- !.
test_moiven(X,Y,_) :- pock_matoo(Y,Z), pock_matoo(Z,X), !.
test_moiven(X,Y,P) :- bink_ptui(Z,Y),
                      not(member(Z,P)),
                      test_moiven(X,Z,[Z|P]),
                      !.

member(X,[X|_]).
member(X,[_|Y]) :- member(X,Y).

-- Dave Seaman

------------------------------

Date: Fri 10 Jan 86 18:03:31-EST
From: Paul G. Weiss <PGW@XX.LCS.MIT.EDU>
Subject: Puzzle

Dear Puzzle Fans:

The following puzzle appeared in a Filene's Department Store circular.
It was a contest whose deadline has unfortunately passed, but which
is still challenging.  I tried to solve it in a ZEBRA-like fashion
and was not  successful.  Any takers?

Text of Puzzle:

Christmas was one short month away, and Filene's was crowded with
holiday shoppers.  The throngs moved quickly, however, and the vivid
decorations and festivities added a cheerful air.  Among the shoppers
on one snowy Saturday morning were members of December 25, a Christmas
shoppers' club of 12 married couples.  A Sales Associate waited on all
12 couples consecutively, as they bought a total of 8 each of the
following items:

        1. Aris Gloves
        2. Airplane Book
        3. COCO Perfume
        4. Pearl Strands
        5. A Football Sweater
        6. A Handbag

Each husband and wife were waited on together.  Each couple bought
4 items.  No two couples bought the same combination of items, and
none of the couples bought two or more of the same item.  Using the
following clues, can you determine:

        1. The full name of each husband and wife.
        2. What order they were waited on.
        3. What items each couple bought.

CLUES:

Hint: One husband is Bob, one wife is Elizabeth, and one surname
is Stanton.

1. The Craigs, who bought a handbag, were waited on before the
Murphys, who were not waited on last.

2. The Collins bought Aris gloves, a sweater, and handbag, and
COCO.

3. The couples waited on 8th and 10th bought the Airplane Book.

4. These five couples were waited on consecutively:  the Smiths;
Gary and his wife;  a couple who bought the Airplane Book and a
handbag;  the Swains;  and Bill and his wife.

5. Geraldine and her husband did not buy either a handbag or a
sweater.

6. The couple who were waited on last did not buy pearls.

7. One of the items Tom and his wife bought was the Airplane Book.

8. The Marshalls did not buy COCO or pearls.

9. Evelyn and her husband bought Aris gloves but not COCO.

10. These five couples were waited on consecutively:  Martha and
her husband;  Jack and his wife;  the couple who bought Aris gloves,
COCO, the Airplane Book, and a handbag;  the couple who did not buy
either pearls or the Airplane Book; and Margaret and her husband.

11. The first five couples waited on all bought COCO.

12. Chuck and his wife did not buy Aris gloves.

13. The couples waited on first, second, and fourth did not buy
a sweater.

14. Eleanor and her husband did not buy COCO.

15. Neither Allen and his wife, who did not buy a handbag, nor
the Anthonys bought Aris gloves.

16. Cheryl and her husband, who were not waited on 10th or 12th,
and John and his wife are two couples who bought both a sweater
and a handbag.

17. The Douglases, who did not buy Aris gloves or a sweater, were
waited on 9th.

18. Adam and his wife, who did not buy a handbag, were waited on
immediately before the Days.

19. Steve and his wife bought pearls, the Airplane Book, a sweater,
and one other item.

20. The last three couples waited on did not buy Aris gloves.

21. The Joneses did not buy a sweater.

22. Susan and her husband bought pearls.

23. George and his wife bought a sweater.

24. The four couples who did not buy Aris gloves are (in no particular
order): Dorothy and her husband;  the Craigs;  Joe and his wife;  and
Rosalyn and her husband (who did not buy a sweater).

25. The O'Connors bought both COCO and a sweater.

26. Sandra and her husband, who did not buy a sweater, were waited on
immediately before Cathleen and her husband.


Logic Problem courtesy of your friends at Dell ... the Puzzle People!

------------------------------

End of PROLOG Digest
********************