client.v 1.38 KB
Newer Older
Ralf Jung's avatar
Ralf Jung committed
1
From barrier Require Import barrier.
2
From program_logic Require Import auth sts saved_prop hoare ownership.
Ralf Jung's avatar
Ralf Jung committed
3
4
5
6
7
Import uPred.

Definition client := (let: "b" := newchan '() in wait "b")%L.

Section client.
8
9
  Context {Σ : iFunctorG} `{!heapG Σ} `{!barrierG Σ}.
  Context (N : namespace) (heapN : namespace).
Ralf Jung's avatar
Ralf Jung committed
10
11
12
13
14
15
16

  Local Notation iProp := (iPropG heap_lang Σ).

  Lemma client_safe :
    heapN  N  heap_ctx heapN  || client {{ λ _, True }}.
  Proof.
    intros ?. rewrite /client.
17
    ewp eapply (newchan_spec N heapN True%I); last done.
Ralf Jung's avatar
Ralf Jung committed
18
19
20
21
22
23
24
    apply sep_intro_True_r; first done.
    apply forall_intro=>l. apply wand_intro_l. rewrite right_id.
    wp_let. etrans; last eapply wait_spec.
    apply sep_mono_r. apply wand_intro_r. eauto.
  Qed.

End client.
25
26

Section ClosedProofs.
27
  Definition Σ : iFunctorG := #[ heapGF ; barrierGF ].
28
29
30
31
  Notation iProp := (iPropG heap_lang Σ).

  Lemma client_safe_closed σ : {{ ownP σ : iProp }} client {{ λ v, True }}.
  Proof.
32
    apply ht_alt. rewrite (heap_alloc  (nroot ..: "Barrier")); last first.
33
    { (* FIXME Really?? set_solver takes forever on "⊆ ⊤"?!? *)
Robbert Krebbers's avatar
Robbert Krebbers committed
34
      by move=>? _. }
35
    apply wp_strip_pvs, exist_elim=> ?. rewrite and_elim_l.
36
    rewrite -(client_safe (nroot ..: "Heap" ) (nroot ..: "Barrier" )) //.
37
    (* This, too, should be automated. *)
Robbert Krebbers's avatar
Robbert Krebbers committed
38
    by apply ndot_ne_disjoint.
39
40
41
42
  Qed.

  Print Assumptions client_safe_closed.
End ClosedProofs.