【发布时间】:2016-09-04 02:18:28
【问题描述】:
在Type Driven Development with Idris 的第 9 章中,我们介绍了带有构造函数 Here 和 There 的 Elem 谓词,用于证明元素是向量的成员。例如
oneInVector : Elem 1 [1, 2, 3]
oneInVector = Here
twoInVector : Elem 2 [1, 2, 3]
twoInVector = There Here
我想知道如何在向量中显示一个元素不是。也许应该通过为这种类型提供解决方案:
notThere : Elem 4 [1, 2, 3] -> Void
notThere = ?rhs
表达式/证明搜索在这种情况下没有给出答案,给出:
notThere : Elem 4 [1,2,3] -> Void
notThere = \__pi_arg => ?rhs1
Scanning through the library for Data.Vect,这些定义看起来很有用(但我不确定如何连接这些点):
||| Nothing can be in an empty Vect
noEmptyElem : {x : a} -> Elem x [] -> Void
noEmptyElem Here impossible
Uninhabited (Elem x []) where
uninhabited = noEmptyElem
【问题讨论】:
标签: idris theorem-proving