Add hash function for Expr

Fixes #4406