https://github.com/quchen/geb-miu-puzzle
Visualize the GEB MIU puzzle using Haskell and GraphViz
https://github.com/quchen/geb-miu-puzzle
Last synced: 3 months ago
JSON representation
Visualize the GEB MIU puzzle using Haskell and GraphViz
- Host: GitHub
- URL: https://github.com/quchen/geb-miu-puzzle
- Owner: quchen
- Created: 2013-11-26T15:29:45.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-20T23:55:23.000Z (over 11 years ago)
- Last Synced: 2025-01-22T09:09:21.879Z (5 months ago)
- Language: DOT
- Size: 40.3 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GEB MIU-puzzle graphs
=====================(Initially written around the end of 2012.)

The problem
-----------In Douglas Hofstadter's book *Gödel, Escher, Bach*, the reader is presented the following puzzle:
There are words consisting of the letters `M`, `I` and `U`. A word can be transformed into another word using one of four rules:
1. When there is `UU` somewhere in the word, it can be deleted. For example `MIUUIUU` can be transformed to `MIIUU` by deleting the first `UU`, or to `MIUUI` by deleting the second `UU`.
2. A `U` can be appended to a word whenever it ends in `I`. `MUI` becomes `MUIU` under this rule.
3. `III` can be replaced by `U`, for example `MIIIUI` becomes `MUUI`.
4. When a word begins with an `M`, everything that follows can be duplicated. For example `MUI` becomes `MUIUI`, or `MIIIIUU` becomes `MIIIIUUIIIIUU`.
When there are multple rules that can be applied at the same time, one of them can be chosen arbitrarily.
The puzzle is to start with the word `MI`, and to try to find a series of applications of the above rules to transform this word to `MU`.
The program
-----------What the program does is simply taking a word, and producing the set of all possible words that can follow from this word in one step. It then does this procedure recursively, keeping track of how each word can be reached. The whole thing is aggregated into a graph showing all the correspondences, with the colour of the arrows indicating the applied rule.
The generated graphs, `miu*.png`, picture these graphs when all words and rules up to a certain length have been tried. Therefore, `miu8.png` will only show words up to length 8. (You'll notice that the longest word here is only 7 long though - that's because in order to create a 8-long word, you have to produce longer intermediate ones.)
The program is significantly faster than actually plotting its output, so it was not optimized any further.