/usr/share/Yap/minisat_examples/adder.pl is in yap 6.2.2-6build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | :- module(adder,[sum/3]).
sum([B],[S],(S==B)).
sum([B1,B2|Bs],Sum,F1*F2*F3) :-
split([B1,B2|Bs],Xs,Ys),
sum(Xs,S1,F1), sum(Ys,S2,F2),add(S1,S2,Sum,F3).
split([],[],[]).
split([X],[X],[0]).
split([X,Y|XYs],[X|Xs],[Y|Ys]) :- split(XYs,Xs,Ys).
add([X|Xs],[Y|Ys],[Z|Zs],(Z==SumXY)*Sum) :-
halfadder(X,Y,SumXY,CarryXY),
adder(Xs,Ys,CarryXY,Zs,Sum).
adder([],[],Carry,[Z],Z==Carry).
adder([X|Xs],[Y|Ys],Carry,[Z|Zs],(Z==SumXY)*Rest) :-
fulladder(X,Y,Carry,SumXY,CarryXY),
adder(Xs,Ys,CarryXY,Zs,Rest).
fulladder(X, Y, C, (X xor Y xor C), (C->(X+Y);(X*Y)) ).
halfadder(X, Y, (X xor Y), X*Y ).
|