Lambda Calculus Flashcards

1
Q

What are Lambda Calculus benefits?

A
  • Define computable functions
  • Mathematical foundation for functional programming
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a function?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

(T/F) Lambda calculus is a method of representing functions.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Lambda calculus provides a set of conversion rules for syntactically transforming functions. Give an example.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give an example:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give an example of the following in ML & Scheme:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

(T/F)

λ y. * (+ x y) 2
x is bound in this expression
y is free

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

(T/F)

λ x. λ y. * (+ x y) 2
both x and y are bound in this expression.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

(T/F)

In the pure form of lambda calculus, everything is a fuction.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Simple syntax for lambda calculus:

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Is this in the abstraction or application form?

(λx. ((* 2) x))

A

Abstraction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Is this in the abstraction or application form?

((λx. ((* 2) x)) 3)

A

Application

This is a function defined by a lambda abstraction and given an argument.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is this special case?

(λx. x)

A

function of x that returns x, is the identity function since it is the function or

((λx. x) E) = E

for any lambda expression E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

(T/F)

In applications, association groupings associate to the right.

A

False

(f g h) = (f g) h

not f (g h)

In ML:

fun f x :: xs gives error because this is interpreted as (f x) :: xs and it should be f (x::xs).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which has higher precedence, abstraction or application?

A

Application has higher precedence than abstraction

λx.A B = λx.(A B)

not (λx.A) B <– This makes B an argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Express the following nested list expression with parenthesis.

λ x y z . E

A

(λ x. (λ y . (λ z . E )))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Give names to λ expressions

Example: define f = (λ x . ((+ x) 1))

What is this in ML and Scheme?

A

Use val keyword in ML

val f = fn x => x+1

f 3

Use define keyword in Scheme

(define f (lambda (x) (+ x 1)))

(f 3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Reduction rules in lambda expressions:

A

Apply a set of reduction rules to simplify the expression

4 kinds of reduction rules:
δ (delta)
β (beta)
α (alpha)
η (eta)

19
Q

Delta Reduction:

Use for the built-in constants

A

+ 2 3
->δ
5

Read “+ 2 3” reduced to 5 with the delta indicating that reduction used a delta rule

20
Q

Delta Reduction:

* (+ 1 2)(- 5 1)

A
21
Q

Beta Reduction:

Given
((λ x. E1) E2)

Replace all occurrences of bound variable x in the body, E1, with E2.

What is the Beta reduction for the following?

((λ x . * 2 x) 5)

A
22
Q

Beta Reduction:

( (λ x. λ y. + x y) 7 ) 8

A
23
Q

Issues with Beta reduction:

( λ x. ( (λ x.x) (+ 1 x) ) ) 3

A
24
Q

Name clash resolution:

The example again

(λ x. (λ x.x) (+ 1 x)) 3

A
25
Q

Alternative reduction:

(λ x. (λ x.x) (+ 1 x)) 3

A

Previous Reduction:

26
Q

Eta Conversion

A
27
Q

What is Normal form in Lambda Calculus?

A

A lambda expression is in normal form if it cannot be further reduced using beta reduction, a delta rule, or eta reduction.

28
Q

Can every lambda expression be reduced to normal form?

A

No, not all expressions can be reduced to normal form.

29
Q

Not all expressions can be reduced to normal form.

Are there any consequences of the failure to find normal form for all expressions?

A
30
Q

Is there more than one way to reduce a lambda expression?

A

Yes

31
Q

If there is more than one reduction strategy, does each lead to the same normal form expression?

A

Yes
Church-Rosser theorem implies that if an expression E can be reduced in two different ways to two normal forms, then these normal forms are the same up to alphabetic equivalence (i.e. you can get one from the other using alpha conversion).

This is also called the diamond property.

32
Q

Is there a reduction strategy that guarantees that a normal form expression will be produced (if there is one)?

A

Yes:
**Standardization theorem: **
If an expression E has a normal form, then a strategy that reduces the leftmost outermost redex at each state in the reduction is guaranteed to reach that normal form.

33
Q

Outermost and Innermost example:

A
34
Q

Definitions:

A
  • Redex - an expression that can be reduced
  • Leftmost -** **a redex whose lambda (or primitive function identifier) is textually to the left of all other redexes.
  • **Outermost - **a redex not contained within any other redex
  • **Innermost - **a redex that contains no other redex
35
Q

(T/F)

Lambda calculus has computational power equivalent to Turing machines

A

True

36
Q

What are the two reduction strategies?

A
37
Q

Connection between reduction strategies and parameter passing.

A
38
Q

Example of normal vs applicative order reduction:

A
39
Q

What is an alternative to Normal order and Applicative order reduction?

A

Lazy Evaluation

Like normal order, but introduce pointer to expression (rather than copying it) and evaluate it only once, when its value is needed.
Also called graph reduction.

40
Q

Lazy Evaluation Example:

A
41
Q

Benefits of Lazy Evaluation

A
42
Q

Example: booleans and conditionals

show if true a b = a

A
43
Q

Do functional programming use iteration?

A

No. Recursion is used instead.

44
Q

Info on recursive functions:

A