-
Notifications
You must be signed in to change notification settings - Fork 5
/
ILP-handcrafted-ilp-rules-for-metagol.pl
69 lines (56 loc) · 1.8 KB
/
ILP-handcrafted-ilp-rules-for-metagol.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
57
58
59
60
61
62
63
64
65
66
67
68
69
:- multifile(library_directory/1).
library_directory('/metagol').
:- use_module(library(metagol)).
%% To run, exec into a djwj/uob-summer-project docker container
%% change dircetory into /project/code then run:
%% swipl ILP-handcrafted-ilp-rules-test.pl
%% metagol settings
body_pred(alloc_mem/1).
body_pred(pointer/1).
body_pred(pointer_written_to/2).
body_pred(alloc_checks_size/1).
body_pred(alloc_doesnt_check_size/1).
%% background knowledge
alloc_mem(bad_location_62852).
alloc_mem(bad_location_62869).
alloc_mem(bad_location_62804).
alloc_mem(good_location_62852).
alloc_mem(good_location_62869).
alloc_mem(good_location_62804).
alloc_checks_size(good_location_62852).
alloc_checks_size(good_location_62869).
alloc_checks_size(good_location_62804).
alloc_doesnt_check_size(MemoryAlloc) :- alloc_mem(MemoryAlloc), not(alloc_checks_size(MemoryAlloc)).
pointer(bad_62804_data).
pointer(bad_62852_data).
pointer(bad_62869_data).
pointer(good_62804_data).
pointer(good_62852_data).
pointer(good_62869_data).
pointer_written_to(bad_62804_data, bad_location_62852).
pointer_written_to(bad_62852_data, bad_location_62869).
pointer_written_to(bad_62869_data, bad_location_62804).
pointer_written_to(good_62804_data, good_location_62852).
pointer_written_to(good_62852_data, good_location_62869).
pointer_written_to(good_62869_data, good_location_62804).
%% metarules
% metarule([P,Q],[P,A,B],[[Q,A,B]]).
% metarule([P,Q,R],[P,A,B],[[Q,A,B],[R,A,B]]).
% metarule([P,Q,R],[P,A,B],[[Q,A,C],[R,C,B]]).
metarule([P,Q,R],[P,A],[[Q,A],[R,A]]).
metarule([P,Q,R],[P,A],[[Q,A,B],[R,B]]).
%% learning task
:-
%% positive examples
Pos = [
bug(bad_62804_data),
bug(bad_62852_data),
bug(bad_62869_data)
],
%% negative examples
Neg = [
bug(good_62804_data),
bug(good_62852_data),
bug(good_62869_data)
],
learn(Pos,Neg).