How will you represent following programs in Prolog? 1.If John feels hungry, the
ID: 3719794 • Letter: H
Question
How will you represent following programs in Prolog?
1.If John feels hungry, then he eats quickly. If he eats quickly, he gets heartburn. If he gets heartburn, he takes medicine. John feels hungry. Write rules and solve what will be the answer to this query takes(John, medicine).
2.John is dating Nancy, but right now he is wondering if he must leave the country. Now John will take a vacation in either of two circumstances: if the IRS is after him, or if he is doomed. He is also dating Susan. If he is dating both of them, then Nancy knows this. Now John is in fact doomed if both Nancy and Susan know he is dating both of them. If John will take a vacation, then he must leave the country. So must John leave the country?
Explanation / Answer
1.If John feels hungry, then he eats quickly. If he eats quickly, he gets heartburn. If he gets heartburn, he takes medicine. John feels hungry. Write rules and solve what will be the answer to this query takes(John, medicine)
Answer:
give Prolog the following facts:
ask Prolog "takes(john,medicine)." the answer should be "yes"
2.John is dating Nancy, but right now he is wondering if he must leave the country. Now John will take a vacation in either of two circumstances: if the IRS is after him, or if he is doomed. He is also dating Susan. If he is dating both of them, then Nancy knows this. Now John is in fact doomed if both Nancy and Susan know he is dating both of them. If John will take a vacation, then he must leave the country. So must John leave the country?
Answer:
give Prolog the following facts:
ask Prolog "leaves(john,country)." the answer should be "no" because the computer hasn't been told that Susan knows that John is dating both Nancy and Susan, and so it interprets this statement as false (unproved) and so the inference doesn't go through.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.