fail on illegal ops in patternify

patternify is the only use of subs/rules. It's the only case when we
are likely to fail
Merge pull request #1660 from jrioux/documentation

Better handling of tutorial translations
3518: fix necklace routine

Although a better algorithm could be used, this one (along with a more
robust minlex routine) at least corrects the error that was present.
Added tests will help to ensure that any replacement is correct.
fix Bell permutation generation
deprecate unrestricted_necklaces; use bracelets
simplify generate_derangements

derangements of a multiset are much faster now:

Now

>>> t=time();len(list(generate_derangements(
... [1,2,3,4,3,2,1,2,1,2,3])));print time()-t
1148
0.816480875015

Pervious

>>> t=time();len(list(generate_derangements(
... [1,2,3,4,3,2,1,2,1,2,3])));print time()-t
1148
129.046013832
fix involutions

The tests were insufficient to show that the criteria were not
being satisfied.

Previously

>>> set([Permutation(pi)**2 for pi in generate_involutions(4)])
set([Permutation(0, 2, 3), Permutation(0, 1, 3), Permutation(3)])

Now

>>> set([Permutation(pi)**2 for pi in generate_involutions(3)])
set([Permutation(2)])
>>> set([Permutation(pi)**2 for pi in generate_involutions(4)])
set([Permutation(3)])
>>> set([Permutation(pi)**2 for pi in generate_involutions(5)])
set([Permutation(4)])
>>> set([Permutation(pi)**2 for pi in generate_involutions(6)])
set([Permutation(5)])
>>> set([Permutation(pi)**2 for pi in generate_involutions(3)])
docstring edits
Make Matrix sympifiable.

* sympify(<Matrix>) now returns an ImmutableMatrix
* for consistency with general sympy conventions, this forces
  <MutableMatrix> + <ImmutableMatrix> -> ImmutableMatrix.
* Some hacking of arithmetic operator dispatch is required to
  still get scalar * MutableMatrix -> MutableMatrix
Refactor integer_powers()

* Use for: else:
* Kill the index flag, since it complicates the code without
  giving any performance advantage.
* Sort terms with default_sort_key, which gives consistent
  ordering across platforms.
Use .sort_key() to order symbolic arguments in secondquant
sympy.stats: don't rely implicitly on bool(Relational)
Merge pull request #1644 from pernici/can3

Canonical tensors using Butler-Portugal algorithm
sympy_parser: don't change attribute access into Symbols (#2663)

Only fixes the issue relating to attribute access, not keyword
arguments.
sympy_parser: don't change keyword arguments into Symbols

Fixes #3423 and #2663.
sympy_parser: Add tests for keyword args and attributes
Refactor sympy_parser
sympy_parser: Update tests to reflect new API
parse_expr: Allow override of globals
Add imports for tests