A Formal Model of the Economy