The Mystery of the Monte Carlo Lock

Bruce Ediger

February, 2013

This web page implements some of the various formal systems in Raymond Smullyan's neglected classic, The Lady or The Tiger. Lots of web pages exist explaining the titular "Lady or Tiger" problems in the book, but few have bothered to emulate the Monte Carlo Lock, or any of McCulloch's "logic machines".


A Curious Number Machine

Input:
Output:


This JavaScript program emulates McCulloch's Machine as Smullyan describes in Chapter 9, A Curious Number Machine

  1. For any number X, 2X produces X
  2. For any numbers X and Y, if X produces Y, 3X produces the associate of Y

The associate of any number X is X2X. Smullyan uses "number" to mean "string of symbols", where a symbol is one of '1', '2', '3'... '9'. This emulated machine is a bit more forgiving of improper inputs than the machine Smullyan describes, as it will allow '0' (zero) and any single US ASCII letter as a symbol.


Craig's Law

Input:
Output:



This JavaScript program emulates McCulloch's Machine with two additional rules of behavior, as in Chapter 10, Craig's Law

  1. For any number X, 2X produces X
  2. For any numbers X and Y, if X produces Y, 3X produces the associate of Y, the number Y2Y
  3. For any numbers X and Y, if X produces Y, 4X produces the reverse of Y
  4. For any numbers X and Y, if X produces Y, 5X produces the repeat of Y
The reverse of a number is the lexical reverse of the symbols making up the number. The number 789 has reverse 987.

The repeat of a number is the number (which is a string) concatenated with itself: the repeat of 789 is 789789.


Scratch Space

Scratch:

Scratch space exists to help you check your answers. Suppose you want to solve chapter 10, problem 9, a number that produces the associate of its own repeat. In the "Craig's Law" input field, you enter your candidate. Click "Input to scratch" in the "Craig's Law" box, then click "repeat" and "assoc" buttons in the "Scratch Space" box to see the associate of the repeat of your candidate number.

The "Scratch Space" tool can also work the other way: use its buttons to build up a number, then draw that number into an "Input" field before computing what your number produces.




McCulloch's New Machine

Input:
Output:



Smullyan describes McCulloch's New Machine in Chapter 13, The Key

M-IFor any number X, 2X2 produces X.
M-IIIf X produces Y, 6X produces 2Y.
M-IIIIf X produces Y, 4X produces the reverse of Y.
M-IVIf X produces Y, 5X produces YY.

Monte Carlo Lock

Input:
Output:

Martin Farkus notes on the lock

  • Property Q: For any combination x, the combination QxQ is specially related to x.
  • Property L: If x is specially related to y, then Lx is specially related to Qy.
  • Property V (the reversal property: If x is specially related to y, then Vx is specially related to the reverse of y.
  • Property R (the repetition property: If x is specially related to y, then Rx is specially related to yy.
  • Property Sp: If x is specially related to y, then if x jams the lock, y is neutral, and if x is neutral, then y jams the lock.

My emulator does not implement Property Sp - it gives no indication of whether the input combination unlocks or jams the lock or is neutral. The Monte Carlo Lock must be an intricate piece of machinery indeed, if it actually does all of Property Sp.

Marnix Klooster's Mysterious Monte Carlo Lock

Marnix Klooster wrote a very nice derivation of a combination that unlocks the Monte Carlo lock. His notation is a bit different, so I include a version of the Monte Carlo lock emulator in Klooster's notation.

Input:
Output:

Klooster uses [3x] = y2y to mean the same thing that Smullyan means when he writes "if x produces y, 3x produces the associate of y".

  • (A) [2x2] = x
  • (B) [1x] = 2[x]
  • (C) [5x] = <[x]>  <x> means reverse of x
  • (D) [9x] = [x][x]

More classes of combinations that unlock the lock.

Programming Notes

Implementation

I implemented each of the machines or "locks" as a pretty simple JavaScript program. They all run in your browser, locally. Because the only acceptable numbers have a quote character or digit in them ('2' or 'Q'), the recursion terminates readily. Either the recursion encounters a quote, or it encounters a digit that has no rule (not a '2', '3', '4', '5' or '6').

Initially, I found Smullyan's terminology a bit confusing. He phrased the recursion rules as "If X produces Y, then MX produces something". Once I realized that you recurse on the remaining characters in the string until you get to a quote character, I found it simple to write the JavaScript implementations.

Somewhat theoretical considerations

The logical machines and locks comprise simple, recursive programs, with a stop condition on a quoted sub-string. All operations (repeat, reverse, associate) happens on the way back "up" the recursion. Does this mean that a Simple Recursive Function (in the mathematical logic sense) could compute the output of the various "locks" or "machines" on this page?

Mathoverflow features a technical explanation of solutions to the Monte Carlo Lock.


I renounce all rights - do with this as you will.