@*Intro. This program generates {\mc DLX} data that finds all polymorphisms of given relations. I've tried to make it fairly general, so that I can use it for experiments. But I haven't tried to make it especially efficient. The first command-line parameter is $d,ドル the domain size. It is followed by $k,ドル the arity of the polymorphism. Then come the tuples of a relation. And the next parameter might then be `\.{/}', in which case another relation (or sequence of relations) follows. @d maxk 7 /* maximum arity of the polymorphism */ @d maxm 10 /* maximum arity of the relations */ @d maxr 10 /* maximum number of relations */ @d maxt 16 /* maximum number of tuples per relation */ @c #include #include #include int d,k; /* command-line parameters */ char tup[maxr][maxt][maxm]; /* tuples of the relations */ char siz[maxr]; /* the number of tuples in each relation */ char arity[maxr]; /* the arity of each relation */ char a[maxk]; /* controlling digits */ int nam[maxk]; /* hexadecimal names of arguments */ main(int argc,char*argv[]) { register i,j,l,m,p,r,s,t,v; @; @; @; for (i=0;i; } @ @= if (argc<3 || sscanf(argv[1],"%d", &d)!=1 || sscanf(argv[2],"%d", &k)!=1) { fprintf(stderr,"Usage: %s d k [/ ]*\n", argv[0]); exit(-1); } if (k<=0 || k>maxk) { fprintf(stderr,"Sorry, k must be positive and at most %d!\n", maxk); exit(-2); } for (r=0,p=3;r; if (r==maxr) { fprintf(stderr,"Too many relations (maxr=%d)!\n", maxr@t)@>); exit(-9); } @; @ @= { for (s=0;argv[p] && argv[p][0]!='/';p++,s++) { if (s==0) m=strlen(argv[p]); else if (m!=strlen(argv[p])) { fprintf(stderr,"tuple %s should have length %d, not %d!\n", argv[p],m,(int)strlen(argv[p])); exit(-3); } if (s==maxt) { fprintf(stderr,"too many tuples (maxt=%d)!\n", maxt@t)@>); exit(-4); } for (j=0;j=d) { fprintf(stderr,"value in tuple %s is out of range!\n", argv[p]); exit(-4); } tup[r][s][j]=v; } } if (s==0) { fprintf(stderr,"Empty relation (no tuples)!\n"); exit(-5); } siz[r]=s, arity[r]=m; if (!argv[p++]) break; } @ @= r++; fprintf(stderr,"OK, I've input %d relation%s of size%s!arit%s", r,r==1?"":"s",r==1?"":"s",r==1?"y":"ies"); for (j=0;j= printf("|"); for (j=0;j= for (i=0;i=0 && a[j]==siz[i]-1;j--) a[j]=0; if (j<0) break; a[j]++; } } printf("|"); for (j=0;j=0 && a[j]==d-1;j--) a[j]=0; if (j<0) break; a[j]++; } printf("\n"); @ @= { for (j=0;j=0 && a[j]==siz[i]-1;j--) a[j]=0; if (j<0) break; a[j]++; } } @*Index.

AltStyle によって変換されたページ (->オリジナル) /