Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
87a02d4
Delete unnecessary 3rd party implementation of `std::optional`.
kunalsheth Apr 10, 2025
fc1a28e
Updated IDE configuration files
kunalsheth Apr 10, 2025
4182249
Add statistics counters to pattern matching code.
kunalsheth Apr 10, 2025
e0f2fa5
Sort clause prior to pattern matching to avoid fruitless substitution…
kunalsheth Apr 10, 2025
f8f5c79
Fruitless attempt at creating estimation heuristic for cost of patter…
kunalsheth Apr 10, 2025
72c7cd9
Implement predicate statistics collector for future heuristic develop…
kunalsheth Apr 10, 2025
b4d3491
Plumbing for efficient/cached heuristics collection.
kunalsheth Apr 10, 2025
8c076f4
Fruitless attempt at optimizing `attempt_substitution()`.
kunalsheth Apr 10, 2025
c505d6c
Write `make_conjunction_SKIP_CHECKS_KUNAL_HACK()` to slightly speed u…
kunalsheth Apr 10, 2025
e39067a
sat_solver.cc cleanup.
kunalsheth Apr 10, 2025
3282241
Bolt in statistics, telemetry, and logging for benchmarking run - Apr…
kunalsheth Apr 10, 2025
b86a84f
Tune load factors and preallocations for substitutions_map's internal…
kunalsheth Apr 11, 2025
ef097f1
Add trained 'WORTH IT' heuristic linear regression model.
kunalsheth Apr 11, 2025
8bbb860
Create option to disable lemma heuristic training CSV generation.
kunalsheth Apr 11, 2025
1acfc1e
Add const getters to substitutions_map.h.
kunalsheth Apr 13, 2025
040fcc3
Switch `explanation` learned clause/lemma data structures from set to…
kunalsheth Apr 13, 2025
6bc0073
Sort assertions, and add big, middle, small stats variants to logging.
kunalsheth Apr 13, 2025
76757e2
Implement timeout mechanism for pattern matching!
kunalsheth Apr 13, 2025
4305c86
REVERT ME - changes for blasty training.
kunalsheth Apr 13, 2025
4e22b15
Move pattern_matching_test.cc from /solver to /util to match it's cor…
kunalsheth Apr 14, 2025
a31ba7e
Upgrade regression model to small neural network.
kunalsheth Apr 14, 2025
fa82b66
Revert "REVERT ME - changes for blasty training."
kunalsheth Apr 14, 2025
6d58de6
Fix subtle segfault in trace mode.
kunalsheth Apr 14, 2025
ecf8067
Improve logging for benchmarking run!
kunalsheth Apr 14, 2025
9b68c59
Revert "Upgrade SAT solver from PicoSAT to CaDiCaL."
kunalsheth Apr 14, 2025
eb8b10d
Revert "Revert "Upgrade SAT solver from PicoSAT to CaDiCaL.""
kunalsheth Apr 17, 2025
3ffeefd
Update logging levels to make DEBUG mode more useful on large queries.
kunalsheth Apr 17, 2025
ee73de7
Tap into SAT solver learned clauses via `CaDiCaL::Learner` listening …
kunalsheth Apr 17, 2025
84ee72c
Remove unnecessary lemma_stats measurements and retrain neural network.
kunalsheth Apr 17, 2025
5fd5176
Support intervals for BOOLEAN variables in boxes.
kunalsheth Apr 17, 2025
b44fdbd
Separate SAT solver infrastructure code from theory-related code.
kunalsheth Apr 17, 2025
3eaa183
Add note clarifying on "forward"/"backward" mapping meaning in substi…
kunalsheth Apr 17, 2025
171555a
Flush out simple quantifier handling in predicate_heuristic.cc and pa…
kunalsheth Apr 17, 2025
9ed6f0e
Fix soundness bug in how filter_assertion handles strict upper bounds…
kunalsheth Apr 19, 2025
f843fdc
Lower priority of more logs from Debug to Trace.
kunalsheth Apr 19, 2025
18d8b9d
Re-train neural network because I accidentally said "LOG2_worth_it > …
kunalsheth Apr 19, 2025
e8585c9
Fix many bugs in SAT-level interval logic.
kunalsheth Apr 19, 2025
645d627
Add rounding guards to prefix_printer.cc.
kunalsheth Apr 21, 2025
a3fed52
Add SAT logging to auditor.cc.
kunalsheth Apr 21, 2025
a269808
Tune CaDiCaL options - increase vivification and subsumption aggressi…
kunalsheth Apr 21, 2025
e5a077d
Increase load factor of heavily queried hash maps in predicate_abstra…
kunalsheth Apr 21, 2025
1e6e0ff
Create concept of underconstrained models.
kunalsheth Apr 21, 2025
59f4e2c
Add conjunction unrolling to `Context::Impl::Assert` for more accurat…
kunalsheth Apr 21, 2025
a9de323
Add `FMCAD25_MODE_*` macros for easier benchmarking runs.
kunalsheth Apr 21, 2025
3b38ae7
Cleanup - make sure SAT logging hooks don't harm benchmarking perform…
kunalsheth Apr 21, 2025
8ad6993
Use tabs to improve readability of std:cerr prints.
kunalsheth Apr 21, 2025
6bbdfc1
Add exponential backoff to fully/under constrained switching logic in…
kunalsheth Apr 23, 2025
ff975f9
Log SAT clauses learned to std::err instead of INFO.
kunalsheth Apr 23, 2025
9c5619f
Remove `sat_solver->AddBox(pn_, box);` from `FMCAD25_MODE_CONTROL`.
kunalsheth Apr 23, 2025
7e96676
Make it build on ubuntu.
kunalsheth Apr 23, 2025
37e2900
Fix build on CentOS with GCC 14 (sherlock).
kunalsheth Apr 25, 2025
f76a99a
Fix includes for more restrictive headers on CentOS
kunalsheth Apr 25, 2025
4122e06
Make cmake STATIC
kunalsheth Apr 26, 2025
7539e55
Consolidate experimental build flags into version.h to avoid accident…
kunalsheth Apr 26, 2025
e953754
Add additional build flags for using partial v.s. full SAT models.
kunalsheth Apr 26, 2025
d9f2842
Add pattern matching upper timeout to version.h.
kunalsheth Apr 26, 2025
2d3b259
Downgrade verbose `Finding matches for:...` logs to DEBUG.
kunalsheth Apr 26, 2025
9f40016
Remove no longer necessary permutation check in pmtg.cc.
kunalsheth Apr 26, 2025
cab058d
Filter theory solver explanations at the top level to avoid unnecessa…
kunalsheth Apr 27, 2025
b78d0c7
Add QF_IDL to supported logics.
kunalsheth Apr 27, 2025
97b7cce
Revert "Add QF_IDL to supported logics."
kunalsheth Apr 27, 2025
6d114df
Revert "Filter theory solver explanations at the top level to avoid u…
kunalsheth Apr 30, 2025
1580ec6
Revert "Remove no longer necessary permutation check in pmtg.cc."
kunalsheth Apr 30, 2025
abf64f6
Add safety checks preventing segfaults and/or egregiously wasted effo…
kunalsheth May 1, 2025
9185405
Set RLIMIT stack size in main to avoid overflows on pattern matching …
kunalsheth May 1, 2025
75017a5
Rotate pattern matching "starting" variable in parent vector to avoid…
kunalsheth May 1, 2025
ae4312b
Tweak PM filtering for ODEs.
kunalsheth May 1, 2025
4ab2e90
Remove unused case from find_matches().
kunalsheth May 8, 2025
9302102
Revert "Rotate pattern matching "starting" variable in parent vector …
kunalsheth May 8, 2025
e56c31a
Always `AddLearnedClauseUnboxed`, in all cases.
kunalsheth May 8, 2025
6d10c9e
Always `AddLearnedClauseUnboxed`, in all cases.
kunalsheth May 8, 2025
c6d544a
Add labels to theory auditor.
kunalsheth May 13, 2025
2e74821
Remove SAT inverval behavior from pattern matching.
kunalsheth May 14, 2025
9a660e7
Get rid of `EST` heuristic mess.
kunalsheth Jul 22, 2025
4bb5528
Improve pattern matching performance using alpha-aware hashing.
kunalsheth Jul 22, 2025
b56bb15
ASPLOS circuit tweaks.
kunalsheth Aug 11, 2025
cf6dc89
Tweak PM thresholds and timeouts
kunalsheth Aug 12, 2025
0eb5200
Speed up prints for benchmarking.
kunalsheth Aug 12, 2025
484e65f
Remove lemma/assertion statistics from collected data for benchmarking.
kunalsheth Aug 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

