I'd argue that if the intention is entirely to rehabilitate (and incapacitate if necessary) then a prison sentence would only incidentally be a punishment.
Giving someone a life sentence means you (or the justice system at large) are either unwilling or unable to rehabilitate that person.