Sunday, October 1, 2017

October 01, 2017 Sunday

Bedtime Story 


Creating Simple Functions True and False in Lambda Calculus


In programming languages, logical values are used to make a choice in between doing two things.

If True, then do so and if false then do something else.

This idea can be used to encode the logical values True and False in lambda calculus.

Let us see how.

We make certain expressions in the syntax of lambda calculus for true and false.

True = λx.λy.x

So what does this expression mean?

It means that the black box takes in two inputs x and y and chooses x as the output.

Now with False it will be the opposite.

It will take in two inputs x and y and choose y as output.

False = λx.λy.y

So now we have generated two lambda functions, the first one, the True takes in two inputs x and y and gives output as x.

The second False function takes in two inputs x and y and gives output as y.

So what can be done with these two functions?

Can we work out some way to use these two functions to make a logical operator or what is popularly called a logic gate in electronics?

Perhaps the simplest logical operator is the operator NOT.

Electronically, it is called an inverter as it simply converts an input A to not A or a 0 to 1 or a 1 to 0.

No operation can be simpler than that.

So can we create this operator from the two lambda functions that we have created above?

In our case, if we can create an operator that can convert True to False or False to True, then we have achieved creating this operator of logical negation.

Let us take a logical value b or a Boolean, a term that is commonly used in formal logic.

Not let us apply it (b) to both the functions False and True.

Now we shall proclaim it to be a NOT function.

So if we claim it to be a NOT function, then we can write it in the syntax of lambda calculus as follows:

NOT = λb.b

Then this proclaimed NOT function is applied to first False and then to True.

This will be written down in lambda calculus as follows:

NOT = λb.b False True

Please stay with me on this idea and we shall continue it in the nights to come.

Stay tuned to the voice of an average story storytelling chimpanzee or login at http://panarrans.blogspot.com
                              
Good night mon ami and my fellow cousin ape.
                           
  
                

             












Advertisements

Another great educator and a teacher that I am aware of is Professor Subhashish Chattopadhyay in Bangalore, India.

While I narrate stories, Professor Subhashish an electronic engineer and a former professor at BARC, does and teaches real mathematics and physics.

He started the participation of Indian students at the International Physics Olympiad.

Do visit him here:


All his books can be downloaded for free through this link:


For edutainment and English education of your children, I recommend this large collection of Halloween Songs for Kids:


No comments:

Post a Comment