Logic Playground



Math Playground has more than 500 free, online math games, logic games and strategy puzzles that will give your brain a workout. Play Bloxorz, 2048 and all your favorite games. Play Logic Magnets at Math Playground! Push and pull the magnetic discs to cover all the white spaces.

  • Math Playground has more than 500 free, online math games, logic games and strategy puzzles that will give your brain a workout. Play Bloxorz, 2048 and all your favorite games.
  • To make a permanent system from the Logic Noise potpourri, there's a ton of choices that need to be made. Here's a record of what I've been thinking. Chips: Clearly, we'll need at least one of each chip that's been featured in the Logic Noise series so far. That is to say: 40106, 4051, 4040, 4015, 4017, 4070, and a 4069UB.

John's
Lambda Calculus
and
Combinatory Logic
Playground

Playground

Pictured above you can see on the left the 206 bit binary lambda calculus (blc) self-interpreterin graphical notation, and on the right a 167 bit primes program,in both binary and graphical notation, together with the first 300 bits of output.You can run this right away by feeding primes.blc intothe tiny blc interpreter in perl with(Outputting much more than 300 bits in Perl will land your computer in swap hell.)or into the blc interpreter in C withOption -b denotes bit-oriented IO rather than the default byte-oriented mode.An obfuscated version of this interpreterwon as Most functionalin the 2012 International Obfuscated C Code Contest.

Json logic playground

Binary lambda calculus is explained in detail in my latest paper available inPostScript and PDF,and in somewhat less detail in this former Wikipedia entry.

I recently proposed a functional Busy Beaver which led to this OEIS entry.

Inspired by an April 13, 2008FP Lunch blog byThorsten Altenkirch,I was able to improve the constant in the symmetry-of-information theoremfrom 1876 down to 1636, and again on Mar 3, 2009 down to 1388.On September 3, 2011, Bertram Felgenhauer came up with a monadic evaluator that allows oneto keep track of the bits of input read so far, which avoids the need for symbolic reduction,and cut the constant all the way down to 667 bits. Bertram also improved the brainfuck interpreterby 64 bits.

On Mar 10, 2009, I determined the first 4 bits of the halting probability: .0001.On June 17, 2011, following a suggestion by Chris Hendrie, I changed the integer/string correspondence to avoid reversing. This big-endian representation makes lexicographic order on delimited numbers coincide with numeric order.

In March 2012 I worked out this simplest stepwise lambda calculus reducer,a necessary ingredient in a proof of the Symmetry of Information theorem.

Logic Playground

This design of a minimalistic universal computer was motivated bymy desire to come up with a concrete definition ofKolmogorov Complexity, which studies randomness of individualobjects.All ideas in the paper have beenimplementedin the the wonderfully elegant Haskelllanguage, which is basically pure typed lambda calculus with lots ofsyntactic sugar on top. An example session:showing a 10 byte program for ``stuttering', a 21 byte program for primes,and a 104 byte Brainfuck interpreter.

Thisonline course at Oberlin Collegeprovides a very readable introduction to combinators.Colin Taylor has written a very similarinterpreterfor the Lambda Calculus, whileGregory Chaitin,promotor of algorithmic information theory, wroteonefor LISP.TheUnlambdaProgramming Language is a combinator based language with input, output,delayed evaluation, and call-with-current-continuation. Interpretershave beenwritten in many languages, including c, java, perl, scheme, SMLNJ, CAML,and even in unlambdaitself!Recently, Ben Rudiak-Gould (benrgATdarkDOTdarkwebDOTcom)made available amost comprehensive combinatory logic interpreter, usingChurch numerals for character encodings. By tying the combinator code tostandard input/output, his Lazy K languagesupports familiar utilities such as sort! To top it off, heprovides a compiler (itself written in Scheme) from (a subset of)Scheme into Lazy K.Chris Barker also has severalpages of interest, including a Lambda tutorial and some highly minimalistic languages.

Before discovering how to interpret lambda calculus in binary,I figured out how to make a universal machine in binary combinatory logic.The former turns out to be a lot more descriptive, i.e. generally needingfewer bits. But for historical interest, I keep this old applet here:Actually, it slows down page loading too much, so I comment it out.

This program is an interpreter for the simplest language possible:both functions and data are represented by combinators, built upfrom S and K by application.The primitive combinators are defined by

Logic Playground Music

  • Kxy=x
  • Sxyz=xz(yz)
Combinator identifiers are all a single character.Apart from the primitive combinators S and K, the interpreter hasthe following predefined combinators:
  • I=SKK
  • Y=SSK(S(K(SS(S(SSK))))K)
  • Pxyz=zxy
  • 0xy=x
  • 1xy=y
  • ?$=0
  • ?(Pxy)=1
In the text input field, you can enter definitions such as theabove, or combinations to be evaluated. In case the result is too largeto be shown in detail, parts of it are shown as asterisks.If the result can be interpreted as a list, this is shown as an output stringwith bits 0,1 and again asterisks indicating non-bit elements.An example session is (input lines shown with a > prompt):Logic

The Simplest Oscillator

Making sound with a single logic chip is really quite easy. Let's take a look at the most basic sound producing circuit we cover in our serise. The full details of this are covered in the first installment of Logic Noise, but here we're going to boil it down even further. You need:

  • 40106 Inverter Chip
  • 2x 0.1uF capacitors
  • 2x 100k potentiometer
  • 1x 100k resistor
  • 1x 10k resistor
  • 9v battery
  • powered speakers, like computer speakers
  • Some way to connect everything together (a breadboard and jumper wires)

Here is a connection illustration:

When connecting your computer speakers you will also need a connection to ground (the blue lines in the diagram).

The heart of the circuit is shown below. The circuit makes sound using a concept called Hysteresis. This is a type of delay found in some integrated circuits. The 40106 chip we're using has a time delay between producing a low signal and a high signal; this is an oscillator. This change from low to high is at a frequency that produces a note. The protentiometer can change this frequency, making the sound higher or lower.

Brainstorming / Architecture

To make a permanent system from the Logic Noise potpourri, there's a ton of choices that need to be made. Here's a record of what I've been thinking.

  • Chips: Clearly, we'll need at least one of each chip that's been featured in the Logic Noise series so far. That is to say: 40106, 4051, 4040, 4015, 4017, 4070, and a 4069UB.
  • Hard-wired and convenient vs Flexible: This is the crux of the biscuit: what separates a Moog Modular from a Minimoog. So far we've been doing everything on a breadboard, which is the extreme of flexibility, but suffers for convenience. I'd like to be making simple sounds with three or four patch cords, and sequenced things with five or six. Not patch-cable spaghetti, but flexible.
  • Special Functions: Flexibility is great, but re-wiring up the cymbal or bass drum circuit every time would be silly. Some things will just have to be hard-wired modules. We use a few 40106 oscillators every time -- they should just work out of the box.
  • Connectors: Ideally, we'd all be rich, have huge workspaces, and the every input/output would have a well-labelled banana jack. With eight chips and 10-12 pins per chip, assuming 1in^2 and $0.50 per jack, that's something like 200 in^2 and $100 just in connectors for the whole system. That won't do. The compromise is to break everything out on male pin-headers and use female-female 'Dupont' wires as patch cables. It's cheap, small, and easily compatible with breadboards.
  • Multiples: Many connections to the chips will need to be doubled or tripled. Example: you'll want a tempo oscillator that can feed multiple clocks. I'll put two or three outputs where necessary and make up the rest with a few well-placed multiples.
  • Power: Easy. 9V battery. Small, cheap, convenient. Works with rechargeables if necessary.
  • Overall flow: Oscillators -> clocks / switches -> special modules -> output mixer. Not that it needs to be hardwired, but that keeping the order in mind will help layout.
  • Audio Out: Ideally, headphone and line out jack. In practice, it's easy to do the line out correctly, but headphones really want a dedicated driver/amplifier and their specs are all over the map. So we'll fudge and do something with the 4069UB chip that'll probably work for both. Wish I had space for a speaker, but anything plausible will have crappy bass response anyway.
  • Fine points: Inputs/outputs in the same order as on the chips, or grouped into logical sets, or grouped and ordered. Since space for writing legends is going to be tight, I think re-organizing stuff to make as much intrinsic sense is the only way to go.
  • Luxuries: It's nice to have some LEDs around to help debug. A few tie points to VCC and GND never hurt. Pulldown resistors on all the sensitive inputs?
  • Art / labels: It'd be nice to describe all the chips on the board artwork. OTOH, we're going to be cramped for space. Sexy artwork for the back side is a must.