【问题标题】:Ignore missing pattern in Isabelle忽略 Isabelle 中缺失的模式
【发布时间】:2020-12-09 13:34:09
【问题描述】:
例如,我想定义一个提取列表第一个元素的函数。对于这个函数,我不关心列表为空的情况(例如,我可以确保每次使用该函数时,我都会传递一个非空列表)。但伊莎贝尔会警告这一点
Missing patterns in function definition:
extracts [] = undefined
我该如何处理这种情况?
【问题讨论】:
标签:
functional-programming
isabelle
theorem-proving
【解决方案1】:
您有很多可用的选项,例如:
fun extracts where "extracts xs = hd xs"
definition extracts where [simp]: "extracts = hd"
fun extracts where "extracts xs = (case xs of (x # _) ⇒ x)"
fun extracts where "extracts (x # _) = x" | "extracts [] = undefined"