Commit 0f6567ec authored by Dan Frumin's avatar Dan Frumin

Use expr's and IntoVal as much as possible

parent f9333b2c
...@@ -8,7 +8,6 @@ Section Derived. ...@@ -8,7 +8,6 @@ Section Derived.
Context `{locking_heapG Σ, heapG Σ, flockG Σ, spawnG Σ}. Context `{locking_heapG Σ, heapG Σ, flockG Σ, spawnG Σ}.
Lemma a_load_ret (l: loc) (w: val) R Φ: Lemma a_load_ret (l: loc) (w: val) R Φ:
l U w (l U w - Φ w) - l U w (l U w - Φ w) -
awp (a_load (a_ret (#l)%E)) R Φ. awp (a_load (a_ret (#l)%E)) R Φ.
...@@ -18,11 +17,12 @@ Section Derived. ...@@ -18,11 +17,12 @@ Section Derived.
iExists l, w. by iFrame. iExists l, w. by iFrame.
Qed. Qed.
Lemma a_alloc_ret (w: val) R Φ: Lemma a_alloc_ret (e: expr) (ev: val) R Φ:
( (l: loc), (l U w - Φ #l)) - IntoVal e ev
awp (a_alloc (a_ret w)) R Φ. ( (l: loc), (l U ev - Φ #l)) -
awp (a_alloc (a_ret e)) R Φ.
Proof. Proof.
iIntros "H". iApply a_alloc_spec. iIntros (<-%of_to_val) "H". iApply a_alloc_spec.
iApply awp_ret. by wp_value_head. iApply awp_ret. by wp_value_head.
Qed. Qed.
......
...@@ -113,7 +113,6 @@ Section a_wp_rules. ...@@ -113,7 +113,6 @@ Section a_wp_rules.
iIntros (γ π env l) "#Hlock Hunfl". do 2 wp_lam. iFrame. iIntros (γ π env l) "#Hlock Hunfl". do 2 wp_lam. iFrame.
Qed. Qed.
(* Use [IntoVal] everywhere *)
Lemma awp_bind (f e : expr) R Φ : Lemma awp_bind (f e : expr) R Φ :
AsVal f AsVal f
awp e R (λ ev, awp (f ev) R Φ) - awp e R (λ ev, awp (f ev) R Φ) -
...@@ -127,7 +126,7 @@ Section a_wp_rules. ...@@ -127,7 +126,7 @@ Section a_wp_rules.
iIntros (v) "H". by iApply ("H" with "[$]"). iIntros (v) "H". by iApply ("H" with "[$]").
Qed. Qed.
Lemma awp_atomic e (ev : val) R Φ : Lemma awp_atomic (e : expr) (ev : val) R Φ :
IntoVal e ev IntoVal e ev
(R - R', R' awp (ev #()) R' (λ w, R' - R Φ w)) - (R - R', R' awp (ev #()) R' (λ w, R' - R Φ w)) -
awp (a_atomic e) R Φ. awp (a_atomic e) R Φ.
...@@ -148,7 +147,7 @@ Section a_wp_rules. ...@@ -148,7 +147,7 @@ Section a_wp_rules.
iIntros "Hunfl1". wp_seq. iFrame. iIntros "Hunfl1". wp_seq. iFrame.
Qed. Qed.
Lemma awp_atomic_env e (ev : val) R Φ : Lemma awp_atomic_env (e : expr) (ev : val) R Φ :
IntoVal e ev IntoVal e ev
( env, env_inv env - R - ( env, env_inv env - R -
WP ev env {{ w, env_inv env R Φ w }}) - WP ev env {{ w, env_inv env R Φ w }}) -
...@@ -191,11 +190,12 @@ End a_wp_rules. ...@@ -191,11 +190,12 @@ End a_wp_rules.
Section a_wp_run. Section a_wp_run.
Context `{heapG Σ, flockG Σ, spawnG Σ, locking_heapPreG Σ}. Context `{heapG Σ, flockG Σ, spawnG Σ, locking_heapPreG Σ}.
Lemma awp_run (v : val) R Φ : Lemma awp_run (e : expr) R Φ :
R - ( `{locking_heapG Σ}, awp v R (λ w, R ={}= Φ w)) - AsVal e
WP a_run v {{ Φ }}. R - ( `{locking_heapG Σ}, awp e R (λ w, R ={}= Φ w)) -
WP a_run e {{ Φ }}.
Proof. Proof.
iIntros "HR Hwp". rewrite /awp /a_run /=. wp_let. iIntros ([ev <-%of_to_val]) "HR Hwp". rewrite /awp /a_run /=. wp_let.
wp_bind (mset_create #()). iApply mset_create_spec; first done. wp_bind (mset_create #()). iApply mset_create_spec; first done.
iNext. iIntros (env) "Henv". wp_let. iNext. iIntros (env) "Henv". wp_let.
iMod (locking_heap_init ) as (?) "Hσ". iMod (locking_heap_init ) as (?) "Hσ".
......
...@@ -79,7 +79,7 @@ Section proofs. ...@@ -79,7 +79,7 @@ Section proofs.
iIntros (v) "[[% H] | [% H]]"; simplify_eq; awp_lam; by awp_if. iIntros (v) "[[% H] | [% H]]"; simplify_eq; awp_lam; by awp_if.
Qed. Qed.
Lemma a_if_true_spec R (e1 e2 : val) `{Closed [] e1, Closed [] e2} Φ : Lemma a_if_true_spec R (e1 e2 : expr) `{Closed [] e1, Closed [] e2} Φ :
awp e1 R Φ - awp (a_if (a_ret #true) (λ: <>, e1) (λ: <>, e2))%E R Φ. awp e1 R Φ - awp (a_if (a_ret #true) (λ: <>, e1) (λ: <>, e2))%E R Φ.
Proof. Proof.
iIntros "HΦ". iIntros "HΦ".
...@@ -88,7 +88,7 @@ Section proofs. ...@@ -88,7 +88,7 @@ Section proofs.
iLeft. iSplit; eauto. by awp_seq. iLeft. iSplit; eauto. by awp_seq.
Qed. Qed.
Lemma a_if_false_spec R (e1 e2 : val) `{Closed [] e1, Closed [] e2} Φ : Lemma a_if_false_spec R (e1 e2 : expr) `{Closed [] e1, Closed [] e2} Φ :
awp e2 R Φ - awp (a_if (a_ret #false) (λ: <>, e1) (λ: <>, e2))%E R Φ. awp e2 R Φ - awp (a_if (a_ret #false) (λ: <>, e1) (λ: <>, e2))%E R Φ.
Proof. Proof.
iIntros "HΦ". iIntros "HΦ".
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment