Neil Smith's Prolog Resources

Neil Smith home

Prolog

All I have here at present are some library files, mainly of use for LPA Prolog on Windows machines, and some implementations of Lisp.

Library files

These are mainly conversions of the Edinburgh Prolog library files, targetted at LPA Prolog. However, I've extended the Applic.pl file to include more higher-order features. These include things like map, filter, and fold. Also, all the ordered set predicates now optionally accept a separate comparator predicate, for ordering arbitrary items

Lisp implementations

I have two implementations of Lisp. The Lisp interpreter is a simple interpreter of a small subset of Lisp. It does, however, accept standard Lisp syntax input, including all the brackets. A sample interaction might go something like:

| ?- lisp.
Welcome to Pro-Lisp!
This is a miniscule Lisp interpreter, written in Prolog
> (cons 1 nil)
( 1 ) 
> (defun my_second (lst) (car (cdr lst)))
MY_SECOND 
> (my_second '(a b c))
B 
> quit
Terminating Pro-Lisp
yes

The Lisp compiler is a more complex beast. It uses term_expansion/2 to rewrite function specifications into Prolog clauses. Have a look at the test files for examples of the syntax. The compiler consists of three files:

There are a two of files of examples:

  • tests.pl contains a few scraps of code, used by me to test the compiler. It shows off the sorts of things the compiler can do.
  • streams.pl is an example implementation of streams (lazy lists), showing that I finally managed to get lexical closures working properly.

Other programs

This is an implementation of Djirkstra's shortest-path algorithm. It works on both directed and undirected graphs. Graphs are defined by a separate predicate that will enumerate nodes adjacent to a given node. It uses the ordered sets module to maintain the list of nodes to explore in order of cost. Colin Barker has written another version, also for LPA Prolog.

More Prolog stuff found in comp.lang.prolog and the FAQs.


 

Maths & Computing Faculty

 
Computing Department website

This page maintained by Neil Smith (N.Smith@open.ac.uk)