SysML v2 Traces
semantifyr-sysml verify and Live show the run of a case as a SysML v2 model, trace.sysml. It is a package <Case>Trace whose part definition Run specializes the verified part's definition and states which states each part was in, which transitions fired with the items they sent, and how much time passed. Since Run refines the model, any SysML v2 tool reads the trace next to it. A run that cannot be expressed in SysML v2 keeps its verdict and gets no trace.
The trace of LampLitOnlyWhileSwitchOnViolated from the lesson:
package LampLitOnlyWhileSwitchOnViolatedTrace {
private import Occurrences::HappensJustBefore;
private import Time::DurationOf;
private import SI::s;
private import VerificationCases::VerdictKind;
verification witness : LampLitOnlyWhileSwitchOnViolated {
subject :>> system : Run;
return :>> verdict = VerdictKind::fail;
}
part def Run :> Room {
bind init.startShot = self.startShot;
timeslice init [1] {
assert constraint { DurationOf(init) == 0 [s] }
event switch.Behaviour.start [1];
event lamp.Behaviour.start [1];
}
succession : HappensJustBefore [1] first init then step1;
timeslice step1 [1] {
assert constraint { DurationOf(step1) == 0 [s] }
event switch.Behaviour.turnOn1 [1];
}
succession : HappensJustBefore [1] first step1 then step2;
timeslice step2 [1] {
assert constraint { DurationOf(step2) == 0 [s] }
event switch.Behaviour.turnOff1 [1];
event lamp.Behaviour.lightUp1 [1];
}
part switch :>> switch {
exhibit state Behaviour :>> Behaviour [1] {
state off1 [1] :> Off;
transition turnOn1 [1] :> turnOn
first off1
accept Press via button
do action {
action sendToggle1 [1] send new Toggle() via output;
}
then on1;
state on1 [1] :> On;
transition turnOff1 [1] :> turnOff
first on1
accept Press via button
do action {
action sendToggle1 [1] send new Toggle() via output;
}
then off2;
state off2 [1] :> Off;
}
}
part lamp :>> lamp {
exhibit state Behaviour :>> Behaviour [1] {
state dark1 [1] :> Dark;
transition lightUp1 [1] :> lightUp
first dark1
accept Toggle via input
then lit1;
state lit1 [1] :> Lit;
}
}
}
}
- The verification usage
witnessredefines the subject toRunand binds the verdict:failfor a run that breaksmustAlways,passfor one that reaches whateventuallyasks for. Runspecializes the system definition, so its values are the system lives the run is a prefix of.- The timeline is
init, then for each step K adwellKfor the time that passed before it, if any, and astepKwhen a transition fired in it, each atimeslice, ordered bysuccession. - An entered state is an occurrence of its state inside the occurrence of its owner, numbered within that owner (
off1,off2). - A fired transition is a transition usage in the occurrence of the state that declares it, with its source occurrence, the model's trigger and guard, the sends of its effect, and its target occurrence.