minor tidy up: move In_option_rwt2 to miscTheory
tweak exp_to_Cexp to match state_monadTheory's monadic style

flip argument order, and use state_transformerTheory's UNIT
go further with state_transformer

use monadic bind throughout the definition of exp_to_Cexp
make remove_mat work wrt a code env

in particular, its calls to free vars (to know what vars should be fresh
for) need to take the real code env as an argument.
cannot assume the code env is always empty, since exp_to_Cexp uses it
now.
define new v_to_Cv, start on fixing pmatchTheory

but now might be better to press ahead with the back end of the proof,
to see if this new intermediate language has actually made things easier
(as payment for breaking everything...)
fix some comments regarding compile_closures
fix Holmakefile in bytecode/benchmarking for new repo
go back to intLang with optional labels for bodies

Aim is to keep the proofs up to exp_to_Cexp intact, since labelising can
be done separately and it's not worth breaking the proofs to do it at
the same time as exp_to_Cexp.

This is based on code in 9fedec64b61ad3e35a848b4ed6d769dac00401a2 in the
HOL repository. (This repository's history doesn't go back far enough to
contain the old intLag.)

Working on a new, simpler approach to labelising:
Pull any unlabeled bodies into the code env (but without
recursively doing the same to the bodies).
Repeat on each exp in the range of the code env (merge the resulting
code env in), until no unlabeled bodies remain.

In this commit:
Old correctness proofs (up to exp_to_Cexp) work.
Defined new labelise, but haven't proved anything about it (including
termination) and compiler tests are broken.
fix labelise to pass compiler tests

also added some more tests
some compiler termination proofs

easy ones, and a cheating template for the difficult one in
repeat_label_closures
make a type abbreviation for the defs argument to a CLetfun

also fix compile_emit to handle the new type abbrev
use def type abbrev to constrain type of label_defs
Attempt to prove termination of repeat_label_closures
Finish termination proof for repeat_label_closures

There was actually a relatively easy measure (and did not have to deal
with the apparent nested recursion). The idea is:
  - count the number of syntactic bodies in expressions, ignoring the
    code environment and any pointers into it
  - label_closures moves bodies out of an expression and into the code
    environment, so total bodies of exp = length of code env + total
    bodies in code env
  - repeat_label_closures's recursions are:
      - work on the first item of a code env
      - work on the rest of a code env
      - work on the code env generated from an expression
  - hence we can measure the total number of bodies in the expression
    argument or the total bodies in + length of the code env argument,
    and this will either go down or stay exactly the same (in the last
    listed recursion).
move some stuff into main HOL repo
start towards correctness of repeat_label_closures

replace codeEnvTheory with labelClosuresTheory.
define free_labs and subst_labs (simple versions that don't recurse
through the code env).
prove a lemma about subst_labs, and work on statement of
(repeat_)label_closures correctness.
theorem characterising label_closures's effects on its state

in terms of free_bods.
remove fmap_size_def from CexpTypesTheory

it is already in finite_mapTheory
Generalise subst_labs_any_env

Changed the definition slightly too, so it leaves a label in place if it
doens't occur in the code environment's domain.

Also, the start of an attempt to extend label_closures_thm to also
characterise returned exp (in terms of subst_labs).

Also start of attempt to say something about Cevaluate_subst_labs.
simplify statement and proof of subst_labs_any_env