Ejemplo n.º 1
0
void DPLLFormulaParseLOP(Scanner_p in, Sig_p sig, DPLLFormula_p form)
{
   Clause_p clause;
   DPLLClause_p pclause;
   TB_p terms = TBAlloc(sig);
   
   while(ClauseStartsMaybe(in))
   {
      clause = ClauseParse(in, terms);
      pclause = DPLLClauseFromClause(form->sig, clause);
      ClauseFree(clause);
      fprintf(GlobalOut, "New clause: ");
      DPLLClausePrintLOP(GlobalOut, form->sig, pclause);
      if(DPLLClauseNormalize(pclause))
      {
	 fprintf(GlobalOut, "...discarded (tautology)\n");
	 DPLLClauseFree(pclause);
	 continue;
      }
      DPLLFormulaInsertClause(form, pclause);
      fprintf(GlobalOut, "...accepted\n");
   }
   terms->sig = NULL;
   TBFree(terms);
}
Ejemplo n.º 2
0
int main(int argc, char* argv[])
{
   TB_p            terms;
   GCAdmin_p       collector;
   VarBank_p       freshvars;
   Sig_p           sig;
   ClauseSet_p     clauses;
   FormulaSet_p    formulas, f_ax_archive;
   Scanner_p       in;    
   int             i;
   CLState_p       state;
   StrTree_p       skip_includes = NULL;
   ClauseSet_p     demodulators[1];
   OCB_p           ocb;

   assert(argv[0]);
   
   InitIO(NAME);
#ifdef STACK_SIZE
   IncreaseMaxStackSize(argv, STACK_SIZE);
#endif   
   ESignalSetup(SIGXCPU);

   state = process_options(argc, argv);
   
   OpenGlobalOut(outname);
   
   if(state->argc ==  0)
   {
      CLStateInsertArg(state, "-");
   }
   
   sig          = SigAlloc(); 
   SigInsertInternalCodes(sig);
   terms        = TBAlloc(sig);
   collector    = GCAdminAlloc(terms);
   clauses      = ClauseSetAlloc();
   formulas     = FormulaSetAlloc();
   f_ax_archive = FormulaSetAlloc();

   GCRegisterClauseSet(collector, clauses);
   GCRegisterFormulaSet(collector, formulas);
   GCRegisterFormulaSet(collector, f_ax_archive);

   for(i=0; state->argv[i]; i++)
   {
      in = CreateScanner(StreamTypeFile, state->argv[i], true, NULL);
      ScannerSetFormat(in, parse_format);
      /* ClauseSetParseList(in, clauses, terms); */
      FormulaAndClauseSetParse(in,clauses, formulas, terms, 
         NULL, &skip_includes);
      CheckInpTok(in, NoToken);
      DestroyScanner(in);
   }
   CLStateFree(state);

   if(FormulaSetPreprocConjectures(formulas, f_ax_archive, false, false))
   {
      VERBOUT("Negated conjectures.\n");
   }
   freshvars = VarBankAlloc();
   if(FormulaSetCNF(formulas, f_ax_archive, 
                    clauses, terms, freshvars, collector))
   {
      VERBOUT("CNFization done\n");
   }
   VarBankFree(freshvars);

   GCDeregisterFormulaSet(collector, formulas);
   FormulaSetFree(formulas);
   GCDeregisterFormulaSet(collector, f_ax_archive);
   FormulaSetFree(f_ax_archive);

   demodulators[0] = ClauseSetAlloc();
   demodulators[0]->demod_index = PDTreeAlloc();
   GCRegisterClauseSet(collector, demodulators[0]);

   build_rw_system(demodulators[0], clauses);


   GCDeregisterClauseSet(collector, clauses);
   ClauseSetFree(clauses);  

   VERBOUT("# Demodulators\n");
   VERBOSE(ClauseSetPrint(stderr, demodulators[0], true););