Definition insub x := if idP is ReflectT Px then Some (Sub x Px) else None.Definition insubd u0 x := odflt u0 (insub x).

(* Specifications: *)
Lemma insubP x : insub_spec x (insub x).
Lemma insubT x Px : insub x = Some (Sub x Px).
Lemma insubF x : P x = false -> insub x = None.
Lemma insubN x : ~~ P x -> insub x = None.
Lemma insubK : ocancel insub val.
Lemma valP u : P (val u).
Lemma valK : pcancel val insub.
Lemma val_inj : injective val.
Lemma valKd u0 : cancel val (insubd u0).
Lemma val_insubd u0 x : val (insubd u0 x) = if P x then x else val u0.