work in progress towards patLang -> callLang

When finished this will need to be reorganised and probably moved under
compiler/. Currently just copy-pasting a bunch of stuff from
compiler/proofs rather than depending on the theories there.