AI::Prolog update

Ovid on 2005-03-05T03:39:46

Though I've been rather quiet about it (not having much time to work on it the past week), the work on AI::Prolog is continuing. The current version on my hard drive handles numbers quite a bit better, adds the pow/2 predicate (for exponentiation), has a bit of cleanup of the internals and adds trace/0 and notrace/0 predicates. The latter predicates pretty much do what one would expect of Prolog. They control the tracing of the engine's attempts to satisfy Prolog goals. This was in the Perl code itself, but I've pushed it down in the Prolog code because really, that's where it belongs.

I've also taken to lurking on comp.lang.prolog. Many times students ask questions there. Naturally, rather than looking for pointers, they are often just looking for someone to do their homework for them. So I do. I just don't post it back to the list, but it is a nice way to keep in practice. One fun one was to take facts like this:

details(car1, [owner, john, colour, blue, make, ford, type, hatchback, doors, 3]).
details(car2, [colour, red, make, volkswagen, type, saloon, owner, sue]).
details(car3, [owner, ovid, colour, gold, make, saturn, doors, 4, type, sedan]).

And create a predicate that would describe each car but treat the list like a hash of key/value pairs. The following works in both SWI-Prolog and my aiprolog shell:

writelist([]) :- !.

writelist([First, Second|Rest]) :-
    print(First), print(' = '), print(Second), nl,
    writelist(Rest).

describe(Car) :-
    details(Car, List),
    writelist(List).

To be honest, I was actually suprised that worked given that I'm used to treating the head of a list as being a single element :)

I also suppose it's too much to hope that my logic programming proposal was chosen for this year's OSCON, I confess that I'm curious to know if it was accepted or not. I suppose if more than handful of people had even an inkling of what was going on, that would help :)