Debian Codegraph @

test-suite/bugs/bug_14725.v

raw
1 From Corelib Require Import Setoid Morphisms.
2
3 Axiom T : Type.
4 Axiom Teq : relation T.
5 #[local] Declare Instance Teq_Equivalence : Equivalence Teq.
6
7 Axiom P : T -> Prop.
8 Axiom P_Proper : Proper (Teq ==> Basics.flip Basics.impl) P.
9
10 (** This is a manually crafted hint which is essentially declaring P_Proper as
11 a typeclass instance, except that it builds a proof term that captures the
12 marker variable of type [apply_subrelation]. If that variable were to
13 escape, the call to rewrite below would fail with a type error. *)
14 Ltac manual_P_proper :=
15 match goal with
16 | [ H : apply_subrelation |- Proper (Teq ==> Basics.flip Basics.impl) P ] =>
17 case H; apply P_Proper
18 end.
19
20 #[local] Hint Extern 1 => manual_P_proper : typeclass_instances.
21
22 Lemma foo : forall x y : T, Teq x y -> P y -> P x.
23 Proof.
24 intros m n e h.
25 rewrite e.
26 exact h.
27 Qed.