Exemplo n.º 1
0
//Checks if during transformations we come up with nodes with equal clauses
void ProofGraph::checkClauseDuplicates()
{
	int count=0;
	bool succ;

	cout << "# Checking for duplicates and subsumptions" << endl;

	for(size_t i=0;i<graph.size();i++)
		for(size_t j=i+1;j<graph.size();j++)
			if(graph[i]!=NULL && graph[j]!=NULL)
			{
				if(graph[i]->clause.size()==graph[j]->clause.size())
				{
					succ=true;
					for(size_t k=0;k<graph[i]->clause.size();k++)
						if(!litEq(graph[i]->clause[k],graph[j]->clause[k]))
						{ succ=false; break;}
					if(succ)
					{
						cerr << "Clause " << i << " of type " << graph[i]->type << " is equal to clause "
								<< j << " of type " << graph[j]->type << endl;
						printClause(graph[i]);
						printClause(graph[j]);
						count++;
					}
				}
			}
}
Exemplo n.º 2
0
//Checks for various issues
//return false if issues present
void ProofGraph::checkClause(clauseid_t nid)
{
	ProofNode* n=graph[nid];
	assert(n!=NULL);
	assert(n->getId()==nid);

	//Check if empty clause
	if(n->getId()==root)
	{
		if(n->clause.size()!=0)
		{
			cerr << n->getId() << " is the sink but not an empty clause" << endl;
			printClause(n);
			assert(false);
		}
	}
	if(n->getClauseSize()==0)
	{
		if(n->getType()==CLAORIG || n->getType()==CLALEMMA)
		{
			cerr << n->getId() << " is an empty original or lemma clause" << endl;
			assert(false);
		}
	}

	if(n->ant1==NULL && n->ant2!=NULL)
	{
		cerr << "Antecedent 1 null" << endl;
		assert(false);
	}
	if(n->ant1!=NULL && n->ant2==NULL)
	{
		cerr << "Antecedent 2 null" << endl;
		assert(false);
	}

	if(n->ant1!=NULL && n->ant2!=NULL)
	{
		assert(n->id != n->ant1->id && n->id !=n->ant2->id);

		vector<Lit> v;
		mergeClauses(n->ant1->clause,n->ant2->clause,v,n->pivot);
		if(v.size()!=n->clause.size())
		{
			cerr << "Clause : "; printClause(graph[nid]); cout << " does not correctly derive from antecedents " << endl;
			printClause(graph[n->ant1->id]);
			printClause(graph[n->ant2->id]);
			assert(false);
		}
		for(size_t i=0;i<n->clause.size();i++)
			if(!litEq(n->clause[i],v[i]))
			{
				cerr << "Clause : "; printClause(graph[nid]); cout << " does not correctly derive from antecedents " << endl;
				printClause(graph[n->ant1->id]);
				printClause(graph[n->ant2->id]);
				assert(false);
			}
		assert(graph[n->ant1->id]!=NULL);
		assert(graph[n->ant2->id]!=NULL);
	}
}
Exemplo n.º 3
0
//Checks for various issues
//return false if issues present
void ProofGraph::checkClause(clauseid_t nid)
{
	ProofNode* n=graph[nid];
	assert(n!=NULL);
	assert(n->id==nid);

	//Check if empty clause
	if(n->id==root)
	{
		if(n->clause.size()!=0)
		{
			cerr << n->id << " is the sink but not an empty clause" << endl;
			printClause(n);
			assert(false);
		}
	}
	if(n->clause.size()==0)
	{
		if(n->id!=root)
		{
			cerr << n->id << " is an empty clause not sink" << endl;
			printClause(n);
			assert(false);
		}
	}
	else
	{
		checkClauseSorting(nid);
	}

	if(n->ant1==NULL && n->ant2!=NULL)
	{
		cerr << "Antecedent 1 null" << endl;
		assert(false);
	}
	if(n->ant1!=NULL && n->ant2==NULL)
	{
		cerr << "Antecedent 2 null" << endl;
		assert(false);
	}

	if(n->ant1!=NULL && n->ant2!=NULL)
	{
		assert(n->id != n->ant1->id && n->id !=n->ant2->id);

		vector<Lit> v;
		mergeClauses(n->ant1->clause,n->ant2->clause,v,n->pivot);
		if(v.size()!=n->clause.size())
		{
			cerr << "Clause : "; printClause(graph[nid]); cout << " does not correctly derive from antecedents " << endl;
			printClause(graph[n->ant1->id]);
			printClause(graph[n->ant2->id]);
			assert(false);
		}
		for(size_t i=0;i<n->clause.size();i++)
			if(!litEq(n->clause[i],v[i]))
			{
				cerr << "Clause : "; printClause(graph[nid]); cout << " does not correctly derive from antecedents " << endl;
				printClause(graph[n->ant1->id]);
				printClause(graph[n->ant2->id]);
				assert(false);
			}
		assert(graph[n->ant1->id]!=NULL);
		assert(graph[n->ant2->id]!=NULL);
	}

	set<ProofNode*>::iterator it;
	ProofNode* r;
	for(it=n->res.begin();it!=n->res.end();it++)
	{
		r=(*it);
		if(graph[r->id]==NULL)
		{
			cerr << "Clause " << nid << " resolvent " << r->id << " does not exist anymore " << endl;
			assert(false);
		}
		assert(r->ant1==n || r->ant2==n);
	}
}