Section Init.
Variable init:initstate.
(** [word_has_stack_semantics] relates a word with a stack, stating that the word is a concatenation of words that have the semantic values stored in the stack. **)
Inductive word_has_stack_semantics:
forall (word:list token) (stack:stack), Prop :=
| Nil_stack_whss: word_has_stack_semantics [] []
| Cons_stack_whss:
forall (wordq:list token) (stackq:stack),
word_has_stack_semantics wordq stackq ->
forall (wordt:list token) (s:noninitstate)
(pt:parse_tree (last_symb_of_non_init_state s) wordt),
word_has_stack_semantics
(wordq++wordt) (existT noninitstate_type s (pt_sem pt)::stackq).

(** [pop] preserves the invariant **)
Lemma pop_spec_ptl A symbols_to_pop action word_stk stk (res : A) stk' :
pop_spec symbols_to_pop stk action stk' res ->
word_has_stack_semantics word_stk stk ->
exists word_stk' word_res (ptl:parse_tree_list symbols_to_pop word_res),
(word_stk' ++ word_res = word_stk)%list /\
word_has_stack_semantics word_stk' stk' /\
ptl_sem ptl action = res.