Coq 中 setoid_rewrite 的奇怪行为

发布于 2024-12-15 08:58:47 字数 1410 浏览 6 评论 0原文

我在使用 setoid_rewrite 策略重写时遇到问题。在下面的实例声明中,我希望 setoid_rewrite fmapComp 会将 fmap iso ∘ fmap inv 重写为 fmap (iso ∘ inv)。然而,Coq 报告说重写期间“没有取得任何进展”:

Instance functorsPreserveIsomorphisms
 `{C : Cat o η} `{D : Cat u ρ}
   {a b : o} {φ : o → u} (F : Functor C D φ) (I : a ≅ b) : φ a ≅ φ b.
Proof.
  apply (Build_Isomorphism _ _ _ (φ a) (φ b) (fmap iso) (fmap inv)).

 o : Type
 η : o → o → Type
 C : Cat o η
 u : Type
 ρ : u → u → Type
 D : Cat u ρ
 a : o
 b : o
 φ : o → u
 F : Functor C D φ
 I : a ≅ b
 ============================
  fmap iso ∘ fmap inv ≡ id (φ a)

我不明白为什么 setoid_rewrite 失败。作为参考,same 命令在使用 same 术语的其他上下文中工作。例如,它将以下目标的任一侧重写为另一侧:

Lemma worksotherwise
 `{C : Cat o η} `{D : Cat u ρ}
   {a b : o} {φ : o → u} (F : Functor C D φ) (I : a ≅ b) :
     fmap iso ∘ fmap inv ≡ fmap (iso ∘ inv)

 o : Type
 η : o → o → Type
 C : Cat o η
 u : Type
 ρ : u → u → Type
 D : Cat u ρ
 a : o
 b : o
 φ : o → u
 F : Functor C D φ
 I : a ≅ b
 ============================
  fmap iso ∘ fmap inv ≡ fmap (iso ∘ inv)

尚不清楚为什么 setoid_rewrite 在第二种情况下有效,但在第一种情况下不起作用。作为参考,QIequivfmapProper。除了 FunctorCat 是类之外,我没有看到任何其他相关事实。另外,setoid_replace 工作正常。

I am having problems with rewriting using the setoid_rewrite tactic. In the following instance declaration, I expect that setoid_rewrite fmapComp would rewrite fmap iso ∘ fmap inv to fmap (iso ∘ inv). However, Coq reports that "no progress was made" during rewriting:

Instance functorsPreserveIsomorphisms
 `{C : Cat o η} `{D : Cat u ρ}
   {a b : o} {φ : o → u} (F : Functor C D φ) (I : a ≅ b) : φ a ≅ φ b.
Proof.
  apply (Build_Isomorphism _ _ _ (φ a) (φ b) (fmap iso) (fmap inv)).

 o : Type
 η : o → o → Type
 C : Cat o η
 u : Type
 ρ : u → u → Type
 D : Cat u ρ
 a : o
 b : o
 φ : o → u
 F : Functor C D φ
 I : a ≅ b
 ============================
  fmap iso ∘ fmap inv ≡ id (φ a)

I don't understand why setoid_rewrite fails. For reference, the same command works in other contexts using the same terms. For example, it rewrites either side of the following goal to the other:

Lemma worksotherwise
 `{C : Cat o η} `{D : Cat u ρ}
   {a b : o} {φ : o → u} (F : Functor C D φ) (I : a ≅ b) :
     fmap iso ∘ fmap inv ≡ fmap (iso ∘ inv)

 o : Type
 η : o → o → Type
 C : Cat o η
 u : Type
 ρ : u → u → Type
 D : Cat u ρ
 a : o
 b : o
 φ : o → u
 F : Functor C D φ
 I : a ≅ b
 ============================
  fmap iso ∘ fmap inv ≡ fmap (iso ∘ inv)

It's unclear why setoid_rewrite works in the second case but not the first. For reference, is equiv and fmap is Proper. Other than that , Functor and Cat are classes, I don't see any other relevant facts. Also, setoid_replace works fine.

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

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

发布评论

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

评论(1

小草泠泠 2024-12-22 08:58:47

这是在没有看到整个发展的情况下在黑暗中拍摄的,但有时,当你看不到差异时,这意味着你看不到的部分存在差异。即隐式参数。

例如,您可能在某处有一个隐式参数,该参数在工作证明尝试中的两个位置中相同地出现,并且在非工作证明尝试中出现在两个不同但可相互转换(甚至只是相等)的地方。有时,策略需要相同的项来启动,而可相互转换的项足以使用相同的证明树,而相等的项则足以通过明智地引入 eq_refl 来满足。当您使用高级策略(例如 setoid 策略)时,可能很难理解幕后发生的事情。

尝试比较设置隐式打印设置打印全部下的情况,或使用无严格隐式无隐式参数 > 证明的一小部分。

This is a shot in the dark without seeing the whole development, but sometimes, when you can't see a difference, it means that there's a difference in a part you don't see. Namely, implicit arguments.

For example, you might have an implicit argument somewhere that appears identically in two locations in the working proof attempt, and that appears in two distinct but interconvertible (or even merely equal) in the non-working proof attempt. Occasionally tactics require identical terms to fire up, whereas interconvertible terms would suffice with the same proof tree, and equal terms would suffice with judicious introduction of eq_refl. When you're working with high-level tactics such as the setoid tactics, it can be difficult to understand what's going on under the hood.

Try comparing the situations under Set Printing Implicit or Set Printing All, or working with No Strict Implicit or No Implicit Arguments for a small part of the proof.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文