saved_prop.v 1.91 KB
Newer Older
1 2
From iris.algebra Require Export agree.
From iris.program_logic Require Export ghost_ownership.
Robbert Krebbers's avatar
Robbert Krebbers committed
3 4
Import uPred.

5
Class savedPropG (Λ : language) (Σ : gFunctors) (F : cFunctor) :=
Robbert Krebbers's avatar
Robbert Krebbers committed
6
  saved_prop_inG :> inG Λ Σ (agreeR (laterC (F (iPrePropG Λ Σ)))).
7
Definition savedPropGF (F : cFunctor) : gFunctor :=
8
  GFunctor (agreeRF ( F)).
9 10
Instance inGF_savedPropG  `{inGF Λ Σ (savedPropGF F)} : savedPropG Λ Σ F.
Proof. apply: inGF_inG. Qed.
11

12
Definition saved_prop_own `{savedPropG Λ Σ F}
13
    (γ : gname) (x : F (iPropG Λ Σ)) : iPropG Λ Σ :=
14
  own γ (to_agree $ Next (cFunctor_map F (iProp_fold, iProp_unfold) x)).
15
Typeclasses Opaque saved_prop_own.
16
Instance: Params (@saved_prop_own) 4.
Robbert Krebbers's avatar
Robbert Krebbers committed
17

18
Section saved_prop.
19
  Context `{savedPropG Λ Σ F}.
20
  Implicit Types x y : F (iPropG Λ Σ).
Robbert Krebbers's avatar
Robbert Krebbers committed
21 22
  Implicit Types γ : gname.

23 24
  Global Instance saved_prop_persistent γ x : PersistentP (saved_prop_own γ x).
  Proof. rewrite /saved_prop_own; apply _. Qed.
25

26
  Lemma saved_prop_alloc_strong E x (G : gset gname) :
27
    True ={E}=>  γ,  (γ  G)  saved_prop_own γ x.
28
  Proof. by apply own_alloc_strong. Qed.
29

30
  Lemma saved_prop_alloc E x : True ={E}=>  γ, saved_prop_own γ x.
31
  Proof. by apply own_alloc. Qed.
Robbert Krebbers's avatar
Robbert Krebbers committed
32

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