Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Logic Programming

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29666] Logic Programming
  • From: "Hu Zhe" <huzhe at public3.sta.net.cn>
  • Date: Mon, 2 Jul 2001 02:20:27 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
Prolog and Logic programming is interesting.

The Logic package which implements logic programming in Mathematica is 
also very instructive. (The logic programming package can be downloaded 
from www.mathsource.com )

I tried to use it to solve the "Who drinks milk and who owns the horse" 
problem.
The main obstacle I have got is how to express the statements to the 
computer, especially when the relationships become complex.

Though I can understand I should post this problem to Prolog's 
newsgroup, I believe that Mathematica users are so universe and 
outstanding that someone may help or give some suggestions.

The puzzle was appeared in Trott's article on the Mathematica Journal. 
He solved it using Mathematica. Below is what I copied from his article:

"""
I copied this text from achalfin at netmagic.net. It was discussed in the 
newsgroup comp.soft.sys.mathematica in December 1997.

water.  Then, decide who owns the zebra.

1. There are five houses.

2. The Englishman lives in the red house.

3. The Spaniard owns a dog.

4. Coffee is drunk in the green house.

5. The Ukrainian drinks tea.

6. The green house is immediately to the right of the ivory house.

7. The Old Gold smoker owns snails.

8. Kools are smoked in the yellow house.

9. Milk is drunk in the middle house.

10. The Norwegian lives in the first house.

11. The Chesterfield smoker lives next door to the man with the fox.

12. Kools are smoked in the house next to the house with a horse.

13. The Lucky Strike smoker drinks orange juice.

14. The Japanese smokes Parliaments.

15. The Norwegian lives next door to the blue house.

16. In each house there is one nationality, one pet, one brand of 
cigarette smoked, and one kind of liquid drunk.

"""

So my question is whether it is possible to solve the problem by logic 
programming:

First to express these statements like this:

Knowledge = Statements[
    Lives[Englishman, RedHouse, _],
    Lives[Norwegian, _, 1],
    Owns[Spaniard, Dog],
    Drinks[Ukranian, Tea],
    Smokes[Japanese, Parliaments],
    Lives[_, BlueHouse, 2]]
 .... ....
 ]

Then one can ask the question:
Question[Knowledge, Drinks[X_, Milk], X]
Question[Knowledge, Owns[X_, Horse], X]

Sincerely,
Hu Zhe


  • Prev by Date: Re: Problems with TeX and EPS output (v3.0, mac)
  • Next by Date: Re: Question: How to display matrixes with a tube-defined figure
  • Previous by thread: Re: Problems with TeX and EPS output (v3.0, mac)
  • Next by thread: Re: Logic Programming