Coq 避免不动点的隐式参数在证明模式中变得显式
有没有办法强制不动点隐式参数在证明模式中保持隐式 例如:Coq 避免不动点的隐式参数在证明模式中变得显式,coq,Coq,有没有办法强制不动点隐式参数在证明模式中保持隐式 例如: Fixpoint foo {a : Set} (l : list a) : nat := match l with | nil => 1 | _ :: xs => ltac:(exact (1 + foo _ xs)) ^^^ end. 但是我想写 Fixpoint foo {a : Set} (l : list a) : nat :=
Fixpoint foo {a : Set} (l : list a) : nat :=
match l with
| nil => 1
| _ :: xs => ltac:(exact (1 + foo _ xs))
^^^
end.
但是我想写
Fixpoint foo {a : Set} (l : list a) : nat :=
match l with
| nil => 1
| _ :: xs => ltac:(exact (1 + foo xs))
end.
正如人们一直说的,我认为它不会被实现,但在某些情况下,我相信您可以使用小节来规避这个问题
From Coq Require Import List.
Import ListNotations.
Section Foo.
Context {a : Set}.
Fixpoint foo (l : list a) : nat :=
match l with
| nil => 1
| _ :: xs => ltac:(exact (1 + foo xs))
end.
End Foo.
请注意,这相当于(因为它产生了相同的定义):
这里的技巧更为明确,在进行定点运算之前,先获取参数a:Set
当然,只有当所讨论的隐式论点在定义上是一致的时,这才有效。我很想说“不”,但如果以前没有人遇到过这个问题,我也不会感到惊讶。您最好在GitHub()上发布一个问题。它作为wontfix关闭。失败的原因是“本地定义不包含有关其参数的任何信息”,而且这一点也不会改变。@HTNW您的评论看起来像是对我的回答:)
Definition foo' {a : Set} :=
fix foo' (l : list a) : nat :=
match l with
| nil => 1
| _ :: xs => ltac:(exact (1 + foo' xs))
end.