Lambda Calculus 서적 읽고 정리

Chapter 2. λ calculus

2 장

Chapter 3. Coditions, boolean and numbers

3.1 Truth values and conditional expression

Boolean logic is based on the truth values TRUE adn FALSE with logical operations NOT, AND, OR and so one.

We are going to represent TRUE by select_first and FALSE by select_second and use a version of make_pair to build logical operations.

<aside> 💡 TRUE/FALSE 그리고 NOT,AND,OR 같은 연산자 모두 람다로 이루어진다!

</aside>

C언어에서 그 힌트를 얻자.

<condition> ? <expression1> : <expression2>

<condision>TRUE라면 <expression1>이 평가되고, FALSE라면 <expression2>가 평가된다.

We can model a conditional expression using a version of the make_pair function:

make_pair로 조건절을 만들자.

def cond = λe1.λe2.λc((c e1) e2)

((cond <expr1>) <expr2>) ==
((λe1.λe2.λc.((c e1) e2) <expr1>) <expr2>) =>
(λe2.λc.((c <expr1>) e2) <expr2>) =>
λc.((c <expr1>) <expr2>)

make_pair와 비슷하게 생겼다. 아니 동일하다. 적용된 매개변수만 A, B 에서 expr1, expr2 이렇게 바뀐 것이다.

3.2 NOT