-
Notifications
You must be signed in to change notification settings - Fork 0
/
grgclass.sl
1080 lines (991 loc) · 37.2 KB
/
grgclass.sl
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
%==========================================================================%
% GRGclass.sl Assignment, Macro Functions, Classification %
%==========================================================================%
% GRG 3.2 Standard Lisp Source Code (C) 1988-96 Vadim V. Zhytnikov %
%==========================================================================%
% This file is distributed without any warranty. You may modify it but you %
% are not allowed to remove author's name and/or distribute modified file. %
%==========================================================================%
%------- Assignment Command 09.91,03.94 -------------------------------
%
% Assignment Command in forms
% Tetrad T0=..., ...;
% Tetrad T(j)=..., ...;
% T(j)=..., ...;
% T0=..., ...;
%
(de seti!> (lst)
(prog (w wl wa wr was)
(setq ![newabbr!] nil)
(setq w (seek!> lst '(!=)))
(cond ((or (null w) (null(car w)) (null(cdr w)))
(prog2 (setq ![er!] 2204) (return !!er!!))))
(setq wa (car w))
(setq wl (length wa))
(cond
((or (eqn wl 1) % t0 = ...
(and(eqn wl 2)(pairp(car wa)))) % t(j) = ...
(progn
(setq wa(cond((eqn wl 1) (car wa))
(t (cadr wa))))
(cond((not(idp wa))
(prog2(setq ![er!] 2204)(return !!er!!))))
(setq was wa)
(setq wa (explode2 wa))
(cond((eqn wl 1)(setq wr(selid!> wa nil))))
(setq wa(incomiv!> wa))
(cond((not(flagp wa '!+ivar))
(cond
(wr(progn(doub!> was)(setq ![er!] 8604)(return !!er!!)))
((or(flagp wa '!+grgmac)(gettype!> wa))
(progn(doub!> was)(setq ![er!] 3000)(return !!er!!)))
(t(progn
(cond((flagp was '!+grg)(prog2(doub!> was)(msg!> 8603))))
(setq ![abbr!] (cons wa ![abbr!]))
(setq ![newabbr!] wa)
(global (ncons wa))
(flag (ncons wa) '!+ivar)
(flag (ncons wa) '!+abbr))))))
(return(datr!> lst wa)))) % ---> datr> ...
((atom(car wa))(prog2
(setq w(cons(car wa)(cdr w)))
(setq wa(cdr wa))))
(t (prog2 (setq w(cons(cadr wa)(cons(car wa)(cdr w))))
(setq wa(cddr wa)))))
(setq wa(reverse wa))
(setq was wa)
(setq wa (assocf!> wa ![datl!]))
(cond((or(null wa)(pairp(car wa)))
(progn(setq ![er!] 6030)(doubl!> was)(return !!er!!))))
(setq wa(car wa))
(return(datr!> w wa)))) % ---> datr> ...
% 03.94, 05.96 ... WN - Internal Variable, LST - Text
(de datr!> (lst wn)
(proc (w wl wr ww)
(cond ((null lst) (return nil))
((setq w (constrp!> wn)) % constrained!
(progn (doubo!> wn) (setq ![er!] w) (return !!er!!))))
(setq lst (memlistbr!> '!, lst))
(cond ((eq lst !!er!!) (prog2 (setq ![er!] 2202) (return !!er!!))))
(while!> lst
(setq w (seek1!> (car lst) '!=))
(cond((or (null w) (null(car w)) (null(cdr w)))
(prog2 (setq ![er!] 2204) (return !!er!!))))
(setq wl (reverse (car w)))
(setq wr (cdr w))
(cond((or (not(idp(car wl)))
(and (cdr wl) (not(pairp(cadr wl))))
(greaterp (length wl) 2))
(prog2 (setq ![er!] 2204) (return !!er!!))))
(setq ww
(cond ((cdr wl) (transi!> wn wl wr))
(t (trans!> wn (car wl) wr))))
(cond ((eq ww !!er!!) (cond (![newabbr!] (forget1!> ![newabbr!])))
(return !!er!!)))
(cond
((eq wn '!#!G) (mtype!>))
((eq wn '!#!G!I) (mitype!>))
((eq wn '!#!T) (ftype!>))
((eq wn '!#!D) (fitype!>)))
(setq lst (cdr lst)) )))
% Normal Form ...
% 11.94 ... WN Internal var, WL Left, WR Right
(de trans!> (wn wl wr)
(prog (wi wc)
(cond((and (flagp wn '!+equ) (not(memq '!= wr)))
(prog2 (setq ![er!] 2208) (return !!er!!))))
(setq wi (get wn '!=idxl)) % index types list
(setq wc (transn!> wl wn wi)) % id = ... translation
(cond ((eq wc !!er!!) (return !!er!!)))
(return (trans0!> wn wc wr)) ))
% 11.94 ... WN Internal var, WL indices, WR Right
(de trans0!> (wn wc wr)
(prog (wss wi wt we wnn)
(setq wss (get wn '!=sidxl)) % symmetry list
(setq wi (get wn '!=idxl)) % index types list
(setq wt (gettype!> wn)) % expression type
(cond((null(eval wn)) % prepare space for storing if not exists
(prog2(setq wnn t)(set wn (mkbox!> wn)))))
(cond (wc (setq wc (syaidx!> wc wss))))
(cond((and wi (null wc)) (return nil)))
(setq wr (cschtr!> wr (flagp wn '!+equ)))
(setq ![extvar!] nil)
(cond((flagp wn '!+equ) (setq we (translateeq!> wr))) % expr translation
(t (setq we (translate!> wr))))
(cond ((equal we !!er!!)
(cond (wnn (set wn nil)))
(return !!er!!))
((null we)
(cond ((null wt) (put wn '!=type 0))))
((null wt)
(setq wt (car we))
(put wn '!=type wt))
((not(eqn wt (car we))) % incorrect expression type
(cond(wnn(set wn nil)))
(expects!> wt)
(setq ![er!] 2100) (return !!er!!)))
% storing of the data component
(putel!> (cond(we(cdr we))(t nil)) (eval wn) (cond(wc wc)(t '(0))))
(return t)))
% Perform Sign Changing [CS] and Complex Conjugations [CH] ...
(de cschtr!> (wr we)
(cond((and ![ch!] ![cs!])
(cond (we (progn (setq wr (seek1!> wr '!=))
(list (csch0!>(reverse(car wr))) (csch0!>(cdr wr)))))
(t (csch0!> wr))))
(![cs!]
(cond (we (progn (setq wr (seek1!> wr '!=))
(list (cs0!>(reverse(car wr))) (cs0!>(cdr wr)))))
(t (cs0!> wr))))
(![ch!]
(cond (we (progn (setq wr (seek1!> wr '!=))
(list (ch0!>(reverse(car wr))) (ch0!>(cdr wr)))))
(t (ch0!> wr))))
(t wr)))
% aux functions ...
(de cs0!> (w) (list2 '!- (ncons w)))
(de ch0!> (w) (list2 '!~ (ncons w)))
(de csch0!> (w) (list '!- '!~ (ncons w)))
% Message about wrong type of the expression ...
(de expects!> (wt)
(progn
(cond((eqn wt 0) (prin2 "Algebraic expression"))
((eqn wt -1) (prin2 "Vector"))
(t (prin2 wt) (prin2 "-form")))
(prin2 " is expected.")
(terpri)))
% w - id = ... wn - internal variable wi - index types list
(de transn!> (w wn wi)
(prog(wa wb wc wd wl wf)
(setq wb(explode2 w))
(setq wa(cdr(explode2 wn)))
(setq wf(selid!> wb nil)) % wb - id wf - indices
(cond((not(equal wb wa))
(progn(expid!> wa)(setq ![er!] 2101)(return !!er!!))))
(cond((null wf)(cond((null wi)(return nil)) % scalar data ...
(t(prog2(setq ![er!] 2102)(return !!er!!))))))
(setq wf (mapcar wf 'digorerr!>))
(cond((memq !!er!! wf)
(prog2(setq ![er!] 2102)(return !!er!!))))
(cond ((eq (goodidxl!> wf wi) !!er!!) (return !!er!!)))
(return wf)))
% aux fun ...
(de digorerr!> (w)
(cond((digit w)(compress (ncons w)))
(t !!er!!)))
% w is expected ...
(de expid!> (w)
(progn (mapc w 'prin2)
(prin2 " is expected.")
(terpri)))
% Verifies correct range of indices ...
(de goodidxl!> (wb wi)
(cond ((and (null wb) (null wi)) t)
((null wb) (setq ![er!] 21023) !!er!!)
((null wi) (setq ![er!] 21024) !!er!!)
((lessp (dimid!>(car wi) )(car wb)) (setq ![er!] 21022) !!er!!)
(t (goodidxl!> (cdr wb) (cdr wi)))))
% Verifies correct range the index ...
(de goodid1!> (w wt)
(cond((lessp(dimid!> wt)w) nil)
(t t)))
% Tensorial Form ...
% WN - Internal Variable WL - Left WR - Right
(de transi!> (wn wl wr)
(proc (wt wi w wll wa wii)
(setq wll(cons nil(get wn '!=idxl)))
(setq wt (car wl))
(setq wi (cadr wl))
(setq wt (explode2 wt))
(cond((not(equal wt(cdr(explode2 wn))))
(progn(expid!>(cdr(explode2 wn)))
(setq ![er!] 2101)(return !!er!!))))
(setq wi(memlist!> '!, wi))
(cond((eq wi !!er!!) (prog2(setq ![er!] 2202)(return !!er!!))))
(cond((not(eqn(length wi)(length(get wn '!=idxl))))
(prog2 (cond (![newabbr!] (doubo!> ![newabbr!])
(setq ![er!] 22071))
(t (setq ![er!] 2207)))
(return !!er!!))))
(setq wii nil)
(while!> wi
(setq wii
(cons (prog2 (setq wll(cdr wll)) (sumintr!> (car wi) (car wll)))
wii))
(setq wi (cdr wi)))
(setq wi (reverse wii)) % here now the list of indices in lhs
(cond((memq !!er!! wi)(return !!er!!)))
(setq ![extvar!] (mkextvars!> wi)) % prepare list of ext. vars.
(cond((memq !!er!! ![extvar!]) (return !!er!!))
((null ![extvar!]) % only numerical indices ...
(return (trans0!> wn (mklitind!> wi) wr))))
(cond((flagp wn '!+equ)(setq wr (pretranseq!> wr))) % pre translation
(t (setq wr (pretrans!> wr))))
(cond((eq wr !!er!!)(return !!er!!)))
(setq ![idl!] wi) (setq ![texpr!] wr)
(setq w(cond((null(eval wn))(mkbox!> wn))
(t(eval wn))))
(setq w (errorset!> (list 'allcoll!> (list 'quote w)
(list 'quote wn)
nil
(list 'quote (get wn '!=idxl))
(list 'function 'transel!>)
) ![erst1!] ![erst2!] ))
(remsubindex!> ![idl!])(setq ![texpr!] nil)
(cond((atom w)(prog2(setq ![er!] w)(return !!er!!)))
(t(set wn(car w))))
(return t)))
% Prepare List of Ext. vars ...
(de mkextvars!> (lst)
(cond((null lst) nil)
((atom(car lst))(consmemer!>(car lst)(mkextvars!>(cdr lst))))
(t(appmemer!>(car lst)(mkextvars!>(cdr lst))))))
(de appmemer!> (wa wb)
(prog2 (while!> wa
(setq wb (consmemer!> (car wa)wb))
(setq wa (cdr wa)))
wb))
(de consmemer!> (w lst)
(cond((and(idp w)(memq w lst))
(prog2(setq ![er!] 2205)(cons !!er!! lst)))
((idp w) (cons w lst))
(t lst)))
(de mklitind!> (lst)
(mapcar lst 'mklitind1!>))
(de mklitind1!> (w)
(cond ((numberp w) w)
(t (eval(cons 'plus w)))))
% Translate the element ...
(de transel!> (lst wi wn)
(cond((and (syaidxp!> wi (get wn '!=sidxl))
(coidxp!> wi ![idl!]) )
(progn
(putindex!> wi)
(cond((flagp wn '!+equ)(setq lst(unievaluateeq!> ![texpr!])))
(t (setq lst(unievaluate!> ![texpr!]))))
(remsubindex!> ![idl!])
(cond((null(gettype!> wn))(put wn '!=type (car lst))))
(cond((and lst(not(eqn(car lst)(gettype!> wn))))
(prog2 (expects!>(gettype!> wn))
(err!> 2100))))
(cond(lst(cdr lst))
(t nil))))
(t lst)))
% Summed index treatment if exists ...
(de sumintr!> (w wl)
(cond((atom wl) % tetrad or holonomic index
(cond((or(cdr w)(not(or(idp(car w))(numberp(car w)))))
(prog2(setq ![er!] 2206) !!er!!))
((and(numberp(car w))(not(goodid1!>(car w)wl)))
(prog2(setq ![er!] 21022) !!er!!))
(t(car w))))
((null(cdr w)) % spinor or enumerating index
(cond((not(or(idp(car w))(numberp(car w))))
(prog2(setq ![er!] 2206) !!er!!))
((and(numberp(car w))(not(goodid1!>(car w)wl)))
(prog2(setq ![er!] 21022) !!er!!))
(t(car w))))
(t(prog nil % summed spinor index
(setq w(memlist!> '!+ w))
(cond((or(eq w !!er!!)(not(eqn(length w)(dimid!> wl))))
(prog2(setq ![er!] 2206) (return !!er!!))))
(setq w (mapcar w 'auxfun1!>))
(cond((memq !!er!! w)
(prog2(setq ![er!] 2206)(return !!er!!)))
(t(return w)))))))
(de auxfun1!> (w)
(cond((or (cdr w) (and (not(idp(car w))) (not(numberp(car w)))))
!!er!!)
((and (numberp(car w)) (greaterp(car w)1)) !!er!!)
(t(car w))))
% Compares current list of indices WI with concrete values in WL ...
(de coidxp!> (wi wl)
(cond((and(null wi)(null wl)) t)
(t(and (coidxp1!> (car wi)(car wl))
(coidxp!> (cdr wi)(cdr wl))))))
(de coidxp1!> (wi wl)
(cond((numberp wl)
(cond((eqn wi wl)t)
(t nil)))
((pairp wl)
(prog2 (setq wl (putindex2!> wl))
(cond((or (lessp wi (car wl))
(lessp(length(cdr wl))(difference wi (car wl))))
nil)
(t t))))
(t t)))
% Preparing Ext. vars for translator ...
(de putindex!> (wi)
(proc(w)
(setq w ![idl!])
(while!> wi
(cond((numberp(car w)) nil)
((atom(car w))(put (car w) '!=subind (car wi)))
(t(putindex1!> (car w) (car wi))))
(setq w(cdr w)) (setq wi(cdr wi)))))
(de putindex1!> (wa wb)
(proc nil
(setq wa (putindex2!> wa))
(setq wb (difference wb (car wa)))
(setq wa (cdr wa))
(setq wb (add1 wb))
(while!> wa
(put (car wa) '!=subind
(cond((lessp(length wa)wb) 1)
(t 0)))
(setq wa(cdr wa)))))
(de putindex2!> (w)
(proc (wn wr)
(setq wn 0)
(while!> w
(cond
((numberp(car w)) (setq wn (plus wn (car w))))
(t(setq wr (cons(car w)wr))))
(setq w (cdr w)))
(return(cons wn (reversip wr)))))
% Removing Ext. vars. after translation ...
(de remsubindex!> (w)
(cond((null w) nil)
((pairp(car w))
(prog2 (remsubindex!>(car w)) (remsubindex!>(cdr w))))
((idp(car w))(prog2
(remprop (car w) '!=subind)
(remsubindex!>(cdr w))))
(t(remsubindex!>(cdr w)))))
%----- Macro Functions. 08.01.91, 05.96 -------------------------------
% Solution ...
(de getsoln!> (lst)
(cond((cdr lst) (prog2(doub!> '!S!o!l)(err!> 2105)))
((null(car lst)) (getsoln1!> 0))
((not(zerop(caar lst))) (prog2(doub!> '!S!o!l)(err!> 2023)))
((not(numberp(cdar lst))) (prog2(doub!> '!S!o!l)(err!> 2106)))
(t(getsoln1!> (cdar lst)))))
(de getsoln1!> (wn)
(cond((null ![sol!]) (err!> 2113))
(t(proc (w wnn)
(setq wnn wn)
(setq w ![sol!])
(while!> (and w (not(zerop wn)))
(setq w (cdr w))
(setq wn (sub1 wn)))
(cond((or(null w)(not(zerop wn)))
(prog2 (doub!> wnn) (err!> 2114))))
(return(cona1!> 0 (get1equ!>(car w))))))))
%----- Classify command 06.96 ------------------------------------------
(de classify!> (lst)
(proc (w wc wi)
(cond ((null lst) (return nil)))
(cond ((eq (setq w (dgood!> lst)) !!er!!) (return !!er!!)))
(setq w (altdata!> w))
(while!> w
(setq wc (car w))
(cond
((not(zerop(get wc '!=type)))
(setq ![er!] 9100) (doubo!> wc) (return !!er!!))
((null(eval wc))
(abse!> wc) (go lab)))
(setq wi (get wc '!=idxl))
(cond
((null wi) (cmsg!> wc) (scaltype!> (eval wc)))
((eqn (length wi) 1)
(cond
((eqn (dimid!> (car wi)) 2) (cmsg!> wc) (emtype!> (eval wc)))
((eqn (dimid!> (car wi)) 4) (cmsg!> wc) (petrov!> (eval wc)))
(t (setq ![er!] 9101) (doubo!> wc) (return !!er!!))))
((eqn (length wi) 2)
(cond
((and (eqn (dimid!> (car wi)) 2) (eqn (dimid!> (cadr wi)) 2))
(cmsg!> wc) (riccisclass!> (eval wc)))
((and (eqn (dimid!> (car wi)) 1) (eqn (dimid!> (cadr wi)) 1))
(cmsg!> wc) (vectype!> (eval wc)))
(t (setq ![er!] 9101) (doubo!> wc) (return !!er!!))))
(t (setq ![er!] 9101) (doubo!> wc) (return !!er!!)))
lab
(setq w (cdr w)))))
(de cmsg!> (w)
(progn (gprinreset!>)
(gprils!> '("Classifying"))
(pn0!> w)
(gprils0!> '(":"))
(gterpri!>)))
%----- Petrov classification. 08.01.91, 06.96 --------------------------
(de petrov!> (lst)
(prog (w0 w1 w2 w3 w4 wc wr)
(cond (!*trace
(prin2 "Petrov classification ...") (terpri)
(prin2 " Using algorithm by F.W.Letniowski & R.G.McLenaghan") (terpri)
(prin2 " Gen. Rel. Grav. 20 (1988) 463-483") (terpri)))
(setq w0 (aeval (nz!> (getel1!> lst 0 ))))
(setq w1 (aeval (nz!> (getel1!> lst 1 ))))
(setq w2 (aeval (nz!> (getel1!> lst 2 ))))
(setq w3 (aeval (nz!> (getel1!> lst 3 ))))
(setq w4 (aeval (nz!> (getel1!> lst 4 ))))
(setq wc (plus (times 16 (to1!> w0))
(times 8 (to1!> w1))
(times 4 (to1!> w2))
(times 2 (to1!> w3))
(times 1 (to1!> w4)) ))
(cond (!*trace
(prin2 "Case ") (prin2 wc) (prin2 ": ")
(foreach!> x in (list w0 w1 w2 w3 w4) do (progn
(prin2 " ") (cond ((zerop x) (prin2 0)) (t (prin2 "N")))))
(prin2 " =>")
(terpri) ))
(setq wr
(cond
((eqn wc 0) (finis!> "0" ))
((eqn wc 1) (finis!> "N" ))
((eqn wc 2) (finis!> "III" ))
((eqn wc 3) (finis!> "III" ))
((eqn wc 4) (finis!> "D" ))
((eqn wc 5) (finis!> "II" ))
((eqn wc 6) (finis!> "II" ))
((eqn wc 7) (alter!> (list 'plus (list 'times 2 w3 w3)
(list 'times -3 w2 w4))
"2*W3^2-3*W2*W4" "D" "II"))
((eqn wc 8) (finis!> "III" ))
((eqn wc 9) (finis!> "I" ))
((eqn wc 10) (finis!> "I" ))
((eqn wc 11) (alter!> (list 'plus (list 'times 27 w4 w4 w1)
(list 'times 64 w3 w3 w3))
"27*W4^2*W1+64*W3^3" "II" "I"))
((eqn wc 12) (finis!> "II" ))
((eqn wc 13) (alter!> (list 'plus (list 'times w1 w1 w4)
(list 'times 2 w2 w2 w2))
"W1^2*W4+2*W2^3" "II" "I"))
((eqn wc 14) (alter!> (list 'plus (list 'times 9 w2 w2)
(list 'times -16 w1 w3))
"9*W2^2-16*W1*W3" "II" "I"))
((eqn wc 15) (scase15!> w0 w1 w2 w3 w4))
((eqn wc 16) (finis!> "N" ))
((eqn wc 17) (finis!> "I" ))
((eqn wc 18) (finis!> "I" ))
((eqn wc 19) (alter!> (list 'plus (list 'times w0 w4 w4 w4)
(list 'times -27 w3 w3 w3 w3))
"W0*W4^3-27*W3^4" "II" "I"))
((eqn wc 20) (finis!> "II" ))
((eqn wc 21) (alter!> (list 'plus (list 'times 9 w2 w2)
(list 'times -1 w0 w4))
"9*W2^2-W0*W4" "D" "I"))
((eqn wc 22) (alter!> (list 'plus (list 'times w3 w3 w0)
(list 'times 2 w2 w2 w2))
"W3^2*W0+2*W2^3" "II" "I"))
((eqn wc 23) (scase23!> w0 w1 w2 w3 w4))
((eqn wc 24) (finis!> "III" ))
((eqn wc 25) (alter!> (list 'plus (list 'times w4 w0 w0 w0)
(list 'times -27 w1 w1 w1 w1))
"W4*W0^3-27*W1^4" "II" "I"))
((eqn wc 26) (alter!> (list 'plus (list 'times 27 w0 w0 w3)
(list 'times 64 w1 w1 w1))
"27*W0^2*W3+64*W1^3" "II" "I"))
((eqn wc 27) (scase27!> w0 w1 w2 w3 w4))
((eqn wc 28) (alter!> (list 'plus (list 'times 2 w1 w1)
(list 'times -3 w2 w0))
"2*W1^2-3*W2*W0" "D" "II"))
((eqn wc 29) (scase29!> w0 w1 w2 w3 w4))
((eqn wc 30) (scase30!> w0 w1 w2 w3 w4))
((eqn wc 31) (scase31!> w0 w1 w2 w3 w4))
))
(return wr)))
(de to1!> (w)
(cond ((zerop w) 0)
(t 1)))
(de finis!> (w)
(progn
(prin2 "Petrov type is ")
(prin2 w)
(prin2 ".")
(terpri)
w))
(de alter!> (w wp w0 w1)
(prog2
(setq w (aeval w))
(cond ((zerop w) (iszero!> wp 2) (finis!> w0))
(t (isnonzero!> wp 2 w) (finis!> w1)))))
(de iszero!> (wp wl)
(cond (!*trace
(spaces wl)
(prin2 wp)
(prin2 " = 0 =>")
(terpri))))
(de isnonzero!> (wp wl w)
(cond (!*trace
(spaces wl)
(prin2 wp)
(cond (!*showexpr
(prin2 " = ") (terpri)
(algpri!> " ") (algpri!> w) (algterpri!>)
(spaces (sub1 wl))))
(prin2 " is nonzero =>")
(terpri))))
(de zt!> (we wp wl)
(cond ((zerop we) (prog2 (iszero!> wp wl) t))
(t (prog2 (isnonzero!> wp wl we) nil))))
(de scase15!> (w0 w1 w2 w3 w4)
(prog (wi wf1 wf2 wdh)
(setq wi (aeval (list 'plus (list 'times 3 w2 w2)
(list 'times -4 w1 w3))))
(setq wf1 (aeval (list 'plus (list 'times 2 w2 w3)
(list 'times -3 w1 w4))))
(cond
((zt!> wi "I=3*W2^2-4*W1*W3" 2)
(cond
((zt!> wf1 "F1=2*W2*W3-3*W1*W4" 4) (return(finis!> "III")))
(t (return(finis!> "I")))))
(t (cond
((zt!> wf1 "F1=2*W2*W3-3*W1*W4" 4) (return(finis!> "I")))
(t (setq wf2 (aeval (list 'plus (list 'times 9 w2 w4)
(list 'times -8 w3 w3))))
(cond
((zt!> wf2 "F2=9*W2*W4-8*W3^2" 6) (return(finis!> "I")))
(t (setq wdh (aeval (list 'plus (list 'times 3 wf1 wf1)
(list 'times 2 wi wf2))))
(cond
((zt!> wdh "D^=3*F1^2+2*I*F2" 8)
(return(finis!> "II")))
(t (return(finis!> "I"))))))))))))
(de scase30!> (w0 w1 w2 w3 w4)
(prog (wi wf1 wf2 wdh)
(setq wi (aeval (list 'plus (list 'times 3 w2 w2)
(list 'times -4 w1 w3))))
(setq wf1 (aeval (list 'plus (list 'times 2 w2 w1)
(list 'times -3 w3 w0))))
(cond
((zt!> wi "I=3*W2^2-4*W1*W3" 2)
(cond
((zt!> wf1 "F1=2*W2*W1-3*W3*W0" 4) (return(finis!> "III")))
(t (return(finis!> "I")))))
(t (cond
((zt!> wf1 "F1=2*W2*W1-3*W3*W0" 4) (return(finis!> "I")))
(t (setq wf2 (aeval (list 'plus (list 'times 9 w2 w0)
(list 'times -8 w1 w1))))
(cond
((zt!> wf2 "F2=9*W2*W0-8*W1^2" 6) (return(finis!> "I")))
(t (setq wdh (aeval (list 'plus (list 'times 3 wf1 wf1)
(list 'times 2 wi wf2))))
(cond
((zt!> wdh "D^=3*F1^2+2*I*F2" 8)
(return(finis!> "II")))
(t (return(finis!> "I"))))))))))))
(de scase23!> (w0 w1 w2 w3 w4)
(prog (wi wjh wf3 wdt)
(setq wi (aeval (list 'plus (list 'times w0 w4)
(list 'times 3 w2 w2))))
(setq wjh (aeval (list 'plus (list 'times 4 w2 w4)
(list 'times -3 w3 w3))))
(cond
((zt!> wi "I=W0*W4+3*W2^2" 2)
(cond
((zt!> wjh "J^=4*W2*W4-3*W3^2" 4) (return(finis!> "III")))
(t (return(finis!> "I")))))
(t (cond
((zt!> wjh "J^=4*W2*W4-3*W3^2" 4) (return(finis!> "I")))
(t (setq wf3 (aeval (list 'plus (list 'times w0 wjh)
(list 'times -2 w2 wi ))))
(cond
((zt!> wf3 "F3=W0*J^-2*W2*I" 6) (return(finis!> "I")))
(t (setq wdt (aeval (list 'plus (list 'times w4 wi wi)
(list 'times -3 wjh wf3))))
(cond
((zt!> wdt "D~=W4*I^2-3*J^*F3" 8)
(return(finis!> "II")))
(t (return(finis!> "I"))))))))))))
(de scase29!> (w0 w1 w2 w3 w4)
(prog (wi wjh wf3 wdt)
(setq wi (aeval (list 'plus (list 'times w0 w4)
(list 'times 3 w2 w2))))
(setq wjh (aeval (list 'plus (list 'times 4 w2 w0)
(list 'times -3 w1 w1))))
(cond
((zt!> wi "I=W0*W4+3*W2^2" 2)
(cond
((zt!> wjh "J^=4*W2*W0-3*W1^2" 4) (return(finis!> "III")))
(t (return(finis!> "I")))))
(t (cond
((zt!> wjh "J^=4*W2*W0-3*W1^2" 4) (return(finis!> "I")))
(t (setq wf3 (aeval (list 'plus (list 'times w4 wjh)
(list 'times -2 w2 wi ))))
(cond
((zt!> wf3 "F3=W4*J^-2*W2*I" 6) (return(finis!> "I")))
(t (setq wdt (aeval (list 'plus (list 'times w0 wi wi)
(list 'times -3 wjh wf3))))
(cond
((zt!> wdt "D~=W0*I^2-3*J^*F3" 8)
(return(finis!> "II")))
(t (return(finis!> "I"))))))))))))
(de scase27!> (w0 w1 w2 w3 w4)
(prog (wv wu ww wi wj wd)
(setq wv (aeval (list 'plus (list 'times w0 w3 w3)
(list 'times -1 w1 w1 w4))))
(cond
((zt!> wv "V=W0*W3^3-W1^2*W4" 2)
(setq wu (aeval (list 'plus (list 'times w0 w4)
(list 'times 2 w1 w3))))
(cond
((zt!> wu "U=W0*W4+2*W1*W3" 4) (return(finis!> "D")))
(t
(setq ww (aeval (list 'plus (list 'times w0 w4)
(list 'times -16 w1 w3))))
(cond
((zt!> ww "W=W0*W4-16*W1*W3" 6) (return(finis!> "II")))
(t (return(finis!> "I")))))))
(t
(setq wi (aeval (list 'plus (list 'times w0 w4)
(list 'times -4 w1 w3))))
(setq wj (aeval (list 'plus (list 'times -1 w0 w3 w3)
(list 'times -1 w1 w1 w4))))
(cond
((ZT!> WI "I=W0*W4-4*W1*W3" 4)
(cond
((zt!> wj "J=-W0*W3^2-W1^2*W4" 6) (return(finis!> "III")))
(t (return(finis!> "I")))))
((zt!> wj "J=-W0*W3^2-W1^2*W4" 6) (return(finis!> "I")))
(t
(setq wd (aeval (list 'plus (list 'times wi wi wi)
(list 'times -27 wj wj ))))
(cond
((zt!> wd "D=I^3-27*J^2" 8) (return(finis!> "II")))
(t (return(finis!> "I"))))))))))
(de scase31!> (w0 w1 w2 w3 w4)
(prog (wh wf we wa wi wq wj wg wz wss wd)
(setq wh (aeval (list 'plus (list 'times w0 w2 )
(list 'times -1 w1 w1 ))))
(cond
((zt!> wh "H=W0*W2-W1^2" 2)
(setq wf (aeval (list 'plus (list 'times w0 w3 )
(list 'times -1 w1 w2 ))))
(setq we (aeval (list 'plus (list 'times w0 w4 )
(list 'times -1 w2 w2 ))))
(cond
((zt!> wf "F=W0*W3-W1*W2" 4)
(cond
((zt!> we "E=W0*W4-W2^2" 6) (return(finis!> "N")))
(t (return(finis!> "I")))))
((zt!> we "E=W0*W4-W2^2" 6)
(setq wq (aeval (list 'plus (list 'times 37 w2 w2 )
(list 'times 27 w1 w3 ))))
(cond
((zt!> wq "Q=37*W2^2+27*W1*W3" 8) (return(finis!> "II")))
(t (return(finis!> "I")))))
(t
(setq wa (aeval (list 'plus (list 'times w1 w3 )
(list 'times -1 w2 w2 ))))
(setq wi (aeval (list 'plus we (list 'times -4 wa ))))
(cond
((zt!> wi "A=W1*W3-W2^2; I=E-4*A" 8) (return(finis!> "I")))
(t
(setq wj (aeval (list 'plus (list 'times w4 wh )
(list 'times -1 w3 wf )
(list 'times w2 wa ))))
(setq wd (aeval (list 'plus (list 'times wi wi wi )
(list 'times -27 wj wj ))))
(cond
((zt!> wd "J=W4*H-W3*F+W2*A; D=I^3-27*J^2" 10)
(return(finis!> "II")))
(t (return(finis!> "I")))))))))
(t
(setq wf (aeval (list 'plus (list 'times w0 w3 )
(list 'times -1 w1 w2 ))))
(setq we (aeval (list 'plus (list 'times w0 w4 )
(list 'times -1 w2 w2 ))))
(setq wa (aeval (list 'plus (list 'times w1 w3 )
(list 'times -1 w2 w2 ))))
(setq wi (aeval (list 'plus we (list 'times -4 wa ))))
(cond
((zt!> wi "E=W0*W4-W2^2; A=W1*W3-W2^2; I=E-4*A" 4)
(setq wf (aeval (list 'plus (list 'times w0 w3 )
(list 'times -1 w1 w2 ))))
(setq wj (aeval (list 'plus (list 'times w4 wh )
(list 'times -1 w3 wf )
(list 'times w2 wa ))))
(cond
((zt!> wj "F=W0*W3-W1*W2; J=W4*H-W3*F+W2*A" 6)
(return(finis!> "III")))
(t (return(finis!> "I")))))
(t
(setq wf (aeval (list 'plus (list 'times w0 w3 )
(list 'times -1 w1 w2 ))))
(setq wg (aeval (list 'plus (list 'times w0 wf )
(list 'times -2 w1 wh ))))
(cond
((zt!> wg "G=W0*F-2*W1*H" 6)
(setq wz (aeval (list 'plus (list 'times w0 w0 wi )
(list 'times -12 wh wh ))))
(cond
((zt!> WZ "Z=W0^2*I-12*H^2" 8) (return(finis!> "D")))
(t
(setq wss (aeval (list 'plus (list 'times w0 w0 wi )
(list 'times -3 wh wh ))))
(cond
((zt!> wss "S=W0^2*I-3*H^2" 10)
(return(finis!> "II")))
(t (return(finis!> "I")))))))
(t
(setq wj (aeval (list 'plus (list 'times w4 wh )
(list 'times -1 w3 wf )
(list 'times w2 wa ))))
(cond
((zt!> wj "J=W4*H-W3*F+W2*A" 8) (return(finis!> "I")))
(t
(setq wd (aeval (list 'plus (list 'times wi wi wi )
(list 'times -27 wj wj ))))
(cond
((zt!> wd "D=I^3-27*J^3" 10)
(return(finis!> "II")))
(t (return(finis!> "I"))))))))))))))
%------- EM Type 06.96 ----------------------------------------------------
(de emtype!> (lst)
(prog (w0 w1 w2 wc wr wd)
(cond (!*trace
(prin2 "EM strength classification ...") (terpri)))
(setq w0 (aeval (nz!> (getel1!> lst 0 ))))
(setq w1 (aeval (nz!> (getel1!> lst 1 ))))
(setq w2 (aeval (nz!> (getel1!> lst 2 ))))
(setq wc (plus (times 4 (to1!> w0))
(times 2 (to1!> w1))
(times 1 (to1!> w2)) ))
(cond (!*trace
(prin2 "Case ") (prin2 wc) (prin2 ": ")
(foreach!> x in (list w0 w1 w2) do (progn
(prin2 " ") (cond ((zerop x) (prin2 0)) (t (prin2 "N")))))
(prin2 " =>")
(terpri) ))
(setq wr
(cond
((eqn wc 0) (emfinis!> "0"))
((eqn wc 1) (emfinis!> "N"))
((eqn wc 2) (emfinis!> "I"))
((eqn wc 3) (emfinis!> "I"))
((eqn wc 4) (emfinis!> "N"))
((eqn wc 5) (emfinis!> "I"))
((eqn wc 6) (emfinis!> "I"))
((eqn wc 7)
(setq wd (aeval (list 'plus (list 'times w0 w2)
(list 'times -1 w1 w1))))
(cond
((zt!> wd "D=F0*F2-F1^2" 2) (emfinis!> "N"))
(t (emfinis!> "I"))))))
(return wr)))
(de emfinis!> (w)
(progn
(prin2 "EM type is ")
(prin2 w)
(prin2 ".")
(terpri)
w))
%------- Ricci spinor classification 06.96 --------------------------------
(de riccisclass!> (lst)
(prog (f00 f01 f02 f11 f12 f22 w0 w1 w2 w3 w4 wc wr wpp wi6 ww
wq ws1 ws2 ws3 ws4 ws5 ws6 ws7 wip wi7)
(cond (!*trace
(prin2 "Ricci Spinor classification ...") (terpri)
(prin2 " Using algorithm by G.C.Joly, M.A.H.McCallum & W.Seixas") (terpri)
(prin2 " Class. Quantum Grav. 7 (1990) 541-556") (terpri)
(prin2 " Class. Quantum Grav. 8 (1991) 1577-1585") (terpri)))
(setq f00 (aeval (nz!> (getel2!> lst 0 0))))
(setq f01 (aeval (nz!> (getel2!> lst 0 1))))
(setq f02 (aeval (nz!> (getel2!> lst 0 2))))
(setq f11 (aeval (nz!> (getel2!> lst 1 1))))
(setq f12 (aeval (nz!> (getel2!> lst 1 2))))
(setq f22 (aeval (nz!> (getel2!> lst 2 2))))
(setq wc (mapcar (list f00 f01 f02 f11 f12 f22) 'to1!>))
(cond (!*trace
(prin2 "Case ")
(foreach!> x in wc do (prin2 x))
(prin2 " =>")
(terpri) ))
% Special cases ...
(setq wr
(cond
((equal wc '(0 0 0 0 0 0)) (rfin!> "0" "[(1111)]"))
((equal wc '(0 0 0 1 0 0)) (rfin!> "D" "[(11)(1,1)]"))
((equal wc '(0 0 1 0 0 0)) (rfin!> "D" "[11(1,1)]"))
((equal wc '(0 0 0 0 0 1)) (rfin!> "0" "[(112)]"))
((equal wc '(1 0 0 0 0 0)) (rfin!> "0" "[(112)]"))
((equal wc '(0 0 0 1 0 1)) (rfin!> "D" "[(11)2]"))
((equal wc '(1 0 0 1 0 0)) (rfin!> "D" "[(11)2]"))
((equal wc '(0 0 1 0 0 1)) (rfin!> "II" "[112]"))
((equal wc '(1 0 1 0 0 0)) (rfin!> "II" "[112]"))
((equal wc '(0 0 0 0 1 0)) (rfin!> "N" "[(13)]"))
((equal wc '(0 1 0 0 0 0)) (rfin!> "N" "[(13)]"))
((equal wc '(0 0 0 1 1 0)) (rfin!> "D" "[(11)2]"))
((equal wc '(0 1 0 1 0 0)) (rfin!> "D" "[(11)2]"))
((equal wc '(0 0 0 0 1 1)) (rfin!> "N" "[(13)]"))
((equal wc '(1 1 0 0 0 0)) (rfin!> "N" "[(13)]"))
((equal wc '(0 1 0 0 0 1)) (rfin!> "I" "[11ZZ~]"))
((equal wc '(1 0 0 0 1 0)) (rfin!> "I" "[11ZZ~]"))
))
(cond (wr (return wr)))
% General case ...
% PP type first ...
(setq w0 (aeval(wff!> 0 lst)))
(setq w1 (aeval(wff!> 1 lst)))
(setq w2 (aeval(wff!> 2 lst)))
(setq w3 (aeval(wff!> 3 lst)))
(setq w4 (aeval(wff!> 4 lst)))
(cond (!*trace
(prin2 "Making Petrov-Plebanski (PP) classification ...")
(terpri)))
(setq wpp (petrov!> (list w0 w1 w2 w3 w4)))
% Segre type ...
(setq wr
(cond
((equal wpp "0" )
(setq ww (aeval (list 'plus
(list 'times f11 f11)
(list 'times -1 f12 (gfab!> 1 0 lst)))))
(cond
((zt!> ww "W=F11'^2-F10'*F12'" 2) (rfin!> wpp "[(112)]"))
((zt!> f00 "F00" 4) (rfin!> wpp "[1(11,1)]"))
((zt!> f22 "F22" 4) (rfin!> wpp "[1(11,1)]"))
(t (rfincond!> wpp "[(111),1]"
" if W>0 and "
"[1(11,1)]"
" if W<0"))))
((equal wpp "I" ) (rfincond!> wpp "[111,1]"
" if D>0 and "
"[11ZZ~]"
" if D<0"))
((equal wpp "II" ) (rfin!> wpp "[112]"))
((equal wpp "III") (rfin!> wpp "[13]"))
((equal wpp "N" )
(setq wi6 (aeval (list 'plus
(list 'times (gfab!> 0 0 lst) (gfab!> 2 2 lst))
(list 'times 2 (gfab!> 1 1 lst) (gfab!> 1 1 lst))
(list 'times -2 (gfab!> 0 1 lst) (gfab!> 2 1 lst))
(list 'times -2 (gfab!> 1 0 lst) (gfab!> 1 2 lst))
(list 'times (gfab!> 0 2 lst) (gfab!> 2 0 lst)))))
(cond
((zt!> wi6 "I6" 2) (rfin!> wpp "[(13)]"))
(t (rfin!> wpp "[1(12)]"))))
((equal wpp "D" )
(setq wi6 (aeval (list 'plus
(list 'times (gfab!> 0 0 lst) (gfab!> 2 2 lst))
(list 'times 2 (gfab!> 1 1 lst) (gfab!> 1 1 lst))
(list 'times -2 (gfab!> 0 1 lst) (gfab!> 2 1 lst))
(list 'times -2 (gfab!> 1 0 lst) (gfab!> 1 2 lst))
(list 'times (gfab!> 0 2 lst) (gfab!> 2 0 lst)))))
(cond
((zt!> wi6 "I6" 2) (rfin!> wpp "[(11)ZZ~]"))
(t
(setq wip (aeval (list 'plus
(list 'times w0 w4)
(list 'times -4 w1 w3)
(list 'times 3 w2 w2))))
(setq ww (aeval (list 'plus
(list 'times f11 f11)
(list 'times -1 f12 (gfab!> 1 0 lst)))))
(setq wq (aeval
(list 'plus wip
(list 'times -3 (list 'expt (list 'plus w2 ww) 2)))))
(cond
((zt!> wq "Q" 4)
(setq ws1 (aeval (list 'plus
(list 'times (gfab!> 2 0 lst) (gfab!> 1 2 lst))
(list 'times -1 (gfab!> 1 0 lst) (gfab!> 2 2 lst)))))
(setq ws2 (aeval (list 'plus
(list 'times (gfab!> 0 0 lst) (gfab!> 2 2 lst))
(list 'times -1 (gfab!> 2 0 lst) (gfab!> 0 2 lst)))))
(setq ws3 (aeval (list 'plus
(list 'times (gfab!> 1 0 lst) (gfab!> 0 2 lst))
(list 'times -1 (gfab!> 0 0 lst) (gfab!> 1 2 lst)))))
(setq ws4 (aeval (list 'plus
(list 'times (gfab!> 0 0 lst) (gfab!> 1 1 lst))
(list 'times -1 (gfab!> 1 0 lst) (gfab!> 0 1 lst)))))
(setq ws5 (aeval (list 'plus
(list 'times (gfab!> 0 1 lst) (gfab!> 1 2 lst))
(list 'times -1 (gfab!> 0 2 lst) (gfab!> 1 1 lst)))))
(setq ws6 (aeval (list 'plus
(list 'times (gfab!> 1 1 lst) (gfab!> 2 2 lst))
(list 'times -1 (gfab!> 1 2 lst) (gfab!> 2 1 lst)))))
(setq wi7 (aeval (list 'plus
(list 'times f01 ws1)
(list 'times f11 ws2)
(list 'times (gfab!> 2 1 lst) ws3))))
(cond
((and (zt!> ws1 "S1" 6)
(zt!> ws2 "S2" 6)
(zt!> ws3 "S3" 6))
(cond
((and (zt!> ws4 "S4" 6)
(zt!> ws5 "S5" 6)
(zt!> ws6 "S6" 6))
(rfin!> wpp "[(11)(1,1)]"))
(t (rfin!> wpp "[(11)2]"))))
((zt!> wi7 "I7" 6) (rfin!> wpp "[(11)2]"))
(t (rfin!> wpp "[11ZZ~]"))))
(t (rfincond!> wpp "[(11)ZZ~]"
" if S7<0 and "
"[(11)1,1] or [11(1,1)]"
" if S7>0"))))
))))
(return wr)))