Module DSolver.
Local Existing Instances Deep.L Deep.minL Deep.pL Deep.GP Deep.minAX Deep.ipG.
Instance Adj : Adjointness _ _ andp impp.
Instance Comm : Commutativity _ _ andp.
Instance Mono : Monotonicity _ _ andp.
Instance Assoc : Associativity _ _ andp.
Instance LUnit : LeftUnit _ _ truep andp.
Instance RUnit : RightUnit _ _ truep andp.
Fixpoint flatten_imp (e : expr) : list expr * expr :=
match e with
| Deep.impp p q => let (cxt, fq) := flatten_imp q in (p :: cxt, fq)
| _ => (nil, e)
end.
Definition flatten_imp_inv (p : list Deep.expr * Deep.expr) :=
let (ctx, r) := p in multi_imp ctx r.

Lemma flatten_imp_sound :
forall e, e = flatten_imp_inv (flatten_imp e).