-
Notifications
You must be signed in to change notification settings - Fork 0
/
bt-p2lp_test1.pl
39 lines (27 loc) · 1.65 KB
/
bt-p2lp_test1.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
% back-translates Prolog to List Prolog then List Prolog to Prolog.
% bt-p2lp_test(A,B).
% A - output: total tests
% B - output: total correct results
% bt-p2lp_test1(N,B).
% N - input: number to test
% B - output: result
bt-p2lp_test(BL,RL) :-
findall(A,(p2lp_test(N,_I,O),((lp2p1(O,I1),p2lpconverter([string,I1],O2),O=O2)->(writeln([bt-p2lp_test,N,passed]),A=passed);(writeln([bt-p2lp_test,N,failed]),A=failed))),B),
length(B,BL),
findall(_,member(passed,B),R),length(R,RL),!.
bt-p2lp_test1(N,A) :-
p2lp_test(N,_I,O),((lp2p1(O,I1),p2lpconverter([string,I1],O2),O=O2)->(writeln([bt-p2lp_test,N,passed]),A=passed);(writeln([bt-p2lp_test,N,failed]),A=failed)),!.
bt-p2lp_pp_test(BL,RL) :-
findall(A,(p2lp_test(N,_I,O),((pp_lp2p0(O,I1),p2lpconverter([string,I1],O2),O=O2)->(writeln([bt-p2lp_test,N,passed]),A=passed);(writeln([bt-p2lp_test,N,failed]),A=failed))),B),
length(B,BL),
findall(_,member(passed,B),R),length(R,RL),!.
bt-p2lp_pp_test1(N,A) :-
p2lp_test(N,_I,O),((pp_lp2p0(O,I1),p2lpconverter([string,I1],O2),O=O2)->(writeln([bt-p2lp_test,N,passed]),A=passed);(writeln([bt-p2lp_test,N,failed]),A=failed)),!.
% to do
% back-translation, on I not O
bt1-p2lp_test(BL,RL) :-
findall(A,(p2lp_test(N,I,_O),(p2lpconverter([string,I],O1),(lp2p1(O1,I2),(string_concat(I1,"\n",I2)->true;I1=I2),I=I1)->(writeln([bt1-p2lp_test,N,passed]),A=passed);(writeln([bt1-p2lp_test,N,failed]),A=failed))),B),
length(B,BL),
findall(_,member(passed,B),R),length(R,RL),!.
bt1-p2lp_test1(N,A) :-
p2lp_test(N,I,_O),(p2lpconverter([string,I],O1),(lp2p1(O1,I2),(string_concat(I1,"\n",I2)->true;I1=I2),I=I1)->(writeln([bt1-p2lp_test,N,passed]),A=passed);(writeln([bt1-p2lp_test,N,failed]),A=failed)),!.