【问题标题】:How to interpret SPIN error output?如何解释 SPIN 错误输出?
【发布时间】:2013-06-10 07:50:51
【问题描述】:

我正在尝试对以下 LTL 属性的简单 Promela 模型进行模型检查:

ltl { M[0] U M[1] }

我遇到了一个错误,错误线索上的引导模拟会产生以下输出:

ltl ltl_0: (M[0]) U (M[1])
spin: couldn't find claim 2 (ignored) 
0 :init ini M[0] = 1             
Process Statement                M[0]       M[1]       
0 :init ini M[1] = 0             1          0          
Starting net with pid 2
0 :init ini run net()            1          0          
spin: trail ends after 4 steps
#processes: 2
  4:    proc  1 (net) petri:11 (state 13)
  4:    proc  0 (:init:) petri:25 (state 5)
2 processes created
Exit-Status 0

现在我看不到“M[0] until M[1]”在这里被违反了。 M[0] 在初始化过程中被设置为 1,并且一直如此,直到 M[1] 变为 1。并且跟踪结束得这么早,或者我可能完全误解了“stronguntil”的语义。 我非常有信心是这种情况......但我做错了什么?在 Promela 文件中指定 LTL 可以吗?

有问题的模型如下(一个简单的 petri 网):

#define nPlaces 2
#define nTransitions 2
#define inp1(x1) (x1>0) -> x1--
#define out1(x1) x1++

int M[nPlaces];
int T[nTransitions];

proctype net()
{
    do
    ::  d_step{inp1(M[0])->T[0]++;out1(M[1]);skip}
    ::  d_step{inp1(M[1])->T[1]++;out1(M[0]);skip}
    od
}
init
{
    atomic 
    {
        M[0] = 1;
        M[1] = 0;
    }
    run net();
}

ltl { M[0] U M[1] }

【问题讨论】:

    标签: formal-verification model-checking spin promela


    【解决方案1】:

    您的声明在初始状态下被违反(在init 使用atomic 之前)。这是一个 SPIN 验证运行 (pan -a),输出来自跟踪文件:

    ebg@ebg$ spin -a foo.pml
    ltl ltl_0: (M[0]) U (M[1])
    ebg@ebg$ gcc -o pan pan.c
    ebg@ebg$ ./pan -a
    pan:1: assertion violated  !(( !(M[0])&& !(M[1]))) (at depth 0)
    pan: wrote foo.pml.trail
    
    (Spin Version 6.2.4 -- 21 November 2012)
    Warning: Search not completed
        + Partial Order Reduction
    
    Full statespace search for:
        never claim             + (ltl_0)
        assertion violations    + (if within scope of claim)
        acceptance   cycles     + (fairness disabled)
        invalid end states  - (disabled by never claim)
    
    State-vector 36 byte, depth reached 6, errors: 1
            4 states, stored (7 visited)
            1 states, matched
            8 transitions (= visited+matched)
            0 atomic steps
    hash conflicts:         0 (resolved)
    
    Stats on memory usage (in Megabytes):
        0.000   equivalent memory usage for states (stored*(State-vector + overhead))
        0.290   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
    ebg@ebg$ spin -p -t foo.pml
    ltl ltl_0: (M[0]) U (M[1])
    starting claim 2
    using statement merging
    spin: _spin_nvr.tmp:5, Error: assertion violated
    spin: text of failed assertion: assert(!((!(M[0])&&!(M[1]))))
    Never claim moves to line 5 [D_STEP]
    spin: trail ends after 1 steps
    #processes: 1
            M[0] = 0
            M[1] = 0
            T[0] = 0
            T[1] = 0
      1:    proc  0 (:init:) foo.pml:18 (state 3)
      1:    proc  - (ltl_0) _spin_nvr.tmp:3 (state 6)
    1 processes created
    

    你可以看到ltl被翻译成:assert(!(( !(M[0])&& !(M[1])))),即:

      !(( !0 && !0))
      !((  1 &&  1))
      !((  1 ))
      0
    

    因此违反了断言。

    避免该问题的最简单方法是将数组更改为单独的变量。由于您的数组只有 2 大小,因此很容易做到:

    int M0 = 1;
    int M1 = 0;
    int T0 = 0;
    int T1 = 0;
    /* then use as appropriate. */
    

    有了这个,您可以跳过init,只需将net proctype 声明为active proctype net ()

    【讨论】:

    • 谢谢!那么如何声明“真正的”初始值呢? C 风格?
    • 你的意思是......我怎样才能设置初始状态以满足 ltl?
    • 没错。还是修改 LTL 会更好?
    【解决方案2】:

    您的 ltl 公式放置得很好。如果您使用 ispin 并验证(而不是模拟)您的程序,请确保选择“使用声明”选项。注意:默认为“不使用 never claim 或 ltl 属性”。

    【讨论】:

    • 感谢您的提示!听起来我做错了什么。但我找不到有关如何设置此选项的任何信息。我正在使用 jSpin (code.google.com/p/jspin),但命令行选项应该相同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-11
    • 2016-08-18
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多