Output from Lambda Calculus in OBJ3


This is the output from running the OBJ3 code for the lambda calculus.
awk% obj
                     \|||||||||||||||||/
                   --- Welcome to OBJ3 ---
                     /|||||||||||||||||\
         OBJ3 version 2.04oxford built: 1994 Feb 28 Mon 15:07:40
            Copyright 1988,1989,1991 SRI International
                   1999 Mar 6 Sat 0:18:48
OBJ> in lambda
==========================================
obj LIST
==========================================
obj VAR
==========================================
reduce in VAR : var u
rewrites: 41
result Bool: true
==========================================
reduce in VAR : var ERROR
rewrites: 41
result Bool: false
==========================================
obj LAMBDA
==========================================
reduce in LAMBDA : x free in x
rewrites: 2
result Bool: true
==========================================
reduce in LAMBDA : x free in y
rewrites: 2
result Bool: false
==========================================
reduce in LAMBDA : x free in .\ x . (.\ y . x)
rewrites: 2
result Bool: false
==========================================
reduce in LAMBDA : x free in .\ y . (.\ x . x)
rewrites: 4
result Bool: false
==========================================
reduce in LAMBDA : x free in .\ y . (.\ z . x)
rewrites: 6
result Bool: true
==========================================
reduce in LAMBDA : x free in [(.\ y . (.\ z . z)) x]
rewrites: 10
result Bool: true
==========================================
reduce in LAMBDA : x free in [(.\ y . (.\ z . y)) x]
rewrites: 10
result Bool: true
==========================================
reduce in LAMBDA : x free in [(.\ x . (.\ z . x)) (.\ x . x)]
rewrites: 6
result Bool: false
==========================================
reduce in LAMBDA : x free in [(.\ x . (.\ z . x)) (.\ y . x)]
rewrites: 8
result Bool: true
==========================================
reduce in LAMBDA : x free in [(.\ y . [(.\ x . x) y]) (.\ y . x)]
rewrites: 14
result Bool: true
==========================================
reduce in LAMBDA : sub x for y in x
rewrites: 2
result Var: x
==========================================
reduce in LAMBDA : sub x for y in y
rewrites: 1
result Var: x
==========================================
reduce in LAMBDA : sub x for y in z
rewrites: 2
result Var: z
==========================================
reduce in LAMBDA : sub x for y in .\ x . (.\ y . x)
rewrites: 44
result Lxp: .\ x . (.\ x . x)
==========================================
reduce in LAMBDA : sub x for y in .\ z . (.\ w . x)
rewrites: 6
result Lxp: .\ z . (.\ w . x)
==========================================
reduce in LAMBDA : sub x for y in .\ z . (.\ w . y)
rewrites: 5
result Lxp: .\ z . (.\ w . x)
==========================================
reduce in LAMBDA : sub x for y in .\ z . (.\ w . [y z])
rewrites: 8
result Lxp: .\ z . (.\ w . [x z])
==========================================
reduce in LAMBDA : sub x for y in .\ z . (.\ y . [y z])
rewrites: 46
result Lxp: .\ z . (.\ x . [x z])
==========================================
obj ALPHA
==========================================
***> test alpha:
==========================================
reduce in ALPHA : alpha y for x in x
rewrites: 1
result Lxp: ERROR(y)
==========================================
reduce in ALPHA : alpha y for x in .\ x . x
rewrites: 6
result Lxp: .\ y . y
==========================================
reduce in ALPHA : alpha y for x in .\ x . (.\ y . x)
rewrites: 8
result Lxp: .\ y . (.\ y . y)
==========================================
reduce in ALPHA : alpha y for x in .\ x . (.\ z . x)
rewrites: 10
result Lxp: .\ y . (.\ z . y)
==========================================
reduce in ALPHA : alpha y for x in .\ y . (.\ x . y)
rewrites: 7
result Lxp: FREE-ERROR(y)
==========================================
reduce in ALPHA : alpha y for x in .\ y . (.\ x . x)
rewrites: 7
result Lxp: FREE-ERROR(y)
==========================================
reduce in ALPHA : alpha y for x in .\ y . (.\ x . z)
rewrites: 7
result Lxp: FREE-ERROR(y)
==========================================
reduce in ALPHA : alpha y for x in [(.\ x . x) c]
rewrites: 1
result Lxp: ERROR
==========================================
obj BETA
==========================================
***> test beta reduction:
==========================================
reduce in BETA : [(.\ x . x) c]
rewrites: 5
result Var: c
==========================================
reduce in BETA : [(.\ x . y) c]
rewrites: 6
result Var: y
==========================================
reduce in BETA : [(.\ y . (.\ z . [z y])) c]
rewrites: 10
result Lxp: .\ z . [z c]
==========================================
reduce in BETA : [([(.\ y . (.\ z . [z y])) c]) (.\ x . x)]
rewrites: 25
result Var: c
==========================================
reduce in BETA : [([(.\ x . (.\ y . [x y])) (.\ z . x)]) c]
rewrites: 5
result Lxp: [([(.\ x . (.\ y . [x y])) (.\ z . x)]) c]
==========================================
reduce in BETA : [([(.\ x . (.\ y . x)) c]) ([(.\ z . [f z]) b])]
rewrites: 25
result Var: c
==========================================
reduce in BETA : [([(.\ x . (.\ y . [x y])) (.\ z . z)]) c]
rewrites: 22
result Var: c
==========================================
reduce in BETA : [(.\ y . (.\ z . [z y])) (.\ z . [z z])]
rewrites: 16
result Lxp: .\ z . [z (.\ z . [z z])]
==========================================
reduce in BETA : [(.\ y . (.\ z . [z y])) (.\ z . [y z])]
rewrites: 9
result Lxp: [(.\ y . (.\ z . [z y])) (.\ z . [y z])]
==========================================
reduce in BETA : [([(.\ x . (.\ y . (.\ x . [x ([x y])]))) (.\ z . 
    [([f x]) z])]) ([g x])]
