r"""1Abstract base class for fields2"""34#*****************************************************************************5# Copyright (C) 2005 William Stein <[email protected]>6#7# Distributed under the terms of the GNU General Public License (GPL)8#9# This code is distributed in the hope that it will be useful,10# but WITHOUT ANY WARRANTY; without even the implied warranty of11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12# General Public License for more details.13#14# The full text of the GPL is available at:15#16# http://www.gnu.org/licenses/17#*****************************************************************************1819from sage.rings.ring import Field2021def is_PrimeField(R):22r"""23Determine if ``R`` is a field that is equal to its own prime subfield.2425INPUT:2627- ``R`` -- a ring or field2829OUTPUT:3031- ``True`` if R is `\QQ` or a finite field `\GF{p}` for `p` prime,32``False`` otherwise.3334EXAMPLES::3536sage: sage.rings.field.is_PrimeField(QQ)37True38sage: sage.rings.field.is_PrimeField(GF(7))39True40sage: sage.rings.field.is_PrimeField(GF(7^2,'t'))41False42"""43from finite_rings.constructor import is_FiniteField44from rational_field import is_RationalField4546if is_RationalField(R):47return True48if is_FiniteField(R):49return R.degree() == 150return False51525354