You have to bisect the facts. There's an open issue to do this
automatically
https://github.com/sympy/sympy/issues/8029.
I played with it and I believe the facts
CheckOneByOneMatrix(Q.diagonal)) and CheckEmptyMatrix(Q.zero)) are
wrong. These compile to Equivalent(Q.diagonal(A), A.shape == (1, 1))
and Equivalent(Q.zero(A), A.shape == (0, 0)). But Equivalent is
incorrect here. It should just be reverse implication. Diagonal
matrices are not necessarily 1x1, and zero matrices are not
necessarily empty.
I'm assuming you modeled these after CheckIsPrime. Direct equivalence
handler classes like this should only be used to show the system that
an assumption is equivalent to some computation on an object (e.g.,
Q.prime is equivalent to the isprime() function). No doubt some better
naming, and perhaps some refactoring could make this clearer.
Something like EmptyMatrix would need to be a predicate, not a
handler. Something like
(MatrixExpr, CheckEmptyMatrix(Q.EmptyMatrix))
would be a correct fact.
Finally, your fact Implies(Q.diagonal, Q.symmetric)) is unnecessary
(it's already in the known_facts in ask.py), and Implies(Q.zero &
Q.square, Q.diagonal)) should go in ask.py, since it's a completely
free fact (it's true regardless of what expression you apply it to).
I also want to note that I'm a little worried about the use of Q.zero
to refer to zero matrices. That could lead to problems down the road,
since Q.zero means "real and zero" in the assumptions. However, just
looking at the existing known_facts, I see a lot of inconsistencies
and confusion of numbers and matrices (and operators) in the new
assumptions, so as long as things work, we can probably punt this to
another day.
Aaron Meurer
>
https://groups.google.com/d/msgid/sympy/0ea41a27-64fb-4dfb-8ad0-bed1472c7b81%40googlegroups.com.