Definition oboxopt Delta ret P :=
match ret with
| Some id => obox Delta id P
| _ => P
end.
Definition odiaopt Delta ret P :=
match ret with
| Some id => odia Delta id P
| _ => P
end.
Definition temp_guard_opt (Delta : tycontext) (i: option ident): Prop :=
match i with
| Some i => temp_guard Delta i
| None => True
end.

(* Specifications: *)
Lemma substopt_oboxopt: forall Delta id v (P: environ -> mpred), substopt id (`v) (oboxopt Delta id P) = oboxopt Delta id P.
Lemma oboxopt_closed: forall Delta i P,
temp_guard_opt Delta i ->
closed_wrt_vars (fun id => isSome (match i with Some i' => insert_idset i' idset0 | None => idset0 end) ! id) P ->
oboxopt Delta i P = P.
Lemma oboxopt_T: forall Delta i (P: environ -> mpred),
temp_guard_opt Delta i ->
local (tc_environ Delta) && oboxopt Delta i P |-- P.
Lemma odiaopt_D: forall Delta i (P: environ -> mpred),
temp_guard_opt Delta i ->
local (tc_environ Delta) && P |-- odiaopt Delta i P.
Lemma oboxopt_odiaopt: forall Delta i P, temp_guard_opt Delta i -> oboxopt Delta i (odiaopt Delta i P) = odiaopt Delta i P.
Lemma oboxopt_K: forall Delta i P Q, P |-- Q -> oboxopt Delta i P |-- oboxopt Delta i Q.
Lemma odiaopt_derives_EX_substopt: forall Delta i P,
odiaopt Delta i P |-- EX v : val, substopt i (` v) P.
Lemma oboxopt_left2: forall Delta i P Q,
temp_guard_opt Delta i ->
local (tc_environ Delta) && P |-- Q ->
local (tc_environ Delta) && oboxopt Delta i P |-- oboxopt Delta i Q.
Lemma oboxopt_left2': forall Delta i P Q,
temp_guard_opt Delta i ->
local (tc_environ Delta) && (allp_fun_id Delta && P) |-- Q ->
local (tc_environ Delta) && (allp_fun_id Delta && oboxopt Delta i P) |-- oboxopt Delta i Q.
Lemma oboxopt_sepcon: forall Delta i P Q,
oboxopt Delta i P * oboxopt Delta i Q |-- oboxopt Delta i (P * Q).