Beispiel #1
0
//
// check_consistency -- test that the ON-set, OFF-set and DC-set form
// a partition of the boolean space.
//
bool
check_consistency(PLA_t *PLA)
{
    bool verify_error = FALSE;
    set_family_t *T;

    T = cv_intersect(PLA->F, PLA->D);
    if (T->count == 0)
        printf("ON-SET and DC-SET are disjoint\n");
    else {
        printf("Some minterm(s) belong to both the ON-SET and DC-SET !\n");
        if (verbose_debug)
            cprint(T);
        verify_error = TRUE;
    }
    fflush(stdout);
    sf_free(T);

    T = cv_intersect(PLA->F, PLA->R);
    if (T->count == 0)
        printf("ON-SET and OFF-SET are disjoint\n");
    else {
        printf("Some minterm(s) belong to both the ON-SET and OFF-SET !\n");
        if (verbose_debug)
            cprint(T);
        verify_error = TRUE;
    }
    fflush(stdout);
    sf_free(T);

    T = cv_intersect(PLA->D, PLA->R);
    if (T->count == 0)
        printf("DC-SET and OFF-SET are disjoint\n");
    else {
        printf("Some minterm(s) belong to both the OFF-SET and DC-SET !\n");
        if (verbose_debug)
            cprint(T);
        verify_error = TRUE;
    }
    fflush(stdout);
    sf_free(T);

    if (tautology(cube3list(PLA->F, PLA->D, PLA->R)))
        printf("Union of ON-SET, OFF-SET and DC-SET is the universe\n");
    else {
        T = complement(cube3list(PLA->F, PLA->D, PLA->R));
        printf("There are minterms left unspecified !\n");
        if (verbose_debug)
            cprint(T);
        verify_error = TRUE;
        sf_free(T);
    }
    fflush(stdout);
    return verify_error;
}
Beispiel #2
0
int
removeTautologies(Array<BinaryTree_AVL<Clause> > &clarray, 
	unsigned int curdepth)
{
	// list of tautologies to remove
	List<Clause> clausesToRemove;

	// check if these tests should be run
	if (!tautologytest)
		return(OK);

	// scan each equivalence set for tautologies
	BinaryTree_AVL_Iterator_InOrder<Clause> clIter(clarray[curdepth]);
	for ( ; !clIter.done(); clIter++)
	{
		// check each member for being a tautolgy
		Clause clause(clIter());
		statistics[AttemptedTautologyTests] += 1;
		totalstatistics[TotalAttemptedTautologyTests] += 1;
		if (tautology(clause) == OK)
		{
			// we have a tautology, remove it.
			statistics[TautologiesRemoved] += 1;
			totalstatistics[TotalTautologiesRemoved] += 1;
			if (clausesToRemove.insert(clause) != OK)
			{
				ERROR("insert failed.", errno);
				return(NOTOK);
			}
		}
	}

	// remove any clauses
	ListIterator<Clause> cltrIter(clausesToRemove);
	for ( ; !cltrIter.done(); cltrIter++)
	{
		Clause clause(cltrIter());
		int status = clarray[curdepth].remove(clause);
		if (status != OK && status != NOMATCH)
		{
			ERROR("remove failed.", errno);
			return(NOTOK);
		}
	}

	// all done
	return(OK);
}
Beispiel #3
0
// remove tautologies
int
removeTautologies(Array<OrderedSet<Clause> > &clarray, unsigned int curdepth)
{
	// list of tautologies to remove
	List<Clause> clausesToRemove;

	// scan each equivalence set for tautologies
	OrderedSetIterator<Clause> clIter(clarray[curdepth]);
	for ( ; !clIter.done(); clIter++)
	{
		// check each member in an equivalence set.
		ListIterator<Clause> dataIter(clIter.data());
		for ( ; !dataIter.done(); dataIter++)
		{
			Clause clause(dataIter());
			if (tautology(clause) == OK)
			{
				// we have a tautology, remove it.
				if (clausesToRemove.insert(clause) != OK)
					return(NOTOK);
			}
		}
	}

	// remove any clauses
	ListIterator<Clause> cltrIter(clausesToRemove);
	for ( ; !cltrIter.done(); cltrIter++)
	{
		Clause clause(cltrIter());
		if (clarray[curdepth].remove(clause) != OK)
			return(NOTOK);
	}

	// all done
	return(OK);
}