【问题标题】:Basic Isabelle sequence limit proof基本伊莎贝尔序列极限证明
【发布时间】:2019-11-14 11:15:54
【问题描述】:

正如数百人在我之前尝试过的那样,我试图通过证明极其基本的数学定理来学习 Isabelle。这项任务很艰巨,因为出于某种原因,大多数 Isabelle 教程和书籍都侧重于程序分析(列表、树、递归函数)或基本命题/一阶逻辑,其中的练习在很大程度上可以由 (induct_tac "xs") 和一对夫妇解决应用语句。

但是,通过挖掘现有伊莎贝尔理论的一页又一页,我已经弄清楚了如何定义一些东西。在这种情况下,我定义了一个序列的极限:

theory Exercises
  imports Main "Isabelle2019.app/Contents/Resources/Isabelle2019/src/HOL/Rat"
begin

definition limit :: "(nat ⇒ rat) ⇒ rat ⇒ bool"
  where limit_def: "limit sequence l = (∃(d::nat). ∀(e::nat)≥d. ∀(ε::rat). abs((sequence d) - l) ≤ ε)"

end

然后我试图证明lim 1/n --> 0。 (抱歉,Latex 不适用于 Stack Overflow)。

我想到的证明很简单:给我一个epsilon,我会给你一个d,然后是1/d < epsilon。但是,在几个最基本的步骤之后,我被困住了。我能得到关于如何完成这个证明的提示吗?

lemma limit_simple: "limit (λ (x::nat). (Fract 1 (int x))) (rat 0)"
  unfolding limit_def
proof
  fix ε::rat
  obtain d_rat::rat where d_rat: "(1 / ε) < d_rat" using linordered_field_no_ub by auto
  then obtain d_int::int where d_int: "d_int = (⌊d_rat⌋ + 1)" by auto
  then obtain d::nat where "d = max(d_int, 0)"
end

从这个证明的第一行可以看出,我已经被困在试图说服 Isabelle 有一个自然数 d 大于 1/epsilon 对于每个理性 epsilon ...

【问题讨论】:

  • 初学者的教程倾向于关注更多函数式编程风格的东西的原因是因为这样更容易而且你不会很快感到沮丧。
  • 另外,您是否知道 Isabelle 的库已经提供了一个大型分析库,当然包括限制的概念? (此外,写1 / of_nat x 而不是Fract 1 (int x) 要容易得多。此外,我会直接使用real 类型,而不是rat。出于某种原因,rat 在 Isabelle 中不经常使用)
  • 嗨,感谢 cmets。我确实意识到 Isabelle 已经包含了一个大型分析库,但如果我想基于 Isabelle 中尚不存在的内容构建证明,我必须同时使用实际上很难的数学概念来处理 Isabelle。相反,我试图证明一些超级基础的东西,这让我可以专注于伊莎贝尔,但当然,非常基础的定理已经内置了。

标签: isabelle proof theorem-proving


【解决方案1】:

首先,您对limit 的定义是错误的。你混淆了量词顺序。下面是我的写法:

definition limit :: "(nat ⇒ rat) ⇒ rat ⇒ bool"
  where "limit sequence l = (∀ε>0. ∃d. ∀e≥d. ¦sequence e - l¦ ≤ ε)"

然后是如何证明你想要的东西:

lemma limit_simple: "limit (λ(x::nat). 1 / of_nat x) 0"
  unfolding limit_def
