Painless
A framework to ease parallelization of sequential CDCL SAT solvers
Loading...
Searching...
No Matches
Parsers.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include "../solvers/SolverInterface.hpp"
9#include "containers/ClauseUtils.hpp"
10#include "containers/Formula.hpp"
11#include <algorithm>
12#include <functional>
13
18namespace Parsers {
19
27{
28 public:
29 ClauseProcessor() = default;
30
37 virtual bool initMembers(unsigned int varCount, unsigned int clauseCount) = 0;
38
44 virtual bool operator()(simpleClause& clause) = 0;
45
46 virtual ~ClauseProcessor() = default;
47};
48
55{
56 public:
63 bool initMembers(unsigned int varCount, unsigned int clauseCount) override;
64
74 bool operator()(simpleClause& clause) override;
75
76 private:
77 mutable std::unordered_set<simpleClause, ClauseUtils::ClauseHash> clauseCache;
78};
79
87{
88 public:
95 bool initMembers(unsigned int varCount, unsigned int clauseCount) override;
96
105 bool operator()(simpleClause& clause) override;
106};
107
117bool
118parseCNF(const char* filename,
119 std::vector<simpleClause>& clauses,
120 unsigned int* varCount,
121 const std::vector<std::unique_ptr<ClauseProcessor>>& processors = {});
122
131bool
132parseCNF(const char* filename, Formula& formula, const std::vector<std::unique_ptr<ClauseProcessor>>& processors = {});
133
142bool
143parseCNFParameters(FILE* f, unsigned int& varCount, unsigned int& clauseCount);
144
145} // namespace Parsers
Represents a SAT formula with unit and non-unit clauses.
Definition Formula.hpp:20
Abstract base class for clause processors.
Definition Parsers.hpp:27
virtual bool operator()(simpleClause &clause)=0
Process a clause.
virtual bool initMembers(unsigned int varCount, unsigned int clauseCount)=0
Initialize the processor with problem parameters.
Filter for removing redundant clauses.
Definition Parsers.hpp:55
bool initMembers(unsigned int varCount, unsigned int clauseCount) override
Initialize the redundancy filter.
bool operator()(simpleClause &clause) override
Check if a clause is redundant.
Filter for removing tautological clauses. A tautological clause or simple a tautology is a clause tha...
Definition Parsers.hpp:87
bool initMembers(unsigned int varCount, unsigned int clauseCount) override
Initialize the tautology filter.
bool operator()(simpleClause &clause) override
Check if a clause is a tautology.
A set of helper functions for CNF file parsing.
Definition StructuredBva.hpp:286
bool parseCNFParameters(FILE *f, unsigned int &varCount, unsigned int &clauseCount)
Parse the CNF parameters (variable count and clause count) from a file.
bool parseCNF(const char *filename, std::vector< simpleClause > &clauses, unsigned int *varCount, const std::vector< std::unique_ptr< ClauseProcessor > > &processors={})
Parse a CNF formula from a file into a vector of clauses.