Fix `Basic.rewrite()` behavior

Fixes the behavior of `Basic.rewrite` to call the opropriate rule
function.  Furthermore, added handling for `deep` keyword to
`Basic.rewrite()`, which defaults to `True`.  This change allows the
removal of `Function.rewrite()` and `physics.quantum.QExpr.rewrite()`
methods, however, the default behavior is changed from `deep=False` to
`deep=True`.
Revert physics.quantum.QExpr.rewrite to fix spin doctest
Merge pull request #7556 from flacjacket/rewrite_fix

Fix `Basic.rewrite()` behavior