Skip to content
Snippets Groups Projects
Commit 031d822e authored by Amin Timany's avatar Amin Timany
Browse files

Make the spec for filter stronger

parent eab61393
Branches amin/ci/filer-spec
No related tags found
1 merge request!68Make the spec for filter stronger
Pipeline #109283 passed
...@@ -385,31 +385,30 @@ Proof. ...@@ -385,31 +385,30 @@ Proof.
Qed. Qed.
Lemma filter_spec (hd p : val) (xs : list val) (P : val -> bool) : Lemma filter_spec (hd p : val) (xs : list val) (R : val -> bool) (Q : val iProp Σ) :
{{{ is_list hd xs {{{ is_list hd xs
( x : val , ( x : val ,
{{{ True }}} {{{ Q x }}}
p x p x
{{{r, RET r; r = #(P x) }}}) {{{r, RET r; r = #(R x) }}}) [ list] x xs, Q x
}}} }}}
filter p hd filter p hd
{{{ v, RET v; is_list hd xs {{{ v, RET v; is_list hd xs
is_list v (List.filter P xs) is_list v (List.filter R xs)
}}}. }}}.
Proof. Proof.
iIntros (ϕ) "[H_isList #H_p] H_ϕ". wp_rec. wp_pures. iIntros (ϕ) "(H_isList & #H_p & HQs) H_ϕ". wp_rec. wp_pures.
iApply (foldr_spec_PI (fun x => True)%I iApply (foldr_spec_PI Q
(fun xs' acc => is_list acc (List.filter P xs'))%I (fun xs' acc => is_list acc (List.filter R xs'))%I
with "[$H_isList] [H_ϕ]"). with "[$H_isList HQs] [H_ϕ]").
- iSplitL. - iSplitR.
+ iIntros (x a' ?) "!# %ϕ'". iIntros "[_ H_isList] H_ϕ'". + iIntros (x a' ?) "!# %ϕ'". iIntros "[HQ H_isList] H_ϕ'".
repeat (wp_pure _). wp_bind (p x). iApply "H_p"; first done. repeat (wp_pure _). wp_bind (p x). iApply ("H_p" with "[$HQ]").
iNext. iIntros (r) "H". iSimplifyEq. destruct (P x); wp_if. iNext. iIntros (r) "H". iSimplifyEq. destruct (R x); wp_if.
* wp_rec. wp_pures. wp_alloc l. wp_pures. iApply "H_ϕ'". * wp_rec. wp_pures. wp_alloc l. wp_pures. iApply "H_ϕ'".
iExists l, a'. by iFrame. iExists l, a'. by iFrame.
* by iApply "H_ϕ'". * by iApply "H_ϕ'".
+ iSplit; last done. + by iSplit.
rewrite big_sepL_forall. eauto.
- iNext. iApply "H_ϕ". - iNext. iApply "H_ϕ".
Qed. Qed.
......
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