Update the semantics and type system

The semantics  of declarations needs to keep track of which types and
exceptions have been declared, so that it can raise a type error if a
duplicate is encountered. This is necessary to get the tag allocation
proof for IL2 working. The type system needs also needs to track the
definitions, or else it might allow a duplicate that has no
constructors.

Work in progress. The type soundness proof is currently broken.