from matexpr import ShapeError
from matpow import MatPow


class Inverse(MatPow):
    """Matrix Inverse

    Represents the Inverse of a matrix expression

    Use .I as shorthand

    >>> from sympy import MatrixSymbol, Inverse
    >>> A = MatrixSymbol('A', 3, 3)
    >>> B = MatrixSymbol('B', 3, 3)
    >>> Inverse(A)
    A^-1
    >>> A.I
    A^-1
    >>> Inverse(A*B)
    B^-1*A^-1

    """
    is_Inverse = True

    def __new__(cls, mat, **kwargs):

        if not mat.is_Matrix:
            return mat**(-1)

        if not mat.is_square:
            raise ShapeError("Inverse of non-square matrix %s" % mat)

        try:
            return mat._eval_inverse(**kwargs)
        except (AttributeError, NotImplementedError):
            return MatPow.__new__(cls, mat, -1)

    @property
    def arg(self):
        return self.args[0]

    @property
    def shape(self):
        return self.arg.shape

    def _eval_inverse(self):
        return self.arg

@@ -1,13 +1,81 @@
 from 
+sympy.core.sympify import _sympify%0A%0Afrom sympy.matrices.expressions.
 matexpr 
@@ -97,16 +97,43 @@
 or%0Afrom 
+sympy.matrices.expressions.
 matpow i
@@ -533,21 +533,38 @@
  mat
-, **kwargs):%0A
+):%0A        mat = _sympify(mat)
 %0A   
@@ -615,25 +615,24 @@
 n mat**(-1)%0A
-%0A
         if n
@@ -723,127 +723,8 @@
 at)%0A
-%0A        try:%0A            return mat._eval_inverse(**kwargs)%0A        except (AttributeError, NotImplementedError):%0A    
     
@@ -945,8 +945,178 @@
 elf.arg%0A
+%0A    def doit(self, **hints):%0A        if hints.get('deep', True):%0A            return self.arg.doit(**hints).inverse()%0A        else:%0A            return self.arg.inverse()%0A

fix Inverse