Skip to content
Snippets Groups Projects
Commit d577c62a authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Finish `list_sort_client_le_spec`.

parent 48118e9f
No related branches found
No related tags found
No related merge requests found
...@@ -246,19 +246,27 @@ Section list_sort. ...@@ -246,19 +246,27 @@ Section list_sort.
wp_lam. wp_pures. iApply "HΦ". eauto 10 with iFrame. wp_lam. wp_pures. iApply "HΦ". eauto 10 with iFrame.
Qed. Qed.
Local Arguments val_encode _ _ !_ /.
Lemma list_sort_client_le_spec l (xs : list Z) : Lemma list_sort_client_le_spec l (xs : list Z) :
{{{ l val_encode xs }}} {{{ l val_encode xs }}}
list_sort_client compare_vals #l list_sort_client compare_vals #l
{{{ ys, RET #(); Sorted () ys ys xs l val_encode ys }}}. {{{ ys, RET #(); Sorted () ys ys xs l val_encode ys }}}.
Proof. Proof.
assert (val_encode xs = val_encode (LitV LitInt <$> xs)) as Hxs. assert ( zs : list Z, val_encode zs = val_encode (LitV LitInt <$> zs)) as Henc.
{ admit. } { intros zs. induction zs; f_equal/=; auto with f_equal. }
iIntros (Φ) "Hl HΦ". iIntros (Φ) "Hl HΦ".
iApply (list_sort_client_spec IZ () _ _ (LitV LitInt <$> xs) xs with "[] [Hl] [HΦ]"). iApply (list_sort_client_spec IZ () _ _ (LitV LitInt <$> xs) xs with "[] [Hl] [HΦ]").
{ iApply compare_vals_spec. } { iApply compare_vals_spec. }
{ rewrite -Hxs {Hxs}. 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.
iFrame "IH". by iExists x. } iFrame "IH". by iExists x. }
{ admit. } iIntros "!>" (ys ws) "(?&?&?&HI)".
Admitted. iAssert ws = (LitV LitInt) <$> ys ⌝%I with "[HI]" as %->.
{ iInduction ys as [|y ys] "IH" forall (ws);
destruct ws as [|w ws]; csimpl; try done.
iDestruct "HI" as "[HI1 HI2]"; iDestruct "HI1" as %(?&->&->).
by iDestruct ("IH" with "HI2") as %->. }
rewrite -Henc. iApply ("HΦ" $! ys with "[$]").
Qed.
End list_sort. End list_sort.
...@@ -53,11 +53,13 @@ Proof. split. by intros []. by intros [[]| | | |] ? [= <-]. Qed. ...@@ -53,11 +53,13 @@ Proof. split. by intros []. by intros [[]| | | |] ? [= <-]. Qed.
Instance pair_val_enc `{ValEnc A, ValEnc B} : ValEnc (A * B) := λ p, Instance pair_val_enc `{ValEnc A, ValEnc B} : ValEnc (A * B) := λ p,
(val_encode p.1, val_encode p.2)%V. (val_encode p.1, val_encode p.2)%V.
Arguments pair_val_enc {_ _ _ _} !_ /.
Instance pair_val_dec `{ValDec A, ValDec B} : ValDec (A * B) := λ v, Instance pair_val_dec `{ValDec A, ValDec B} : ValDec (A * B) := λ v,
match v with match v with
| PairV v1 v2 => x1 val_decode v1; x2 val_decode v2; Some (x1, x2) | PairV v1 v2 => x1 val_decode v1; x2 val_decode v2; Some (x1, x2)
| _ => None | _ => None
end. end.
Arguments pair_val_dec {_ _ _ _} !_ /.
Instance pair_val_enc_dec `{ValEncDec A, ValEncDec B} : ValEncDec (A * B). Instance pair_val_enc_dec `{ValEncDec A, ValEncDec B} : ValEncDec (A * B).
Proof. Proof.
split. split.
...@@ -70,12 +72,14 @@ Qed. ...@@ -70,12 +72,14 @@ Qed.
Instance option_val_enc `{ValEnc A} : ValEnc (option A) := λ mx, Instance option_val_enc `{ValEnc A} : ValEnc (option A) := λ mx,
match mx with Some x => SOMEV (val_encode x) | None => NONEV end%V. match mx with Some x => SOMEV (val_encode x) | None => NONEV end%V.
Arguments option_val_enc {_ _} !_ /.
Instance option_val_dec `{ValDec A} : ValDec (option A) := λ v, Instance option_val_dec `{ValDec A} : ValDec (option A) := λ v,
match v with match v with
| SOMEV v => x val_decode v; Some (Some x) | SOMEV v => x val_decode v; Some (Some x)
| NONEV => Some None | NONEV => Some None
| _ => None | _ => None
end. end.
Arguments option_val_dec {_ _} !_ /.
Instance option_val_enc_dec `{ValEncDec A} : ValEncDec (option A). Instance option_val_enc_dec `{ValEncDec A} : ValEncDec (option A).
Proof. Proof.
split. split.
......
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