Skip to content

Commit

Permalink
Trac #14823: Categories of (C)DVR and (C)DVF
Browse files Browse the repository at this point in the history
Here is a small patch defining categories of (complete) discrete
valuation rings and (complete) discrete valuation fields.

URL: http://trac.sagemath.org/14823
Reported by: caruso
Ticket author(s): Xavier Caruso
Reviewer(s): David Roe
  • Loading branch information
Release Manager authored and vbraun committed Jan 9, 2014
2 parents 4eafc31 + b368c80 commit 9dd1e6b
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/sage/categories/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
from principal_ideal_domains import PrincipalIdealDomains
from euclidean_domains import EuclideanDomains
from unique_factorization_domains import UniqueFactorizationDomains
from complete_discrete_valuation import CompleteDiscreteValuationRings

from fields import Fields
from quotient_fields import QuotientFields
from finite_fields import FiniteFields
from discrete_valuation import DiscreteValuationRings, DiscreteValuationFields
from complete_discrete_valuation import CompleteDiscreteValuationRings, CompleteDiscreteValuationFields
129 changes: 129 additions & 0 deletions src/sage/categories/complete_discrete_valuation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
r"""
This module implements the two following categories :
- Complete Discrete Valuation Rings (CDVR)
- Complete Discrete Valuation Fields (CDVF)
"""
#**************************************************************************
# Copyright (C) 2013 Xavier Caruso <xavier.caruso@normalesup.org>
#
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
#**************************************************************************


from sage.misc.abstract_method import abstract_method

from sage.categories.category_singleton import Category_singleton
from discrete_valuation import DiscreteValuationRings, DiscreteValuationFields
#from sage.misc.cachefunc import cached_method

class CompleteDiscreteValuationRings(Category_singleton):
"""
The category of complete discrete valuation rings
EXAMPLES::
sage: Zp(7) in CompleteDiscreteValuationRings()
True
sage: QQ in CompleteDiscreteValuationRings()
False
sage: QQ[['u']] in CompleteDiscreteValuationRings()
True
sage: Qp(7) in CompleteDiscreteValuationRings()
False
sage: TestSuite(CompleteDiscreteValuationRings()).run()
"""
def super_categories(self):
"""
EXAMPLES::
sage: CompleteDiscreteValuationRings().super_categories()
[Category of discrete valuation rings]
"""
return [DiscreteValuationRings()]

class ElementMethods:
@abstract_method
def precision_absolute(self):
"""
Return the absolute precision of this element.
EXAMPLES:
sage: R = Zp(7)
sage: x = R(7); x
7 + O(7^21)
sage: x.precision_absolute()
21
"""

@abstract_method
def precision_relative(self):
"""
Return the relative precision of this element.
EXAMPLES:
sage: R = Zp(7)
sage: x = R(7); x
7 + O(7^21)
sage: x.precision_relative()
20
"""

class CompleteDiscreteValuationFields(Category_singleton):
"""
The category of complete discrete valuation fields
EXAMPLES::
sage: Zp(7) in CompleteDiscreteValuationFields()
False
sage: QQ in CompleteDiscreteValuationFields()
False
sage: LaurentSeriesRing(QQ,'u') in CompleteDiscreteValuationFields()
True
sage: Qp(7) in CompleteDiscreteValuationFields()
True
sage: TestSuite(CompleteDiscreteValuationFields()).run()
"""

def super_categories(self):
"""
EXAMPLES::
sage: CompleteDiscreteValuationFields().super_categories()
[Category of discrete valuation fields]
"""
return [DiscreteValuationFields()]

class ElementMethods:
@abstract_method
def precision_absolute(self):
"""
Return the absolute precision of this element.
EXAMPLES:
sage: K = Qp(7)
sage: x = K(7); x
7 + O(7^21)
sage: x.precision_absolute()
21
"""

