Post to Mathematica SE.  How to get FullSimplify to act on scalars (-1, 0, 1, ...)  that are multiplied by potentially non-commutative symbols (operators, block matrices, ...)?

ClearAll[mdot,x,y,a,b,c,d,f,g]


(*Unprotect[NonCommutativeMultiply];
NonCommutativeMultiply[H__,c_,T__]:=c NonCommutativeMultiply[H,T]/;NumericQ[c]
NonCommutativeMultiply[H___,Times[c_,factors__],T___]:=c NonCommutativeMultiply[H,Times[factors],T]/;NumericQ[c]
NonCommutativeMultiply[H___,0,T___]:=0;
NonCommutativeMultiply[H___,1,T___]:=NonCommutativeMultiply[H,T]
NonCommutativeMultiply[H___,Plus[a_,addends__],T___]:=NonCommutativeMultiply[H,a,T]+NonCommutativeMultiply[H,Plus[addends],T]*)

ClearAll[ExpandNCM];

ExpandNCM[expr_]:=expr/.{(h:NonCommutativeMultiply)[a___,b_Plus,c___]:>Distribute[h[a,b,c],Plus,h,Plus,ExpandNCM@*h],(h:NonCommutativeMultiply)[a___,b_Times,c___]:>Most[b] ExpandNCM[h[a,Last[b],c]]};

mdot[a_, b_] := Inner[NonCommutativeMultiply,a,b,Plus]
x := (1/Sqrt[2]){{a,-b},{c,d}};
y := (1/Sqrt[2]){{1, f}, {-g, 0}};
(mdot[x, y] // ExpandNCM) // MatrixForm