Arbitrary memory emulation

From Esolang
(Redirected from AME)
Jump to navigation Jump to search

Arbitrary memory emulation is a method of encoding memory which, given a value that can be infinite in size without precision loss, allows for arbitrary memory in the event that such is not possible normally. AME can be used to emulate flat data structures like stacks, tapes, and arrays, and with modifications can encode more complex structures.

Structure

Additive AME

Let be the value which will be used for aAME. We define a positive integer greater than 1 which will denote the maximum size of each "cell" in memory, where a cell can have an integer value of . The index of each cell is denoted as . The relative position of each cell in memory, denoted by Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle x} , is Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle S^{i}} , where dividing by results in the cell's value in memory, and multiplying any value Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle v} by results in its relative value. Each cell is times higher than the previous one.

For any given memory structure Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle M} with cells , is equivalent to Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle \sum _{i=0}^{|M|-1}M_{i}S^{i}} .

Array Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 3} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 15} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 32}
Relative position Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 100^{0}=1} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 100^{1}=100} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 100^{3}=1000000}
Relative value Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 1\cdot 1=1} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 100\cdot 3=300} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 10000\cdot 15=150000}
Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle A=1+300+150000+32000000=32150301}

Multiplicative AME

Let be the value which will be used for mAME. For each integer Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle (-\infty ,\infty )} in memory with index , its relative value corresponds to the -th prime raised to its own value.

For any given memory structure Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle M} with integers Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle (-\infty ,\infty )} , is equivalent to .

Array Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 3} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 15} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 32}
Prime Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle \mathbb {P} _{1}=2} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle \mathbb {P} _{3}=5} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle \mathbb {P} _{4}=7}
Relative value Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 2^{1}=2} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 3^{3}=27} Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle 5^{1}5=30517578125}
Failed to parse (Conversion error. Server ("https://en.wikipedia.org/api/rest_") reported: "Cannot get mml. Server problem."): {\displaystyle A=1104427674243920676822877355}

Operations

Operation Equation (aAME) Equation (mAME)


Note that this algorithm is unreliable if stores any trailing zeroes. It is more reliable to manually track this value by incrementing or decrementing as values are added or removed.

Such a function is not possible to construct in mAME. Manual tracking is required instead.

Turing-completeness

A typical requirement for Turing-completeness is that the language has access to unbounded memory, regardless of the size of each cell. AME "flips" this case, where values of infinite size can be used for computational power, regardless of how many memory addresses there actually are. However, this requires that the language is able to handle values of infinite size without precision loss, and the language has the necessary space in order to compute and thereafter process and transform the memory.

In order for a target language to implement AME of either form, it must be able to calculate multiplication, division, and perform some sort of equality check against zero.

Variations

Payload-flag model (aAME)

A variation used by Funciton assigns a fixed length to each cell, reserving the last bit to continue the value into the next cell, allowing an unbounded size for each cell.[note 1]

Each cell is split into a payload of size and a flag of size , both greater than one. The size of the flag determines how many unique states it has (e.g. for two distinct states). The true size of each cell, holding both the payload and flag, is . To extract the payload and flag from a cell, the formulae and are used respectively.

For a simple example, and to match Funciton's case, take cells where and . When , the cell is denoted as having a value greater than , and the next few cells contain the entire amount. Given this, it can be calculated that any value will have to span cells, and the value of each cell is , adding an additional if is not the last cell.

Array
Size
Split form Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \left\lfloor \frac{24 \ \mathrm{mod} \ 100}{10} \right\rfloor = 2} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 119 \ \mathrm{mod} \ 10 + 10 = 19} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \left\lfloor \frac{119 \ \mathrm{mod} \ 100}{10} \right\rfloor + 10 = 11} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle \left\lfloor \frac{119 \ \mathrm{mod} \ 1000}{100} \right\rfloor = 1}
Relative value Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 20^0 \cdot 5 = 5} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 20^1 \cdot 13 = 260} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 20^2 \cdot 1 = 400} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 20^3 \cdot 14 = 112000} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 20^4 \cdot 2 = 320000} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 20^5 \cdot 19 = 60800000} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 20^6 \cdot 11 = 704000000} Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle 20^7 \cdot 1 = 1280000000}
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle A = 2045232665}

Usage

Notes

  1. Funciton's arrays use a slightly different structure than what is described here, making the actual size of each cell vary.