From ChargeCore.SepAlg Require Import SepAlg UUSepAlg.
Set Implicit Arguments.
Unset Strict Implicit.
Set Maximal Implicit Insertion.
Section PartialFun.
(* A partial function is a function from X -> option Y where X equality of members of type X is decidable. *)
Context {X Y : Type}.
Context {RelDec_X : RelDec (@eq X)}.
Context {RDC : RelDec_Correct RelDec_X}.
Definition pfun := X -> option Y.
Definition pfun_eq (f1 f2 : pfun) := forall s, (f1 s) = (f2 s).
Global Instance EquivalencePfun : Equivalence pfun_eq.
Definition emptyFun : pfun := fun _ => None.
Definition pfun_update (f : pfun) (x : X) (y : Y) :=
fun z => if x ?[ eq ] z then Some y else f z.
Definition pfun_in (f : pfun) (x : X) : Prop := exists y, f x = Some y.

Lemma update_lookup (f : pfun) (x : X) (y : Y) :
(pfun_update f x y) x = Some y.