setoid_rewrite:在用2个参数的绑定下重写
我可以使用一个参数在绑定下使用重写
Require Import Setoid.
Require Import Relation_Definitions.
Require Import FunctionalExtensionality.
Parameters f f' : nat -> nat.
Parameter wrap : nat -> (nat -> nat) -> nat.
Axiom ff'_eq : forall x, f x = f' x.
Add Parametric Morphism :
wrap
with signature (Logic.eq ==> pointwise_relation nat Logic.eq ==> Logic.eq)
as wrap_mor.
Proof.
cbv. intros x f f' H.
apply functional_extensionality in H.
rewrite H.
reflexivity.
Qed.
Lemma test_lemma y :
wrap y (fun x => f x) = wrap y (fun x => f' x).
setoid_rewrite ff'_eq.
reflexivity.
Qed.
,但是我无法经历更多涉及的情况,即wrap:nat -> (nat - > nat - > nat)
and f f':nat-> nat-> nat-> nat
。
Require Import Setoid.
Require Import Relation_Definitions.
Require Import FunctionalExtensionality.
Parameter f f' : nat -> nat -> nat -> nat.
Parameter wrap : nat -> (nat -> nat -> nat) -> nat.
(* Axiom ff'_eq : forall x y z, f x y z = f' x y z. *)
Axiom ff''_eq : forall z, (forall x y, f x y z = f' x y z).
Definition pointwise_relation2 :
forall (A1 A2 : Type) {B : Type}, relation B -> relation (A1 -> A2 -> B) :=
let U := Type in
fun (A1 A2 B : U) (R : relation B) (f g : A1 -> A2 -> B) =>
forall (a1 : A1) (a2 : A2), R (f a1 a2) (g a1 a2).
Axiom test1 : forall (x : nat) (f g : nat -> nat -> nat),
pointwise_relation2 nat nat Logic.eq f g -> wrap x f = wrap x g.
Add Parametric Morphism :
wrap with signature
(Logic.eq ==> pointwise_relation2 nat nat Logic.eq ==> Logic.eq)
as wrap_mor.
Proof. exact test1. Qed.
Lemma test_lemma2 y z:
wrap y (fun x1 x2 => f x1 x2 z) = wrap y (fun x1 x2 => f' x1 x2 z).
specialize (ff''_eq z) as feq.
Fail setoid_rewrite feq.
一个问题主要是:我应该用什么作为关系? 我不确定我在这里做错了什么。我是否使用错误的关系,还是尝试将错误的参数转移到setoid_rewrite
?
I'm able to use rewrite under bindings with one parameter
Require Import Setoid.
Require Import Relation_Definitions.
Require Import FunctionalExtensionality.
Parameters f f' : nat -> nat.
Parameter wrap : nat -> (nat -> nat) -> nat.
Axiom ff'_eq : forall x, f x = f' x.
Add Parametric Morphism :
wrap
with signature (Logic.eq ==> pointwise_relation nat Logic.eq ==> Logic.eq)
as wrap_mor.
Proof.
cbv. intros x f f' H.
apply functional_extensionality in H.
rewrite H.
reflexivity.
Qed.
Lemma test_lemma y :
wrap y (fun x => f x) = wrap y (fun x => f' x).
setoid_rewrite ff'_eq.
reflexivity.
Qed.
But I'm not able to go through a bit more involved case, namely when wrap : nat -> (nat -> nat -> nat)
and f f' : nat -> nat -> nat -> nat
.
Require Import Setoid.
Require Import Relation_Definitions.
Require Import FunctionalExtensionality.
Parameter f f' : nat -> nat -> nat -> nat.
Parameter wrap : nat -> (nat -> nat -> nat) -> nat.
(* Axiom ff'_eq : forall x y z, f x y z = f' x y z. *)
Axiom ff''_eq : forall z, (forall x y, f x y z = f' x y z).
Definition pointwise_relation2 :
forall (A1 A2 : Type) {B : Type}, relation B -> relation (A1 -> A2 -> B) :=
let U := Type in
fun (A1 A2 B : U) (R : relation B) (f g : A1 -> A2 -> B) =>
forall (a1 : A1) (a2 : A2), R (f a1 a2) (g a1 a2).
Axiom test1 : forall (x : nat) (f g : nat -> nat -> nat),
pointwise_relation2 nat nat Logic.eq f g -> wrap x f = wrap x g.
Add Parametric Morphism :
wrap with signature
(Logic.eq ==> pointwise_relation2 nat nat Logic.eq ==> Logic.eq)
as wrap_mor.
Proof. exact test1. Qed.
Lemma test_lemma2 y z:
wrap y (fun x1 x2 => f x1 x2 z) = wrap y (fun x1 x2 => f' x1 x2 z).
specialize (ff''_eq z) as feq.
Fail setoid_rewrite feq.
A question mainly is: what should I use as a relation?
I'm not sure what namely i'm doing wrong here. Do I use wrong relation or do I try to pass wrong argument to setoid_rewrite
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将“点角关系的重点关系”用作二进制函数的关系:
You can use the "pointwise relation of a pointwise relation" as a relation on binary functions: