【问题标题】: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】:

    您有很多可用的选项,例如:

    1. fun extracts where "extracts xs = hd xs"
    2. definition extracts where [simp]: "extracts = hd"
    3. fun extracts where "extracts xs = (case xs of (x # _) ⇒ x)"
    4. fun extracts where "extracts (x # _) = x" | "extracts [] = undefined"

    【讨论】:

      猜你喜欢
      • 2020-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      相关资源
      最近更新 更多