This is excellent, I was thinking about similar optimization using inverses:<p>If one calculates some reduction over a data structure, and this reduction is group operator (so it has inverse, like addition), and this data structure is then updated, it may be easier to recalculate the reduction by updating the result through inverse than to recalculate the whole reduction again.<p>For example, we are calculating sum over a list, we take element out, then it&#x27;s easier to just subtract the element from the sum rather than calculating the sum again.<p>Anyway, all in all, I think knowledge of function inverses (and perhaps also isomorphisms between types) by compiler will become very handy in the future, and will enable huge number of optimizations.