Factor out the memory things in a separate module.
Also, add functions for translating sequents and derivations so that they use
explicit memory.