-
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #14823: Categories of (C)DVR and (C)DVF
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
Showing
8 changed files
with
535 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
""" |
Oops, something went wrong.