# Ring with Cohen-Macaulay canonical module

Let $(R,m)$ be Noetherian local ring which is an imagine of a Gorenstein ring $(S,n)$. Set $$K_R:= Ext_S^{s-d}(R,S),$$ where $d=\dim R$, $s=\dim S$. If $K_R$ is Cohen-Macaulay (i.e. $R$ is a canonical Cohen-Macaulay ring) and $R$ is unmixed (i.e. $dim \widehat{R}/p=d$ for all $p \in Ass \widehat{R}$), is there exist an injective homomorphism $$R \overset{\varphi}{\longrightarrow} K_R.$$ If there exists what is $dim Coker(\varphi)$ ?

Thank you very much for your help.

It seem to be we should consider the question when $R$ is Cohen-Macaulay and $R_{\mathfrak{p}}$ is Gorenstein for all minimal primes $\mathfrak{p}$. In this case there exists canonical ideal $I \cong K_R$ (see http://arxiv.org/abs/1106.1301, 2.7) and $\dim R/I = \dim R-1$. If $\dim R = 0$, there is nothing to do. If $\dim R>0$ there is a regular element $a\in I$. So you have an inclusion $0 \to R \to I$, $x \mapsto ax$. Hence we have $\dim K_R/R \cong \dim I/(a)$ is either $0$ if $R$ is Gorenstein and $I=(a)$ or $d-1$ otherwise.
Note: If I am not wrong, the condition $R$ is Cohen-Macaulay can be replaced by $S_2$ condition (I think Goto showed me a proof but I can't remember).
This is in general false. Take $S$ to be a regular local ring and $R$ an Artin quotient which is not Gorenstein (of course $R$ is Cohen-Macaulay). Then the length of $K_R$ is the same as $R$, so if your $\phi$ was injective, it would be an isomorphism, contradicting the assumption that $R$ is not Gorenstein. For a specific example, take $S=k[[x,y]]$ and $R=S/(x^2,xy,y^2)$.