Fix for issue 3987 with deltaproduct.

Fix the no_piecewise logic for recursive deltaproduct calls. This fixes the first two tests reported in issue 3987, where a Piecewise was missing to really make the result valid for all input. Note that this does not address the Karr convention; limits have been assumed and are still assumed to be in increasing order.

c.f. issue 3987: wrong tests in test_deltaproduct
http://code.google.com/p/sympy/issues/detail?id=3987

I've also partly cherry-picked the added caching from #2448.