proof (intro allI impI)
  fix ε :: rat assume "ε > 0"
  obtain d_rat::rat where d_rat: "1 / ε < d_rat" using linordered_field_no_ub by auto
  define d where "d = nat (⌊d_rat⌋ + 1)"

  have "d_rat ≤ of_nat d"
    unfolding d_def by linarith

  from ‹ε > 0› have "0 < 1 / ε" by simp
  also have "1 / ε < d_rat" by fact
  also have "d_rat ≤ of_nat d" by fact
  finally have "d > 0" by simp

  have "d_rat > 0" using ‹1 / ε > 0› and d_rat by linarith

  have "∀e≥d. ¦1 / of_nat e - 0¦ ≤ ε"
  proof (intro allI impI)
    fix e :: nat
    assume "d ≤ e"
    have "¦1 / rat_of_nat e - 0¦ = 1 / rat_of_nat e" by simp
    have "d_rat ≤ rat_of_nat e"
      using ‹d ≤ e› and ‹d_rat ≤ of_nat d› by simp
    hence "1 / rat_of_nat e ≤ 1 / d_rat"
      using ‹d ≤ e› and ‹d > 0› and ‹d_rat > 0›
      by (intro divide_left_mono) auto
    also have "1 / d_rat < ε"
      using ‹ε > 0› and ‹d_rat > 0› and d_rat by (auto simp: field_simps)
    finally show "¦1 / rat_of_nat e - 0¦ ≤ ε" by simp
  qed
  thus "∃d. ∀e≥d. ¦1 / of_nat e - 0¦ ≤ ε"
    by auto
qed

对于实数而不是有理数,证明看起来基本相同。它当然可以自动化一点(好吧,如果你导入 Isabelle 的分析库,它可以在一个步骤中自动证明整个事情)。

在“现实世界”的 Isabelle 中,限制用 过滤器 表示,并且围绕它们有一个大型库。这使得上述证明语句变得不那么乏味。

更新: 回复您的评论:是的,这有点冗长。在惯用的 Isabelle 中,我会这样写证明:

lemma A: "filterlim (λn. 1 / real n) (nhds 0) sequentially"
proof
  fix ε :: real assume "ε > 0"
  have "∀⇩F n in sequentially. n > nat ⌈1 / ε⌉"
    by (rule eventually_gt_at_top)
  hence "∀⇩F n in sequentially. real n > 1 / ε"
    by eventually_elim (use ‹ε > 0› in linarith)
  moreover have "∀⇩F n in sequentially. n > 0"
    by (rule eventually_gt_at_top)
  ultimately show "∀⇩F n in sequentially. dist (1 / real n) 0 < ε"
    by eventually_elim (use ‹ε > 0› in ‹auto simp: field_simps›)
qed

过滤器的概念和持有“最终”的属性(这就是∀⇩F 语法的含义)非常强大。

更好的是,您可以将上述证明进一步模块化,首先证明 1/x 对于 x 趋向于 0→对于真正的 x 是∞,然后证明 real n 趋向于实数∞ 代表n→∞ 代表自然的n,然后简单地结合这两个语句:

lemma B: "filterlim (λx::real. 1 / x) (nhds 0) at_top"
proof
  fix ε :: real assume "ε > 0"
  have "∀⇩F x in at_top. x > 1 / ε"
    by (rule eventually_gt_at_top)
  thus "∀⇩F (x::real) in at_top. dist (1 / x) 0 < ε"
    using eventually_gt_at_top[of 0]
    by eventually_elim (use ‹ε > 0› in ‹auto simp: field_simps›)
qed

lemma C: "filterlim real at_top sequentially"
  unfolding filterlim_at_top
proof
  fix C :: real
  have "∀⇩F n in sequentially. n ≥ nat ⌈C⌉"
    by (rule eventually_ge_at_top)
  thus "∀⇩F n in sequentially. C ≤ real n"
    by eventually_elim linarith
qed

lemma D: "filterlim (λn. 1 / real n) (nhds 0) sequentially"
  by (rule filterlim_compose[OF B C])

或者,当然,您可以简单地导入HOL-Real_Asymp.Real_Asymp,然后所有这些都使用by real_asymp 自动完成。 ;)

您真的不应该以从头开始做所有事情的难度来判断一个系统,特别是当有一种既定的惯用方式来做这些事情并且您正在积极地做一些不同的事情时。标准库及其习语是系统的重要组成部分。

