Lambda Calculus Assignment
Home Up Research Ultimate List

Brian Salomon
COMP 204
10-4-01

 

Lambda Calculus Assignment

1.

XOR  = LxLy (x (y F T) (y T F))

(XOR T F)
(LxLy (x (y F T) (y T F)) T F)
(Lx (x (T F T) (T T F)) F)
(Lx (x F T) F)
(F F T)
T

(XOR T T)
(LxLy (x (y F T) (y T F)) T T)
(Lx (x (T F T) (T T F)) T)
(Lx (x F T) T)
(T F T)
F

 

2.

val T = fn x => fn y => x;
val F = fn x => fn y => y;
val AND = fn x => fn y => (x(y))(F);
val OR = fn x => fn y => (x(T))(y);
val NOT = fn x => (x(F))(T);
val XOR = fn x => fn y=> (x (y F T)) (y T F);

 

3.

I was unable to get this to work because ml put type restrictions on my implementation of XOR ('a->'a->'a)

 

4.

val d = fn x => print 4;
val c = fn x => 5;
c(d(3));

4val it = 5 : int

Eager

 

5.

No, ml binds types so it rejects val a = fn x => x x; because nothing can be inferred about the type of x.  Even if ml accepted this the evaluation would not terminate because of eager evaluation