Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Environment to perform calculations of equivariant vector bundles on homogeneous varieties

1842 views
License: GPL3
ubuntu2204
1
from typing import Iterator
2
3
class Structure ( object ) :
4
5
def __eq__ ( self , other:"Structure" ) -> bool :
6
"""Tests if two objects of the same class and if they coincide."""
7
if isinstance( other , self.__class__ ) :
8
if self.__repr__() == other.__repr__() : return True
9
else : return False
10
else : return False
11
12
13
def __getitem__ ( self , Input:int or slice ) -> "Structure" or list[ "Structure" ] :
14
"""Returns a single datum or slices of data."""
15
if Input in ZZ :
16
Index = Input
17
if Index <= -len(self)-1 : return None
18
elif Index in [ -len(self) .. -1 ] : Index += len(self)
19
elif Index in [ 0 .. len(self) ] : pass
20
else : return None
21
Single_Part = self.Constituent_Parts()[Index]
22
return Single_Part
23
24
elif isinstance( Input , slice ) :
25
Slice = Input
26
New_Constituent_Parts = self.Constituent_Parts()[Slice]
27
if len(New_Constituent_Parts) == 0 :
28
return None
29
elif len(New_Constituent_Parts) == 1 :
30
Single_Part = New_Constituent_Parts[0]
31
return Single_Part
32
else :
33
return self.__class__( New_Constituent_Parts )
34
35
else :
36
raise ValueError('The variable ``Input`` is inappropriate.')
37
38
39
def __ne__ ( self , other:"Structure" ) -> bool :
40
"""Tests if two objects do not coincide."""
41
return not self == other
42
43
44
def Is_Irreducible ( self ) -> bool :
45
"""Tests if ``self`` is irreducible/ simple."""
46
return len(self) == 1
47
48
49
def Is_Not_Trivial ( self ) -> bool :
50
"""Tests if ``self`` is not trivial."""
51
return not self.Is_Trivial()
52
53
54
def Is_Reducible ( self ) -> bool :
55
"""Tests if ``self`` is reducible/ non-simple, i.e. it is trivial/ zero or consists of multiple summands/ components."""
56
return not self.Is_Irreducible()
57
58
59
# Synonyms for the method ``Is_Irreducible``
60
def Is_Simple ( self ) -> bool :
61
"""Tests if ``self`` is irreducible/ simple, i.e. consists only of a single summand/ component."""
62
return self.Is_Irreducible()
63
64
65
def Is_Trivial ( self ) -> bool :
66
"""Tests if ``self`` has no components."""
67
return len(self) == 0
68
69
70
71
class Irreducible_Structure ( Structure ) :
72
73
def __iter__ ( self ) -> Iterator[ "Irreducible_Structure" ] :
74
"""Returns an iterator of ``self``."""
75
yield self
76
77
78
def __len__ ( self ) -> int :
79
"""Returns the number of components of ``self``."""
80
return 1
81
82
83
def Constituent_Parts ( self ) -> list[ "Irreducible_Structure" ] :
84
"""Returns ``self`` in a list ."""
85
return [ self ]
86
87
88
def Irreducible_Components ( self ) -> Iterator[ "Irreducible_Structure" ] :
89
"""Returns ``self``."""
90
yield self
91
92
93
94
class Direct_Sum_Of_Structures ( Structure ) :
95
96
def __eq__ ( self , other:"Direct_Sum_Of_Structures" ) -> bool :
97
"""Tests if two objects of the class ``Direct_Sum_Of_Structures`` coincide."""
98
if type( other ) == self.__class__ :
99
if len( other ) == len( self ) :
100
101
Remaining_Summands = other.Summands()
102
for Summand in self.Summands() :
103
try : Remaining_Summands.remove( Summand )
104
except : return False
105
106
if len( Remaining_Summands ) == 0 : return True
107
108
else : return False
109
else : return False
110
else : return False
111
112
113
def __iter__ ( self ) -> Iterator[ Structure ] :
114
"""Returns an iterator of ``self``."""
115
for Summand in self.Summands() :
116
yield Summand
117
118
119
def __len__ ( self ) -> int :
120
"""Returns the number of components of ``self``."""
121
return len( self.Summands() )
122
123
124
def Constituent_Parts ( self ) -> list[ Structure ] :
125
"""Returns the summands of ``self`` as list."""
126
return self.Summands()
127
128
129
def Irreducible_Components ( self ) -> Iterator[ Irreducible_Structure ] :
130
"""Returns the irreducible components of ``self`` as list."""
131
for Summand in self.Summands() :
132
for Irreducible_Component in Summand.Irreducible_Components() :
133
yield Irreducible_Component
134
135
136
def Summands ( self ) -> list[ Structure ] :
137
"""Returns the attribute ``_Summands``."""
138
return self._Summands
139
140
141
142
class Extension_Of_Structures ( Structure ) :
143
144
def __iter__ ( self ) -> Iterator[ Structure ] :
145
"""Returns an iterator of ``self``."""
146
for Part in self.Constituent_Parts() :
147
yield Part
148
149
150
def __len__ ( self ) -> int :
151
"""Returns the number of constituent parts of ``self``."""
152
return 2
153
154
155
def Constituent_Parts ( self ) -> "Extension_Of_Structures" :
156
"""Returns the summands of ``self`` as list."""
157
return [ self ]
158
159
160
def Irreducible_Components ( self ) -> Iterator[ Irreducible_Structure ] :
161
"""Returns the attribute ``_Components``."""
162
for Component in [ self.Quotient() , self.Subobject() ] :
163
for Irreducible_Component in Component.Irreducible_Components() :
164
yield Irreducible_Component
165
166
167
def Quotient ( self ) -> Structure :
168
"""Returns the attribute ``_Quotient``."""
169
return self._Quotient
170
171
172
def Subobject ( self ) -> Structure :
173
"""Returns the attribute ``_Subobject``."""
174
return self._Subobject
175
176
177
178