Commit bd40a3ac by Robbert Krebbers

### Change FindPred to get better folding/unfolding behavior.

parent 47598d44
 ... @@ -55,9 +55,9 @@ Module LiftingTests. ... @@ -55,9 +55,9 @@ Module LiftingTests. Qed. Qed. Definition FindPred : val := Definition FindPred : val := λ: "x", rec: "pred" "y" := rec: "pred" "x" := λ: "y", let: "yp" := "y" + '1 in let: "yp" := "y" + '1 in if "yp" < "x" then "pred" "yp" else "y". if "yp" < "x" then "pred" "x" "yp" else "y". Definition Pred : val := Definition Pred : val := λ: "x", if "x" ≤ '0 then -FindPred (-"x" + '2) '0 else FindPred "x" '0. λ: "x", if "x" ≤ '0 then -FindPred (-"x" + '2) '0 else FindPred "x" '0. ... @@ -65,22 +65,22 @@ Module LiftingTests. ... @@ -65,22 +65,22 @@ Module LiftingTests. (■ (n1 < n2) ∧ Q (LitV (n2 - 1))) ⊑ wp E (FindPred 'n2 'n1)%L Q. (■ (n1 < n2) ∧ Q (LitV (n2 - 1))) ⊑ wp E (FindPred 'n2 'n1)%L Q. Proof. Proof. (* FIXME there are some annoying scopes shown here: %Z, %L. *) (* FIXME there are some annoying scopes shown here: %Z, %L. *) rewrite /FindPred. revert n1; apply löb_all_1=>n1. rewrite -(wp_bindi (AppLCtx _)) -wp_let //=. revert n1. apply löb_all_1=>n1. rewrite (comm uPred_and (■ _)%I) assoc; apply const_elim_r=>?. rewrite (comm uPred_and (■ _)%I) assoc; apply const_elim_r=>?. rewrite -wp_value' //. (* first need to do the rec to get a later *) rewrite -wp_rec' // =>-/=. rewrite -(wp_bindi (AppLCtx _)). rewrite -wp_rec' // =>-/=; rewrite -wp_value' //=. (* FIXME: ssr rewrite fails with "Error: _pattern_value_ is used in conclusion." *) (* FIXME: ssr rewrite fails with "Error: _pattern_value_ is used in conclusion." *) rewrite ->(later_intro (Q _)). rewrite ->(later_intro (Q _)). rewrite -!later_and; apply later_mono. rewrite -!later_and; apply later_mono. (* Go on *) (* Go on *) rewrite -wp_let //= -later_intro. rewrite -(wp_bindi (LetCtx _ _)) -wp_bin_op //= -wp_let //=. rewrite -(wp_bindi (LetCtx _ _)) -wp_bin_op //= -wp_let //=. rewrite -(wp_bindi (IfCtx _ _)) /= -!later_intro. rewrite -(wp_bindi (IfCtx _ _)) /= -!later_intro. apply wp_lt=> ?. apply wp_lt=> ?. - rewrite -wp_if_true. - rewrite -wp_if_true. rewrite -later_intro (forall_elim (n1 + 1)) const_equiv; last omega. rewrite -!later_intro (forall_elim (n1 + 1)) const_equiv; last omega. rewrite left_id impl_elim_l. by rewrite -(wp_bindi (AppLCtx _)). by rewrite left_id impl_elim_l. - assert (n1 = n2 - 1) as -> by omega. - assert (n1 = n2 - 1) as -> by omega. rewrite -wp_if_false. rewrite -wp_if_false. by rewrite -!later_intro -wp_value' // and_elim_r. by rewrite -!later_intro -wp_value' // and_elim_r. ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!