Isabelle 如何在归纳法中引用变量

Isabelle 如何在归纳法中引用变量,isabelle,Isabelle,我有一个与列表匹配的函数: fun merge where ‹merge [] [] = []› | ‹merge (v#vs) [] = (v#vs)› | ‹merge [] (v#vs) = (v#vs)› | ‹merge (x#xs) (y#ys) = (if x < y then x # merge xs (y#ys) else y # merge (x#xs) ys)› 问题是,我可以证明sorted(merge xs[])的这种情况,但这并不满足s

我有一个与列表匹配的函数:

fun merge where
  ‹merge [] [] = []› |
  ‹merge (v#vs) [] = (v#vs)› |
  ‹merge [] (v#vs) = (v#vs)› |
  ‹merge (x#xs) (y#ys) =
    (if x < y then x # merge xs (y#ys) else y # merge (x#xs) ys)›
问题是,我可以证明
sorted(merge xs[])
的这种情况,但这并不满足
sorted(merge(v#vs)[])
这是证明的目标

因此,我如何将
xs
固定为
v#vs
,或者为该特定案例参考案例分析
xs

因此,如何将xs固定为
v#vs
,或者以其他方式引用案例 针对该特定案例分析了
xs

Isabelle2020参考手册(Isar ref)第6.5节对此进行了解释:

。。。通过使用显式形式
case(cy1…ym)
。。。证据 作者可以选择适合当前环境的本地名称 上下文

因此,在您的情况下,您可以使用类似于

fun merge where
  ‹merge [] [] = []› 
| ‹merge (v#vs) [] = (v#vs)› 
| ‹merge [] (v#vs) = (v#vs)› 
| ‹merge (x#xs) (y#ys) = 
    (if x < y then x # merge xs (y#ys) else y # merge (x#xs) ys)›

lemma sorted_merge:
  assumes s_xs: "sorted(xs)" and s_ys: "sorted(ys)"
  shows ‹sorted(merge xs ys)›  
  using assms
proof(induction xs ys rule: merge.induct[case_names base xs ys both])
  case base then show ?case by auto
next
  case (xs v vs) then show ?case by auto
next
  case (ys v vs) then show ?case by auto
next
  case (both x xs y ys)
  show ?case 
  proof(cases ‹x < y›)
    case True with both(1,3,4) show ?thesis by (induction xs) force+
  next
    case False with both(2,3,4) show ?thesis by (induction ys) force+
  qed      
qed
fun合并在哪里
媫合并[]]=[]›
|è合并(v#vs)[]=(v#vs)›
|è合并[](v#vs)=(v#vs)›
|èmerge(x#xs)(y#ys)=
(如果x

伊莎贝尔版本:伊莎贝尔2020

fun merge where
  ‹merge [] [] = []› 
| ‹merge (v#vs) [] = (v#vs)› 
| ‹merge [] (v#vs) = (v#vs)› 
| ‹merge (x#xs) (y#ys) = 
    (if x < y then x # merge xs (y#ys) else y # merge (x#xs) ys)›

lemma sorted_merge:
  assumes s_xs: "sorted(xs)" and s_ys: "sorted(ys)"
  shows ‹sorted(merge xs ys)›  
  using assms
proof(induction xs ys rule: merge.induct[case_names base xs ys both])
  case base then show ?case by auto
next
  case (xs v vs) then show ?case by auto
next
  case (ys v vs) then show ?case by auto
next
  case (both x xs y ys)
  show ?case 
  proof(cases ‹x < y›)
    case True with both(1,3,4) show ?thesis by (induction xs) force+
  next
    case False with both(2,3,4) show ?thesis by (induction ys) force+
  qed      
qed