Set Implicit Arguments.
Unset Strict Implicit.
Set Primitive Projections.
Set Maximal Implicit Insertion.
Set Universe Polymorphism.
Class ValNull (val : Type) := {
null : val
}.
Section Defs.
Context {A val : Type}.
Context {HA : RelDec (@eq A)} {HR : RelDec_Correct HA}.
Context {VNB : ValNull val}.
Definition stack := A -> val.
Definition stack_empty : stack := fun x => null.
Definition stack_get (x : A) : stack -> val  := fun s => s x.
Definition stack_add x v s : stack :=
fun x' => if x' ?[ eq ] x then v else s x'.

Lemma stack_lookup_add (s : stack) (x : A) (v : val) :
((stack_add x v s) : stack) x = v.