|Metamath Music Page|
|Mirrors > Home > Metamath Music Page|
|Contents of this page||
The Metamath Music Page offers some eerie
sounds that will certainly pass for music in avant-garde circles. We
must admit to a certain fascination at hearing the steps of a proof
rendered as notes that occasionally announce themes, only to abandon
— AK Dewdney (author, The Turing Omnibus)
...instead of turning in analysis homework, I'll just bring an electronic
piano to class and play the proof for my professor.
Is it "music"? I guess that's for you to decide. It is richly structured, with underlying themes that on the one hand seem to repeat but on the other hand are interestingly unpredictable, teasing your mind as the piece progresses.
For these MIDI files, make sure your media player is set to a "piano" sound and not an "electronic organ" sound, otherwise it will sound horrible, because the sustained notes need to decay automatically. For example, I had to select Yamaha OPL3-SA SoftSynth from Devices/Properties in Microsoft Media Player on a Windows 95 computer I tried. More recent computers seem to default to the piano sound. If you are using QuickTime, it has a bug that sometimes causes a burst of loud, annoying static at the beginning of a piece; you can work around this bug by changing the MIDI settings [retrieved 3-Feb-2017 from archive.org].
I set the tempo quite fast, partly to help you decide more quickly whether it interests you. (The tempo can be slowed down by rerunning the program that generated these.) I chose to give the selections a "syncopated" character by substituting a repeated note with a silent pause, since to me it usually sounded a little better. The frenetic non-syncopated version can be interesting too, with one note for every proof step. Sometimes, syncopation has only a small effect, as in the case of the Second Peano Postulate 0:16. Other times the effect is significant; compare the syncopated1:49 and non-syncopated1:49 versions of the Triangle Inequality (and also another version). Another curious piece with a pronounced syncopated effect is the Square Root Theorem 0:41.
In deeper proofs, a kind of tension sometimes builds up, with occasional partial relief but growing overall, until finally many subproofs come together. For example, you may want to sample the Axiom of Choice Equivalent 3:51, where a crescendo slowly builds up starting at around 2:20 minutes, reaching a dramatic climax at 3:11 minutes and then suddenly cascading down to the main theme. Another frenzied, climactic piece is Zermelo's Well-Ordering Theorem 0:50. The Schröder-Bernstein Theorem 1:47 (I like this one) changes its theme during its course, starting off with a ominous staccato then breaking out into a colorful display of notes.
The music generated from these mathematical proofs stands in sharp contrast to certain other experimental music based on such mathematics as the digits of π (pi). Unlike a proof's tree structure, which is inherently suggestive of a musical score, the digits of π have no obvious pattern. To make it interesting, a human composer will often add a non-mathematical creative element such as an underlying beat with pre-selected chords and instrumentation. What one hears, then, might be based as much on the originality of the composer as on the essential nature of π: the same algorithm applied to the digits of say e (Euler's constant), or even a series of random digits, would typically sound about the same after the first few notes. The music here, on the other hand, is a raw and unadorned representation of the mathematics itself, involving few human preconceptions beyond a basic mapping needed to accommodate the Western tonal scale.
The theorems below are from (the August 2000 version of) the Theorem Sampler on the Metamath Proof Explorer Home Page. Click on a theorem name to see its proof, and click on the musical note to hear it set to music. The music is faithful to the original proofs. For example, the five sustained (lower) notes you will hear in the Law of Identity match, in order, the five steps of its proof, while the faster notes represent the construction of the formulas used in those steps.
Each of the above proofs is actually just the highest level of each theorem's proof, where typically several other theorems are pieced together to obtain the final result. In fact the Metamath database has over 7,000 other proofs - who knows what they sound like!
What does this mean? I'm not sure, other than that it says something about the complexity of the music structure. But it looks neat. [Images used by permission of Martin Wattenberg.]
Here is how to generate these melodies with the Metamath program. There are currently over 19,000 proofs in the Metamath database set.mm, each with a different melody.
Step 1. Extract the file t2mf.exe (a program that converts a text file to a MIDI file) from mf2t.zip, which you can download from http://www.hitsquad.com/smm/programs/mf2t/download.shtml [retrieved 3-Feb-2017]. (You can also download and unzip mf2t.zip. The t2mf.exe file is located in the folder mf2t\mf2t-original\mf2t\.)
Step 2. Extract the files metamath.exe (the Metamath program) and set.mm (the Metamath set theory database) from metamath.zip, which is the Metamath Program download.
Step 3. Put the three files metamath.exe, set.mm and t2mf.exe into a new directory (folder).
Step 4. Browse through the Metamath Proof Explorer proof pages to find a proof you want to listen to. For this example, we'll suppose you want to listen to the Schröder-Bernstein Theorem, whose proof page is sbth.html. The name "sbth" is the name of the theorem that you will give to the program.
Step 5. Let's say you called your new directory C:\metamidi in Step 3. To create the MIDI file for theorem sbth, open an MS-DOS or Command Prompt window (Start -> Programs -> Accessories -> Command Prompt, or Start -> Run -> command, or Start -> Run -> cmd) and type:
C:\WINDOWS>cd \metamidi C:\metamidi>metamath set.mm MM> midi sbth /parameter "fsh" Creating MIDI source file "sbth.txt"... length = 107 sec MM> exit C:\metamidi>t2mf sbth.txt sbth.midNow you can play the MIDI for the Schröder-Bernstein Theorem 1:47 by clicking on sbth.mid in the Windows Explorer.
The parameter argument is specified by a combination of the following letters, with no spaces separating them:
You can see what theorems are available by typing "show labels". In general you can use "help" to guide you, including "help midi".
Tip:The "midi" command in Metamath will not destroy existing files, but will rename an existing one with ~1 appended (for example, an older sbth.txt would be renamed sbth.txt~1), an existing ~1 to ~2, etc. up to ~9. (An existing ~9 is deleted.) This makes it safer to use but also will clutter up your directory, so you may want to clean them out occasionally.
Tip: There is a problem with t2mf.exe: it can only handle Microsoft's 8.3 file format (8-character file name, period, and 3-character extension). It will complain if you ask it to convert pm2.11.txt because a file name can't have 2 periods, so you have to use the "real" Microsoft file name such as PM211~1.TXT which you can see with the MS-DOS DIR command (or DIR/X in the Windows XP Command Prompt). Alternately you could rename the file to, say, pm2_11.txt before running t2mf.exe. I am not the author of t2mf.exe and unfortunately have no other solution at this point.
In 2006, Luca Ciciriello modified the program to run on MacOSX. Download and unzip mf2t.zip. The files are located in mf2t/mf2t-Mac/. I have not tested it personally.
The t2mf program was written in 1991, before C was standardized by ANSI, and it will not compile on modern compilers. However, if you wish to attempt to convert it to modern C, download and unzip mf2t.zip. The source files are located in mf2t/mf2t-original/mf2tsrc/, which includes the sources for t2mf. You may also wish to consult the sources for Luca Ciciriello's Mac upgrade, located in mf2t/mf2t-Mac/Midi_MacOSX_Xcode/Midi_MacOSX_Xcode/midisrc/t2mf/. If you are successful, let me know and I will add it to the mf2t.zip download. Note that the authors Tim Thompson (original author) and M. Czeiszperger agreed to place their code in the public domain, but I was unable to contact Piet van Oostrum who made some additional modifications to the code.
For Unix/Linux and MacOSX:
Assuming you have successfully compiled t2mf, next download the file metamath.tar.gz. Type:
$ tar -xzf metamath.tar.gz
This will create a directory called "metamath". To compile the program with gcc, type
$ cd metamath $ gcc m*.c -o metamathNow you can run the Metamath program, then t2mf, to create the MIDI file:
$ ./metamath MM> read "set.mm" MM> midi sbth /parameter "fsh" Creating MIDI source file "sbth.txt"... length = 107 sec MM> exit $ t2mf sbth.txt sbth.mid
See the notes above for Windows for information on the parameters.
MM> save proof id1 / normalThen we type
MM> show proof id1 / allThis will show the microsteps that construct wffs, as well as regular proof steps, in the form of an indented proof tree. The notation for proofs is described in the Metamath book (1.3Mb) if you are interested. You'll see:
1 wph=wph $f wff ph 2 wph=wph $f wff ph 3 wps=wph $f wff ph 4 wps=wi $a wff ( ph -> ph ) 5 wph=wi $a wff ( ph -> ( ph -> ph ) ) 6 wph=wph $f wff ph 7 wps=wph $f wff ph 8 wps=wi $a wff ( ph -> ph ) 9 wph=wph $f wff ph 10 wps=wph $f wff ph 11 min=ax-1 $a |- ( ph -> ( ph -> ph ) ) 12 wph=wph $f wff ph 13 wph=wph $f wff ph 14 wps=wph $f wff ph 15 wph=wi $a wff ( ph -> ph ) 16 wps=wph $f wff ph 17 wps=wi $a wff ( ( ph -> ph ) -> ph ) 18 wph=wi $a wff ( ph -> ( ( ph -> ph ) -> ph ) ) 19 wph=wph $f wff ph 20 wph=wph $f wff ph 21 wps=wph $f wff ph ...
Reading down, you can see the indentation levels (each
level indents 2 more spaces) are
We want to fit the proof within a desirable maximum dynamic range of note frequencies, which I defined as 27 < n < 104, where n is the midi note number. We obtain an the largest possible integer "scale factor", with a maximum of 4, that allows the music to fit in the dynamic range. For the id1 proof, the scale factor will be 4.
We also compute a "baseline" note which allows the proof to fit in the dynamic range. For the id1 proof, the baseline is 61.
We multiply the indentation level by the scale factor 4 and add it to the baseline. In addition, whenever we encounter a "logical" (real) proof step (as opposed to a formula-building proof step), identified by a |- in the proof listing, we shift the note down by 12 (one octave) and sustain it rather than turning it on and off.
So in this example the midi note numbers will be
where 53 = 65-12 is the shifted note of step 11, which you can see has a |- in it in the proof listing.
Finally, if syncopation is selected, which was the case for all the
selections on this page, repeated notes are replaced with silence. (The
sustained notes are not syncopated.) So what we hear through step 12
where the 53 is the first sustained note.
Now, listen carefully to the Law of Identity 0:05, and you will hear that the first 12 notes and pauses match exactly the above sequence.
"Kind of amusing in that the entire output of these pages proves a theorem of its own: that not all mathematicians make good music (take THAT, Douglas Hofstadter!). Mis-step one was to program using only equal distances between pitches (MIDI note numbers), resulting in endless whole-tone melodies." —musician Tom Djll [external](By the way, the "b", "w", and "i" parameters that are already available may appeal to more conventional musical tastes. An example is the Triangle Inequality 1:49 played with the black keys, using the parameter string "fsbi". To me it lacks some of the vaguely disturbing eeriness of the other versions, and there is a certain gentle pleasantness to it. What do you think?)
To modify the algorithm, download the Metamath program, which includes the source code. In the file mmcmds.c, at the very end you will find the function outputMidi() which generates the MIDI file. I put in a lot of comments, so hopefully you won't find it too hard to follow what it does. I recommend confining any experiments to this function, which gives you access to everything you should need. Let me know if there is something you don't understand.
Tip: In Metamath program download, the C programs are stored in Unix ASCII format with no carriage-return at the end of lines. If you are using Windows, see the note on text files at the end of the download help section.
The user parameter from the "/parameter" argument in the Metamath "midi" command is just an arbitrary string that is not syntax-checked, and you can use it to put in your own parameters to experiment with.
To compile the program, you need an ANSI C compiler such as gcc, which is built into Linux and available free for Windows as part of Cygwin [external]. Assuming you have only the Metamath source files in your directory, you type in the Cygwin or Linux shell
gcc m*.c -o metamath.exewhere you omit the .exe in Unix/Linux.
"Natural music has fascinated me for some time.... It is a strange music that seems to speak to the soul in a way that manufactured music cannot."
The "Abstricombo" arrangement is copyright © 2000 by DarkBlues.
The "78 RPM record label" image may be copyright and/or trademarked by says-it.com. The "Shape of Song" images are copyright by Martin Wattenberg. Any short attributed quotations may be copyright by their authors. All other text and images on this page are placed in the public domain.
See also Metamath Web Site - Copyright Terms.
page was last updated on 3-Feb-2017.
Your comments are welcome: Norman Megill
|W3C HTML validation [external]|