(**
 Coercion of sum-style datatypes into bool, which makes it possible
 to use ssr's boolean if rather than Coq's "generic" if.             **)

Coercion isSome T (u : option T) := if u is Some _ then true else false.Coercion is_inl A B (u : A + B) := if u is inl _ then true else false.Coercion is_left A B (u : {A} + {B}) := if u is left _ then true else false.Coercion is_inleft A B (u : A + {B}) := if u is inleft _ then true else false.Definition decidable P := {P} + {~ P}.Variant if_spec (not_b : Prop) : bool -> A -> Set :=
  | IfSpecTrue  of      b : if_spec not_b true vT
  | IfSpecFalse of  not_b : if_spec not_b false vF.Variant if_spec (not_b : Prop) : bool -> A -> Set :=
  | IfSpecTrue  of      b : if_spec not_b true vT
  | IfSpecFalse of  not_b : if_spec not_b false vF.Variant if_spec (not_b : Prop) : bool -> A -> Set :=
  | IfSpecTrue  of      b : if_spec not_b true vT
  | IfSpecFalse of  not_b : if_spec not_b false vF.

(* Specifications: *)
Lemma ifP : if_spec (b = false) b (if b then vT else vF).
Lemma ifPn : if_spec (~~ b) b (if b then vT else vF).
Lemma ifT : b -> (if b then vT else vF) = vT.
Lemma ifF : b = false -> (if b then vT else vF) = vF.
Lemma ifN : ~~ b -> (if b then vT else vF) = vF.
Lemma if_same : (if b then vT else vT) = vT.
Lemma if_neg : (if ~~ b then vT else vF) = if b then vF else vT.
Lemma fun_if : f (if b then vT else vF) = if b then f vT else f vF.
Lemma if_arg (fT fF : A -> B) : (if b then fT else fF) x = if b then fT x else fF x.