forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ncsf.py
5679 lines (4563 loc) · 235 KB
/
ncsf.py
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# sage.doctest: needs sage.combinat sage.modules
"""
Non-Commutative Symmetric Functions
"""
#*****************************************************************************
# Copyright (C) 2009 Nicolas M. Thiery <nthiery at users.sf.net>,
# 2012 Franco Saliola <saliola@gmail.com>,
# 2012 Chris Berg <chrisjamesberg@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
#
# This code is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
#*****************************************************************************
########################################
# TODO:
# 1. Make Coercion run faster between multiple bases.
########################################
from sage.misc.bindable_class import BindableClass
from sage.misc.cachefunc import cached_method
from sage.misc.lazy_attribute import lazy_attribute
from sage.misc.misc_c import prod
from sage.structure.parent import Parent
from sage.structure.unique_representation import UniqueRepresentation
from sage.arith.misc import factorial
from sage.categories.realizations import Category_realization_of_parent
from sage.categories.rings import Rings
from sage.categories.fields import Fields
from sage.categories.graded_hopf_algebras import GradedHopfAlgebras
from sage.combinat.composition import Compositions
from sage.combinat.free_module import CombinatorialFreeModule
from sage.combinat.ncsf_qsym.generic_basis_code import BasesOfQSymOrNCSF
from sage.combinat.ncsf_qsym.combinatorics import (coeff_pi, coeff_lp,
coeff_sp, coeff_ell, m_to_s_stat, number_of_fCT, number_of_SSRCT, compositions_order)
from sage.combinat.partition import Partition
from sage.combinat.permutation import Permutations
from sage.matrix.constructor import matrix
from sage.matrix.matrix_space import MatrixSpace
from sage.combinat.sf.sf import SymmetricFunctions
class NonCommutativeSymmetricFunctions(UniqueRepresentation, Parent):
r"""
The abstract algebra of non-commutative symmetric functions.
We construct the abstract algebra of non-commutative symmetric
functions over the rational numbers::
sage: NCSF = NonCommutativeSymmetricFunctions(QQ)
sage: NCSF
Non-Commutative Symmetric Functions over the Rational Field
sage: S = NCSF.complete()
sage: R = NCSF.ribbon()
sage: S[2,1]*R[1,2]
S[2, 1, 1, 2] - S[2, 1, 3]
NCSF is the unique free (non-commutative!) graded connected algebra with
one generator in each degree::
sage: NCSF.category()
Join of Category of Hopf algebras over Rational Field
and Category of graded algebras over Rational Field
and Category of monoids with realizations
and Category of graded coalgebras over Rational Field
and Category of coalgebras over Rational Field with realizations
and Category of cocommutative coalgebras over Rational Field
sage: [S[i].degree() for i in range(10)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
We use the Sage standard renaming idiom to get shorter outputs::
sage: NCSF.rename("NCSF")
sage: NCSF
NCSF
NCSF has many representations as a concrete algebra. Each of them
has a distinguished basis, and its elements are expanded in this
basis. Here is the `\Psi`
(:class:`~sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Psi`)
representation::
sage: Psi = NCSF.Psi()
sage: Psi
NCSF in the Psi basis
Elements of ``Psi`` are linear combinations of basis elements indexed
by compositions::
sage: Psi.an_element()
2*Psi[] + 2*Psi[1] + 3*Psi[1, 1]
The basis itself is accessible through::
sage: Psi.basis()
Lazy family (Term map from Compositions of non-negative integers...
sage: Psi.basis().keys()
Compositions of non-negative integers
To construct an element one can therefore do::
sage: Psi.basis()[Composition([2,1,3])]
Psi[2, 1, 3]
As this is rather cumbersome, the following abuses of notation are
allowed::
sage: Psi[Composition([2, 1, 3])]
Psi[2, 1, 3]
sage: Psi[[2, 1, 3]]
Psi[2, 1, 3]
sage: Psi[2, 1, 3]
Psi[2, 1, 3]
or even::
sage: Psi[(i for i in [2, 1, 3])]
Psi[2, 1, 3]
Unfortunately, due to a limitation in Python syntax, one cannot use::
sage: Psi[] # not implemented
Instead, you can use::
sage: Psi[[]]
Psi[]
Now, we can construct linear combinations of basis elements::
sage: Psi[2,1,3] + 2 * (Psi[4] + Psi[2,1])
2*Psi[2, 1] + Psi[2, 1, 3] + 2*Psi[4]
.. rubric:: Algebra structure
To start with, ``Psi`` is a graded algebra, the grading being induced by
the size of compositions. The one is the basis element indexed by the empty
composition::
sage: Psi.one()
Psi[]
sage: S.one()
S[]
sage: R.one()
R[]
As we have seen above, the ``Psi`` basis is multiplicative; that is
multiplication is induced by linearity from the concatenation of
compositions::
sage: Psi[1,3] * Psi[2,1]
Psi[1, 3, 2, 1]
sage: (Psi.one() + 2 * Psi[1,3]) * Psi[2, 4]
2*Psi[1, 3, 2, 4] + Psi[2, 4]
.. rubric:: Hopf algebra structure
``Psi`` is further endowed with a coalgebra structure. The coproduct
is an algebra morphism, and therefore determined by its values on
the generators; those are primitive::
sage: Psi[1].coproduct()
Psi[] # Psi[1] + Psi[1] # Psi[]
sage: Psi[2].coproduct()
Psi[] # Psi[2] + Psi[2] # Psi[]
The coproduct, being cocommutative on the generators, is
cocommutative everywhere::
sage: Psi[1,2].coproduct()
Psi[] # Psi[1, 2] + Psi[1] # Psi[2] + Psi[1, 2] # Psi[] + Psi[2] # Psi[1]
The algebra and coalgebra structures on ``Psi`` combine to form a
bialgebra structure, which cooperates with the grading to form a
connected graded bialgebra. Thus, as any connected graded bialgebra,
``Psi`` is a Hopf algebra. Over ``QQ`` (or any other `\QQ`-algebra),
this Hopf algebra ``Psi`` is isomorphic to the tensor algebra of
its space of primitive elements.
The antipode is an anti-algebra morphism; in the ``Psi`` basis, it
sends the generators to their opposites and changes their sign if
they are of odd degree::
sage: Psi[3].antipode()
-Psi[3]
sage: Psi[1,3,2].antipode()
-Psi[2, 3, 1]
sage: Psi[1,3,2].coproduct().apply_multilinear_morphism(lambda be,ga: Psi(be)*Psi(ga).antipode())
0
The counit is defined by sending all elements of positive degree to
zero::
sage: S[3].degree(), S[3,1,2].degree(), S.one().degree()
(3, 6, 0)
sage: S[3].counit()
0
sage: S[3,1,2].counit()
0
sage: S.one().counit()
1
sage: (S[3] - 2*S[3,1,2] + 7).counit()
7
sage: (R[3] - 2*R[3,1,2] + 7).counit()
7
It is possible to change the prefix used to display the basis
elements using the method
:meth:`~sage.structure.indexed_generators.IndexedGenerators.print_options`.
Say that for instance one wanted to display the
:class:`~NonCommutativeSymmetricFunctions.Complete` basis as having
a prefix ``H`` instead of the default ``S``::
sage: H = NCSF.complete()
sage: H.an_element()
2*S[] + 2*S[1] + 3*S[1, 1]
sage: H.print_options(prefix='H')
sage: H.an_element()
2*H[] + 2*H[1] + 3*H[1, 1]
sage: H.print_options(prefix='S') #restore to 'S'
.. rubric:: Concrete representations
NCSF admits the concrete realizations defined in [NCSF1]_::
sage: Phi = NCSF.Phi()
sage: Psi = NCSF.Psi()
sage: ribbon = NCSF.ribbon()
sage: complete = NCSF.complete()
sage: elementary = NCSF.elementary()
To change from one basis to another, one simply does::
sage: Phi(Psi[1])
Phi[1]
sage: Phi(Psi[3])
-1/4*Phi[1, 2] + 1/4*Phi[2, 1] + Phi[3]
In general, one can mix up different bases in computations::
sage: Phi[1] * Psi[1]
Phi[1, 1]
Some of the changes of basis are easy to guess::
sage: ribbon(complete[1,3,2])
R[1, 3, 2] + R[1, 5] + R[4, 2] + R[6]
This is the sum of all fatter compositions. Using the usual
Möbius function for the boolean lattice, the inverse change of
basis is given by the alternating sum of all fatter compositions::
sage: complete(ribbon[1,3,2])
S[1, 3, 2] - S[1, 5] - S[4, 2] + S[6]
The analogue of the elementary basis is the sum over
all finer compositions than the 'complement' of the composition
in the ribbon basis::
sage: Composition([1,3,2]).complement()
[2, 1, 2, 1]
sage: ribbon(elementary([1,3,2]))
R[1, 1, 1, 1, 1, 1] + R[1, 1, 1, 2, 1] + R[2, 1, 1, 1, 1] + R[2, 1, 2, 1]
By Möbius inversion on the composition poset, the ribbon
basis element corresponding to a composition `I` is then the
alternating sum over all compositions fatter than the
complement composition of `I` in the elementary basis::
sage: elementary(ribbon[2,1,2,1])
L[1, 3, 2] - L[1, 5] - L[4, 2] + L[6]
The `\Phi`
(:class:`~sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Phi`)
and `\Psi` bases are computed by changing to and from the
:class:`~sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Complete`
basis. The expansion of `\Psi` basis is given in Proposition 4.5
of [NCSF1]_ by the formulae
.. MATH::
S^I = \sum_{J \geq I} \frac{1}{\pi_u(J,I)} \Psi^J
and
.. MATH::
\Psi^I = \sum_{J \geq I} (-1)^{\ell(J)-\ell(I)} lp(J,I) S^J
where the coefficients `\pi_u(J,I)` and `lp(J,I)` are coefficients in the
methods :meth:`~sage.combinat.ncsf_qsym.combinatorics.coeff_pi` and
:meth:`~sage.combinat.ncsf_qsym.combinatorics.coeff_lp` respectively. For
example::
sage: Psi(complete[3])
1/6*Psi[1, 1, 1] + 1/3*Psi[1, 2] + 1/6*Psi[2, 1] + 1/3*Psi[3]
sage: complete(Psi[3])
S[1, 1, 1] - 2*S[1, 2] - S[2, 1] + 3*S[3]
The
:class:`~sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Phi`
basis is another analogue of the power sum basis from the algebra of
symmetric functions and the expansion in the Complete basis is given in
Proposition 4.9 of [NCSF1]_ by the formulae
.. MATH::
S^I = \sum_{J \geq I} \frac{1}{sp(J,I)} \Phi^J
and
.. MATH::
\Phi^I = \sum_{J \geq I} (-1)^{\ell(J)-\ell(I)}
\frac{\prod_i I_i}{\ell(J,I)} S^J
where the coefficients `sp(J,I)` and `\ell(J,I)` are coefficients in the
methods :meth:`~sage.combinat.ncsf_qsym.combinatorics.coeff_sp` and
:meth:`~sage.combinat.ncsf_qsym.combinatorics.coeff_ell` respectively.
For example::
sage: Phi(complete[3])
1/6*Phi[1, 1, 1] + 1/4*Phi[1, 2] + 1/4*Phi[2, 1] + 1/3*Phi[3]
sage: complete(Phi[3])
S[1, 1, 1] - 3/2*S[1, 2] - 3/2*S[2, 1] + 3*S[3]
Here is how to fetch the conversion morphisms::
sage: f = complete.coerce_map_from(elementary); f
Generic morphism:
From: NCSF in the Elementary basis
To: NCSF in the Complete basis
sage: g = elementary.coerce_map_from(complete); g
Generic morphism:
From: NCSF in the Complete basis
To: NCSF in the Elementary basis
sage: f.category()
Category of homsets of unital magmas and right modules over Rational Field and
left modules over Rational Field
sage: f(elementary[1,2,2])
S[1, 1, 1, 1, 1] - S[1, 1, 1, 2] - S[1, 2, 1, 1] + S[1, 2, 2]
sage: g(complete[1,2,2])
L[1, 1, 1, 1, 1] - L[1, 1, 1, 2] - L[1, 2, 1, 1] + L[1, 2, 2]
sage: h = f*g; h
Composite map:
From: NCSF in the Complete basis
To: NCSF in the Complete basis
Defn: Generic morphism:
From: NCSF in the Complete basis
To: NCSF in the Elementary basis
then
Generic morphism:
From: NCSF in the Elementary basis
To: NCSF in the Complete basis
sage: h(complete[1,3,2])
S[1, 3, 2]
.. rubric:: Additional concrete representations
NCSF has some additional bases which appear in the literature::
sage: Monomial = NCSF.Monomial()
sage: Immaculate = NCSF.Immaculate()
sage: dualQuasisymmetric_Schur = NCSF.dualQuasisymmetric_Schur()
The :class:`~sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Monomial`
basis was introduced in [Tev2007]_ and the
:class:`~sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Immaculate`
basis was introduced in [BBSSZ2012]_. The
:class:`~sage.combinat.ncsf_qsym.qsym.QuasiSymmetricFunctions.Quasisymmetric_Schur`
were defined in [QSCHUR]_ and the dual basis is implemented here as
:class:`~sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.dualQuasisymmetric_Schur`.
Refer to the documentation for the use and definition of these bases.
.. TODO::
- implement fundamental, forgotten, and simple (coming
from the simple modules of HS_n) bases.
We revert back to the original name from our custom short name NCSF::
sage: NCSF
NCSF
sage: NCSF.rename()
sage: NCSF
Non-Commutative Symmetric Functions over the Rational Field
TESTS::
sage: TestSuite(Phi).run()
sage: TestSuite(Psi).run()
sage: TestSuite(complete).run()
"""
def __init__(self, R):
r"""
TESTS::
sage: NCSF1 = NonCommutativeSymmetricFunctions(FiniteField(23))
sage: NCSF2 = NonCommutativeSymmetricFunctions(Integers(23))
sage: TestSuite(NonCommutativeSymmetricFunctions(QQ)).run()
"""
# change the line below to assert R in Rings() once MRO issues from #15536, #15475 are resolved
assert R in Fields() or R in Rings() # side effect of this statement assures MRO exists for R
self._base = R # Won't be needed once CategoryObject won't override base_ring
cat = GradedHopfAlgebras(R).WithRealizations().Cocommutative()
Parent.__init__(self, category=cat)
# COERCION METHODS
Psi = self.Psi()
Phi = self.Phi()
complete = self.complete()
elementary = self.elementary()
ribbon = self.ribbon()
# complete to ribbon, and back
complete.module_morphism(ribbon.sum_of_fatter_compositions,
codomain=ribbon).register_as_coercion()
ribbon.module_morphism(complete.alternating_sum_of_fatter_compositions,
codomain=complete).register_as_coercion()
complete.algebra_morphism(elementary.alternating_sum_of_compositions,
codomain=elementary).register_as_coercion()
elementary.algebra_morphism(complete.alternating_sum_of_compositions,
codomain=complete).register_as_coercion()
complete.algebra_morphism(Psi._from_complete_on_generators,
codomain=Psi).register_as_coercion()
Psi.algebra_morphism(Psi._to_complete_on_generators,
codomain=complete).register_as_coercion()
complete.algebra_morphism(Phi._from_complete_on_generators,
codomain=Phi).register_as_coercion()
Phi.algebra_morphism(Phi._to_complete_on_generators,
codomain=complete).register_as_coercion()
def _repr_(self): # could be taken care of by the category
r"""
EXAMPLES::
sage: N = NonCommutativeSymmetricFunctions(ZZ)
sage: N._repr_()
'Non-Commutative Symmetric Functions over the Integer Ring'
"""
return "Non-Commutative Symmetric Functions over the %s" % self.base_ring()
def a_realization(self):
r"""
Gives a realization of the algebra of non-commutative symmetric functions. This
particular realization is the complete basis of non-commutative symmetric functions.
OUTPUT:
- The realization of the non-commutative symmetric functions in the
complete basis.
EXAMPLES::
sage: NonCommutativeSymmetricFunctions(ZZ).a_realization()
Non-Commutative Symmetric Functions over the Integer Ring in the Complete basis
"""
return self.complete()
_shorthands = tuple(['S', 'R', 'L', 'Phi', 'Psi', 'nM', 'I', 'dQS', 'dYQS', 'ZL', 'ZR'])
def dual(self):
r"""
Return the dual to the non-commutative symmetric functions.
OUTPUT:
- The dual of the non-commutative symmetric functions over a ring. This
is the algebra of quasi-symmetric functions over the ring.
EXAMPLES::
sage: NCSF = NonCommutativeSymmetricFunctions(QQ)
sage: NCSF.dual()
Quasisymmetric functions over the Rational Field
"""
from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions
return QuasiSymmetricFunctions(self.base_ring())
class Bases(Category_realization_of_parent):
"""
Category of bases of non-commutative symmetric functions.
EXAMPLES::
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: N.Bases()
Category of bases of Non-Commutative Symmetric Functions over the Rational Field
sage: R = N.Ribbon()
sage: R in N.Bases()
True
"""
def super_categories(self):
r"""
Return the super categories of the category of bases of the
non-commutative symmetric functions.
OUTPUT:
- list
TESTS::
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: N.Bases().super_categories()
[Category of bases of Non-Commutative Symmetric Functions or Quasisymmetric functions over the Rational Field,
Category of realizations of graded modules with internal product over Rational Field]
"""
R = self.base().base_ring()
from .generic_basis_code import GradedModulesWithInternalProduct
return [BasesOfQSymOrNCSF(self.base()),
GradedModulesWithInternalProduct(R).Realizations()]
class ParentMethods:
def to_symmetric_function_on_basis(self, I):
r"""
The image of the basis element indexed by ``I`` under the map
to the symmetric functions.
This default implementation does a change of basis and
computes the image in the complete basis.
INPUT:
- ``I`` -- a composition
OUTPUT:
- The image of the non-commutative basis element of
``self`` indexed by the composition ``I`` under the map from
non-commutative symmetric functions to the symmetric
functions. This will be a symmetric function.
EXAMPLES::
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: I = N.Immaculate()
sage: I.to_symmetric_function(I[1,3])
-h[2, 2] + h[3, 1]
sage: I.to_symmetric_function(I[1,2])
0
sage: Phi = N.Phi()
sage: Phi.to_symmetric_function_on_basis([3,1,2])==Phi.to_symmetric_function(Phi[3,1,2])
True
sage: Phi.to_symmetric_function_on_basis([])
h[]
"""
S = self.realization_of().complete()
return S.to_symmetric_function(S(self[I]))
@lazy_attribute
def to_symmetric_function(self):
r"""
Morphism to the algebra of symmetric functions.
This is constructed by extending the computation on the basis
or by coercion to the complete basis.
OUTPUT:
- The module morphism from the basis ``self`` to the symmetric
functions which corresponds to taking a commutative image.
EXAMPLES::
sage: N = NonCommutativeSymmetricFunctions(QQ)
sage: R = N.ribbon()
sage: x = R.an_element(); x
2*R[] + 2*R[1] + 3*R[1, 1]
sage: R.to_symmetric_function(x)
2*s[] + 2*s[1] + 3*s[1, 1]
sage: nM = N.Monomial()
sage: nM.to_symmetric_function(nM[3,1])
h[1, 1, 1, 1] - 7/2*h[2, 1, 1] + h[2, 2] + 7/2*h[3, 1] - 2*h[4]
"""
on_basis = self.to_symmetric_function_on_basis
codom = on_basis([]).parent()
return self.module_morphism(on_basis, codomain=codom)
def immaculate_function(self, xs):
r"""
Return the immaculate function corresponding to the
integer vector ``xs``, written in the basis ``self``.
If `\alpha` is any integer vector -- i.e., an element of
`\ZZ^m` for some `m \in \NN` --, the *immaculate function
corresponding to* `\alpha` is a non-commutative symmetric
function denoted by `\mathfrak{S}_{\alpha}`. One way to
define this function is by setting
.. MATH::
\mathfrak{S}_{\alpha}
= \sum_{\sigma \in S_m} (-1)^{\sigma}
S_{\alpha_1 + \sigma(1) - 1}
S_{\alpha_2 + \sigma(2) - 2}
\cdots
S_{\alpha_m + \sigma(m) - m},
where `\alpha` is written in the form
`(\alpha_1, \alpha_2, \ldots, \alpha_m)`, and where `S`
stands for the complete basis
(:class:`~NonCommutativeSymmetricFunctions.Complete`).
The immaculate function `\mathfrak{S}_{\alpha}` first
appeared in [BBSSZ2012]_ (where it was defined
differently, but the definition we gave above appeared as
Theorem 3.27).
The immaculate functions `\mathfrak{S}_{\alpha}` for
`\alpha` running over all compositions (i.e., finite
sequences of positive integers) form a basis of `NCSF`.
This is the *immaculate basis*
(:class:`~NonCommutativeSymmetricFunctions.Immaculate`).
INPUT:
- ``xs`` -- list (or tuple or any iterable -- possibly a
composition) of integers
OUTPUT:
The immaculate function `\mathfrak{S}_{xs}`
written in the basis ``self``.
EXAMPLES:
Let us first check that, for ``xs`` a composition, we get
the same as the result of
``self.realization_of().I()[xs]``::
sage: def test_comp(xs):
....: NSym = NonCommutativeSymmetricFunctions(QQ)
....: I = NSym.I()
....: return I[xs] == I.immaculate_function(xs)
sage: def test_allcomp(n):
....: return all( test_comp(c) for c in Compositions(n) )
sage: test_allcomp(1)
True
sage: test_allcomp(2)
True
sage: test_allcomp(3)
True
Now some examples of non-composition immaculate
functions::
sage: NSym = NonCommutativeSymmetricFunctions(QQ)
sage: I = NSym.I()
sage: I.immaculate_function([0, 1])
0
sage: I.immaculate_function([0, 2])
-I[1, 1]
sage: I.immaculate_function([-1, 1])
-I[]
sage: I.immaculate_function([2, -1])
0
sage: I.immaculate_function([2, 0])
I[2]
sage: I.immaculate_function([2, 0, 1])
0
sage: I.immaculate_function([1, 0, 2])
-I[1, 1, 1]
sage: I.immaculate_function([2, 0, 2])
-I[2, 1, 1]
sage: I.immaculate_function([0, 2, 0, 2])
I[1, 1, 1, 1] + I[1, 2, 1]
sage: I.immaculate_function([2, 0, 2, 0, 2])
I[2, 1, 1, 1, 1] + I[2, 1, 2, 1]
TESTS:
Basis-independence::
sage: NSym = NonCommutativeSymmetricFunctions(QQ)
sage: L = NSym.L()
sage: S = NSym.S()
sage: L(S.immaculate_function([0, 2, 0, 2])) == L.immaculate_function([0, 2, 0, 2])
True
"""
S = self.realization_of().S()
res = S.zero()
m = len(xs)
ys = [xs_i - i - 1 for i, xs_i in enumerate(xs)]
for s in Permutations(m):
psco = [ys[i] + s_i for i, s_i in enumerate(s)]
if not all(j >= 0 for j in psco):
continue
psco2 = [j for j in psco if j != 0]
pr = s.sign() * S[psco2]
res += pr
return self(res)
class ElementMethods:
def verschiebung(self, n):
r"""
Return the image of the noncommutative symmetric function
``self`` under the `n`-th Verschiebung operator.
The `n`-th Verschiebung operator `\mathbf{V}_n` is defined
to be the map from the `\mathbf{k}`-algebra of noncommutative
symmetric functions to itself that sends the complete function
`S^I` indexed by a composition `I = (i_1, i_2, \ldots , i_k)`
to `S^{(i_1/n, i_2/n, \ldots , i_k/n)}` if all of the numbers
`i_1, i_2, \ldots, i_k` are divisible by `n`, and to `0`
otherwise. This operator `\mathbf{V}_n` is a Hopf algebra
endomorphism. For every positive integer `r` with `n \mid r`,
it satisfies
.. MATH::
\mathbf{V}_n(S_r) = S_{r/n},
\quad \mathbf{V}_n(\Lambda_r) = (-1)^{r - r/n} \Lambda_{r/n},
\quad \mathbf{V}_n(\Psi_r) = n \Psi_{r/n},
\quad \mathbf{V}_n(\Phi_r) = n \Phi_{r/n}
(where `S_r` denotes the `r`-th complete non-commutative
symmetric function, `\Lambda_r` denotes the `r`-th elementary
non-commutative symmetric function, `\Psi_r` denotes the `r`-th
power-sum non-commutative symmetric function of the first kind,
and `\Phi_r` denotes the `r`-th power-sum non-commutative
symmetric function of the second kind). For every positive
integer `r` with `n \nmid r`, it satisfes
.. MATH::
\mathbf{V}_n(S_r) = \mathbf{V}_n(\Lambda_r)
= \mathbf{V}_n(\Psi_r) = \mathbf{V}_n(\Phi_r) = 0.
The `n`-th Verschiebung operator is also called the `n`-th
Verschiebung endomorphism.
It is a lift of the `n`-th Verschiebung operator on the ring
of symmetric functions
(:meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.verschiebung`)
to the ring of noncommutative symmetric functions.
The action of the `n`-th Verschiebung operator can also be
described on the ribbon Schur functions. Namely, every
composition `I` of size `n \ell` satisfies
.. MATH::
\mathbf{V}_n ( R_I )
= (-1)^{\ell(I) - \ell(J)} \cdot R_{J / n},
where `J` denotes the meet of the compositions `I` and
`(\underbrace{n, n, \ldots, n}_{|I|/n \mbox{ times}})`,
where `\ell(I)` is the length of `I`, and
where `J / n` denotes the composition obtained by dividing
every entry of `J` by `n`.
For a composition `I` of size not divisible by `n`, we have
`\mathbf{V}_n( R_I ) = 0`.
.. SEEALSO::
:meth:`adams_operator method of QSym
<sage.combinat.ncsf_qsym.qsym.QuasiSymmetricFunctions.Bases.ElementMethods.adams_operator>`,
:meth:`verschiebung method of Sym
<sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.verschiebung>`
INPUT:
- ``n`` -- a positive integer
OUTPUT:
The result of applying the `n`-th Verschiebung operator (on the
ring of noncommutative symmetric functions) to ``self``.
EXAMPLES::
sage: NSym = NonCommutativeSymmetricFunctions(ZZ)
sage: S = NSym.S()
sage: S[3,2].verschiebung(2)
0
sage: S[6,4].verschiebung(2)
S[3, 2]
sage: (S[9,1] - S[8,2] + 2*S[6,4] - 3*S[3] + 4*S[[]]).verschiebung(2)
4*S[] + 2*S[3, 2] - S[4, 1]
sage: (S[3,3] - 2*S[2]).verschiebung(3)
S[1, 1]
sage: S([4,2]).verschiebung(1)
S[4, 2]
sage: R = NSym.R()
sage: R([4,2]).verschiebung(2)
R[2, 1]
Being Hopf algebra endomorphisms, the Verschiebung operators
commute with the antipode::
sage: all( R(I).verschiebung(2).antipode()
....: == R(I).antipode().verschiebung(2)
....: for I in Compositions(4) )
True
They lift the Verschiebung operators of the ring of symmetric
functions::
sage: all( S(I).verschiebung(2).to_symmetric_function()
....: == S(I).to_symmetric_function().verschiebung(2)
....: for I in Compositions(4) )
True
The Frobenius operators on `QSym` are adjoint to the
Verschiebung operators on `NSym` with respect to the duality
pairing::
sage: QSym = QuasiSymmetricFunctions(ZZ)
sage: M = QSym.M()
sage: all( all( M(I).adams_operator(3).duality_pairing(S(J))
....: == M(I).duality_pairing(S(J).verschiebung(3))
....: for I in Compositions(2) )
....: for J in Compositions(3) )
True
"""
# Convert to the homogeneous basis, there apply Verschiebung
# componentwise, then convert back.
parent = self.parent()
S = parent.realization_of().S()
C = parent._indices
dct = {C([i // n for i in I]): coeff
for (I, coeff) in S(self) if all(i % n == 0 for i in I)}
return parent(S._from_dict(dct))
def bernstein_creation_operator(self, n):
r"""
Return the image of ``self`` under the `n`-th Bernstein
creation operator.
Let `n` be an integer. The `n`-th Bernstein creation
operator `\mathbb{B}_n` is defined as the endomorphism of
the space `NSym` of noncommutative symmetric functions
which sends every `f` to
.. MATH::
\sum_{i \geq 0} (-1)^i H_{n+i} F_{1^i}^\perp,
where usual notations are in place (the letter `H` stands
for the complete basis of `NSym`, the letter `F` stands
for the fundamental basis of the algebra `QSym` of
quasisymmetric functions, and `F_{1^i}^\perp` means
skewing (:meth:`~sage.combinat.ncsf_qsym.generic_basis_code.BasesOfQSymOrNCSF.ElementMethods.skew_by`)
by `F_{1^i}`). Notice that `F_{1^i}` is nothing other than the
elementary symmetric function `e_i`.
This has been introduced in [BBSSZ2012]_, section 3.1, in
analogy to the Bernstein creation operators on the
symmetric functions
(:meth:`~sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.bernstein_creation_operator`),
and studied further in [BBSSZ2012]_, mainly in the context
of immaculate functions
(:class:`~NonCommutativeSymmetricFunctions.Immaculate`).
In fact, if `(\alpha_1, \alpha_2, \ldots, \alpha_m)` is
an `m`-tuple of integers, then
.. MATH::
\mathbb{B}_n I_{(\alpha_1, \alpha_2, \ldots, \alpha_m)}
= I_{(n, \alpha_1, \alpha_2, \ldots, \alpha_m)},
where `I_{(\alpha_1, \alpha_2, \ldots, \alpha_m)}` is the
immaculate function associated to the `m`-tuple
`(\alpha_1, \alpha_2, \ldots, \alpha_m)` (see
:meth:`~NonCommutativeSymmetricFunctions.Bases.ParentMethods.immaculate_function`).
EXAMPLES:
We get the immaculate functions by repeated application of
Bernstein creation operators::
sage: NSym = NonCommutativeSymmetricFunctions(ZZ)
sage: I = NSym.I()
sage: S = NSym.S()
sage: def immaculate_by_bernstein(xs):
....: # immaculate function corresponding to integer
....: # tuple ``xs``, computed by iterated application
....: # of Bernstein creation operators.
....: res = S.one()
....: for i in reversed(xs):
....: res = res.bernstein_creation_operator(i)
....: return res
sage: import itertools
sage: all( immaculate_by_bernstein(p) == I.immaculate_function(p)
....: for p in itertools.product(range(-1, 3), repeat=3))
True
Some examples::
sage: S[3,2].bernstein_creation_operator(-2)
S[2, 1]
sage: S[3,2].bernstein_creation_operator(-1)
S[1, 2, 1] - S[2, 2] - S[3, 1]
sage: S[3,2].bernstein_creation_operator(0)
-S[1, 2, 2] - S[1, 3, 1] + S[2, 2, 1] + S[3, 2]
sage: S[3,2].bernstein_creation_operator(1)
S[1, 3, 2] - S[2, 2, 2] - S[2, 3, 1] + S[3, 2, 1]
sage: S[3,2].bernstein_creation_operator(2)
S[2, 3, 2] - S[3, 2, 2] - S[3, 3, 1] + S[4, 2, 1]
"""
# We use the definition of this operator.
parent = self.parent()
res = parent.zero()
if not self:
return res
max_degree = max(sum(m) for m, c in self)
# ``max_degree`` is now the maximum degree in which ``self``
# has a nonzero coefficient.
NSym = parent.realization_of()
S = NSym.S()
F = NSym.dual().F()
for i in range(max_degree + 1):
if n + i > 0:
res += (-1) ** i * S[n + i] * self.skew_by(F[[1] * i])
elif n + i == 0:
res += (-1) ** i * self.skew_by(F[[1] * i])
return res
def star_involution(self):
r"""
Return the image of the noncommutative symmetric function
``self`` under the star involution.
The star involution is defined as the algebra antihomomorphism
`NCSF \to NCSF` which, for every positive integer `n`, sends
the `n`-th complete non-commutative symmetric function `S_n` to
`S_n`. Denoting by `f^{\ast}` the image of an element
`f \in NCSF` under this star involution, it can be shown that
every composition `I` satisfies
.. MATH::
(S^I)^{\ast} = S^{I^r}, \quad
(\Lambda^I)^{\ast} = \Lambda^{I^r}, \quad
R_I^{\ast} = R_{I^r}, \quad
(\Phi^I)^{\ast} = \Phi^{I^r},
where `I^r` denotes the reversed composition of `I`, and
standard notations for classical bases of `NCSF` are being used
(`S` for the complete basis, `\Lambda` for the elementary basis,
`R` for the ribbon basis, and `\Phi` for that of the power-sums
of the second kind). The star involution is an involution and a
coalgebra automorphism of `NCSF`. It is an automorphism of the
graded vector space `NCSF`. Under the canonical isomorphism
between the `n`-th graded component of `NCSF` and the descent
algebra of the symmetric group `S_n` (see
:meth:`to_descent_algebra`), the star involution (restricted to
the `n`-th graded component) corresponds to the automorphism
of the descent algebra given by
`x \mapsto \omega_n x \omega_n`, where `\omega_n` is the
permutation `(n, n-1, \ldots, 1) \in S_n` (written here in
one-line notation). If `\pi` denotes the projection from `NCSF`
to the ring of symmetric functions
(:meth:`to_symmetric_function`), then `\pi(f^{\ast}) = \pi(f)`
for every `f \in NCSF`.
The star involution on `NCSF` is adjoint to the star involution
on `QSym` by the standard adjunction between `NCSF` and `QSym`.
The star involution has been denoted by `\rho` in [LMvW13]_,
section 3.6.
See [NCSF2]_, section 2.3 for the properties of this map.
.. SEEALSO::
:meth:`star involution of QSym
<sage.combinat.ncsf_qsym.qsym.QuasiSymmetricFunctions.Bases.ElementMethods.star_involution>`,
:meth:`psi involution of NCSF
<sage.combinat.ncsf_qsym.ncsf.NonCommutativeSymmetricFunctions.Bases.ElementMethods.psi_involution>`.
EXAMPLES::
sage: NSym = NonCommutativeSymmetricFunctions(ZZ)
sage: S = NSym.S()
sage: S[3,2].star_involution()
S[2, 3]
sage: S[6,3].star_involution()
S[3, 6]
sage: (S[9,1] - S[8,2] + 2*S[6,4] - 3*S[3] + 4*S[[]]).star_involution()
4*S[] + S[1, 9] - S[2, 8] - 3*S[3] + 2*S[4, 6]
sage: (S[3,3] - 2*S[2]).star_involution()
-2*S[2] + S[3, 3]