/* wordreduce.c 1/11/94. * 6/11/99 re-introduce option to input list of words from filename. * also added -e option (expanded) to output expanded powers. * 6/8/98 large scale reorganisation to omit globals, etc. * 5/2/98 change generators from type char to type `gen'. * * 15/3/96 - amalgamated with wordreducecos.c, which was specially written * for reducing cosets using a word-difference machines. * There is now a -cos option, which means reduce cosets (using either * a rewriting system or a word-difference machine). * For coset reduction using a rewrting system, the word to be reduced can * contain any of available symbols, but to make sense (for H subgroup of G), * it should either be a word in the G-generators alone, or a word in the * H-generators alone, or a word of form H-word*_H*G-word. * For coset reduction using a word-difference machine, the word to be * reduced must either be in the G-generators alone, or have form _H*G-word. * * Input of words from a filename specified on command line no longer works. * * 18/1/95 - added options to reduce words using rewriting system. * Reduce words using a rewriting system or a word-difference machine. * * SYNOPSIS: * wordreduce [-kbprog/-diff1/-diff2/-diff1c] [-mrl maxreducelen] [-e] * [-cos] groupname [cosname] [-f filename] * * If -cos is false: * Input is from groupname.kbprog, groupname.diff1, groupname.diff2 or * groupname.diff1c, and stdin. * * If -cos is true: * cosname defaults to "cos" * Input is from groupname.cosname.kbprog, groupname.cosname.midiff1, * groupname.cosname.midiff2, and stdin (unless -f filename is used). * * Output is to stdout (unless -f filename is used). * * If the optional "-f filename" argument is present, then the file filename * should contain an assignment of a list of words to be reduced * (e.g. words := [a^3,(a*b)^7];), and output will be a list of reduced words * to filename.reduced. * * OPTIONS: * -cos If set reduce cosets. This changes i/o files. * * -kbprog/diff1/diff2/diff1c * This determines which finite state automaton is used for * the word-reduction. * If the kbprog flag is called, then a rewriting system is * input from groupname.kbprog * (or, if -cos, groupname.cosname.kbprog). * Otherwise, a word-difference machine is input from the * appropriate file. * The default is groupname.kbprog if that file is present, * and otherwise groupname.diff2. * * Words are input interactively to stdin and output to stdout.
*/
if (file_ip) { /* open file containing list of words, and deal with assignment */ if ((rfile = fopen(inf2, "r")) == 0) {
fprintf(stderr, "Cannot open file %s.\n", inf2); exit(1);
}
wfile = fopen(outf, "w");
read_ident(rfile, kbm_buffer, &delim, FALSE);
fprintf(wfile, "%s.reduced := [\n", kbm_buffer); if (delim != ':') {
fprintf(stderr, "#Input error: file must contain a list assignment\n"); exit(1);
}
check_next_char(rfile, '=');
read_delim(rfile, &delim); if (delim != '[') {
fprintf(stderr, "#Input error: file must contain a list assignment\n"); exit(1);
}
first = TRUE;
} else {
printf("#Input words for reduction.\n#Separate words with ','.\n");
printf("#Terminate input with ';'.\n");
rfile = stdin;
wfile = stdout;
}
delim = 0; while (delim != ';' && delim != ']') {
read_word(rfile, gen_word, gen_word + rwsptr->maxreducelen, &delim,
gen_names, num_gens, TRUE);
reduce_word(gen_word, &rs); if (genstrlen(gen_word) > rwsptr->maxreducelen / 2) {
fprintf(wfile, "Word grew too long during reduction!\n");
} else { if (file_ip) { if (first)
first = FALSE; else
fprintf(wfile, ",\n");
} else
fprintf(wfile, "reduces to:\n");
strcpy(kbm_buffer, " "); if (expwds)
add_expanded_word_to_buffer(wfile, gen_word, gen_names); else
add_word_to_buffer(wfile, gen_word, gen_names); if (file_ip)
fprintf(wfile, "%s", kbm_buffer); else
fprintf(wfile, "%s\n", kbm_buffer);
}
} if (file_ip) {
check_next_char(rfile, ';');
fprintf(wfile, "\n];\n");
fclose(wfile);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.