@abstract_method
def precision_relative(self):
"""
Return the relative precision of this element.
EXAMPLES:
sage: K = Qp(7)
sage: x = K(7); x
7 + O(7^21)
sage: x.precision_relative()
20
"""
189 changes: 189 additions & 0 deletions src/sage/categories/discrete_valuation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
r"""
This module implements the two following categories :
- Discrete Valuation Rings (DVR)
- Discrete Valuation Fields (DVF)
"""
#**************************************************************************
# Copyright (C) 2013 Xavier Caruso <xavier.caruso@normalesup.org>
#
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
#**************************************************************************


from sage.misc.abstract_method import abstract_method

from sage.categories.category import Category
from sage.categories.category_singleton import Category_singleton
from sage.categories.principal_ideal_domains import PrincipalIdealDomains
from sage.categories.fields import Fields
#from sage.misc.cachefunc import cached_method

class DiscreteValuationRings(Category_singleton):
"""
The category of discrete valuation rings
EXAMPLES::
sage: GF(7)[['x']] in DiscreteValuationRings()
True
sage: TestSuite(DiscreteValuationRings()).run()
"""
def super_categories(self):
"""
EXAMPLES::
sage: DiscreteValuationRings().super_categories()
[Category of principal ideal domains]
"""
return [PrincipalIdealDomains()]

class ParentMethods:
@abstract_method
def uniformizer(self):
"""
Return a uniformizer of this ring.
EXAMPLES::
sage: Zp(5).uniformizer()
5 + O(5^21)
sage: K.<u> = QQ[[]]
sage: K.uniformizer()
u
"""

@abstract_method
def residue_field(self):
"""
Return the residue field of this ring.
EXAMPLES::
sage: Zp(5).residue_field()
Finite Field of size 5
sage: K.<u> = QQ[[]]
sage: K.residue_field()
Rational Field
"""

class ElementMethods:
@abstract_method
def valuation(self):
"""
Return the valuation of this element.
EXAMPLES::
sage: x = Zp(5)(50)
sage: x.valuation()
2
"""

def is_unit(self):
"""
Return True if self is invertible.
EXAMPLES::
sage: x = Zp(5)(50)
sage: x.is_unit()
False
sage: x = Zp(7)(50)
sage: x.is_unit()
True
"""
return self.valuation() == 0

def gcd(self,other):
"""
Return the greatest common divisor of self and other,
normalized so that it is a power of the distinguished
uniformizer.
"""
from sage.rings.infinity import Infinity
val = min(self.valuation(), other.valuation())
if val is Infinity:
return self.parent()(0)
else:
return self.parent().uniformizer() ** val

def lcm(self,other):
"""
Return the least common multiple of self and other,
normalized so that it is a power of the distinguished
uniformizer.
"""
from sage.rings.infinity import Infinity
val = max(self.valuation(), other.valuation())
if val is Infinity:
return self.parent()(0)
else:
return self.parent().uniformizer() ** val


class DiscreteValuationFields(Category_singleton):
"""
The category of discrete valuation fields
EXAMPLES::
sage: Qp(7) in DiscreteValuationFields()
True
sage: TestSuite(DiscreteValuationFields()).run()
"""

def super_categories(self):
"""
EXAMPLES::
sage: DiscreteValuationFields().super_categories()
[Category of fields]
"""
return [Fields()]

class ParentMethods:
@abstract_method
def uniformizer(self):
"""
Return a uniformizer of this ring.
EXAMPLES::
sage: Qp(5).uniformizer()
5 + O(5^21)
"""

@abstract_method
def residue_field(self):
"""
Return the residue field of the ring of integers of
this discrete valuation field.
EXAMPLES::
sage: Qp(5).residue_field()
Finite Field of size 5
sage: K.<u> = LaurentSeriesRing(QQ)
sage: K.residue_field()
Rational Field
"""

class ElementMethods:
@abstract_method
def valuation(self):
"""
Return the valuation of this element.
EXAMPLES::
sage: x = Qp(5)(50)
sage: x.valuation()
2
"""

0 comments on commit 9dd1e6b

Please sign in to comment.