blob: d91df01e85c99a0055aa237ffc5cede317230c45 (
plain) (
tree)
|
|
-- Cet exemple est clairement trop compliqué.
node diff(incr, decr: bool) returns (diff: int)
let
diff = (0 -> pre diff) +
(if incr and not decr then 1
else if not incr and decr then -1
else 0);
tel
node train(beacon, second: bool) returns (early, late: bool)
var probe advance: int;
let
advance = diff(beacon, second);
automaton
initial state NotEarly
unless if advance > 10 resume Early;
let early = false; tel
state Early
unless if advance = 0 resume NotEarly;
let early = true; tel
returns early;
automaton
initial state NotLate
unless if advance < -10 resume Late;
let late = false; tel
state Late
unless if advance = 0 resume NotLate;
let late = true; tel
returns late;
tel
node observer(early, late: bool) returns (alarm: bool)
var ontime: bool;
let
ontime = not (late or early);
automaton
initial state Ok
unless if early resume Early;
let alarm = false; tel
state Early
unless if ontime resume Ok;
let alarm = late; tel
returns alarm;
tel
node train_check(beacon, second: bool) returns (early, late, alarm: bool)
let
early, late = train(beacon, second);
alarm = observer(early, late);
guarantee ok : not alarm;
tel
node test(i: int) returns(a, b, c: int; exit: bool)
var early, late, alarm: bool;
let
exit = i >= 100;
early, late, alarm = train_check((i+1) mod 2 = 0, i mod 3 = 0);
c = if alarm then 1 else 0;
a = if early then 1 else 0;
b = if late then 1 else 0;
tel
|