You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Isabelle中list类型order实例化证明报错:无法细化待处理目标

Isabelle实例化order类时的子目标匹配错误原因分析

问题场景代码

datatype 'a list = Cons 'a  "'a list"  | Nil

instantiation list :: (order) order
begin

fun less_eq_list :: "'a list ⇒ 'a list ⇒ bool" where
"less_eq_list Nil Nil = True" |
"less_eq_list (Cons _ _) Nil = True" |
"less_eq_list Nil (Cons _ _) = False" |
"less_eq_list (Cons _ a) (Cons _ b) = less_eq_list a b"

instance 
proof
  fix x y:: "'a list"
  show "x ≤ x"
    apply(induct_tac x)
    apply(auto)
    done
(* at this point the state is

show x ≤ x 
Successful attempt to solve goal by exported rule:
  ?x2 ≤ ?x2 
proof (state)
this:
  x ≤ x

goal (3 subgoals):
 1. ⋀x y. (x < y) = (x ≤ y ∧ ¬ y ≤ x)
 2. ⋀x y z. x ≤ y ⟹ y ≤ z ⟹ x ≤ z
 3. ⋀x y. x ≤ y ⟹ y ≤ x ⟹ x = y

*)
  show "(x < y) = (x ≤ y ∧ ¬ y ≤ x)"
(* I get an error here

Failed to refine any pending goal 
Local statement fails to refine any pending goal
Failed attempt to solve goal by exported rule:
  (?x2 < ?y2) = (?x2 ≤ ?y2 ∧ ¬ ?y2 ≤ ?x2)
*)
qed
end

错误原因

核心问题是子目标的变量绑定与你show语句中的变量不匹配:

  • 证明状态里的第一个待解决子目标是⋀x y. (x < y) = (x ≤ y ∧ ¬ y ≤ x),这里的⋀x y表示这是一个全称量化的目标,子目标内的x和y是全新的绑定变量。
  • 你之前手动fix x y:: "'a list"的变量,和子目标里被⋀绑定的变量不属于同一作用域,导致show "(x < y) = ..."无法匹配到带全称量词的子目标。

额外注意点

你定义的less_eq_list逻辑存在缺陷:当前实现忽略列表元素,仅通过递归尾部比较长度,这种“小于等于”关系不满足order类要求的反对称性——第三个子目标x ≤ y ⟹ y ≤ x ⟹ x = y会证明失败,因为两个长度相同但元素不同的列表会互相满足≤,但它们并不相等。

解决方向

  • 移除手动fix x y,让Isabelle自动处理变量绑定,直接用策略(如apply(auto))解决子目标;
  • 如果要手动匹配子目标,需要明确带上全称量词,写成show "(⋀x y. (x < y) = (x ≤ y ∧ ¬ y ≤ x))";
  • 修正less_eq_list的定义,使其符合order类的公理要求(比如按字典序比较,同时考虑元素和长度)。

内容的提问来源于stack exchange,提问作者alagris

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 02:50:32