Implement type inference for expressions with the following (abstract) syntax:
Expr ::= num | id | Expr '+' Expr | 'fun' id '=' Expr | Expr Expri.e., integers, variables, addition, function definition (lambda abstraction) and application. Free variables are allowed. You may assume no two lambda abstractions bind the same variable (no renaming is needed). Report invalid typing using exceptions.