COMBINATORS IX : K and KI

From: Bruno Marchal <marchal.domain.name.hidden>
Date: Thu, 31 Mar 2005 16:39:14 +0200

I hope you enjoy the combinators. I will send the solution of the fixed
point equation asap.
In the meantime let me give you a glimpse of "programming".


Let me present you K and KI, the Tweedledum and Tweedledee of the
Eliminators.

You know K. Well I hope, K is the first combinator we met. It is the
kestrel and it obeys the following dynamical law, where x and y are any
combinators:

Kxy = x

So, on the two inputs xy, K eliminates y. K can rightly be called the
Elementary Right Eliminator.

And KI ?

Easy: KIxy = (KIx)y = Iy = y

So KI is the left eliminator. Applied on xy it gives y. It is the
Elementary Left Eliminator.

What is the relation with programming? Well, it happens that K and KI
makes it possible to implement in a incredible simple way the most
important control structure in computer science: the IF...THEN...ELSE.

We want to implement IF A THEN B ELSE C; meaning that if the condition
A is true, where A is represented by some combinator, then the
combinator B will be trigged, and if A is false then C will be trigged.

For this we need to represent the constant boolean TRUE and FALSE, like
in formal logic.

Well, everybody in the field agree that one of the nicer choice
consists in representing TRUE by

       K,

and FALSE by

      KI.

Do you see why? Well, with that representation "IF A THEN B ELSE C" is
represented simply by

    ABC

Why? Because if A reduces (is equal) to TRUE, that is: is equal to K
then

ABC = KBC = B, and so if A is true then B is trigged.

And if A is false, that is if A = KI, obviously

ABC = KIBC = C, so if A is false then C is trigged.

That will be useful when we will write program. For this we need to
solve the last fixed point post question, and to define numbers with
those birds ... (that means two posts. Perhaps one more on
"curryfication"). Then we will come back to the measure problem, and
the question of what is an "observer moment" to make (hopefully) more
precise our older conversations.

No question so far? Someone asks me "is there a COMBINATORS VII". The
answer is "no".

Bruno


http://iridia.ulb.ac.be/~marchal/
Received on Thu Mar 31 2005 - 09:49:01 PST

This archive was generated by hypermail 2.3.0 : Fri Feb 16 2018 - 13:20:10 PST