首页 > 解决方案 > 评估 lambda 演算:if false false true

问题描述

lambda 演算具有以下表达式:

e ::=           Expressions
      x         Variables
      (λx.e)    Functions
      e e       Function application

在此基础上,我们可以定义许多额外的构造,例如布尔值和条件语句:

let true = (λx.(λy.x))
false = (λx.(λy.y))
if = (λcond.(λthen.(λelse.cond then else)))

展示你的作品,展示对以下节目的评价: if false false true.

也许if(false (then false ( else true then true)))

但这正是它的意思。if false then false else true then true.

我不知道如何处理它。

标签: lambdaschemesemanticslambda-calculus

解决方案


有定义

true = (λx.(λy.x))
false = (λx.(λy.y))
if = (λcond.(λthen.(λelse.cond then else)))

定义,意味着

true x y = x
false x y = y
if cond then else = cond then else

因此,例如,

   if true true false
-- if cond then else   = cond then else
                       = true true false
                     --  true x    y      = x
                                          = true

这里没有更多的定义可以应用,所以我们有我们的结果。

现在您可以尝试制定您的示例。


推荐阅读