2 changes: 0 additions & 2 deletions .idea/dreal4-cmake.iml

This file was deleted.

483 changes: 0 additions & 483 deletions .idea/editor.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.30)
cmake_minimum_required(VERSION 3.16)
project(dreal4_cmake)
include(CMakePrintHelpers)

Expand Down Expand Up @@ -52,6 +52,8 @@ set(LIBCDS_HOME "${PROJECT_SOURCE_DIR}/src/third_party/com_github_khizmax_libcds
set(JSON_HOME "${PROJECT_SOURCE_DIR}/src/third_party/com_github_nlohmann_json/")
set(PICOSAT_HOME "${PROJECT_SOURCE_DIR}/src/third_party/com_github_dreal-deps_picosat/")

unset(DREAL_SOURCES)
unset(DREAL_SOURCES CACHE)
file(GLOB_RECURSE DREAL_SOURCES
"${PROJECT_SOURCE_DIR}/src/dreal/*/**.cc"
"${PROJECT_SOURCE_DIR}/src/dreal/*/**.yy"
Expand All @@ -61,7 +63,7 @@ file(GLOB_RECURSE DREAL_SOURCES
"${LIBCDS_HOME}/src/**.cpp"
"${PICOSAT_HOME}/src/**.c"
)
add_library(dreal4_cmake
add_library(dreal4_cmake STATIC
${DREAL_SOURCES}
${BISON_smt2_parser_OUTPUTS} ${FLEX_smt2_scanner_OUTPUTS}
${BISON_dr_parser_OUTPUTS} ${FLEX_dr_scanner_OUTPUTS}
Expand All @@ -79,8 +81,9 @@ target_include_directories(dreal4_cmake PUBLIC
)

# system dependencies
find_library( FLEX_LIB NAMES libfl.a HINTS "${FLEX_ROOT}" PATH_SUFFIXES lib libs lib32 lib64 REQUIRED NO_CACHE)
target_include_directories(dreal4_cmake PUBLIC "${FLEX_INCLUDE_DIRS}")
target_link_libraries(dreal4_cmake PUBLIC "${FLEX_LIBRARIES}")
target_link_libraries(dreal4_cmake PUBLIC "${FLEX_LIB}")

find_path( GMP_INC NAMES gmpxx.h HINTS "${GMP_ROOT}" PATH_SUFFIXES include includes REQUIRED NO_CACHE)
find_library( GMP_C_LIB NAMES libgmp.a HINTS "${GMP_ROOT}" PATH_SUFFIXES lib libs lib32 lib64 REQUIRED NO_CACHE)
Expand All @@ -106,7 +109,7 @@ include(FetchContent)
FetchContent_Declare(
ibex
GIT_REPOSITORY https://github.com/ncsys-lab/ibex-lib
GIT_TAG 4d61b84139eaeab628506d9edaf5fd8879a3302e) # Kunal's M1 + namespace fixes
GIT_TAG 33408ed0733da56979ddf797473609d4c39ea1ea) # Kunal's M1 + namespace fixes
FetchContent_MakeAvailable(ibex)

FetchContent_Declare(
Expand Down Expand Up @@ -154,6 +157,9 @@ target_link_libraries(
dreal4_cmake PUBLIC ibex nlopt spdlog::spdlog fmt::fmt
)

# On some platforms, linking is purely sequential, and the order you specify libraries in matters.
# I am repeating these libraries from above so that everything gets resolved on Ubuntu
target_link_libraries(dreal4_cmake PUBLIC "${GMP_C_LIB}" "${GMP_CXX_LIB}")

# executable
add_executable(dreal4 "${PROJECT_SOURCE_DIR}/src/dreal/dreal_main.cc")
Expand Down
18 changes: 18 additions & 0 deletions src/dreal/dreal_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,24 @@ void HandleSigInt(const int) {
} // namespace

int main(int argc, const char* argv[]) {
// default stack size is 8MB
// CPS-pattern matching algo goes DEEP...
// doing 63MB because that's approximately the max on macOS
constexpr rlim_t desired_stack_size = 63 * 1024 * 1024;
rlimit rl{0};
getrlimit(RLIMIT_STACK, &rl);
rl.rlim_cur = std::max(rl.rlim_cur, desired_stack_size);
setrlimit(RLIMIT_STACK, &rl);
rl.rlim_cur = 0;
getrlimit(RLIMIT_STACK, &rl);
if (rl.rlim_cur < desired_stack_size) {
std::cerr << "Failed to configure desired stack size limit. Exiting." << std::endl;
std::cerr << "\tCurrent Size = " << rl.rlim_cur << std::endl;
std::cerr << "\tMaximum Size = " << rl.rlim_max << std::endl;
std::cerr << "\tDesired Size = " << desired_stack_size << std::endl;
exit(-1);
}

std::signal(SIGINT, HandleSigInt);
dreal::MainProgram main_program{argc, argv};
return main_program.Run();
Expand Down
61 changes: 59 additions & 2 deletions src/dreal/solver/auditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,73 @@
#include "dreal/solver/filter_assertion.h"
#include "dreal/util/assert.h"
#include "dreal/util/logging.h"
#include "dreal/version.h"

namespace dreal
{
void audit(const Formula& formula, const std::optional<Box>& box) {
std::ofstream literal_log("/tmp/dreal_audit_sat_literal_log.txt");
std::set<int> literal_log_clause;

void sat_log_label_clause(const std::string& s) {
if (!DREAL_EXPERIMENTAL_SAT_AUDIT_ENABLED) return;
literal_log << s << std::endl;
}

void sat_log_literal(const int lit, const std::optional<Variable>& def) {
if (!DREAL_EXPERIMENTAL_SAT_AUDIT_ENABLED) return;
DREAL_ASSERT(lit != 0);

static std::set<Variable> seen_literals;
if (def && !seen_literals.count(*def)) {
literal_log << "def:\t" << ::abs(lit) << " := " << *def << std::endl;
seen_literals.emplace(*def);
}

literal_log_clause.insert(lit);
}

void sat_log_literal0() {
if (!DREAL_EXPERIMENTAL_SAT_AUDIT_ENABLED) return;
for (int v : literal_log_clause) literal_log << v << ' ';
literal_log << '0' << std::endl;
literal_log_clause.clear();
}

void theory_audit_literals(
const std::string& label,
const PredicateAbstractor& pa, /*copy*/ std::vector<Formula> lits, const std::optional<Box>& box
) {
// the operands passed here are expensive to produce, so really shouldn't be called unnecessarily.
DREAL_ASSERT(DREAL_EXPERIMENTAL_THEORY_AUDIT_ENABLED);

for (auto& l : lits) {
if (is_variable(l)) {
// f = b
const auto iter = pa.var_to_formula_map().find(get_variable(l));
if (iter != pa.var_to_formula_map().end()) l = iter->second;
// else ... the variable is probably, actually, a BOOL such as `DigitalPDController_0__omega_sensor_bit0__t0ad`
}
else {
// f = ¬b
DREAL_ASSERT(is_negation(l) && is_variable(get_operand(l)));
const auto iter = pa.var_to_formula_map().find(get_variable(get_operand(l)));
if (iter != pa.var_to_formula_map().end()) l = !iter->second;
// else ... the variable is probably, actually, a BOOL such as `DigitalPDController_0__omega_sensor_bit0__t0ad`
}
}
theory_audit_formula(label, make_disjunction(lits), box);
}

void theory_audit_formula(const std::string& label, const Formula& formula, const std::optional<Box>& box) {
// the operands passed here are expensive to produce, so really shouldn't be called unnecessarily.
DREAL_ASSERT(DREAL_EXPERIMENTAL_THEORY_AUDIT_ENABLED);

const auto& vs = formula.GetFreeVariables();

std::string lemma_comment;
{
std::ostringstream s;
s << ";\t∀ ";
s << ";\t" << label << "\t∀ ";
for (const auto& v : vs) {
s << v;
if (box) s << "∈" << (*box)[v];
Expand Down
14 changes: 13 additions & 1 deletion src/dreal/solver/auditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@
#define AUDITOR_H

#include <dreal/util/box.h>
#include <dreal/util/predicate_abstractor.h>
#include <optional>

namespace dreal
{
void audit(const Formula& formula, const std::optional<Box>& box);

void sat_log_label_clause(const std::string& label);
void sat_log_literal(int lit, const std::optional<Variable>& def = {});
void sat_log_literal0();

void theory_audit_literals(
const std::string& label,
const PredicateAbstractor& pa, /*copy*/ std::vector<Formula> lits,
const std::optional<Box>& box
);
void theory_audit_formula(const std::string& label, const Formula& formula, const std::optional<Box>& box);
}

#endif //AUDITOR_H
21 changes: 20 additions & 1 deletion src/dreal/solver/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,26 @@ optional<string> Context::GetOption(const string& key) const {
const Config& Context::config() const { return impl_->config(); }
Config& Context::mutable_config() { return impl_->mutable_config(); }

string Context::version() { return DREAL_VERSION_STRING; }
string Context::version() {
std::ostringstream oss;
oss << DREAL_VERSION_FULL << '.';
oss << DREAL_VERSION_MAJOR << '.';
oss << DREAL_VERSION_MINOR << '.';
oss << DREAL_VERSION_REVISION << '.';

oss << "patmat" << pattern_matching_mode << '.';
oss << "parmod" << partial_model_mode << '.';

oss << "audit" <<
static_cast<int>(DREAL_EXPERIMENTAL_THEORY_AUDIT_ENABLED) <<
static_cast<int>(DREAL_EXPERIMENTAL_SAT_AUDIT_ENABLED);

#ifdef DREAL_EXPERIMENTAL_GENERATE_HEURISTICS_CSV
oss << ".GENERATE_CSV";
#endif

return oss.str();
}

const Box& Context::box() const { return impl_->box(); }

Expand Down
Loading