expression: add utility function to ensure unnamed refs

And use it in rules/algebra. Also add some comments.