split; intros; induction v. simpl in *.
rewrite PTree.gempty in *. congruence.
simpl in *. destruct a. inv H. rewrite PTree.gsspec in *. if_tac in H0.
inv H0. auto. intuition.
inv H0.
simpl in *. destruct a. simpl in *. rewrite PTree.gsspec. destruct H0.
inv H0. if_tac. auto. intuition. inv H. if_tac. subst.
clear - H0 H3. rewrite in_map_iff in *. destruct H3. exists (i,ty). auto.
apply IHv; auto.
Qed.

Lemma set_inside : forall i0 t1 t p id,
list_disjoint (map fst p) (i0 :: map fst t) ->
(fold_right
(fun param : ident * type =>
PTree.set (fst param) (snd param, true))
(PTree.set i0 (t1, false)
(fold_right
(fun (temp : ident * type) (tenv : PTree.t (type * bool)) =>
let (id, ty) := temp in PTree.set id (ty, false) tenv)
(PTree.empty (type * bool)) t)) p) ! id =
(PTree.set i0 (t1, false) (
(fold_right
(fun param : ident * type =>
PTree.set (fst param) (snd param, true))
(fold_right
(fun (temp : ident * type) (tenv : PTree.t (type * bool)) =>
let (id, ty) := temp in PTree.set id (ty, false) tenv)
(PTree.empty (type * bool)) t)) p)) ! id
.