forked from uwplse/verdi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpdateLemmas.v
95 lines (82 loc) · 2.16 KB
/
UpdateLemmas.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Require Import VerdiTactics.
Require Import Net.
Require Import FunctionalExtensionality.
Section OU.
Context `{params : MultiParams}.
Lemma update_diff :
forall A sigma x (v : A) y,
x <> y ->
update sigma x v y = sigma y.
Proof.
unfold update.
intros.
break_if; congruence.
Qed.
Lemma update_nop :
forall A sigma x y,
update (A:=A) sigma x (sigma x) y = sigma y.
Proof.
unfold update.
intros. break_if; congruence.
Qed.
Lemma update_eq :
forall A sigma x y (v : A),
x = y ->
update sigma x v y = v.
Proof.
intros. subst.
unfold update.
break_if; congruence.
Qed.
Lemma update_nop_ext :
forall A sigma h,
update (A:=A) sigma h (sigma h) = sigma.
Proof.
intros.
apply functional_extensionality.
intros.
apply update_nop.
Qed.
Lemma update_fun_comm :
forall A B (f : A -> B) st y v x,
f (update st y v x) = update (fun x => f (st x)) y (f v) x.
Proof.
intros.
destruct (name_eq_dec x y); subst;
repeat first [rewrite update_diff by congruence |
rewrite update_eq by auto ]; auto.
Qed.
Lemma update_nop_ext' :
forall A (sigma : name -> A) y v,
sigma y = v ->
update sigma y v = sigma.
Proof.
intros.
subst.
apply update_nop_ext.
Qed.
Lemma update_overwrite :
forall A (sigma : name -> A) h st st',
update (update sigma h st) h st' = update sigma h st'.
Proof.
intros.
apply functional_extensionality.
intros. destruct (name_eq_dec h x).
- repeat rewrite update_eq; auto.
- repeat rewrite update_diff; auto.
Qed.
End OU.
Ltac update_destruct :=
match goal with
| [ |- context [ update _ ?y _ ?x ] ] => destruct (name_eq_dec y x)
end.
Ltac rewrite_update' H :=
first [rewrite update_diff in H by congruence |
rewrite update_eq in H by auto ].
Ltac rewrite_update :=
repeat match goal with
| [ H : context [ update _ _ _ _ ] |- _ ] =>
rewrite_update' H; repeat rewrite_update' H
| [ |- _ ] => repeat (try rewrite update_diff by congruence;
try rewrite update_eq by auto)
end.