Commit 5de26893 authored by Robbert's avatar Robbert

Merge branch 'robbert/some_cmra_lemmas' into 'master'

Generalize `Excl_included` & more `singleton_included` lemmas

See merge request iris/iris!419
parents 65860ea8 a73602c0
...@@ -95,6 +95,12 @@ Coq development, but not every API-breaking change is listed. Changes marked ...@@ -95,6 +95,12 @@ Coq development, but not every API-breaking change is listed. Changes marked
* Better support for telescopes in the proof mode, i.e., all tactics should * Better support for telescopes in the proof mode, i.e., all tactics should
recognize and distribute telescopes now. recognize and distribute telescopes now.
* Remove namespace `N` from `is_lock`. * Remove namespace `N` from `is_lock`.
* Make lemma `Excl_included` a bi-implication.
* Add lemma `singleton_included : {[ i := x ]} ≼ ({[ i := y ]} ↔ x ≡ y ∨ x ≼ y`,
and rename existing asymmetric lemmas (with a singleton on just the LHS):
+ `singleton_includedN``singleton_includedN_l`.
+ `singleton_included``singleton_included_l`.
+ `singleton_included_exclusive``singleton_included_exclusive_l`
**Changes in heap_lang:** **Changes in heap_lang:**
......
...@@ -118,10 +118,14 @@ Proof. by destruct mx. Qed. ...@@ -118,10 +118,14 @@ Proof. by destruct mx. Qed.
Lemma excl_validN_inv_r n mx a : {n} (mx Excl' a) mx = None. Lemma excl_validN_inv_r n mx a : {n} (mx Excl' a) mx = None.
Proof. by destruct mx. Qed. Proof. by destruct mx. Qed.
Lemma Excl_includedN n a b : Excl' a {n} Excl' b a {n} b. Lemma Excl_includedN n a b : Excl' a {n} Excl' b a {n} b.
Proof. by intros [[c|] Hb%(inj Some)]; inversion_clear Hb. Qed. Proof.
Lemma Excl_included a b : Excl' a Excl' b a b. split; [|by intros ->]. by intros [[c|] Hb%(inj Some)]; inversion_clear Hb.
Proof. by intros [[c|] Hb%(inj Some)]; inversion_clear Hb. Qed. Qed.
Lemma Excl_included a b : Excl' a Excl' b a b.
Proof.
split; [|by intros ->]. by intros [[c|] Hb%(inj Some)]; inversion_clear Hb.
Qed.
End excl. End excl.
Arguments exclO : clear implicits. Arguments exclO : clear implicits.
......
...@@ -308,7 +308,7 @@ Global Instance gmap_singleton_core_id i (x : A) : ...@@ -308,7 +308,7 @@ Global Instance gmap_singleton_core_id i (x : A) :
CoreId x CoreId {[ i := x ]}. CoreId x CoreId {[ i := x ]}.
Proof. intros. by apply core_id_total, core_singleton'. Qed. Proof. intros. by apply core_id_total, core_singleton'. Qed.
Lemma singleton_includedN n m i x : Lemma singleton_includedN_l n m i x :
{[ i := x ]} {n} m y, m !! i {n} Some y Some x {n} Some y. {[ i := x ]} {n} m y, m !! i {n} Some y Some x {n} Some y.
Proof. Proof.
split. split.
...@@ -321,7 +321,7 @@ Proof. ...@@ -321,7 +321,7 @@ Proof.
+ by rewrite lookup_op lookup_singleton_ne// lookup_partial_alter_ne// left_id. + by rewrite lookup_op lookup_singleton_ne// lookup_partial_alter_ne// left_id.
Qed. Qed.
(* We do not have [x ≼ y ↔ ∀ n, x ≼{n} y], so we cannot use the previous lemma *) (* We do not have [x ≼ y ↔ ∀ n, x ≼{n} y], so we cannot use the previous lemma *)
Lemma singleton_included m i x : Lemma singleton_included_l m i x :
{[ i := x ]} m y, m !! i Some y Some x Some y. {[ i := x ]} m y, m !! i Some y Some x Some y.
Proof. Proof.
split. split.
...@@ -333,13 +333,21 @@ Proof. ...@@ -333,13 +333,21 @@ Proof.
+ by rewrite lookup_op lookup_singleton lookup_partial_alter Hi. + by rewrite lookup_op lookup_singleton lookup_partial_alter Hi.
+ by rewrite lookup_op lookup_singleton_ne// lookup_partial_alter_ne// left_id. + by rewrite lookup_op lookup_singleton_ne// lookup_partial_alter_ne// left_id.
Qed. Qed.
Lemma singleton_included_exclusive m i x : Lemma singleton_included_exclusive_l m i x :
Exclusive x m Exclusive x m
{[ i := x ]} m m !! i Some x. {[ i := x ]} m m !! i Some x.
Proof. Proof.
intros ? Hm. rewrite singleton_included. split; last by eauto. intros ? Hm. rewrite singleton_included_l. split; last by eauto.
intros (y&?&->%(Some_included_exclusive _)); eauto using lookup_valid_Some. intros (y&?&->%(Some_included_exclusive _)); eauto using lookup_valid_Some.
Qed. Qed.
Lemma singleton_included i x y :
{[ i := x ]} ({[ i := y ]} : gmap K A) x y x y.
Proof.
rewrite singleton_included_l. split.
- intros (y'&Hi&?). rewrite lookup_insert in Hi.
apply Some_included. by rewrite Hi.
- intros ?. exists y. by rewrite lookup_insert Some_included.
Qed.
Global Instance singleton_cancelable i x : Global Instance singleton_cancelable i x :
Cancelable (Some x) Cancelable {[ i := x ]}. Cancelable (Some x) Cancelable {[ i := x ]}.
......
...@@ -146,7 +146,7 @@ Section to_gen_heap. ...@@ -146,7 +146,7 @@ Section to_gen_heap.
Lemma gen_heap_singleton_included σ l q v : Lemma gen_heap_singleton_included σ l q v :
{[l := (q, to_agree v)]} to_gen_heap σ σ !! l = Some v. {[l := (q, to_agree v)]} to_gen_heap σ σ !! l = Some v.
Proof. Proof.
rewrite singleton_included=> -[[q' av] []]. rewrite singleton_included_l=> -[[q' av] []].
rewrite /to_gen_heap lookup_fmap fmap_Some_equiv => -[v' [Hl [/= -> ->]]]. rewrite /to_gen_heap lookup_fmap fmap_Some_equiv => -[v' [Hl [/= -> ->]]].
move=> /Some_pair_included_total_2 [_] /to_agree_included /leibniz_equiv_iff -> //. move=> /Some_pair_included_total_2 [_] /to_agree_included /leibniz_equiv_iff -> //.
Qed. Qed.
......
...@@ -102,7 +102,7 @@ Section to_proph_map. ...@@ -102,7 +102,7 @@ Section to_proph_map.
Lemma proph_map_singleton_included R p vs : Lemma proph_map_singleton_included R p vs :
{[p := Excl vs]} to_proph_map R R !! p = Some vs. {[p := Excl vs]} to_proph_map R R !! p = Some vs.
Proof. Proof.
rewrite singleton_included_exclusive; last by apply to_proph_map_valid. rewrite singleton_included_exclusive_l; last by apply to_proph_map_valid.
by rewrite leibniz_equiv_iff /to_proph_map lookup_fmap fmap_Some=> -[v' [-> [->]]]. by rewrite leibniz_equiv_iff /to_proph_map lookup_fmap fmap_Some=> -[v' [-> [->]]].
Qed. Qed.
End to_proph_map. End to_proph_map.
......
...@@ -90,8 +90,8 @@ Section lifting. ...@@ -90,8 +90,8 @@ Section lifting.
Lemma ownP_eq σ1 σ2 κs n : state_interp σ1 κs n - ownP σ2 - ⌜σ1 = σ2. Lemma ownP_eq σ1 σ2 κs n : state_interp σ1 κs n - ownP σ2 - ⌜σ1 = σ2.
Proof. Proof.
iIntros "Hσ● Hσ◯". rewrite /ownP. iIntros "Hσ● Hσ◯". rewrite /ownP.
iDestruct (own_valid_2 with "Hσ● Hσ◯") as %[Hps _]%auth_both_valid. by iDestruct (own_valid_2 with "Hσ● Hσ◯")
by pose proof (leibniz_equiv _ _ (Excl_included _ _ Hps)) as ->. as %[->%Excl_included _]%auth_both_valid.
Qed. Qed.
Lemma ownP_state_twice σ1 σ2 : ownP σ1 ownP σ2 False. Lemma ownP_state_twice σ1 σ2 : ownP σ1 ownP σ2 False.
Proof. rewrite /ownP -own_op own_valid. by iIntros (?). Qed. Proof. rewrite /ownP -own_op own_valid. by iIntros (?). Qed.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment