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_add_overwrite (s: stack) x v v':
stack_add x v (stack_add x v' s) = stack_add x v s.