Skip to content
Snippets Groups Projects
Commit fe3d3831 authored by Jonas Kastberg's avatar Jonas Kastberg
Browse files

More clean up

parent 084cecf5
No related branches found
No related tags found
No related merge requests found
...@@ -216,7 +216,7 @@ Section with_Σ. ...@@ -216,7 +216,7 @@ Section with_Σ.
Lemma send_all_spec c l xs xs' prot : Lemma send_all_spec c l xs xs' prot :
{{{ llist IT l xs c send_all_prot (length xs) xs' prot }}} {{{ llist IT l xs c send_all_prot (length xs) xs' prot }}}
send_all c #l send_all c #l
{{{ RET #(); llist IT l [] c (prot (rev (rev xs ++ xs'))) }}}. {{{ RET #(); llist IT l [] c prot (rev (rev xs ++ xs')) }}}.
Proof. Proof.
iIntros (Φ) "[Hl Hc] HΦ". iIntros (Φ) "[Hl Hc] HΦ".
iInduction xs as [|x xs] "IH" forall (xs'). iInduction xs as [|x xs] "IH" forall (xs').
...@@ -237,7 +237,7 @@ Section with_Σ. ...@@ -237,7 +237,7 @@ Section with_Σ.
end. end.
Lemma recv_all_spec c p l xs : Lemma recv_all_spec c p l xs :
{{{ llist IU l [] c (recv_all_prot xs p) }}} {{{ llist IU l [] c recv_all_prot xs p }}}
swap_mapper.recv_all c #l #(length xs) swap_mapper.recv_all c #l #(length xs)
{{{ ys, RET #(); ys = (map f xs) llist IU l ys c p }}}. {{{ ys, RET #(); ys = (map f xs) llist IU l ys c p }}}.
Proof. Proof.
...@@ -245,29 +245,26 @@ Section with_Σ. ...@@ -245,29 +245,26 @@ Section with_Σ.
iLöb as "IH" forall (xs Φ). iLöb as "IH" forall (xs Φ).
destruct xs. destruct xs.
{ wp_lam. wp_pures. iApply ("HΦ" $![]). simpl. by iFrame. } { wp_lam. wp_pures. iApply ("HΦ" $![]). simpl. by iFrame. }
wp_lam. wp_lam. wp_recv (w) as "Hw". wp_pures.
wp_recv (w) as "Hw".
wp_pures.
rewrite Nat2Z.inj_succ. rewrite Nat2Z.inj_succ.
replace (Z.succ (Z.of_nat (length xs)) - 1)%Z with (Z.of_nat (length xs)) by lia. replace (Z.succ (Z.of_nat (length xs)) - 1)%Z with (Z.of_nat (length xs)) by lia.
wp_apply ("IH" with "Hl Hc"). wp_apply ("IH" with "Hl Hc").
iIntros (ys) "(% & Hl & Hc)". iIntros (ys) "(% & Hl & Hc)".
wp_pures. wp_apply (lcons_spec with "[$Hl $Hw]"). wp_apply (lcons_spec with "[$Hl $Hw]").
iIntros "Hl". iApply "HΦ". iFrame. iPureIntro. by f_equiv. iIntros "Hl". iApply "HΦ". iFrame. iPureIntro. by f_equiv.
Qed. Qed.
Lemma recv_all_mono xs prot1 prot2 : Lemma recv_all_prot_mono prot1 prot2 xs :
prot1 prot2 -∗ recv_all_prot xs prot1 recv_all_prot xs prot2. prot1 prot2 -∗ recv_all_prot xs prot1 recv_all_prot xs prot2.
Proof. Proof.
iIntros "Hsub". iIntros "Hsub".
iInduction xs as [|xs] "IHxs"=> //. iInduction xs as [|xs] "IHxs"=> //.
simpl.
iIntros (w) "Hw". iExists w. iFrame "Hw". iModIntro. iIntros (w) "Hw". iExists w. iFrame "Hw". iModIntro.
by iApply "IHxs". by iApply "IHxs".
Qed. Qed.
Lemma recv_all_prot_fwd xs v prot : Lemma recv_all_prot_fwd xs v prot :
recv_all_prot xs (<!> MSG v ; prot)%proto recv_all_prot xs (<!> MSG v ; prot)%proto
(<!> MSG v ; recv_all_prot xs prot)%proto. (<!> MSG v ; recv_all_prot xs prot)%proto.
Proof. Proof.
iInduction xs as [|x xs] "IH"=> //=. iInduction xs as [|x xs] "IH"=> //=.
...@@ -335,7 +332,7 @@ Section with_Σ. ...@@ -335,7 +332,7 @@ Section with_Σ.
Proof. Proof.
iInduction n as [|n] "IHn" forall (xs)=> /=. iInduction n as [|n] "IHn" forall (xs)=> /=.
- iApply iProto_le_trans. - iApply iProto_le_trans.
{ iApply recv_all_mono. { iApply recv_all_prot_mono.
rewrite /mapper_prot fixpoint_unfold /mapper_prot_aux /iProto_choice. rewrite /mapper_prot fixpoint_unfold /mapper_prot_aux /iProto_choice.
iExists false. iApply iProto_le_refl. } iExists false. iApply iProto_le_refl. }
iApply recv_all_prot_fwd. iApply recv_all_prot_fwd.
...@@ -361,10 +358,8 @@ Section with_Σ. ...@@ -361,10 +358,8 @@ Section with_Σ.
Proof. Proof.
iIntros "#Hfspec !>" (Φ) "Hc HΦ". iIntros "#Hfspec !>" (Φ) "Hc HΦ".
iLöb as "IH". iLöb as "IH".
wp_rec. wp_rec. wp_branch.
wp_branch. - wp_recv (x v) as "HT". wp_apply ("Hfspec" with "HT").
- wp_recv (x v) as "HT".
wp_apply ("Hfspec" with "HT").
iIntros (w) "HU". iIntros (w) "HU".
wp_send with "[$HU]". wp_pures. iApply ("IH" with "Hc HΦ"). wp_send with "[$HU]". wp_pures. iApply ("IH" with "Hc HΦ").
- wp_pures. by iApply "HΦ". - wp_pures. by iApply "HΦ".
...@@ -378,7 +373,6 @@ Section with_Σ. ...@@ -378,7 +373,6 @@ Section with_Σ.
Proof. Proof.
iIntros "#Hfspec !>" (Φ) "HIT HΦ". iIntros "#Hfspec !>" (Φ) "HIT HΦ".
wp_lam. wp_lam.
wp_pures.
wp_apply (start_chan_spec mapper_prot); iIntros (c) "// Hc". wp_apply (start_chan_spec mapper_prot); iIntros (c) "// Hc".
{ wp_lam. rewrite -(iProto_app_end_r (iProto_dual mapper_prot)). { wp_lam. rewrite -(iProto_app_end_r (iProto_dual mapper_prot)).
iApply (swap_mapper_service_spec _ _ END%proto with "Hfspec Hc"). iApply (swap_mapper_service_spec _ _ END%proto with "Hfspec Hc").
...@@ -389,8 +383,7 @@ Section with_Σ. ...@@ -389,8 +383,7 @@ Section with_Σ.
iApply subprot_n_swap_end. } iApply subprot_n_swap_end. }
iIntros "[HIT Hc]". iIntros "[HIT Hc]".
wp_send with "[//]". wp_send with "[//]".
rewrite right_id. rewrite right_id rev_involutive.
rewrite rev_involutive.
wp_apply (recv_all_spec with "[$HIT $Hc]"). wp_apply (recv_all_spec with "[$HIT $Hc]").
iIntros (ys) "(% & HIT & Hc)". iIntros (ys) "(% & HIT & Hc)".
iApply "HΦ". iApply "HΦ".
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment