Added a test for set vs hasvalue

- Added patterns for simplifying arithmetic