Eodermdrome

From Esolang
Jump to: navigation, search

Eodermdrome is a graph-rewriting tarpit created in 2008 by User:ais523.

Syntax

An Eodermdrome program consists of a sequence of commands, separated by whitespace; each command consists of the following, separated by whitespace:

  • optionally, a set of 1 or more characters enclosed in parentheses (if a closing parenthesis is in that set, it must be the first character of that set); this is the input set of the command
  • a string of letters, representing a graph (see below); this is the match subgraph
  • optionally, a string of 1 or more characters enclosed in parentheses (the first character may be a closing parenthesis, but none of the others may be); this is the output string of the command
  • a string of letters, representing a graph (see below); this is the replacement subgraph

Graphs are written with a string of lowercase letters; each unique letter in the string represents a different node of the graph, and if the same letter is used more than once, it refers to the same node of the graph. There is an arc between any two letters which are consecutive in the string, but not otherwise. For instance, the string abcdae would map to the following graph:

c-d
| |
b-a-e

Comments can be included in the source file between commas, and are legal anywhere whitespace would be; also, any strings of whitespace that contain punctuation marks other than commas and parentheses are ignored along with the punctuation marks they contain (so abc. def is equivalent to abcdef).

Semantics

An Eodermdrome program works by repeatedly rewriting a graph, which represents the internal state of the program. At the start of any Eodermdrome program, the internal state is the graph corresponding to the string thequickbrownfoxjumpsoverthelazydog. Which letter is used for which node is immaterial between commands; it's the shape of the graph that matters, not the letters used to define it.

Execution of the program works by repeatedly running commands; the commands do not run in any particular order and can run any number of times. However, commands only run if all their prerequisites are met. If no command in the program has its prerequisites met, the program will exit; otherwise, an unspecified command whose prerequisites are met will be run (this means that an interpreter can always choose the first, or the last, or a random command, or use any other method to determine which command runs, if more than one can run).

If a command has an input set, it has a prerequisite that the next character to be read in from standard input must be a member of the set.

All commands also have a prerequisite based on their subgraphs and the internal state graph: the match subgraph must be a subgraph of the internal state graph (i.e. there is a 1-to-1 mapping of a subset of the internal state graph's nodes to the match subgraph's nodes, such that all arcs in the match subgraph also exist between the corresponding nodes in the internal state graph), and also all closed nodes in the match subgraph must have the same degree as the corresponding node in the internal state graph. A node in a match subgraph is open if the letter used to describe it in the match subgraph is also used to describe a node in the replacement subgraph, and closed otherwise; likewise, a node in a replacement subgraph is open if the letter used to describe it in the replacement subgraph is used to describe a node in the match subgraph, and closed otherwise.

When a command runs, it does the following, in order:

  1. Removes a character from standard input, if it has an input set
  2. Prints its output string to standard output, if it has one
  3. Deletes all arcs in the internal state graph corresponding to arcs in the match subgraph
  4. Deletes all nodes from the internal state graph that correspond to closed nodes in the match subgraph
  5. Creates a node in the internal state graph corresponding to each closed node in the replacement subgraph
  6. For each arc in the replacement subgraph, create an arc in the internal state graph corresponding to it (i.e. such that if two nodes are joined in the replacement subgraph, an arc is created between the two nodes in the internal state graph that correspond to them)

Initial state graph

Eodermdrome initial state graph.png

The initial state graph is planar, and has no cycles of length 3 or 5, but has every other cycle length from 4 up to the maximum of 18. It has 1 node of degree 1, 21 nodes of degree 2, 2 nodes of degree 4, one node of degree 5 and one node of degree 8. It has a single nontrivial automorphism, switching w and f.

Implementation

There exists a proof-of-concept interpreter for Eodermdrome, written in python. It uses a modified Ullmann's algorithm for selecting match graphs and is capable of executing a couple of commands per second. Source code can be found on GitHub.

Efficiently implementing Eodermdrome is impaired by the fact that selecting match graphs requires an implementation of the subgraph isomorphism problem, which is NP-complete in its base case.

Computational class

The following program is untested. However it is supposed to be a Bitwise Cyclic Tag interpreter, proving Eodermdrome to be Turing complete. However, this is in the sense of "at least one universal Turing machine which takes external input can be simulated in Eodermdrome" (see .) Eodermdrome cannot be Turing-complete in the sense of "Every Turing machine can be mapped to an Eodermdrome program", because there are only a finite number of Eodermdrome programs when I/O matching is not considered.

A version including ASCII drawings of relevant subgraphs is available.

Note: BCT program part should be at least 3 characters long.

thequickbrownfoxjumpsoverthelazydog (Program: ) miewehit
(1) byanad buguramat
(0) byanad buramat
(
) sehened (Data: ) sihiabruramat
(
) ianadabar (Running: ) iamtmabar
abrand (end.
) a
psewelklihiandnabarfrux (1 appended, ) chewelisksiamtmaybobyargruz
psewelklihiandnarfryx (1 not appended, ) chewelisksiamtmargrux
scewelklihiandnabarfrux (0 appended, ) wheliosokoiamtmaybyargruz
scewelklihiandnarfryx (0 not appended, ) wheliosokoiamtmargrux
sceweihiandnarfrux (1 deleted, ) sowoieheiamtmaur
sceweihiandnarfryx (0 deleted, ) sowoieheiamtmaurux