# Lambda-calculus: 布尔逻辑

Recap: λ-Combinators
A λ-Term without free variables is a combinator.

# Lambda-Calculus

$\text{TRUE}:= \lambda x.(\lambda y. x)$
$\text{FALSE}:= \lambda x.(\lambda y. y)$

TRUE 和FALSE 都是“函数”,TRUE 接受两个参数，返回第一个参数，FALSE接受两个参数，返回第二个参数。

$\text{NOT}:= \lambda a.(a)(\text{FALSE TRUE})$

WTF? … Let’s see…

$\neg \text{TRUE}=\text{FALSE}$
$\neg \text{FALSE}=\text{TRUE}$

    NOT TRUE
=   (λa.(a) (FALSE TRUE)) TRUE
=>  (TRUE) (FALSE TRUE)
=>  FALSE

NOT FALSE
=   (λa.(a) (FALSE TRUE)) FALSE
=>  (FALSE) (FALSE TRUE)
=>  TRUE



AND $\text{AND}:= \lambda xy.(x)(y)(\text{FALSE})$


AND X  Y
=>  (X) (Y) (FALSE)

x\y  | TRUE | FALSE
--------------------
TRUE | TRUE | FALSE
--------------------
FALSE| FALSE| FALSE


OR $\text{OR}:= \lambda xy.(x)(\text{TRUE})(y)$

     OR X Y
=>   X (TRUE) Y

x\y  | TRUE | FALSE
--------------------
TRUE | TRUE | TRUE
--------------------
FALSE| TRUE | FALSE


## 是否满足性质？

AND(x,y): {TRUE,FALSE}x{TRUE,FALSE} -> {TRUE,FALSE}
f = {<<TRUE,TRUE>,TRUE> , ...... }


F := λx.[x + 1]
G := λx.[x + 2 - 1]


SEE THIS

# Bool logic:

• True (1)
• False (0)

• AND $\wedge$
• OR $\vee$
• NOT $\neg$

• 结合律
• $x\vee (y\vee z) = (x\vee y) \vee z$
• $x\wedge (y\wedge z) = (x\wedge y) \wedge z$
• 交换律
• $x\vee y=y\vee x$
• $x\wedge y=y\wedge x$
• 分配率
• $x\wedge (y\vee z) = (x\wedge y)\vee (x\wedge z)$
• $x\vee (y\wedge z) = (x\vee y)\wedge (x\vee z)$
• identy
• $x\vee 0 = x$
• $x\wedge 1 = x$
• Annihilator
• $x\wedge 0 = 0$
• $y\vee1 = 1$
• Idempotence
• $x\vee x = x$
• $x\wedge x = x$
• Absorption
• $x\wedge (x\vee y)=x$
• $x\vee (x\wedge y)=x$
• Complementation
• $x\wedge \neg x = 0$
• $x\vee \neg x = 1$
• Double negation:
• $\neg(\neg x) = x$
• De Morgan laws:
• $\neg x \wedge \neg y = \neg(x\vee y)$
• $\neg x \vee \neg y = \neg(x\wedge y)$
the comment system on this blog works via email. The button