Coq Eta转换策略?

Coq Eta转换策略?,coq,coq-tactic,Coq,Coq Tactic,在下面的示例中,我是否可以使用一种策略来代替replace,以简化此表达式 Require Import Vector. Goal forall (n b:nat) (x:t nat n), (map (fun a => plus b a) x) = x. Proof. intros n b x. replace (fun a => plus b a) with (plus b) by auto. ... 您可能正在寻找以下方面的信息: repeat change (

在下面的示例中,我是否可以使用一种策略来代替
replace
,以简化此表达式

Require Import Vector.

Goal forall (n b:nat) (x:t nat n), (map (fun a => plus b a) x) = x.
Proof.
  intros n b x.
  replace (fun a => plus b a) with (plus b) by auto.
  ...

您可能正在寻找以下方面的信息:

repeat change (fun x => ?h x) with h.
它允许您减少任意算术的函数。此解决方案使用
change
处理模式的能力(在上述代码段中为
?h

让我们给这个策略起个更具启发性的名字,比如:

(* h is a dummy argument to make Coq happy, it gets shadowed with `?h` *)
Ltac eta_reduce_all_private h := repeat change (fun x => ?h x) with h.

Ltac eta_reduce_all := eta_reduce_all_private idtac.
如果我们试图定义
eta\u reduce\u all
,如下所示

Ltac eta_reduce_all := repeat change (fun x => ?h x) with h.

Coq会抱怨“无界的”
h

我担心
fun a=>加上b a=plus a
转换后确实成立,所以我认为替换是合适的;当然你可以用一些LTAC。这里有一个有趣的问题是,为什么首先要进行替换?我有很多复杂的表达式,其中包含很多函数,这使得它们很难阅读。我想通过去掉所有不必要的lambda来简化它们。
change(fun a=>plus b a)with(plus b)。
更简单一些。是的,你可以定义一种策略来清理你的表达式,只要它们是可转换的,相对便宜;一个更好的办法可能是控制你定义的展开,这样你就可以避免一开始创造的“丑陋”。您可以尝试使用参数或技巧,如ssr的
nosimpl
,YMMV。我对LTAC不是很有经验。有没有可能在LTAC中编写这样的通用策略,它可以处理任意函数?有人能为这个画一些初始的LTAC代码吗?酷!如果有办法将其推广到任意数量的参数?@krokodil我已经用黑客更新了答案。对于任意数量的参数来说,这不是一个真正的解决方案。@krokodil我更新了答案。您能检查一下新的解决方案是否适用于您的用例吗?