-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.m
2372 lines (1859 loc) · 77.1 KB
/
init.m
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
(*=======SuperLie.m====== Package for Lie Superalgebras =========== *)
(********** SubPackages *********)
DeclarePackage["SuperLie`Cartmatr`", {"CartanMatrixAlgebra", "CartanMatrix",
"RootReflection", "WeightToPolyGrade", "PolyGradeToWeight"}]
DeclarePackage["SuperLie`Deriv`", {"Der", "Der0", "der", "NDer", "ZDer", "ExteriorAlgebra"}]
DeclarePackage["SuperLie`Envsort`", {"EnvNormal", "EnvSortRule", "$EnvLess",
"EnvelopingOperation", "EnvelopingSymbol", "ExpandOp", "ExpandOpRule",
"dSortRule", "dNormal", "dSymbol", "CleardSymbol", "DiffAlgebra", "Dc"}]
DeclarePackage["SuperLie`Free`", {"FreeLieAlgebra" }]
DeclarePackage["SuperLie`Generate`", {"GenRel", "GenBasis", "GRange", "ToDegree"}]
DeclarePackage["SuperLie`Genvect`", {"GeneralSum", "GeneralSolve", "GeneralZero",
"GeneralReduce", "GeneralPreImage", "GeneralBasis", "GeneralImage", "GeneralKernel",
"GeneralInverseImage", "GeneralPlus", "GeneralDim", "GeneralAct", "GeneralIntersection"}]
DeclarePackage["SuperLie`Gl`", {"glAlgebra", "slAlgebra", "pslAlgebra" }]
DeclarePackage["SuperLie`Irrmod`", {"HWModule"}]
DeclarePackage["SuperLie`Poisson`", {"PoissonAlgebra", "Pb", "pb",
"HamiltonAlgebra", "Hb", "hb",
"ContactAlgebra", "Kb", "kb", "ButtinAlgebra", "Bb", "bb",
"MoebiusAlgebra", "Mb", "mb", "OKAlgebra", "Ob", "ob",
"RamondAlgebra", "Rb", "rb", "RamondD", "ZRamondD", "RamondK",
"HamiltonianH", "\[CapitalDelta]", "EulerOp", "ContactK", "NewBrace" }]
DeclarePackage["SuperLie`Q`", {"qAlgebra", "sqAlgebra", "pqAlgebra",
"psqAlgebra", "q2Algebra", "psq2Algebra", "psl2pAlgebra" }]
DeclarePackage["SuperLie`Space`", {"VectorSpace", "ReGrade", "TrivialSpace", "SpacePlus",
"Relatives", "GetRelative", "NewRelative", "Mapping", "MappingRule",
"MLeft", "CoLeft", "MRight", "CoRight", "PiRight", "DLeft", "PiLeft", "DRight",
"SubSpace", "Algebra", "CommutativeLieAlgebra", "Basis", "BasisPattern",
"Image", "InSpace", "TheSpace", "TheAlgebra", "TheModule", (* "$Algebra", *)
(*"$Module",*) "Components", "GList", "WList" }]
DeclarePackage["SuperLie`Subspace`", {"KerSpace", "GradedKerSpace"}]
DeclarePackage["SuperLie`Subalg`", {"SubAlgebra", "DefSubAlgebra", "AlgebraDecomposition"}]
DeclarePackage["SuperLie`Submod`", {"SubModule", "Ideal", "RestrictModule",
"QuotientModule", "FactorModule", "QuotientAlgebra" }]
DeclarePackage["SuperLie`Symalg`", {"DegreeBasis", "UpToDegreeBasis",
"GradeBasis", "FilterBasis"}]
DeclarePackage["SuperLie`Tensor`", {"MatrixLieAlgebra", "TensorSpace", "CompList", "Rank"}]
DeclarePackage["SuperLie`Vecfield`", {"VectorLieAlgebra", "VectorRepresentation",
"Lb", "lb", "Div" }]
DeclarePackage["SuperLie`Vsplit`", {"SplitSum", "SplitList", "ForSplit", "AddSplit",
"MergeSplit", "JoinSplit", "ApplySplit", "MapSplit", "PartSplit", "SkipVal"}]
(*DeclarePackage["SuperLie`Char`", {"FieldChar", "ModSolve", "DivPowers",
"DivPowersQ", "UnDivPowers"}]*)
DeclarePackage["SuperLie`Solvars`", {"ParamAssume", "ParamSolve", "SolveSupportsPattern",
"$ParamAssume"}]
DeclarePackage["SuperLie`Sparse`", {"ActToSparse", "SquaringToSparse", "FormToSparse",
"PowerToSparse", "TestSparseBracket"}]
Off[General::shdw, Remove::rmnsm]
(* $osStart = "vect.osy" *)
BeginPackage["SuperLie`", {"SuperLie`Domain`", "SuperLie`Enum`"}]
dmn`ValuesList = {}
dmn`FlagsList = {Alpha, Scalar}
(* #################### PART 1. Domains #################### *)
SuperLie`STimesOp::usage = "STimesOp[domain] is the name of \"*\" in Scalar*domain."
SuperLie`PlusOp::usage = "PlusOp[domain] is the name of \"+\" in the domain."
SuperLie`CondOp::usage =
"CondOp[domain] is the name of \"If\" operation with values in the domain.
CondOp[domain->name] defines this operation"
SuperLie`SumOp::usage =
"SumOp[op] is the name of \"Sum\" function, associated with \"plus\"
operation op. SumOp[op->name] defines this operation."
SuperLie`PowerOp::usage =
"PowerOp[op] is the name of \"power\" operation, associated with \"times\"
operation op. PowerOp[op->name] defines this operation."
(*
SuperLie`UnitElement::usage =
"UnitElement[domain] is the \"1\" element in this domain"
*)
(* --------- Common Domain --------------- *)
SuperLie`GPlus::usage = "GPlus is the name of \"+\" in Common domain."
SuperLie`GTimes::usage = "GTimes is the name of \"*\" in Common domain."
SuperLie`GPower::usage = "GPower is the name of \"^\" in Common domain."
(* GSum::usage = "GSum is the name of Sum function in Common domain." *)
(* --------- Vector Domain --------------- *)
SuperLie`Vector::usage =
"Vector is the domain of vectors. Vector[obj,..] is the constructor of
Vector objects."
SuperLie`UnVector::usage = "UnVector[obj,..] is the destructor of Vector objects."
SuperLie`VectorQ::usage =
"VectorQ[x] returns True if x is an object of Vector domain."
SuperLie`VPlus::usage = "VPlus is the name of \"+\" in Vector domain."
SuperLie`VTimes::usage = "VTimes is the name of \"*\" in Vector domain."
SuperLie`VPower::usage = "VPower is the name of \"^\" in Vector domain."
SuperLie`VSum::usage = "VSum is the name of Sum function in Vector domain."
SuperLie`VIf::usage = "VIf[cond, v] is a vector-valued version of If function."
SuperLie`SVTimes::usage = "SVTimes is the name of \"*\" in Scalar*Vector."
SuperLie`tPower::usage = "v ^\[CircleTimes] n is the n-th tensor power of v."
(*SuperLie`ePower::usage = "v /\\^ n is the n-th exterior power of v."*)
SuperLie`VExpand::usage = SuperLie`VExpandRule::usage =
"VExpand[expr] or expr //. VExpandRule expand out all VTimes and SVTimes
products in expr."
SuperLie`SVExpandRule::usage =
"expr /. SVExpandRule expand out all scalar coefficients in SVTimes."
SuperLie`SVFactorRule::usage =
"expr /. SVFactorRule factors all scalar coefficients in SVTimes."
SuperLie`SVSimplifyRule::usage =
"expr /. SVSimplifyRule simplifies all scalar coefficients in SVTimes."
SuperLie`SVNormalRule::usage =
"expr /. SVNormalRule converts all scalar coefficients in SVTimes to the
normal form using the function $SNormal."
SuperLie`VCollect::usage =
"VCollect[expr] collects together terms c*v with the same v."
SuperLie`TCollect::usage =
"TCollect[expr,case] collects together terms a**b with the same a (if case=First)
or with same b (if case=Last). TCollect[expr,case,op] collect terms of operation
op rather than **. The operation should not be declared additive or linear."
SuperLie`VNormal::usage =
"VNormal[expr] returns the normal form of the vector expression."
SuperLie`SymmetricNormal::usage =
"SymmetricNormal[expr] returns the normal form of the vector expression,
assuming the supersymmetry of vector product VTimes."
SuperLie`$SNormal::usage =
"$SNormal is the user-defined function which is called by VNormal function
to convert the scalar coefficients to the normal form. Default is Together.
The function $SNormal must always convert to zero the scalars equal to zero."
SuperLie`VBasis::usage =
"VBasis[expr] returns the list of vectors in the expression."
SuperLie`VSort::usage =
"VSort[sum] sorts the terms of the vector sum in alphabetical order of
vectors."
SuperLie`VOrder::usage =
"VOrder[v1,v2] returns 0,+1,-1 depending of order of vectors v1 and v2."
SuperLie`VOrderQ::usage =
"VOrderQ[v1,v2] returns True or False depending of order of vectors v1 and v2."
SuperLie`VSameQ::usage =
"VSameQ[v1,v2] returns True if v1=c1*v, v2=c2*v with scalars c1, c2
and False otherwise."
SuperLie`SameElement::usage =
"SameElement[v1,v2] returns True if the arguments represents the same element
of the basis of a vector space (maybe with differens scalar coefficients) and
False if they represent different elements.
If the arguments have symbolic indices, the function returns the condition of
equality of these indices e.g., SameElement[x[i],x[j]] returns i==j."
SuperLie`VSolve::usage =
"VSolve[eqns, vars] attempts to solve an equation or set of equations for the
vector variables vars. VSolve[eqns] treats all vector variables encountered as
vars above. For other parameters and options see Solve."
SuperLie`SVSolve::usage =
"SVSolve[eqns, vars] attempts to solve a vector equation or set of equations
for the scalar variables vars. SVSolve[eqns] treats all non-vector variables
encountered as vars above. For other parameters and options see Solve."
SuperLie`ScalarEquation::usage =
"ScalarEquation[equ] converts the equation with scalar variables to
scalar equation"
SuperLie`LinearChange::usage =
"LinearChange[expr, rule] applies the rule or list of rules in an attempt to
transform each vector in an expression expr."
SuperLie`$Solve::usage =
"$Solve is the user-defined function for solving the scalar equations. The
default setting is $Solve = Solve."
SuperLie`$p::usage = "The value of $p is the characteristic of the base field"
(* ################### PART 2. Properties ################## *)
SuperLie`ZeroArg::usage = SuperLie`UnZeroArg::usage =
"ZeroArg[f] is the property f[.., 0, ..] = 0."
SuperLie`ZeroArgRule::usage =
"Use expr /. ZeroArgRule[f] to remove terms with f[..,0,..]."
(*
SuperLie`IdArg::usage = SuperLie`UnIdArg::usage =
"IdArg[f] is the property f[x, Id, y] = f[x,y]."
SuperLie`IdArgRule::usage =
"Use expr /. IdArgRule[f] to remove Id from f[..,Id,..]."
*)
SuperLie`Homogen::usage = SuperLie`UnHomogen::usage =
"Homogen[f->deg] is the property f[c*v] = (c^deg)*f[v] for scalar c.
Homogen[f] is equivalent to Homogen[f->1]."
SuperLie`HomogenRule::usage =
"HomogenRule[f,deg] is replacement rule f[c*v] -> (c^deg)*f[v] where c is
scalar. Default value of deg is 1."
SuperLie`Symmetric::usage = SuperLie`UnSymmetric::usage = SuperLie`SymmetricQ::usage =
"Symmetric[f] is the property f[..,x,y,..] = (-1)^(P[x]P[y]) f[..,y,x,..]."
SuperLie`SymmetricRule::usage =
"SymmetricRule[f] is the replacement rule for sorting the arguments of the
supercommutative function f."
SuperLie`SkewSymmetric::usage = SuperLie`UnSkewSymmetric::usage = SuperLie`SkewSymmetricQ::usage =
"SkewSymmetric[f] is the property
f[..,x,y,..] = (-1)^((1+P[x])(1+P[y])) f[..,y,x,..]."
SuperLie`SkewSymmetricRule::usage =
"SkewSymmetricRule[f] is the replacement rule for sorting the arguments of the
superskewcommutative function f."
SuperLie`AntiSymmetric::usage = SuperLie`UnAntiSymmetric::usage = SuperLie`AntiSymmetricQ::usage =
"AntiSymmetric[f] is the property f[..,x,y,..] = - (-1)^(P[x]P[y]) f[..,y,x,..]."
SuperLie`AntiSymmetricRule::usage =
"AntiSymmetricRule[f] is the replacement rule for sorting the arguments of the
superanticommutative function f."
SuperLie`AntiSkewSymmetric::usage =
"AntiSkewSymmetric[f] introduces the automatical sorting of operands of f using
super-anti-skew simmetry f[..,x,y,..] = - (-1)^((1+P[x])(1+P[y])) f[..,y,x,..]."
SuperLie`UnAntiSkewSymmetric::usage =
"UnAntiSkewSymmetric[f] cancels the automatical sorting of operands of f."
SuperLie`AntiSkewSymmetricQ::usage =
"AntiSkewSymmetricQ[f] returns True if f was declared anti-skew-simmetric."
SuperLie`AntiSkewSymmetricRule::usage =
"AntiSkewSymmetricRule[f] is the replacement rule for sorting the arguments of f
using super-anti-skew simmetry f[..,x,y,..] -> - (-1)^((1+P[x])(1+P[y])) f[..,y,x,..]."
SuperLie`Leibniz::usage = SuperLie`UnLeibniz::usage =
"Leibniz[f->g] is the property f @ g[x1,x2,..] = g[f@x1,x2,..] +/-
g[x1,f@x2,...] +/- ... (f acts as a derivation of parity P[f]).
Leibniz[f->{g1,..}] is the list if properties."
SuperLie`LeibnizRule::usage =
"LeibnizRule[f, g] is the rule to expand f[g[..]] into sum of
(+/-) g[.. f[.] ..] (like a derivation of parity P[f]).
LeibnizRule[f,{g1,..}] is the list of rules."
(*
SuperLie`LeibnizExpand::usage =
"LeibnizExpand[d[f[arg]],p] expands d[f[arg]] as a derivation of parity p."
*)
SuperLie`Jacobi::usage = SuperLie`UnJacobi::usage =
"Jacobi[f->g] is the property f[x, g[y1,y2,..]] = g[f[x,y1],y2,..] +/-
g[y1,f[x,y2],...] +/- ... (f acts as a bracket in Lie superalgebra).
Jacobi[f->{g1,..}] is the list if properties."
SuperLie`JacobiRule::usage =
"JacobiRule[f, g] is the rule to expand f[x, g[..]] into sum of
(+/-) g[.. f[x,.] ..] (like a bracket in Lie superalgebra).
JacobiRule[f,{g1,..}] is the list of rules."
SuperLie`Graded::usage = SuperLie`UnGraded::usage = SuperLie`GradedQ::usage =
"Graded[op] is the property Grade[a ~op~ b] = Grade[a] + Grade[b]."
SuperLie`GradedPw::usage = SuperLie`UnGradedPw::usage = SuperLie`GradedPwQ::usage =
"GradedPw[op] is the property Grade[a ~op~ k] = k*Grade[a]."
SuperLie`ThreadGraded::usage = SuperLie`UnThreadGraded::usage =
"ThreadGraded[f] is the property f[a ~op~ b] = f[a] + f[b] for any
graded operation op. ThreadGraded[f->sm] is f[a ~op~ b] = f[a] ~sm~ f[b]."
SuperLie`ThreadGradedRule::usage =
"ThreadGradedRule[f,sm] is the replacement rule f[a ~op~ b] -> f[a] ~sm~ f[b],
where op is any graded operation. Default sm is Plus."
SuperLie`DegTimes::usage = SuperLie`UnDegTimes::usage =
"DegTimes[op] is the property Deg[a ~op~ b, x] = Deg[a,x] + Deg[b,x]."
SuperLie`TestFirst::usage = SuperLie`UnTestFirst::usage =
"TestFirst[f] is the property f[x1+...] = f[x1]."
SuperLie`TestFirstRule::usage =
"TestFirstRule[f] is the replacement rule f[x1+...] -> f[x1]."
SuperLie`LogPower::usage = SuperLie`UnLogPower::usage =
"LogPower[f] is the property f[x^p] = p*f[x]. LogPower[f->tms] is
f[x^p] = tm[p, f[x]]."
SuperLie`LogPowerPule::usage =
"LogPowerRule[f, tm] is the replacement rule f[x^p] -> p ~tm~ f[x]. Default
tm is Scalar*Vector Times."
SuperLie`Additive::usage =
"Additive[f] constitutes the property f[.., x+y, ..] = f[..,x,..] + f[..,y,..].
Additive[f->First] and Additive[f->Last] declares the additivity in the first
(last) argument of f."
SuperLie`UnAdditive::usage =
"UnAdditive[f] cancels the additive expansion of f[.., x+y, ..].
UnAdditive[f->First] and UnAdditive[f->Last] cancel the additive expansion of the
first (last) argument of f."
SuperLie`AdditiveRule::usage =
"AdditiveRule[f] is the replacement rule f[..,x+y,..] -> f[..,x,..] + f[..,y,..].
AdditiveRule[f,First] and Additive[f,Last] are rules for additive expansion of the
first (last) argument of f."
SuperLie`Linear::usage = SuperLie`UnLinear::usage = (* SuperLie`LinearQ::usage = *)
"Linear[f] is the (multi)linearity of f."
SuperLie`LinearRule::usage =
"LinearRule[f] is the list of rules for expand f[expr] if \"f\"
is linear function."
SuperLie`LinearCollectRule::usage =
"LinearCollectRule[f] is the list of rules for collect together the term
in the sum f[x1,y1,..] + f[x2,y2,..]+... wich differe in one argument only,
there f is linear function."
SuperLie`Output::usage = SuperLie`UnOutput::usage =
"Output[v->f] defines the format of v[...] in OutputForm as f[v[...]].
The space constructor option Output->f defines the output format of the elements
of the space basis.
UnOutput[v] cancels the definition given by Output."
SuperLie`TeX::usage = SuperLie`UnTeX::usage =
"TeX[v->f] defines the format of v[...] in TeXForm as f[v[...]].
The space constructor option TeX->f defines the TeX output format of the elements
of the space basis.
UnTeX[v] cancels the definition given by TeX."
SuperLie`Standard::usage = SuperLie`UnStandard::usage =
"Standard[v->f] defines the format of v[...] in StandardForm as f[v[...]].
The space constructor option Standard->f defines the Standard output format of the elements
of the space basis.
UnStandard[v] cancels the definition given by Standard."
SuperLie`Traditional::usage = SuperLie`UnTraditional::usage =
"Traditional[v->f] defines the format of v[...] in TraditionalForm as f[v[...]].
The space constructor option Traditional->f defines the Traditional output format of the elements
of the space basis.
UnTraditional[v] cancels the definition given by Traditional."
(* ################## PART 3. Tools ###################### *)
SuperLie`MatchList::usage =
"MatchList[expr, ptrn] returns list of terms in \"expr\", matching the
pattern \"ptrn\".\n MatchList[expr, ptrn, f] returns the list of values of
f[term].";
SuperLie`WithUnique::usage =
"WithUnique[{symb..}, expr] evalutes expr replacing the listed symbols
with the new symbols with unique names."
SuperLie`UniqueCounters::usage =
"UniqueCounters[expr] return the expr with all counters in all sums and
tables replaced with unique symbols."
SuperLie`SimplifySignRule::usage =
"SimplifySignRule is the rule for simplifying (-1)^expression."
SuperLie`SimplifySign::usage =
"SimplifySign[expr] simplifies the (-1)^expo in the expr."
SuperLie`ArgForm::usage =
"ArgForm[\"controlstring\"][expr] prints as the text of the
controlstring, with the printed forms of the arguments of expr embedded."
SuperLie`SeqForm::usage =
"SeqForm[e1,...][h[a1,..]] prints the sequence e1,..., substituting
h, a1,... instead of placeholders #0, #1,... ."
(* ######### PART 4. Operations, Functions, Parameters ######### *)
SuperLie`FieldChar::usage =
"FieldChar[p] sets the characteristic of the base field, that may be zero or a prime number"
SuperLie`ModSolve::usage =
"ModSolve[eq, ...] solves scalar equations modulo $p (the characteristic of the base field).
The arguments are the same as for Solve"
SuperLie`DivPowers::usage = SuperLie`DivPowersQ::usage = SuperLie`UnDivPowers::usage =
"The property DivPowers[u] means that u^n and u[_]^n denote divided powers of u and u[_].
DivPowers[u->power] defines divided semantic for given \"power\" operation (e.g. exterior power)."
SuperLie`Dim::usage = "Dim[v] = dimension of the vector space v."
SuperLie`PDim::usage = "PDim[v] = {EvenDim,OddDim} is the dimension of the
vector superspace \"v\"."
SuperLie`FDim::usage = "FDim[v] returns dimension of the vector (super)space v
formatted for output"
SuperLie`PList::usage = "PList[v] stores the list of parities of the element
of the basis of the vector space v."
SuperLie`P::usage = "P[vect] is the parity of vect."
SuperLie`Parity::usage = SuperLie`Mixed::usage =
"Parity[vect] checks if vect is homogenious and returnt its parity.
For nonhomogenious vectors, and when checking fails, returns Mixed."
SuperLie`Plus2::usage = "Plus2[x,...] is a sum modulo 2"
SuperLie`Times2::usage = "Times2[x,...] is a product modulo 2"
SuperLie`Delta::usage =
"Delta[x,y] = 1 if x=y and =0 if x!=y; Delta[x] = Delta[x,0]."
SuperLie`Grade::usage =
"For graded object \"m\" value Grade[m[..]] is grading (degree)
of m[..]."
SuperLie`ToGrade::usage =
"ToGrade->g is an optional parameter for space constructors. It restricts the
calculations to the range from -g to +g (the range of generators must be given).
ToGrade[m] returns this limit. The results of operations in m are evaluated
only if its grade is berweein -ToGrade[m] and +ToGrade[m]."
SuperLie`Weight::usage = "Weight[v] is the weight of the homogeneous element \"v\"."
SuperLie`WeightMark::usage = "WeightMark[length, mark, ...] returns a list of given
length. All elements of the result are initially set to 0.
For every mark mi, if mi>0, the mi-th element of the result is increased by 1.
If mi<0, the (-mi)-th element is diminished by 1."
SuperLie`PolyGrade::usage = "PolyGrade[v] - weight range - is the weight of v in the
basis of primitive roots."
SuperLie`NewBracket::usage =
"NewBracket[op] defines op as the bracket in Lie superalgebra.
The options Parity and Grade declare the parity and the grade of the bracket"
SuperLie`Bracket::usage =
"Bracket[alg] is the name of the bracket operation in the Lie algebra."
SuperLie`bracket::usage =
"bracket[alg] is the name of unevaluated form of the bracket in Lie algebra."
SuperLie`BracketMode::usage = SuperLie`Regular::usage = SuperLie`Tabular::usage =
"BracketMode[md] is the method of the definition of the bracket operation
on the algebra or of the action of the algebra on the module. The value
of BracketMode[md] can be Regular or Tabular."
SuperLie`Operator::usage =
"If symb denotes the passive form of some operatot, Operator[symb] returns the name
of the active form of the same operator."
SuperLie`OpSymbol::usage =
"If symb denotes the active form of some operatot, OpSymbol[symb] returns the name
of the passive form of the same operator."
SuperLie`Act::usage = "Act[g,m] - the action of the element \"g\" on \"m\"."
SuperLie`act::usage =
"act[g,m] - the action of the element \"g\" on \"m\" (unevaluated)."
SuperLie`ActTable::usage =
"ActTable[g] is the table used to define the bracket on algebra g
if BracketMode[g] is Tabular. ActTable[g,m] is used to define the
action of g on m."
SuperLie`Squaring::usage =
"2*Squaring[x,bracket] = bracket[x,x] for odd x. This operation is defined independently
of the bracket so it is defined even for fields with characteristic 2."
SuperLie`SqrTable::usage =
"SqrTable[g] is the table used to define the squaring on algebra g
if BracketMode[g] is Tabular."
SuperLie`Deg::usage =
"Deg[times[...], x] is the degree of \"x\" in expression \"times[...]\"."
SuperLie`LDer::usage =
"LDer[expr, x, ptrn] is the left partial derivative of expression expr.
The pattern ptrn should match all independent and none dependent variables."
SuperLie`ZLDer::usage =
"ZLDer[x,ptrn][expr] is the left partial derivative of expression expr.
The pattern ptrn should match all independent and none dependent variables.
ZLDer[x,ptrn] may be used in symbolic calculations."
SuperLie`RDer::usage =
"RDer[expr, x, ptrn] is the right partial derivative of expression expr.
The pattern ptrn should match all independent and none dependent variables."
SuperLie`ZRDer::usage =
"ZRDer[x,ptrn][expr] is the right partial derivative of expression expr.
The pattern ptrn should match all independent and none dependent variables.
ZRDer[x,ptrn] may be used in symbolic calculations."
CircleTimes::usage = "v1 \[CircleTimes] v2 ... is the tensor product of the vectors."
Wedge::usage = "v1\[Wedge]v2\[Wedge]... is the exterior product of the vectors."
SuperLie`wPower::usage = "\!\(v\^\(\[Wedge]n\)\" is the n-th exterior power of vector v\"\)"
SuperLie`wedge::usage = "wedge[e1,...,en] is the internal representation of the basis of
exterior algebras. The external representation is e1\[Wedge]...\[Wedge]en."
SuperLie`Tp::usage =
"expr1 ** expr2 ** ... is the tensor product of expressions."
(* SuperLie`up::usage = "\"up\" is the multiplication in the enveloping algebra." *)
(* SuperLie`Id::usage = "Id is the unit element in tensor algebra" *)
SuperLie`ZId::usage = "ZId is the identity operator. Used in symbolical calculations."
SuperLie`Auto::usage = "Auto is the default value for some options"
SuperLie`CTimes::usage =
"CTimes[op] declares new \"Coefficient Times\" operation that may be used instead of **
between coefficient and vector parts of forms, vector fields, etc.
CTimes->op is an options that indicates such operation."
(* ########### PART 5. Space Constructors ############## *)
SuperLie`DecompositionList::usage =
"DecompositionList[g,f] returns the list of subalgebras in the decomposition
f of the algeba g."
SuperLie`DecompositionRule::usage =
"expr /. DecompositionRule[g,f] replaces the elements of the basis of g in
the expression expr with their images under decomposition f."
SuperLie`CartanTriade::usage =
"CartanTriade is the decomposition of algebras in 3 subalgebras:
g -> {g+, g0, g-} (the components of positive, null and negative weight)"
SuperLie`NGen::usage = "NGen[g] is the number of generators of the \"g\""
(*SuperLie`UEBasis::usage =
"UEBasis[alg] builds a graded basis of the Enveloping Algebra of the
given graded algebra \"alg\"."*)
Unprotect[General]
General::novect = "`` is not a vector. Replaced with 0."
General::novl = "`` is not vector or list of vectors."
Protect[General]
(* --------- Debug tools -------------- *)
SuperLie`$DPrint::usage = SuperLie`DPrint::usage =
"DPrint[level, data...] prints data (using Print) if $DPrint>=level."
SuperLie`$DPrintLabel::usage =
"The value of $DPrintLabel[] is printed as a label for debug printing.
Use $DPrintLabel=DateString or TimeString to use [date and] time as label.
Use $DPrintLabel=None for debug printing without labels."
If [$VersionNumber < 6,
DateString::usage =
"DateString[] return a string representing the current date and time."]
SuperLie`TimeString::usage =
"TimeString[] return a string representing the current time."
Begin["$`"] (* =============================== Private ========== *)
(*
VariantFirst[def_, var_] :=
With[{hdef=HoldPattern[def], hvar=HoldPattern[var]},
With[{head=hdef[[1,0]]},
With[{rule=Select[DownValues[head], #[[1]]===hdef&][[1]]},
Append[ DownValues[head],
rule /.
{Verbatim[hdef] ->hvar,
All->First,
f_[Verbatim[$`x___],rest___]:>f[rest],
f_[$`x,rest___]:>f[rest]}]]]]
*)
(* ----------- PROPERTY : ZeroArg ------------ *)
With[{wrapper=If[$VersionNumber>=3.0, HoldPattern, Literal]},
ZeroArgRule[f_] := ( wrapper[f[x___, 0, y___]] -> 0 );
ZeroArgRule[f_, First] := ( wrapper[f[0, y___]] -> 0 );
ZeroArgRule[f_, Last] := ( wrapper[f[x___, 0]] -> 0 );
]
NewProperty[ ZeroArg, {Rule} ]
(* ----------- PROPERTY : IdArg ------------ *)
(*
With[{wrapper=If[$VersionNumber>=3.0, HoldPattern, Literal]},
IdArgRule[f_] := ( wrapper[f[x___, Id, y___]] :> f[x,y] )]
NewProperty[ IdArg, {Rule} ]
*)
(* ----------- PROPERTY : Homogen ------------- *)
With[{wrapper=If[$VersionNumber>=3.0, HoldPattern, Literal]},
HomogenRule[f_,First,deg_:1] :=
{With[ {times = STimesOp[Domain[f]]},
Switch[deg,
1, wrapper[f[SVTimes[c_,v_], y___]] :> c ~times~ f[v,y],
0, wrapper[f[(SVTimes|VIf)[c_,v_], y___]] :> f[v,y],
_, wrapper[f[SVTimes[c_,v_], y___]] :> (c^deg) ~times~ f[v,y]
] ],
With[ {if = CondOp[Domain[f]]},
If[if=!=None && deg=!=0,
wrapper[f[VIf[c_,v_], y___]] :> if[c, f[v,y]],
(*else*) Unevaluated[]
] ]
};
HomogenRule[f_,Last,deg_:1] :=
{With[ {times = STimesOp[Domain[f]]},
Switch[deg,
1, wrapper[f[x___, SVTimes[c_,v_]]] :> c ~times~ f[x,v],
0, wrapper[f[x___, (SVTimes|VIf)[c_,v_]]] :> f[x,v],
_, wrapper[f[x___, SVTimes[c_,v_]]] :> (c^deg) ~times~ f[x,v]
] ],
With[ {if = CondOp[Domain[f]]},
If[if=!=None && deg=!=0,
wrapper[f[x___, VIf[c_,v_]]] :> if[c, f[x,v]],
(*else*) Unevaluated[]
] ]
};
HomogenRule[f_,{arg___}] := HomogenRule[f,arg];
HomogenRule[f_,deg_:1] :=
{With[ {times = STimesOp[Domain[f]]},
Switch[deg,
1, wrapper[f[x___, SVTimes[c_,v_], y___]] :> c ~times~ f[x,v,y],
0, wrapper[f[x___, (SVTimes|VIf)[c_,v_], y___]] :> f[x,v,y],
_, wrapper[f[x___, SVTimes[c_,v_], y___]] :> (c^deg) ~times~ f[x,v,y]
] ],
With[ {if = CondOp[Domain[f]]},
If[if=!=None && deg=!=0,
wrapper[f[x___, VIf[c_,v_], y___]] :> if[c, f[x,v,y]],
(*else*) Unevaluated[]
] ]
}
]
HomogenPowerOp[f_,deg_:1] := With[ {pw = PowerOp[f]}, If[pw=!=None, HomogenPower[pw->deg]]]
UnHomogenPowerOp[f_,deg_:1] := With[ {pw = PowerOp[f]}, If[pw=!=None, UnHomogenPower[pw->deg]]]
With[{wrapper=If[$VersionNumber>=3.0, HoldPattern, Literal]},
HomogenPowerRule[pw_,deg_:1] :=
With[ {times = STimesOp[Domain[pw]]},
wrapper[pw[times[c_,v_], n_]] :> times[Power[c,n*deg], pw[v,n]]]]
NewProperty[Homogen, {Rule, Also->HomogenPowerOp}]
NewProperty[HomogenPower, {Rule}]
(* ------------ PROPERTIES : Symmetric, SkewSymmetric ------------ *)
SymmetricRule[op_] = genSymmetricRule[op,1,0]
SkewSymmetricRule[op_] = genSymmetricRule[op,1,1]
AntiSymmetricRule[op_] = genSymmetricRule[op,-1,0]
AntiSkewSymmetricRule[op_] = genSymmetricRule[op,-1,1]
With[{wrapper=If[$VersionNumber>=3.0, HoldPattern, Literal]},
genSymmetricRule[op_,sign_,skew_] :=
With[{pw = PowerOp[op], stimes=STimesOp[Domain[op]],
asym=If[sign>0, 1-skew,skew]},
If [pw===None,
{ wrapper[ op[args___ /; !OrderedQ[{args}]] ] :>
(SuperSignature[{args}, sign, skew] //. SimplifySignRule) ~stimes~
Sort[Unevaluated[op[args]]],
wrapper[op[___, x_/;P[x]==asym, x_, ___]] :> 0
},
(*else*)
With [{ord = OrderedQ[#/.pw[a_,_]:>a]&},
{ wrapper[ op[args___ /; !ord[{args}]] ] :>
(SuperSignature[{args}, sign, skew, ord] //. SimplifySignRule)
~stimes~ Sort[Unevaluated[op[args]],ord[{#1,#2}]&],
wrapper[ (x_/;P[x]==asym)~pw~(n_/;n!=1&&n!=-1)] :> 0
} ]
]
]
]
Attributes[SuperSignature] = {HoldFirst}
SuperSignature[arg_,sign_,skew_,ord_:OrderedQ] :=
Block[{ssgn=1, pplist},
pplist = P /@ arg;
If [skew=!=0, pplist = 1 - pplist];
Do [If [!ord[arg[[{i,j}]]],
ssgn *= sign*(-1)^(pplist[[i]]*pplist[[j]])],
{j,2,Length[pplist]}, {i, j-1}
];
ssgn
]
NewProperty[Symmetric, {Rule,Flag}]
NewProperty[SkewSymmetric, {Rule,Flag}]
NewProperty[AntiSymmetric, {Rule,Flag}]
NewProperty[AntiSkewSymmetric, {Rule,Flag}]
Symmetric[v_] := True /;
Which[SkewSymmetricQ[v], UnSkewSymmetric[v]; False,
AntiSymmetricQ[v], UnAntiSymmetric[v]; False,
AntiSkewSymmetricQ[v], UnAntiSkewSymmetric[v]; False,
SymmetricQ[v], True,
True, False]
AntiSymmetric[v_] := True /;
Which[SkewSymmetricQ[v], UnSkewSymmetric[v]; False,
AntiSymmetricQ[v], True,
AntiSkewSymmetricQ[v], UnAntiSkewSymmetric[v]; False,
SymmetricQ[v], UnSymmetric[v]; False,
True, False]
SkewSymmetric[v_] := True /;
Which[SkewSymmetricQ[v], True,
AntiSymmetricQ[v], UnAntiSymmetric[v]; False,
AntiSkewSymmetricQ[v], UnAntiSkewSymmetric[v]; False,
SymmetricQ[v], UnSymmetric[v]; False,
True, False]
AntiSkewSymmetric[v_] := True /;
Which[SkewSymmetricQ[v], UnSkewSymmetric[v]; False,
AntiSymmetricQ[v], UnAntiSymmetric[v]; False,
AntiSkewSymmetricQ[v], True,
SymmetricQ[v], UnSymmetric[v]; False,
True, False]
(* ------------------ PowerOp -------------------- *)
PowerOp[_] = None;
PowerOp[op_->powerop_] :=
( PowerOp[op] ^= powerop;
powerop/: Domain[powerop, First] = Domain[powerop] ^= Domain[op];
powerop/: Domain[powerop, Last] = Scalar;
Default[powerop, 2] := 1;
Attributes[powerop] = {Listable, OneIdentity};
powerop[x_,0] := Evaluate[ op[] ];
powerop[x_,1] := x;
powerop[powerop[x_,k_],l_] := (* the outer power is NEVER divided *)
If[DivPowersQ[x,powerop],
SVTimes[Product[Binomial[i*k,k],{i,l}], powerop[x, k*l]],
powerop[x, k*l]];
If [op=!=Wedge,
op[y___,x_~powerop~(n1_.), x_~powerop~(n2_.),z___] :=
If[DivPowersQ[x,powerop],
Binomial[n1+n2,n1] ~SVTimes~ op[y,x~powerop~(n1+n2),z],
op[y,x~powerop~(n1+n2),z]]];
powerop[op[],n_] := op[];
powerop[0,n_/;n>0] := 0;
If[DegTimesQ[op], DegPowerQ[powerop]^=True];
If[GradedQ[op], GradedPwQ[powerop]^=True];
P[powerop[x_, n_]] ^:= PolynomialMod[P[x]*n, 2];
With[{asym=Which[SymmetricQ[op]||AntiSkewSymmetricQ[op], 1,
AntiSymmetricQ[op]||SkewSymmetricQ[op], 0]},
If[NumberQ[asym],
(x_/;P[x]==asym)~powerop~(n_/;n!=1&&n!=-1) := 0]]
)
NewValue[PowerOp];
PolyPattern[times_, ptrn_]:=
With[{power=PowerOp[times]},
If [power===None,
ptrn|times[ptrn...],
power[ptrn,_.] | times[(power[ptrn,_.])...]
]]
(* ------------------ SumOp -------------------- *)
SumOp[_] = None;
SumOp[op_->sumop_] :=
( SumOp[op] ^= sumop;
Attributes[sumop] = {HoldAll,OneIdentity};
SetProperties[sumop, {Domain[op], Domain[op]->First, ZeroArg->First}];
sumop[f_] := Unevaluated[f];
sumop[f_, it1___,iter:{_,bnd__/;(NumberQ/@Unevaluated[And[bnd]])},it2___] :=
sumop[ Evaluate[op @@ Table[sumop[f, it2],iter], it1]];
sumop[f_,it1___,{i_,from_->to_},it2___] :=
With [{diff = Expand[to-from]},
Which [ TrueQ[diff>0],
Evaluate[sumop[f, it1, Evaluate[{i,from,to-1}],it2]],
TrueQ[diff<0],
Evaluate[STimesOp[Domain[op]] [-1,
sumop[f, it1, Evaluate[{i,to,from-1}],it2]]],
TrueQ[diff==0], 0
] /; NumberQ[diff]
]
)
NewValue[SumOp];
(* ------------------ CondOp -------------------- *)
CondOp[_] = None;
CondOp[dmn_->if_] :=
( CondOp[dmn] ^= if;
Attributes[if] = {HoldRest};
SetProperties[if, {dmn, dmn->Last, ZeroArg->Last}];
if[True, v_] := v;
if[False, _] = 0;
Default[if, 1] ^= True;
)
NewValue[CondOp];
(* ---------- PROPERTIES : Leibniz and Jacobi ------------- *)
Leibniz::par = "No parity of `` defined. Assumed 0."
LeibnizExpandPower[f_[prm___,power_[v_,n_]], times_] :=
If[DivPowersQ[v,power],
f[prm,v] ~times~ power[v,n-1],
n ~SVTimes~ (f[prm,v] ~times~ power[v,n-1])]
LeibnizExpand[ f_[prm___,expr_], par_ ] :=
Module [{ m, fm, s=1, s1, ph=P[Head[expr]] },
If[!NumberQ[ph],
Message[Leibniz::par, Head[expr]];
ph = 0];
VPlus @@ Table[
m = expr[[i]];
s1 = s;
s *= (-1)^(par~Times~(P[m]+ph));
If [(fm = f[prm,m])===0, 0,
(*else*) s1 ~SVTimes~ ReplacePart[expr, fm, i]
],
(*sum index*) { i, Length[expr]}
]
]
LeibnizExpand[ f_[prm___,expr_], 0 ] :=
Module [{ m, fm },
VPlus @@ Table[
m = expr[[i]];
If [(fm = f[prm,m])===0, 0,
(*else*) ReplacePart[expr, fm, i]
],
(*sum index*) { i, Length[expr]}
]
]
Attributes[LeibnizRule] = {Listable}
With[{wrapper=If[$VersionNumber>=3.0, HoldPattern, Literal]},
LeibnizRule[f_, g_] :=
{ wrapper[f[expr_g]] :> LeibnizExpand[Unevaluated[f[expr]], P[f]],
With[{power=PowerOp[g]},
If [power===None, Unevaluated[],
(*else*) wrapper[f[expr_power]] :>
LeibnizExpandPower[ Unevaluated[f[expr]], g ]
]
]
};
JacobiRule[f_, g_] :=
{ With[{pf=P[f], fn=LeibnizExpandFn[g]},
Which[
!NumberQ[pf],
Message[Leibniz::par, f];
wrapper[f[any_, expr_g]] :> fn[Unevaluated[f[any,expr]], P[any]],
pf===0,
wrapper[f[any_, expr_g]] :> fn[Unevaluated[f[any,expr]], P[any]],
True,
wrapper[f[any_, expr_g]] :> fn[Unevaluated[f[any,expr]], P[any]+pf]]],
With[{power=PowerOp[g]},
If [power===None,
Unevaluated[],
(*else*)
wrapper[f[any_, expr_power]] :>
LeibnizExpandPower[ Unevaluated[f[any, expr]], g ]
]
]
}
]
LeibnizExpandFn[_] = LeibnizExpand
LeibnizRule[f_, g_List] := Join @@ (LeibnizRule[f, #]& /@ g)
JacobiRule[f_, g_List] := Join @@ (JacobiRule[f, #]& /@ g)
NewProperty[ Leibniz, {Rule} ]
(*NewProperty[ Jacobi, {TagRule} ]*)
Jacobi[fn_->op_] :=
(AutoRule[Unevaluated[JacobiRule[fn,op][[1]]], op];
With[{power=PowerOp[op]},
If [power=!=None,
AutoRule[Unevaluated[JacobiRule[fn,op][[2]]], power]]];
Rules[fn] ^= Union[Rules[fn], {HoldForm[JacobiRule[fn,op]]}])
Jacobi[fn_->op_List] := (Jacobi[fn->#]& /@ op; Rules[fn])
UnJacobi[fn_->op_] :=
(UnAutoRule[JacobiRule[fn,op][[1]]];
With[{power=PowerOp[op]},
If [power=!=None,UnAutoRule[JacobiRule[fn,op][[2]]]]];
Rules[fn] ^= Complement[Rules[fn], {HoldForm[JacobiRule[fn,op]]}])
UnJacobi[fn_->op_List] := (UnJacobi[fn->#]& /@ op; Rules[fn])
(* ---- PROPERTIES : Graded, ThreadGraded, TestFirst, LogPower ---- *)
With[{wrapper=If[$VersionNumber>=3.0, HoldPattern, Literal]},
ThreadGradedRule[func_, add_] :=
wrapper[func[(hd_?GradedQ)[ff___]]] :> func /@ Unevaluated[add[ff]];
ThreadGradedRule[func_] :=
With[{add=PlusOp[Domain[func]],times=STimesOp[Domain[func]]},
{wrapper[func[(hd_?GradedQ)[ff___]]] :> func /@ Unevaluated[add[ff]],
wrapper[func[(hd_?GradedPwQ)[e_,n_]]] :> times[n,func[e]]}];
TestFirstRule[func_] :=
wrapper[func[expr_VPlus]] :> func[First[expr]];
LogPowerRule[func_, times_] :=
wrapper[func[VPower[x_,p_]]] :> p ~times~ func[x];
LogPowerRule[func_] :=
wrapper[func[VPower[x_,p_]]] :> p ~(TimesOp[Domain[func]])~ func[x]
]
NewProperty[Graded]
NewProperty[GradedPw]
NewProperty[ThreadGraded, {Rule} ]
NewProperty[TestFirst, {Rule}]
NewProperty[LogPower, {Rule}]
DegTimes[op_]:=
(DegTimesQ[op]^=True;
With[{pw=PowerOp[op]},If[pw=!=None,DegPowerQ[pw]^=True]];
)
DegTimes[op_, ops__] := Scan[DegTimes, {op, ops}]
UnDegTimes[op_]:=
(op/:DegTimesQ[op]=.;
With[{pw=PowerOp[op]},If[pw=!=None,pw/:DegPowerQ[pw]=.]];
)
UnDegTimes[op_, ops__] := Scan[UnDegTimes, {op, ops}]
(* ============ DOMAIN : Scalar =============== *)
tmp$ = Unprotect[Plus, Times, Power, Expand, Sum, DirectedInfinity]
Operation[ Plus, GPlus[Scalar..]->Scalar ]
Operation[ Times, GTimes[Scalar..]->Scalar ]
Operation[ Power, GPower[Scalar, Scalar]->Scalar ]
(*UnitElement[Scalar] ^= 1;*)
STimesOp[Scalar] ^= Times
PlusOp[Scalar] ^= Plus
PowerOp[Times] ^= Power
SumOp[Plus] ^= Sum
Scalar[Sum]
CondOp[Scalar] ^= If
ScalarQ[DirectedInfinity] ^= True
Sum[f_, {i_,v_/;!NumberQ[v],n_Integer}, iter___] := - Sum[f,{i,n,v},iter]
Sum[f_,{i_,from_->to_},iter___] :=
With [{diff = Expand[to-from]},
Which [ TrueQ[diff>0], Sum[f,{i,from,to-1},iter],
TrueQ[diff<0], - Sum[f,{i,to,from-1},iter],
TrueQ[diff==0], 0,
NumberQ[from], Sum[f,{i,from,to-1},iter],
NumberQ[to], - Sum[f,{i,to,from-1},iter],
True, Sum[f,{i,to-1},iter] - Sum[f,{i,from-1},iter]