(expr, assumptions)
return expr
>>> from sympy import MatrixSymbol, Q, assuming, refine
    >>> X = MatrixSymbol('X', 2, 2)
    >>> X.I
    X^-1
    >>> with assuming(Q.orthogonal(X)):
    ...     print(refine(X.I))
    X'
>>> from sympy import MatrixSymbol, Q, assuming, refine
    >>> X = MatrixSymbol('X', 2, 2)
    >>> X.I
    X^-1
    >>> with assuming(Q.orthogonal(X)):
    ...     print(refine(X.I))
    X'
>>> from sympy import MatrixSymbol Q assuming refine >>> X = MatrixSymbol ( X 2 2 ) >>> X . I X^ - 1 >>> with assuming ( Q . orthogonal ( X )) : ... print ( refine ( X . I )) X
def refine_Inverse(expr, assumptions):
    """
    >>> from sympy import MatrixSymbol, Q, assuming, refine
    >>> X = MatrixSymbol('X', 2, 2)
    >>> X.I
    X^-1
    >>> with assuming(Q.orthogonal(X)):
    ...     print(refine(X.I))
    X'
    """
    if ask(Q.orthogonal(expr), assumptions):
        return expr.arg.T
    elif ask(Q.unitary(expr), assumptions):
        return expr.arg.conjugate()
    elif ask(Q.singular(expr), assumptions):
        raise ValueError("Inverse of singular matrix %s" % expr.arg)

    return expr
def refine_Inverse ( expr , assumptions ) : if ask ( Q . orthogonal ( expr ) , assumptions ) : return expr . arg . T elif ask ( Q . unitary ( expr ) , assumptions ) : return expr . arg . conjugate ( ) elif ask ( Q . singular ( expr ) , assumptions ) : raise ValueError ( "Inverse of singular matrix %s" % expr . arg ) return expr