具有纯粹基于堆栈的内存的编程环境?

发布于 2024-11-27 03:24:59 字数 1456 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

久夏青 2024-12-04 03:24:59

在计算理论中,这样的计算机仍然是图灵等价的(至少在真正的 RAM 计算机的意义上......即使它们对内存量有限制)。一台具有两个堆栈(任意堆栈,但可能不是无限容量)的机器就足够了。

注意:这是为了表达算法,而不是进行 I/O。确实,由于内存有限,您无法接受非常规语言(即解决所有算法问题)...这意味着您的假设计算机和真实计算机只能接受常规语言(并且只能接受其中的某些语言!)如果假设内存有限。由于我们有大量内存,因此这个问题通常会被忽略。

In the theory of computation, such computers would still be Turing equivalent (at least in the sense that real RAM computers are... even they have a limit to the amount of memory). A machine with two stacks (of arbitrary, though perhaps not infinite) capacity would suffice.

Note: this is for expressing algorithms, not doing I/O. Really, with finite memory, you can't accept non-regular languages (I.e. Solve all algorithmic problems)... Meaning that your hypothetical computer, and real computers, can only accept regular languages (and only certain ones of those!) if finite memory is assumed. Since we have lots of memory, this problem is normally ignored.

別甾虛僞 2024-12-04 03:24:59

如果您的程序的内存仅限于一组固定的堆栈(以及我假设的寄存器),那么程序的行为可以仅根据 PC 寄存器和所有这些堆栈的顶部来确定。由于这些堆栈具有预定的固定大小,因此您可以将整个系统的行为模拟为有限自动机。特别是:

  1. 自动机对于这些堆栈和寄存器的位的每种可能的配置都有一个单一的状态。这可能会使自动机呈指数级巨大,但它仍然是有限的。

  2. 如果程序处于第一个状态,则程序将执行一条指令,该指令会以某种方式更改内存,使其看起来像第二个状态下的内存配置,则自动机会在两个不同状态之间进行转换。< /p>

因此,您的程序可能不会比 DFA 更强大。因此,可以使用常规语言来描述其状态的转换顺序,因此您的程序无法例如打印出平衡的括号系列,或打印出所有素数等。

但是,它基本上是 弱于 DFA。如果所有内存都必须存储在有限多个堆栈中,那么您就无法在大于所有堆栈加在一起的输入上运行程序(因为您没有空间来存储输入)。因此,您的程序本质上将通过成为 DFA 来工作,该 DFA 从与堆栈的初始配置相对应的许多可能状态之一开始。因此你的程序只能有有限多个可能的行为序列。

If your program's memory is limited to a fixed set of stacks (and, I'm assuming, registers), then the behavior of the program can be determined solely from the PC register and the tops of all of these stacks. Since these stacks have a predetermined fixed size, you could simulate the behavior of the entire system as a finite automaton. In particular:

  1. The automaton has a single state for every possible configuration of the bits of these stacks plus the registers. This might make the automaton exponentially huge, but it's still finite.

  2. The automaton has transitions between two different states if, if the program were in the first state, the program would execute an instruction that would change memory in a way that caused it to look like the memory configuration in the second state.

Consequently, your program could be no stronger than a DFA. The sequence of transitions through its states could thus be described using a regular language, so your program could not, for example, print out balanced series of parentheses, or print out all the prime numbers, etc.

However, it is substantially weaker than a DFA. If all memory has to be stored in finitely many stacks, then you can't run the program on inputs any larger than all of the stacks put together (since you wouldn't have space to store the input). Consequently, your program would essentially work by being a DFA that begins in one of many possible states corresponding to the initial configuration of the stacks. Thus your program could have only finitely many possible sequences of behaviors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文