Module 4: Lambda Calculus Flashcards

1
Q

True or False:

Lambda Calculus is its own programming language.

A

True

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

What is everything in lambda calculus expressed as?

A

Everything in lambda calculus uses the expressions (E)

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

What are valid ways to write lambda expressions?

a. E -> ID
b. E -> λ ID . E
c. E -> E
d. E -> E E
e. E -> (E)

A

a. E -> ID
b. E -> λ ID . E
d. E -> E E
e. E -> (E)

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

Is lambda left-associative or right-associative?

A

lambda is left-associative meaning it is parsed from left to right.

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

Is (λ x . y) x equivalent to λ x . y x?

A

No they are not the same!

This is because when extending to the right in (λ x . y) x stops at the )

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

When are variables considered free in lambda calculus?

a. If the variable does not appear in the meta data.
b. If the variable does not appear within the body of an abstraction with a metavariable of the same name
c. If the variable is not in the abstraction
d. If the variable is in the ID

A

b. If the variable does not appear within the body of an abstraction with a metavariable of the same name

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

Is x free in the following?

λx . x y z

A

No x is not free

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

True or False:

In lambda calculus, the term metavariable and formal parameter are the same?

A

True

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

Is y free in λx . x y z?

A

Yes y is free in the lambda function

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

Is x free in the following?

(λx . (+ x 1))x

A

The x on the outside of the function is free, however, the x that inside of the (λx . (+ x 1)) is not free (more specifically the x in (+ x 1)

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

Is z free in the following:

λx . λy . λz . zyx

A

No Z is not free because it is both the metavariable and in the body

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

Is x free in (λx . z foo)(λ y . y x)?

A

In (λx . z foo) x is free

In (λy. y x) x is free as well because it is not a formal parameter of this statement.

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

Which of the following are rules for finding free variables?

a. E = x
b. E != x
c. E = λ y . E1, where y = x and x is free in E1
d. E = λ y . E1, where y != x and x is free in E1
e. E = E1 E2, where x is free in E1
f. E = E1 E2, where x is free in E2 and every occurrence of

A

a. E = x
c. E = λ y . E1, where y = x and x is free in E1
d. E = λ y . E1, where y != x and x is free in E1
e. E = E1 E2, where x is free in E1
f. E = E1 E2, where x is free in E2 and every occurrence of

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

Is x free in the following?

x λ x . x

A
in E1 (x before λ) x is free
in E2 (λx.x) x is not free
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When is an expression considered to be a combinator?

a. When it has free variables
b. When there are only two free variables
c. When there is not a metadata
d. When there are not any free variables

A

d. When there is not any free variables

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

Is the following considered to be a combinator?

λx . λy . x y z

A

Yes, this is a combinator because x is in the body of λy . xyz
and y is in the body of xyz

17
Q

Why is the following now a combinator?

λz . λx . xyz

A

λz . λx . xyz is not a combinator because y does not have a meta variable making it free.

18
Q

True or False:

If a variable is free it is bound?

A

False

A variable is bound if it is not free

19
Q

What are the rules for bound variables?

A
  • If an occurrence of x is free in E, then it is bound by λx . in λx . E
  • If an occurrence of x is bound by a particular λx . in E, then x is bound by the same λx . in λz . E
  • If an occurrence of x is bound by a particular λx . in E1, then that occurrence in E1 is tied by the same abstraction λx . in E1 E2 and E2 E1
20
Q

What are the free variables in the following?

(λx . x (λy . xyzy) x) x y

A

(λx . x (λy . x y Z y) x) X Y

21
Q

What is every ID in lambda calculus called?

a. Body
b. Variable
c. Abstraction
d. All of the above

A

b. Variable

22
Q

What is E -> λ ID . E called?

A

An abstraction

23
Q

What is currying?

A

Currying is a technique to translate the evaluation of a function that takes multiple arguments into a sequence o functions that each take a single argument