In lambda calculus, how would I write a function that returns true when its input is the identity function?

StackOverflow https://stackoverflow.com/questions/19625425

  •  01-07-2022
  •  | 
  •  

문제

In lambda calculus, how would I write a function that returns true when its input is the identity function?

Assume true is some church encoded value of true.

It seems like this should be an easy function to write. But for every test I think of, a tricky input can outsmart it. Is it impossible?

도움이 되었습니까?

해결책

I := λx.x
0 := λf.λx.x
1 := λf.λx.f x
TRUE := λx.λy.x
FALSE := λx.λy.y
PRED := λn.λf.λx.n (λg.λh.h (g f)) (λu.x) (λu.u)
ISZERO := λn.n (λx.FALSE) TRUE

The identity function λx.x is Eta equivalent to church numeral 1 λf.λx.f x. The Fn below will return FALSE for any function that does not evaluate to a church numeral zero (λf.λx.x) after being passed through the predicate function.

λx.(ISZERO (PRED x)) TRUE FALSE

There may exist a function BAD that behaves as such:

λx.(ISZERO (PRED x)) TRUE FALSE BAD := TRUE
BAD != I
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top