SPIN 断言未触发

SPIN assert not triggered

我想了解为什么未触发此模型中的断言。

ltl { !A@wa U B@sb && !B@wb U A@sa }

byte p = 0
byte q = 0
int  x = 0

inline signal(sem) { sem++ }
inline wait  (sem) { atomic { sem > 0 ; sem-- } }

proctype A() {
    x = 10*x + 1
    signal(p)
sa: wait(q)
wa: x = 10*x + 2
}

proctype B() {
    x = 10*x + 3
    signal(q)
sb: wait(p)
wb: x = 10*x + 4
}

init {
    atomic { run A(); run B() }
    _nr_pr == 1
    assert(x != 1324) 
}

显然,有一个产生最终值的操作顺序 x = 1324:

当求解器证明 属性

时,断言未被触发,因为它是 "never reached"
ltl { !A@wa U B@sb && !B@wb U A@sa }

是真的。

看看求解器给出的输出,它清楚地指出:

  • 它正在检查任何断言,但前提是在声明的范围内:

    Full statespace search for:
        never claim             + (ltl_0)
        assertion violations    + (if within scope of claim)
    
  • 未达到断言:

    unreached in init
        t.pml:27, state 5, "assert((x!=1324))"
        t.pml:28, state 6, "-end-"
        (2 of 6 states)
    

您可以使用选项 -noclaim 以便仅检查模型的断言,然后很容易证明它是错误的:

~$ spin -search -noclaim t.pml 
ltl ltl_0: ((! ((A@wa))) U ((B@sb))) && ((! ((B@wb))) U ((A@sa)))
pan:1: assertion violated (x!=1324) (at depth 13)
pan: wrote t.pml.trail

(Spin Version 6.4.8 -- 2 March 2018)
Warning: Search not completed
    + Partial Order Reduction

Full statespace search for:
    never claim             - (not selected)
    assertion violations    +
    cycle checks        - (disabled by -DSAFETY)
    invalid end states  +

State-vector 36 byte, depth reached 15, errors: 1
       48 states, stored
        6 states, matched
       54 transitions (= stored+matched)
        1 atomic steps
hash conflicts:         0 (resolved)

Stats on memory usage (in Megabytes):
    0.003   equivalent memory usage for states (stored*(State-vector + overhead))
    0.286   actual memory usage for states
  128.000   memory used for hash table (-w24)
    0.534   memory used for DFS stack (-m10000)
  128.730   total actual memory usage



pan: elapsed time 0 seconds