We study when a programming language can emulate programs written in that same language without delegating the guest program back to the host evaluator or compiler. We call this property emulation-completeness. The central observation is that Turing-completeness by itself is not enough: a self-emulator must not only compute the guest program's result, but must also account for the guest-visible state on which realistic programs depend, including control flow, exceptions, callbacks, timing, memory usage, and runtime metadata such as stack traces or line numbers. This paper is a systematization paper. Its contribution is not a new emulator implementation, but a precise vocabulary and a structured taxonomy for reasoning about self-emulation. We distinguish source-level evaluation from compiled-code emulation, define syntactic and compiled-code emulation-completeness, and separate weak from strong emulation-completeness according to how much observable runtime behavior must be preserved. We then organize the requirements into two classes: language-side requirements, which determine whether the guest semantics can be represented explicitly inside the language, and emulator-side requirements, which determine whether the resulting emulator can faithfully mask or reproduce relevant observations. The discussion is grounded by concrete examples, including publicly documented details from Erlang, where argument limits, bitstring pattern matching, and message reception expose subtle mismatches between direct execution and self-emulation. The resulting framework is intended as guidance for language designers, implementers of evaluators and emulators, and researchers interested in secure sandboxing, decompilation, and reflective execution.
翻译:我们研究编程语言是否能够在不将客程序委派给宿主求值器或编译器的情况下,模拟用同一种语言编写的程序。我们将这一性质称为自模拟完备性。核心发现是:图灵完备性本身并不足够——自模拟器不仅需要计算出客程序的结果,还必须处理现实程序所依赖的客可见状态,包括控制流、异常、回调、时序、内存使用以及运行时元数据(如栈追踪或行号)。本文是一篇系统化论文,其贡献并非实现新的模拟器,而是提供一套精确的术语和结构化的分类法,用以推理自模拟问题。我们将源代码级求值与编译代码模拟区分开来,定义了语法层自模拟完备性和编译代码自模拟完备性,并根据需保留的运行时可观测行为程度,将弱自模拟完备性与强自模拟完备性加以区分。随后,我们将需求组织为两类:语言侧需求(决定客语义能否在语言内部显式表达)和模拟器侧需求(决定所得模拟器能否忠实地掩盖或复现相关观测现象)。讨论以具体示例为支撑,包括Erlang语言中公开记录的技术细节——参数限制、位串模式匹配以及消息接收揭示了直接执行与自模拟之间的微妙不匹配。由此形成的框架旨在为语言设计者、求值器与模拟器实现者,以及对安全沙箱、反编译和反射执行感兴趣的研究人员提供指导。