How to compare two functions for equivalence, as in (λx.2*x) == (λx.x+x)?

后端 未结 6 1714
忘掉有多难
忘掉有多难 2020-11-30 21:11

Is there a way to compare two functions for equality? For example, (λx.2*x) == (λx.x+x) should return true, because those are obviously equivalent.

6条回答
  •  生来不讨喜
    2020-11-30 21:56

    In addition to practical examples given in the other answer, let us pick the subset of functions expressible in typed lambda calculus; we can also allow product and sum types. Although checking whether two functions are equal can be as simple as applying them to a variable and comparing results, we cannot build the equality function within the programming language itself.

    ETA: λProlog is a logic programming language for manipulating (typed lambda calculus) functions.

提交回复
热议问题