-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-nfqp.js
102 lines (92 loc) · 2.47 KB
/
test-nfqp.js
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
__pr = require("./webchurch/probabilistic-js/probabilistic/index"); __pr.openModule(__pr);
__ch = require("./webchurch/church_builtins"); __pr.openModule(__ch);
__tr = require("./traced_builtins");
__int = require("./trace_interface");
__sh = require("./shred");
function test_nfqp_0() {
__sh.reset_trace_state();
var S = function () {
enterfn(0);
var call0 = wrapped_flip();
leavefn();
enterfn(5);
var call5 = _if(call0, function () {
enterfn(1);
var call1 = _const([null]);
leavefn();
return call1;
}, function () {
enterfn(2);
var call2 = _const(1);
leavefn();
enterfn(3);
var call3 = S();
leavefn();
enterfn(4);
var call4 = pair(call2, call3);
leavefn();
return call4;
});
leavefn();
return call5;
};
enterfn(6);
var call6 = S();
leavefn();
var sample = call6;
return sample;
}
function test_nfqp_1() {
__sh.reset_trace_state();
var S = function () {
enterfn(0);
var call0 = wrapped_flip();
leavefn();
enterfn(5);
var call5 = _if(call0, function () {
enterfn(1);
var call1 = _const([null]);
leavefn();
return call1;
}, function () {
enterfn(2);
var call2 = _const(1);
leavefn();
enterfn(3);
var call3 = S();
leavefn();
enterfn(4);
var call4 = pair(call2, call3);
leavefn();
return call4;
});
leavefn();
return call5;
};
enterfn(6);
var call6 = S();
leavefn();
enterfn(7);
var call7 = S();
leavefn();
enterfn(8);
var call8 = list(call6, call7);
leavefn();
var sample = call8;
return sample;
}
var traces = [];
function next_trace() {
var tr = newTrace(nfqp, undefined);
traces.push(tr);
}
var wg = new_worldgraph();
function explore_worldgraph(wg, num_iter, proc) {
for (var i = 0; i < num_iter; i++) {
wg.incorp_trace(newTrace(proc, undefined));
}
}
explore_worldgraph(wg, 10, test_nfqp_1);
console.log(JSON.stringify(wg.transitions));
var mh_samples = traceMH(test_nfqp_0, 10, 10, true, undefined);
console.log(mh_samples)