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)).

(* Specifications: *)
Lemma cnt_irr: forall t tid (cnt1 cnt2: containsThread t tid), cnt1 = cnt2.
Lemma numUpdateC : forall {tid tp} (cnt: containsThread tp tid) c, num_threads tp = num_threads (updThreadC cnt c).
Lemma cntUpdateC : forall {tid tid0 tp} c (cnt: containsThread tp tid), containsThread tp tid0 -> containsThread (updThreadC cnt c) tid0.
Lemma cntUpdateC': forall {tid tid0 tp} c (cnt: containsThread tp tid), containsThread (updThreadC cnt c) tid0 -> containsThread tp tid0.
Lemma cntUpdateR: forall {i j tp} r (cnti: containsThread tp i), containsThread tp j-> containsThread (updThreadR cnti r) j.
Lemma cntUpdateR': forall {i j tp} r (cnti: containsThread tp i), containsThread (updThreadR cnti r) j -> containsThread tp j.
Lemma cntUpdate : forall {i j tp} c p (cnti: containsThread tp i), containsThread tp j -> containsThread (updThread cnti c p) j.
Lemma cntUpdate': forall {i j tp} c p (cnti: containsThread tp i), containsThread (updThread cnti c p) j -> containsThread tp j.
Lemma cntUpdateL: forall {j tp} add lf, containsThread tp j -> containsThread (updLockSet tp add lf) j.
Lemma cntRemoveL: forall {j tp} add, containsThread tp j -> containsThread (remLockSet tp add) j.
Lemma cntUpdateL': forall {j tp} add lf, containsThread (updLockSet tp add lf) j -> containsThread tp j.
Lemma cntRemoveL': forall {j tp} add, containsThread (remLockSet tp add) j -> containsThread tp j.
Lemma cntAdd: forall {j tp} vf arg p, containsThread tp j -> containsThread (addThread tp vf arg p) j.
Lemma cntAddLatest: forall {tp} vf arg p, containsThread (addThread tp vf arg p) (latestThread 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.
Lemma contains_add_latest: forall ds p a r, containsThread (addThread ds p a r) (latestThread ds).
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.
Lemma remLock_updThread_comm: forall ds, forall i (cnti: containsThread ds i) c map l, forall (cnti': containsThread (remLockSet ds l) i), remLockSet (updThread cnti c map) l = updThread cnti' c map.
Lemma remLock_updThreadC_comm : forall ds i (cnti: containsThread ds i) c l (cnti': containsThread (remLockSet ds l) i), remLockSet (updThreadC cnti c) l = updThreadC cnti' c.
Lemma gsslockResUpdLock: forall js a res, lockRes (updLockSet js a res) a = Some res.