Ranking infer1
This is the example Fig. 1 in the paper using relational ranking
include order
instance time : unbounded_sequence
module signal = {
action raise
specification {
relation now
after init { now := false; }
before raise {
now := true;
now := false;
}
invariant ~now
}
}
module signal1(data) = {
action raise(val:data)
specification {
relation now
var value : data
after init { now := false; }
before raise {
value := val;
now := true;
now := false;
}
invariant ~now
}
}
module isolate unbounded_queue with time = {
action send(x:time)
receiving if successful.
action recv
specification {
var pending(X:time) : bool
after init {
pending(X) := false;
}
instance sending : signal1(time)
instance trying : signal
instance receiving : signal1(time)
before send {
require pending(T) -> T < x;
pending(x) := true;
sending.raise(x); # ghost action to signal a send
}
before recv {
trying.raise;
if some (y:time) pending(y) minimizing y {
pending(y) := false;
receiving.raise(y);
}
}
temporal property [lpq]
(globally eventually trying.now)
->
forall X. globally (sending.now & sending.value = X) ->
(eventually receiving.now & receiving.value = X)
proof {
tactic skolemize;
tactic ranking_infer with {
definition work_created(X) = pending(X)
definition work_needed(X) = pending(X) & X <= _X
definition work_invar = pending(_X)
definition work_progress = trying.now
definition work_helpful = true
}
showgoals
}
}
}
instance q1 : unbounded_queue
export q1.send
export q1.recv