Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

//***CODE THIS PRO-LOG PROGRAMMING LANGUAGE***// //*** IT\'S VERY LESS CODE BUT

ID: 3856104 • Letter: #

Question

//***CODE THIS PRO-LOG PROGRAMMING LANGUAGE***//

//*** IT'S VERY LESS CODE BUT YOU SHOULD USE ONLY PRO-LOG PROGRAMMING PLEASE DON'T GIVE ANSWERS IN OTHER PROGRAMMING LANGUAGES***//

A map maker is making a map which will include the states of Arkansas, Louisiana, Tennessee, Mississippi, & Alabama. The map maker only has 3 colors to use and no two states which share a border can be colored the same color. Write a program which finds an acceptable assignment of colors to states. Write a Prolog program states/5 which finds an acceptable assignment of colors to the 5 states above states without using a graph as the underlying data structure.

Explanation / Answer

love_compatible(X, Y) :- likes(X, Y), likes(Y, X).
X = Arkansas,
Y = Louisiana
X = Arkansas,
Y = Louisiana ; /* typing semicolon causes Prolog to find the next match */
X = Arkansas,
Y = Louisiana.
likes(Tennessee,Mississippi).
likes(Mississippi,Alabama).
likes(Arkansas,Louisiana,).
likes(Louisiana,Arkansas,).
love_compatible(X, Y) :- likes(X, Y), likes (Y, X).
germany(BW, BY) :- neighbor(BW, BY).
germany(BW, BY, SL, RP, HE) :- neighbor(BW, BY), neighbor(BW, RP), neighbor(BW, HE).
When we add in all adjacencies we have

germany(SH, MV, HH, HB, NI, ST, BE, BB, SN, NW, HE, TH, RP, SL, BW, BY) :-
neighbor(SH, NI), neighbor(SH, HH), neighbor(SH, MV),
neighbor(HH, NI),
neighbor(MV, NI), neighbor(MV, BB),
neighbor(NI, HB), neighbor(NI, BB), neighbor(NI, ST), neighbor(NI, TH),
neighbor(NI, HE), neighbor(NI, NW),
neighbor(ST, BB), neighbor(ST, SN), neighbor(ST, TH),
neighbor(BB, BE), neighbor(BB, SN),
neighbor(NW, HE), neighbor(NW, RP),
neighbor(SN, TH), neighbor(SN, BY),
neighbor(RP, SL), neighbor(RP, HE), neighbor(RP, BW),
neighbor(HE, BW), neighbor(HE, TH), neighbor(HE, BY),
neighbor(TH, BY),
neighbor(BW, BY).