Isabelle中的诱导证明:给定子目标,如何创建正确的辅助引理

发布于 2025-01-28 16:22:04 字数 1321 浏览 2 评论 0原文

我已经定义了一个标记的过渡系统,以及可以访问该系统可以到达的列表的功能。令人信服的是,我定义了另一种用于收集可及状态的功能。我想证明这两个功能之间的关系。

type_synonym ('q,'a) LTS = "('q * 'a set * 'q) set"

primrec LTS_is_reachable :: "('q, 'a) LTS \<Rightarrow> 'q \<Rightarrow> 'a list \<Rightarrow> 'q \<Rightarrow> bool" where
   "LTS_is_reachable \<Delta> q [] q' = (q = q')"|
   "LTS_is_reachable \<Delta> q (a # w) q' =
      (\<exists>q'' \<sigma>. a \<in> \<sigma> \<and> (q, \<sigma>, q'') \<in> \<Delta> \<and> LTS_is_reachable \<Delta> q'' w q')"


primrec LTS_is_reachable_set :: "('q, 'a) LTS ⇒ 'q ⇒ 'a list ⇒ 'q set" where    
  "LTS_is_reachable_set Δ q [] = {q}"|
  "LTS_is_reachable_set Δ q (a # w) = \<Union> ((λ(q, σ, q''). if a \<in> σ then LTS_is_reachable_set Δ q'' w else {}) ` Δ)"

lemma "LTS_is_reachable Δ q1 w q2 \<Longrightarrow> q2\<in>(LTS_is_reachable_set Δ  q1 w)"
  apply (induct w)
   apply simp

有这样的引理,我不知道如何证明这一点。

子目标在这里:

 ⋀a w. (LTS_is_reachable Δ q1 w q2 ⟹ q2 ∈ LTS_is_reachable_set Δ q1 w) ⟹
           ∃q'' σ. a ∈ σ ∧ (q1, σ, q'') ∈ Δ ∧ LTS_is_reachable Δ q'' w q2 ⟹
           ∃x∈Δ. q2 ∈ (case x of (q, σ, q'') ⇒ if a ∈ σ then LTS_is_reachable_set Δ q'' w else {})

I have defined a labeled transition system, and the function which accpets the list that system could reach. For convinence, I defined another funtion used for collecting reachable states. And I want to prove the relation between these two functions.

type_synonym ('q,'a) LTS = "('q * 'a set * 'q) set"

primrec LTS_is_reachable :: "('q, 'a) LTS \<Rightarrow> 'q \<Rightarrow> 'a list \<Rightarrow> 'q \<Rightarrow> bool" where
   "LTS_is_reachable \<Delta> q [] q' = (q = q')"|
   "LTS_is_reachable \<Delta> q (a # w) q' =
      (\<exists>q'' \<sigma>. a \<in> \<sigma> \<and> (q, \<sigma>, q'') \<in> \<Delta> \<and> LTS_is_reachable \<Delta> q'' w q')"


primrec LTS_is_reachable_set :: "('q, 'a) LTS ⇒ 'q ⇒ 'a list ⇒ 'q set" where    
  "LTS_is_reachable_set Δ q [] = {q}"|
  "LTS_is_reachable_set Δ q (a # w) = \<Union> ((λ(q, σ, q''). if a \<in> σ then LTS_is_reachable_set Δ q'' w else {}) ` Δ)"

lemma "LTS_is_reachable Δ q1 w q2 \<Longrightarrow> q2\<in>(LTS_is_reachable_set Δ  q1 w)"
  apply (induct w)
   apply simp

Have such a lemma, I don't know how to prove it.

The subgoal is here:

 ⋀a w. (LTS_is_reachable Δ q1 w q2 ⟹ q2 ∈ LTS_is_reachable_set Δ q1 w) ⟹
           ∃q'' σ. a ∈ σ ∧ (q1, σ, q'') ∈ Δ ∧ LTS_is_reachable Δ q'' w q2 ⟹
           ∃x∈Δ. q2 ∈ (case x of (q, σ, q'') ⇒ if a ∈ σ then LTS_is_reachable_set Δ q'' w else {})

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪若未夕 2025-02-04 16:22:04

您的示例有一个问题,除了如何证明引理:您对lts_is_reachable_set的定义是错误的。考虑此定义的第二个方程:

"LTS_is_reachable_set Δ q (a # w) = ⋃ ((λ(q, σ, q''). ...

这里的问题是Q in λ(q,σ,q'') is not 与左侧的参数q相同。因此,您应该在右侧重命名q,例如q',并明确检查qq '相等如下:

"LTS_is_reachable_set Δ q (a # w) = ⋃ ((λ(q', σ, q''). if a ∈ σ ∧ q' = q then ...

现在,您可以按照您的意愿来通过w来证明您的引理。但是,您需要通过制作Q1任意值来削弱归纳假设,以便您可以有效地将其应用于证明。这是您如何证明自己的引理的一个示例:

lemma "LTS_is_reachable Δ q1 w q2 ⟹ q2 ∈ LTS_is_reachable_set Δ q1 w"
proof (induction w arbitrary: q1)
  case Nil
  then show ?case
    by simp
next
  case (Cons a w)
  from `LTS_is_reachable Δ q1 (a # w) q2`
  obtain q'' and σ
  where "a ∈ σ" and "(q1, σ, q'') ∈ Δ" and "LTS_is_reachable Δ q'' w q2"
    by auto
  moreover from `LTS_is_reachable Δ q'' w q2` and Cons.IH
  have "q2 ∈ LTS_is_reachable_set Δ q'' w"
    by simp
  ultimately show ?case
    by fastforce
qed

There is a problem with your example beyond how to prove the lemma: Your definition of LTS_is_reachable_set is buggy. Consider the second equation of this definition:

"LTS_is_reachable_set Δ q (a # w) = ⋃ ((λ(q, σ, q''). ...

The issue here is that variable q in λ(q, σ, q'') is not the same as the parameter q in the left-hand side. Therefore, you should rename q in the right-hand side to, for example, q' and explicitly check that q and q' are equal as follows:

"LTS_is_reachable_set Δ q (a # w) = ⋃ ((λ(q', σ, q''). if a ∈ σ ∧ q' = q then ...

Now, you can prove your lemma by induction on w as you intended to do it. However, you need to weaken the induction hypotheses by making q1 an arbitrary value so you can effectively apply it in your proof. Here's an example of how you can prove your lemma:

lemma "LTS_is_reachable Δ q1 w q2 ⟹ q2 ∈ LTS_is_reachable_set Δ q1 w"
proof (induction w arbitrary: q1)
  case Nil
  then show ?case
    by simp
next
  case (Cons a w)
  from `LTS_is_reachable Δ q1 (a # w) q2`
  obtain q'' and σ
  where "a ∈ σ" and "(q1, σ, q'') ∈ Δ" and "LTS_is_reachable Δ q'' w q2"
    by auto
  moreover from `LTS_is_reachable Δ q'' w q2` and Cons.IH
  have "q2 ∈ LTS_is_reachable_set Δ q'' w"
    by simp
  ultimately show ?case
    by fastforce
qed
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文