Category Archives: Good Math

Simple Programming in Binary: Binary Combinatory Logic

For reasons that I’ll explain in another post, I don’t have a lot of time for writing a long pathological programming post, so I’m going to hit you with something short, sweet, and beautiful: binary combinatory logic.

I’ve written in the past about lambda calculus, and it’s equivalent variable-free form, the SKI combinator calculus. I’ve ever written about other combinator calculus based languages, like Unlambda and Iota.

Binary combinatory logic, aka BCL, is a language based on SKI calculus – except that it encodes the entire thing into binary. Two characters, plus two rewrite rules, and that’s it – a complete
combinator calculus based programming language.

SKI combinator calculus is a simple variable-free calculus with three constructs: S, K, and I; and I isn’t really primitive, but can be defined in terms of S and K.

  1. S=λx y z.x z (y z)
  2. K=λx.(λy.x)
  3. I=λx.x=SKK

So, in BCL, S is written “01”; K is written “00”. And there are two rewrite rules, which basically define “1” without a zero prefix as a a paren-like grouping construct:

  1. “1100xy”, where “x” and “y” are valid BCL terms (that is, complete syntactic units),
    gets rewritten to be “x”. If you follow that through, that means that it reduces to ((Kx)y).
  2. “11101xzy” gets rewritten to “11xz1yz”. Again, following it through, and that
    reduces out to “(((Sx)y)z)”.

So, following on unlambda’s method of handling IO, “hello world” in BCL is:

010001101000010000010110000000000101101111
000010110111110011111111011110000010011010

bcl.gif

And here’s the really neat thing. Write an interpreter for BCL in BCL. Take the bit string that results, and convert it to a bitmap. That’s what’s over the right here. So, for example, the first line is “1111100000111001”; keep going, and you’ll find the entire BCL interpreter.

Basics: Tautology (with a free bonus rant!)

Today’s bit of basics is inspired by that bastion of shitheaded ignorance, Dr. Michael Egnor. In part of his latest screed (a podcast with Casey Luskin of the Discovery Institute), Egnor discusses antibiotic resistance, and along the way, asserts that the theory of evolution has no relevance to antibiotic resistance, because what evolution says about the subject is just
a tautology. (I’m deliberately not linking to the podcast; I will not help increase the hit-count that DI will use to promote it’s agenda of willful ignorance.)

So what is a tautology?

A tautology is a logical statement which is universally true, by nature of its fundamental structure. That is, even without knowing anything about what the statement means,
you can infer that it must be true.

Continue reading

Theories, Theorems, Lemmas, and Corollaries

I’ve been getting so many requests for “basics” posts that I’m having trouble keeping up! There are so many basic things in math that non-mathematicians are confused about. I’m doing my best to keep up: if you’ve requested a “basics” topic and I haven’t gotten around to it, rest assured, I’m doing my best, and I will get to it eventually!

One of the things that multiple people have written to be about is confusion about what a mathematician means by a theory; and what the difference is between a theory and a theorem?

Continue reading

Basics: Modal Logic

I’ve received a request from a long-time reader to write a basics post on modal logics. In particular, what is a modal logic, and why did Gödel believe that a proof for the existence of God was more compelling in modal logic than in standard predicate logic.

The first part is the easy one. Modal logics are logics that assign values to statements that go beyond “This statement is true” or “This statement is false”. Modal logics add the concepts of possibility and necessity. Modal logic allows statements like “It is necessary for X to be true”, “It is possible for X to be true”, etc.

Continue reading

Basics: Going Meta

In math and computer science, we have a tendency to talk about “going meta”. It’s actually a
pretty simple idea, which tends to crop up in other places, as well. It’s also one of my favorite concepts – the idea of going meta is just plain cool. (Not to mention useful. There’s a running joke among computer scientists that the solution to any problem is to add a level of indirection – which is programmer-speak for going meta on constructs inside of a programming language. Object-orientation is, in some sense, just an example of how to go meta on procedures. Haskell type-classes are an example of going meta on types.)

Going meta basically means taking a step back, and instead of talking about some subject X, you talk about talking about X.

Continue reading

The Bad Ballet of Regular Expressions: Pathological Programming in Thutu

For today’s installation of programming insanity, I decided to go with a relative of Thue, which is one of my favorite languages insane languages that I wrote about before. Thue is a language based on a rewriting system specified by a semi-Thue grammar. Todays language is called Thutu (pronounced tutu); it’s a string rewriting system like Thue, only it’s based on regular expressions instead of grammars, and it’s even got regular expression-based control flow mechanisms, making it a sort of hybrid language.

The scary thing about Thutu is that it’s not all that different from a language I’ve wanted to find some time to write myself – except that the one I want to write isn’t intended to be pathological. I’ve never stopped missing Teco for writing text processing programs; and since
my TECO programs tended to be roughly of the form: “Find something matching this pattern, and then take this action”, a regular-expression based language would make a lot of sense.

But anyway, today we’re looking at Thutu, which is a deliberately obscure version of this idea.

Continue reading

Books for Young Mathgeeks: Rabbits, Rabbits, Everywhere

As promised, another review of a childrens math book. Tonight, my daughter and I read “Rabbits, Rabbits, Everywhere: a Fibonacci Tale” by Ann McCallum.

This time, I have absolutely no complaints. “Rabbits” is a beautifully told story, with delightful artwork, which makes the basic idea of the Fibonacci series understandable to a first grader. It’s a wonderful book, which I recommend absolutely without reservation. If you have a child around 1st grade age, buy this book.

Continue reading

Basics: Axioms

Today’s basics topic was suggested to me by reading a crackpot rant sent to me by a reader. I’ll deal with said crackpot in a different post when I have time. But in the meantime, let’s take a look at axioms.

Continue reading

Simplices and Simplicial Complexes

One thing that comes up a lot in homology is the idea of simplices and simplicial complexes. They’re interesting in their own right, and they’re one more thing that we can talk about
that will help make understanding the homology and the homological chain complexes easier when we get to them.

A simplex is a member of an interesting family of filled geometric figures. Basically, a simplex is an N-dimensional analogue of a triangle. So a 1-simplex is a line-segment; a 2-simplex is a triangle; a three simplex is a tetrahedron; a four-simplex is a pentachoron. (That cool image to the right is a projection of a rotating pentachoron from wikipedia.) If the lengths of the sides of the simplex are equal, it’s called a regular simplex.

Continue reading

Books for Young Mathgeeks: "A Place for Zero"

I recently had the opportunity to get hold of a collection of children’s picture books with math stories. A fellow scienceblogger had been contacted by a publisher, who offered to send review copies of their books to interested SBers.

The publisher turned out to be the folks who publish the “Sir Cumference” books. My wife bought me a copy of the first of that series as a joke, and my daughter immediately appropriated it, and absolutely loved it. So I requested copies of a large bunch of their math adventures, and I’ll be posting reviews as my daughter and I finish them.

The first one that we read together is “A Place for Zero”:, by Angeline Sparagna Lopresti. My daughter picked this one because of the artwork: it’s done in a really attractive style – simple enough to be engaging, and yet complex enough to really be a part of the story.

Continue reading