简体   繁体   English

Dafny 到 Python 代码是否经过认证? 如果是这样,为什么 Python 没有原生的前置选项? 如果不是,为什么要翻译?

[英]Is the Dafny to Python code certified? If so, why does not Python have native pre-post options? If not, why translate it?

I have recently started testing with the Dafny to Python compiler dafny build --target:py A.dfy offered in its latest version.我最近开始使用 Dafny 测试 Python 编译器dafny build --target:py A.dfy在其最新版本中提供。 I'm not sure if it "works well", because it doesn't generate all the functions I have in Dafny (is this normal?).我不确定它是否“运行良好”,因为它不会生成我在 Dafny 中拥有的所有功能(这正常吗?)。

However, I have a rather "philosophical" question about the use of translating a Dafny file into a Python file.但是,关于将 Dafny 文件转换为 Python 文件的用途,我有一个相当“哲学”的问题。 Essentially, the Dafny code is a "certified" code in the sense that it guarantees that the functions fulfill their properties (if pre , then post );本质上,Dafny 代码是一种“认证”代码,因为它保证函数满足它们的属性(如果是pre ,则post ); my question is, does the Python code fulfill this same thing?我的问题是,Python 代码是否满足同样的要求?

If the answer is yes , the question is: why is not "certified" code written in Python?如果答案是肯定的,那么问题是:为什么Python中没有写“认证”代码? I mean why does not Python have some kind of native pre , post and assert (not the assert of Python).我的意思是为什么 Python 没有某种原生的prepostassert (不是 Python 的assert )。 If the answer is no , the question is: what is the point of translating "certified" code to a "non-certified" one?如果答案是否定的,那么问题是:将“认证”代码转换为“非认证”代码有什么意义?

Only the executable code, but not the specifications are compiled.只编译可执行代码,不编译规范。 function s are not, whereas function method s are. function不是,而function method是。 Check the reference manual for more details on that.查看参考手册以获取更多详细信息。 If you find that what is documented to work is not in line with what you experience, consider opening a ticket.如果您发现记录在案的工作与您的体验不符,请考虑开工单。

The translation to Python is meant to preserve the semantics of your program.翻译成 Python 是为了保留程序的语义。 As this process isn't verified, there is no way of knowing that it does do that in all circumstances.由于此过程未经验证,因此无法知道它在所有情况下都会这样做。 Extending a language like Python with the necessary constructs for contracts and writing a verifier for the whole language sounds like a tall order, but this is ultimately a question for the Python community, not us.用必要的合同结构扩展像 Python 这样的语言并为整个语言编写验证器听起来像是一项艰巨的任务,但这最终是 Python 社区的问题,而不是我们。 The point of compilation is that it lets you run your Dafny programs.编译的要点是它可以让你运行你的 Dafny 程序。 If we would compile down to Assembly, you probably wouldn't worry about preserving the specifications.如果我们将编译为汇编,您可能不会担心保留规范。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM