Dear all,
I've been working on this, following Simon King's worksheet (at
http://flask.sagenb.org/home/pub/82) closely, but am stuck. The files
I am using (witt.py and witt_element.py), based on Roe and Dupuy
previous work, are attached for your reference.
I cannot create an element as below:
t510[~/comp/witt-sage]$ sageb
----------------------------------------------------------------------
| Sage Version 5.0.beta4, Release Date: 2012-02-14 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
**********************************************************************
* *
* Warning: this is a prerelease version, and it may be unstable. *
* *
**********************************************************************
Loading Sage library. Current Mercurial branch is:
witt
sage:
R=RingOfWittVectors(GF(5),3)
sage:
F=GF(5)
sage:
w=[F(1),F(2),F(0)]
sage: v=R(w)
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
/home/finotti/comp/witt-sage/<ipython console> in <module>()
/usr/local/sage-5.0.beta4/local/lib/python2.7/site-packages/sage/structure/parent.so
in sage.structure.parent.Parent.__call__
(sage/structure/parent.c:7706)()
NotImplementedError:
I cannot interpret the error...
I can create the element directly:
sage: v=WittVector(w,F)
sage: v
_12 = [1, 2, 0]
sage: v.length()
_13 = 3
One thing that does not seem to work (and I don't know why) when
comparing with the reference above, is the following:
sage: R.element_class
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/finotti/comp/witt-sage/<ipython console> in <module>()
/usr/local/sage-5.0.beta4/local/lib/python2.7/site-packages/sage/structure/parent.so
in sage.structure.parent.Parent.__getattr__
(sage/structure/parent.c:6677)()
/usr/local/sage-5.0.beta4/local/lib/python2.7/site-packages/sage/structure/parent.so
in sage.structure.parent.getattr_from_other_class
(sage/structure/parent.c:3228)()
AttributeError: 'RingOfWittVectors_with_category' object has no attribute
'element_class'
On the other hand, the following works:
sage: type(R)
_14 = <class 'sage.rings.padics.witt.RingOfWittVectors_with_category'>
sage:
isinstance(R,RingOfWittVectors)
_15 = True
sage: isinstance(R,CommutativeRings().parent_class)
_17 = True
Any pointers would be greatly appreciated.
Best to all,
Luis
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org
r"""
Rings of Witt Vectors
AUTHORS:
- Taylor Dupuy and David Roe (2011-06-11):
"""
#################################################################################
# Copyright (C) 2011 William Stein <[email protected]>
# Taylor Dupuy <[email protected]>
# David Roe <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# http://www.gnu.org/licenses/
#*****************************************************************************
from sage.structure.parent import Parent
from sage.rings.ring import CommutativeRing
#from sage.categories import Rings
from sage.misc.latex import latex
from sage.structure.element import Element
from sage.structure.element import CommutativeRingElement
#from sage.structure.factory import UniqueFactory
from sage.categories.commutative_rings import CommutativeRings
class RingOfWittVectors(CommutativeRing):
def __init__(self, parent, n, p=None, category=None):
# R = entry ring
# n = length
# p = prime in the contruction
CommutativeRing.__init__(self, parent, category=category or CommutativeRings())
self.entry_ring=parent
self.length=n
# if no p is given, use the characteristic
q = parent.characteristic()
if (p != None):
self.prime=p
elif (q != 0):
# p not given, use char. of entry_ring
self.prime=q
else:
# R has char 0 and p not given
raise TypeError, "%s has characteristic 0 and no prime was given."%R
def _repr_(self):
return "Ring of Witt vectors of length %s over %s with prime %s"%(self.length, self.entry_ring, self.prime)
def base_ring(self):
return self.entry_ring
def characteristic(self):
return self.prime**(self.length)
# class Big_Witt_Ring(CommutativeRing):
# def __init__(self, R):
# self.R = R
# Parent.__init__(self) #Parent.__init__(self, category=CommutativeRings())
# def _element_constructor_(self, x):
# return Big_Witt_Vector(self, x)
# def _coerce_map_from_(self, S):
# if isinstance(S, Big_Witt_Ring):
# if self.R.has_coerce_map_from(S.R):
# return True
# #from sage.rings.integer_ring import ZZ
# #if S is ZZ:
# # return True
# def _convert_map_from_(self, S):
# if isinstance(S, Big_Witt_Ring):
# if self.R.has_convert_map_from(S.R):
# return True
# def _repr_(self):
# return "Ring of big Witt vectors over %s"%(self.R)
# def _latex_(self):
# return "W(%s)"%(latex(self.R))
# # def construction(self):
# # from sage.categories.pushout import BigWittVectorFunctor
# # return (BigWittVectorFunctor(), self.R)
# def __hash__(self):
# return hash(self.R)
# def __cmp__(self, other):
# c = cmp(type(self), type(other))
# if c: return c
# return cmp(self.R, other.R)
r"""
Rings of Witt Vectors
AUTHORS:
- Taylor Dupuy (2011-06-09):
- David Roe (2011-06-09)
"""
#################################################################################
# Copyright (C) 2011 William Stein <[email protected]>
# 2011 Taylor Dupuy <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# http://www.gnu.org/licenses/
#*****************************************************************************
from sage.structure.parent import Parent
from sage.rings.ring import CommutativeRing
# #from sage.categories.all import Rings #FIXME: implement the category theory calls correctly.
from sage.misc.latex import latex
from sage.structure.element import Element
from sage.structure.element import CommutativeRingElement
# from sage.structure.factory import UniqueFactory
from sage.rings.padics.witt import RingOfWittVectors
def is_witt_vector(x):
return isinstance(x,RingOfWittVectors)
class WittVector(CommutativeRingElement):
def __init__(self, data, parent, coerce=True):
# if parent == None:
# # parent not given, guess from first entry
# parent=vector[0].parent()
# # test if other entries are in same parent
# i=1
# while (i < len(vector)) and (vector[i].parent() == parent):
# i+=1
# if i != len(vector):
# raise TypeError, "Entries of %s must be in same parent, or parent must be specified."%vector
CommutativeRingElement.__init__(self, parent)
# define parent
self._base_ring=parent
if isinstance(data, RingOfWittVectors):
data = data._list
if isinstance(data, (list, tuple)):
if coerce:
self._list = [parent(a) for a in data]
else:
self._list = [a for a in data]
# return
#if not isinstance(data, Element):
# data = ZZ(data)
# need to finish this....
# Value Error?
def modp(self):
# projection onto entry ring
return self._list[0]
def length(self):
# length
return len(self._list)
def _repr_(self):
return "%s" %self._list
def __cmp__(self,other):
return cmp(self._list, other._list)
def _add_(self,other):
# dummy example!
l=min(self.length(),other.length())
if other.length()>l:
C=self.__class__
return C([ self._list[i] + other._list[i] for i in range(self.length) ], self._base_ring)
else:
C=other.__class__
return C([ self._list[i] + other._list[i] for i in range(other.length()) ], other._base_ring)
class RingOfWittVectors(RingOfWittVectors):
# def _call_(self,data,parent,coerce=True):
# return WittVector(data,parent,coerce)
Element=WittVector
# class Big_Witt_Vector(Element):
# def __init__(self, parent, data, coerce=True):
# Element.__init__(self, parent)
# if isinstance(data, Big_Witt_Vector):
# data = data._list
# if isinstance(data, (list, tuple)):
# if coerce:
# self._list = [parent.R(a) for a in data]
# else:
# self._list = [a for a in data]
# return
# if not isinstance(data, Element):
# data = ZZ(data)
# # need to finish this....
# # Value Error?
# def _repr_(self):
# return "%s" %self._list
# def _add_(self, right):
# v = self._list
# w = right._list
# N = max(len(v),len(w))
# s = []
# for n in range(1,N):
# snew = ( -witt(n,s) + witt(n,v) + witt(n,w))/n
# s.append(snew)
# return Big_Witt_Vector(s)
# def _mult_(self, right):
# v = self._list
# w = right._list
# N = max(len(v),len(w))
# s = []
# for n in range(1,N):
# snew = ( -witt(n,s) + witt(n,v) * witt(n,w))/n
# s.append(snew)
# return Big_Witt_Vector(s)
# def _neg_(self):
# v = self._list
# N = len(v)
# zeros = Big_Witt_Vector([0 for j in range(N)])
# s=self._sub_(zeros)
# return Big_Witt_Vector(s)
# def _sub_(self, right):
# v = self._list
# w = right._list
# N = max(len(v),len(w))
# s = []
# for n in range(1,N):
# snew = ( -witt(n,s) + witt(n,w) - witt(n,v))/n
# s.append(snew)
# return Big_Witt_Vector(s)
# ################ FUNCTIONS USED TO DEFINE ADDITION AND SUBTRACTION ##################
# def witt(n,x):
# """
# The witt polynomials as a function
# INPUT: a list of numbers
# OUTPUT: the nth witt polynomial evaluated at those numbers
# Examples ::
# """
# #TODO: return errors for bad inputs
# if n==0:
# return x[0]
# if n>0:
# divs = divisors(n)
# dict = {}
# wn = 0
# for d in divs:
# wn = wn + d * (x[d]^(n/d))
# return wn
# #The functions wittsum, wittprod etc were originally used for computing sums of witt vectors,
# #they have been replaced in the add functions
# def wittsum(n,v,w):
# """
# Examples ::
# sage: var('v0 v1 v2 v3 w0 w1 w2 w3')
# sage: v = [0, v1, v2, v3]
# sage: w = [0, w1, w2, w3]
# sage: sum3 = v3 + w3 + ( v1^3 + w1^3 - (v1+w1)^3 )/3
# sage: expand(wittsum(3,v,w)- sum3)
# 0
# """
# if n == 0:
# return 0
# if n == 1:
# return v[1] + w[1]
# if n > 0:
# #var('sumpolyn')
# #s = [wittsum(j,v,w) for j in range(n)] + [sumpolyn]
# #ans = solve( witt(n,s) == witt(n,v) + witt(n,w), sumpolyn, solution_dict=True)[0][sumpolyn]
# s = [wittsum(j,v,w) for j in range(n)] + [0]
# return (-witt(n,s) + (witt(n,v) + witt(n,w)))/n
# def wittsub(n,v,w):
# """
# Examples ::
# """
# if n == 0:
# return 0
# if n == 1:
# return v[1] - w[1]
# if n > 0:
# s = [wittsub(j,v,w) for j in range(n)] + [0]
# return (-witt(n,s) + (witt(n,v) - witt(n,w)))/n
# def wittprod(n,v,w):
# """
# Examples ::
# sage: var('v0 v1 v2 v3 w0 w1 w2 w3')
# sage: v = [0, v1, v2, v3]
# sage: w = [0, w1, w2, w3]
# sage: prod3 = v3*w1^3 + v1^3*w3+ 3*w3*v3
# sage: expand(wittprod(3,v,w)- prod3)
# 0
# """
# if n == 0:
# return 0
# if n == 1:
# return v[1] * w[1]
# if n > 0:
# pr = [wittprod(j,v,w) for j in range(n)] + [0]
# return (-witt(n,pr) + (witt(n,v)*witt(n,w)))/n