arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.23931cs.AIcs.PLcs.SE
收藏

BODHI:精确的操作系统内核规范推断

BODHI: Precise OS Kernel Specification Inference

Department of Applied Mathematics and Statistics(应用数学与统计学系);Johns Hopkins University(约翰霍普金斯大学);Department of Computer Science(计算机科学系)

Zhiming Chang, Ziyang Li

AI总结:

提出一种领域知识提示方法BODHI,通过结构化C到Python翻译指南增强少样本提示,在OSV-Bench基准上将Pass@1从55.10%提升至96.73%,缩小了通用代码生成与形式规范合成之间的差距。

摘要:

操作系统内核的形式化验证需要精确的规范来捕获系统调用的预期行为。手动编写这些规范需要深厚的领域专业知识,这促使使用大型语言模型(LLM)来自动化该过程。然而,在OSV-Bench(一个源自Hyperkernel操作系统内核的245个规范生成任务基准)中,最佳报告的Pass@1为55.10%。我们提出了一种领域知识提示方法(BODHI),该方法通过一个涵盖15类领域特定翻译模式的结构化C到Python翻译指南来增强标准的少样本提示。受结构化思维链(SCoT)提示的启发,该指南通过关注点分离来组织翻译,将前置条件提取和后置条件生成作为不同的类别处理。在来自六个提供商(Anthropic、Mistral、Amazon、DeepSeek、Meta、Alibaba)的九个模型上进行了评估,涵盖了密集、混合专家和推理架构,BODHI改进了所有测试的模型,提升幅度从+11%到+32%。最佳配置(Claude Opus 4.6 + BODHI)达到了96.73%的Pass@1。BODHI减少了语法和语义错误,对具有足够指令跟随能力以利用结构化参考材料的模型效果最强。这些结果表明,领域知识注入是一种与模型无关的技术,显著缩小了通用代码生成与形式规范合成之间的差距。

英文摘要:

The formal verification of operating system kernels requires precise specifications that capture the intended behavior of system calls. Writing these specifications manually demands deep domain expertise, motivating the use of large language models (LLMs) to automate the process. However, in OSV-Bench, a benchmark of 245 specification generation tasks derived from the Hyperkernel OS kernel, the best reported Pass@1 is 55.10%. We propose a domain knowledge prompting method (BODHI), which augments the standard few-shot prompt with a structured C-to-Python translation guide covering 15 categories of domain-specific translation patterns. Inspired by Structured Chain-of-Thought (SCoT) prompting, the guide organizes translation by separation of concerns, addressing pre-condition extraction and post-condition generation as distinct categories. Evaluated on nine models from six providers (Anthropic, Mistral, Amazon, DeepSeek, Meta, Alibaba), covering dense, mixture-of-experts and reasoning architectures, BODHI improves every model tested, with gains ranging from +11% to +32%. The best configuration (Claude Opus 4.6 + BODHI) reaches 96.73% Pass@1. BODHI reduces both syntax and semantic errors, with the strongest effect on models that have sufficient instruction-following capability to utilize structured reference material. These results demonstrate that domain knowledge injection is a model-agnostic technique that substantially bridges the gap between general-purpose code generation and formal specification synthesis.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