-
Notifications
You must be signed in to change notification settings - Fork 6
/
mint.pl
56 lines (45 loc) · 867 Bytes
/
mint.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
%
% Meta-interpreter experiments.
%
%
% Basic knowledge for testing purposes
%
a(1).
a(2).
b(2).
c(X, f(X)).
%
% Trivial meta-interpreter
%
solve1(A) :- A.
%
% Vanilla meta-interpreter
%
solve2(true).
solve2((A,B)) :- solve2(A), solve2(B).
solve2(A) :- clause(A,B), solve2(B).
%
% Vanilla interpreter corrected
%
solve3(true) :- !.
solve3((A,B)) :- !, solve3(A), solve3(B).
solve3(A) :- clause(A,B), solve3(B).
%
% Built-in predicate resolution absorption
%
solve4(true) :- !.
solve4((A, B)) :- !, solve4(A), solve4(B).
solve4(A) :- predicate_property(A,built_in), !, A.
solve4(A) :- clause(A,B), solve4(B).
%
% Occurs-check reification
%
solve5(true) :- !.
solve5((A, B)) :- !, solve5(A), solve5(B).
solve5(A) :- predicate_property(A,built_in), !, A.
solve5(A) :-
functor(A,F,R),
functor(B,F,R),
clause(B,C),
unify_with_occurs_check(A,B),
solve5(C).