Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call by value in the lambda calculus

I'm working my way through Types and Programming Languages, and Pierce, for the call by value reduction strategy, gives the example of the term id (id (λz. id z)). The inner redex id (λz. id z) is reduced to λz. id z first, giving id (λz. id z) as the result of the first reduction, before the outer redex is reduced to the normal form λz. id z.

But call by value order is defined as 'only outermost redexes are reduced', and 'a redex is reduced only when its right-hand side has already been reduced to a value'. In the example id (λz. id z) appears on the right-hand side of the outermost redex, and is reduced. How is this squared with the rule that only outermost redexes are reduced?

Is the answer that 'outermost' and 'innermost' only refers to lambda abstractions? So for a term t in λz. t, t can't be reduced, but in a redex s t, t is reduced to a value v if this is possible, and then s v is reduced?

like image 203
topynate Avatar asked May 29 '11 15:05

topynate


People also ask

What does λ mean in calculus?

Lambda calculus is Turing complete, that is, it is a universal model of computation that can be used to simulate any Turing machine. Its namesake, the Greek letter lambda (λ), is used in lambda expressions and lambda terms to denote binding a variable in a function. Lambda calculus may be untyped or typed.

Is OCaml call-by-value?

Ignoring lazy expressions, OCaml is call-by-value (CBV) Also called strict or eager.

What is the value of lambda in math?

In the system of Greek numerals, lambda has a value of 30. Lambda is derived from the Phoenician Lamed.


2 Answers

Short answer: yes. You can never reduce inside a lambda-term you can only reduce term outside, starting by right.

The set of evaluation contexts in lambda-calculus by value is defined as follow:

E = [ ] | (λ.t)E | Et

E is what you can value..

For example in lambda calculus by name the evaluation context is :

E = [ ] | Et | fE

as you can reduce an application even if a term is not a value. For example (λx.x)(z λx.x) is stuck in call by value but in call by name it reduce to (z λx.x), which is a normal form.
In the context grammar f is a normal form (in call by name) defined as:

f = λx.t | L  
L = x | L f

You can see another definition of contexts at chapter 19.5.3 of the Pierce.

like image 111
fabiofili2pi Avatar answered Nov 14 '22 22:11

fabiofili2pi


Is the answer that 'outermost' and 'innermost' only refers to lambda abstractions? So for a term t in λz. t, t can't be reduced, but in a redex s t, t is reduced to a value v if this is possible, and then s v is reduced?

Yes, that's exactly right.

like image 29
sepp2k Avatar answered Nov 14 '22 22:11

sepp2k