2016-11-19 10:16:45 +00:00
|
|
|
#include "thickenings.h"
|
2016-11-20 22:19:08 +00:00
|
|
|
#include "weyl.h"
|
2016-07-26 08:09:34 +00:00
|
|
|
#include "queue.h"
|
2016-11-19 10:16:45 +00:00
|
|
|
|
|
|
|
#include <strings.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2016-11-23 19:58:05 +00:00
|
|
|
char stringbuffer[100];
|
|
|
|
char stringbuffer2[100];
|
|
|
|
|
|
|
|
typedef struct {
|
2017-01-27 19:48:44 +00:00
|
|
|
doublequotient_t *dq;
|
2016-11-23 19:58:05 +00:00
|
|
|
int rank;
|
|
|
|
int order;
|
2017-01-27 19:48:44 +00:00
|
|
|
int positive;
|
2016-11-23 19:58:05 +00:00
|
|
|
int *buffer;
|
2016-12-02 09:31:31 +00:00
|
|
|
int level;
|
2016-11-23 19:58:05 +00:00
|
|
|
} info_t;
|
|
|
|
|
2017-01-27 19:48:44 +00:00
|
|
|
static char* alphabetize(weylgroup_element_t *e, char *str)
|
|
|
|
{
|
|
|
|
if(e->wordlength == 0)
|
|
|
|
sprintf(str, "1");
|
2017-01-31 15:29:03 +00:00
|
|
|
else {
|
2017-01-27 19:48:44 +00:00
|
|
|
for(int j = 0; j < e->wordlength; j++)
|
2017-01-31 15:29:03 +00:00
|
|
|
str[j] = e->word[j] + 'a';
|
|
|
|
str[e->wordlength] = 0;
|
|
|
|
}
|
2017-01-27 19:48:44 +00:00
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
int shorten(int i, unsigned long left, unsigned long right, doublequotient_t *dq, int rank)
|
2016-11-23 19:58:05 +00:00
|
|
|
{
|
|
|
|
int other, shorter = i;
|
|
|
|
do {
|
|
|
|
i = shorter;
|
|
|
|
for(int j = 0; j < rank; j++) {
|
|
|
|
other = graph[shorter].left[j];
|
|
|
|
if(left & (1 << j) &&
|
|
|
|
graph[other].wordlength < graph[shorter].wordlength)
|
|
|
|
shorter = other;
|
|
|
|
other = graph[shorter].right[j];
|
|
|
|
if(right & (1 << j) &&
|
|
|
|
graph[other].wordlength < graph[shorter].wordlength)
|
|
|
|
shorter = other;
|
|
|
|
}
|
|
|
|
} while(shorter != i);
|
|
|
|
|
|
|
|
return shorter;
|
|
|
|
}
|
2017-01-27 19:48:44 +00:00
|
|
|
*/
|
2016-11-23 19:58:05 +00:00
|
|
|
|
2016-11-19 10:16:45 +00:00
|
|
|
void balanced_thickening_callback(const bitvec_t *pos, int size, void *data)
|
|
|
|
{
|
|
|
|
static long totcount = 0;
|
|
|
|
|
2016-11-23 19:58:05 +00:00
|
|
|
if(data) {
|
|
|
|
info_t *info = (info_t*)data;
|
|
|
|
|
|
|
|
unsigned long right_invariance = FIRSTBITS(info->rank);
|
|
|
|
unsigned long left_invariance = FIRSTBITS(info->rank);
|
|
|
|
|
|
|
|
int bit1, bit2left, bit2right, left, right;
|
|
|
|
|
|
|
|
for(int i = 0; i < size; i++) {
|
|
|
|
bit1 = i < size/2 ? bv_get_bit(pos, i) : !bv_get_bit(pos, size - 1 - i);
|
|
|
|
for(int j = 0; j < info->rank; j++) {
|
2017-01-27 19:48:44 +00:00
|
|
|
left = info->dq->cosets[i].min->left[j]->coset - info->dq->cosets;
|
|
|
|
right = info->dq->cosets[i].min->right[j]->coset - info->dq->cosets;
|
2016-11-23 19:58:05 +00:00
|
|
|
bit2left = left < size/2 ? bv_get_bit(pos, left) : !bv_get_bit(pos, size - 1 - left);
|
|
|
|
bit2right = right < size/2 ? bv_get_bit(pos, right) : !bv_get_bit(pos, size - 1 - right);
|
|
|
|
if(bit1 != bit2left)
|
|
|
|
left_invariance &= ~BIT(j);
|
|
|
|
if(bit1 != bit2right)
|
|
|
|
right_invariance &= ~BIT(j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-02 09:31:31 +00:00
|
|
|
printf("%4d left: ", totcount++);
|
2016-11-23 19:58:05 +00:00
|
|
|
for(int j = 0; j < info->rank; j++)
|
2017-01-27 19:48:44 +00:00
|
|
|
printf("%c", left_invariance & (1 << j) ? j + 'a' : ' ');
|
2016-11-23 19:58:05 +00:00
|
|
|
printf(" right: ");
|
|
|
|
for(int j = 0; j < info->rank; j++)
|
2017-01-27 19:48:44 +00:00
|
|
|
printf("%c", right_invariance & (1 << j) ? j + 'a' : ' ');
|
2016-11-23 19:58:05 +00:00
|
|
|
|
2017-01-27 19:48:44 +00:00
|
|
|
/*
|
2016-11-23 19:58:05 +00:00
|
|
|
if(info->buffer) {
|
|
|
|
printf(" generators:");
|
|
|
|
queue_t queue;
|
2017-01-27 19:48:44 +00:00
|
|
|
int cur, left, right;
|
2016-11-23 19:58:05 +00:00
|
|
|
int *buffer = info->buffer;
|
|
|
|
|
|
|
|
for(int i = 0; i < size/2; i++) {
|
|
|
|
buffer[i] = bv_get_bit(pos, i);
|
|
|
|
buffer[size-1-i] = !buffer[i];
|
|
|
|
}
|
|
|
|
for(int i = size-1; i >= 0; i--) {
|
|
|
|
if(buffer[i]) {
|
2017-01-27 19:48:44 +00:00
|
|
|
weylgroup_element_t *shortest = shorten(i, left_invariance, right_invariance, info->dq);
|
|
|
|
printf(" %s", alphabetize(shortest, stringbuffer));
|
2016-11-23 19:58:05 +00:00
|
|
|
buffer[i] = 0;
|
|
|
|
queue_init(&queue);
|
|
|
|
queue_put(&queue, i);
|
2017-01-27 19:48:44 +00:00
|
|
|
while((cur = queue_get(&queue)) != -1) {
|
|
|
|
for(doublecoset_list_t *current = info->dq->coset[cur].bruhat_lower; current; current = current->next) {
|
|
|
|
int idx = current->to - info->dq->cosets;
|
|
|
|
if(buffer[idx]) {
|
|
|
|
buffer[idx] = 0;
|
|
|
|
queue_put(&queue, idx);
|
2016-11-23 19:58:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int j = 0; j < info->rank; j++) {
|
2017-01-27 19:48:44 +00:00
|
|
|
left = info->dq->coset[cur].min.left[j] - info->dq->cosets;
|
2016-11-23 19:58:05 +00:00
|
|
|
if(left_invariance & (1 << j) &&
|
2017-01-27 19:48:44 +00:00
|
|
|
info->graph[left].wordlength < info->graph[cur].wordlength &&
|
2016-11-23 19:58:05 +00:00
|
|
|
buffer[left]) {
|
|
|
|
buffer[left] = 0;
|
|
|
|
queue_put(&queue, left);
|
|
|
|
}
|
2017-01-27 19:48:44 +00:00
|
|
|
right = info->graph[cur].left[j];
|
2016-11-23 19:58:05 +00:00
|
|
|
if(right_invariance & (1 << j) &&
|
2017-01-27 19:48:44 +00:00
|
|
|
info->graph[right].wordlength < info->graph[cur].wordlength &&
|
2016-11-23 19:58:05 +00:00
|
|
|
buffer[right]) {
|
|
|
|
buffer[right] = 0;
|
|
|
|
queue_put(&queue, right);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-02 09:31:31 +00:00
|
|
|
if(info->level >= 5) {
|
|
|
|
printf(" ids: [0");
|
|
|
|
for(int i = 1; i < size/2; i++)
|
|
|
|
if(bv_get_bit(pos, i))
|
|
|
|
printf(", %d", info->graph[i].id);
|
|
|
|
for(int i = 0; i < size/2; i++)
|
|
|
|
if(!bv_get_bit(pos, i))
|
|
|
|
printf(", %d", info->graph[size-1-i].id);
|
|
|
|
printf("]");
|
|
|
|
}
|
2016-11-23 19:58:05 +00:00
|
|
|
}
|
2017-01-27 19:48:44 +00:00
|
|
|
*/
|
2016-11-23 19:58:05 +00:00
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
2016-12-02 09:31:31 +00:00
|
|
|
}
|
2016-11-23 19:58:05 +00:00
|
|
|
|
2016-12-02 09:31:31 +00:00
|
|
|
void balanced_thickening_simple_callback(const bitvec_t *pos, int size, void *data)
|
|
|
|
{
|
|
|
|
long *count = (long*)data;
|
|
|
|
|
|
|
|
if((++(*count)) % 100000000 == 0) {
|
2016-11-19 10:16:45 +00:00
|
|
|
bv_print(stderr, pos, size/2);
|
|
|
|
fprintf(stderr, "\n");
|
2016-12-02 09:31:31 +00:00
|
|
|
}
|
2016-11-19 10:16:45 +00:00
|
|
|
}
|
2016-07-26 08:09:34 +00:00
|
|
|
|
|
|
|
int main(int argc, const char *argv[])
|
|
|
|
{
|
|
|
|
semisimple_type_t type;
|
2016-11-11 16:07:45 +00:00
|
|
|
unsigned long right_invariance, left_invariance;
|
2017-01-27 19:48:44 +00:00
|
|
|
int rank, order, positive;
|
2016-11-14 10:54:52 +00:00
|
|
|
int fixpoints;
|
2016-07-26 08:09:34 +00:00
|
|
|
|
2017-01-27 19:48:44 +00:00
|
|
|
doublequotient_t *dq;
|
2016-07-26 08:09:34 +00:00
|
|
|
|
|
|
|
const char *alphabet = "abcdefghijklmnopqrstuvwxyz";
|
|
|
|
|
2016-11-11 16:07:45 +00:00
|
|
|
// read arguments
|
|
|
|
|
2016-07-26 08:09:34 +00:00
|
|
|
ERROR(argc < 2, "Too few arguments!\n");
|
|
|
|
|
2016-11-11 16:07:45 +00:00
|
|
|
type.n = 0;
|
2016-07-26 08:09:34 +00:00
|
|
|
for(int i = 0; i < argc - 1; i++) {
|
2016-12-13 20:55:21 +00:00
|
|
|
if(argv[i+1][0] < 'A' || argv[i+1][0] > 'G')
|
2016-11-11 16:07:45 +00:00
|
|
|
break;
|
|
|
|
type.n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
type.factors = (simple_type_t*)malloc(type.n*sizeof(simple_type_t));
|
|
|
|
for(int i = 0; i < type.n; i++) {
|
2016-07-26 08:09:34 +00:00
|
|
|
type.factors[i].series = argv[i+1][0];
|
|
|
|
type.factors[i].rank = argv[i+1][1] - '0';
|
2016-12-13 20:55:21 +00:00
|
|
|
ERROR(argv[i+1][0] < 'A' || argv[i+1][0] > 'I' || argv[i+1][1] < '1' || argv[i+1][1] > '9', "Arguments must be Xn with X out of A-G and n out of 1-9\n");
|
2016-07-26 08:09:34 +00:00
|
|
|
}
|
|
|
|
|
2016-11-11 16:07:45 +00:00
|
|
|
left_invariance = right_invariance = 0;
|
2016-07-26 08:09:34 +00:00
|
|
|
|
2016-11-11 16:07:45 +00:00
|
|
|
if(argc - type.n >= 3) {
|
|
|
|
if(strcmp(argv[type.n + 1], "-") != 0)
|
|
|
|
for(int i = 0; i < strlen(argv[type.n + 1]); i++)
|
|
|
|
left_invariance |= (1 << (argv[type.n + 1][i] - 'a'));
|
|
|
|
if(strcmp(argv[type.n + 2], "-") != 0)
|
|
|
|
for(int i = 0; i < strlen(argv[type.n + 2]); i++)
|
|
|
|
right_invariance |= (1 << (argv[type.n + 2][i] - 'a'));
|
2016-07-26 08:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// generate graph
|
|
|
|
|
2017-01-27 19:48:44 +00:00
|
|
|
dq = weyl_generate_bruhat(type, left_invariance, right_invariance);
|
2016-07-26 08:09:34 +00:00
|
|
|
|
|
|
|
// print stuff
|
|
|
|
|
2016-11-23 19:58:05 +00:00
|
|
|
int output_level = 2;
|
|
|
|
if(getenv("OUTPUT_LEVEL"))
|
|
|
|
output_level = atoi(getenv("OUTPUT_LEVEL"));
|
|
|
|
|
2016-11-20 22:19:08 +00:00
|
|
|
rank = weyl_rank(type); // number of simple roots
|
|
|
|
order = weyl_order(type); // number of Weyl group elements
|
2017-01-27 19:48:44 +00:00
|
|
|
positive = weyl_positive(type); // number of positive roots
|
2016-07-26 08:09:34 +00:00
|
|
|
|
2016-11-23 19:58:05 +00:00
|
|
|
if(output_level >= 1) {
|
|
|
|
if(left_invariance) {
|
|
|
|
printf("<");
|
|
|
|
for(int j = 0; j < rank; j++)
|
|
|
|
if(left_invariance & BIT(j))
|
|
|
|
fputc(alphabet[j], stdout);
|
|
|
|
printf("> \\ ");
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i = 0; i < type.n; i++)
|
|
|
|
printf("%s%c%d", i == 0 ? "" : " x ", type.factors[i].series, type.factors[i].rank);
|
2016-11-19 10:16:45 +00:00
|
|
|
|
2016-11-23 19:58:05 +00:00
|
|
|
if(right_invariance) {
|
|
|
|
printf(" / <");
|
|
|
|
for(int j = 0; j < rank; j++)
|
|
|
|
if(right_invariance & BIT(j))
|
|
|
|
fputc(alphabet[j], stdout);
|
|
|
|
printf(">");
|
|
|
|
}
|
|
|
|
fprintf(stdout, "\n");
|
|
|
|
|
2017-01-27 19:48:44 +00:00
|
|
|
fprintf(stdout, "Rank: %d\tOrder: %d\tPositive Roots: %d\tCosets: %d\n\n", rank, order, positive, dq->count);
|
2016-11-23 19:58:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(output_level >= 3) {
|
|
|
|
fprintf(stdout, "Shortest coset representatives: \n");
|
2017-01-27 19:48:44 +00:00
|
|
|
for(int i = 0, wl = 0; i < dq->count; i++) {
|
|
|
|
if(dq->cosets[i].min->wordlength > wl) {
|
|
|
|
printf("\n");
|
|
|
|
wl = dq->cosets[i].min->wordlength;
|
|
|
|
}
|
2017-01-31 19:24:53 +00:00
|
|
|
fprintf(stdout, "%s ", alphabetize(dq->cosets[i].min, stringbuffer));
|
2016-11-23 19:58:05 +00:00
|
|
|
}
|
|
|
|
fprintf(stdout, "\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(output_level >= 4) {
|
|
|
|
fprintf(stdout, "Bruhat order in graphviz format:\n");
|
|
|
|
fprintf(stdout, "digraph test123 {\n");
|
2017-01-27 19:48:44 +00:00
|
|
|
for(int i = 0; i < dq->count; i++)
|
|
|
|
for(doublecoset_list_t *current = dq->cosets[i].bruhat_lower; current; current = current->next)
|
2016-11-23 19:58:05 +00:00
|
|
|
fprintf(stdout, "%s -> %s;\n",
|
2017-01-27 19:48:44 +00:00
|
|
|
alphabetize(dq->cosets[i].min, stringbuffer),
|
|
|
|
alphabetize(current->to->min, stringbuffer2));
|
2016-11-23 19:58:05 +00:00
|
|
|
fprintf(stdout, "}\n\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if(output_level >= 4) {
|
|
|
|
fprintf(stdout, "Opposites:\n");
|
2017-01-27 19:48:44 +00:00
|
|
|
for(int i = 0; i < dq->count; i++)
|
2016-11-23 19:58:05 +00:00
|
|
|
fprintf(stdout, "%s <-> %s\n",
|
2017-01-27 19:48:44 +00:00
|
|
|
alphabetize(dq->cosets[i].min, stringbuffer),
|
|
|
|
alphabetize(dq->cosets[i].opposite->min, stringbuffer2));
|
2016-11-23 19:58:05 +00:00
|
|
|
fprintf(stdout, "\n");
|
2016-07-26 08:09:34 +00:00
|
|
|
}
|
|
|
|
|
2016-11-14 10:54:52 +00:00
|
|
|
fixpoints = 0;
|
2017-01-27 19:48:44 +00:00
|
|
|
for(int i = 0; i < dq->count; i++)
|
|
|
|
if(dq->cosets[i].opposite == &dq->cosets[i]) {
|
2016-11-23 19:58:05 +00:00
|
|
|
if(output_level >= 1) {
|
|
|
|
if(fixpoints == 0)
|
2017-01-27 19:48:44 +00:00
|
|
|
fprintf(stdout, "No thickenings since the longest element fixes the following cosets:");
|
|
|
|
fprintf(stdout, " %s", alphabetize(dq->cosets[i].min, stringbuffer));
|
2016-11-23 19:58:05 +00:00
|
|
|
}
|
2016-11-14 10:54:52 +00:00
|
|
|
fixpoints++;
|
|
|
|
}
|
2016-11-23 19:58:05 +00:00
|
|
|
if(output_level >= 1 && fixpoints)
|
|
|
|
fprintf(stdout, "\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
if(!fixpoints) {
|
2017-01-27 19:48:44 +00:00
|
|
|
int *buffer = (int*)malloc(dq->count*sizeof(int));
|
2016-11-14 10:54:52 +00:00
|
|
|
|
2016-11-23 19:58:05 +00:00
|
|
|
info_t info;
|
2017-01-27 19:48:44 +00:00
|
|
|
info.dq = dq;
|
|
|
|
info.rank = weyl_rank(type);
|
|
|
|
info.order = weyl_order(type);
|
|
|
|
info.positive = weyl_positive(type);
|
2016-11-23 19:58:05 +00:00
|
|
|
info.buffer = buffer;
|
2016-12-02 09:31:31 +00:00
|
|
|
info.level = output_level;
|
2016-11-23 19:58:05 +00:00
|
|
|
|
|
|
|
long count;
|
|
|
|
if(output_level >= 2) {
|
|
|
|
fprintf(stdout, "Balanced ideals:\n", count);
|
2017-01-27 19:48:44 +00:00
|
|
|
count = enumerate_balanced_thickenings(dq, balanced_thickening_callback, &info);
|
2016-11-23 19:58:05 +00:00
|
|
|
fprintf(stdout, "\n", count);
|
2016-12-02 09:31:31 +00:00
|
|
|
} else {
|
|
|
|
long outputcount = 0;
|
2017-01-27 19:48:44 +00:00
|
|
|
count = enumerate_balanced_thickenings(dq, balanced_thickening_simple_callback, &outputcount);
|
2016-11-23 19:58:05 +00:00
|
|
|
}
|
2016-11-14 10:54:52 +00:00
|
|
|
|
2016-11-23 19:58:05 +00:00
|
|
|
if(output_level >= 1)
|
|
|
|
fprintf(stdout, "Found %ld balanced ideal%s\n", count, count == 1 ? "" : "s");
|
2016-11-14 10:54:52 +00:00
|
|
|
}
|
2016-07-26 08:09:34 +00:00
|
|
|
|
2017-01-27 19:48:44 +00:00
|
|
|
weyl_destroy_bruhat(dq);
|
2016-07-26 08:09:34 +00:00
|
|
|
free(type.factors);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|