Programming Assignment 3: Introductory Prolog

Table of Contents

Problem Domain

This assignment is intended to build familiarity with the Prolog programming language.

Project Infrastructure

You will need to download and install your own version of SWI-Prolog. It is freely available from for major operating systems. Major Linux distributions have copies available within their package system.


You are given a directed graph specified in what is termed "arc-clausal form" where, a prolog clause (or fact) is specified for each edge. An example graph and its representation appears below.



Write a Prolog predicate path(A,B,P) that returns the shortest path from A to B.


Submit your assignment via TAMU eCampus using these submission instructions

  • Files to include in zip file:
    • The code you wrote for this assignment.
    • A short README.txt file with the following information:
      • Name: (Your name)
      • UIN: (Your TAMU UIN)
      • A description of how to run the submission.
      • A list of the resources used (e.g., online forums, links to example code on the web, etc.).
      • A statement of the Aggie Code of Honor.
      • Additional comments: ...

You may discuss this openly with your friends and classmates, but are expected to write your own code and compile your submission independently. If in doubt about whether a resource you used should be included in the list of resources, err on the side of caution and include it.

Academic Integrity: "An Aggie does not lie, cheat, or steal, or tolerate those who do." For additional information please visit:

Getting Help: You are not alone! If you find yourself stuck on something, contact the TA for help. Office hours are there for your support; please use them. If you can't make our office hours, let us know and we will schedule more. We want these projects to be rewarding and instructional, not frustrating and demoralizing. But, we don't know when or how to help unless you ask.