为什么我不能在假设上应用f_ qual?

发布于 2025-01-26 04:42:49 字数 365 浏览 3 评论 0原文

在我的假设列表中,我有:

X : Type
l' : list X
n' : nat
H : S (length l') = S n'

我的目标是长度L'= n'

因此,我在h 中尝试了f_equal。但是我会收到以下错误:

语法错误:[tatic:ltac_use_default]预期[tatic:tatic]之后(在[vernac:tactic_command]))。

我认为我应该能够应用<我错了代码> f_equal to h以删除双方的s

In my list of hypothesis, I have:

X : Type
l' : list X
n' : nat
H : S (length l') = S n'

My goal is length l' = n'.

So I tried f_equal in H. But I get the following error:

Syntax error: [tactic:ltac_use_default] expected after [tactic:tactic] (in [vernac:tactic_command]).

Am I wrong in thinking I should be able to apply f_equal to H in order to remove the S on both sides?

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

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

发布评论

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

评论(2

美人迟暮 2025-02-02 04:42:49

f_equal是关于平等的一致性。它可用于证明fx = f y来自x = y。但是,它不能用于从fx = f y中推导x = y,因为这通常不正确,只有当f是注入时。

这是一种特殊的情况,因为s是归纳类型的构造函数,并且构造函数确实是注入性的。例如,您可以使用反转H之类的策略来获得所需的平等。

涉及f_equal的另一个解决方案是应用一个删除s喜欢的函数

Definition removeS n :=
  match n with
  | S m => m
  | 0 => 0
  end.

,然后使用

apply (f_equal removeS) in H.

f_equal is about congruence of equality. It can be used to prove f x = f y from x = y. However, it cannot be used to deduce x = y from f x = f y because that is not true in general, only when f is injective.

Here it is a particular case as S is a constructor of an inductive type, and constructors are indeed injective. You could for instance use tactics like inversion H to obtain the desired equality.

Another solution involving f_equal would be to apply a function that removes the S like

Definition removeS n :=
  match n with
  | S m => m
  | 0 => 0
  end.

and then use

apply (f_equal removeS) in H.
人间不值得 2025-02-02 04:42:49

f_equal告诉您,如果x = y,则fx = f y。换句话说,当您 x = y需要 fx = f y时,您可以使用> f_equal

您的情况是相反的。您 fx = f y,并且您需要 x = y,因此您不能使用f_equal

如果您考虑自己的结论,那么只有当s是注射时才正确。您需要其他策略。

f_equal tells you that if x = y, then f x = f y. In other words, when you have x = y and need f x = f y, you can use f_equal.

Your situation is the reverse. You have f x = f y and you need x = y, so you can't use f_equal.

If you think about your conclusion, it is only true when S is an injection. You need a different tactic.

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