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?
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