@Override
	public Expression simplify() {
		// TODO Auto-generated method stub
		System.out.println("exp化简");
		Expression newLeft = left.simplify();
        Expression newRight = right.simplify();
        ConstantExpression leftConst =null;
        ConstantExpression rightConst =null;
        try {
        	leftConst =(ConstantExpression) newLeft;
		} catch (Exception e) {	}
		try {
			rightConst =(ConstantExpression) newRight;
		} catch (Exception e) {	}
		
		if ( leftConst != null && rightConst != null )
        {
            // two constants;  just evaluate it;
            return new ConstantExpression( Math.pow( leftConst.getValue(),rightConst.getValue() ) );
        }
        else if ( rightConst != null )
        {
            if ( rightConst.getValue() == 0 )
            {
                // x ^ 0;  return 1;
                return new ConstantExpression( 1 );
            }
            else if ( rightConst.getValue() == 1 )
            {
                // x ^ 1;  return x;
                return newLeft;
            }
        }
        else if ( leftConst != null && leftConst.getValue() == 0 )
        {
            // 0 ^ y;  return 0;
            return new ConstantExpression( 0 );
        }
        // x ^ y;  no simplification
        return new ExpExpression( newLeft, newRight );
	}