Looked over it, i am interested now, let's see if I have a flaw; note: it's late here where I am so mistakes can happen in calculations below, which i have done on the fly:
Do you consider, in your calculation, that in the case of a mortgage, I still have 500k invested in the market, where if I payed cash it would be 300k left?
The difference in generated returns, (Ignoring withdrawals, only a ballpark example here); over 10y@5% is 190k vs 315k. That's massive. Also, add to that, in the mortgage case I already payed of around 50% of the mortgage.
After 10y I would have this situation:
Hypothetical Summary: mortgage wins by roughly having 175k more in the bank after everything is paid after 10y.
(Yes, I am aware that i have withdrawals from the PF, but, as you already stated, those are effectively %wise the same in both cases and I ignored em for this example as well as made a simple loan calculation with rough estimates).