rewrites: 13
result Lxp: [([(.\ x . (.\ y . (.\ x . [x ([x y])]))) (.\ z . [([f 
    x]) z])]) ([g x])]
==========================================
reduce in BETA : [([(.\ x . (.\ y . [x y])) (.\ z . y)]) c]
rewrites: 23
result Var: c
==========================================
openr 
==========================================
let I = ( .\ x . x ) .
==========================================
let K = ( .\ u . ( .\ v . u ) ) .
==========================================
let S = ( .\ x . ( .\ y . ( .\ z . [ [ x z ] [ y z ] ] ) ) ) .
==========================================
let XX = ( .\ x . [ x x ] ) .
==========================================
close
==========================================
reduce in BETA : [K z]
rewrites: 8
result Lxp: .\ v . z
==========================================
reduce in BETA : [([([S K]) K]) w] == [I w]
rewrites: 66
result Bool: true
==========================================
reduce in BETA : [([([S K]) K]) w]
rewrites: 59
result Var: w
==========================================
reduce in BETA : [([S K]) K] == I
rewrites: 56
result Bool: false
==========================================
reduce in BETA : [([S K]) K]
rewrites: 54
result Lxp: .\ z . z
==========================================
***> red [XX XX].  *** fails to terminate!
==========================================
***> yields "Error: Value stack overflow."
==========================================
obj BETA-ETA
==========================================
reduce in BETA-ETA : [K z]
rewrites: 9
result Lxp: .\ v . z
==========================================
reduce in BETA-ETA : [([([S K]) K]) w] == [I w]
rewrites: 74
result Bool: true
==========================================
reduce in BETA-ETA : [([([S K]) K]) w]
rewrites: 64
result Var: w
==========================================
reduce in BETA-ETA : [([S K]) K] == I
rewrites: 58
result Bool: false
==========================================
reduce in BETA-ETA : [([S K]) K]
rewrites: 56
result Lxp: .\ z . z
==========================================
***> red [XX XX].  *** fails to terminate!
==========================================
obj ARITH
==========================================
reduce in ARITH : IF[T,a,b]
rewrites: 16
result Var: a
==========================================
reduce in ARITH : IF[F,a,b]
rewrites: 18
result Var: b
==========================================
reduce in ARITH : First[Pair[a,b]]
rewrites: 34
result Var: a
==========================================
reduce in ARITH : Rest[Pair[a,b]]
rewrites: 36
result Var: b
==========================================
reduce in ARITH : IsZero[Zero] == T
rewrites: 22
result Bool: true
==========================================
reduce in ARITH : IsZero[Zero]
rewrites: 20
result Lxp: .\ x . (.\ y . x)
==========================================
reduce in ARITH : IsZero[Succ[Zero]] == T
rewrites: 92
result Bool: false
==========================================
reduce in ARITH : IsZero[Succ[Zero]]
rewrites: 90
result Lxp: .\ x . NOT-VAR-ERROR(r:Lxp>Var(.\ v . v))
==========================================
***> this needs an alpha
==========================================
reduce in ARITH : Pred[Succ[Zero]] == Zero
rewrites: 52
result Bool: true
==========================================
reduce in ARITH : Pred[Succ[Zero]]
rewrites: 50
result Lxp: .\ v . v
OBJ> q
Bye.
awk% 
The number of rewrites is artificially high in the examples, because the specification calls for OBJ to check for errors involving variables, which includes scrolling through a list of 13 items; so the number of actual beta reductions will be very roughly one tenth of the number of rewrites.
Back to the OBJ3 source code for the lambda calculus.
Back to CSE 230 homepage
Maintained by Joseph Goguen
Last modified 5 March 1999