-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathb.dl
17 lines (13 loc) · 855 Bytes
/
b.dl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
empty_battery(B) :- battery(B), c(B,is,empty).
half_full_battery(B) :- battery(B), c(B,is,half_full).
full_battery(B) :- battery(B), c(B,is,full).
% Empty cases
p(B,op,ID) :- empty_battery(B), p(B,ip,IP), c(B,id,ID), ID <= IP, not ab(B).
p(B,op,IP) :- empty_battery(B), p(B,ip,IP), c(B,id,ID), ID > IP, not ab(B).
% Half full
p(B,op,ID) :- half_full_battery(B), p(B,ip,IP), c(B,id,ID), const(cb,CB), X = CB + IP, ID <= X, not ab(B).
p(B,op,X) :- half_full_battery(B), p(B,ip,IP), c(B,id,ID), const(cb,CB), X = CB + IP, ID > X, not ab(B).
% Full
p(B,op,IP) :- full_battery(B), p(B,ip,IP), c(B,id,ID), const(cb,CB), ID <= IP, not ab(B).
p(B,op,ID) :- full_battery(B), p(B,ip,IP), c(B,id,ID), const(cb,CB), ID > IP, X = CB + IP, ID <= X, not ab(B).
p(B,op,X) :- full_battery(B), p(B,ip,IP), c(B,id,ID), const(cb,CB), X = CB + IP, ID > X, not ab(B).