Question
Start this Prolog assignment by entering the following five facts and two in-rules into your Prolog engine inFact(bangor,penobscotCounty). inFact(portland,cumberlandCounty). inFact(penobscotCounty,maine). inFact(cumberlandCounty,maine). inFact(maine,newEngland). contains(A,B):-inFact(B,A). contains(A,B):-inFact(C,A),contains(C,B). 6
Start this Prolog assignment by entering the following five facts and two in-rules into your Prolog engine
inFact(bangor,penobscotCounty).
inFact(portland,cumberlandCounty).
inFact(penobscotCounty,maine).
inFact(cumberlandCounty,maine).
inFact(maine,newEngland).
contains(A,B):-inFact(B,A).
contains(A,B):-inFact(C,A),contains(C,B).
6 . Use your in rule to determine all items that are in orono . Briefly explain the query result.
7 . Write a query to determine in what items is orono .
8 . Extend your facts by adding inFact predicates for another five counties in Maine. Also add inFact predicates for the corresponding county seats. NOTE: A county seat is the city/town where the administrative tasks of the county occur.
9 . Write a query to determine all items that are in mai ne .
10 . In the contains rule (lines 6 and 7 in the facts and rules listed before question 1) , what would happen if you replaced the second predicate contains (A,B) : - inFact ( C,A ), contains ( C,B ). with contains (A,B) : - contains ( C,B ) , inFact ( C,A ). If you cannot find the answer, give it a try by making the change in your Prolog code and then run some of the Queries 1 - 3. What happens? Why? If you made these changes, be sure to revert afterwards to the original. For all rules that you write, use only basic Prolog statements as introduced in class (i.e., only Horn clauses, with each rule having a single consequent predicate and all antecedent predicates linked by commas representing conjunctions. Do not use any oth er syntax, even if Prolog parses and processes it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started