Skip to content
Snippets Groups Projects
Commit 7d16a1d8 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Better setoid-rewriting for updates.

parent e29ce6f1
No related branches found
No related tags found
No related merge requests found
...@@ -359,11 +359,9 @@ Section lemmas. ...@@ -359,11 +359,9 @@ Section lemmas.
Proof. Proof.
induction m' as [|k v m' ? IH] using map_ind. induction m' as [|k v m' ? IH] using map_ind.
{ rewrite right_id_L big_opM_empty right_id //. } { rewrite right_id_L big_opM_empty right_id //. }
rewrite big_opM_insert //. etrans. rewrite big_opM_insert //.
- rewrite [gmap_view_frag _ _ _ _]comm assoc. rewrite [gmap_view_frag _ _ _ _]comm assoc IH gmap_view_delete.
eapply cmra_update_op; [eapply IH|reflexivity]. rewrite -delete_difference. done.
- etrans; first by eapply gmap_view_delete.
rewrite -delete_difference. done.
Qed. Qed.
Lemma gmap_view_update m k v v' : Lemma gmap_view_update m k v v' :
...@@ -388,18 +386,16 @@ Section lemmas. ...@@ -388,18 +386,16 @@ Section lemmas.
rewrite dom_insert_L in Hdom. rewrite dom_insert_L in Hdom.
assert (k dom (gset K) m1) as Hindom by set_solver. assert (k dom (gset K) m1) as Hindom by set_solver.
apply elem_of_dom in Hindom as [v' Hlookup]. apply elem_of_dom in Hindom as [v' Hlookup].
rewrite big_opM_insert //. etrans; last etrans. rewrite big_opM_insert //.
- rewrite [gmap_view_frag _ _ _ _]comm assoc. rewrite [gmap_view_frag _ _ _ _]comm assoc.
eapply cmra_update_op; [eapply (IH (delete k m1))|reflexivity]. rewrite (IH (delete k m1)); last first.
rewrite dom_delete_L Hdom. { rewrite dom_delete_L Hdom.
apply not_elem_of_dom in Hnotdom. set_solver -Hdom. apply not_elem_of_dom in Hnotdom. set_solver -Hdom. }
- rewrite -assoc [_ gmap_view_frag _ _ _]comm assoc. rewrite -assoc [_ gmap_view_frag _ _ _]comm assoc.
eapply cmra_update_op; last reflexivity. rewrite (gmap_view_update _ _ _ v').
eapply (gmap_view_update _ _ v v'). rewrite (big_opM_delete _ m1 k v') // -assoc.
- rewrite (big_opM_delete _ m1 k v') // -assoc. rewrite insert_union_r; last by rewrite lookup_delete.
eapply cmra_update_op; last done. rewrite union_delete_insert //.
rewrite insert_union_r; last by rewrite lookup_delete.
rewrite union_delete_insert //.
Qed. Qed.
Lemma gmap_view_persist k dq v : Lemma gmap_view_persist k dq v :
......
...@@ -52,6 +52,8 @@ Lemma cmra_update_exclusive `{!Exclusive x} y: ...@@ -52,6 +52,8 @@ Lemma cmra_update_exclusive `{!Exclusive x} y:
Proof. move=>??[z|]=>[/exclusiveN_l[]|_]. by apply cmra_valid_validN. Qed. Proof. move=>??[z|]=>[/exclusiveN_l[]|_]. by apply cmra_valid_validN. Qed.
(** Updates form a preorder. *) (** Updates form a preorder. *)
Global Instance cmra_update_rewrite_relation :
RewriteRelation (@cmra_update A) := {}.
Global Instance cmra_update_preorder : PreOrder (@cmra_update A). Global Instance cmra_update_preorder : PreOrder (@cmra_update A).
Proof. Proof.
split. split.
...@@ -59,7 +61,16 @@ Proof. ...@@ -59,7 +61,16 @@ Proof.
- intros x y z. rewrite !cmra_update_updateP. - intros x y z. rewrite !cmra_update_updateP.
eauto using cmra_updateP_compose with subst. eauto using cmra_updateP_compose with subst.
Qed. Qed.
Global Instance cmra_update_rewrite_relation : RewriteRelation (@cmra_update A) := {}. Global Instance cmra_update_proper_update :
Proper (flip cmra_update ==> cmra_update ==> impl) (@cmra_update A).
Proof.
intros x1 x2 Hx y1 y2 Hy ?. etrans; [apply Hx|]. by etrans; [|apply Hy].
Qed.
Global Instance cmra_update_flip_proper_update :
Proper (cmra_update ==> flip cmra_update ==> flip impl) (@cmra_update A).
Proof.
intros x1 x2 Hx y1 y2 Hy ?. etrans; [apply Hx|]. by etrans; [|apply Hy].
Qed.
Lemma cmra_updateP_op (P1 P2 Q : A Prop) x1 x2 : Lemma cmra_updateP_op (P1 P2 Q : A Prop) x1 x2 :
x1 ~~>: P1 x2 ~~>: P2 ( y1 y2, P1 y1 P2 y2 Q (y1 y2)) x1 ~~>: P1 x2 ~~>: P2 ( y1 y2, P1 y1 P2 y2 Q (y1 y2))
...@@ -81,6 +92,13 @@ Proof. ...@@ -81,6 +92,13 @@ Proof.
rewrite !cmra_update_updateP; eauto using cmra_updateP_op with congruence. rewrite !cmra_update_updateP; eauto using cmra_updateP_op with congruence.
Qed. Qed.
Global Instance cmra_update_op_proper :
Proper (cmra_update ==> cmra_update ==> cmra_update) (op (A:=A)).
Proof. intros x1 x2 Hx y1 y2 Hy. by apply cmra_update_op. Qed.
Global Instance cmra_update_op_flip_proper :
Proper (flip cmra_update ==> flip cmra_update ==> flip cmra_update) (op (A:=A)).
Proof. intros x1 x2 Hx y1 y2 Hy. by apply cmra_update_op. Qed.
Lemma cmra_update_op_l x y : x y ~~> x. Lemma cmra_update_op_l x y : x y ~~> x.
Proof. intros n mz. rewrite comm cmra_op_opM_assoc. apply cmra_validN_op_r. Qed. Proof. intros n mz. rewrite comm cmra_op_opM_assoc. apply cmra_validN_op_r. Qed.
Lemma cmra_update_op_r x y : x y ~~> y. Lemma cmra_update_op_r x y : x y ~~> y.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment