SAW C验证示例失败

时间:2017-08-18 10:54:02

标签: formal-verification

在文档SAWScript Galois中,是验证点积实现的示例。我收到一个错误:

dotprod.c:

#include <stdint.h>
#include <stdlib.h>

uint32_t dotprod(uint32_t *x, uint32_t *y, uint32_t size)
{
    uint32_t res = 0;
    for(size_t i = 0; i < size; i++) {
        res += x[i] * y[i];
    }
    return res;
}

dotprod.saw:

import "dotprod.cry";
m <- llvm_load_module "dotprod.bc";


xs <- fresh_symbolic "xs" {| [12][32] |};
ys <- fresh_symbolic "ys" {| [12][32] |};
let allocs = [ ("x", 12), ("y", 12) ];
let inputs = [ ("*x", xs, 12) , ("*y", ys, 12) , ("size", {{ 12:[32] }}, 1)     ];
let outputs = [(" return", 1)];

t <- llvm_symexec m "dotprod" allocs inputs outputs true;
thm1 <- abstract_symbolic {{ t == dotprod xs ys }};
prove_print thm1;

SAW脚本给出错误:

Loading module Cryptol
Loading file "dotprod.saw"
Loading module Main
saw: user error (Bitcode parsing of inc_file.bc failed:
not implemented
  from:
    FUNC_CODE_INST_GEP
    dotprod
    FUNCTION_BLOCK
    MODULE_BLOCK)

我用:

  • SAW版本0.2
  • cryptol version 2.5.0
  • clang version 3.7

更新1:

SAW从其git存储库重新编译,我正在使用stack version 1.5.1

更新错误后更改为:

Loading module Cryptol
Loading file "... /dotprod.saw"
Loading module Main
saw: user error ("llvm_symexec" (... /dotprod.saw:11:6):
"Parse error: \"expr\" (line 1, column 1):\nunexpected \" \"\nexpecting   \"*\", \"return\", \"args[\", letter, \"_\" or \"(\"")

1 个答案:

答案 0 :(得分:0)

问题已在project's git site

上得到解答

解决方案代码段

let outputs = [("return", 1)];

t <- llvm_symexec m "dotprod" allocs inputs outputs true;
thm1 <- abstract_symbolic {{ t == dotprod xs ys }};
prove_print abc thm1;