(* Operational semantics of the elementary instructions *)

 Definition Exec1 (c : Instr) (v : Config) : Config :=
   let (m, s) := v in
   match c with
   | MUL => config (oM m (top s)) (pop s) 
   | SQR => config (oM m m) s
   | PUSH => config m (push m s)
   | SWAP => config m (push (top (pop s)) (push (top s) (pop (pop s))))
   end.(****************************************************************)



(* Execution of a compound instruction *)


Fixpoint Exec (c : Code) : Config -> Config :=
  fun v : Config =>
  match c with
  | End => v
  | seq i c => Exec c (Exec1 i v)
  end.

(* Specifications: *)
Lemma Exec_app : forall (c c' : Code) (v : Config), Exec (app c c') v = Exec c' (Exec c v).