簡體   English   中英

當目標具有影響和存在意義時,如何在 Isabelle 中進行?

[英]How to proceed in Isabelle when the goal has implications and existentials?

我正在嘗試以 Isabelle 的“結構化風格”編寫證明,但我不確定如何指定存在變量的值。 具體來說,我正在嘗試擴展此證明中的sorry s:

lemma division_theorem: "lt Zero n ⟹ ∃ q r. lt r n ∧ m = add (mul q n) r"
proof (induct m)
  case Zero
  then show ?case
    by (metis add_zero_right mul.simps(1)) 
next
  case (Suc m)
  then show ?case
  proof (cases "Suc r = n")
    case True
    then show ?thesis sorry
  next
    case False
    then show ?thesis sorry
  qed
qed

Zeroaddmul是在一個類似 nat 的類上定義的,我只是為了編寫簡單的數論證明而創建的,希望這是直觀的。 我已經以“應用”風格完成了這項工作,所以我熟悉證明應該如何進行,我只是不明白如何將它變成“結構化”風格。

所以這些案例產生的目標是:

 1. (lt Zero n ⟹ ∃q r. lt r n ∧ m = add (mul q n) r) ⟹
    lt Zero n ⟹ cnat.Suc r = n ⟹ ∃q r. lt r n ∧ cnat.Suc m = add (mul q n) r
 2. (lt Zero n ⟹ ∃q r. lt r n ∧ m = add (mul q n) r) ⟹
    lt Zero n ⟹ cnat.Suc r ≠ n ⟹ ∃q r. lt r n ∧ cnat.Suc m = add (mul q n) r 

在高層次上,對於第一個目標,我想從第一個存在性中獲取qr ,為第二個存在性指定q' = Suc qr' = Zero ,然后讓大錘准確地敲出算術引理的組合用來證明它有效。 然后對第二種情況對q' = qr' = Suc r做同樣的事情。

我怎樣才能做到這一點? 我嘗試了obtainrule exI的各種組合,但我覺得我不了解這里的一些基本機制。 當我應用subgoal_tac時,使用應用樣式會起作用,但似乎這不太可能是這里的理想解決方法。

正如您在命令cases "Suc r = n"生成的兩個目標中看到的那樣,表達式cnat.Suc r = ncnat.Suc r ≠ n中變量r的出現實際上是免費的,因此與存在量化的公式。 為了從歸納假設中“獲取” qr ,您需要使用obtain命令。 作為附帶說明,我建議使用induction法而不是induct法,這樣您就可以將歸納假設稱為Suc.IH而不是Suc.hyps 一旦你從歸納假設中“抓取”了qr ,你只需要證明

  1. lt r' n ,還有那個
  2. Suc m = add (mul q' n) r'

為您的兩種情況中的每一種定義q'r' 這是除法定理的(稍微不完整的)證明:

lemma division_theorem: "lt Zero n ⟹ ∃ q r. lt r n ∧ m = add (mul q n) r"
proof (induction m)
  case Zero
  then show ?case
    by (metis add_zero_right mul.simps(1)) 
next
  case (Suc m)
  (* "Grab" q and r from IH *)
  from ‹lt Zero n› and Suc.IH obtain q and r where "lt r n ∧ m = add (mul q n) r"
    by blast
  show ?case
  proof (cases "Suc r = n")
    case True
    (* In this case, we use q' = Suc q and r' = Zero as witnesses  *)
    from ‹Suc r = n› and ‹lt r n ∧ m = add (mul q n) r› have "Suc m = add (mul (Suc q) n) Zero"
      using add_comm by auto
    with ‹lt Zero n› show ?thesis
      by blast
  next
    case False
    (* In this case, we use q' = q and r' = Suc r as witnesses  *)
    from ‹lt r n ∧ m = add (mul q n) r› have "Suc m = add (mul q n) (Suc r)"
      by simp
    moreover have "lt (Suc r) n"
      sorry (* left as exercise :) *)
    ultimately show ?thesis
      by blast
  qed
qed

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM