簡體   English   中英

如何證明 Frama-C + EVA 中非確定性值的簡單等式?

[英]How does one prove simple equalities of non-deterministic values in Frama-C + EVA?

我對 Frama-C 18.0 版(Argon)的行為有點困惑。

給定以下程序:

#include <assert.h>
#include <limits.h>


/*@ requires order: min <= max;
    assigns \result \from min, max;
    ensures result_bounded: min <= \result <= max ;
 */
extern int Frama_C_interval(int min, int max);


int main() {

  int i,j;

  i = Frama_C_interval(INT_MIN, INT_MAX);

  j = i;

  assert(j == i);

  return 0;
}

我希望使用任何跟蹤相等性的抽象域都能很容易地證明該斷言。 但是,調用

frama-c -eva -eva-equality-domain -eva-polka-equalities foo.c

給出:

[eva] Warning: The Apron domains binding is experimental.
[kernel] Parsing stupid_test.c (with preprocessing)
[eva] Analyzing a complete application starting at main
[eva] Computing initial state
[eva] Initial state computed
[eva:initial-state] Values of globals at initialization

[eva] using specification for function Frama_C_interval
[eva] using specification for function __FC_assert
[eva:alarm] foo.c:20: Warning: 
  function __FC_assert: precondition 'nonnull_c' got status unknown.
[eva] done for function main
[eva] ====== VALUES COMPUTED ======
[eva:final-states] Values at end of function main:
  i ∈ [--..--]
  j ∈ [--..--]
  __retres ∈ {0}

我錯過了什么嗎?

有趣。 您的示例不是由-eva -eva-equality-domain ,它是出於其他目的而編寫的。 因此,當xy已知相等時, x == y的特殊情況尚未寫入。 這很容易添加。

(鑒於域的名稱,這可能會令人驚訝。當我們有不感興趣的別名時,相等域更適合於實現更多的向后傳播,例如內核添加的臨時值。)

關於來自Apron的域名,這更令人驚訝。 我修改了你的例子:

  j = i;

  int b = j - i;
  int c = j == i;
  Frama_C_dump_each_domain();

運行frama-c -eva -eva-polka-equalities foo.c -value-msg-key d-apron給出以下結果:

[eva] c/eq.c:23: 
  Frama_C_dump_each_domain:
  # Cvalue domain:
  i ∈ [--..--]
  j ∈ [--..--]
  b ∈ {0}
  c ∈ {0; 1}
  __retres ∈ UNINITIALIZED
  # Polka linear equalities domain:
  [|-i_44+j_45=0; b_46=0|]

正如你所看到的,Apron已經推斷出ij之間的關系(后綴是行號),簡化為b到0,但是沒有將c簡化為1.這對我來說是令人驚訝的,但是解釋了你觀察到的不精確性。 它不適用於八邊形域。

我對關系域上的抽象變換器並不熟悉,所以這可能是預期的,但這肯定令人費解。 處理關系運算符的代碼存在於Frama-C / Eva / Apron中,但部分是在家編寫的(它不僅僅是對Apron原語的簡單調用)。 特別是,它調用運算符進行減法,並用0分析結果的相等性。很難看出為什么b精確但不是c

更新:在更新的 Frama-C 版本上(我嘗試使用 Frama-C 25.0,但它肯定也適用於一些舊版本),八邊形域能夠處理這種特定情況: -eva -eva-domains octagon is在您的特定代碼中足以避免警報。

另請注意,可以使用選項-eva-precision 5 (或更高)間接啟用八邊形域。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM