case InferenceId::NL_T_TANGENT: return "T_TANGENT";
case InferenceId::NL_IAND_INIT_REFINE: return "IAND_INIT_REFINE";
case InferenceId::NL_IAND_VALUE_REFINE: return "IAND_VALUE_REFINE";
+ case InferenceId::NL_IAND_SUM_REFINE: return "IAND_SUM_REFINE";
case InferenceId::NL_CAD_CONFLICT: return "CAD_CONFLICT";
case InferenceId::NL_CAD_EXCLUDED_INTERVAL: return "CAD_EXCLUDED_INTERVAL";
case InferenceId::NL_ICP_CONFLICT: return "ICP_CONFLICT";
NL_IAND_INIT_REFINE,
// value refinements (IAndSolver::checkFullRefine)
NL_IAND_VALUE_REFINE,
+ // sum refinements (IAndSulver::checkFullRefine)
+ NL_IAND_SUM_REFINE,
//-------------------- cad solver
// conflict / infeasible subset obtained from cad
NL_CAD_CONFLICT,
// ************* additional lemma schemas go here
if (options::iandMode() == options::IandMode::SUM)
{
- // add lemmas based on sum mode
+ Node lem = sumBasedLemma(i); // add lemmas based on sum mode
+ Trace("iand-lemma")
+ << "IAndSolver::Lemma: " << lem << " ; SUM_REFINE" << std::endl;
+ d_im.addPendingArithLemma(lem, InferenceId::NL_IAND_SUM_REFINE, true);
}
else if (options::iandMode() == options::IandMode::BITWISE)
{
return lem;
}
+Node IAndSolver::sumBasedLemma(Node i)
+{
+ Assert(i.getKind() == IAND);
+ Node x = i[0];
+ Node y = i[1];
+ size_t bvsize = i.getOperator().getConst<IntAnd>().d_size;
+ uint64_t granularity = options::BVAndIntegerGranularity();
+ NodeManager* nm = NodeManager::currentNM();
+ Node lem = nm->mkNode(
+ EQUAL, i, d_iandTable.createBitwiseNode(x, y, bvsize, granularity));
+ return lem;
+}
} // namespace nl
} // namespace arith
#include "expr/node.h"
#include "theory/arith/arith_state.h"
#include "theory/arith/inference_manager.h"
+#include "theory/arith/nl/iand_table.h"
#include "theory/arith/nl/nl_lemma_utils.h"
#include "theory/arith/nl/nl_model.h"
Node d_two;
Node d_true;
Node d_false;
+ IAndTable d_iandTable;
/** IAND terms that have been given initial refinement lemmas */
NodeSet d_initRefine;
/** all IAND terms, for each bit-width */
* ((_ iand k) x y) = Rewriter::rewrite(((_ iand k) M(x) M(y)))
*/
Node valueBasedLemma(Node i);
+ /**
+ * Sum-based refinement lemma for i of the form ((_ iand k) x y). Returns:
+ * i = 2^0*min(x[0],y[0])+...2^{k-1}*min(x[k-1],y[k-1])
+ * where x[i] is x div i mod 2
+ * and min is defined with an ite.
+ */
+ Node sumBasedLemma(Node i);
}; /* class IAndSolver */
} // namespace nl
}
// compute the most common result
- uint64_t most_common_result;
+ uint64_t most_common_result = 0;
uint64_t max_num_of_occ = 0;
for (uint64_t i = 0; i <= num_of_values; i++)
{
most_common_result = i;
}
}
+ // sanity check: some value appears at least once.
+ Assert(max_num_of_occ != 0);
+
// -1 is the default case of the table.
// add it to the table
table[std::make_pair(-1, -1)] = most_common_result;
regress1/nl/exp_monotone.smt2
regress1/nl/factor_agg_s.smt2
regress1/nl/iand-native-1.smt2
+ regress1/nl/iand-native-2.smt2
regress1/nl/issue3300-approx-sqrt-witness.smt2
regress1/nl/issue3441.smt2
regress1/nl/issue3617.smt2
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1
-; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=2
-; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=3
-; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=4
; EXPECT: unsat
(set-logic QF_BV)
(declare-fun x () (_ BitVec 4))
; COMMAND-LINE: --iand-mode=value
+; COMMAND-LINE: --iand-mode=sum --bvand-integer-granularity=1 --finite-model-find
; EXPECT: sat
(set-logic QF_NIA)
(set-info :status sat)
--- /dev/null
+; COMMAND-LINE: --iand-mode=value
+; COMMAND-LINE: --iand-mode=sum --bvand-integer-granularity=1
+; EXPECT: unsat
+(set-logic QF_NIA)
+(set-info :status unsat)
+(declare-fun x () Int)
+(declare-fun y () Int)
+
+(assert (and (<= 0 x) (< x 16)))
+(assert (and (<= 0 y) (< y 16)))
+(assert (> ((_ iand 4) x y) 0))
+(assert (= (* x y) 0))
+(assert (= (+ x y) 15))
+
+(check-sat)
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1
-; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=5
-; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=8
; EXPECT: sat
(set-logic QF_BV)
(declare-fun a () (_ BitVec 8))
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1
-; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=8
; EXPECT: unsat
(set-logic QF_BV)
(declare-fun a () (_ BitVec 8))
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-unsat-cores
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=5 --no-check-unsat-cores
-; COMMAND-LINE: --solve-bv-as-int=iand --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=value --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=sum --no-check-unsat-cores
; COMMAND-LINE: --solve-bv-as-int=bv --no-check-unsat-cores
; EXPECT: unsat
(set-logic QF_BV)
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1
-; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=4
-; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=8
; EXPECT: sat
(set-logic QF_BV)
(declare-fun a () (_ BitVec 8))
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1 --no-check-unsat-cores
-; COMMAND-LINE: --solve-bv-as-int=iand --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=value --no-check-unsat-cores
+; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=sum --no-check-unsat-cores
; COMMAND-LINE: --solve-bv-as-int=bv --no-check-unsat-cores
; EXPECT: unsat
(set-logic ALL)
; COMMAND-LINE: --solve-bv-as-int=sum --bvand-integer-granularity=1
-; COMMAND-LINE: --solve-bv-as-int=iand
+; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=value
+; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=sum
; COMMAND-LINE: --solve-bv-as-int=bv
; EXPECT: sat
(set-logic ALL)
-; COMMAND-LINE: --cegqi-all --full-saturate-quant --bvand-integer-granularity=1 --solve-bv-as-int=sum --no-check-models
-; COMMAND-LINE: --cegqi-all --full-saturate-quant --bvand-integer-granularity=2 --solve-bv-as-int=sum --no-check-models
+; COMMAND-LINE: --solve-bv-as-int=sum --no-check-models
; EXPECT: sat
(set-logic BV)
(declare-fun s () (_ BitVec 3))
; COMMAND-LINE: --solve-bv-as-int=bv
-; COMMAND-LINE: --cegqi-all --full-saturate-quant --bvand-integer-granularity=1 --solve-bv-as-int=sum
-; COMMAND-LINE: --cegqi-all --full-saturate-quant --bvand-integer-granularity=1 --solve-bv-as-int=iand --iand-mode=sum
-; COMMAND-LINE: --cegqi-all --full-saturate-quant --bvand-integer-granularity=1 --solve-bv-as-int=iand --iand-mode=bitwise
-; COMMAND-LINE: --cegqi-all --full-saturate-quant --bvand-integer-granularity=1 --solve-bv-as-int=iand
-; COMMAND-LINE: --cegqi-all --full-saturate-quant --bvand-integer-granularity=2 --solve-bv-as-int=sum
+; COMMAND-LINE: --solve-bv-as-int=sum
+; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=sum
+; COMMAND-LINE: --solve-bv-as-int=iand --iand-mode=value
; EXPECT: unsat
(set-logic ALL)
(declare-fun t () (_ BitVec 4))
+; COMMAND-LINE: --solve-bv-as-int=bv --no-check-models
; COMMAND-LINE: --bvand-integer-granularity=1 --solve-bv-as-int=sum --full-saturate-quant --cegqi-all --no-check-models
;EXPECT: sat
(set-logic BV)