Definition key_in_stash_dec k s :
  { v : nat & blk_in_stash k v s } +
  { ~ exists v, blk_in_stash k v s }.Definition key_in_path_dec k s :
  { v : nat & blk_in_path k v s } +
  { ~ exists v, blk_in_path k v s }.Definition def_or_undef k s :
  { v : nat & blk_in_state k v s } +
  { undef k s }.Definition get_state_val k s : option nat :=
  match def_or_undef k s with
  | inleft p => Some (projT1 p)
  | inright _ => None
  end.Definition get_val k s : nat :=
  match get_state_val k s with
  | Some v => v
  | None => 0
  end.

Lemma blk_in_state_get_state_val : forall k v s, well_formed s -> blk_in_state k v s -> get_state_val k s = Some v.