subs cleanup

    All input to subs is reduced to a sequence of old, new tuples.
    If the input is a dict or set (unordered containers) the replacements
    are ordered. A special routine is used for dict; sets are sorted by
    op count and in case of a tie, by the number of arguments.

    This reduction to a single container allows all the individual
    routines for different containers to be removed. In their place
    is _subs which handles a single old->new substitution and caches
    results. That routine also handles the case of self == old, allowing
    that to be factored out of all _eval_subs routines.

    An _eval_subs routine only needs to be written if more than just trying
    the replacement on all the args of the object. For example,
    Integrals need to watch out for the integration variables and not
    allow certain changes to them. Many objects (especially in secondquant)
    were essentially duplicating what is now the fallback behavior in _subs
    (i.e. trying the substitution on all arguments) so they could be (and
    were) removed.

    The recursion by _eval_subs into sub-arguments has been removed: when
    _eval_subs has not made any changes and wants to try the replacement
    of old -> new on sub-arguments, it should return None and this will be
    handled by _subs. If no further processing of the expression is needed
    then an expression should be returned.

    Summary: call subs with raw old, new pairs: they will be sympified and
             sorted if necessary.

	     _eval_subs need only deal with the case of self != old and
	     should not do any recursive calls. If the subs cannot
	     be performed on the given object and it should be tried on the
	     sub-arguments of the object, then None should be returned. If
	     further substitution of a subset of an expressions arguments
	     needs to be performed, _subs (not _eval_subs) should be called
	     on them; alternatively, if a subexpression (rather than a
	     subset of an expressions arguments) needs to be processed, then
	     _subs should be called on it, too.

   There are further developer's notes in the subs docstring.

Other changes:

    o remove special trig subs behavior: tan(x).subs(x,pi/2)->zoo

    o fix GeometryEntity.subs

    o eliminate hasattr check in _subs

    o give Basic _eval_subs routine

    o remove O(n**2) sorting from subs

        This is not currently needed. Perhaps if some sort of wild patterns
        were used to do replacements something other than the current method
        would be necessary, but nothing fails with the current sorting scheme.

    o update xreplace docstring
keep only Expr.as_numer_denom() stub

    It doesn't make sense for Basic to have a numerator and denominator.

    AtomicExpr derives from Expr, so it inherits Expr's as_numer_denom stub.
2552: give Mul._eval_subs a chance to handle Muls in denominator
matexpr comment added to _eval_subs
2976: check for _subs attribute
complete coverage of subs cleanup work
let equivalent new/old subs pass; use better test for self==old
1581: prefer str->Symbol in subs
update exp subs tests to pass

    The input expression is unchanged if no substitutions take place.
2749: use items() to get data from dict and Dict
default_sort_key breaks ties in subs sort
raise error if an unordered sequence appears ambiguous

    The ambiguous() function is not guaranteed to catch all
    ambiguous substitution sequences nor does it guarantee that
    for a given expr the apparently ambiguous sequence wouldn't
    have been ambiguous. It's just a safeguard that will raise
    an error (unless suppressed with the keyword, `warn`) if
    it appears that the order of substitutions will matter.

    Even if the error is not raised, unordered sequences will
    still be ordered before substitution.
watch for negated Numbers`
watch for Piecewise UndefinedFunction-like args
pep8 cleanup of test_subs.py
remove ambiguity checking from subs
2571: allow subs of integrand for indefinite integrals

        indefinite integral

        >>> i = Integral(x, x)
        >>> i.as_dummy()
        Integral(x, x)
        >>> i.subs(x, 1)
        Integral(1, x)

        "evaluate at" integral

        >>> at = Integral(x, (x, x))
        >>> at.as_dummy()
        Integral(_x, (_x, x))
        >>> at.subs(x, 1)
        Integral(x, (x, 1))

        >>> i.doit() == at.doit()
        True
        >>> i.diff(x) == at.diff(x).doit() # get rid of Integral(0, (x, x))
        True
subs gets parallel keyword

    This allows products to have all replacements made before
    evaluating and disallows subsequent substitutions from affecting
    former replacements (as happens fo serial susbtitutions).

    This is shown in the docstring.