Definition getThreadR {i tp} (cnt: containsThread tp i) : res :=
      (perm_maps tp) (Ordinal cnt).Definition latestThread tp := n (num_threads tp).Definition updLockSet tp (add:address) (lf:lock_info) : t :=
      mk (num_threads tp)
         (pool tp)
         (perm_maps tp)
         (AMap.add add lf (lockGuts tp)).Definition remLockSet tp  (add:address) : t :=
      mk (num_threads tp)
         (pool tp)
         (perm_maps tp)
         (AMap.remove add (lockGuts tp)).

Lemma cntAdd': forall {j tp} vf arg p, containsThread (addThread tp vf arg p) j -> (containsThread tp j /\ j <> num_threads tp) \/ j = num_threads tp.