libgsjj  1
Deterministic finite automata learning library
Public Member Functions | Protected Member Functions | List of all members
gsjj::passive::CNF::SATCNFMethod Class Referenceabstract

Base class for every method that relies on a SAT solver. More...

#include <SATCNFMethod.h>

Inheritance diagram for gsjj::passive::CNF::SATCNFMethod:
Inheritance graph
[legend]
Collaboration diagram for gsjj::passive::CNF::SATCNFMethod:
Collaboration graph
[legend]

Public Member Functions

 SATCNFMethod ()=delete
 
virtual ~SATCNFMethod ()
 
bool solve () override
 Solves the SAT/SMT problem induced by the method. More...
 
std::unique_ptr< DFA< char > > constructDFA () override
 Constructs the DFA induced by the variables according to the method. More...
 
virtual void setStopTrigger (const std::chrono::seconds &timeLimit, std::atomic_bool &stopTrigger, const bool *stopPointer) override
 Sets the stop trigger for this method. More...
 
- Public Member Functions inherited from gsjj::passive::Method
 Method ()=delete
 
virtual ~Method ()
 
bool hasSolution () const
 If solve() has been called and if there exists a solution, return True. More...
 
unsigned int numberOfStates () const
 Gives the number of states of the prospected DFA (the n) More...
 
double timeToSolve () const
 Gives the CPU time taken to solve the problem. More...
 

Protected Member Functions

Minisat::Var newVariable ()
 Creates a new variable in the SAT solver. More...
 
void addClause (const Minisat::vec< Minisat::Lit > &clause)
 Adds a new clause to the SAT solver. More...
 
virtual void createVariables ()=0
 Creates all needed variables for the method. More...
 
virtual void createClauses ()=0
 Creates all needed clauses for the method. More...
 
virtual std::unique_ptr< DFA< char > > toDFA (const Minisat::vec< Minisat::lbool > &model) const =0
 Effectively creates the DFA from the values of the variables in the given model. More...
 
 SATCNFMethod (const std::set< std::string > &SpSet, const std::set< std::string > &SmSet, const std::set< std::string > &SSet, const std::set< std::string > &prefixesSet, const std::set< char > &alphabetSet, unsigned int n)
 
- Protected Member Functions inherited from gsjj::passive::Method
 Method (const std::set< std::string > &SpSet, const std::set< std::string > &SmSet, const std::set< std::string > &SSet, const std::set< std::string > &prefixesSet, const std::set< char > &alphabetSet, unsigned int n)
 Creates the method. More...
 

Additional Inherited Members

- Protected Attributes inherited from gsjj::passive::Method
const std::set< std::string > m_Sp
 The set of words to accept $S_+$. More...
 
const std::set< std::string > m_Sm
 The set of words to reject $S_-$. More...
 
const unsigned int m_numberStates
 The number of states in the DFA to construct. More...
 
const std::set< std::string > m_S
 In the code, $S = S_+ \cup S_-$. More...
 
const std::set< std::string > m_prefixes
 $Pref(S_+ \cup S_-)$ More...
 
const std::set< char > m_alphabet
 $\Sigma$ More...
 
bool m_triedSolve
 
bool m_hasSolution
 
double m_cpuTimeStart
 
double m_cpuTimeEnd
 

Detailed Description

Base class for every method that relies on a SAT solver.

It creates a SAT solver and defines some functions to easily create a new variable and new clauses.

Definition at line 22 of file SATCNFMethod.h.

Constructor & Destructor Documentation

◆ SATCNFMethod() [1/2]

gsjj::passive::CNF::SATCNFMethod::SATCNFMethod ( )
delete

◆ ~SATCNFMethod()

gsjj::passive::CNF::SATCNFMethod::~SATCNFMethod ( )
virtual

Definition at line 18 of file SATCNFMethod.cpp.

◆ SATCNFMethod() [2/2]

