functions.v 1.27 KB
Newer Older
1
From stdpp Require Export base tactics.
2
Set Default Proof Using "Type*".
3 4

Section definitions.
5
  Context {A T : Type} `{EqDecision A}.
6 7 8 9
  Global Instance fn_insert : Insert A T (A  T) :=
    λ a t f b, if decide (a = b) then t else f b.
  Global Instance fn_alter : Alter A T (A  T) :=
    λ (g : T  T) a f b, if decide (a = b) then g (f a) else f b.
10 11
End definitions.

Ralf Jung's avatar
TODO  
Ralf Jung committed
12
(* TODO: For now, we only have the properties here that do not need a notion
13 14 15
   of equality of functions. *)

Section functions.
16
  Context {A T : Type} `{!EqDecision A}.
17

18 19
  Lemma fn_lookup_insert (f : A  T) a t : <[a:=t]>f a = t.
  Proof. unfold insert, fn_insert. by destruct (decide (a = a)). Qed.
20
  Lemma fn_lookup_insert_rev  (f : A  T) a t1 t2 :
21
    <[a:=t1]>f a = t2  t1 = t2.
22
  Proof. rewrite fn_lookup_insert. congruence. Qed.
23 24
  Lemma fn_lookup_insert_ne (f : A  T) a b t : a  b  <[a:=t]>f b = f b.
  Proof. unfold insert, fn_insert. by destruct (decide (a = b)). Qed.
25

26 27
  Lemma fn_lookup_alter (g : T  T) (f : A  T) a : alter g a f a = g (f a).
  Proof. unfold alter, fn_alter. by destruct (decide (a = a)). Qed.
28
  Lemma fn_lookup_alter_ne (g : T  T) (f : A  T) a b :
29 30
    a  b  alter g a f b = f b.
  Proof. unfold alter, fn_alter. by destruct (decide (a = b)). Qed.
31
End functions.