很难在证明助手中模拟纸笔式推理,尤其是在许多事情是“显而易见的”的渐近学领域。幸运的是,有了一个好的库,确实可以实现某种近似的推理。当然,如果您愿意,可以进行明确的 ε-δ-推理,但这只会让您的生活更加困难。当我开始在 Isabelle 中使用限制时,我犯了同样的错误(因为 ε-δ 是我知道的唯一正式的处理限制的方法,而且我不理解所有花哨的过滤器的东西),但是当我开始理解过滤器时更多,事情变得更清晰、更容易、更自然。

【讨论】:

  • 哎呀!这比我想象的要长得多——考虑到即使在介绍性数学教科书中,“人类”证明也会非常短。我将尝试逐行遵循您的证明,并且总是猜测下一行...
  • 我稍微更新了我的答案,以更简洁地展示如何做到这一点。
  • 您的回答已经非常有帮助了。昨天我还试图证明 (Sum_i i)^2 = Sum_i i^3,这又带来了一些问题,因为 Isabelle 非常缓慢且不乐意统一涉及诸如“1/4 n^2 (n + 1)^2 + (n+1)^3 = 1/4 (n^4 + 6n^3 + 13n^2 + 12n + 4)"(我希望我从手写笔记中正确复制)
  • 我想知道是否有可能编写一个教程来证明上面的基本数学定理和 HM GM AM QM 不等式,使用一些方法,例如 Isabelle 中的 Cauchy Schwarz 和 Lagrange 乘子。 . 这可能会大大降低进入门槛
  • 我对 Isabelle 的体验是喜忧参半的,因为我对使用该系统可以证明哪些复杂的东西印象深刻,但也有点失望的是,表达许多极其基本的推理链需要许多复杂且不直观的步骤或者对 Isabelle 图书馆有极其广泛的了解......
【解决方案2】:

我认为这里的很多困难来自natrat 之间的所有转换。在有理数上证明等价函数的极限更容易:

definition limit_r :: "(rat ⇒ rat) ⇒ rat ⇒ bool"
  where "limit_r sequence l = (∀ε>0. ∃d. ∀e≥d. ¦sequence e - l¦ ≤ ε)"

lemma limit_simple_r: "limit_r (λx. 1 / x) 0"
 unfolding limit_r_def
proof (intro allI impI)
  fix ε :: rat assume "ε > 0"

  hence "¦1 / (1/ε) - 0¦ ≤ ε"
    by auto

  hence "∀e≥(1/ε). ¦1 / e - 0¦ ≤ ε"
    using `ε > 0` by (auto simp add: divide_le_eq order_trans )

  thus "∃d. ∀e≥d. ¦1 / e - 0¦ ≤ ε"
    by blast
qed

然后可以将结果传输回序列:

definition limit :: "(nat ⇒ rat) ⇒ rat ⇒ bool"
  where "limit sequence l = (∀ε>0. ∃d. ∀e≥d. ¦sequence e - l¦ ≤ ε)"

lemma to_rat_limit:
  assumes a1: "limit_r sequence_r l"
    and a2: "⋀n. sequence n = sequence_r (of_nat n)"
  shows "limit sequence l"
  unfolding limit_def proof (intro allI impI)
  fix ε :: rat
  assume "0 < ε"

  from assms obtain d where "∀e≥d. ¦sequence_r e - l¦ ≤ ε"
    using ‹0 < ε› using limit_r_def by blast  

  hence "¦sequence e - l¦ ≤ ε" if "e ≥ nat ⌈d⌉" for e
    using that a2 by (auto, meson of_nat_ceiling of_nat_mono order_trans)

  thus "∃d. ∀e≥d. ¦sequence e - l¦ ≤ ε"
    by blast
qed


lemma limit_simple: "limit (λ(x::nat). 1 / of_nat x) 0"
  using limit_simple_r to_rat_limit by auto

【讨论】:

    猜你喜欢
    • 2023-04-09
    • 2021-07-18
    • 1970-01-01
    • 1970-01-01
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-31
    相关资源
    最近更新 更多