Debian Codegraph @

src/Util/Compose.v

raw
1 From Coq Require Import Morphisms Setoid.
2 Require Import Crypto.Util.FixCoqMistakes.
3 Require Import Crypto.Util.GlobalSettings.
4 Require Import Crypto.Util.Notations.
5
6 Definition compose {A B} {C : B -> Type} (g : forall b : B, C b) (f : A -> B) (x : A)
7 := g (f x).
8 Global Arguments compose {A B C} g f x / .
9
10 Infix "'o'" := compose : function_scope.
11 Infix "∘" := compose : function_scope.
12
13 #[global]
14 Typeclasses Opaque compose.
15
16 Global Instance Proper_compose {A B C}
17 {RA RB RC}
18 : Proper ((RB ==> RC) ==> (RA ==> RB) ==> RA ==> RC) (@compose A B (fun _ => C)).
19 Proof. cbv in *; eauto. Qed.
20
21 Global Instance Proper_compose_app {A B C} (g : B -> C) (f : A -> B)
22 {RA RB RC}
23 {Hg : Proper (RB ==> RC) g}
24 {Hf : Proper (RA ==> RB) f}
25 : Proper (RA ==> RC) (g ∘ f).
26 Proof. cbv in *; eauto. Qed.
27
28 Ltac Proper_compose_hint :=
29 lazymatch goal with
30 | [ |- Proper _ (fun x => ?g (?f x)) ]
31 => simple eapply (@Proper_compose_app _ _ _ g f)
32 end.
33
34 (*Global Hint Extern 2 (Proper _ (fun x => ?g (?f x))) => simple eapply (@Proper_compose_app _ _ _ g f) : typeclass_instances.*)