受限函数的函数平等 [英] Function equality on restricted functions

查看:142
本文介绍了受限函数的函数平等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经发布了一个关于函数平等的问题。它很快得出结论:一般函数平等是一个难以置信的难题,可能在数学上是不可证明的。



我想存一个函数

 函数等于(f,g,域){

}

f & g 正在停止带有一个参数的函数。他们的论点是一个自然数。这些函数将返回一个布尔值。



如果没有域名被传递,那么您可能会认为该域名默认为全部自然数字。



domain 对于等于函数是最方便的。



<另一个重要的事实是 f & g 是确定性的。并将一致地返回 f(n)


$ b相同的布尔值 m $ b

您可能会认为 f g 总是返回,并且不会抛出任何异常或崩溃只要它们的输入在域内



这个问题是语言不可知的并且要求实现等于函数。我不确定是否适合这个地方。

f & g 没有副作用。和不一定是有限的。

解决方案

不可能的。



您可以测试两个函数的一些有限输入,并检查它们是否相等。如果它们对于任何输入都不相等,那么这两个函数就不一样了。如果他们在每一种情况下都是相同的,那么他们就有相同的功能,但是你不能完全确定。

总的来说,它是除非域很小,否则不可能测试每个可能的输入。如果域是一个32位整数,并且你的函数评估速度很快,那么检查每个可能的输入可能是可行的。


I already posted a question about function equality. It quickly concluded that general function equality is an incredibly hard problem and might be mathematically disprovable.

I would like to stub up a function

function equal(f, g, domain) {

}

f & g are halting functions that take one argument. Their argument is an natural number. These functions will return a boolean.

If no domain is passed then you may assume the domain defaults to all natural numbers.

The structure of domain is whatever is most convenient for the equal function.

Another important fact is that f & g are deterministic. and will consistantly return the same boolean m for f(n).

You may assume that f and g always return and don't throw any exceptions or crash due to errors as long as their input is within the domain

The question is language-agnostic and Asking for an implementation of the equal function. i'm not certain whether SO is the right place for this anymore.

f & g have no side-effects. and the domain does not have to be finite.

解决方案

It's still not possible.

You could test both functions for some finite number of inputs and check them for equality on those inputs. If they are unequal for any input then the two functions are not identical. If they are equal in every case you tested then there is a reasonable chance that they are the same function, but you can't be completely certain.

In general it is infeasible to test every possible input unless the domain is small. If the domain is a 32 bit integer and your function is quite fast to evaluate then it might be feasible to check every possible input.

这篇关于受限函数的函数平等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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