【发布时间】:2015-10-27 22:08:34
【问题描述】:
考虑以下对树和子树的愚蠢 Isabelle 定义:
datatype tree = Leaf int
| Node tree tree
fun children :: "tree ⇒ tree set" where
"children (Leaf _) = {}" |
"children (Node a b) = {a, b}"
lemma children_decreasing_size:
assumes "c ∈ children t"
shows "size c < size t"
using assms
by (induction t, auto)
function subtrees :: "tree ⇒ tree set" where
"subtrees t = { s | c s. c ∈ children t ∧ s ∈ subtrees c }"
by auto
termination
apply (relation "measure size", simp)
subtrees 的终止证明在这一点上卡住了,尽管递归调用只对孩子进行,根据有充分根据的 size 关系严格来说,这些孩子更小(正如微不足道的引理所示)。
证明状态如下:
goal (1 subgoal):
1. ⋀t x xa xb. (xa, t) ∈ measure size
当然,这是不可能证明的,因为xa 是t 的子代的信息丢失了。我做错什么了吗?我能做些什么来保存证明吗?我注意到我可以使用列表而不是集合来制定相同的定义:
fun children_list :: "tree ⇒ tree list" where
"children_list (Leaf _) = []" |
"children_list (Node a b) = [a, b]"
function subtrees_list :: "tree ⇒ tree list" where
"subtrees_list t = concat (map subtrees_list (children_list t))"
by auto
termination
apply (relation "measure size", simp)
并获得一个信息更丰富、可证明的终止目标:
goal (1 subgoal):
1. ⋀t x.
x ∈ set (children_list t) ⟹
(x, t) ∈ measure size
这是 Isabelle 的一些限制,我应该通过不使用集合来解决这个问题吗?
【问题讨论】:
-
您是否知道,根据您的定义,
subtrees总是返回空集? -
嘿,不错。这是从我正在尝试做的更复杂的事情中简化的(太多了)。
标签: isabelle termination