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 updLock_updThread_comm: forall ds, forall i (cnti: containsThread ds i) c map l lmap, forall (cnti': containsThread (updLockSet ds l lmap) i), updLockSet (@updThread _ ds cnti c map) l lmap = @updThread _ (updLockSet ds l lmap) cnti' c map.