如何在 Isabelle 中将谓词转换为函数?

How do I convert a predicate to a function in Isabelle?

在 Isabelle HOL 中,我有一个像这样的两个数字的谓词:

definition f :: "nat ⇒ nat ⇒ bool"
  where 
    ...

我可以证明这个谓词在道德上是一个函数:

lemma f_function:
  fixes x :: nat
  shows "∃! y . f x y""
  ...

直觉上,这应该足以让我构造一个函数 f' :: nat ⇒ nat 可证明等价于 f',即:

lemma f'_correct:
  "f x y = (f' x = y)" 

但是我该怎么做呢?

definition f' :: "nat ⇒ nat"
  where
    "f' x ≡ ?"

我应该为问号输入什么?

典型的做法是使用定性描述运算符THE:

definition f' :: "nat ⇒ nat" where "f' x = (THE y. f x y)"

如果您已经证明这个 y 是唯一的,那么您可以使用例如定理 theI' 证明 f x (f' x) 成立,theI_unique 证明如果 f x y 成立,则 y = f' x.

有关 THESOME 等的更多信息,请参阅以下内容: