Definition join (j k:meminj):meminj := fun b =>
  match j b with
     Some (b1, delta) => Some (b1,delta)
   | None => k b
  end.Definition disjoint (j k:meminj):Prop :=
    forall b, j b = None \/ k b = None.

(* Specifications: *)
Lemma join_assoc: forall f g h, join f (join g h) = join (join f g) h.
Lemma join_com: forall f g, disjoint f g -> join f g = join g f.
Lemma disjoint_com: forall f g, disjoint f g <-> disjoint g f.
Lemma disjoint_sub: forall j k (D: disjoint j k) j' k' (J: inject_incr j' j) (K:inject_incr k' k), disjoint j' k'.
Lemma joinI: forall f g b p (Hp: f b = Some p \/ (f b = None /\ g b = Some p)), join f g b = Some p.
Lemma joinD: forall j k (D: disjoint j k) b, match join j k b with Some(b1,delta) => (j b = Some(b1,delta) /\ k b = None) \/ (k b = Some(b1,delta) /\ j b = None) | None => j b = None /\ k b = None end.
Lemma joinD_Some: forall j k b b' delta (J: join j k b = Some(b',delta)), j b = Some(b',delta) \/ (j b = None /\ k b = Some(b',delta)).
Lemma joinD_None: forall j k b (J: join j k b = None), j b = None /\ k b = None.
Lemma joinI_None: forall j k b (J:j b = None) (K:k b = None), join j k b = None.
Lemma inject_incr_join: forall j j' k k' (J: inject_incr j j') (K: inject_incr k k') (D: disjoint j' k'), inject_incr (join j k) (join j' k').
Lemma join_incr_left: forall j k, inject_incr j (join j k).
Lemma join_incr_right: forall j k (D:disjoint j k), inject_incr k (join j k).
Lemma disjointD_left: forall j k b b' delta (J: j b = Some (b',delta)) (D:disjoint j k), k b = None.
Lemma disjointD_right: forall j k b b' delta (K: k b = Some (b',delta)) (D:disjoint j k), j b = None.
Lemma join_left_agree: forall j k b b1 d1 (JK: join j k b = Some(b1,d1)) b2 d2 (J: j b = Some(b2,d2)), b1=b2 /\ d1=d2.
Lemma join_right_agree: forall j k b b1 d1 (JK: join j k b = Some(b1,d1)) b2 d2 (K: k b = Some(b2,d2)) (D:disjoint j k), b1=b2 /\ d1=d2.
Lemma join_disjoint: forall f g h (FH: disjoint f h) (GH: disjoint g h), disjoint (join f g) h.
Lemma join_None_rightneutral: forall j, join j (fun b => None) = j.
Lemma join_None_leftneutral: forall j, join (fun b => None) j = j.
Lemma local_pubpriv: forall mu, local_of mu = join (pub_of mu) (priv_of mu).
Lemma join_assoc: forall f g h, join f (join g h) = join (join f g) h.
Lemma join_com: forall f g, disjoint f g -> join f g = join g f.
Lemma disjoint_com: forall f g, disjoint f g <-> disjoint g f.
Lemma disjoint_sub: forall j k (D: disjoint j k) j' k' (J: inject_incr j' j) (K:inject_incr k' k), disjoint j' k'.
Lemma joinI: forall f g b p (Hp: f b = Some p \/ (f b = None /\ g b = Some p)), join f g b = Some p.
Lemma joinD: forall j k (D: disjoint j k) b, match join j k b with Some(b1,delta) => (j b = Some(b1,delta) /\ k b = None) \/ (k b = Some(b1,delta) /\ j b = None) | None => j b = None /\ k b = None end.
Lemma joinD_Some: forall j k b b' delta (J: join j k b = Some(b',delta)), j b = Some(b',delta) \/ (j b = None /\ k b = Some(b',delta)).
Lemma joinD_None: forall j k b (J: join j k b = None), j b = None /\ k b = None.
Lemma joinI_None: forall j k b (J:j b = None) (K:k b = None), join j k b = None.
Lemma inject_incr_join: forall j j' k k' (J: inject_incr j j') (K: inject_incr k k') (D: disjoint j' k'), inject_incr (join j k) (join j' k').
Lemma join_incr_left: forall j k, inject_incr j (join j k).
Lemma join_incr_right: forall j k (D:disjoint j k), inject_incr k (join j k).
Lemma disjointD_left: forall j k b b' delta (J: j b = Some (b',delta)) (D:disjoint j k), k b = None.
Lemma disjointD_right: forall j k b b' delta (K: k b = Some (b',delta)) (D:disjoint j k), j b = None.
Lemma join_left_agree: forall j k b b1 d1 (JK: join j k b = Some(b1,d1)) b2 d2 (J: j b = Some(b2,d2)), b1=b2 /\ d1=d2.
Lemma join_right_agree: forall j k b b1 d1 (JK: join j k b = Some(b1,d1)) b2 d2 (K: k b = Some(b2,d2)) (D:disjoint j k), b1=b2 /\ d1=d2.
Lemma join_disjoint: forall f g h (FH: disjoint f h) (GH: disjoint g h), disjoint (join f g) h.
Lemma join_None_rightneutral: forall j, join j (fun b => None) = j.
Lemma join_None_leftneutral: forall j, join (fun b => None) j = j.