4%% Include the BASIC EVENT CALCULUS THEORY 5#include '../bec_theory'.
9% If a light is turned on, it will be on: 10initiates(turn_on, light_on, T). 11 12% If a light is turned on, whether it is red or green will be released 13% from the commonsense law of inertia: 14releases(turn_on, light_red, T). 15releases(turn_on, light_green, T). 16 17% If a light is turned off, it will not be on. 18terminates(turn_off, light_on, T). 19 20% After a light is turned on, it will emit red for up to two seconds 21% and green after at least two seconds: 22trajectory(light_on, T1, light_red, T2) :- T2 .>=. T1, T2.<.T1 + 2. 23trajectory(light_on, T1, light_green, T2) :- T2 .>=. T1 + 2. 24 25initiallyN(light_on).
28happens(turn_on, 1/2). 29happens(turn_off, 4). 30happens(turn_on, 6).
39% ?- holdsAt(light_on, -1). % no 40 ?- holdsAt(light_on, 2). % success 41% ?- holdsAt(light_on, 4). % success 42% ?- holdsAt(light_on, 5). % no 43% ?- holdsAt(light_on, 6). % no 44% ?- holdsAt(light_on, 104/10). % success 45 46% ?- -holdsAt(light_on, 1/10). % no 47% ?- -holdsAt(light_on, 2). % no 48% ?- -holdsAt(light_on, 5). % success 49 50% ?- T is 1/2 + 2 - 1/10, holdsAt(light_red, T). % success 51% ?- T is 1/2 + 2 + 1/10, holdsAt(light_red, T). % no 52% ?- holdsAt(light_red, 4). % no 53% ?- holdsAt(light_red, 6). % success 54% ?- holdsAt(light_red, 8). % no 55% ?- holdsAt(light_green, 6). % no 56% ?- holdsAt(light_green, 8). % success