It's not impossible, but will take a bit of figuring out, for everybody.
It might be that you buy the house outright, give your dad half the value and give your mum a right of residence, and treat the difference as an inheritance / gift. But your mum needs to be treated fairly and have security. Because you're raising a mortgage, it'd only be possible to put the legal right of residence in place after the mortgage is in place.
Your parents aren't the first in their circumstances, so while uncommon, it's not unique. Hopefully someone with practical experience will be able to share. Unfortunately the only case I'm aware of didn't involve a mortgage on the home (there wasn't a huge amount involved, and the mum and 2 children raised personal loans / mortgaged other property to buy out the dad)