Understanding `k : Nat ** 5 * k = n` Signature

这一生的挚爱 提交于 2019-12-02 00:50:46

(k : Nat) ** (5 * k = n) is a dependent pair consisting of

  • A first element k : Nat
  • A second element prf : 5 * k = n

In other words, this is an existential type that says "there exists some k : Nat such that 5 * k = n". To be constructive, you must give such a k and a proof that it indeed satisfies 5 * k = n.

In your example, if you partially apply onlyModByFive to 5, you get something of type

onlyModModByFive 5 : ((k : Nat) ** (5 * k = 5)) -> Nat

so the second argument has to be of type (k : Nat) ** (5 * k = 5). There is only one choice of k we can make here, by setting it to 1, and proving that 5 * 1 = 5:

foo : Nat
foo = onlyModByFive 5 (1 ** Refl)

This works because 5 * 1 reduces to 5, so we have to prove 5 = 5, which can be trivially done by using Refl : a = a directly (unifying a ~ 5).

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