calc_wa = TRUE; while (calc_wa) { /* First read in word-difference machine for calculating word-acceptor, *fromgroupname.(mi)diff1(if-diff1flagset)orgroupname.(mi)diff2
*/ if ((rfile = fopen(inf1, "r")) == 0) {
fprintf(stderr, "Cannot open file %s.\n", inf1); exit(1);
}
fsa_read(rfile, &diff2, DENSE, 0, 0, TRUE, fsaname);
fclose(rfile);
/* Now calculate word-acceptor */
wa = cosets ? fsa_wa_cos(&diff2, op_store_wa, TRUE, tempfilename)
: fsa_wa(&diff2, op_store_wa, TRUE, tempfilename);
assert(wa);
if (kbm_print_level > 1)
printf(" #Number of states of word-acceptor before minimisation = %d.\n",
wa->states->size); if (fsa_minimize(wa) == -1) exit(1); if (kbm_print_level > 1)
printf(" #Number of states of word-acceptor after minimisation = %d.\n",
wa->states->size);
if (foundeqns) { /*This is the case where the calculation failed and new equations was *found.Ifthe-diff1flagwasset,wecorrectthegroupname.(mi)diff1 *machine.
*/ if (correction) { if (kbm_print_level > 1)
printf(" #Altering first wd-machine to make it accept new " "equations.\n"); /* Read in diff1 machine from groupname.diff1 */ if ((rfile = fopen(inf1, "r")) == 0) {
fprintf(stderr, "Cannot open file %s.\n", inf1); exit(1);
}
fsa_read(rfile, &diff1, DENSE, 0, maxwdiffs, TRUE, fsaname);
fclose(rfile); /* we need the original diff2 machine to do word-reduction- *Thiscomesfromgroupname.diff2orgroupname.midiff2
*/ if (cosets) {
tmalloc(diff1.is_initial, boolean, maxwdiffs + 1); for (i = 1; i <= maxwdiffs; i++)
diff1.is_initial[i] = FALSE; for (i = 1; i <= diff1.num_initial; i++)
diff1.is_initial[diff1.initial[i]] = TRUE;
}
rs_wd.wd_fsa = &diff2; /* We use this to do the word-reductions */ if (cosets)
rs_wd.separator = diff2.alphabet->base->size + 1;
reduce_word = cosets ? diff_reduce_cos : diff_reduce; if (fsa_table_dptr_init(&diff1) == -1) exit(1);
/* We need to know the inverses of generators - let's just work them
* out! */
ngens = diff1.alphabet->base->size; if (calculate_inverses(&inv, ngens, &rs_wd) == -1) exit(1);
i = 0; if (cosets)
tmalloc(rhscos, gen, 8192); while (eqnptr[i].lhs && i < maxeqns1) { if (cosets) { /* Here we need to re-reduce the lhs, to get the prefix in the
* subgroup */
tfree(eqnptr[i].rhs);
genstrcpy(rhscos, eqnptr[i].lhs);
reduce_word(rhscos, &rs_wd);
tmalloc(eqnptr[i].rhs, gen, genstrlen(rhscos) + 1);
genstrcpy(eqnptr[i].rhs, rhscos); if (add_wd_fsa_cos(&diff1, eqnptr + i, inv, FALSE, &rs_wd) == -1) exit(1);
} elseif (add_wd_fsa(&diff1, eqnptr + i, inv, FALSE, &rs_wd) == -1) exit(1);
i++;
} if (cosets) {
tfree(rhscos);
tfree(diff1.initial);
tmalloc(diff1.initial, int, diff1.num_initial + 1);
ct = 0; for (i = 1; i <= diff1.states->size; i++) if (diff1.is_initial[i])
diff1.initial[++ct] = i;
tfree(diff1.is_initial);
}
if (kbm_print_level > 1)
printf(" #First word-difference machine now has %d states.\n",
diff1.states->size);
tfree(inv);
fsa_clear(&diff1);
i = 0; while (eqnptr[i].lhs && i < maxeqns1) {
tfree(eqnptr[i].lhs);
tfree(eqnptr[i].rhs);
i++;
}
tfree(eqnptr);
}
calc_wa = TRUE;
tfree(wa);
fsa_clear(&diff2); break;
} if (genmultptr == 0) exit(1);
/* At this stage we have successfully calculated the generalised *multiplier.
*/ if (correction)
tfree(eqnptr);
if (kbm_print_level > 1) { if (cosets)
printf(" #Number of states of mi-multiplier before minimisation = " "%d.\n",
genmultptr->states->size); else
printf( " #Number of states of multiplier before minimisation = %d.\n",
genmultptr->states->size);
} if (readback) { if (cosets) { if (midfa_labeled_minimize(genmultptr) == -1) exit(1);
} elseif (fsa_labeled_minimize(genmultptr) == -1) exit(1);
} elseif (fsa_ip_labeled_minimize(genmultptr) == -1) exit(1); if (kbm_print_level > 1) { if (cosets)
printf( " #Number of states of mi-multiplier after minimisation = %d.\n",
genmultptr->states->size); else
printf(" #Number of states of multiplier after minimisation = %d.\n",
genmultptr->states->size);
}
if (kbm_print_level > 0) { if (cosets)
printf("#General mi-multiplier with %d states computed.\n",
genmultptr->states->size); else
printf("#General multiplier with %d states computed.\n",
genmultptr->states->size);
}
fsa_clear(genmultptr);
calc_gm = FALSE;
if (cosets) { /* Now we read back in the general mi-multiplier and determinize it */ if ((rfile = fopen(outf2mi, "r")) == 0) {
fprintf(stderr, "Cannot open file %s.\n", outf2mi); exit(1);
}
fsa_read(rfile, &migenmult, ip_store, dr, 0, TRUE, fsaname);
fclose(rfile);
tfree(genmultptr);
genmultptr =
migm_determinize(&migenmult, op_store_gm, TRUE, tempfilename); if (kbm_print_level > 1)
printf( " #Number of states of multiplier before minimisation = %d.\n",
genmultptr->states->size); if (fsa_labeled_minimize(genmultptr) == -1) exit(1); if (kbm_print_level > 1)
printf(" #Number of states of multiplier after minimisation = %d.\n",
genmultptr->states->size); if (kbm_print_level > 0)
printf("#General multiplier with %d states computed.\n",
genmultptr->states->size);
base_prefix(fsaname);
strcat(fsaname, ".gm");
wfile = fopen(outf2, "w");
fsa_print(wfile, genmultptr, fsaname);
fclose(wfile);
}
/* Now perform the check on the multiplier - we read it back in, since *thestoragetypehasusuallychanged.
*/
if (cosets)
separator = genmultptr->alphabet->base->size + 1;
tmalloc(eqnptr, reduction_equation, maxeqns2)
if ((numeqns = fsa_checkmult(genmultptr, eqnptr, maxeqns2, cosets,
separator)) > 0)
{ /* A multiplier was not valid, so groupname.diff2 will need updating. */
fsa_clear(genmultptr); if (kbm_print_level > 1)
printf(" #Altering second wd-machine to make it accept new " "equations.\n"); /* We read it into diff2, and then copy it into *wd_fsa.Thecopyisusedforreducingwords-Notsurprisingly, *wegetproblemsifwetrytoalteritwhileusingitat *thesametime!
*/ if ((rfile = fopen(inf2, "r")) == 0) {
fprintf(stderr, "Cannot open file %s.\n", inf2); exit(1);
}
fsa_read(rfile, &diff2, DENSE, 0, maxwdiffs, TRUE, fsaname);
fclose(rfile);
tmalloc(wd_fsa, fsa, 1);
fsa_copy(wd_fsa, &diff2);
reduce_word = cosets ? diff_reduce_cos : diff_reduce;
rs_wd.wd_fsa = wd_fsa; if (fsa_table_dptr_init(wd_fsa) == -1) exit(1); if (fsa_table_dptr_init(&diff2) == -1) exit(1); if (cosets) {
tmalloc(diff2.is_initial, boolean, maxwdiffs + 1); for (i = 1; i <= maxwdiffs; i++)
diff2.is_initial[i] = FALSE; for (i = 1; i <= diff2.num_initial; i++)
diff2.is_initial[diff2.initial[i]] = TRUE;
rs_wd.separator = separator;
} /* We need to know the inverses of generators - let's just work them
* out! */
ngens = diff2.alphabet->base->size; if (calculate_inverses(&inv, ngens, &rs_wd) == -1) exit(1);
old_ndiff = diff2.states->size;
/* Now add the new equations *Therighthandsideoftheequationtobeaddedwillbethereduction *ofthelhstimesthegeneratorwhichiscurrentlyinthelhs.
*/ for (i = 0; i < numeqns; i++) {
genstrcat(eqnptr[i].lhs, eqnptr[i].rhs);
tfree(eqnptr[i].rhs); /* In the cosets case, we need to allow some extra room for the *reductionoftheword,sinceitmightacquirealongprefixinthe *subgroup.
*/ if (cosets)
tmalloc(
eqnptr[i].rhs, gen,
PREFMARGIN +
genstrlen(
eqnptr[i].lhs)) else tmalloc(eqnptr[i].rhs, gen, 1 + genstrlen(
eqnptr[i].lhs));
genstrcpy(eqnptr[i].rhs, eqnptr[i].lhs);
reduce_word(eqnptr[i].rhs, &rs_wd); if (cosets) { if (add_wd_fsa_cos(&diff2, eqnptr + i, inv, TRUE, &rs_wd) == -1) exit(1);
} elseif (add_wd_fsa(&diff2, eqnptr + i, inv, TRUE, &rs_wd) == -1) exit(1);
}
if (cosets) {
tfree(diff2.initial);
tmalloc(diff2.initial, int, diff2.num_initial + 1);
ct = 0; for (i = 1; i <= diff2.states->size; i++) if (diff2.is_initial[i])
diff2.initial[++ct] = i;
tfree(diff2.is_initial);
make_full_wd_fsa_cos(&diff2, inv, old_ndiff + 1, &rs_wd);
} else
make_full_wd_fsa(&diff2, inv, old_ndiff + 1, &rs_wd); if (kbm_print_level > 1)
printf(" #Second word-difference machine now has %d states.\n",
diff2.states->size);
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.