Definition reindex (thd:threads) pool : _ -> map :=
  fun x : nat + nat =>
           match x with
           | inl n =>
             match nth thd n with
             | Some (m, _) => m
             | None => emptymap
             end
           | inr n =>
             match pool n with
             | Some m => m
             | None => emptymap
             end
           end.

Lemma natnateqdec (x y : nat + nat) : {x=y}+{x<>y}.