This file is indexed.

/usr/share/polymake/demo/apps_group.ipynb is in polymake-common 3.2r2-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Groups in polymake\n",
    "\n",
    "`polymake` can deal with symmetry groups acting on polytopes, point/vector configurations and simplicial complexes. This can take the guise of permutation or matrix groups acting on the set of vertices (points), facets, or coordinates of realizations of polytopes or point/vector configurations, or abstract permutation groups acting on the set of vertices or facets of a simplicial complex.\n",
    " \n",
    "Some functionality builds on `PermLib`, a `C++`-library for permutation computations written by [Thomas Rehn](http://www.math.uni-rostock.de/~rehn/index.html), but much functionality is built in natively into `polymake`. For example, you can natively calculate conjugation classes of permutation or matrix groups, projectors to the isotypic components of representations, or the invariant polynomials of a matrix representation.\n",
    "\n",
    "\n",
    "## General properties of groups\n",
    "\n",
    "We start with the description of permutation groups in `polymake`. An object of type [ Group](https///polymake.org/release_docs/latest/group.html#group__Group__5 ) records the abstract properties of the groups that do not depend on any particular representation, which essentially are just the `ORDER`, `CHARACTER_TABLE`, and `CONJUGACY_CLASS_SIZES`. Moreover, a `Group` object can contain several subobjects that encode actions (representations) of the group, most notably a `PERMUTATION_ACTION` that encodes permutations of indices. If the Group object is contained inside a `Cone`, `Polytope`, `PointConfiguration`, or `VectorConfiguration`, it may be encoded more specifically as a `RAY_ACTION`, `FACET_ACTION`, etc. See the [ documentation](https///polymake.org/doku.php/release_docs/latest/group.html ) for more information on the action types.\n",
    "\n",
    "In order to access the complete set of functions dealing with groups, you should switch to the corresponding [ application](howto/lingo# application).\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "application \"group\";"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "### Conjugacy classes and character tables\n",
    "\n",
    "As we mentioned before, the only properties that are stored directly in the `Group` object are the order, the sizes of the conjugacy classes, and sometimes the character table. Other properties, such as representatives for the conjugacy classes themselves, depend on the action chosen, and are thus stored inside the corresponding `*_ACTION` object. \n",
    "\n",
    "For the symmetric groups, we currently include the `CHARACTER_TABLE` up to degree 7; for the `group::dihedral_group` we provide the conjugacy classes in full generality, and the `CHARACTER_TABLE` in an exact form for the dihedral groups of order 10, 16, 20, and 24 (where it can be expressed using a single quadratic extension of the rationals). For the other dihedral groups, we provide `AccurateFloat` representations of the entries of the character table, as `polymake` currently cannot work with arbitrary cyclotomic integers.\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1 1 1 1 1 1 1 1\n",
       "1 1 1 1 1 1 -1 -1\n",
       "1 -1 1 -1 1 -1 1 -1\n",
       "1 -1 1 -1 1 -1 -1 1\n",
       "2 1/2+1/2r5 -1/2+1/2r5 1/2-1/2r5 -1/2-1/2r5 -2 0 0\n",
       "2 -1/2+1/2r5 -1/2-1/2r5 -1/2-1/2r5 -1/2+1/2r5 2 0 0\n",
       "2 1/2-1/2r5 -1/2-1/2r5 1/2+1/2r5 -1/2+1/2r5 -2 0 0\n",
       "2 -1/2-1/2r5 -1/2+1/2r5 -1/2+1/2r5 -1/2-1/2r5 2 0 0\n",
       "    \n"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print dihedral_group(20)->CHARACTER_TABLE;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1 1 1 1 1 1 1\n",
       "1 1 1 1 1 1 -1\n",
       "2 3788669096982621/2251799813685248 3741725795518811/4503599627370496 -2563716210467435/9007199254740992 -2949230557375555/2251799813685248 -8642344396869719/4503599627370496 0\n",
       "2 3741725795518811/4503599627370496 -2949230557375555/2251799813685248 -1080293049608715/562949953421312 -2563716210467439/9007199254740992 3788669096982621/2251799813685248 0\n",
       "2 -2563716210467435/9007199254740992 -1080293049608715/562949953421312 7483451591037615/9007199254740992 3788669096982621/2251799813685248 -2949230557375555/2251799813685248 0\n",
       "2 -2949230557375555/2251799813685248 -2563716210467439/9007199254740992 3788669096982621/2251799813685248 -8642344396869719/4503599627370496 7483451591037615/9007199254740992 0\n",
       "2 -8642344396869719/4503599627370496 3788669096982621/2251799813685248 -2949230557375555/2251799813685248 7483451591037615/9007199254740992 -2563716210467435/9007199254740992 0\n",
       "\n"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print dihedral_group(22)->CHARACTER_TABLE;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Important notice\n",
    "\n",
    "For internal consistency, it is crucial that the `GROUP->*_ACTION->CONJUGACY_CLASS_REPRESENTATIVES` (and thus the `->CONJUGACY_CLASSES` themselves) be ordered in accordance with the columns of the `GROUP->CHARACTER_TABLE`. This is guaranteed to be the case for the character tables provided natively by `polymake`, but if you import character tables from GAP or other sources, correctly ordering the conjugacy classes is up to you.\n",
    "\n",
    "## Permutation groups\n",
    "\n",
    "An instance of a group action is created by specifying its property `GENERATORS`, a set of permutations or matrices that generates the group. The Group object itself is then constructed by passing the action. In the following example we create a symmetric group of degree 3, and then compute its order.\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polymake: used package permlib\n",
       "  A callable C++ library for permutation computations. \n",
       "  Written by Thomas Rehn.\n",
       "  http://www.math.uni-rostock.de/~rehn/software/permlib.html \n",
       "    \n"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$p = new PermutationAction(GENERATORS => [[1,0,2],[0,2,1]]);\n",
    "$g = new Group(PERMUTATION_ACTION => $p);\n",
    "print $g->ORDER;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    6\n",
    "\n",
    "\n",
    "Of course, there is a user function for creating symmetric groups given the degree, as well as for several other standard constructions. See the [ docs](https///polymake.org/release_docs/latest/group.html#group__Producing_a_group__15 ) for a comprehensive list.\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1 0 2\n",
       "0 2 1\n",
       "\n"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$h = symmetric_group(3);\n",
    "print $h->PERMUTATION_ACTION->GENERATORS;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "### Properties of permutation actions\n",
    "\n",
    "We can compute some interesting properties of a PermutationAction:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0 1 2\n",
       "0 2 1\n",
       "1 0 2\n",
       "1 2 0\n",
       "2 0 1\n",
       "2 1 0\n",
       "\n"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$p = new PermutationAction(GENERATORS => [[1,0,2],[0,2,1]]);\n",
    "print all_group_elements($p);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "There also exist basic functions to compute orbits and stabilizers, for instance:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0 2 1\n"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$p = new PermutationAction(GENERATORS => [[1,0,2],[0,2,1]]);\n",
    "$s = stabilizer_of_set($p,new Set<Int>(1,2));\n",
    "print $s->PERMUTATION_ACTION->GENERATORS;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0}\n",
       "{2 1}\n",
       "\n"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $s->PERMUTATION_ACTION->ORBITS;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### A note on permutations in polymake\n",
    "\n",
    "`polymake` natively uses index notation for permutations: a permutation g ∈ S<sub>n</sub> is an `Array<Int> of length n with entries 0, . . . , n − 1 which corresponds to the second row of the common permutation notation. For instance, the permutation\n",
    "\n",
    "    \n",
    "    0 1 2\n",
    "    1 0 2\n",
    "\n",
    "which is equal to (0 1) ∈ S<sub>3</sub> in cyclic notation, is represented in `polymake` by the integer array [1, 0, 2]. Methods for conversion between the notation in `polymake` and the 1-based cyclic notation as used, for instance, in GAP are also available:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1,2),\n",
       "(2,3)\n"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$p = new PermutationAction(GENERATORS=>[[1,0,2],[0,2,1]]);\n",
    "print action_to_cyclic_notation($p);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0 2 3 4 1\n",
       "1 2 4 0 3\n",
       "\n"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$AGL_1_5 = group_from_cyclic_notation1(\"(2,3,4,5), (1,2,3,5,4)\");\n",
    "print $AGL_1_5->PERMUTATION_ACTION->GENERATORS;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "## Symmetry groups of polymake objects\n",
    "\n",
    "We switch to the polytope application for the following section:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "application 'polytope';"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "### Polytopes\n",
    "\n",
    "There is more than one way to associate a group with any given polytope, depending on which kind of structural information you want to preserve. You can find some functions concerning symmetry groups of polytopes [ here](https///polymake.org/release_docs/latest/polytope.html#polytope__Symmetry__36 ). It is possibile to attach the group objects described above to polytopes or cones by using the property `GROUP`. As there are many possible groups that operate on a polytope, the property can contain multiple subobjects; see [ here](https///polymake.org/doku.php/scripting/start#multiple_subobjects ) for information on how to handle those.\n",
    "\n",
    "One interesting group is the group of *combinatorial* automorphisms, the ones preserving the face lattice. Since the face lattice of a polytope is atomic and coatomic this group coincides with group of (bipartite) graph automorphisms of the vertex/facet incidences.\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(<0 1 4 5 2 3> <0 1 4 5 2 3 6 7>)\n",
       "(<2 3 0 1 4 5> <0 2 1 3 4 6 5 7>)\n",
       "(<1 0 2 3 4 5> <1 0 3 2 5 4 7 6>)\n",
       "\n"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$c = cube(3);\n",
    "$aut = automorphisms($c->VERTICES_IN_FACETS);\n",
    "print $aut;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This says that the combinatorial automorphisms are generated by three elements, one per line in the output.  Each generator is written as a pair of permutations.  The first one gives the action on the FACETS, the second one gives the action on the VERTICES. Note that `automorphisms` does not necessarily output a minimal representation.\n",
    "\n",
    "Let's wrap some of this information up in a Group object:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "@g = map { $_->first } @{$aut};\n",
    "$fperm = new group::PermutationAction(GENERATORS=>\\@g);\n",
    "$g = new group::Group(FACETS_ACTION=>$fperm);           # note how we use the FACETS_ACTION property this time\n",
    "$g->name = \"fullCombinatorialGroupOnFacets\";            # is is advisable to give multiple objects a meaningful name\n",
    "$c->add(\"GROUP\",$g);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "Now we can, e.g., compute the generators of the action on the vertices from the action on the facets:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0 1 4 5 2 3 6 7\n",
       "0 2 1 3 4 6 5 7\n",
       "1 0 3 2 5 4 7 6\n",
       "\n"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $c->GROUP->VERTICES_ACTION->GENERATORS;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "Many standard constructions of polytopes come with an option to compute the canonical symmetry group during construction in a more efficient way than computing the face lattice and then solving the graph automorphism problem. If you type the name of the function you want to execute and then hit F1 twice, the available options will be displayed. You will find a description of the action that will be computed too. For example, the following creates a cube, but with the action on the facets already attached:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1 0 2 3 4 5\n",
       "2 3 0 1 4 5\n",
       "0 1 4 5 2 3\n",
       "\n"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$cg = cube(3,group=>1);\n",
    "print $cg->GROUP->FACETS_ACTION->GENERATORS;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "#### Orbit polytopes\n",
    "\n",
    "Given a group with either a `COORDINATE_ACTION` or a `MATRIX_ACTION`, you can calculate the convex hull of the orbits of a tuple of points:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "48\n",
       "\n"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$cg = cube(3,group=>1);\n",
    "print orbit_polytope(new Matrix([[1,1,2,1],[1,5/2,1,0]]), $cg->GROUP->MATRIX_ACTION)->N_VERTICES;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "See [the documentation](https///polymake.org/release_docs/latest/polytope.html#polytope__orbit_polytope__319) for more options.\n",
    "\n",
    "### Quotient spaces\n",
    "\n",
    "One way of constructing interesting topological spaces is by identifying points on the boundary of a fundamental region. Polymake can do this in the case where the fundamental region is a convex polytope. For example, a cylinder is obtained by identifying opposite sides of a square, and the [quarter_turn_manifold()](https///polymake.org/release_docs/latest/polytope.html#polytope__quarter_turn_manifold__238) (see [here](http://www.math.cornell.edu/~dwh/books/eg99/Ch20/Ch20.html)) is obtained from the boundary of a 3-dimensional cube by identifying opposite faces by a quarter turn. \n",
    "\n",
    "For example, to obtain a topological space homeomorphic to a cylinder, type\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2 3 0 1\n"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$p = cylinder_2();\n",
    "print $p->QUOTIENT_SPACE->IDENTIFICATION_ACTION->GENERATORS;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0 2}\n",
       "{1 3}\n"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $p->QUOTIENT_SPACE->IDENTIFICATION_ACTION->ORBITS;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{{0} {1}}\n",
       "{{0 1} {0 2} {1 3}}\n",
       "{{0 1 2 3}}\n"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $p->QUOTIENT_SPACE->FACES;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2 3 1\n",
       "\n"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $p->QUOTIENT_SPACE->F_VECTOR;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Thus, vertices 0,2 and vertices 1,3 of a square (a 2-dimensional cube) are identified, and after identification two vertices, three edges, and one two-dimensional face remain. In  order to get a simplicial complex without identifications among the vertices, you can calculate the second barycentric subdivision by asking for the property SIMPLICIAL_COMPLEX:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26 72 48\n"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $p->QUOTIENT_SPACE->SIMPLICIAL_COMPLEX->F_VECTOR;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "({} 0)\n",
       "({} 0)\n",
       "({} 1)\n",
       "\n"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $p->QUOTIENT_SPACE->SIMPLICIAL_COMPLEX->HOMOLOGY;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "An easy way to make projective spaces is to identify opposite faces in a centrally symmetric polytope, using the function [cs_quotient()](https///polymake.org/release_docs/latest/polytope.html#polytope__cs_quotient__239). For example, to calculate the homology of real 3-dimensional projective space **RP<sup>3</sup>, write\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "({} 0)\n",
       "({(2 1)} 0)\n",
       "({} 0)\n",
       "({} 1)\n",
       "\n"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$m = cs_quotient(cube(3));\n",
    "print $m->QUOTIENT_SPACE->SIMPLICIAL_COMPLEX->HOMOLOGY;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "As another example, the [Davis Manifold](https///people.math.osu.edu/davis.12/old_papers/4-mfld.pdf) is a 4-dimensional hyperbolic manifold obtained by identifying opposite vertices of a 120-cell:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "300 600 360 60 1\n",
       "\n"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$m=davis_manifold();\n",
    "print $m->QUOTIENT_SPACE->F_VECTOR;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Calculating the homology takes a little bit longer:\n",
    "\n",
    "   polytope > print $m->QUOTIENT_SPACE->SIMPLICIAL_COMPLEX->F_VECTOR;\n",
    "    94321 1146960 3644640 4320000 1728000\n",
    "   polytope > print $m->QUOTIENT_SPACE->SIMPLICIAL_COMPLEX->HOMOLOGY;\n",
    "    ({} 0)\n",
    "    ({(2 1)} 0)\n",
    "    ({} 0)\n",
    "    ({(2 1)} 0)\n",
    "    ({} 0)\n",
    "\n",
    "\n",
    "## Matrix groups\n",
    "\n",
    "Let's switch back to `group`.\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "application 'group';"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "Polymake can also deal with groups given by matrices that act on the ambient space. They are stored in the property `GROUP.MATRIX_ACTION`, and are paramterized by the number type of the matrices. One way to get a `MATRIX_ACTION` is to convert a permutation action on the vertices of a polytope:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "type: Group as Polytope<QuadraticExtension<Rational>>::GROUP\n",
       "    \n"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "$d = polytope::dodecahedron();\n",
    "$d->GROUP->properties();"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    VERTICES_ACTION\n",
    "    type: PermutationAction<Int, Rational>\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "$d->GROUP->MATRIX_ACTION;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<1 0 0 0\n",
       "0 -1 0 0\n",
       "0 0 1 0\n",
       "0 0 0 1\n",
       ">\n",
       "<1 0 0 0\n",
       "0 1/4-1/4r5 1/2 -1/4-1/4r5\n",
       "0 1/2 1/4+1/4r5 -1/4+1/4r5\n",
       "0 -1/4-1/4r5 -1/4+1/4r5 1/2\n",
       ">\n",
       "<1 0 0 0\n",
       "0 1 0 0\n",
       "0 0 1 0\n",
       "0 0 0 -1\n",
       ">\n",
       "\n"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $d->GROUP->MATRIX_ACTION->GENERATORS;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As we can see, the property `MATRIX_ACTION` was calculated on the fly, specifically by solving matrix equations involving the `VERTICES` and `VERTICES_ACTION->GENERATORS`. Moreover, in this case the matrices are calculated exactly by adjoining the square root of 5 to the rationals.\n",
    "\n",
    "Of course, not every combinatorial symmetry group of a concrete point configuration has a realization as a matrix group, in which case the above computation will fail. A sure-fire way to get a matrix group is to calculate the `REGULAR_REPRESENTATION` of a permutation group, which yields the action by permutation matrices on the ambient space of dimension = number of points.\n",
    "\n",
    "### Orbits\n",
    "\n",
    "Once you have a matrix group, you may calculate the orbit of an arbitrary vector under it:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "$s = symmetric_group(3); "
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "$a = $s->REGULAR_REPRESENTATION;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{<3 2 1> <1 2 3> <2 1 3> <1 3 2> <3 1 2> <2 3 1>}\n",
       "\n"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print orbit($a->GENERATORS, new Vector([1,2,3]));"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Invariant polynomials\n",
    "\n",
    "Or you can regard the matrices as acting on polynomials, and calculate a set of invariant polynomials of a given maximum degree. For this, recall that the action of a matrix on a polynomial is exemplified by\n",
    "\n",
    "    [ 1  1 ]\n",
    "    [ 1 -1 ]  .  ( x^2 - y^2 )  =  ( x + y )^2 - ( x - y )^2.\n",
    "\n",
    "You can calculate the polynomials left invariant by the matrices sending the vertices of a dodecahedron into each other as follows:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "$d = polytope::dodecahedron();"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "$d->GROUP->MATRIX_ACTION;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "x_0^2 + x_1^2 + x_2^2\n",
       "x_0^4 + 2*x_0^2*x_1^2 + 2*x_0^2*x_2^2 + x_1^4 + 2*x_1^2*x_2^2 + x_2^4\n",
       "\n"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print join \"\\n\", @{invariant_polynomials($d->GROUP->MATRIX_ACTION, 5)};"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is consistent with the Molien series of this action starting out as 1 + x^2 + x^4 + 2x^6 + ..., so in particular no invariant of degree exactly 5 is found. See [this paper](http://www.ams.org/journals/bull/1979-01-03/S0273-0979-1979-14597-X/S0273-0979-1979-14597-X.pdf) by Stanley for more information.\n",
    "\n",
    "## Decomposition into irreps, and bases of isotypic components\n",
    "\n",
    "You can calculate \n",
    "\n",
    "\n",
    "*  the character of a permutation action or matrix action, \n",
    "\n",
    "*  the decomposition of the action into irreducible representations, and \n",
    "\n",
    "*  the projection operators to (and vector space bases of) the isotypic components. \n",
    "\n",
    "For `MATRIX_ACTION`s, the character can always be calculated, but for the rest of these computations the `CHARACTER_TABLE` must be known:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-2 0 2 1 4 1 1/2-1/2r5 3/2-1/2r5 1/2+1/2r5 3/2+1/2r5\n",
       "    \n"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $d->GROUP->MATRIX_ACTION->CHARACTER;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "     group > print irreducible_decomposition($d->GROUP->MATRIX_ACTION->CHARACTER, $d->GROUP);\n",
    "    polymake:  WARNING: available properties insufficient to compute 'CHARACTER_TABLE'\n",
    "\n",
    "This didn't work, because the dodecahedron doesn't (yet) come with a character table; this might change in future versions, though.\n",
    "\n",
    "It does work, for instance, for the symmetric group of order 5! (in fact, up to order 7!):\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "$s=symmetric_group(5);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1 -1 1 1 -1 -1 1\n",
       "4 -2 0 1 1 0 -1\n",
       "5 -1 1 -1 -1 1 0\n",
       "6 0 -2 0 0 0 1\n",
       "5 1 1 -1 1 -1 0\n",
       "4 2 0 1 -1 0 -1\n",
       "1 1 1 1 1 1 1\n",
       "    \n"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $s->CHARACTER_TABLE;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "$s->REGULAR_REPRESENTATION;"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5 3 1 2 0 1 0\n",
       "    \n"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $s->REGULAR_REPRESENTATION->CHARACTER;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0 0 0 0 0 1 1\n",
       "\n"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print irreducible_decomposition($s->REGULAR_REPRESENTATION->CHARACTER,$s);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "So the regular (permutation) representation decomposes into one copy each of the invariant subspaces associated to the characters in the last two lines of the character table. The first entries there, 4 and 1, say that these components should have dimensions 4 and 1, respectively:\n",
    "\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4/5 -1/5 -1/5 -1/5 -1/5\n",
       "-1/5 4/5 -1/5 -1/5 -1/5\n",
       "-1/5 -1/5 4/5 -1/5 -1/5\n",
       "-1/5 -1/5 -1/5 4/5 -1/5\n",
       "    \n"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print isotypic_basis($s, $s->REGULAR_REPRESENTATION, 5);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1/5 1/5 1/5 1/5 1/5\n",
       "\n"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print isotypic_basis($s, $s->REGULAR_REPRESENTATION, 6);"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "polymake",
   "language": "polymake",
   "name": "polymake"
  },
  "language_info": {
   "codemirror_mode": "perl",
   "file_extension": ".pm",
   "mimetype": "text/x-polymake",
   "name": "polymake"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}