Idris:模式匹配后重建平等

Idris: reconstruct equality after pattern-matching

我正在将一个列表解构为头部和尾部,但稍后我需要证明它们在合并后会返回原始列表:

test: Bool -> String
test b = let lst = the (List Nat) ?getListFromOtherFunction in
        case lst of
          Nil => ""
          x :: xs =>
            let eq = the ((x::xs) = lst) ?howToDoIt in ""

我正在使用 Idris 1.3.1。

您可以使用依赖模式匹配来做到这一点:

test: List Nat -> String
test lst with (lst) proof prf
  | Nil = ""
  | (x :: xs) = ?something

此处prf将保持你的平等。

但是,我认为最好在 LHS 中简单地匹配 lst,然后您的证明将在需要的地方自动简化。