End RAMIF_Q.
Ltac formalize :=
match goal with
| |- @derives ?Pred _ ?g (?l * @allp ?Pred _ ?T ?Func) =>
let g' := fresh "g'" in evar (g': T -> Pred);
let l' := fresh "l'" in evar (l': T -> Pred);
let x := fresh "x" in
let H := fresh "H" in
assert (Func = l' -* g') as H;
[
extensionality x; cbv beta;
match goal with
| |- ?L' -* exp ?G' = _ =>
super_pattern L' x; super_pattern_in_func G' x
| |- ?L' -* ?G' = _ =>
super_pattern L' x; super_pattern G' x
end;
match goal with
| |- ?L' _ -* exp (fun a => ?G' a _) = _ =>
instantiate (1 := L') in (Value of l');
instantiate (1 := exp G') in (Value of g')
| |- ?L' _ -* ?G' _ = _ =>
instantiate (1 := L') in (Value of l');
instantiate (1 := G') in (Value of g')
end;
subst g' l';
reflexivity
| subst g' l'; rewrite H; clear H]
end.
End RAMIF_Q.
Module RAMIF_Q'.
Section RAMIF_Q'.
Context {A : Type}.
Context {ND : NatDed A}.
Context {SL : SepLog A}.
Context {CoSL: CorableSepLog A}.

Lemma trans: forall {B BG BL} g m l p pG pL g' mG' mL' l' (fG: B -> BG) (fL: B -> BL),
corable p ->
corable pL ->
corable pG ->
g |-- m * allp (pG --> (mG' -* g')) ->
m |-- l * allp (pL --> (l' -* mL')) ->
(forall b, p b |-- pL (fL b)) ->
(forall b, p b && mL' (fL b) |-- pG (fG b) && mG' (fG b)) ->
g |-- l * allp (p --> (Basics.compose l' fL -* Basics.compose g' fG)).