Commit 288be712 authored by Léon Gondelman's avatar Léon Gondelman

working on extending vcg_wp on function calls by evaluating the arguments

parent 189d129e
......@@ -90,6 +90,13 @@ Notation "'whileᶜ' ( e1 ) { e2 }" := (a_while (λ:<>, e1)%E (λ:<>, e2)%E)
Definition a_invoke: val := λ: "f" "arg",
a_seq_bind (λ: "a", a_atomic (λ: <>, "f" "a")) "arg".
Notation "f ❲ a ❳ " :=
( a_invoke f a)%E
(at level 100, a at level 200,
format "f ❲ a ❳") : expr_scope.
Section proofs.
Context `{amonadG Σ}.
......
......@@ -208,6 +208,7 @@ Inductive dcexpr : Type :=
| dCUnOp : un_op dcexpr dcexpr
| dCSeq : dcexpr dcexpr dcexpr
| dCPar : dcexpr dcexpr dcexpr
| dCInvoke (f: val) `{!Closed [] f} (de: dcexpr)
| dCUnknown (e : expr) `{!Closed [] e}.
Fixpoint dcexpr_interp (E: known_locs) (de: dcexpr) : expr :=
......@@ -217,10 +218,12 @@ Fixpoint dcexpr_interp (E: known_locs) (de: dcexpr) : expr :=
| dCLoad de1 => a_load (dcexpr_interp E de1)
| dCStore de1 de2 => a_store (dcexpr_interp E de1) (dcexpr_interp E de2)
| dCBinOp op de1 de2 => a_bin_op op (dcexpr_interp E de1) (dcexpr_interp E de2)
| dCPreBinOp op de1 de2 => a_pre_bin_op op (dcexpr_interp E de1) (dcexpr_interp E de2)
| dCPreBinOp op de1 de2 =>
a_pre_bin_op op (dcexpr_interp E de1) (dcexpr_interp E de2)
| dCUnOp op de => a_un_op op (dcexpr_interp E de)
| dCSeq de1 de2 => dcexpr_interp E de1 ; dcexpr_interp E de2
| dCPar de1 de2 => dcexpr_interp E de1 ||| dcexpr_interp E de2
| dCInvoke fv de => fv dcexpr_interp E de
| dCUnknown e1 => e1
end.
......@@ -236,8 +239,9 @@ Fixpoint dval_wf (E: known_locs) (dv : dval) : bool :=
Fixpoint dcexpr_wf (E: known_locs) (de: dcexpr) : bool :=
match de with
| dCRet dv => dval_wf E dv
| dCAlloc de1 | dCLoad de1 | dCUnOp _ de1 => dcexpr_wf E de1
| dCStore de1 de2 | dCBinOp _ de1 de2 | dCPreBinOp _ de1 de2 | dCSeq de1 de2 | dCPar de1 de2 =>
| dCAlloc de1 | dCLoad de1 | dCUnOp _ de1 | dCInvoke _ de1 => dcexpr_wf E de1
| dCStore de1 de2 | dCBinOp _ de1 de2
| dCPreBinOp _ de1 de2 | dCSeq de1 de2 | dCPar de1 de2 =>
dcexpr_wf E de1 && dcexpr_wf E de2
| dCUnknown _ => true
end.
......@@ -246,7 +250,7 @@ Fixpoint dcexpr_wf (E: known_locs) (de: dcexpr) : bool :=
Lemma dval_wf_mono (E E': known_locs) (dv: dval) :
dval_wf E dv E `prefix_of` E' dval_wf E' dv.
Proof.
induction dv as [d| |]; try naive_solver.
induction dv as [d| | ]; try naive_solver.
destruct d; eauto.
destruct d as [i|]; last done; simplify_eq /=.
intros Hb Hpre. case_bool_decide; last done.
......@@ -285,7 +289,7 @@ Proof. destruct op, dv1,dv2; simpl; repeat case_match; naive_solver. Qed.
Lemma dval_interp_mono (E E': known_locs) (dv: dval) :
dval_wf E dv E `prefix_of` E' dval_interp E dv = dval_interp E' dv.
Proof.
induction dv as [d| | ]; try naive_solver.
induction dv as [d| |]; try naive_solver.
destruct d; eauto.
destruct d as [i|]; last done; simplify_eq /=.
intros Hb Hpre. case_bool_decide; last done.
......@@ -438,6 +442,14 @@ Global Instance into_dcexpr_par E e1 e2 de1 de2:
IntoDCexpr E (e1 ||| e2) (dCPar de1 de2).
Proof. intros [-> ?] [-> ?]; split; simpl; auto. Qed.
Global Instance into_dcexpr_invoke E `{Closed [] e1} ef f `{!IntoVal ef f} de1 :
IntoDCexpr E e1 de1
IntoDCexpr E (efe1) (dCInvoke f de1).
Proof.
intros. unfold IntoVal in *. simplify_eq /=.
split; simpl; auto; f_equal; by inversion H0.
Qed.
Global Instance into_dcexpr_unknown E e `{Closed [] e}:
IntoDCexpr E e (dCUnknown e) | 100.
Proof. done. Qed.
......@@ -60,7 +60,15 @@ Section test.
iIntros "**". vcg_solver. eauto with iFrame.
Qed.
(*TODO: test function call with multiple arguments *)
Definition c_id : val := λ: "v", a_ret ("v").
Lemma test_invoke_1 (l: loc) (v : val) R :
l C v -
AWP c_id❲∗ᶜ l @ R {{ v, v = #73 }}%I.
Proof.
iIntros "Hl". vcg_solver.
Admitted.
Lemma test6 (l : loc) (z0 : Z) R:
l C #z0 -
......@@ -72,7 +80,8 @@ Section test.
Lemma test7 (l k : loc) (z0 z1 : Z) R:
l C #z0 -
k C #z1 -
AWP (l += 1) + (∗ᶜ♯k) @ R {{ v, v = #(z0+z1) l C[LLvl] #(z0+1) k C #z1 }}.
AWP (l += 1) + (∗ᶜ♯k) @
R {{ v, v = #(z0+z1) l C[LLvl] #(z0+1) k C #z1 }}.
Proof.
iIntros "Hl Hk". vcg_solver. eauto with iFrame.
Qed.
......
This diff is collapsed.
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