3737 current_predicate(neg_index /2),
3838 neg_index(ID ,Atom ).
3939
40- test_ex (X ):-
40+ test_ex (Atom ):-
41+ functor(Atom ,P ,A ),
42+ current_predicate(P /A ),! ,
4143 timeout(T ),
42- catch(call_with_time_limit(T , call(X )),time_limit_exceeded ,false ),! .
44+ catch(call_with_time_limit(T , call(Atom )),time_limit_exceeded ,false ),! .
4345
4446success_set (Xs ):-
4547 findall (ID , (ex_index(ID ,Atom ),test_ex(Atom )), Xs ).
6567redundant_clause (P1 ):-
6668 select(C1 ,P1 ,P2 ),
6769 member(C2 ,P2 ),
68- subsumes(C1 ,C2 ),! .
69-
70-
71- %% do_test(TP,FN,TN,FP):-
72- %% do_test_pos(TP,FN),!,
73- %% do_test_neg(TN,FP),!.
74-
75- %% do_test_pos(0,0):-
76- %% \+ current_predicate(pos/1),!.
77- %% do_test_pos(TP,FN):-
78- %% aggregate_all(count,(pos(X),test_ex(X)),TP),
79- %% num_pos(NumPos),
80- %% FN is NumPos-TP.
81-
82- %% do_test_neg(0,0):-
83- %% \+ current_predicate(neg/1),!.
84- %% do_test_neg(TN,FP):-
85- %% aggregate_all(count,(neg(X),test_ex(X)),FP),
86- %% num_neg(NumNeg),
87- %% TN is NumNeg-FP.
88-
89-
90-
91- %% count_pos(0):-
92- %% \+ current_predicate(pos/1),!.
93- %% count_pos(N):-
94- %% aggregate_all(count,pos(_),N),!.
95- %% count_neg(0):-
96- %% \+ current_predicate(neg/1),!.
97- %% count_neg(N):-
98- %% aggregate_all(count,neg(_),N),!.
99-
100- %%%%%%%%%% MINIMAL TESTING %%%%%%%%%%
101- %% we do not need to test all the examples
102- %% we want to know:
103- %% 1. whether a program is incomplete (whether a positive example is not entailed) FN > 0
104- %% 2. whether a program is inconsistent (whether a negative example is entailed) FP > 0
105- %% 3. whether a program is totally incomplete (whether no positive examples are entailed) TP > 0 FN > 0
106- %% AC: TN IS UNSUSED WITH MINIMAL TESTING
107- do_test_minimal(TP ,FN ,0 ,FP ):-
108- minimal_test_pos(TP ,FN ),! ,
109- minimal_test_neg(FP ),! .
110-
111- test_pos_ex_aux (X ,Counter ,_ ):-
112- test_ex(X ),! ,
113- arg(1 ,Counter ,C0 ),
114- C1 is C0 + 1 ,
115- nb_setarg(1 ,Counter ,C1 ).
116-
117- test_pos_ex_aux (_ ,_ ,Counter ):-
118- arg(1 ,Counter ,C0 ),
119- C1 is C0 + 1 ,
120- nb_setarg(1 ,Counter ,C1 ).
121-
122- minimal_test_pos (0 ,0 ):-
123- \+ current_predicate(pos /1),! .
124- minimal_test_pos (TP ,FN ):-
125- TPC = counter(0 ),
126- FNC = counter(0 ),
127- (
128- pos(X ),
129- test_pos_ex_aux(X ,TPC ,FNC ),
130- %% if TP > 0 and FN > 0 then a program is incomplete but not totally_incomplete
131- ((\+ arg(1 ,TPC ,0 ),\+ arg(1 ,FNC ,0 )) -> (arg(1,TPC ,TP ),arg(1,FNC ,FN )); fail );
132- arg(1 ,TPC ,TP ),
133- arg(1 ,FNC ,FN )
134- ).
135-
136- minimal_test_neg (0 ):-
137- \+ current_predicate(neg /1),! .
138- minimal_test_neg (1 ):-
139- neg(X ),
140- test_ex(X ),! .
141- minimal_test_neg (0 ).
142-
143-
70+ subsumes(C1 ,C2 ),! .
0 commit comments