1r"""
2.. _simplicialapl:
3
4We define now a simplicial object in the category of cochain algebras, called the **simplicial cochain algebra**
5:math:`A_{PL} = \{(A_{PL})_n\}_{n \geq 0}` as follows:
6
7* For each :math:`n \geq 0`, the cochain algebra :math:`(A_{PL})_n` is the one defined above.
8
9* The face and degeneration morphisms are the unique cochain algebra morphisms
10
11.. math::
12
13 \begin{array}{rll}
14 \partial_i: & (A_{PL})_{n} \rightarrow (A_{PL})_{n-1}, \; & 0 \leq i \leq n, \\
15 s_j: & (A_{PL})_{n} \rightarrow (A_{PL})_{n+1}, \; & 0 \leq j \leq n, \\
16 \end{array}
17
18satisfying:
19
20.. math::
21
22 \partial_i (t_k) = \left\{\begin{matrix}
23 t_k, & k<i \\
24 0, & k=i \\
25 t_{k-1}, & k>i
26 \end{matrix}\right., \; \; \; \; \; \;
27 s_j (t_k) = \left\{\begin{matrix}
28 t_k, & k<j \\
29 t_k+t_{k+1}, & k=j \\
30 t_{k+1}, & k>j
31 \end{matrix}\right.
32
33The structure of the simplicial cochain algebra :math:`A_{PL}` can be visualized in figure :ref:`simplicial_apln`,
34where horizontally is represented the simplicial structure for a given dimension :math:`n` (subscript), and vertically
35the graded structure of the algebra (representing the degree :math:`p`, with superscript). This object has a triangular
36structure due to the vanishing of the elements when :math:`p>n`.
37
38.. image:: /_static/simplicialapllight.svg
39 :align: center
40 :class: only-light
41 :alt: The structure of the simplicial cochain algebra :math:`A_{PL}`.
42
43.. image:: /_static/simplicialapldark.svg
44 :align: center
45 :class: only-dark
46 :alt: The structure of the simplicial cochain algebra :math:`A_{PL}`.
47
48
49.. raw:: latex
50
51 \begin{figure}[H]
52 \centering
53 \begin{tikzcd}
54 & & & & & \\
55 0 & \arrow[l, "\partial_i" above] (A_{PL})^{0}_{0} \arrow[d, "d^{0}_A"] & \arrow[l, |shift left=1| ] \arrow[l, |shift right=1| , "\partial_i" above] (A_{PL})^{0}_{1} \arrow[d, "d^{0}_A"] & \arrow[l, |shift left=2| ] \arrow[l] \arrow[l, |shift right=2| ,"\partial_i" above] (A_{PL})^{0}_{2} \arrow[d, "d^{0}_A"] & \arrow[l, |shift left=3| ] \arrow[l, |shift left=1| ] \arrow[l, |shift right=1| ] \arrow[l, "\partial_i" above, |shift right=3| ] (A_{PL})^{0}_{3} \arrow[d, "d^{0}_A"] & \arrow[l, |shift left=4| ] \arrow[l, |shift left=2| ] \arrow[l] \arrow[l, |shift right=2| ] \arrow[l, |shift right=4| ,"\partial_i" above] \cdots \\
56 & 0 & \arrow[l, "\partial_i" {above, yshift=5pt}, |shift left=1| ] \arrow[l, |shift right=1| ] (A_{PL})^{1}_{1} \arrow[d, "d^{1}_A"] & \arrow[l, "\partial_i" {above, yshift=12pt}, |shift left=2| ] \arrow[l] \arrow[l, |shift right=2| ] (A_{PL})^{1}_{2} \arrow[d, "d^{1}_A"] & \arrow[l, |shift left=3| ] \arrow[l, |shift left=1| ] \arrow[l, |shift right=1| ] \arrow[l, "\partial_i" above, |shift right=3| ] (A_{PL})^{1}_{3} \arrow[d, "d^{1}_A"] & \arrow[l, |shift left=4| ] \arrow[l, |shift left=2| ] \arrow[l] \arrow[l, |shift right=2| ] \arrow[l, |shift right=4| ,"\partial_i" above] \cdots \\
57 & & 0 & \arrow[l, |shift left=2| ] \arrow[l] \arrow[l, |shift right=2| ,"\partial_i" above] (A_{PL})^{2}_{2} \arrow[d, "d^{2}_A"] & \arrow[l, |shift left=3| ] \arrow[l, |shift left=1| ] \arrow[l, |shift right=1| ] \arrow[l, "\partial_i" above, |shift right=3| ] (A_{PL})^{2}_{3} \arrow[d, "d^{2}_A"] & \arrow[l, |shift left=4| ] \arrow[l, |shift left=2| ] \arrow[l] \arrow[l, |shift right=2| ] \arrow[l, |shift right=4| ,"\partial_i" above]\cdots \\
58 & & & 0 & \arrow[l, |shift left=3| ] \arrow[l, |shift left=1| ] \arrow[l, |shift right=1| ] \arrow[l, "\partial_i" above, |shift right=3| ] (A_{PL})^{3}_{3} & \arrow[l, |shift left=4| ] \arrow[l, |shift left=2| ] \arrow[l] \arrow[l, |shift right=2| ] \arrow[l, |shift right=4| ,"\partial_i" above] \cdots \\
59 \end{tikzcd}
60 \caption{The structure of the simplicial cochain algebra $(A_{PL})_n$.}
61 \label{simplicial_apln}
62 \end{figure}
63
64"""
65
66from sage.structure.unique_representation import UniqueRepresentation, CachedRepresentation
67from sage.misc.cachefunc import cached_method, cached_function
68from sage.all import *
69from sage.algebras.commutative_dga import *
70from sage.structure.parent import Parent
71from sage.structure.element import Element
72from sage.topology.simplicial_set import *
73from sage.rings.integer_ring import ZZ
74from sage.structure.richcmp import rich_to_bool, op_EQ, op_NE, op_LT, op_LE, op_GT, op_GE
75from sage.rings.polynomial.polydict import ETuple
76from copy import deepcopy
77import itertools
78from itertools import combinations
79from .AlgebraPL import AplN
80
81
[docs]
82class SimplicialAPL(UniqueRepresentation, CachedRepresentation):
83 r"""
84 The simplicial cochain algebra :math:`A_{PL} = \{(A_{PL})_{n}\}_{n \geq 0}`.
85 """
86
87 def __init__(self, n):
88 r"""
89 Initialization of ``self``
90 """
91 self.n = n
92 self._data = {i: AplN(i) for i in range((n + 1))}
93
94 @cached_method(do_pickle=True)
95 def _coface_coeff_endomorphism(self, faces, dim_from, dim_to):
96 dom = self.n_th_object(dim_from).base_ring()
97 cod = self.n_th_object(dim_to).base_ring()
98 if (dim_from > dim_to):
99 face_matrix = identity_matrix(cod, len(dom.gens()), sparse=True)
100 face_matrix = face_matrix.delete_rows(faces).T
101 else:
102 face_matrix = identity_matrix(cod, len(cod.gens()), sparse=True)
103 face_matrix = face_matrix.delete_rows(faces)
104 codgens = vector(cod, cod.gens())
105 image = list((face_matrix * codgens))
106 return dom.hom(image, cod)
107
108 @cached_method(do_pickle=True)
109 def _face(self, dim, deg, face_idx):
110 if (not (0 <= face_idx <= dim)):
111 raise ValueError(
112 f'the face must be an integer in the range {{0,{dim}}}')
113 if (not (0 <= deg <= (dim + 1))):
114 raise ValueError(
115 f'the degree must be an integer in the range {{1,{(dim + 1)}}}')
116 baseRingFaceHom = self._face_coeff_endomorphism(dim, face_idx)
117 if (deg == 0):
118 return {'base_ring_hom': baseRingFaceHom, 'graded_module_hom': {}}
119 A = self.n_th_object(dim)
120 B = self.n_th_object((dim - 1))
121 MA = A._free_graded_module(deg)
122 face_matrix = A._graded_face_matrix(face_idx, deg)
123 face_matrix = face_matrix.change_ring(QQ)
124 idx = A._reduction_indices(face_idx, deg)
125 m = identity_matrix(QQ, MA.dimension())
126 face_hom = m[idx, : ]
127 return {'base_ring_hom': baseRingFaceHom, 'graded_module_hom': face_hom}
128
129 @cached_method(do_pickle=True)
130 def _face_coeff_endomorphism(self, dim, face):
131 dom = self.n_th_object(dim).base_ring()
132 cod = self.n_th_object((dim - 1)).base_ring()
133 image = list(cod.gens())
134 image.insert(face, 0)
135 return dom.hom(image, cod)
136
137 @cached_method(do_pickle=True)
138 def _degen_coeff_homomorphism(self, dim, i):
139 """
140 Description
141
142 """
143 dom = self.n_th_object(dim).base_ring()
144 cod = self.n_th_object(dim + 1).base_ring()
145 image = list(cod.gens())[:i] + [sum(cod.gens()[i:(i + 2)])] + list(cod.gens())[i + 2:]
146 return dom.hom(image, cod)
147
148 @cached_method(do_pickle=True)
149 def _degen_mon_homomorphism(self, dim, i):
150 r"""
151 Description
152
153 """
154 dom = self.n_th_object(dim)
155 cod = self.n_th_object(dim + 1)
156 m = identity_matrix(QQ,dim+2)
157 m = m.delete_columns([i])
158 m[i,i] = 1
159 return dom.lift_morphism(m, names=cod.variable_names())
160
161 def __repr__(self):
162 r"""
163 String representation of ``self``.
164
165 """
166 return 'The Simplicial Commutative Differential Graded Algebra (A_{PL})_{%s}' % self.n
167
168 @cached_method(do_pickle=True)
169 def affine_map(self, faces, dim, coef=1, normalized=True):
170 r"""
171 Returns the differential form on :math:`\omega \in (A_{PL})_{dim}` of degree
172 ``n = dim-len(faces)`` for which
173
174 .. math::
175
176 \partial_J(\omega)= \frac{coef}{n!} * \mathcal{Whitney}
177
178 with the face-path :math:`J` specified in ``faces``.
179
180 If ``normalized=True``, then :math:`\int \partial_J(\omega) = 1`.
181
182 .. NOTE::
183
184 If ``coef= factorial(n)``, this map is equivalent to :meth:`whitney_map`.
185
186 INPUT:
187
188 - ``faces`` -- tuple; the face path specified by an strictly increasing sequence of non-negative integers
189
190 - ``dim`` -- integer; codomain\'s dimension
191
192 - ``coef`` -- an element of the domain's base_ring (default:1)
193
194 - ``normalized`` -- boolean; if ``True``, returns the normalized differential form
195
196 .. tab:: Sage
197
198 EXAMPLES::
199
200 sage: S = SimplicialAPL(5)
201 sage: A = S.n_th_object(4)
202 sage: R = A.base_ring()
203 sage: A.inject_variables()
204 Defining y0, y1, y2, y3, y4
205 sage: R.inject_variables()
206 Defining t0, t1, t2, t3, t4
207 sage: S.affine_map(faces=(1,),dim=5,coef=factorial(4)) == S.whitney_map((1,),5)
208 True
209 sage: w = S.affine_map(faces=(1,),dim=5,coef=factorial(4))
210 sage: [S.face(w,i).reduce(0) for i in range(6)]
211 [0, 24*y1*y2*y3*y4, 0, 0, 0, 0]
212
213 sage: coef = t0*t1
214 sage: theta = S.affine_map((4,),5,coef)
215 sage: [S.face(theta,i).reduce(0) for i in range(6)]
216 [0, 0, 0, 0, (-t1^2 - t1*t2 - t1*t3 - t1*t4 + t1)*y1*y2*y3*y4, 0]
217 sage: S.face(theta,4).integral()
218 1/720
219
220 sage: eta = S.affine_map((4,),5,coef, normalized=True)
221 sage: S.face(eta,4).integral()
222 1
223
224
225
226
227 """
228 dim_from = (dim - len(faces))
229 hom = self._coface_coeff_endomorphism(faces, dim_from, dim)
230 Apl_from = self.n_th_object(dim_from)
231 Apl_to = self.n_th_object(dim)
232 R = Apl_from.base_ring()
233
234 w_form = self.whitney_map(faces, dim)
235 if not normalized:
236 return hom(coef) * (1/factorial(dim_from))*w_form
237 else:
238 if (coef in R and not coef in QQ):
239 c = Apl_to.zero()
240 for (i, m) in enumerate(coef.monomials()):
241 cf = hom(coef.coefficients()[i])
242 num = factorial(dim_from+m.degree())
243 den = factorial(m.degree())*factorial(dim_from)
244 c += ((cf * (num / den)) * hom(m))
245 return (c * w_form)
246
247 @cached_method(do_pickle=True)
248 def degeneracy(self, p, i):
249 r"""
250 Returns the degeneracy ``i`` of the differential form ``p``
251
252 .. tab:: Sage
253
254 EXAMPLES::
255
256 sage: from Sullivan_MM import *
257 sage: S = SimplicialAPL(10)
258 sage: A = AplN(4)
259 sage: R = A.base_ring()
260 sage: A.inject_variables()
261 Defining y0, y1, y2, y3, y4
262 sage: R.inject_variables()
263 Defining t0, t1, t2, t3, t4
264 sage: theta = t1*y0
265 sage: S.degeneracy(theta,0)
266 t2*y0 + t2*y1
267
268 sage: theta = A(t4)
269 sage: S.degeneracy(theta,4)
270 t4 + t5
271
272 sage: theta = y4
273 sage: S.degeneracy(theta,4)
274 y4 + y5
275
276 sage: theta = t0*y3*y4
277 sage: S.degeneracy(theta,4)
278 t0*y3*y4 + t0*y3*y5
279 sage: _ in AplN(5)
280 True
281
282
283 """
284 dom = p.parent()
285 dim = dom.n
286 cod = self.n_th_object(dim + 1)
287 homcoef = self._degen_coeff_homomorphism(dim, i)
288 hommon = self._degen_mon_homomorphism(dim, i)
289 degeneracy = cod.zero()
290 for term in p.terms():
291 c = term.leading_coefficient()
292 m = term.leading_monomial()
293 degeneracy += cod(homcoef(c))*hommon(m)
294 return degeneracy
295
296 @cached_method(do_pickle=True)
297 def face(self, p, i):
298 r"""
299 Returns the face ``i`` of the differential form ``p``
300
301 .. tab:: Sage
302
303 EXAMPLES::
304
305 sage: S = SimplicialAPL(10)
306 sage: A = S.n_th_object(4)
307 sage: R = A.base_ring()
308 sage: A.inject_variables()
309 Defining y0, y1, y2, y3, y4
310 sage: R.inject_variables()
311 Defining t0, t1, t2, t3, t4
312 sage: w = t0*y1*y3
313 sage: S.face(w,0)
314 0
315 sage: S.face(w,2)
316 t0*y1*y2
317 sage: _ in S.n_th_object(3)
318 True
319 sage: S.face(w,4)
320 t0*y1*y3
321 sage: _ in S.n_th_object(3)
322 True
323
324 """
325 A = p.parent()
326 dim = A.n
327 if (not (0 <= i <= dim)):
328 raise ValueError(
329 f'the face must be an integer in the range {{0,{dim}}}')
330 if (not p):
331 return self.n_th_object((dim - 1)).zero()
332 deg = A(p).degree()
333 if (not (0 <= deg <= (dim + 1))):
334 raise ValueError(
335 f'the degree must be an integer in the range {{1,{(dim + 1)}}}')
336 hom = self._face(dim, deg, i)
337 baseRingFaceHom = hom['base_ring_hom']
338 B = self.n_th_object((dim - 1))
339 if (A(p).degree() == 0):
340 return B(baseRingFaceHom(A(p).leading_coefficient()))
341 MB = B._free_graded_module(deg)
342 face_hom = hom['graded_module_hom']
343 new_element = B.zero()
344 for term in p.terms():
345 c = term.leading_coefficient()
346 m = term.leading_monomial()
347 v = m._to_graded_module().to_vector()
348 vb = MB.from_vector((face_hom * v))
349 new_coeff = baseRingFaceHom(c)
350 new_monomial = B._from_graded_module(deg, vb)
351 new_element += (new_coeff * new_monomial)
352 return new_element
353
354 @cached_method(do_pickle=True)
355 def n_th_object(self, n):
356 r"""
357 Returns the ``n``-simplex of ``self``.
358
359 .. tab:: Sage
360
361 EXAMPLES::
362
363 sage: S = SimplicialAPL(10)
364 sage: S.n_th_object(5)
365 The Commutative Differential Graded Algebra (A_{PL})_{5} defined as
366 the tensor product of the Polynomial Ring QQ<t_{0},...,t_{5}> with
367 the Exterior Algebra generated by QQ<y_{0},...,y_{5}>.
368
369 The degrees of the generators are:
370
371 deg(t_i)=0
372 deg(y_j)=1
373
374 The differential 'd' is defined as:
375
376 d(t_i)=y_i
377 d(y_j)=0
378
379 .. tab:: Python code
380
381 EXAMPLES::
382
383 S = SimplicialAPL(10)
384 S.n_th_object(5)
385
386
387
388 """
389 return self._data[n]
390
391 @cached_method(do_pickle=True)
392 def whitney_map(self, faces, dim):
393 r"""
394 Let :math:`\mathbb{K}` be a field of characteristic :math:`0` and let :math:`S = \{S_n\}_{n \geq 0}` be a
395 simplicial set. Also, let :math:`A_{PL}(S)` be the algebra of polynomial differential forms defined on :math:`S`,
396 and :math:`C^*(S)`, the simplicial cochain complex associated to :math:`S`.
397
398 Let :math:`I = \{i_0,\dots,i_p\}`, with :math:`0 \leq i_0 < \cdots < i_p \leq n,` and define
399
400 .. math::
401
402 J := [n] \smallsetminus I = \{j_0,\dots,j_q\}
403
404 such that :math:`0 \leq j_0 < \cdots < j_q \leq n` and :math:`p+q=n`.
405
406 Let :math:`\sigma_p \in S_p` and :math:`\sigma_n \in S_n` be two simplices of `S` such that,
407 :math:`\partial_J(\sigma_n) = \sigma_p` where
408
409 .. math::
410
411 \partial_J = \partial_{j_0} \circ \cdots \circ \partial_{j_q}.
412
413 Let :math:`\beta \in C^p(S)`. The Whitney map (see :cite:`Whitney1957GeometricIT, WhitneyFormsLOHI`)
414
415 .. math::
416
417 \mathcal{W}^p = \{\mathcal{W}^p_n: C^p(S_p) \rightarrow A^p_{PL}(S_n)\}
418
419 is defined as:
420
421 .. math::
422
423 \mathcal{W}^p_n(\beta)(\sigma_n)|_{\sigma_p} = \beta(\sigma_p) \cdot n! \cdot \sum_{k=0}^{p} (-1)^j t_{i_k}
424 y_{i_0} \wedge \cdots \wedge \hat{y}_{i_k} \wedge \cdots \wedge y_{i_p}
425
426 where the symbol :math:`\; \hat{} \;` means the term is omitted. The elements in the image of
427 :math:`\mathcal{W}` are called the `elementary differential forms` or just `Whitney forms`.
428 The motivation behind this notation is that the subset `I` comes from the inclusion
429
430 .. math::
431
432 i: \Delta^p \hookrightarrow{} \Delta^n
433
434 that, by the :math:`A_{PL}` functor translates to the inclusion of algebras:
435
436 .. math::
437
438 \begin{array}{cccc}
439 A_{PL}(i): &(A_{PL})_p & \hookrightarrow{} & (A_{PL})_n \\
440 & (t_0,\dots, t_p) & \rightarrow & (t_{i_0},\dots, t_{i_p})
441 \end{array}
442
443 .. tab:: Sage
444
445 EXAMPLES::
446
447 This example ilustrates the locallity property of Whitney forms::
448
449 sage: S = SimplicialAPL(10)
450 sage: A3 = S.n_th_object(3)
451 sage: w1 = S.whitney_map((1,), 4)
452 sage: w1
453 -6*t4*y0*y2*y3 + 6*t3*y0*y2*y4 - 6*t2*y0*y3*y4 + 6*t0*y2*y3*y4
454 sage: S.face(w1,0)
455 0
456 sage: S.face(w1,1)
457 -6*t3*y0*y1*y2 + 6*t2*y0*y1*y3 - 6*t1*y0*y2*y3 + 6*t0*y1*y2*y3
458 sage: S.face(w1,2)
459 0
460 sage: S.face(w1,3)
461 0
462 sage: S.face(w1,4)
463 0
464 sage: S.face(w1,1) == A3.whitney_form()
465 True
466
467 This example ilustrates the Whitney map along a face-path of length 2::
468
469 sage: w23 = S.whitney_map((2,3),5)
470 sage: w23
471 -6*t5*y0*y1*y4 + 6*t4*y0*y1*y5 - 6*t1*y0*y4*y5 + 6*t0*y1*y4*y5
472 sage: S.face(S.face(w23,3),2) == A3.whitney_form()
473 True
474
475 """
476 Apl = self.n_th_object(dim)
477 n = Apl.n
478 R = Apl.base_ring()
479 rgens = list(R.gens())
480 w_form = Apl.zero()
481 gens = list(Apl.gens())
482 for face in reversed(faces):
483 rgens.pop(face)
484 gens.pop(face)
485 for i in range(len(rgens)):
486 y_gens = copy.deepcopy(gens)
487 y_gens.pop(i)
488 w_form += ((((- 1) ** i) * rgens[i]) * prod(y_gens))
489 return (factorial((dim - len(faces))) * w_form)
490
491