抽象代数的Sage快速入门

这个 Sage 快速入门教程是为MAA准备工作坊“Sage:对本科生使用开源数学软件”开发的(由NSF提供资金,到期日:0817071)。它是根据Creative Commons Attribution -ShareLiked 3.0许可证授权的 (CC BY-SA

由于计算机是离散的和有限的,任何具有离散的、有限的生成器集的东西都是自然实现和探索的。

群论

许多公共群是预先定义的,通常是置换群:也就是说,显式地描述为对称群的子群。

  • 每一个15阶或更低阶的组都可以作为置换组使用。

  • 不过,有时它们也有特殊的名称。

sage: G = QuaternionGroup()
sage: G
Quaternion group of order 8 as a permutation group
sage: H = AlternatingGroup(5)
sage: H
Alternating group of order 5!/2 as a permutation group
sage: H.is_simple()
True
sage: D = DihedralGroup(8)
sage: D
Dihedral group of order 16 as a permutation group

我们可以访问许多有关组的信息,例如:

  • 直到共轭的子群的列表,

  • 或者稳定剂,

  • 或者下面展示的其他东西。

sage: for K in D.conjugacy_classes_subgroups():
....:     print(K)
Subgroup generated by [()] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(2,8)(3,7)(4,6)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,2)(3,8)(4,7)(5,6)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(2,8)(3,7)(4,6), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,2)(3,8)(4,7)(5,6), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(2,8)(3,7)(4,6), (1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,2,3,4,5,6,7,8), (1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,2)(3,8)(4,7)(5,6), (1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(2,8)(3,7)(4,6), (1,2,3,4,5,6,7,8), (1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)

在上一个单元格中,我们再次对一组对象执行for循环,而不仅仅是一组数字。这是非常强大的。

sage: D.stabilizer(3)
Subgroup generated by [(1,5)(2,4)(6,8)] of (Dihedral group of order 16 as a permutation group)
sage: for K in D.normal_subgroups():
....:     print(K)
Subgroup generated by [(1,2,3,4,5,6,7,8), (1,8)(2,7)(3,6)(4,5)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,2,3,4,5,6,7,8), (1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8), (1,8)(2,7)(3,6)(4,5)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(2,8)(3,7)(4,6), (1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,3,5,7)(2,4,6,8), (1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [(1,5)(2,6)(3,7)(4,8)] of (Dihedral group of order 16 as a permutation group)
Subgroup generated by [()] of (Dihedral group of order 16 as a permutation group)

如果我们知道生成元是一个置换群,我们就可以访问特定的子群。

sage: L = D.subgroup(["(1,3,5,7)(2,4,6,8)"])
sage: L.is_normal(D)
True
sage: Q=D.quotient(L)
sage: Q
Permutation Group with generators [(1,2)(3,4), (1,3)(2,4)]
sage: Q.is_isomorphic(KleinFourGroup())
True

还有一些矩阵群,既有有限的也有无限的。

sage: S = SL(2, GF(3))
sage: S
Special Linear Group of degree 2 over Finite Field of size 3

我们可以打印出来 all 这群人的元素。

sage: for a in S:
....:     print(a)
[1 0]
[0 1]
...
[2 2]
[2 1]
sage: SS = SL(2, ZZ)

当然,你要小心你要做的事!

sage: SS.list()
Traceback (most recent call last):
...
NotImplementedError: group must be finite
sage: for a in SS.gens():
....:     print(a)
[ 0  1]
[-1  0]
...

Sage有许多预定义的环可供实验。下面是一个如何访问 \(\ZZ/12\ZZ\) 例如。

sage: twelve = Integers(12)
sage: twelve
Ring of integers modulo 12
sage: twelve.is_field()
False
sage: twelve.is_integral_domain()
False

四元数和推广

我们可以定义广义四元数代数,其中 \(i^2=a\)\(j^2=b\)\(k=i\cdot j\) ,全部 \(\QQ\) ::

sage: quat = QuaternionAlgebra(-1, -1)
sage: quat
Quaternion Algebra (-1, -1) with base ring Rational Field
sage: quat.is_field()
False
sage: quat.is_commutative()
False
sage: quat.is_division_algebra()
True
sage: quat2 = QuaternionAlgebra(5, -7)
sage: quat2.is_division_algebra()
True
sage: quat2.is_field()
False

多项式环

多项式算法是Sage中一个非常重要的工具。

第一个细胞带我们回到符号世界。这是 不是一回事 作为多项式!

sage: reset('x') # This returns x to being a variable
sage: (x^4 + 2*x).parent()
Symbolic Ring

现在我们要转身了 \(x\) 生成多项式环。语法有点不寻常,但你会经常看到它。

sage: R.<x> = QQ[]
sage: R
Univariate Polynomial Ring in x over Rational Field
sage: R.random_element() # random
-5/2*x^2 - 1/4*x - 1
sage: R.is_integral_domain()
True
sage: (x^4 + 2*x).parent()
Univariate Polynomial Ring in x over Rational Field
sage: (x^2+x+1).is_irreducible()
True
sage: F = GF(5)
sage: P.<y> = F[]
sage: P.random_element() # random
2*y
sage: I = P.ideal(y^3+2*y)
sage: I
Principal ideal (y^3 + 2*y) of Univariate Polynomial Ring in y over Finite Field of size 5
sage: Q = P.quotient(I)
sage: Q
Univariate Quotient Polynomial Ring in ybar over Finite Field of size 5 with modulus y^3 + 2*y

领域

Sage对有限域和有理数的扩张有极好的支持。

有限域

sage: F.<a> = GF(3^4)
sage: F
Finite Field in a of size 3^4

默认情况下,生成器满足Conway多项式,或者可以指定多项式。

sage: F.polynomial()
a^4 + 2*a^3 + 2
sage: F.list()
[0, a, a^2, a^3, a^3 + 1, a^3 + a + 1, a^3 + a^2 + a + 1, 2*a^3 + a^2 + a + 1, a^2 + a + 2, a^3 + a^2 + 2*a, 2*a^3 + 2*a^2 + 1, a^3 + a + 2, a^3 + a^2 + 2*a + 1, 2*a^3 + 2*a^2 + a + 1, a^3 + a^2 + a + 2, 2*a^3 + a^2 + 2*a + 1, 2*a^2 + a + 2, 2*a^3 + a^2 + 2*a, 2*a^2 + 2, 2*a^3 + 2*a, 2*a^3 + 2*a^2 + 2, a^3 + 2*a + 2, a^3 + 2*a^2 + 2*a + 1, 2*a^2 + a + 1, 2*a^3 + a^2 + a, a^2 + 2, a^3 + 2*a, a^3 + 2*a^2 + 1, a + 1, a^2 + a, a^3 + a^2, 2*a^3 + 1, 2*a^3 + a + 2, 2*a^3 + a^2 + 2*a + 2, 2*a^2 + 2*a + 2, 2*a^3 + 2*a^2 + 2*a, a^3 + 2*a^2 + 2, 2*a + 1, 2*a^2 + a, 2*a^3 + a^2, 2, 2*a, 2*a^2, 2*a^3, 2*a^3 + 2, 2*a^3 + 2*a + 2, 2*a^3 + 2*a^2 + 2*a + 2, a^3 + 2*a^2 + 2*a + 2, 2*a^2 + 2*a + 1, 2*a^3 + 2*a^2 + a, a^3 + a^2 + 2, 2*a^3 + 2*a + 1, 2*a^3 + 2*a^2 + a + 2, a^3 + a^2 + 2*a + 2, 2*a^3 + 2*a^2 + 2*a + 1, a^3 + 2*a^2 + a + 2, a^2 + 2*a + 1, a^3 + 2*a^2 + a, a^2 + 1, a^3 + a, a^3 + a^2 + 1, 2*a^3 + a + 1, 2*a^3 + a^2 + a + 2, a^2 + 2*a + 2, a^3 + 2*a^2 + 2*a, 2*a^2 + 1, 2*a^3 + a, 2*a^3 + a^2 + 2, 2*a + 2, 2*a^2 + 2*a, 2*a^3 + 2*a^2, a^3 + 2, a^3 + 2*a + 1, a^3 + 2*a^2 + a + 1, a^2 + a + 1, a^3 + a^2 + a, 2*a^3 + a^2 + 1, a + 2, a^2 + 2*a, a^3 + 2*a^2, 1]
sage: (a^3 + 2*a^2 + 2)*(2*a^3 + 2*a + 1)
2*a^3 + a^2 + a + 1

\(F\) 应该是多项式的分裂域 \(x^{{81}}-x\) ,所以很好的情况是我们没有从下面的单元中得到输出,这个单元组合了一个循环和一个条件语句。

sage: for a in F:
....:     if not (a^81 - a == 0):
....:         print("Oops!")

字段扩展名,数字字段

你在大学代数课堂上需要的大部分东西都已经在Sage里了。

sage: N = QQ[sqrt(2)]
sage: N
Number Field in sqrt2 with defining polynomial x^2 - 2 with sqrt2 = 1.414213562373095?
sage: var('z')
z
sage: M.<a>=NumberField(z^2-2)
sage: M
Number Field in a with defining polynomial z^2 - 2
sage: M.degree()
2
sage: M.is_galois()
True
sage: M.is_isomorphic(N)
True