intuition.
eapply cost_le.
eapply (cost_compose f1 _ ).
eauto.
intuition.
eapply cost_const.
intuition.
eauto.
omega.
Qed.

Theorem cost_compose_binary :
forall (A B C D: Type)
(f1 : A -> B)(f2 : A ->C)(f3 : B -> C -> D) c1 c2 c3 c4,
cost f1 c1 ->
cost f2 c2 ->
cost f3 c3 ->
(forall a, cost (f3 a) c4) ->
cost (fun a => f3 (f1 a) (f2 a)) (c1 + c2 + c3 + c4).