Commit e31372f3 authored by Robbert Krebbers's avatar Robbert Krebbers

Simplify stuff.

parent ee9d4038
This diff is collapsed.
......@@ -84,42 +84,46 @@ Section vcg.
| m::ms => Some (ms, m)
end.
Fixpoint vcg_sp (E: known_locs) (mIn : denv) (mOut : list denv) (de : dcexpr)
: option (denv * list denv * denv * dval) :=
Fixpoint vcg_sp (E: known_locs) (ms : list denv) (de : dcexpr)
: option (list denv * denv * dval) :=
match de with
| dCRet dv => Some (mIn, mOut, [], dv)
| dCRet dv => Some (ms, [], dv)
| dCLoad de1 =>
''(mIn1, mOut1, mNew, dl) vcg_sp E mIn mOut de1;
i is_dloc E dl;
''(mIn2, mOut2, mNew2, q, dv) denv_delete_frac_3 i mIn1 mOut1 mNew;
Some (mIn2, mOut2, denv_insert i ULvl q dv mNew2, dv)
''(ms1, mNew, dl) vcg_sp E ms de1;
i is_dloc E dl;
''(ms2, mNew2, q, dv) denv_delete_frac_2 i ms1 mNew;
Some (ms2, denv_insert i ULvl q dv mNew2, dv)
| dCStore de1 de2 =>
''(mIn1, mOut1, mNew1, dl) vcg_sp E mIn mOut de1;
i is_dloc E dl;
''(mIn2, mOut2, mNew2, dv) vcg_sp E mIn1 mOut1 de2;
''(mIn3, mOut3, mNew3, _) denv_delete_full_3 i mIn2 mOut2 (denv_merge mNew1 mNew2);
Some (mIn3, mOut3, denv_insert i LLvl 1 dv mNew3, dv)
''(ms1, mNew1, dl) vcg_sp E ms de1;
i is_dloc E dl;
''(ms2, mNew2, dv) vcg_sp E ms1 de2;
''(ms3, mNew3, _) denv_delete_full_2 i ms2 (denv_merge mNew1 mNew2);
Some (ms3, denv_insert i LLvl 1 dv mNew3, dv)
| dCBinOp op de1 de2 =>
''(mIn1, mOut1, mNew1, dv1) vcg_sp E mIn mOut de1;
''(mIn2, mOut2, mNew2, dv2) vcg_sp E mIn1 mOut1 de2;
''(ms1, mNew1, dv1) vcg_sp E ms de1;
''(ms2, mNew2, dv2) vcg_sp E ms1 de2;
match dbin_op_eval E op dv1 dv2 with
| dSome dv => Some (mIn2, mOut2, denv_merge mNew1 mNew2, dv)
| dSome dv => Some (ms2, denv_merge mNew1 mNew2, dv)
| dNone | dUnknown _ => None
end
| dCUnOp op de =>
''(mIn1, mOut1, mNew1, dv) vcg_sp E mIn mOut de;
''(ms1, mNew1, dv) vcg_sp E ms de;
match dun_op_eval E op dv with
| dSome dv' => Some (mIn1, mOut1, mNew1, dv')
| dSome dv' => Some (ms1, mNew1, dv')
| dNone | dUnknown _ => None
end
| dCSeq de1 de2 =>
''(mIn1, mOut1, mNew1, _) vcg_sp E mIn mOut de1;
''(mIn2, mOut2, mNew2, dv2) vcg_sp E mIn1 (denv_unlock mNew1::mOut1) de2;
''(mOut3, mNew3) popstack mOut2;
Some (mIn2, mOut3, denv_merge mNew2 mNew3, dv2)
''(ms1, mNew1, _) vcg_sp E ms de1;
''(ms2, mNew2, dv2) vcg_sp E (denv_unlock mNew1 :: ms1) de2;
''(ms3, mNew3) popstack ms2;
Some (ms3, denv_merge mNew2 mNew3, dv2)
| dCAlloc _ | dCUnknown _ => None
end.
Definition vcg_sp' (E: known_locs) (m : denv) (de : dcexpr) : option (denv * denv * dval) :=
''(ms,mNew,dv) vcg_sp E [m] de;
''(_, m') popstack ms;
Some (m', mNew, dv).
Definition vcg_wp_unknown (R : iProp Σ) (E: known_locs) (de: dcexpr) (m: denv)
(Φ : known_locs denv dval wp_expr) : wp_expr :=
......@@ -181,28 +185,28 @@ Section vcg.
| dCLoad de1 =>
vcg_wp E m de1 R (λ E m' dv, vcg_wp_load E dv m' (Φ E))
| dCStore de1 de2 =>
match vcg_sp E m [] de1 with
| Some (mIn, mOut, mNew, dv1) =>
vcg_wp E mIn de2 R (λ E mIn dv2,
vcg_wp_store E dv1 dv2 (denv_merge (denv_merge mNew (denv_stack_merge mOut)) mIn) (Φ E))
match vcg_sp' E m de1 with
| Some (m', mNew, dv1) =>
vcg_wp E m' de2 R (λ E m'' dv2,
vcg_wp_store E dv1 dv2 (denv_merge mNew m'') (Φ E))
| None =>
match vcg_sp E m [] de2 with
| Some (mIn, mOut, mNew, dv2) =>
vcg_wp E mIn de1 R (λ E mIn dv1,
vcg_wp_store E dv1 dv2 (denv_merge mNew (denv_merge (denv_stack_merge mOut) mIn)) (Φ E))
match vcg_sp' E m de2 with
| Some (m', mNew, dv2) =>
vcg_wp E m' de1 R (λ E m'' dv1,
vcg_wp_store E dv1 dv2 (denv_merge mNew m'') (Φ E))
| None => vcg_wp_unknown R E de m Φ
end
end
| dCBinOp op de1 de2 =>
match vcg_sp E m [] de1 with
| Some (mIn, mOut, mNew, dv1) =>
vcg_wp E mIn de2 R (λ E mIn dv2,
vcg_wp_bin_op E op dv1 dv2 (denv_merge mNew (denv_merge (denv_stack_merge mOut) mIn)) (Φ E))
match vcg_sp' E m de1 with
| Some (m', mNew, dv1) =>
vcg_wp E m' de2 R (λ E m'' dv2,
vcg_wp_bin_op E op dv1 dv2 (denv_merge mNew m'') (Φ E))
| None =>
match vcg_sp E m [] de2 with
| Some (mIn, mOut, mNew, dv2) =>
vcg_wp E mIn de1 R (λ E mIn dv1,
vcg_wp_bin_op E op dv1 dv2 (denv_merge mNew (denv_merge (denv_stack_merge mOut) mIn)) (Φ E))
match vcg_sp' E m de2 with
| Some (m', mNew, dv2) =>
vcg_wp E m' de1 R (λ E m'' dv1,
vcg_wp_bin_op E op dv1 dv2 (denv_merge mNew m'') (Φ E))
| None => vcg_wp_unknown R E de m Φ
end
end
......
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