Fixes #7870.
Notice this node converter is potentially unnecessary if we ever get rid of arithmetic subtyping.
node_visitor.h
skolem_manager.cpp
skolem_manager.h
+ subtype_elim_node_converter.cpp
+ subtype_elim_node_converter.h
symbol_manager.cpp
symbol_manager.h
symbol_table.cpp
--- /dev/null
+/******************************************************************************
+ * Top contributors (to current version):
+ * Andrew Reynolds
+ *
+ * This file is part of the cvc5 project.
+ *
+ * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
+ * in the top-level source directory and their institutional affiliations.
+ * All rights reserved. See the file COPYING in the top-level source
+ * directory for licensing information.
+ * ****************************************************************************
+ *
+ * Implementation of subtype elimination node conversion
+ */
+
+#include "expr/subtype_elim_node_converter.h"
+
+using namespace cvc5::kind;
+
+namespace cvc5 {
+
+SubtypeElimNodeConverter::SubtypeElimNodeConverter() {}
+
+bool SubtypeElimNodeConverter::isRealTypeStrict(TypeNode tn)
+{
+ return tn.isReal() && !tn.isInteger();
+}
+
+Node SubtypeElimNodeConverter::postConvert(Node n)
+{
+ Kind k = n.getKind();
+ bool convertToRealChildren = false;
+ if (k == PLUS || k == MULT || k == NONLINEAR_MULT)
+ {
+ convertToRealChildren = isRealTypeStrict(n.getType());
+ }
+ else if (k == EQUAL || k == GEQ)
+ {
+ convertToRealChildren =
+ isRealTypeStrict(n[0].getType()) || isRealTypeStrict(n[1].getType());
+ }
+ if (convertToRealChildren)
+ {
+ NodeManager* nm = NodeManager::currentNM();
+ std::vector<Node> children;
+ for (const Node& nc : n)
+ {
+ if (nc.getType().isInteger())
+ {
+ // we use CAST_TO_REAL for constants, so that e.g. 5 is printed as
+ // 5.0 not (to_real 5)
+ Kind nk = nc.isConst() ? CAST_TO_REAL : TO_REAL;
+ children.push_back(nm->mkNode(nk, nc));
+ }
+ else
+ {
+ children.push_back(nc);
+ }
+ }
+ return nm->mkNode(k, children);
+ }
+ return n;
+}
+
+} // namespace cvc5
--- /dev/null
+/******************************************************************************
+ * Top contributors (to current version):
+ * Andrew Reynolds
+ *
+ * This file is part of the cvc5 project.
+ *
+ * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
+ * in the top-level source directory and their institutional affiliations.
+ * All rights reserved. See the file COPYING in the top-level source
+ * directory for licensing information.
+ * ****************************************************************************
+ *
+ * Implementation of subtype elimination node conversion
+ */
+#include "cvc5_private.h"
+
+#ifndef CVC4__PROOF__EXPR__SUBTYPE_ELIM_NODE_CONVERTER_H
+#define CVC4__PROOF__EXPR__SUBTYPE_ELIM_NODE_CONVERTER_H
+
+#include <iostream>
+#include <map>
+
+#include "expr/node.h"
+#include "expr/node_converter.h"
+#include "expr/type_node.h"
+
+namespace cvc5 {
+
+/**
+ * This converts a node into one that does not involve (arithmetic) subtyping.
+ * In particular, all applications of arithmetic symbols that involve at least
+ * one (strict) Real child are such that all children are cast to real.
+ */
+class SubtypeElimNodeConverter : public NodeConverter
+{
+ public:
+ SubtypeElimNodeConverter();
+ ~SubtypeElimNodeConverter() {}
+ /** convert node n as described above during post-order traversal */
+ Node postConvert(Node n) override;
+ private:
+ /** Is real type (not integer)? */
+ static bool isRealTypeStrict(TypeNode tn);
+};
+
+} // namespace cvc5
+
+#endif
#include "theory/quantifiers_engine.h"
#include "theory/theory_engine.h"
#include "util/string.h"
+#include "expr/subtype_elim_node_converter.h"
using namespace cvc5::theory;
using namespace cvc5::kind;
{
ret = SkolemManager::getOriginalForm(ret);
}
+ // make so that the returned formula does not involve arithmetic subtyping
+ SubtypeElimNodeConverter senc;
+ ret = senc.convert(ret);
return ret;
}
// otherwise, just true/false
regress1/quantifiers/qbv-test-urem-rewrite.smt2
regress1/quantifiers/qcft-javafe.filespace.TreeWalker.006.smt2
regress1/quantifiers/qcft-smtlib3dbc51.smt2
- regress1/quantifiers/qe-partial.smt2
regress1/quantifiers/qe.smt2
+ regress1/quantifiers/qe-partial.smt2
+ regress1/quantifiers/qe-subtypes.smt2
regress1/quantifiers/qid.smt2
regress1/quantifiers/qid-debug-inst.smt2
regress1/quantifiers/quant-wf-int-ind.smt2
--- /dev/null
+; EXPECT: (>= (* (- 1.0) x) (- 100.0))
+(set-logic LRA)
+(declare-fun x () Real)
+(get-qe
+ (exists ((Y Bool)) (>= (* (- 1.0) x) (- 100.0))
+))