Section constant_cost_theory.
Context `(constant_cost_relation).
intuition.
apply constant_cost_pair_args in H0.
destruct H0.
destruct H0.
intuition.
eapply constant_cost_le.
eauto.
omega.
Qed.
intuition.
eapply constant_cost_le.
eapply (constant_cost_compose f1 _ ).
eauto.
eapply constant_cost_const.
intuition.
eauto.
omega.
Qed.
intuition.
eapply constant_cost_le.
eapply (constant_cost_compose f2 (fun a x => f3 (f1 a) x)).
eauto.
eapply (constant_cost_compose f1 (fun a y x => f3 y x)).
eauto.
eapply constant_cost_const.
intuition.
eauto.
intuition.
omega.
Qed.
intuition.
eapply constant_cost_le.
eapply (constant_cost_compose f1 (fun _ x => f3 x c)).
eauto.
eapply constant_cost_const.
intuition.
eauto.
omega.
Qed.
intuition.
eapply constant_cost_le.
eapply (constant_cost_compose f2 (fun _ x => f3 b x)).
eauto.
eapply constant_cost_const.
intuition.
eauto.
omega.
Qed.
intuition.
eapply constant_cost_le.
eapply constant_cost_bind; eauto.
eapply constant_cost_const.
omega.
Qed.
intuition.
apply constant_cost_pair_args in H0.
destruct H0.
destruct H0.
intuition.
eapply constant_cost_le.
eapply constant_cost_bind; eauto.
eapply constant_cost_const.
omega.
Qed.

Theorem constant_cost_bind_const2 :
forall (A  : Type)(B C: Set)
(f1 : A -> (Comp B))(f2 : B -> Comp C) c1 c2,
cost f1 c1 ->
cost f2 c2 ->
cost (fun a => Bind (f1 a) f2) (c1 + c2).