解决办法是
pointwise_relation
来自COQ Stdlib:
Link here
我还复制粘贴了定义以防链接位损坏:
Definition pointwise_relation (R : relation B) : relation (A -> B) :=
fun f g => forall a, R (f a) (g a).
因此,我们希望有一个恰当的例子:
Axiom proper: Proper (pointwise_relation T equiv ==> equiv ==> equiv) combiner.
也就是说,如果第一个函数是逐点相等的,而第二个参数是相等的,则结果是相等的。
以下是编译的完整代码列表:
Require Import Setoid.
Require Import Relation_Definitions.
Require Import Morphisms.
(** Feel free to assume FunExt *)
Require Import FunctionalExtensionality.
Section FOOBAR.
Variable T: Type.
Variable x: T -> T.
Variable y: T -> T.
Variable t0: T.
Variable combiner: (T -> T) -> T -> T.
Variable equiv: T -> T -> Prop.
Infix "â¡" := equiv (at level 50).
Axiom equivalence_equiv: Equivalence equiv.
Axiom proper: Proper (pointwise_relation T equiv ==> equiv ==> equiv) combiner.
Axiom X_EQUIV_Y_EXT: forall (t: T), x t â¡ y t.
(** Check that coq can resolve the Equivalence instance **)
Theorem equivalence_works: t0 â¡ t0.
Proof.
reflexivity.
Qed.
Theorem rewrite_in_lambda:
combiner (fun t => x t) t0 â¡
combiner (fun t => y t) t0.
Proof.
intros.
(* I wish to replace x with y.
What are the Proper rules I need for this to happen? *)
setoid_rewrite X_EQUIV_Y_EXT.
reflexivity.
Qed.
End FOOBAR.