client.v 1.45 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
8
9
10
11
12
13
14
15
16
17
18
Import uPred.

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

Section client.
  Context {Σ : iFunctorG} (N : namespace).
  Context `{heapG Σ} (heapN : namespace).
  Context `{stsG heap_lang Σ barrier_proto.sts}.
  Context `{savedPropG heap_lang Σ}.

  Local Notation iProp := (iPropG heap_lang Σ).

  Lemma client_safe :
    heapN  N  heap_ctx heapN  || client {{ λ _, True }}.
  Proof.
    intros ?. rewrite /client.
19
    ewp eapply (newchan_spec N heapN True%I); last done.
Ralf Jung's avatar
Ralf Jung committed
20
21
22
23
24
25
26
    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.
27
28

Section ClosedProofs.
29
  Definition Σ : iFunctorG := heapF .:: barrierFs .++ endF.
30
31
32
33
  Notation iProp := (iPropG heap_lang Σ).

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

  Print Assumptions client_safe_closed.
End ClosedProofs.