This repository has been archived by the owner on Sep 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vessel_01.clingo
64 lines (48 loc) · 1.72 KB
/
vessel_01.clingo
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
%% Inspired by example from Shanahan (1999)
timestep(0..30*P) :- precision(P).
% One world - vessel size = 10
max_level(10*P) :- precision(P), not max_level(16*P).
max_level(16*P) :- precision(P), not max_level(10*P).
initiates(tapOn,filling,T) :- timestep(T).
terminates(tapOff,filling,T) :- timestep(T).
initiates(overflow,spilling,T) :-
timestep(T),
max_level(Max),
holdsAt(level(Max), T).
% Note that (S1.3) has to be a Releases formula instead of a
% Terminates formula, so that the Level fluent is immune from the
% common sense law of inertia after the tap is turned on.
releases(tapOn,level(0),T) :- timestep(T), happens(tapOn, T).
% Now we have the Trajectory formula, which describes the continuous
% variation in the Level fluent while the Filling fluent holds.
trajectory(filling,T1,level(X2),T2) :-
timestep(T1), timestep(T2),
T1 < T2,
X2 = X + (4 * (T2 - T1)/3),
max_level(Max),
X2 <= Max,
holdsAt(level(X),T1).
trajectory(filling,T1,overlimit,T2) :-
timestep(T1), timestep(T2),
T1 < T2,
X2 = X + (4 * (T2 - T1)/3),
max_level(Max),
X2 > Max,
holdsAt(level(X),T1).
% Now we have the Trajectory formula, which describes the continuous
% variation in the Leaf fluent while the Spilling fluent holds.
trajectory(spilling,T1,leak(X),T2) :-
timestep(T1), timestep(T2),
holdsAt(filling, T2),
T1 < T2,
X = 4 * (T2 - T1) /3.
initiallyP(level(0)).
%% Actions
% The next formulae ensures the Overflow event is triggered when it
% should be.
happens(overflow,T) :- timestep(T).
% Here’s a simple narrative. The level is initially 0, and the tap is
% turned on at time 5.
happens(tapOn,5*P) :- precision(P).
%% Query
:- not query.