[英]forall equality in Coq
I am trying to prove the following equality: 我试图证明以下相等性:
Lemma Foo (A : Type) (n : nat) (gen : forall p : nat, p < S n -> A)
(ic0 : 0 < S n) (ic1 : 0 mod S n < S n):
gen (n - n) ic1 = gen 0 ic0.
The nn
is 0 by Nat.sub_diag
and 0 mod S n
is also 0 by Nat.mod_0_l
. 的
nn
是0通过Nat.sub_diag
和0 mod S n
也为0通过Nat.mod_0_l
。 However I could not easily apply these lemmas to types. 但是,我不能轻易将这些引理应用于类型。 I tried usual trick of
remember/rewrite/subst
but subst
part fails: 我尝试了
remember/rewrite/subst
通常技巧,但是subst
部分失败了:
remember (gen (n-n)) as Q.
remember (n-n) as Q1.
rewrite Nat.sub_diag in HeqQ1.
subst.
PS This question may use a better title. PS此问题可能使用更好的标题。 Please suggest.
请提出建议。
The subst
tactic fails because remember
is buggy; subst
策略失败了,因为remember
是越野车。 I have reported this bug here . 我在这里报告了这个错误。 (As a sanity, check, finishing a goal with
abstract admit
, where admit
comes from Coq.Compat.AdmitAxiom
, should never fail with a type error. If it does, that means there's a bug in Coq (or a plugin you're using).) (
Coq.Compat.AdmitAxiom
理智,请使用abstract admit
完成目标,其中admit
来自Coq.Compat.AdmitAxiom
,绝不应该因类型错误而失败。如果确实如此,则意味着Coq中存在错误(或您在使用的插件使用)。)
Here is a working proof (tested in 8.6.1 and 8.7+beta2): 这是一个有效的证明(在8.6.1和8.7 + beta2中测试):
Require Import Coq.Arith.Arith.
Lemma Foo (A : Type) (n : nat) (gen : forall p : nat, p < S n -> A)
(ic0 : 0 < S n) (ic1 : 0 mod S n < S n):
gen (n - n) ic1 = gen 0 ic0.
Proof.
revert ic0 ic1; simpl; rewrite Nat.sub_diag; intros ic0 ic1.
apply f_equal, le_unique.
Qed.
Note that you got lucky, in some sense, that n - n
and 0 mod S n
are judgmentally equal. 请注意,从某种意义上来说,您很幸运,
n - n
和0 mod S n
在判断上是相等的。 Using simpl
exposes this fact, and allows rewrite
to work. 使用
simpl
揭示这一事实,并允许rewrite
工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.