(*************************************)
(* interpretation of syntactic heaps *)
(*************************************)
(* lookup functions for heaps and pointers *)
Definition plook := [fun i => onth (ptr_ctx i)].
(* notation for lookups with default *)
Notation plook' i x := (odflt null (plook i x)).
(* interpretation function for elements *)
Definition einterp i e :=
match e with
Pts x d =>
if plook i x is Some x'
then x' :-> Dyn.val d
else Undef
| Var h => if hlook i h is Some h' then h' else Undef
end.
(* main interpretation function *)
Fixpoint interp i t :=
if t is e :: t' then
if t' is [::] then einterp i e else einterp i e :+ interp i t'
else empty.

Lemma interp_subctx j k t: valid j t -> subctx j k -> interp j t = interp k t.
Inductive fact :=
eqH of synheap & synheap | eqD of dynamic & dynamic | eqX of nat & nat.