saved_prop.v 1.88 KB
Newer Older
Ralf Jung's avatar
Ralf Jung committed
1
From iris.base_logic Require Export own.
2 3
From iris.algebra Require Import agree.
From iris.prelude Require Import gmap.
4
Set Default Proof Using "Type".
Robbert Krebbers's avatar
Robbert Krebbers committed
5 6
Import uPred.

7 8
Class savedPropG (Σ : gFunctors) (F : cFunctor) :=
  saved_prop_inG :> inG Σ (agreeR (laterC (F (iPreProp Σ)))).
9 10
Definition savedPropΣ (F : cFunctor) : gFunctors :=
  #[ GFunctor (agreeRF ( F)) ].
11

12 13
Instance subG_savedPropΣ  {Σ F} : subG (savedPropΣ F) Σ  savedPropG Σ F.
Proof. apply subG_inG. Qed.
14

15 16
Definition saved_prop_own `{savedPropG Σ F}
    (γ : gname) (x : F (iProp Σ)) : iProp Σ :=
17
  own γ (to_agree $ Next (cFunctor_map F (iProp_fold, iProp_unfold) x)).
18
Typeclasses Opaque saved_prop_own.
19
Instance: Params (@saved_prop_own) 3.
Robbert Krebbers's avatar
Robbert Krebbers committed
20

21
Section saved_prop.
22 23
  Context `{savedPropG Σ F}.
  Implicit Types x y : F (iProp Σ).
Robbert Krebbers's avatar
Robbert Krebbers committed
24 25
  Implicit Types γ : gname.

26 27
  Global Instance saved_prop_persistent γ x : PersistentP (saved_prop_own γ x).
  Proof. rewrite /saved_prop_own; apply _. Qed.
28

29
  Lemma saved_prop_alloc_strong x (G : gset gname) :
30
    (|==>  γ, ⌜γ  G  saved_prop_own γ x)%I.
31
  Proof. by apply own_alloc_strong. Qed.
32

33
  Lemma saved_prop_alloc x : (|==>  γ, saved_prop_own γ x)%I.
34
  Proof. by apply own_alloc. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
35

36
  Lemma saved_prop_agree γ x y :
37
    saved_prop_own γ x  saved_prop_own γ y   (x  y).
Robbert Krebbers's avatar
Robbert Krebbers committed
38
  Proof.
39
    rewrite -own_op own_valid agree_validI agree_equivI later_equivI.
40
    set (G1 := cFunctor_map F (iProp_fold, iProp_unfold)).
41
    set (G2 := cFunctor_map F (@iProp_unfold Σ, @iProp_fold Σ)).
42 43
    assert ( z, G2 (G1 z)  z) as help.
    { intros z. rewrite /G1 /G2 -cFunctor_compose -{2}[z]cFunctor_id.
44
      apply (ne_proper (cFunctor_map F)); split=>?; apply iProp_fold_unfold. }
45
    rewrite -{2}[x]help -{2}[y]help. apply later_mono.
46
    apply (internal_eq_rewrite (G1 x) (G1 y) (λ z, G2 (G1 x)  G2 z))%I;
47
      first solve_proper; auto with I.
Robbert Krebbers's avatar
Robbert Krebbers committed
48
  Qed.
49
End saved_prop.