Mixtus, a sample session
The examples below are quite small so that the main ideas behind partial
evaluation with Mixtus are illustrated. Mixtus will also work well on
quite large programs with lots of non-logical predicates.
The file vars8.pl (consulted below) contains definitions for
append/3 and rev/2 as follows:
append([], L, L).
append([H|T], L, [H|R]) :-
append(T, L, R).
rev(X,Xrev) :- rev(X,[],Xrev).
rev([],Acc,Acc).
rev([X|Xs],Acc,Xrev) :- rev(Xs,[X|Acc],Xrev).
The following is a sample session using Mixtus.
The two main top level commands are pconsult/1 for reading in a file
and pe/1 for doing a partial evaluation of a certain query.
dan> ./mixtus
SICStus 2.1 #7: Mon Feb 8 14:29:06 MET 1993
Mixtus 0.3.6
{consulting /home/echnaton2/dan/.sicstusrc...}
{/home/echnaton2/dan/.sicstusrc consulted, 0 msec 80 bytes}
| ?- pconsult(vars8).
{consulting for mixtus: /a/echnaton/home2/dan/mixtus/vars8}
yes
| ?- pe(append(X,Y,[1,2,3])).
append(A, B, [1,2,3]) :-
append1(A, B).
% append1(A,B):-append(A,B,[1,2,3])
append1([], [1,2,3]).
append1([1], [2,3]).
append1([1,2], [3]).
append1([1,2,3], []).
true ?
yes
| ?- pe(rev(X,Y)).
rev(A, B) :-
rev1(A, B).
% rev1(A,B):-rev(A,B)
rev1([], []).
rev1([A], [A]).
rev1([B,C|D], A) :-
rev2(D, C, B, [], A).
% rev2(A,B,C,[],D):-rev(A,[B,C],D)
rev2([], A, B, C, [A,B|C]).
rev2([E|F], A, B, C, D) :-
rev2(F, E, A, [B|C], D).
true ?
yes
| ?- pe(rev([A,B,C],D)).
rev([B,C,D], A) :-
'rev.1'(B, C, D, A).
% 'rev.1'(A,B,C,D):-rev([A,B,C],D)
'rev.1'(A, B, C, [C,B,A]).
true ?
yes