Lambda Calculus Flashcards
What are Lambda Calculus benefits?
- Define computable functions
- Mathematical foundation for functional programming
What is a function?
(T/F) Lambda calculus is a method of representing functions.
True
Lambda calculus provides a set of conversion rules for syntactically transforming functions. Give an example.
Give an example:
Give an example of the following in ML & Scheme:
(T/F)
λ y. * (+ x y) 2
x is bound in this expression
y is free
False
(T/F)
λ x. λ y. * (+ x y) 2
both x and y are bound in this expression.
True
(T/F)
In the pure form of lambda calculus, everything is a fuction.
True
Simple syntax for lambda calculus:
Is this in the abstraction or application form?
(λx. ((* 2) x))
Abstraction
Is this in the abstraction or application form?
((λx. ((* 2) x)) 3)
Application
This is a function defined by a lambda abstraction and given an argument.
What is this special case?
(λx. x)
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
(T/F)
In applications, association groupings associate to the right.
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).
Which has higher precedence, abstraction or application?
Application has higher precedence than abstraction
λx.A B = λx.(A B)
not (λx.A) B <– This makes B an argument
Express the following nested list expression with parenthesis.
λ x y z . E
(λ x. (λ y . (λ z . E )))
Give names to λ expressions
Example: define f = (λ x . ((+ x) 1))
What is this in ML and Scheme?
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)