3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-04 06:15:46 +00:00

Polysat: refactor constraints (#5372)

* Refactor: remove sign and dep from constraint

* fix some bugs

* improve log messages

* Add missing premises to lemma

* Rename getter in an attempt to fix linux build
This commit is contained in:
Jakob Rath 2021-06-25 20:04:25 +02:00 committed by GitHub
parent a0b0c1f428
commit 3436b52c4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 435 additions and 325 deletions

View file

@ -0,0 +1,49 @@
/*++
Copyright (c) 2021 Microsoft Corporation
Module Name:
polysat clause builder
Author:
Nikolaj Bjorner (nbjorner) 2021-03-19
Jakob Rath 2021-04-6
--*/
#pragma once
#include "math/polysat/constraint.h"
#include "math/polysat/types.h"
namespace polysat {
/// Builds a clause from literals and constraints.
/// Takes care to
/// - resolve with unit clauses and accumulate their dependencies,
/// - skip trivial new constraints such as "4 <= 1".
class clause_builder {
solver& m_solver;
sat::literal_vector m_literals;
constraint_ref_vector m_new_constraints;
p_dependency_ref m_dep;
unsigned m_level = 0;
public:
clause_builder(solver& s);
bool empty() const { return m_literals.empty() && m_new_constraints.empty() && m_dep == nullptr && m_level == 0; }
void reset();
/// Build the clause. This will reset the clause builder so it can be reused.
clause_ref build();
void add_dependency(p_dependency* d);
/// Add a literal to the clause.
/// Intended to be used for literals representing a constraint that already exists.
void push_literal(sat::literal lit);
/// Add a constraint to the clause that does not yet exist in the solver so far.
void push_new_constraint(constraint_literal c);
};
}