用 C 语言进行契约设计,用于自动定理证明

发布于 2024-07-18 07:00:03 字数 197 浏览 11 评论 0原文

我正在开发几个 C 项目,我想使用自动定理证明来验证代码。 理想情况下,我只想使用 ATP 来验证函数契约。 C/gcc 或外部软件/软件包/等中是否有任何功能可以实现合同设计风格编码?

如果没有,那就是我自己开始的动力。

我对此的参考资料类似于 MSR 的 Spec# 或 Sing#,但我是一个开源人士,我正在寻找开源解决方案。

I'm working on a couple of C projects and I'd like to use automated theorem proving to validate the code. Ideally I'd just like to use the ATP to validate the functions contracts. Is there any functionality in C/gcc or external software/packages/etc that would enable design-by-contract style coding?

If not then thats just incentive to get started on my own.

My references for this would be something like Spec# or Sing# from MSR, but I'm an open source guy and I'm looking for open source solutions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绿光 2024-07-25 07:00:03

开源:检查。

自动定理证明:勾选。

您应该非常喜欢 Frama-C 及其 Frama-C 。 cea.fr/acsl.html" rel="noreferrer">ACSL 规范语言。 您可能已经听说过它的 Caduceus 祖先,但目前它被认为已被 Frama-C/Jessie 取代。

Open-Source:check.

Automated Theorem Proving:check.

You should really like Frama-C and its ACSL specification language. You might have already heard about its Caduceus ancestor, but at this time it is considered superseded by Frama-C/Jessie.

寂寞美少年 2024-07-25 07:00:03

显然它没有内置到该语言中,但是有很多附加组件可以帮助您继续前进。 其中大多数都是测试版 - 但您可能会考虑为它们做出贡献,而不是创建自己的。

RubyForge 的Design by Contract for C看起来非常有前途。 GNU Nana 已经存在很长时间了,可能会很好地满足您的需求。 希望这些有帮助。

编辑:查看O'Reily 的这篇文章 关于 C 的合同设计:

对assert()不满意并且
我对合同设计感到兴奋
开始创建我自己的设计
C.之后的合同执行
查看一些解决方案
适用于 Java 1 我决定
使用对象约束的子集
表达合同的语言[4]。
我使用 Ruby 和 Racc 创建了 Design
通过 C 合约,代码生成器
将合约嵌入到 C 中
注释到 C 代码中以检查
合同。

Obviously it is not built into the language, but there are plenty of add-ons to get you going. Most of them are beta - but you might consider contributing to them rather than starting your own.

The one at RubyForge, Design by Contract for C, looks very promising. GNU Nana has been around for a long time and will probably suit your needs fine. Hope these are helpful.

Edit: Check out this article at O'Reily on Design By Contract for C:

Not satisfied with assert() and
excited about Design by Contract, I
set out to create my own Design by
Contract implementation for C. After
looking at some of the solutions
available for Java 1 I decided to
use a subset of the Object Constraint
Language to express contracts [4].
Using Ruby and Racc, I created Design
by Contract for C, a code generator
that turns contracts embedded in C
comments into C code to check the
contracts.

杯别 2024-07-25 07:00:03

如果您有兴趣使用定理证明器验证 C 代码,您应该查看 VCC 项目
从他们的网页:

VCC 是并发 C 程序的机械验证器。 VCC 需要 C
程序,用函数规范、数据不变量、循环进行注释
不变量和幽灵代码,并尝试证明这些注释
正确的。 如果成功,VCC 承诺您的程序实际上满足
它的规格。

VCC是微软研究院非常成熟的系统,已用于验证Microsoft Hyper-V
VCC 也是开源的。

If you are interested in validating C code using theorem provers, you should check the VCC project.
From their webpage:

VCC is a mechanical verifier for concurrent C programs. VCC takes a C
program, annotated with function specifications, data invariants, loop
invariants, and ghost code, and tries to prove these annotations
correct. If it succeeds, VCC promises that your program actually meets
its specifications.

VCC is very mature system from Microsoft Research, and has been used to verify the hypervisor of Microsoft Hyper-V.
VCC is also open source.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文