(* * Copyright (c) 2009-2011, Andrew Appel, Robert Dockins and Aquinas Hobor. * *)
(* This file contains the class of decidable equality and associated theory of updateable functions. *)
(* Class of decidable equality *)
Class EqDec (A : Type) : Type :=
eq_dec : forall a a' : A, {a = a'} + {a <> a'}.
Instance EqDec_nat : EqDec nat := eq_nat_dec.
(* Theory of updateable functions, defined over decideable domain *)
Definition upd {A} `{EqDec A} (B : Type) (f : A -> B) (a : A) (b : B) : A -> B :=
fun a' => if eq_dec a a' then b else f a'.
Arguments upd [A H B] _ _ _ _.

Lemma upd_eq {A} `{EqDec A} : forall B (f : A -> B) a b,
upd f a b a = b.