Definition next_ptd (ptd:pt_dot): option pt_dot :=
  match ptd with
    | Shift_ptd term sem ptl ptlz =>
      Some (build_pt_dot ptl (Cons_ptl_ptlz (Terminal_pt term sem) ptlz))
    | Reduce_ptd ptlz =>
      let 'existT _ _ (existT _ _ (ptz, pt)) := pop_ptlz Nil_ptl ptlz in
      match ptz in pt_zipper sym _ _ return parse_tree sym _ _ -> _ with
        | Top_ptz => fun pt => None
        | Cons_ptl_ptz ptl ptlz' =>
          fun pt => Some (build_pt_dot ptl (Cons_ptl_ptlz pt ptlz'))
      end pt
  end.

Lemma step_next_ptd: forall (ptd:pt_dot) (stack:stack), ptd_stack_compat ptd stack -> match step init stack (ptd_buffer ptd) with | OK Fail_sr => False | OK (Accept_sr sem buffer) => sem = full_sem /\ buffer = buffer_end /\ next_ptd ptd = None | OK (Progress_sr stack buffer) => match next_ptd ptd with | None => False | Some ptd => ptd_stack_compat ptd stack /\ buffer = ptd_buffer ptd end | Err => True end.