Commit 463f24ef authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Merge branch 'seal_big_opM' into 'master'

Seal big_sepM2

See merge request iris/iris!352
parents d6c5699b bdaec8c5
...@@ -44,6 +44,8 @@ Coq development, but not every API-breaking change is listed. Changes marked ...@@ -44,6 +44,8 @@ Coq development, but not every API-breaking change is listed. Changes marked
STS RA. STS RA.
* Added the type `siProp` of "plain" step-indexed propositions, together with * Added the type `siProp` of "plain" step-indexed propositions, together with
basic proofmode support. basic proofmode support.
* Sealed the definitions of `big_opS`, `big_opMS`, `big_opM` and `big_sepM2`
to prevent undesired simplification.
## Iris 3.2.0 (released 2019-08-29) ## Iris 3.2.0 (released 2019-08-29)
......
...@@ -35,11 +35,13 @@ Notation "'[^' o 'list]' x ∈ l , P" := (big_opL o (λ _ x, P) l) ...@@ -35,11 +35,13 @@ Notation "'[^' o 'list]' x ∈ l , P" := (big_opL o (λ _ x, P) l)
(at level 200, o at level 1, l at level 10, x at level 1, right associativity, (at level 200, o at level 1, l at level 10, x at level 1, right associativity,
format "[^ o list] x ∈ l , P") : stdpp_scope. format "[^ o list] x ∈ l , P") : stdpp_scope.
Definition big_opM `{Monoid M o} `{Countable K} {A} (f : K A M) Definition big_opM_def `{Monoid M o} `{Countable K} {A} (f : K A M)
(m : gmap K A) : M := big_opL o (λ _, curry f) (map_to_list m). (m : gmap K A) : M := big_opL o (λ _, curry f) (map_to_list m).
Definition big_opM_aux : seal (@big_opM_def). by eexists. Qed.
Definition big_opM := big_opM_aux.(unseal).
Arguments big_opM {M} o {_ K _ _ A} _ _.
Definition big_opM_eq : @big_opM = @big_opM_def := big_opM_aux.(seal_eq).
Instance: Params (@big_opM) 7 := {}. Instance: Params (@big_opM) 7 := {}.
Arguments big_opM {M} o {_ K _ _ A} _ _ : simpl never.
Typeclasses Opaque big_opM.
Notation "'[^' o 'map]' k ↦ x ∈ m , P" := (big_opM o (λ k x, P) m) Notation "'[^' o 'map]' k ↦ x ∈ m , P" := (big_opM o (λ k x, P) m)
(at level 200, o at level 1, m at level 10, k, x at level 1, right associativity, (at level 200, o at level 1, m at level 10, k, x at level 1, right associativity,
format "[^ o map] k ↦ x ∈ m , P") : stdpp_scope. format "[^ o map] k ↦ x ∈ m , P") : stdpp_scope.
...@@ -47,20 +49,24 @@ Notation "'[^' o 'map]' x ∈ m , P" := (big_opM o (λ _ x, P) m) ...@@ -47,20 +49,24 @@ Notation "'[^' o 'map]' x ∈ m , P" := (big_opM o (λ _ x, P) m)
(at level 200, o at level 1, m at level 10, x at level 1, right associativity, (at level 200, o at level 1, m at level 10, x at level 1, right associativity,
format "[^ o map] x ∈ m , P") : stdpp_scope. format "[^ o map] x ∈ m , P") : stdpp_scope.
Definition big_opS `{Monoid M o} `{Countable A} (f : A M) Definition big_opS_def `{Monoid M o} `{Countable A} (f : A M)
(X : gset A) : M := big_opL o (λ _, f) (elements X). (X : gset A) : M := big_opL o (λ _, f) (elements X).
Definition big_opS_aux : seal (@big_opS_def). by eexists. Qed.
Definition big_opS := big_opS_aux.(unseal).
Arguments big_opS {M} o {_ A _ _} _ _.
Definition big_opS_eq : @big_opS = @big_opS_def := big_opS_aux.(seal_eq).
Instance: Params (@big_opS) 6 := {}. Instance: Params (@big_opS) 6 := {}.
Arguments big_opS {M} o {_ A _ _} _ _ : simpl never.
Typeclasses Opaque big_opS.
Notation "'[^' o 'set]' x ∈ X , P" := (big_opS o (λ x, P) X) Notation "'[^' o 'set]' x ∈ X , P" := (big_opS o (λ x, P) X)
(at level 200, o at level 1, X at level 10, x at level 1, right associativity, (at level 200, o at level 1, X at level 10, x at level 1, right associativity,
format "[^ o set] x ∈ X , P") : stdpp_scope. format "[^ o set] x ∈ X , P") : stdpp_scope.
Definition big_opMS `{Monoid M o} `{Countable A} (f : A M) Definition big_opMS_def `{Monoid M o} `{Countable A} (f : A M)
(X : gmultiset A) : M := big_opL o (λ _, f) (elements X). (X : gmultiset A) : M := big_opL o (λ _, f) (elements X).
Instance: Params (@big_opMS) 7 := {}. Definition big_opMS_aux : seal (@big_opMS_def). by eexists. Qed.
Arguments big_opMS {M} o {_ A _ _} _ _ : simpl never. Definition big_opMS := big_opMS_aux.(unseal).
Typeclasses Opaque big_opMS. Arguments big_opMS {M} o {_ A _ _} _ _.
Definition big_opMS_eq : @big_opMS = @big_opMS_def := big_opMS_aux.(seal_eq).
Instance: Params (@big_opMS) 6 := {}.
Notation "'[^' o 'mset]' x ∈ X , P" := (big_opMS o (λ x, P) X) Notation "'[^' o 'mset]' x ∈ X , P" := (big_opMS o (λ x, P) X)
(at level 200, o at level 1, X at level 10, x at level 1, right associativity, (at level 200, o at level 1, X at level 10, x at level 1, right associativity,
format "[^ o mset] x ∈ X , P") : stdpp_scope. format "[^ o mset] x ∈ X , P") : stdpp_scope.
...@@ -171,7 +177,7 @@ Section gmap. ...@@ -171,7 +177,7 @@ Section gmap.
( k x, m !! k = Some x R (f k x) (g k x)) ( k x, m !! k = Some x R (f k x) (g k x))
R ([^o map] k x m, f k x) ([^o map] k x m, g k x). R ([^o map] k x m, f k x) ([^o map] k x m, g k x).
Proof. Proof.
intros ?? Hf. apply (big_opL_forall R); auto. intros ?? Hf. rewrite big_opM_eq. apply (big_opL_forall R); auto.
intros k [i x] ?%elem_of_list_lookup_2. by apply Hf, elem_of_map_to_list. intros k [i x] ?%elem_of_list_lookup_2. by apply Hf, elem_of_map_to_list.
Qed. Qed.
...@@ -194,12 +200,12 @@ Section gmap. ...@@ -194,12 +200,12 @@ Section gmap.
Proof. intros f g Hf m ? <-. apply big_opM_forall; apply _ || intros; apply Hf. Qed. Proof. intros f g Hf m ? <-. apply big_opM_forall; apply _ || intros; apply Hf. Qed.
Lemma big_opM_empty f : ([^o map] kx , f k x) = monoid_unit. Lemma big_opM_empty f : ([^o map] kx , f k x) = monoid_unit.
Proof. by rewrite /big_opM map_to_list_empty. Qed. Proof. by rewrite big_opM_eq /big_opM_def map_to_list_empty. Qed.
Lemma big_opM_insert f m i x : Lemma big_opM_insert f m i x :
m !! i = None m !! i = None
([^o map] ky <[i:=x]> m, f k y) f i x `o` [^o map] ky m, f k y. ([^o map] ky <[i:=x]> m, f k y) f i x `o` [^o map] ky m, f k y.
Proof. intros ?. by rewrite /big_opM map_to_list_insert. Qed. Proof. intros ?. by rewrite big_opM_eq /big_opM_def map_to_list_insert. Qed.
Lemma big_opM_delete f m i x : Lemma big_opM_delete f m i x :
m !! i = Some x m !! i = Some x
...@@ -216,12 +222,12 @@ Section gmap. ...@@ -216,12 +222,12 @@ Section gmap.
Qed. Qed.
Lemma big_opM_unit m : ([^o map] ky m, monoid_unit) (monoid_unit : M). Lemma big_opM_unit m : ([^o map] ky m, monoid_unit) (monoid_unit : M).
Proof. induction m using map_ind; rewrite /= ?big_opM_insert ?left_id //. Qed. Proof. by induction m using map_ind; rewrite /= ?big_opM_insert ?left_id // big_opM_eq. Qed.
Lemma big_opM_fmap {B} (h : A B) (f : K B M) m : Lemma big_opM_fmap {B} (h : A B) (f : K B M) m :
([^o map] ky h <$> m, f k y) ([^o map] ky m, f k (h y)). ([^o map] ky h <$> m, f k y) ([^o map] ky m, f k (h y)).
Proof. Proof.
rewrite /big_opM map_to_list_fmap big_opL_fmap. rewrite big_opM_eq /big_opM_def map_to_list_fmap big_opL_fmap.
by apply big_opL_proper=> ? [??]. by apply big_opL_proper=> ? [??].
Qed. Qed.
...@@ -262,7 +268,7 @@ Section gmap. ...@@ -262,7 +268,7 @@ Section gmap.
Lemma big_opM_op f g m : Lemma big_opM_op f g m :
([^o map] kx m, f k x `o` g k x) ([^o map] kx m, f k x `o` g k x)
([^o map] kx m, f k x) `o` ([^o map] kx m, g k x). ([^o map] kx m, f k x) `o` ([^o map] kx m, g k x).
Proof. rewrite /big_opM -big_opL_op. by apply big_opL_proper=> ? [??]. Qed. Proof. rewrite big_opM_eq /big_opM_def -big_opL_op. by apply big_opL_proper=> ? [??]. Qed.
End gmap. End gmap.
...@@ -277,7 +283,7 @@ Section gset. ...@@ -277,7 +283,7 @@ Section gset.
( x, x X R (f x) (g x)) ( x, x X R (f x) (g x))
R ([^o set] x X, f x) ([^o set] x X, g x). R ([^o set] x X, f x) ([^o set] x X, g x).
Proof. Proof.
intros ?? Hf. apply (big_opL_forall R); auto. rewrite big_opS_eq. intros ?? Hf. apply (big_opL_forall R); auto.
intros k x ?%elem_of_list_lookup_2. by apply Hf, elem_of_elements. intros k x ?%elem_of_list_lookup_2. by apply Hf, elem_of_elements.
Qed. Qed.
...@@ -298,11 +304,11 @@ Section gset. ...@@ -298,11 +304,11 @@ Section gset.
Proof. intros f g Hf m ? <-. apply big_opS_forall; apply _ || intros; apply Hf. Qed. Proof. intros f g Hf m ? <-. apply big_opS_forall; apply _ || intros; apply Hf. Qed.
Lemma big_opS_empty f : ([^o set] x , f x) = monoid_unit. Lemma big_opS_empty f : ([^o set] x , f x) = monoid_unit.
Proof. by rewrite /big_opS elements_empty. Qed. Proof. by rewrite big_opS_eq /big_opS_def elements_empty. Qed.
Lemma big_opS_insert f X x : Lemma big_opS_insert f X x :
x X ([^o set] y {[ x ]} X, f y) (f x `o` [^o set] y X, f y). x X ([^o set] y {[ x ]} X, f y) (f x `o` [^o set] y X, f y).
Proof. intros. by rewrite /big_opS elements_union_singleton. Qed. Proof. intros. by rewrite big_opS_eq /big_opS_def elements_union_singleton. Qed.
Lemma big_opS_fn_insert {B} (f : A B M) h X x b : Lemma big_opS_fn_insert {B} (f : A B M) h X x b :
x X x X
([^o set] y {[ x ]} X, f y (<[x:=b]> h y)) ([^o set] y {[ x ]} X, f y (<[x:=b]> h y))
...@@ -334,22 +340,22 @@ Section gset. ...@@ -334,22 +340,22 @@ Section gset.
Qed. Qed.
Lemma big_opS_singleton f x : ([^o set] y {[ x ]}, f y) f x. Lemma big_opS_singleton f x : ([^o set] y {[ x ]}, f y) f x.
Proof. intros. by rewrite /big_opS elements_singleton /= right_id. Qed. Proof. intros. by rewrite big_opS_eq /big_opS_def elements_singleton /= right_id. Qed.
Lemma big_opS_unit X : ([^o set] y X, monoid_unit) (monoid_unit : M). Lemma big_opS_unit X : ([^o set] y X, monoid_unit) (monoid_unit : M).
Proof. Proof.
induction X using set_ind_L; rewrite /= ?big_opS_insert ?left_id //. by induction X using set_ind_L; rewrite /= ?big_opS_insert ?left_id // big_opS_eq.
Qed. Qed.
Lemma big_opS_op f g X : Lemma big_opS_op f g X :
([^o set] y X, f y `o` g y) ([^o set] y X, f y) `o` ([^o set] y X, g y). ([^o set] y X, f y `o` g y) ([^o set] y X, f y) `o` ([^o set] y X, g y).
Proof. by rewrite /big_opS -big_opL_op. Qed. Proof. by rewrite big_opS_eq /big_opS_def -big_opL_op. Qed.
End gset. End gset.
Lemma big_opM_dom `{Countable K} {A} (f : K M) (m : gmap K A) : Lemma big_opM_dom `{Countable K} {A} (f : K M) (m : gmap K A) :
([^o map] k_ m, f k) ([^o set] k dom _ m, f k). ([^o map] k_ m, f k) ([^o set] k dom _ m, f k).
Proof. Proof.
induction m as [|i x ?? IH] using map_ind; [by rewrite dom_empty_L|]. induction m as [|i x ?? IH] using map_ind; [by rewrite big_opM_eq big_opS_eq dom_empty_L|].
by rewrite dom_insert_L big_opM_insert // IH big_opS_insert ?not_elem_of_dom. by rewrite dom_insert_L big_opM_insert // IH big_opS_insert ?not_elem_of_dom.
Qed. Qed.
...@@ -364,7 +370,7 @@ Section gmultiset. ...@@ -364,7 +370,7 @@ Section gmultiset.
( x, x X R (f x) (g x)) ( x, x X R (f x) (g x))
R ([^o mset] x X, f x) ([^o mset] x X, g x). R ([^o mset] x X, f x) ([^o mset] x X, g x).
Proof. Proof.
intros ?? Hf. apply (big_opL_forall R); auto. rewrite big_opMS_eq. intros ?? Hf. apply (big_opL_forall R); auto.
intros k x ?%elem_of_list_lookup_2. by apply Hf, gmultiset_elem_of_elements. intros k x ?%elem_of_list_lookup_2. by apply Hf, gmultiset_elem_of_elements.
Qed. Qed.
...@@ -385,15 +391,15 @@ Section gmultiset. ...@@ -385,15 +391,15 @@ Section gmultiset.
Proof. intros f g Hf m ? <-. apply big_opMS_forall; apply _ || intros; apply Hf. Qed. Proof. intros f g Hf m ? <-. apply big_opMS_forall; apply _ || intros; apply Hf. Qed.
Lemma big_opMS_empty f : ([^o mset] x , f x) = monoid_unit. Lemma big_opMS_empty f : ([^o mset] x , f x) = monoid_unit.
Proof. by rewrite /big_opMS gmultiset_elements_empty. Qed. Proof. by rewrite big_opMS_eq /big_opMS_def gmultiset_elements_empty. Qed.
Lemma big_opMS_disj_union f X Y : Lemma big_opMS_disj_union f X Y :
([^o mset] y X Y, f y) ([^o mset] y X, f y) `o` [^o mset] y Y, f y. ([^o mset] y X Y, f y) ([^o mset] y X, f y) `o` [^o mset] y Y, f y.
Proof. by rewrite /big_opMS gmultiset_elements_disj_union big_opL_app. Qed. Proof. by rewrite big_opMS_eq /big_opMS_def gmultiset_elements_disj_union big_opL_app. Qed.
Lemma big_opMS_singleton f x : ([^o mset] y {[ x ]}, f y) f x. Lemma big_opMS_singleton f x : ([^o mset] y {[ x ]}, f y) f x.
Proof. Proof.
intros. by rewrite /big_opMS gmultiset_elements_singleton /= right_id. intros. by rewrite big_opMS_eq /big_opMS_def gmultiset_elements_singleton /= right_id.
Qed. Qed.
Lemma big_opMS_delete f X x : Lemma big_opMS_delete f X x :
...@@ -405,13 +411,13 @@ Section gmultiset. ...@@ -405,13 +411,13 @@ Section gmultiset.
Lemma big_opMS_unit X : ([^o mset] y X, monoid_unit) (monoid_unit : M). Lemma big_opMS_unit X : ([^o mset] y X, monoid_unit) (monoid_unit : M).
Proof. Proof.
induction X using gmultiset_ind; by induction X using gmultiset_ind;
rewrite /= ?big_opMS_disj_union ?big_opMS_singleton ?left_id //. rewrite /= ?big_opMS_disj_union ?big_opMS_singleton ?left_id // big_opMS_eq.
Qed. Qed.
Lemma big_opMS_op f g X : Lemma big_opMS_op f g X :
([^o mset] y X, f y `o` g y) ([^o mset] y X, f y) `o` ([^o mset] y X, g y). ([^o mset] y X, f y `o` g y) ([^o mset] y X, f y) `o` ([^o mset] y X, g y).
Proof. by rewrite /big_opMS -big_opL_op. Qed. Proof. by rewrite big_opMS_eq /big_opMS_def -big_opL_op. Qed.
End gmultiset. End gmultiset.
End big_op. End big_op.
......
...@@ -13,7 +13,7 @@ Qed. ...@@ -13,7 +13,7 @@ Qed.
Lemma big_opM_None {M : cmraT} `{Countable K} {A} (f : K A option M) m : Lemma big_opM_None {M : cmraT} `{Countable K} {A} (f : K A option M) m :
([^op map] kx m, f k x) = None k x, m !! k = Some x f k x = None. ([^op map] kx m, f k x) = None k x, m !! k = Some x f k x = None.
Proof. Proof.
induction m as [|i x m ? IH] using map_ind=> //=. induction m as [|i x m ? IH] using map_ind=> /=; first by rewrite big_opM_eq.
rewrite -equiv_None big_opM_insert // equiv_None op_None IH. split. rewrite -equiv_None big_opM_insert // equiv_None op_None IH. split.
{ intros [??] k y. rewrite lookup_insert_Some; naive_solver. } { intros [??] k y. rewrite lookup_insert_Some; naive_solver. }
intros Hm; split. intros Hm; split.
...@@ -23,7 +23,7 @@ Qed. ...@@ -23,7 +23,7 @@ Qed.
Lemma big_opS_None {M : cmraT} `{Countable A} (f : A option M) X : Lemma big_opS_None {M : cmraT} `{Countable A} (f : A option M) X :
([^op set] x X, f x) = None x, x X f x = None. ([^op set] x X, f x) = None x, x X f x = None.
Proof. Proof.
induction X as [|x X ? IH] using set_ind_L; [done|]. induction X as [|x X ? IH] using set_ind_L; [by rewrite big_opS_eq |].
rewrite -equiv_None big_opS_insert // equiv_None op_None IH. set_solver. rewrite -equiv_None big_opS_insert // equiv_None op_None IH. set_solver.
Qed. Qed.
Lemma big_opMS_None {M : cmraT} `{Countable A} (f : A option M) X : Lemma big_opMS_None {M : cmraT} `{Countable A} (f : A option M) X :
......
...@@ -100,7 +100,7 @@ Qed. ...@@ -100,7 +100,7 @@ Qed.
Lemma box_alloc : box N True%I. Lemma box_alloc : box N True%I.
Proof. Proof.
iIntros. iExists (λ _, True)%I. iSplit; by auto. iIntros. iExists (λ _, True)%I. by rewrite !big_opM_empty.
Qed. Qed.
Lemma slice_insert_empty E q f Q P : Lemma slice_insert_empty E q f Q P :
......
...@@ -50,12 +50,15 @@ Notation "'[∗' 'list]' k ↦ x1 ; x2 ∈ l1 ; l2 , P" := ...@@ -50,12 +50,15 @@ Notation "'[∗' 'list]' k ↦ x1 ; x2 ∈ l1 ; l2 , P" :=
Notation "'[∗' 'list]' x1 ; x2 ∈ l1 ; l2 , P" := Notation "'[∗' 'list]' x1 ; x2 ∈ l1 ; l2 , P" :=
(big_sepL2 (λ _ x1 x2, P) l1 l2) : bi_scope. (big_sepL2 (λ _ x1 x2, P) l1 l2) : bi_scope.
Definition big_sepM2 {PROP : bi} `{Countable K} {A B} Definition big_sepM2_def {PROP : bi} `{Countable K} {A B}
(Φ : K A B PROP) (m1 : gmap K A) (m2 : gmap K B) : PROP := (Φ : K A B PROP) (m1 : gmap K A) (m2 : gmap K B) : PROP :=
( k, is_Some (m1 !! k) is_Some (m2 !! k) ( k, is_Some (m1 !! k) is_Some (m2 !! k)
[ map] k xy map_zip m1 m2, Φ k xy.1 xy.2)%I. [ map] k xy map_zip m1 m2, Φ k xy.1 xy.2)%I.
Definition big_sepM2_aux : seal (@big_sepM2_def). by eexists. Qed.
Definition big_sepM2 := big_sepM2_aux.(unseal).
Arguments big_sepM2 {PROP K _ _ A B} _ _ _.
Definition big_sepM2_eq : @big_sepM2 = @big_sepM2_def := big_sepM2_aux.(seal_eq).
Instance: Params (@big_sepM2) 6 := {}. Instance: Params (@big_sepM2) 6 := {}.
Typeclasses Opaque big_sepM2.
Notation "'[∗' 'map]' k ↦ x1 ; x2 ∈ m1 ; m2 , P" := Notation "'[∗' 'map]' k ↦ x1 ; x2 ∈ m1 ; m2 , P" :=
(big_sepM2 (λ k x1 x2, P) m1 m2) : bi_scope. (big_sepM2 (λ k x1 x2, P) m1 m2) : bi_scope.
Notation "'[∗' 'map]' x1 ; x2 ∈ m1 ; m2 , P" := Notation "'[∗' 'map]' x1 ; x2 ∈ m1 ; m2 , P" :=
...@@ -687,7 +690,7 @@ Section map. ...@@ -687,7 +690,7 @@ Section map.
Proof. apply big_opM_proper. Qed. Proof. apply big_opM_proper. Qed.
Lemma big_sepM_subseteq `{BiAffine PROP} Φ m1 m2 : Lemma big_sepM_subseteq `{BiAffine PROP} Φ m1 m2 :
m2 m1 ([ map] k x m1, Φ k x) [ map] k x m2, Φ k x. m2 m1 ([ map] k x m1, Φ k x) [ map] k x m2, Φ k x.
Proof. intros. by apply big_sepL_submseteq, map_to_list_submseteq. Qed. Proof. rewrite big_opM_eq. intros. by apply big_sepL_submseteq, map_to_list_submseteq. Qed.
Global Instance big_sepM_mono' : Global Instance big_sepM_mono' :
Proper (pointwise_relation _ (pointwise_relation _ ()) ==> (=) ==> ()) Proper (pointwise_relation _ (pointwise_relation _ ()) ==> (=) ==> ())
...@@ -834,7 +837,7 @@ Section map. ...@@ -834,7 +837,7 @@ Section map.
[ map] kx m, Ψ k x. [ map] kx m, Ψ k x.
Proof. Proof.
apply wand_intro_l. induction m as [|i x m ? IH] using map_ind. apply wand_intro_l. induction m as [|i x m ? IH] using map_ind.
{ by rewrite sep_elim_r. } { by rewrite big_opM_eq sep_elim_r. }
rewrite !big_sepM_insert // intuitionistically_sep_dup. rewrite !big_sepM_insert // intuitionistically_sep_dup.
rewrite -assoc [( _ _)%I]comm -!assoc assoc. apply sep_mono. rewrite -assoc [( _ _)%I]comm -!assoc assoc. apply sep_mono.
- rewrite (forall_elim i) (forall_elim x) pure_True ?lookup_insert //. - rewrite (forall_elim i) (forall_elim x) pure_True ?lookup_insert //.
...@@ -848,17 +851,17 @@ Section map. ...@@ -848,17 +851,17 @@ Section map.
Global Instance big_sepM_empty_persistent Φ : Global Instance big_sepM_empty_persistent Φ :
Persistent ([ map] kx , Φ k x). Persistent ([ map] kx , Φ k x).
Proof. rewrite /big_opM map_to_list_empty. apply _. Qed. Proof. rewrite big_opM_eq /big_opM_def map_to_list_empty. apply _. Qed.
Global Instance big_sepM_persistent Φ m : Global Instance big_sepM_persistent Φ m :
( k x, Persistent (Φ k x)) Persistent ([ map] kx m, Φ k x). ( k x, Persistent (Φ k x)) Persistent ([ map] kx m, Φ k x).
Proof. intros. apply big_sepL_persistent=> _ [??]; apply _. Qed. Proof. rewrite big_opM_eq. intros. apply big_sepL_persistent=> _ [??]; apply _. Qed.
Global Instance big_sepM_empty_affine Φ : Global Instance big_sepM_empty_affine Φ :
Affine ([ map] kx , Φ k x). Affine ([ map] kx , Φ k x).
Proof. rewrite /big_opM map_to_list_empty. apply _. Qed. Proof. rewrite big_opM_eq /big_opM_def map_to_list_empty. apply _. Qed.
Global Instance big_sepM_affine Φ m : Global Instance big_sepM_affine Φ m :
( k x, Affine (Φ k x)) Affine ([ map] kx m, Φ k x). ( k x, Affine (Φ k x)) Affine ([ map] kx m, Φ k x).
Proof. intros. apply big_sepL_affine=> _ [??]; apply _. Qed. Proof. rewrite big_opM_eq. intros. apply big_sepL_affine=> _ [??]; apply _. Qed.
End map. End map.
(** ** Big ops over two maps *) (** ** Big ops over two maps *)
...@@ -869,7 +872,7 @@ Section map2. ...@@ -869,7 +872,7 @@ Section map2.
Lemma big_sepM2_dom Φ m1 m2 : Lemma big_sepM2_dom Φ m1 m2 :
([ map] ky1;y2 m1; m2, Φ k y1 y2) - dom (gset K) m1 = dom (gset K) m2 . ([ map] ky1;y2 m1; m2, Φ k y1 y2) - dom (gset K) m1 = dom (gset K) m2 .
Proof. Proof.
rewrite /big_sepM2 and_elim_l. apply pure_mono=>Hm. rewrite big_sepM2_eq /big_sepM2_def and_elim_l. apply pure_mono=>Hm.
set_unfold=>k. by rewrite !elem_of_dom. set_unfold=>k. by rewrite !elem_of_dom.
Qed. Qed.
...@@ -877,7 +880,8 @@ Section map2. ...@@ -877,7 +880,8 @@ Section map2.
( k y1 y2, m1 !! k = Some y1 m2 !! k = Some y2 Φ k y1 y2 Ψ k y1 y2) ( k y1 y2, m1 !! k = Some y1 m2 !! k = Some y2 Φ k y1 y2 Ψ k y1 y2)
([ map] k y1;y2 m1;m2, Φ k y1 y2) [ map] k y1;y2 m1;m2, Ψ k y1 y2. ([ map] k y1;y2 m1;m2, Φ k y1 y2) [ map] k y1;y2 m1;m2, Ψ k y1 y2.
Proof. Proof.
intros Hm1m2. rewrite /big_sepM2. apply and_mono_r, big_sepM_mono. intros Hm1m2. rewrite big_sepM2_eq /big_sepM2_def.
apply and_mono_r, big_sepM_mono.
intros k [x1 x2]. rewrite map_lookup_zip_with. intros k [x1 x2]. rewrite map_lookup_zip_with.
specialize (Hm1m2 k x1 x2). specialize (Hm1m2 k x1 x2).
destruct (m1 !! k) as [y1|]; last done. destruct (m1 !! k) as [y1|]; last done.
...@@ -897,8 +901,8 @@ Section map2. ...@@ -897,8 +901,8 @@ Section map2.
==> (=) ==> (=) ==> (dist n)) ==> (=) ==> (=) ==> (dist n))
(big_sepM2 (PROP:=PROP) (K:=K) (A:=A) (B:=B)). (big_sepM2 (PROP:=PROP) (K:=K) (A:=A) (B:=B)).
Proof. Proof.
intros Φ1 Φ2 HΦ x1 ? <- x2 ? <-. rewrite /big_sepM2. f_equiv. intros Φ1 Φ2 HΦ x1 ? <- x2 ? <-. rewrite big_sepM2_eq /big_sepM2_def.
f_equiv=> k [y1 y2]. apply HΦ. f_equiv. f_equiv=> k [y1 y2]. apply HΦ.
Qed. Qed.
Global Instance big_sepM2_mono' : Global Instance big_sepM2_mono' :
Proper (pointwise_relation _ (pointwise_relation _ (pointwise_relation _ ())) Proper (pointwise_relation _ (pointwise_relation _ (pointwise_relation _ ()))
...@@ -913,7 +917,7 @@ Section map2. ...@@ -913,7 +917,7 @@ Section map2.
Lemma big_sepM2_empty Φ : ([ map] ky1;y2 ; , Φ k y1 y2) emp. Lemma big_sepM2_empty Φ : ([ map] ky1;y2 ; , Φ k y1 y2) emp.
Proof. Proof.
rewrite /big_sepM2 pure_True ?left_id //. rewrite big_sepM2_eq /big_sepM2_def big_opM_eq pure_True ?left_id //.
intros k. rewrite !lookup_empty; split; by inversion 1. intros k. rewrite !lookup_empty; split; by inversion 1.
Qed. Qed.
Lemma big_sepM2_empty' `{BiAffine PROP} P Φ : P [ map] ky1;y2 ;, Φ k y1 y2. Lemma big_sepM2_empty' `{BiAffine PROP} P Φ : P [ map] ky1;y2 ;, Φ k y1 y2.
...@@ -938,7 +942,7 @@ Section map2. ...@@ -938,7 +942,7 @@ Section map2.
([ map] ky1;y2 <[i:=x1]>m1; <[i:=x2]>m2, Φ k y1 y2) ([ map] ky1;y2 <[i:=x1]>m1; <[i:=x2]>m2, Φ k y1 y2)
Φ i x1 x2 [ map] ky1;y2 m1;m2, Φ k y1 y2. Φ i x1 x2 [ map] ky1;y2 m1;m2, Φ k y1 y2.
Proof. Proof.
intros Hm1 Hm2. rewrite /big_sepM2 -map_insert_zip_with. intros Hm1 Hm2. rewrite big_sepM2_eq /big_sepM2_def -map_insert_zip_with.
rewrite big_sepM_insert; rewrite big_sepM_insert;
last by rewrite map_lookup_zip_with Hm1. last by rewrite map_lookup_zip_with Hm1.
rewrite !persistent_and_affinely_sep_l /=. rewrite !persistent_and_affinely_sep_l /=.
...@@ -959,7 +963,7 @@ Section map2. ...@@ -959,7 +963,7 @@ Section map2.
([ map] kx;y m1;m2, Φ k x y) ([ map] kx;y m1;m2, Φ k x y)
Φ i x1 x2 [ map] kx;y delete i m1;delete i m2, Φ k x y. Φ i x1 x2 [ map] kx;y delete i m1;delete i m2, Φ k x y.
Proof. Proof.
rewrite /big_sepM2 => Hx1 Hx2. rewrite big_sepM2_eq /big_sepM2_def => Hx1 Hx2.
rewrite !persistent_and_affinely_sep_l /=. rewrite !persistent_and_affinely_sep_l /=.
rewrite sep_assoc (sep_comm (Φ _ _ _)) -sep_assoc. rewrite sep_assoc (sep_comm (Φ _ _ _)) -sep_assoc.
apply sep_proper. apply sep_proper.
...@@ -993,7 +997,7 @@ Section map2. ...@@ -993,7 +997,7 @@ Section map2.
([ map] ky1;y2 m1;m2, Φ k y1 y2) - ([ map] ky1;y2 m1;m2, Φ k y1 y2) -
([ map] ky1;y2 <[i:=x1]>m1; <[i:=x2]>m2, Φ k y1 y2). ([ map] ky1;y2 <[i:=x1]>m1; <[i:=x2]>m2, Φ k y1 y2).
Proof. Proof.
intros Ha. rewrite /big_sepM2.