-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathAbstractTypes.jl
More file actions
191 lines (114 loc) · 5.83 KB
/
Copy pathAbstractTypes.jl
File metadata and controls
191 lines (114 loc) · 5.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
###############################################################################
#
# Abstract types
#
###############################################################################
# broad mathematical domains
# these contain the type classes of parent objects
abstract type Set end
abstract type Group <: Set end # with * as operation
abstract type AdditiveGroup <: Set end # with + as operation
abstract type AbstractPermutationGroup <: Group end
abstract type NCRing <: Set end
abstract type Ring <: NCRing end
abstract type Field <: Ring end
# elements of mathematical domains
abstract type SetElem end
abstract type GroupElem <: SetElem end # with * as operation
abstract type AdditiveGroupElem <: SetElem end # with + as operation
abstract type AbstractPerm <: GroupElem end
abstract type NCRingElem <: SetElem end
abstract type RingElem <: NCRingElem end
abstract type FieldElem <: RingElem end
# unions of AbstractAlgebra abstract types and Julia types
const JuliaRingElement = Union{Integer, Rational, AbstractFloat}
const JuliaFieldElement = Union{Rational, AbstractFloat}
const JuliaExactRingElement = Union{Integer, Rational}
const RingElement = Union{RingElem, JuliaRingElement}
const NCRingElement = Union{NCRingElem, JuliaRingElement}
const FieldElement = Union{FieldElem, JuliaFieldElement}
# parameterized domains
abstract type Module{T<:NCRingElement} <: AdditiveGroup end
abstract type FPModule{T} <: Module{T} end
abstract type Ideal{T} <: Set end
abstract type IdealSet{T} <: Set end
# elements of parameterised domains
abstract type ModuleElem{T<:NCRingElement} <: AdditiveGroupElem end
abstract type FPModuleElem{T} <: ModuleElem{T} end
abstract type IdealElem{T} <: SetElem end
abstract type Map{D, C, S, T} <: SetElem end
abstract type SetMap end
abstract type FunctionalMap <: SetMap end
abstract type IdentityMap <: SetMap end
abstract type FPModuleHomomorphism <: FunctionalMap end
# rings, fields etc, parameterised by an element type
# these are the type classes of different kinds of
# mathematical rings/fields/etc, which have a base ring,
# and for which a generic implementation is possible
# over that base ring
abstract type PolyRing{T<:RingElement} <: Ring end
abstract type NCPolyRing{T<:NCRingElement} <: NCRing end
abstract type MPolyRing{T<:RingElement} <: Ring end
abstract type UniversalPolyRing{T<:RingElement} <: Ring end
abstract type LaurentPolyRing{T<:RingElement} <: Ring end
abstract type LaurentMPolyRing{T<:RingElement} <: Ring end
abstract type SeriesRing{T<:RingElement} <: Ring end
abstract type MSeriesRing{T<:RingElement} <: Ring end
abstract type ResidueRing{T<:RingElement} <: Ring end
abstract type ResidueField{T<:RingElement} <: Field end
abstract type FracField{T<:RingElement} <: Field end
abstract type MatRing{T<:NCRingElement} <: NCRing end
abstract type FreeAssociativeAlgebra{T<:RingElement} <: NCRing end
# Abstract types for number fields, parmeterised by the element type of
# the base field.
abstract type NumField{T<:RingElement} <: Field end
# A type for number fields, which are represented using a primitive element.
# (simple number fields)
abstract type SimpleNumField{T} <: NumField{T} end
# mathematical objects parameterised by an element type
# these are the type classes of mathematical objects
# that have some kind of base ring, and a generic
# implementation is meaningful over that base ring
abstract type PolyRingElem{T<:RingElement} <: RingElem end
abstract type NCPolyRingElem{T<:NCRingElement} <: NCRingElem end
abstract type MPolyRingElem{T<:RingElement} <: RingElem end
abstract type UniversalPolyRingElem{T<:RingElement} <: RingElem end
abstract type LaurentPolyRingElem{T<:RingElement} <: RingElem end
abstract type LaurentMPolyRingElem{T<:RingElement} <: RingElem end
abstract type ResElem{T<:RingElement} <: RingElem end
abstract type ResFieldElem{T<:RingElement} <: FieldElem end
abstract type FracElem{T<:RingElement} <: FieldElem end
abstract type SeriesElem{T<:RingElement} <: RingElem end
abstract type MSeriesElem{T<:RingElement} <: RingElem end
abstract type RelPowerSeriesRingElem{T} <: SeriesElem{T} end
abstract type AbsPowerSeriesRingElem{T} <: SeriesElem{T} end
abstract type AbsMSeriesElem{T} <: MSeriesElem{T} end
abstract type MatElem{T} <: ModuleElem{T} end
abstract type MatRingElem{T<:NCRingElement} <: NCRingElem end
abstract type FreeAssociativeAlgebraElem{T<:RingElement} <: NCRingElem end
abstract type NumFieldElem{T<:RingElement} <: FieldElem end
abstract type SimpleNumFieldElem{T} <: NumFieldElem{T} end
# additional abstract types for parents, added ad hoc to form
# collections of types as needed by applications
abstract type FinField <: Field end # for FqPolyRepFieldElem, fqPolyRepFieldElem, etc
# additional abstract types for elements, added ad hoc to form
# collections of types as needed by applications
abstract type FinFieldElem <: FieldElem end # for FqPolyRepFieldElem, fqPolyRepFieldElem, etc
################################################################################
#
# Promotion system
#
# The promote_rule functions are not extending Base.promote_rule. The
# AbstractAlgebra promotion system is orthogonal to the built-in julia promotion
# system. The julia system assumes that whenever you have a method signature of
# the form Base.promote_rule(::Type{T}, ::Type{S}) = R, then there is also a
# corresponding Base.convert(::Type{R}, ::T) and similar for S. Since we
# cannot use the julia convert system (we need an instance of the type and not
# the type), we cannot use the julia promotion system.
#
# The AbstractAlgebra promotion system is used to define catch all functions
# for arithmetic between arbitrary ring elements.
#
################################################################################
promote_rule(T, U) = Union{}
promote_rule(a::Type{S}, b::Type{T}) where {S <: Real, T <: Real} = Base.promote_rule(a, b)