(* extract a value from a distribution arbitrarily, in this case
   taking the first elt of the underlying list *)
Definition peek {X} (d : dist X) : X :=
  match d with
  | {| dist_pmf := dist; dist_law := law |} =>
    match dist as l return ((sum_dist l == 1)%Q -> X) with
    | [] => fun law => 
      match zero_one_neq law with end
    | (x,_) :: _ => fun _ => x
       end law
  end.(* WARNING: distribution should contain non-zero weighted support *)
Definition dist_lift {X} (P : X -> Prop) (d : dist X) : Prop.

Lemma dist_comm {X Y} (P : X -> Y -> Prop) (m1 : dist X) (m2 : dist Y) : dist_lift (fun y => dist_lift (fun x => P x y) m1) m2 -> dist_lift (fun x => dist_lift (P x) m2) m1.