Using heterogenous equality with =

做~自己de王妃 提交于 2019-12-22 09:03:36

问题


What I have so far is:

module Foo

postulate P : 'P
postulate NP : 'NP

complexityProof : P = NP
complexityProof = ?complexityProof_rhs

But on trying to load the file, I just get:

When elaborating type of Foo.complexityProof:
When elaborating argument y to type constructor =:
    Can't unify
            'NP
    with
            'P

    Specifically:
            Can't unify
                    "NP"
            with
                    "P"

A little suprised at the error, as I thought Idris, having heterogeneous "John Major" equality, was fine with differing types on the left and right-hand side of =. There's a different symbol for that, now?


回答1:


From the documentation:

Note: Idris's equality type is potentially heterogeneous, which means that it is possible to state equalities between values of potentially different types. However, Idris will attempt the homogeneous case unless it fails to typecheck.

You may need to use (~=~) to explicitly request heterogeneous equality.

So I'm not sure why = doesn't work, since I think the docs are trying to say that heterogeneous equality is a fallback, but you can use ~=~ instead:

module Foo

postulate P : 'P
postulate NP : 'NP

complexityProof : P ~=~ NP
complexityProof = ?complexityProof_rhs


来源:https://stackoverflow.com/questions/26226950/using-heterogenous-equality-with

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!