示例#1
0
 result_type operator() (logic::tag::nand_tag const& tag, result_type lhs, result_type rhs )
 {
   result_type out = { int(impl::new_var_id()) };
   clause3(-lhs,-rhs,-out);
   clause2( rhs, out);
   clause2( lhs, out);
   return out;
 }
示例#2
0
文件: deletion.cpp 项目: ombt/ombt
int
subsumes(const Clause &cl1, const Clause &cl2, Substitutions &s)
{
	// clear substitution list
	s.clear();

	// make sure the clauses are not the same one.
	// this check works since the index in literals
	// are never reassigned.
	//
	if (cl1 == cl2)
	{
		return(NOMATCH);
	}

	// check that every class in clause 1 exists in clause 2. 
	if (subset(cl1, cl2) != OK)
	{
		return(NOMATCH);
	}

	// now start the actual subsumption algorithm.
	Substitutions subs;
	Clause clause2(cl2);
	if (groundSubstitutions(clause2, subs) != OK)
	{
		ERROR("groundSubstitutions failed.", errno);
		return(NOTOK);
	}

	// convert second clause to a ground clause
	if (subs.applyTo(clause2) != OK)
	{
		ERROR("applyTo failed.", errno);
		return(NOTOK);
	}

	// copy clauses to arrays
	Array<Literal> clarray1(1, cl1.getTotalMembers());
	ClauseIterator cl1Iter(cl1);
	for (int i=1; !cl1Iter.done(); i++, cl1Iter++)
	{
		clarray1[i] = cl1Iter();
	}
	Array<Literal> clarray2(1, cl2.getTotalMembers());
	ClauseIterator cl2Iter(clause2);
#ifdef SC42
	for (i=1; !cl2Iter.done(); i++, cl2Iter++)
#else
	for (int i=1; !cl2Iter.done(); i++, cl2Iter++)
#endif
	{
		clarray2[i] = cl2Iter();
	}

	// use Stillman's algorithm
	statistics[AttemptedStillmanSubsumptionTests] += 1;
	totalstatistics[TotalAttemptedStillmanSubsumptionTests] += 1;
	int status = ST(clarray1, clarray2, 1, 1, s);
	if (status == OK && verbose)
	{
		cout << endl;
		cout << "clause1 subsumes clause2 ..." << endl;
		cout << "clause1: " << cl1 << endl;
		cout << "clause2: " << cl2 << endl;
	}
	return(status);
}