Move AlgebraicNumber class to the core

fixes #8066