2
|
1 :- multifile tclause/2.
|
|
2
|
|
3 % Basic Composite
|
|
4 % fact is not allowed. use a:-true form.
|
|
5 % commented out one is defined internally for efficiency
|
|
6 % @(A) :- more,next(A).
|
|
7 % #(A) :- A,next(#(A)).
|
|
8 % [](A) :- A,next([](A)).
|
|
9 % (A && B) :- (A,more) & B.
|
|
10 % (A &@ B) :- A & @B.
|
|
11 % keep(A) :- next(keep(A)),ifMore(A).
|
|
12 % fin(A) :- next(fin(A)),ifEmpty(A).
|
|
13 % gets(A,B) :- keep(@A = B).
|
|
14 % (A<-B) :- A=B,stable(C),fin(A=C).
|
|
15 (A<-B) :- C<--B,fin(A=C).
|
|
16 skip :- @empty.
|
|
17 <>(A) :- true & A.
|
|
18 halt(A) :- A,!,empty.
|
|
19 halt(A) :- @(halt(A)).
|
|
20 stable(A) :- gets(A,A).
|
|
21 % Framing
|
|
22 % A <= B :- more, <>(A:=B).
|
|
23 A // B :- process(A),process(B).
|
|
24 frame(A,B) :- frame(A), B.
|
|
25 frames([H|T],B) :- frame(H),frames(T,B).
|
|
26 frames([],B) :- B.
|
|
27 readonlys([H|T],B) :- readonly(H),readonlys(T,B).
|
|
28 readonlys([],B) :- B.
|
|
29 % A:=B :- forall_parent(flag(A,assign)),@A=B.
|
|
30 % readonly(A) :- flag(A,stay).
|
|
31 % Closures
|
|
32 *(_) :- empty.
|
|
33 *(A) :- more,A & *(A).
|
|
34 % These are very slow in interpreter
|
|
35 while(A,B) :- (A,!,more,B) & while(A,B).
|
|
36 while(_,_) :- empty.
|
|
37 (if A then B else _) :- A,!,B.
|
|
38 (if _ then _ else C) :- C.
|
|
39 (_ else _) :- fail.
|
|
40 (if A then B) :- A,!,B.
|
|
41 (if _ then _) :- true.
|
|
42 % end
|