簡體   English   中英

忽略 Isabelle 中缺失的模式

[英]Ignore missing pattern in Isabelle

例如,我想定義一個提取列表第一個元素的 function。 對於這個 function,我不關心列表為空的情況(例如我可以確保每次使用 function 時,我都會傳遞一個非空列表)。 但伊莎貝爾會警告說

Missing patterns in function definition:
extracts [] = undefined

我該如何處理這樣的情況?

您有很多可用的選項,例如:

  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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM