arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.00692cs.PLcs.CCcs.FL
收藏

网格程序:一种二维、无变量的计算模型

Grid Programs: A Two-Dimensional, Variable-Free Model of Computation

Universidad de Málaga(马拉加大学);ITIS Software(ITIS软件)

Ezequiel López-Rubio

AI总结:

提出一种二维网格指令排列的计算模型,无变量和语法约束,通过栈和链表维护状态,空间控制流实现分支和循环,证明图灵完备。

摘要:

我们引入了网格程序,一种新颖的计算模型,其中程序是整数网格上指令的有限二维排列,而不是线性语句序列。三个属性使该模型与经典框架根本不同:(i) 程序是平面结构,指令指针在其中沿四个基本方向移动;(ii) 没有语法约束,因此任何指令到网格单元的分配都构成有效程序;(iii) 该模型不使用命名变量或显式内存地址。程序状态通过数据栈、地址栈和通过三个命名指针访问的循环双向链表来维护。控制流在空间上实现,分支编码为指令指针的垂直转弯。地址栈存储三元组(单元格行、单元格列、方向),使得在分支、循环和函数调用后能够精确恢复位置和朝向。我们给出了形式化操作语义,展示了涵盖算术、控制流和链表操作的代表性指令集,并详细讨论了几个示例,包括绝对值函数、阶乘计算、线性搜索算法、字符串反转程序和while循环求和。我们通过模拟任意寄存器机证明了网格程序是图灵完备的,并讨论了它们与先前二维语言(如Befunge和Funge-98)、基于栈的语言(如Forth和PostScript)以及数据流和空间计算模型的关系。网格程序为探索计算设计空间提供了新的视角,在可视化编程环境、细胞自动机启发硬件和抗混淆代码方面具有潜在应用。

英文摘要:

We introduce Grid Programs, a novel model of computation in which programs are finite two-dimensional arrangements of instructions on an integer grid rather than linear sequences of statements. Three properties distinguish this model fundamentally from classical frameworks: (i) programs are planar structures through which an instruction pointer moves in the four cardinal directions; (ii) there are no syntax constraints, so any assignment of instructions to grid cells constitutes a valid program; and (iii) the model uses no named variables or explicit memory addresses. Program state is maintained through a data stack, an address stack, and a circularly doubly linked list accessed via three named pointers. Control flow is achieved spatially, with branching encoded as perpendicular turns of the instruction pointer. The address stack stores triplets (cell row, cell column, direction), enabling precise restoration of both position and heading after branches, loops, and function calls. We give a formal operational semantics, present a representative instruction set covering arithmetic, control flow, and linked-list manipulation, and work through several detailed examples, including an absolute-value function, a factorial computation, a linear-search algorithm, a string-reversal program, and a while-loop summation. We establish that Grid Programs are Turing-complete by simulating an arbitrary register machine, and we discuss their relationship to prior two-dimensional languages such as Befunge and Funge-98, to stack-based languages such as Forth and PostScript, and to dataflow and spatial computation models. Grid Programs offer a fresh vantage point for exploring the design space of computation, with potential applications in visual programming environments, cellular-automaton-inspired hardware, and obfuscation-resistant code.

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

↑