SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
CNFerModule.tpp
Go to the documentation of this file.
1 /*
2  * File: CNFerModule.cpp
3  * Author: Florian Corzilius
4  *
5  * Created on 02. May 2012, 20:53
6  */
7 
8 #include "CNFerModule.h"
9 
10 #include <carl-formula/formula/functions/CNF.h>
11 
12 namespace smtrat
13 {
14  CNFerModule::CNFerModule( const ModuleInput* _formula, Conditionals& _conditionals, Manager* const _manager ):
15  PModule( _formula, _conditionals, _manager )
16  {
17  }
18 
19  CNFerModule::~CNFerModule(){}
20 
21  Answer CNFerModule::checkCore()
22  {
23  auto receivedSubformula = firstUncheckedReceivedSubformula();
24  while( receivedSubformula != rReceivedFormula().end() )
25  {
26  /*
27  * Add the currently considered formula of the received constraint as clauses
28  * to the passed formula.
29  */
30  FormulaT formulaToAssertInCnf = carl::to_cnf(receivedSubformula->formula());
31  if( formulaToAssertInCnf.type() == carl::FormulaType::TRUE )
32  {
33  // No need to add it.
34  }
35  else if( formulaToAssertInCnf.type() == carl::FormulaType::FALSE )
36  {
37  receivedFormulasAsInfeasibleSubset( receivedSubformula );
38  return UNSAT;
39  }
40  else
41  {
42  if( formulaToAssertInCnf.type() == carl::FormulaType::AND )
43  {
44  for( const FormulaT& subFormula : formulaToAssertInCnf.subformulas() )
45  {
46  #ifdef SMTRAT_DEVOPTION_Statistics
47  mStatistics.addClauseOfSize( subFormula.size() );
48  #endif
49  addSubformulaToPassedFormula( subFormula, receivedSubformula->formula() );
50  }
51  }
52  else
53  {
54  #ifdef SMTRAT_DEVOPTION_Statistics
55  mStatistics.addClauseOfSize( receivedSubformula->formula().size() );
56  #endif
57  addSubformulaToPassedFormula( formulaToAssertInCnf, receivedSubformula->formula() );
58  }
59  }
60  ++receivedSubformula;
61  }
62  //No given formulas is SAT but only if no other run was before
63  if( rPassedFormula().empty() && solverState() == UNKNOWN )
64  {
65  return SAT;
66  }
67  else
68  {
69  #ifdef SMTRAT_DEVOPTION_Statistics
70  carl::carlVariables _vars;
71  rPassedFormula().gatherVariables(_vars);
72  mStatistics.nrOfArithVariables() = _vars.arithmetic().size();
73  mStatistics.nrOfBoolVariables() = _vars.boolean().size();
74  #endif
75  Answer a = runBackends();
76 
77  if( a == UNSAT )
78  {
79  getInfeasibleSubsets();
80  }
81  return a;
82  }
83  }
84 } // namespace smtrat