gsjj::passive::CNF::SATCNFMethod::SATCNFMethod ( const std::set< std::string > &  SpSet,
const std::set< std::string > &  SmSet,
const std::set< std::string > &  SSet,
const std::set< std::string > &  prefixesSet,
const std::set< char > &  alphabetSet,
unsigned int  n 
)
protected

Definition at line 12 of file SATCNFMethod.cpp.

Member Function Documentation

◆ addClause()

void gsjj::passive::CNF::SATCNFMethod::addClause ( const Minisat::vec< Minisat::Lit > &  clause)
protected

Adds a new clause to the SAT solver.

It creates a copy of the given clause. Therefore, one can use the same Minisat::vec to construct every clause.

Parameters
clauseThe clause to add

Definition at line 70 of file SATCNFMethod.cpp.

◆ constructDFA()

std::unique_ptr< DFA< char > > gsjj::passive::CNF::SATCNFMethod::constructDFA ( )
overridevirtual

Constructs the DFA induced by the variables according to the method.

If the SAT/SMT problem has not yet been solved, the function automatically solves it. If the SAT/SMT problem is unsolvable, returns a null pointer.

Returns
An unique_ptr to the constructed DFA or an empty pointer if the problem is not solvable

Implements gsjj::passive::Method.

Definition at line 45 of file SATCNFMethod.cpp.

◆ createClauses()

virtual void gsjj::passive::CNF::SATCNFMethod::createClauses ( )
protectedpure virtual

Creates all needed clauses for the method.

Implemented in gsjj::passive::CNF::HeuleVerwerCNFMethod, and gsjj::passive::CNF::UnaryCNFMethod.

◆ createVariables()

virtual void gsjj::passive::CNF::SATCNFMethod::createVariables ( )
protectedpure virtual

Creates all needed variables for the method.

Implemented in gsjj::passive::CNF::HeuleVerwerCNFMethod, and gsjj::passive::CNF::UnaryCNFMethod.

◆ newVariable()

Minisat::Var gsjj::passive::CNF::SATCNFMethod::newVariable ( )
protected

Creates a new variable in the SAT solver.

A Minisat::Var is actually just an integer

Returns
The new variable

Definition at line 66 of file SATCNFMethod.cpp.

◆ setStopTrigger()

void gsjj::passive::CNF::SATCNFMethod::setStopTrigger ( const std::chrono::seconds &  timeLimit,
std::atomic_bool &  stopTrigger,
const bool *  stopPointer 
)
overridevirtual

Sets the stop trigger for this method.

Since we use three different solvers and each has its own way to stop (CVC4 uses a function to set a time limit, Maple is in C++ so we can use an atomic variable and Limboole is in C and we must use a pointer), we must provide each possibility

Parameters
timeLimitThe time in seconds the method can take. It's used by SMT methods.
stopTriggerThe atomic_bool variable. Once set to true, the method will stop. It's used by CNF methods.
stopPointerThe pointer variable. Once the value is set to true, the method will stop. It's used by NonCNF methods.

Implements gsjj::passive::Method.

Definition at line 62 of file SATCNFMethod.cpp.

◆ solve()

bool gsjj::passive::CNF::SATCNFMethod::solve ( )
overridevirtual

Solves the SAT/SMT problem induced by the method.

Il also creates every variable and clause needed

Returns
True iff the problem is solvable

Implements gsjj::passive::Method.

Definition at line 22 of file SATCNFMethod.cpp.

◆ toDFA()

virtual std::unique_ptr<DFA<char> > gsjj::passive::CNF::SATCNFMethod::toDFA ( const Minisat::vec< Minisat::lbool > &  model) const
protectedpure virtual

Effectively creates the DFA from the values of the variables in the given model.

Parameters
modelThe model
Returns
An unique_ptr to the constructed DFA

Implemented in gsjj::passive::CNF::HeuleVerwerCNFMethod, and gsjj::passive::CNF::UnaryCNFMethod.


The documentation for this class was generated from the following files: