用于验证科学调查软件的改进型合同
Refinement type contracts for verification of scientific investigative software
摘要:
我们的科学知识越来越多地建立在软件输出上。定义数据分析管道和计算模型的用户代码对于自然科学和社会科学的研究是必不可少的,但很少有人知道如何确保其正确性。这种代码的结构和用于构建它的开发过程限制了传统测试方法的实用性。软件验证的形式化方法在确保代码正确性方面取得了巨大的成功,但通常需要比自然科学和社会科学更专业的培训,开发时间和资金。在这里,我们提出了一个Python库,它使用轻量级的形式化方法来提供正确性保证,而不需要专门的知识或大量的时间投资。我们的包提供了使用细化类型的函数入口和出口条件契约的运行时验证。它允许检查合同中的超属性,并提供自动测试用例生成来补充在线检查。我们共同开发了我们的工具与一个中型($\approx$ 3000磅)软件包,它模拟决策的认知神经科学。除了帮助我们在开发周期的早期定位小错误之外,我们的工具还能够定位四个使用传统测试方法可能很难找到的错误。它还能够发现用户代码中不包含契约或细化类型注释的bug。这表明形式化方法可以用来验证科学软件的正确性,这是很难测试的主流方法。
英文摘要:
Our scientific knowledge is increasingly built on software output. User code which defines data analysis pipelines and computational models is essential for research in the natural and social sciences, but little is known about how to ensure its correctness. The structure of this code and the development process used to build it limit the utility of traditional testing methodology. Formal methods for software verification have seen great success in ensuring code correctness but generally require more specialized training, development time, and funding than is available in the natural and social sciences. Here, we present a Python library which uses lightweight formal methods to provide correctness guarantees without the need for specialized knowledge or substantial time investment. Our package provides runtime verification of function entry and exit condition contracts using refinement types. It allows checking hyperproperties within contracts and offers automated test case generation to supplement online checking. We co-developed our tool with a medium-sized ($\approx$3000 LOC) software package which simulates decision-making in cognitive neuroscience. In addition to helping us locate trivial bugs earlier on in the development cycle, our tool was able to locate four bugs which may have been difficult to find using traditional testing methods. It was also able to find bugs in user code which did not contain contracts or refinement type annotations. This demonstrates how formal methods can be used to verify the correctness of scientific software which is difficult to test with mainstream approaches.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。