3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 09:35:32 +00:00

add the pdd evaluator and a unit test for it

Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
Lev Nachmanson 2019-12-23 17:37:29 -08:00
parent 7eb1affc7b
commit a9f09beb8e
2 changed files with 118 additions and 75 deletions

42
src/math/dd/pdd_eval.h Normal file
View file

@ -0,0 +1,42 @@
/*++
Copyright (c) 2019 Microsoft Corporation
Module Name:
dd_pdd.cpp
Abstract:
Poly DD package
Author:
Nikolaj Bjorner (nbjorner) 2019-12-23
Lev Nachmanson (levnach) 2019-12-23
Revision History:
--*/
#include "math/dd/dd_pdd.h"
namespace dd {
// calculates the value of a pdd expression based on the given values of the variables
class pdd_eval {
pdd_manager& m;
std::function<rational (unsigned)> m_var2val;
public:
pdd_eval(pdd_manager& m): m(m) {}
void operator=(std::function<rational (unsigned)>& i2v) { m_var2val = i2v; }
rational operator()(pdd const& p) {
if (p.is_val()) {
return p.val();
}
return (*this)(p.hi()) * m_var2val(p.var()) + (*this)(p.lo());
}
};
}