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

Write a Prolog program with the following knowledge base: directTrain(union-stat

ID: 3798470 • Letter: W

Question

Write a Prolog program with the following knowledge base:

directTrain(union-station, san-bernardino).
directTrain(oxnard, union-station).
directTrain(burbank, lancaster).
directTrain(lancaster, union-station).
directTrain(san-bernardino, riverside).
directTrain(santa-ana, burbank).
directTrain(oceanside, santa-ana).

This knowledge base holds facts about towns you can travel between by taking a direct train, e.g., from union station to san bernardino.

Extend your Prolog program with a rule that adds a directTrain between A and B whenever there is one from B to A.

Explanation / Answer

directTrain(union-station, san-bernardino).
directTrain(oxnard, union-station).
directTrain(burbank, lancaster).
directTrain(lancaster, union-station).
directTrain(san-bernardino, riverside).
directTrain(santa-ana, burbank).
directTrain(oceanside, santa-ana).

directTrainrev(a,b):- directTrain(b,a) // directTrainrev is a rule that adds a directTrain between a and b whenever ther is one from b to a.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote