Fixpoint extendr {A} (l : list A) ls :=
match l, ls with
| x :: xs, y :: ys => (y ++ [x]) :: extendr xs ys
| _, _ => ls
end.

Lemma lookup_distinct : forall {A B} (f : A -> B) a l t (Ha : In a l) (Hdistinct : NoDup (map fst l)),
(fold_right (fun v : ident * A => PTree.set (fst v) (f (snd v))) t l) ! (fst a) =
Some (f (snd a)).