Beta reduction in lambda calculus using Haskell -


i have defined following functions beta reduction i'm not sure how consider case free variables bounded.

data term = variable char | lambda char term | pair term term deriving (show,eq) --substition s[m:x]= if (s=x) m else s ab[m:x]= (a[m:x] b [x:m]) lambda x b[m:x] = lambda x b  lambda y p[m:x]= if x=y lambda y p else lambda y p (m:x)     --beta reduction reduce [s]= s reduce[lambda x b]m = b[m:x] reduce[l1 l2] = (reduce [l1] reduce [l2]) 

the link hammar gave in comment describes solution in detail.

i'd offer different solution. nicolaas govert de bruijn, dutch mathematician, invented alternative notation lambda terms. idea instead of using symbols variables, use numbers. replace each variable number representing how many lambdas need cross until find abstraction binds variable. abstraction don't need have information @ all. example:

λx. λy. x 

is converted to

λ λ 2 

or

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

is converted to

λ λ λ 3 1 (2 1) 

this notation has several considerable advantages. notably, since there no variables, there no renaming of variables, no α-conversion. although have renumber indices accordingly when substituting, don't have check names conflicts , renaming. above wikipedia article gives example of how β-reduction works notation.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -