0

1.
In lambda calculus applications have higher precedences than abstractions. Now in this example the author shows two reductions in normal and applicative order. The first is:

(λx.x^2 (λx.(x+1) 2))) → (λx.x^2 (2+1)) → (λx.x^2 (3)) → 3^2 → 9

My problem lies within the 1st and 3rd step. Why can he reduce like this

(λx.x^2 (3)) → 3^2

if application has a higher precedence than abstraction? Shouldn't this be true:

λx.x^2 (3) = λx.(x^2 (3))

and therefore no reduction should be possible? The way he interprets the term is

λx.x^2 (3) = (λx.x^2) (3)

which is incorrect.

2.

Afaik these are the definitions of 4 reduction strategies.

Normal Order:       Leftmost outermost redex reduced first
Applicative Order:  Leftmost innermost redex reduced first
Call by value:      Only outermost redex reduced                Reduction only if right-hand side has been reduced to a value (= variable or abstraction)
Call by name:       Leftmost outermost redex reduced first      No reductions inside abstractions

According to this innermost and outermost only refers to abstractions. Does leftmost (and rightmost) similarly only refer to applications?

3.

So is this a correct recursive algorithm for applicative order reduction (in pseudo code)?

evaluate(t : Term) {
    if (t is Abstraction) {
        evaluate(t.inside)
    } else if (t is Application) {
        evaluate(t.first)
        if (t.first is Abstraction) {
            t.first.apply(t.second)
        }
    } else if (t is Variable) {
        do nothing
    }
}

Abstraction, Application and Variable are all child-classes of Term. The function "apply" applies the given term to the abstraction. The data structures look something like this (please ignore the missing pointer syntax):

class Abstraction {
    var : Variable
    inside : Term
}
class Variable {
    name : String
}
class Application {
    first : Term
    second : Term
}

4. In the link in 1. the author gives an example on a term that can be reduced to normal form with normal order but not with applicative order, because in the latter case the reduction will not terminate. Is there a term where the reduction terminates but yields different results with both strategies? If so, what would be an example?

Sorry for the long question, I didn't want to create 4 different threads for this.

Community
  • 1
  • 1
  • Hi and welcome to StackOverflow! You're actually asking four questions. Split them up into four questions (separate question posts) so that they can be answered independently. – Sentry Dec 02 '14 at 20:30
  • It will only let me post a question every 90 minutes... – lmwienr Dec 02 '14 at 20:51

0 Answers0