/Я language (β)/Tutorials/Lambda calculus interpreter 5/

Full source codePrevious chapter

Let's take a look at traced term with identity function from the previous chapter:

\x.x - Regarding context of variable x, it is used in abstraction body with a parameter called x (ABS'VAR).

> VAR'CTX `har__'st` X `har__` ABS'VAR `ha` X `ryo` Enter @ List

What if we use another name for a single variable in abstraction body?

> VAR'CTX `har__'st` Y `har__` ABS'VAR `ha` X `ryo` Enter @ List

In term \x.x variable x is bound and in \x.y variable y is free - we came to this conclusion by just checking if abstraction parameter and variable in abstraction body are equivalent. It's a good start:

[E][Q]uality relation
`eq` : Latin `P` Latin `AR_____` Latin `P` Latin `S` Latin

Highly likely abstraction parameter and variable in abstraction body would enter separately so let's prepend it with constructing a Product:

(`hjd`) [H]om functor alias mapping A[DJ]oint (reversed) (`eq`) [E][Q]uality relation
`hjd'eq` : Latin `AR__` Latin `AR_` Latin `P` Latin `S` Latin

If product items are equal - result is one of them, if not - result is the same product of items:

> X Unit `hjd'eq` X Unit = That `har'st` X
> X Unit `hjd'eq` Y Unit = This `har'st` X `hop` Y

Work in progress...