事件驱动块程序的可携带证书转换
Certificate-Carrying Transformation of Event-Driven Block Programs
AI总结:
针对Scratch等块语言,提出一种可携带证书的源到源重写方法,通过可信检查器重新计算每个行为保持条件来确保正确性,并在Lean中形式化协作帧精化定理,在300个真实项目上实现94.3%的接受率且零误接受。
摘要:
基于块的最终用户语言(如Scratch)运行着数千万个程序。现有工具通过程序分析和测试来建立行为保持,但缺乏经过检查的保证。我们将优化转化为可携带证书的源到源重写。一个不可信的优化器提出一个重写;一个可信的、故障关闭的检查器只有在显式观察镜头下重新计算重写的行为保持所依赖的每个侧条件后才接受它。检查器是唯一的权威:给定一个正确的检查器和一组小的、明确陈述的模型到虚拟机假设,优化器错误无法产生不合理的接受。观察镜头是一个参数,核心正确性论证是一个协作帧精化定理:在任何线程观察到它之前,在一个没有线程让步的窗口内被覆盖的写入可以被移除。我们在Lean中机械化这个定理,并展示一个参数化陈述覆盖了实例化到变量状态和渲染器状态的两个具体重写族。我们为六个重写族构建了一个检查器,并在300个真实Scratch项目上进行了评估。检查器在94.3%的项目(300个中的283个)上接受了行为保持的重写;每个项目的认证成本低于十分之一秒;一个跨族对抗性活动(4278个扰动重写)产生了零误接受。一次审计发现了每个族测试套件遗漏的八个误接受;现在每个都被拒绝。一项消融实验剥离了语义侧条件,仅保留分析和测试,交付了虚拟机确认改变行为的重写;完整检查器拒绝了每一个。结果展示了如何为并发、事件驱动的最终用户语言提供行为保持保证。检查器重新计算每个所需条件,而不是信任优化器声明,从而保持可信基础很小。
英文摘要:
Block-based end-user languages such as Scratch run tens of millions of programs. Existing tools establish behavior preservation through program analysis and testing without a checked guarantee. We turn optimization into certificate-carrying source-to-source rewriting. An untrusted optimizer proposes a rewrite; a trusted, fail-closed checker accepts it only after recomputing every side condition that the rewrite's behavior preservation depends on under an explicit observation lens. The checker is the sole authority: given a correct checker and a small, explicitly stated set of model-to-VM assumptions, an optimizer bug cannot mint an unsound acceptance. The observation lens is a parameter, and the central soundness argument is a cooperative-frame refinement theorem: a write overwritten before any thread observes it, within a window in which no thread yields, can be removed. We mechanize this theorem in Lean and show that one parametric statement covers two concrete rewrite families instantiated to variable state and renderer state. We build a checker for six rewrite families and evaluate it on 300 real Scratch projects. The checker accepts a behavior-preserving rewrite on 94.3% of projects (283 of 300); certification costs under one tenth of a second per project; and a cross-family adversarial campaign of 4,278 perturbed rewrites produces zero false accepts. An audit found eight false accepts the per-family test suites missed; each is now rejected. An ablation that strips the semantic side conditions, leaving analysis and testing alone, ships rewrites the virtual machine confirms change behavior; the full checker rejects every one. The result shows how to provide behavior-preservation guarantees for a concurrent, event-driven, end-user language. The checker recomputes every required condition instead of trusting optimizer claims, keeping the trusted base small.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。