Commit 1fa2c070 authored by Robbert Krebbers's avatar Robbert Krebbers

Some renaming.

parent 8bf5d63b
...@@ -10,8 +10,8 @@ theories/channel/channel.v ...@@ -10,8 +10,8 @@ theories/channel/channel.v
theories/channel/proto_model.v theories/channel/proto_model.v
theories/channel/proto_channel.v theories/channel/proto_channel.v
theories/channel/proofmode.v theories/channel/proofmode.v
theories/examples/list_sort.v theories/examples/sort.v
theories/examples/list_sort_instances.v theories/examples/sort_client.v
theories/examples/list_sort_elem.v theories/examples/sort_elem.v
theories/examples/loop_sort.v theories/examples/loop_sort.v
theories/examples/list_sort_elem_client.v theories/examples/sort_elem_client.v
...@@ -2,11 +2,11 @@ From stdpp Require Import sorting. ...@@ -2,11 +2,11 @@ From stdpp Require Import sorting.
From osiris.channel Require Import proto_channel. From osiris.channel Require Import proto_channel.
From iris.heap_lang Require Import proofmode notation. From iris.heap_lang Require Import proofmode notation.
From osiris.utils Require Import list. From osiris.utils Require Import list.
From osiris.examples Require Import list_sort. From osiris.examples Require Import sort.
Definition loop_sort_service : val := Definition loop_sort_service : val :=
rec: "go" "c" := rec: "go" "c" :=
if: recv "c" then list_sort_service "c";; "go" "c" if: recv "c" then sort_service "c";; "go" "c"
else if: recv "c" then else if: recv "c" then
let: "d" := start_chan "go" in let: "d" := start_chan "go" in
send "c" "d";; send "c" "d";;
...@@ -33,7 +33,7 @@ Section loop_sort. ...@@ -33,7 +33,7 @@ Section loop_sort.
Proof. Proof.
iIntros (Ψ) "Hc HΨ". iLöb as "IH" forall (c Ψ). iIntros (Ψ) "Hc HΨ". iLöb as "IH" forall (c Ψ).
wp_rec. wp_apply (branch_spec with "Hc"); iIntros ([]) "/= [Hc _]"; wp_if. wp_rec. wp_apply (branch_spec with "Hc"); iIntros ([]) "/= [Hc _]"; wp_if.
{ wp_apply (list_sort_service_spec with "Hc"); iIntros "Hc". { wp_apply (sort_service_spec with "Hc"); iIntros "Hc".
by wp_apply ("IH" with "Hc"). } by wp_apply ("IH" with "Hc"). }
wp_apply (branch_spec with "Hc"); iIntros ([]) "/= [Hc _]"; wp_if. wp_apply (branch_spec with "Hc"); iIntros ([]) "/= [Hc _]"; wp_if.
- wp_apply (start_chan_proto_spec N loop_sort_protocol); iIntros (d) "Hd". - wp_apply (start_chan_proto_spec N loop_sort_protocol); iIntros (d) "Hd".
......
...@@ -3,7 +3,7 @@ From osiris.channel Require Import proto_channel proofmode. ...@@ -3,7 +3,7 @@ From osiris.channel Require Import proto_channel proofmode.
From iris.heap_lang Require Import proofmode notation. From iris.heap_lang Require Import proofmode notation.
From iris.heap_lang Require Import assert. From iris.heap_lang Require Import assert.
From osiris.utils Require Import list compare spin_lock contribution. From osiris.utils Require Import list compare spin_lock contribution.
From osiris.examples Require Import list_sort_elem. From osiris.examples Require Import sort_elem.
From iris.algebra Require Import gmultiset. From iris.algebra Require Import gmultiset.
Definition mapper : val := Definition mapper : val :=
......
...@@ -2,9 +2,7 @@ From stdpp Require Import sorting. ...@@ -2,9 +2,7 @@ From stdpp Require Import sorting.
From osiris.channel Require Import proto_channel proofmode. From osiris.channel Require Import proto_channel proofmode.
From iris.heap_lang Require Import proofmode notation. From iris.heap_lang Require Import proofmode notation.
From iris.heap_lang Require Import assert. From iris.heap_lang Require Import assert.
From iris.heap_lang.lib Require Import spin_lock. From osiris.utils Require Import list compare spin_lock.
From osiris.utils Require Import list compare.
Definition qnew : val := λ: <>, #(). Definition qnew : val := λ: <>, #().
Definition qenqueue : val := λ: "q" "v", #(). Definition qenqueue : val := λ: "q" "v", #().
...@@ -20,55 +18,55 @@ Definition stop := false. ...@@ -20,55 +18,55 @@ Definition stop := false.
Definition some := true. Definition some := true.
Definition none := false. Definition none := false.
Definition dist_queue : val := Definition pd_loop : val :=
rec: "go" "q" "pc" "cc" "c" := rec: "go" "q" "pc" "cc" "c" :=
if: "cc" #0 then #() else if: "cc" #0 then #() else
if: recv "c" (* enq/deq *) if: recv "c" then (* enq/deq *)
then if: recv "c" (* cont/stop *) if: recv "c" then (* cont/stop *)
then "go" (qenqueue "q" (recv "c")) "pc" "cc" "c" "go" (qenqueue "q" (recv "c")) "pc" "cc" "c"
else "go" "q" ("pc"-#1) "cc" "c" else "go" "q" ("pc"-#1) "cc" "c"
else if: (qis_empty "q") else
then if: "pc" #0 if: (qis_empty "q") then
then send "c" #stop;; "go" "q" "pc" ("cc"-#1) "c" if: "pc" #0 then
else send "c" #cont;; send "c" #none;; "go" "q" "pc" "cc" "c" send "c" #stop;;
else send "c" #cont;; send "c" #some;; "go" "q" "pc" ("cc"-#1) "c"
let: "qv" := qdequeue "q" in else
send "c" (Snd "qv");; "go" (Fst "qv") "pc" "cc" "c". send "c" #cont;; send "c" #none;;
"go" "q" "pc" "cc" "c"
Definition producer : val := else
rec: "go" "c" "l" "produce" := send "c" #cont;; send "c" #some;;
(* acquire "l";; *) let: "qv" := qdequeue "q" in
match: "produce" #() with send "c" (Snd "qv");;
SOME "v" => "go" (Fst "qv") "pc" "cc" "c".
acquire "l";;
send "c" #enq;; send "c" #cont;; send "c" "v";; Definition new_pd : val := λ: "pc" "cc",
release "l";; let: "q" := qnew #() in
"go" "c" "l" "produce" let: "c" := start_chan (λ: "c", pd_loop "q" "pc" "cc" "c") in
| NONE => let: "l" := new_lock #() in
acquire "l";; ("c", "l").
send "c" #enq;; send "c" #stop
release "l" Definition pd_send : val := λ: "cl" "x",
end. acquire (Snd "cl");;
send (Fst "cl") #enq;; send (Fst "cl") #cont;; send (Fst "cl") "x";;
Definition consumer : val := release (Snd "cl").
rec: "go" "c" "l" "consume" :=
acquire "l";; Definition pd_stop : val := λ: "cl",
send "c" #deq;; acquire (Fst "cl");;
if: recv "c" (* cont/stop *) send (Snd "cl") #enq;; send (Snd "cl") #stop;;
then if: recv "c" (* some/none *) release (Fst "cl").
then let: "v" := SOME (recv "c") in
release "l";; "consume" "v";; "go" "c" "l" "consume" Definition pd_recv : val :=
(* "consume" "v";; release "l";; "go" "c" "l" "consume" *) rec: "go" "cl" :=
else release "l";; "go" "c" "l" "consume" acquire (Fst "cl");;
else "consume" NONE;; release "l";; #(). send (Snd "cl") #deq;;
(* else release "l";; "consume" NONE;; #(). *) if: recv (Snd "cl") then (* cont/stop *)
if: recv (Snd "cl") then (* some/none *)
(* Makes n producers and m consumers *) let: "v" := recv (Snd "cl") in
Definition produce_consume : val := release (Fst "cl");; SOME "v"
λ: "produce" "consume" "pc" "cc", else release (Fst "cl");; "go" "c" "l"
#(). else release (Fst "cl");; NONE.
Section list_sort_elem. Section sort_elem.
Context `{!heapG Σ, !proto_chanG Σ} (N : namespace). Context `{!heapG Σ, !proto_chanG Σ} (N : namespace).
Definition queue_prot : iProto Σ := (END)%proto. Definition queue_prot : iProto Σ := (END)%proto.
......
...@@ -13,7 +13,7 @@ Definition lmerge : val := ...@@ -13,7 +13,7 @@ Definition lmerge : val :=
then lcons "y" ("go" "cmp" (ltail "ys") "zs") then lcons "y" ("go" "cmp" (ltail "ys") "zs")
else lcons "z" ("go" "cmp" "ys" (ltail "zs")). else lcons "z" ("go" "cmp" "ys" (ltail "zs")).
Definition list_sort_service : val := Definition sort_service : val :=
rec: "go" "c" := rec: "go" "c" :=
let: "cmp" := recv "c" in let: "cmp" := recv "c" in
let: "xs" := recv "c" in let: "xs" := recv "c" in
...@@ -30,12 +30,12 @@ Definition list_sort_service : val := ...@@ -30,12 +30,12 @@ Definition list_sort_service : val :=
"xs" <- lmerge "cmp" !"ys" !"zs";; "xs" <- lmerge "cmp" !"ys" !"zs";;
send "c" #(). send "c" #().
Definition list_sort_client : val := λ: "cmp" "xs", Definition sort_client : val := λ: "cmp" "xs",
let: "c" := start_chan list_sort_service in let: "c" := start_chan sort_service in
send "c" "cmp";; send "c" "xs";; send "c" "cmp";; send "c" "xs";;
recv "c". recv "c".
Section list_sort. Section sort.
Context `{!heapG Σ, !proto_chanG Σ} (N : namespace). Context `{!heapG Σ, !proto_chanG Σ} (N : namespace).
Definition sort_protocol : iProto Σ := Definition sort_protocol : iProto Σ :=
...@@ -82,9 +82,9 @@ Section list_sort. ...@@ -82,9 +82,9 @@ Section list_sort.
iApply "HΨ". iFrame. iApply "HΨ". iFrame.
Qed. Qed.
Lemma list_sort_service_spec p c : Lemma sort_service_spec p c :
{{{ c iProto_dual sort_protocol <++> p @ N }}} {{{ c iProto_dual sort_protocol <++> p @ N }}}
list_sort_service c sort_service c
{{{ RET #(); c p @ N }}}. {{{ RET #(); c p @ N }}}.
Proof. Proof.
iIntros (Ψ) "Hc HΨ". iLöb as "IH" forall (p c Ψ). iIntros (Ψ) "Hc HΨ". iLöb as "IH" forall (p c Ψ).
...@@ -122,21 +122,21 @@ Section list_sort. ...@@ -122,21 +122,21 @@ Section list_sort.
- by iApply "HΨ". - by iApply "HΨ".
Qed. Qed.
Lemma list_sort_client_spec {A} (I : A val iProp Σ) R Lemma sort_client_spec {A} (I : A val iProp Σ) R
`{!RelDecision R, !Total R} cmp l (vs : list val) (xs : list A) : `{!RelDecision R, !Total R} cmp l (vs : list val) (xs : list A) :
cmp_spec I R cmp - cmp_spec I R cmp -
{{{ l val_encode vs [ list] x;v xs;vs, I x v }}} {{{ l val_encode vs [ list] x;v xs;vs, I x v }}}
list_sort_client cmp #l sort_client cmp #l
{{{ ys ws, RET #(); Sorted R ys ys xs {{{ ys ws, RET #(); Sorted R ys ys xs
l val_encode ws [ list] y;w ys;ws, I y w }}}. l val_encode ws [ list] y;w ys;ws, I y w }}}.
Proof. Proof.
iIntros "#Hcmp !>" (Φ) "Hl HΦ". wp_lam. iIntros "#Hcmp !>" (Φ) "Hl HΦ". wp_lam.
wp_apply (start_chan_proto_spec N sort_protocol); iIntros (c) "Hc". wp_apply (start_chan_proto_spec N sort_protocol); iIntros (c) "Hc".
{ rewrite -(right_id END%proto _ (iProto_dual _)). { rewrite -(right_id END%proto _ (iProto_dual _)).
wp_apply (list_sort_service_spec with "Hc"); auto. } wp_apply (sort_service_spec with "Hc"); auto. }
wp_send with "[$Hcmp]". wp_send with "[$Hcmp]".
wp_send with "[$Hl]". wp_send with "[$Hl]".
wp_recv (ys ws) as "(Hsorted & Hperm & Hl & HI)". wp_recv (ys ws) as "(Hsorted & Hperm & Hl & HI)".
wp_pures. iApply "HΦ"; iFrame. wp_pures. iApply "HΦ"; iFrame.
Qed. Qed.
End list_sort. End sort.
...@@ -2,22 +2,22 @@ From stdpp Require Import sorting. ...@@ -2,22 +2,22 @@ From stdpp Require Import sorting.
From osiris.channel Require Import proto_channel. From osiris.channel Require Import proto_channel.
From iris.heap_lang Require Import proofmode notation. From iris.heap_lang Require Import proofmode notation.
From osiris.utils Require Import list compare. From osiris.utils Require Import list compare.
From osiris.examples Require Import list_sort. From osiris.examples Require Import sort.
Section list_sort_instances. Section sort_client.
Context `{!heapG Σ, !proto_chanG Σ} (N : namespace). Context `{!heapG Σ, !proto_chanG Σ} (N : namespace).
Local Arguments val_encode _ _ !_ /. Local Arguments val_encode _ _ !_ /.
Lemma list_sort_client_le_spec l (xs : list Z) : Lemma sort_client_le_spec l (xs : list Z) :
{{{ l val_encode xs }}} {{{ l val_encode xs }}}
list_sort_client cmpZ #l sort_client cmpZ #l
{{{ ys, RET #(); Sorted () ys ys xs l val_encode ys }}}. {{{ ys, RET #(); Sorted () ys ys xs l val_encode ys }}}.
Proof. Proof.
assert ( zs : list Z, val_encode zs = val_encode (LitV LitInt <$> zs)) as Henc. assert ( zs : list Z, val_encode zs = val_encode (LitV LitInt <$> zs)) as Henc.
{ intros zs. induction zs; f_equal/=; auto with f_equal. } { intros zs. induction zs; f_equal/=; auto with f_equal. }
iIntros (Φ) "Hl HΦ". iIntros (Φ) "Hl HΦ".
iApply (list_sort_client_spec N IZ () _ _ (LitV LitInt <$> xs) xs with "[] [Hl] [HΦ]"). iApply (sort_client_spec N IZ () _ _ (LitV LitInt <$> xs) xs with "[] [Hl] [HΦ]").
{ iApply cmpZ_spec. } { iApply cmpZ_spec. }
{ rewrite -Henc. iFrame "Hl". { rewrite -Henc. iFrame "Hl".
iInduction xs as [|x xs] "IH"; csimpl; first by iFrame. iInduction xs as [|x xs] "IH"; csimpl; first by iFrame.
...@@ -30,4 +30,4 @@ Section list_sort_instances. ...@@ -30,4 +30,4 @@ Section list_sort_instances.
by iDestruct ("IH" with "HI2") as %->. } by iDestruct ("IH" with "HI2") as %->. }
rewrite -Henc. iApply ("HΦ" $! ys with "[$]"). rewrite -Henc. iApply ("HΦ" $! ys with "[$]").
Qed. Qed.
End list_sort_instances. End sort_client.
...@@ -7,25 +7,25 @@ From osiris.utils Require Import list compare. ...@@ -7,25 +7,25 @@ From osiris.utils Require Import list compare.
Definition cont := true. Definition cont := true.
Definition stop := false. Definition stop := false.
Definition list_sort_elem_service_split : val := Definition sort_elem_service_split : val :=
rec: "go" "c" "c1" "c2" := rec: "go" "c" "c1" "c2" :=
if: ~(recv "c") then send "c1" #stop;; send "c2" #stop else if: ~(recv "c") then send "c1" #stop;; send "c2" #stop else
let: "x" := recv "c" in let: "x" := recv "c" in
send "c1" #cont;; send "c1" "x";; send "c1" #cont;; send "c1" "x";;
"go" "c" "c2" "c1". "go" "c" "c2" "c1".
Definition list_sort_elem_service_move : val := Definition sort_elem_service_move : val :=
rec: "go" "c" "cin" := rec: "go" "c" "cin" :=
if: ~(recv "cin") then send "c" #stop else if: ~(recv "cin") then send "c" #stop else
let: "x" := recv "cin" in let: "x" := recv "cin" in
send "c" #cont;; send "c" "x";; send "c" #cont;; send "c" "x";;
"go" "c" "cin". "go" "c" "cin".
Definition list_sort_elem_service_merge : val := Definition sort_elem_service_merge : val :=
rec: "go" "cmp" "c" "x1" "c1" "c2" := rec: "go" "cmp" "c" "x1" "c1" "c2" :=
if: ~recv "c2" then if: ~recv "c2" then
send "c" #cont;; send "c" "x1";; send "c" #cont;; send "c" "x1";;
list_sort_elem_service_move "c" "c1" sort_elem_service_move "c" "c1"
else else
let: "x2" := recv "c2" in let: "x2" := recv "c2" in
if: "cmp" "x1" "x2" then if: "cmp" "x1" "x2" then
...@@ -33,7 +33,7 @@ Definition list_sort_elem_service_merge : val := ...@@ -33,7 +33,7 @@ Definition list_sort_elem_service_merge : val :=
else else
send "c" #cont;; send "c" "x2";; "go" "cmp" "c" "x1" "c1" "c2". send "c" #cont;; send "c" "x2";; "go" "cmp" "c" "x1" "c1" "c2".
Definition list_sort_elem_service : val := Definition sort_elem_service : val :=
rec: "go" "cmp" "c" := rec: "go" "cmp" "c" :=
if: ~(recv "c") then send "c" #stop else if: ~(recv "c") then send "c" #stop else
let: "x" := recv "c" in let: "x" := recv "c" in
...@@ -45,59 +45,65 @@ Definition list_sort_elem_service : val := ...@@ -45,59 +45,65 @@ Definition list_sort_elem_service : val :=
let: "c2" := Fst "cc2" in let: "c2'" := Snd "cc2" in let: "c2" := Fst "cc2" in let: "c2'" := Snd "cc2" in
send "c1" #cont;; send "c1" "x";; send "c1" #cont;; send "c1" "x";;
send "c2" #cont;; send "c2" "y";; send "c2" #cont;; send "c2" "y";;
list_sort_elem_service_split "c" "c1" "c2";; sort_elem_service_split "c" "c1" "c2";;
Fork ("go" "cmp" "c1'");; Fork ("go" "cmp" "c2'");; Fork ("go" "cmp" "c1'");; Fork ("go" "cmp" "c2'");;
let: "x" := (if: recv "c1" then recv "c1" else assert #false) in let: "x" := (if: recv "c1" then recv "c1" else assert #false) in
list_sort_elem_service_merge "cmp" "c" "x" "c1" "c2". sort_elem_service_merge "cmp" "c" "x" "c1" "c2".
Definition list_sort_elem_service_top : val := λ: "c", Definition sort_elem_service_top : val := λ: "c",
let: "cmp" := recv "c" in let: "cmp" := recv "c" in
list_sort_elem_service "cmp" "c". sort_elem_service "cmp" "c".
Section list_sort_elem. Section sort_elem.
Context `{!heapG Σ, !proto_chanG Σ} (N : namespace). Context `{!heapG Σ, !proto_chanG Σ} (N : namespace).
Section list_sort_elem_inner. Section sort_elem_inner.
Context {A} (I : A val iProp Σ) (R : relation A) `{!RelDecision R, !Total R}. Context {A} (I : A val iProp Σ) (R : relation A) `{!RelDecision R, !Total R}.
Definition tail_protocol_aux (xs : list A) Definition sort_elem_tail_protocol_aux (xs : list A)
(rec : list A -d> iProto Σ) : list A -d> iProto Σ := λ ys, (rec : list A -d> iProto Σ) : list A -d> iProto Σ := λ ys,
((<?> y v, MSG v {{ TlRel R y ys I y v }}; (rec : _ iProto Σ) (ys ++ [y])) ((<?> y v, MSG v {{ TlRel R y ys I y v }}; (rec : _ iProto Σ) (ys ++ [y]))
<&{ ys xs }> END)%proto. <&{ ys xs }> END)%proto.
Instance tail_protocol_aux_contractive xs : Contractive (tail_protocol_aux xs). Instance sort_elem_tail_protocol_aux_contractive xs :
Contractive (sort_elem_tail_protocol_aux xs).
Proof. solve_proto_contractive. Qed. Proof. solve_proto_contractive. Qed.
Definition tail_protocol (xs : list A) : list A iProto Σ := Definition sort_elem_tail_protocol (xs : list A) : list A iProto Σ :=
fixpoint (tail_protocol_aux xs). fixpoint (sort_elem_tail_protocol_aux xs).
Global Instance tail_protocol_unfold xs ys : Global Instance sort_elem_tail_protocol_unfold xs ys :
ProtoUnfold (tail_protocol xs ys) (tail_protocol_aux xs (tail_protocol xs) ys). ProtoUnfold (sort_elem_tail_protocol xs ys)
Proof. apply proto_unfold_eq, (fixpoint_unfold (tail_protocol_aux _)). Qed. (sort_elem_tail_protocol_aux xs (sort_elem_tail_protocol xs) ys).
Proof. apply proto_unfold_eq, (fixpoint_unfold (sort_elem_tail_protocol_aux _)). Qed.
Definition head_protocol_aux
Definition sort_elem_head_protocol_aux
(rec : list A -d> iProto Σ) : list A -d> iProto Σ := λ xs, (rec : list A -d> iProto Σ) : list A -d> iProto Σ := λ xs,
((<!> x v, MSG v {{ I x v }}; (rec : _ iProto Σ) (xs ++ [x])) ((<!> x v, MSG v {{ I x v }}; (rec : _ iProto Σ) (xs ++ [x]))
<+> tail_protocol xs [])%proto. <+> sort_elem_tail_protocol xs [])%proto.
Instance head_protocol_aux_contractive : Contractive head_protocol_aux. Instance sort_elem_head_protocol_aux_contractive :
Contractive sort_elem_head_protocol_aux.
Proof. solve_proto_contractive. Qed. Proof. solve_proto_contractive. Qed.
Definition head_protocol : list A iProto Σ := fixpoint head_protocol_aux. Definition sort_elem_head_protocol : list A iProto Σ :=
Global Instance head_protocol_unfold xs : fixpoint sort_elem_head_protocol_aux.
ProtoUnfold (head_protocol xs) (head_protocol_aux head_protocol xs) | 100. Global Instance sort_elem_head_protocol_unfold xs :
Proof. apply proto_unfold_eq, (fixpoint_unfold head_protocol_aux). Qed. ProtoUnfold (sort_elem_head_protocol xs)
(sort_elem_head_protocol_aux sort_elem_head_protocol xs).
Proof. apply proto_unfold_eq, (fixpoint_unfold sort_elem_head_protocol_aux). Qed.
Definition list_sort_elem_protocol : iProto Σ := head_protocol []. Definition sort_elem_protocol : iProto Σ := sort_elem_head_protocol [].
Lemma list_sort_elem_service_split_spec c p c1 c2 xs xs1 xs2 : Lemma sort_elem_service_split_spec c p c1 c2 xs xs1 xs2 :
{{{ {{{
c iProto_dual (head_protocol xs) <++> p @ N c iProto_dual (sort_elem_head_protocol xs) <++> p @ N
c1 head_protocol xs1 @ N c2 head_protocol xs2 @ N c1 sort_elem_head_protocol xs1 @ N c2 sort_elem_head_protocol xs2 @ N
}}} }}}
list_sort_elem_service_split c c1 c2 sort_elem_service_split c c1 c2
{{{ xs' xs1' xs2', RET #(); {{{ xs' xs1' xs2', RET #();
xs' xs1' ++ xs2' xs' xs1' ++ xs2'
c iProto_dual (tail_protocol (xs ++ xs') []) <++> p @ N c iProto_dual (sort_elem_tail_protocol (xs ++ xs') []) <++> p @ N
c1 tail_protocol (xs1 ++ xs1') [] @ N c2 tail_protocol (xs2 ++ xs2') [] @ N c1 sort_elem_tail_protocol (xs1 ++ xs1') [] @ N
c2 sort_elem_tail_protocol (xs2 ++ xs2') [] @ N
}}}. }}}.
Proof. Proof.
iIntros (Ψ) "(Hc & Hc1 & Hc2) HΨ". iLöb as "IH" forall (c c1 c2 xs xs1 xs2 Ψ). iIntros (Ψ) "(Hc & Hc1 & Hc2) HΨ". iLöb as "IH" forall (c c1 c2 xs xs1 xs2 Ψ).
...@@ -111,16 +117,16 @@ Section list_sort_elem. ...@@ -111,16 +117,16 @@ Section list_sort_elem.
iApply ("HΨ" $! [] [] []). rewrite !right_id_L. by iFrame. iApply ("HΨ" $! [] [] []). rewrite !right_id_L. by iFrame.
Qed. Qed.
Lemma list_sort_elem_service_move_spec c p cin xs ys zs xs' ys' : Lemma sort_elem_service_move_spec c p cin xs ys zs xs' ys' :
xs xs' ++ zs xs xs' ++ zs
ys ys' ++ zs ys ys' ++ zs
Sorted R ys Sorted R ys
( x, TlRel R x ys' TlRel R x ys) ( x, TlRel R x ys' TlRel R x ys)
{{{ {{{
c iProto_dual (tail_protocol xs ys) <++> p @ N c iProto_dual (sort_elem_tail_protocol xs ys) <++> p @ N
cin tail_protocol xs' ys' @ N cin sort_elem_tail_protocol xs' ys' @ N
}}} }}}
list_sort_elem_service_move c cin sort_elem_service_move c cin
{{{ RET #(); c p @ N cin END @ N }}}. {{{ RET #(); c p @ N cin END @ N }}}.
Proof. Proof.
iIntros (Hxs Hys Hsorted Hrel Ψ) "[Hc Hcin] HΨ". iIntros (Hxs Hys Hsorted Hrel Ψ) "[Hc Hcin] HΨ".
...@@ -139,7 +145,7 @@ Section list_sort_elem. ...@@ -139,7 +145,7 @@ Section list_sort_elem.
iApply "HΨ". iFrame. iApply "HΨ". iFrame.
Qed. Qed.
Lemma list_sort_elem_service_merge_spec cmp c p c1 c2 xs ys xs1 xs2 y1 w1 ys1 ys2 : Lemma sort_elem_service_merge_spec cmp c p c1 c2 xs ys xs1 xs2 y1 w1 ys1 ys2 :
xs xs1 ++ xs2 xs xs1 ++ xs2
ys ys1 ++ ys2 ys ys1 ++ ys2
Sorted R ys Sorted R ys
...@@ -147,11 +153,12 @@ Section list_sort_elem. ...@@ -147,11 +153,12 @@ Section list_sort_elem.
( x, TlRel R x ys2 R x y1 TlRel R x ys) ( x, TlRel R x ys2 R x y1 TlRel R x ys)
cmp_spec I R cmp - cmp_spec I R cmp -
{{{ {{{
c iProto_dual (tail_protocol xs ys) <++> p @ N c iProto_dual (sort_elem_tail_protocol xs ys) <++> p @ N
c1 tail_protocol xs1 (ys1 ++ [y1]) @ N c2 tail_protocol xs2 ys2 @ N c1 sort_elem_tail_protocol xs1 (ys1 ++ [y1]) @ N
c2 sort_elem_tail_protocol xs2 ys2 @ N