在纯函数式语言中,是否有获得反函数的算法? [英] In pure functional languages, is there an algorithm to get the inverse function?

查看:24
本文介绍了在纯函数式语言中,是否有获得反函数的算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在像 Haskell 这样的纯函数式语言中,是否有一种算法可以在函数是双射时获得函数的逆(编辑)?是否有一种特定的方法可以对您的函数进行编程?

In pure functional languages like Haskell, is there an algorithm to get the inverse of a function, (edit) when it is bijective? And is there a specific way to program your function so it is?

推荐答案

在某些情况下,是的!有一篇漂亮的论文叫做双向化免费! 讨论了一些情况——当你的函数足够多态时——在那里可以完全自动地推导出反函数.(它还讨论了当函数不是多态时是什么使问题变得困难.)

In some cases, yes! There's a beautiful paper called Bidirectionalization for Free! which discusses a few cases -- when your function is sufficiently polymorphic -- where it is possible, completely automatically to derive an inverse function. (It also discusses what makes the problem hard when the functions are not polymorphic.)

如果你的函数是可逆的,你得到的是逆(带有虚假输入);在其他情况下,您会得到一个尝试合并"旧输入值和新输出值的函数.

What you get out in the case your function is invertible is the inverse (with a spurious input); in other cases, you get a function which tries to "merge" an old input value and a new output value.

这篇关于在纯函数式语言中,是否有获得反函数的算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