Is there a programming language L where it is possible to write an optimizer O, that, receiving a program in L and a set of cost for every low-level operation in L, returns the equivalent program with the least total cost possible?Practical example:(optimize '(* a a) [['* 2] ['pow 1]])Should return:(pow a)For a hypothetical language where '*' and 'sqrt' are the only primitive operations, as the cost of the 'sqrt' operation (1) is lower than the cost of the '*' operation (2).
Is there any language for which a perfect optimization is decidable?
pl.programming languages