Section GeneralizedMutex.
Variable T : Type. (* the mutex stages, excluding undef and unit *)
Inductive mutex := undef | nown | own | mx of T.
Definition join x y :=
match x, y with
undef, _ => undef
| _, undef => undef
| nown, x => x
| x, nown => x
| own, _ => undef
| _, own => undef
| mx _, mx _ => undef
end.
Definition valid x := if x is undef then false else true.

Lemma joinC : commutative join.