Formalization of the "Twin paradox" for non-uniformly accelerated motions