Definition ptd_stack_compat (ptd:pt_dot) (stack:stack): Prop :=
match ptd with
| Reduce_ptd ptlz => ptlz_stack_compat ptlz stack
| Shift_ptd _ _ _ ptlz => ptlz_stack_compat ptlz stack
end.
Fixpoint build_pt_dot {hole_symbs hole_word hole_sems}
(ptl:parse_tree_list hole_symbs hole_word hole_sems)
(ptlz:ptl_zipper hole_symbs hole_word hole_sems)
:pt_dot :=
match ptl in parse_tree_list hole_symbs hole_word hole_sems
return ptl_zipper hole_symbs hole_word hole_sems -> _
with
| Nil_ptl => fun ptlz =>
Reduce_ptd ptlz
| Cons_ptl pt ptl' =>
match pt in parse_tree hole_symb hole_word hole_sem
return ptl_zipper (hole_symb::_) (hole_word++_) (hole_sem,_) -> _
with
| Terminal_pt term sem => fun ptlz =>
Shift_ptd term sem ptl' ptlz
| Non_terminal_pt ptl'' => fun ptlz =>
build_pt_dot ptl''
(Non_terminal_pt_ptlz (Cons_ptl_ptz ptl' ptlz))
end
end ptlz.

Lemma build_pt_dot_buffer:
forall hole_symbs hole_word hole_sems
(ptl:parse_tree_list hole_symbs hole_word hole_sems)
(ptlz:ptl_zipper hole_symbs hole_word hole_sems),
ptd_buffer (build_pt_dot ptl ptlz) = hole_word ++ ptlz_buffer ptlz.