This is work towards unifying top-level substitutions with model substitutions.
Currently, for model evaluation, BV eager atom preprocessing pass adds mappings (BV_EAGER_ATOM X) -> X to say how (BV_EAGER_ATOM X) should be evaluated in the model. This is not necessary since a rewrite rule (BV_EAGER_ATOM c) -> c for constant c would suffice.
This eliminates the call to addModelSubstitution in that preprocessing pass.
It also makes it so that we don't make true/false themselves into eager atoms.
for (unsigned i = 0, size = assertionsToPreprocess->size(); i < size; ++i)
{
TNode atom = (*assertionsToPreprocess)[i];
+ if (atom.isConst())
+ {
+ // don't bother making true/false into atoms
+ continue;
+ }
Node eager_atom = nm->mkNode(kind::BITVECTOR_EAGER_ATOM, atom);
- d_preprocContext->addModelSubstitution(eager_atom, atom);
assertionsToPreprocess->replace(i, eager_atom);
}
return PreprocessingPassResult::NO_CONFLICT;
EvalSle,
EvalITEBv,
EvalComp,
+ EvalEagerAtom,
/// simplification rules
/// all of these rules decrease formula size
case EvalSltBv: out << "EvalSltBv"; return out;
case EvalITEBv: out << "EvalITEBv"; return out;
case EvalComp: out << "EvalComp"; return out;
+ case EvalEagerAtom: out << "EvalEagerAtom"; return out;
case EvalExtract : out << "EvalExtract"; return out;
case EvalSignExtend : out << "EvalSignExtend"; return out;
case EvalRotateLeft : out << "EvalRotateLeft"; return out;
return utils::mkConst(1, 0);
}
+template <>
+inline bool RewriteRule<EvalEagerAtom>::applies(TNode node)
+{
+ return (node.getKind() == kind::BITVECTOR_EAGER_ATOM && node[0].isConst());
+}
+
+template <>
+inline Node RewriteRule<EvalEagerAtom>::apply(TNode node)
+{
+ Debug("bv-rewrite") << "RewriteRule<EvalComp>(" << node << ")" << std::endl;
+ return node[0];
+}
}
}
} // namespace cvc5
return RewriteResponse(REWRITE_DONE, resultNode);
}
+RewriteResponse TheoryBVRewriter::RewriteEagerAtom(TNode node, bool prerewrite)
+{
+ Node resultNode =
+ LinearRewriteStrategy<RewriteRule<EvalEagerAtom>>::apply(node);
+
+ return RewriteResponse(REWRITE_DONE, resultNode);
+}
+
RewriteResponse TheoryBVRewriter::RewriteMult(TNode node, bool prerewrite) {
Node resultNode = node;
resultNode = LinearRewriteStrategy
d_rewriteTable [ kind::BITVECTOR_ULTBV ] = RewriteUltBv;
d_rewriteTable [ kind::BITVECTOR_SLTBV ] = RewriteSltBv;
d_rewriteTable [ kind::BITVECTOR_ITE ] = RewriteITEBv;
+ d_rewriteTable[kind::BITVECTOR_EAGER_ATOM] = RewriteEagerAtom;
d_rewriteTable [ kind::BITVECTOR_TO_NAT ] = RewriteBVToNat;
d_rewriteTable [ kind::INT_TO_BITVECTOR ] = RewriteIntToBV;
static RewriteResponse RewriteRotateLeft(TNode node, bool prerewrite = false);
static RewriteResponse RewriteRedor(TNode node, bool prerewrite = false);
static RewriteResponse RewriteRedand(TNode node, bool prerewrite = false);
+ static RewriteResponse RewriteEagerAtom(TNode node, bool prerewrite = false);
static RewriteResponse RewriteBVToNat(TNode node, bool prerewrite = false);
static RewriteResponse RewriteIntToBV(TNode node, bool prerewrite = false);