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

ScratchLens: 用于 Scratch 程序的透镜参数化行为等价性

ScratchLens: Lens-Parametric Behavioral Equivalence for Scratch Programs

University of Waterloo(滑铁卢大学)

Yuan Si, Jialu Zhang

AI总结:

针对块编程语言中程序等价性判定问题,提出透镜参数化等价框架SPECTRA,通过因果IR、规范化和Mazurkiewicz迹商等技术,实现高精度行为等价判定。

摘要:

两个Scratch程序可能在语法上相差甚远——重命名变量、拆分脚本、提取自定义块或重新排序初始化——但行为仍然相同;一个单块编辑,例如将阻塞广播替换为异步广播,可能产生仅在特定调度下可见的分歧。判定行为等价性对于自动反馈、评分支持和修复验证至关重要,然而树差异过于严格,单次运行动态比较对于并发、随机和时序依赖行为是不完备的。我们观察到,基于块的程序等价性是透镜参数化的:最终状态、帧轨迹、监视器、事件因果关系和调试轨迹产生不同的观察关系。SPECTRA通过因果发散现象和观察透镜的分类法使这一点明确。它将Scratch项目编译为类型化资源和语义事务的因果IR,规范化重命名、守卫和过程体,用Mazurkiewicz迹范式对同触发器并发进行商化,将程序顺序与竞争分离,并通过SMT义务和虚拟机支持的反例引导精化处理剩余前沿。结论性判定带有证据:通过双射和迹商证明等价,通过类型化见证证明差异,未解决案例保持未知。在来自真实Scratch项目的虚拟机见证突变语料库上,SPECTRA判定所有444个已验证对,并在严格评分下对见证差异对未做出任何假等价声明(0/158)。结构、纯动态和LLM基线在分类法预测的类别上失败;消融实验量化了偏序归约和透镜参数化的贡献;目标场景暴露了随机测试遗漏的模糊突变分歧。

英文摘要:

Two Scratch programs can be syntactically far apart-renamed variables, split scripts, extracted custom blocks, or reordered initialization-and still behave identically; a one-block edit, such as replacing a blocking broadcast with an asynchronous one, can create divergences visible only under specific schedules. Deciding behavioral equivalence is central to automated feedback, grading support, and repair validation, yet tree differencing is too strict and single-run dynamic comparison is unsound for concurrent, random, and timing-dependent behavior. We observe that equivalence for block-based programs is lens-parametric: final state, frame traces, monitors, event causality, and debug traces induce different observation relations. ScratchLens makes this explicit through a taxonomy of causal divergence phenomena and observation lenses. It compiles Scratch projects into a causal IR of typed resources and semantic transactions, canonicalizes renamings, guards, and procedure bodies, quotients same-trigger concurrency with Mazurkiewicz trace normal forms, separates program order from races, and handles residual frontiers through SMT obligations and VM-backed counterexample-guided refinement. Conclusive verdicts carry evidence: equivalence by bijection and trace quotient, difference by a typed witness, and unresolved cases remain unknown. On a VM-witnessed mutation corpus from real Scratch projects, ScratchLens decides all 444 validated pairs and makes 0/158 false-equivalence claims on witnessed-different pairs under strict scoring. Structural, dynamic-only, and LLM baselines fail on the classes predicted by the taxonomy; ablations quantify the contribution of partial-order reduction and lens parametricity; and targeted scenarios expose ambiguous-mutant divergences missed by random testing.

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

↑