summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-11-15 09:35:27 -0600
committerGitHub <noreply@github.com>2021-11-15 09:35:27 -0600
commit829b3c2798c1f2c0bb313d7eff2c1e76f0184ae2 (patch)
tree6855fbf1b5bf7b11958a222f70e9301156931c0b
parent9aeb23f2ae58e4f6dd2b53dbb47cf8c173e56d83 (diff)
parent94c4d5b54e7840fa36d76e7c3d52e19c31a1dbc1 (diff)
Merge branch 'master' into refactorEagerSolverrefactorEagerSolver
-rw-r--r--docs/CMakeLists.txt1
-rw-r--r--docs/api/api.rst5
-rw-r--r--docs/api/cpp/class_hierarchy.rst47
-rw-r--r--docs/api/cpp/cpp.rst50
-rw-r--r--docs/api/java/CMakeLists.txt13
-rw-r--r--docs/api/python/python.rst2
-rw-r--r--docs/binary/binary.rst7
-rw-r--r--docs/binary/languages.rst (renamed from docs/languages.rst)0
-rw-r--r--docs/binary/quickstart.rst2
-rw-r--r--docs/examples/examples.rst2
-rw-r--r--docs/index.rst1
-rw-r--r--docs/theories/sets-and-relations.rst6
-rw-r--r--examples/api/cpp/sets.cpp8
-rw-r--r--examples/api/python/sets.py8
-rw-r--r--examples/api/smtlib/sets.smt26
-rw-r--r--examples/sets-translate/sets_translate.cpp2
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/api/cpp/cvc5.cpp187
-rw-r--r--src/api/cpp/cvc5.h34
-rw-r--r--src/api/cpp/cvc5_kind.h45
-rw-r--r--src/api/java/CMakeLists.txt1
-rw-r--r--src/api/java/genkinds.py.in7
-rw-r--r--src/api/java/io/github/cvc5/api/RoundingMode.java6
-rw-r--r--src/api/java/io/github/cvc5/api/Solver.java20
-rw-r--r--src/api/java/io/github/cvc5/api/Term.java21
-rw-r--r--src/api/java/jni/solver.cpp15
-rw-r--r--src/api/java/jni/term.cpp30
-rw-r--r--src/api/python/cvc5.pxd5
-rw-r--r--src/api/python/cvc5.pxi27
-rw-r--r--src/expr/bound_var_manager.cpp4
-rw-r--r--src/expr/dtype.cpp2
-rwxr-xr-xsrc/expr/mkmetakind85
-rw-r--r--src/expr/nary_term_util.cpp6
-rw-r--r--src/expr/node_algorithm.cpp194
-rw-r--r--src/expr/node_algorithm.h28
-rw-r--r--src/expr/node_manager.cpp6
-rw-r--r--src/expr/node_manager.h28
-rw-r--r--src/expr/term_context_node.cpp4
-rw-r--r--src/parser/antlr_input.cpp1
-rw-r--r--src/parser/input.cpp1
-rw-r--r--src/parser/parser.cpp3
-rw-r--r--src/parser/smt2/smt2.cpp50
-rw-r--r--src/preprocessing/passes/bv_to_int.cpp27
-rw-r--r--src/preprocessing/passes/miplib_trick.cpp20
-rw-r--r--src/preprocessing/passes/real_to_int.cpp10
-rw-r--r--src/preprocessing/passes/unconstrained_simplifier.cpp14
-rw-r--r--src/printer/printer.cpp6
-rw-r--r--src/printer/smt2/smt2_printer.cpp27
-rw-r--r--src/proof/alethe/alethe_post_processor.cpp119
-rw-r--r--src/proof/lfsc/lfsc_node_converter.cpp48
-rw-r--r--src/proof/lfsc/lfsc_util.cpp5
-rw-r--r--src/proof/method_id.cpp5
-rw-r--r--src/proof/proof.cpp18
-rw-r--r--src/proof/proof_checker.cpp3
-rw-r--r--src/proof/proof_node_manager.cpp8
-rw-r--r--src/prop/proof_cnf_stream.cpp10
-rw-r--r--src/smt/assertions.cpp9
-rw-r--r--src/smt/difficulty_post_processor.cpp2
-rw-r--r--src/smt/proof_post_processor.cpp6
-rw-r--r--src/smt/term_formula_removal.cpp42
-rw-r--r--src/smt_util/nary_builder.cpp6
-rw-r--r--src/theory/arith/arith_msum.cpp38
-rw-r--r--src/theory/arith/arith_rewriter.cpp52
-rw-r--r--src/theory/arith/arith_utilities.cpp2
-rw-r--r--src/theory/arith/arith_utilities.h2
-rw-r--r--src/theory/arith/bound_inference.cpp14
-rw-r--r--src/theory/arith/congruence_manager.cpp13
-rw-r--r--src/theory/arith/constraint.cpp28
-rw-r--r--src/theory/arith/infer_bounds.cpp4
-rw-r--r--src/theory/arith/kinds6
-rw-r--r--src/theory/arith/nl/cad/cdcac.cpp4
-rw-r--r--src/theory/arith/nl/cad/proof_generator.cpp4
-rw-r--r--src/theory/arith/nl/ext/ext_state.cpp8
-rw-r--r--src/theory/arith/nl/ext/factoring_check.cpp6
-rw-r--r--src/theory/arith/nl/ext/monomial.cpp2
-rw-r--r--src/theory/arith/nl/ext/monomial_bounds_check.cpp6
-rw-r--r--src/theory/arith/nl/ext/proof_checker.cpp6
-rw-r--r--src/theory/arith/nl/ext/tangent_plane_check.cpp21
-rw-r--r--src/theory/arith/nl/ext_theory_callback.cpp2
-rw-r--r--src/theory/arith/nl/iand_solver.cpp6
-rw-r--r--src/theory/arith/nl/iand_utils.cpp29
-rw-r--r--src/theory/arith/nl/nl_model.cpp14
-rw-r--r--src/theory/arith/nl/nonlinear_extension.cpp6
-rw-r--r--src/theory/arith/nl/poly_conversion.cpp123
-rw-r--r--src/theory/arith/nl/pow2_solver.cpp6
-rw-r--r--src/theory/arith/nl/transcendental/exponential_solver.cpp4
-rw-r--r--src/theory/arith/nl/transcendental/proof_checker.cpp17
-rw-r--r--src/theory/arith/nl/transcendental/sine_solver.cpp23
-rw-r--r--src/theory/arith/nl/transcendental/taylor_generator.cpp36
-rw-r--r--src/theory/arith/nl/transcendental/transcendental_state.cpp54
-rw-r--r--src/theory/arith/operator_elim.cpp92
-rw-r--r--src/theory/arith/proof_checker.cpp18
-rw-r--r--src/theory/arith/theory_arith_private.cpp19
-rw-r--r--src/theory/arith/type_enumerator.h8
-rw-r--r--src/theory/bags/bag_make_op.cpp (renamed from src/theory/bags/make_bag_op.cpp)18
-rw-r--r--src/theory/bags/bag_make_op.h (renamed from src/theory/bags/make_bag_op.h)32
-rw-r--r--src/theory/bags/bag_solver.cpp42
-rw-r--r--src/theory/bags/bag_solver.h6
-rw-r--r--src/theory/bags/bags_rewriter.cpp244
-rw-r--r--src/theory/bags/bags_rewriter.h131
-rw-r--r--src/theory/bags/infer_info.h1
-rw-r--r--src/theory/bags/inference_generator.cpp69
-rw-r--r--src/theory/bags/inference_generator.h84
-rw-r--r--src/theory/bags/kinds74
-rw-r--r--src/theory/bags/normal_form.cpp180
-rw-r--r--src/theory/bags/normal_form.h33
-rw-r--r--src/theory/bags/rewrites.cpp15
-rw-r--r--src/theory/bags/rewrites.h14
-rw-r--r--src/theory/bags/solver_state.cpp2
-rw-r--r--src/theory/bags/solver_state.h3
-rw-r--r--src/theory/bags/theory_bags.cpp18
-rw-r--r--src/theory/bags/theory_bags_type_enumerator.cpp10
-rw-r--r--src/theory/bags/theory_bags_type_rules.cpp48
-rw-r--r--src/theory/bags/theory_bags_type_rules.h26
-rw-r--r--src/theory/booleans/proof_circuit_propagator.cpp4
-rw-r--r--src/theory/builtin/proof_checker.cpp2
-rw-r--r--src/theory/bv/int_blaster.cpp16
-rw-r--r--src/theory/bv/theory_bv_utils.cpp17
-rw-r--r--src/theory/datatypes/datatypes_rewriter.cpp7
-rw-r--r--src/theory/datatypes/infer_proof_cons.cpp4
-rw-r--r--src/theory/datatypes/sygus_extension.cpp12
-rw-r--r--src/theory/datatypes/sygus_simple_sym.cpp4
-rw-r--r--src/theory/datatypes/theory_datatypes.cpp2
-rw-r--r--src/theory/difficulty_manager.cpp4
-rw-r--r--src/theory/evaluator.cpp4
-rw-r--r--src/theory/fp/theory_fp.cpp15
-rw-r--r--src/theory/fp/theory_fp_rewriter.cpp10
-rw-r--r--src/theory/inference_id.cpp14
-rw-r--r--src/theory/inference_id.h13
-rw-r--r--src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp37
-rw-r--r--src/theory/quantifiers/cegqi/ceg_instantiator.cpp18
-rw-r--r--src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp11
-rw-r--r--src/theory/quantifiers/cegqi/vts_term_cache.cpp2
-rw-r--r--src/theory/quantifiers/ematching/inst_match_generator.cpp8
-rw-r--r--src/theory/quantifiers/ematching/pattern_term_selector.cpp6
-rw-r--r--src/theory/quantifiers/ematching/relational_match_generator.cpp5
-rw-r--r--src/theory/quantifiers/ematching/trigger_term_info.cpp2
-rw-r--r--src/theory/quantifiers/extended_rewrite.cpp2
-rw-r--r--src/theory/quantifiers/fmf/bounded_integers.cpp24
-rw-r--r--src/theory/quantifiers/quant_bound_inference.cpp5
-rw-r--r--src/theory/quantifiers/quant_conflict_find.cpp2
-rw-r--r--src/theory/quantifiers/quantifiers_rewriter.cpp2
-rw-r--r--src/theory/quantifiers/skolemize.cpp10
-rw-r--r--src/theory/quantifiers/sygus/cegis_unif.cpp6
-rw-r--r--src/theory/quantifiers/sygus/sygus_enumerator.cpp2
-rw-r--r--src/theory/quantifiers/sygus/sygus_grammar_cons.cpp13
-rw-r--r--src/theory/quantifiers/sygus_sampler.cpp8
-rw-r--r--src/theory/quantifiers/term_database.cpp2
-rw-r--r--src/theory/quantifiers/term_util.cpp10
-rw-r--r--src/theory/sep/theory_sep.cpp20
-rw-r--r--src/theory/sets/cardinality_extension.cpp27
-rw-r--r--src/theory/sets/kinds15
-rw-r--r--src/theory/sets/singleton_op.cpp2
-rw-r--r--src/theory/sets/solver_state.cpp2
-rw-r--r--src/theory/sets/term_registry.cpp2
-rw-r--r--src/theory/sets/theory_sets.cpp2
-rw-r--r--src/theory/sets/theory_sets_private.cpp6
-rw-r--r--src/theory/sets/theory_sets_rewriter.cpp52
-rw-r--r--src/theory/sets/theory_sets_rewriter.h9
-rw-r--r--src/theory/sets/theory_sets_type_rules.cpp55
-rw-r--r--src/theory/sets/theory_sets_type_rules.h82
-rw-r--r--src/theory/strings/arith_entail.cpp26
-rw-r--r--src/theory/strings/array_solver.cpp96
-rw-r--r--src/theory/strings/base_solver.cpp17
-rw-r--r--src/theory/strings/base_solver.h6
-rw-r--r--src/theory/strings/core_solver.cpp20
-rw-r--r--src/theory/strings/infer_proof_cons.cpp6
-rw-r--r--src/theory/strings/inference_manager.cpp4
-rw-r--r--src/theory/strings/proof_checker.cpp10
-rw-r--r--src/theory/strings/regexp_elim.cpp25
-rw-r--r--src/theory/strings/regexp_entail.cpp6
-rw-r--r--src/theory/strings/regexp_operation.cpp15
-rw-r--r--src/theory/strings/rewrites.cpp4
-rw-r--r--src/theory/strings/rewrites.h2
-rw-r--r--src/theory/strings/sequences_rewriter.cpp169
-rw-r--r--src/theory/strings/skolem_cache.cpp13
-rw-r--r--src/theory/strings/solver_state.cpp2
-rw-r--r--src/theory/strings/strings_entail.cpp12
-rw-r--r--src/theory/strings/strings_fmf.cpp3
-rw-r--r--src/theory/strings/strings_rewriter.cpp17
-rw-r--r--src/theory/strings/term_registry.cpp32
-rw-r--r--src/theory/strings/theory_strings.cpp22
-rw-r--r--src/theory/strings/theory_strings_preprocess.cpp22
-rw-r--r--src/theory/strings/theory_strings_utils.cpp3
-rw-r--r--src/theory/uf/ho_extension.cpp274
-rw-r--r--src/theory/uf/ho_extension.h49
-rw-r--r--src/theory/uf/kinds2
-rw-r--r--src/theory/uf/lambda_lift.cpp5
-rw-r--r--src/theory/uf/lambda_lift.h2
-rw-r--r--src/theory/uf/theory_uf.cpp63
-rw-r--r--src/theory/uf/theory_uf.h3
-rw-r--r--test/CMakeLists.txt5
-rw-r--r--test/python/CMakeLists.txt37
-rw-r--r--test/regress/CMakeLists.txt11
-rw-r--r--test/regress/regress0/arrays/issue7596-define-array-uminus.smt25
-rw-r--r--test/regress/regress0/ho/lazy-lambda-model.smt216
-rw-r--r--test/regress/regress0/ho/simple-conf-lazy-lambda-lift-app.smt214
-rw-r--r--test/regress/regress0/ho/simple-conf-lazy-lambda-lift.smt211
-rw-r--r--test/regress/regress0/rels/addr_book_0.cvc.smt22
-rw-r--r--test/regress/regress0/rels/iden_0.cvc.smt22
-rw-r--r--test/regress/regress0/seq/proj-issue340.smt29
-rw-r--r--test/regress/regress0/sets/complement3.cvc.smt22
-rw-r--r--test/regress/regress0/sets/cvc-sample.cvc.smt24
-rw-r--r--test/regress/regress0/sets/eqtest.smt24
-rw-r--r--test/regress/regress0/sets/jan24/deepmeas0.hs.fqout.cvc4.47.smt22
-rw-r--r--test/regress/regress0/sets/jan27/ListConcat.hs.fqout.cvc4.177.smt22
-rw-r--r--test/regress/regress0/sets/rec_copy_loop_check_heap_access_43_4.smt22
-rw-r--r--test/regress/regress0/sets/sets-inter.smt22
-rw-r--r--test/regress/regress0/sets/sets-new.smt22
-rw-r--r--test/regress/regress0/sets/sets-poly-int-real.smt22
-rw-r--r--test/regress/regress0/sets/sets-sample.smt24
-rw-r--r--test/regress/regress0/sets/sharing-simp.smt22
-rw-r--r--test/regress/regress1/bags/choose1.smt22
-rw-r--r--test/regress/regress1/bags/choose3.smt22
-rw-r--r--test/regress/regress1/bags/choose4.smt22
-rw-r--r--test/regress/regress1/bags/difference_remove1.smt24
-rw-r--r--test/regress/regress1/bags/duplicate_removal1.smt24
-rw-r--r--test/regress/regress1/bags/duplicate_removal2.smt26
-rw-r--r--test/regress/regress1/bags/emptybag1.smt22
-rw-r--r--test/regress/regress1/bags/fuzzy1.smt22
-rw-r--r--test/regress/regress1/bags/fuzzy2.smt28
-rw-r--r--test/regress/regress1/bags/fuzzy3.smt22
-rw-r--r--test/regress/regress1/bags/fuzzy4.smt24
-rw-r--r--test/regress/regress1/bags/fuzzy5.smt22
-rw-r--r--test/regress/regress1/bags/fuzzy6.smt213
-rw-r--r--test/regress/regress1/bags/intersection_min1.smt24
-rw-r--r--test/regress/regress1/bags/intersection_min2.smt26
-rw-r--r--test/regress/regress1/bags/issue5759.smt24
-rw-r--r--test/regress/regress1/bags/map-lazy-lam.smt29
-rw-r--r--test/regress/regress1/bags/map1.smt24
-rw-r--r--test/regress/regress1/bags/map3.smt22
-rw-r--r--test/regress/regress1/bags/subbag1.smt24
-rw-r--r--test/regress/regress1/bags/subbag2.smt24
-rw-r--r--test/regress/regress1/bags/union_disjoint.smt24
-rw-r--r--test/regress/regress1/bags/union_max1.smt24
-rw-r--r--test/regress/regress1/bags/union_max2.smt26
-rw-r--r--test/regress/regress1/ho/bug_freevar_PHI004^4-delta.smt22
-rw-r--r--test/regress/regress1/ho/ho-fun-sharing-dd.smt210
-rw-r--r--test/regress/regress1/quantifiers/set8.smt26
-rw-r--r--test/regress/regress1/rels/rel_complex_3.cvc.smt24
-rw-r--r--test/regress/regress1/rels/rel_complex_4.cvc.smt24
-rw-r--r--test/regress/regress1/rels/rel_complex_5.cvc.smt24
-rw-r--r--test/regress/regress1/sets/ListElem.hs.fqout.cvc4.38.smt22
-rw-r--r--test/regress/regress1/sets/ListElts.hs.fqout.cvc4.317.smt22
-rw-r--r--test/regress/regress1/sets/TalkingAboutSets.hs.fqout.cvc4.3577.smt22
-rw-r--r--test/regress/regress1/sets/UniqueZipper.hs.1030minimized.cvc4.smt22
-rw-r--r--test/regress/regress1/sets/UniqueZipper.hs.1030minimized2.cvc4.smt22
-rw-r--r--test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.10.smt22
-rw-r--r--test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.1832.smt22
-rw-r--r--test/regress/regress1/sets/card-3.smt22
-rw-r--r--test/regress/regress1/sets/card-4.smt22
-rw-r--r--test/regress/regress1/sets/card-5.smt22
-rw-r--r--test/regress/regress1/sets/card-6.smt22
-rw-r--r--test/regress/regress1/sets/comp-intersect.smt22
-rw-r--r--test/regress/regress1/sets/deepmeas0.hs.fqout.cvc4.41.smt22
-rw-r--r--test/regress/regress1/sets/finite-type/sets-card-bool-1.smt22
-rw-r--r--test/regress/regress1/sets/finite-type/sets-card-bv-2.smt22
-rw-r--r--test/regress/regress1/sets/finite-type/sets-card-bv-3.smt22
-rw-r--r--test/regress/regress1/sets/finite-type/sets-card-bv-4.smt22
-rw-r--r--test/regress/regress1/sets/finite-type/sets-card-datatype-1.smt22
-rw-r--r--test/regress/regress1/sets/finite-type/sets-card-datatype-2.smt22
-rw-r--r--test/regress/regress1/sets/fuzz14418.smt22
-rw-r--r--test/regress/regress1/sets/fuzz15201.smt26
-rw-r--r--test/regress/regress1/sets/fuzz31811.smt28
-rw-r--r--test/regress/regress1/sets/infinite-type/sets-card-array-int-1.smt22
-rw-r--r--test/regress/regress1/sets/infinite-type/sets-card-array-int-2.smt22
-rw-r--r--test/regress/regress1/sets/infinite-type/sets-card-int-1.smt22
-rw-r--r--test/regress/regress1/sets/infinite-type/sets-card-int-2.smt22
-rw-r--r--test/regress/regress1/sets/insert_invariant_37_2.smt22
-rw-r--r--test/regress/regress1/sets/issue2904.smt22
-rw-r--r--test/regress/regress1/sets/issue4370-2-lemma-ee-iter.smt22
-rw-r--r--test/regress/regress1/sets/issue4370-4-lemma-ee-iter.smt24
-rw-r--r--test/regress/regress1/sets/issue4391-card-lasso.smt22
-rw-r--r--test/regress/regress1/sets/lemmabug-ListElts317minimized.smt22
-rw-r--r--test/regress/regress1/sets/remove_check_free_31_6.smt28
-rw-r--r--test/regress/regress1/sym/sym5.smt22
-rw-r--r--test/regress/regress1/trim.cvc.smt24
-rw-r--r--test/unit/CMakeLists.txt6
-rw-r--r--test/unit/api/CMakeLists.txt15
-rw-r--r--test/unit/api/cpp/CMakeLists.txt24
-rw-r--r--test/unit/api/cpp/datatype_api_black.cpp (renamed from test/unit/api/datatype_api_black.cpp)0
-rw-r--r--test/unit/api/cpp/grammar_black.cpp (renamed from test/unit/api/grammar_black.cpp)0
-rw-r--r--test/unit/api/cpp/op_black.cpp (renamed from test/unit/api/op_black.cpp)0
-rw-r--r--test/unit/api/cpp/op_white.cpp (renamed from test/unit/api/op_white.cpp)0
-rw-r--r--test/unit/api/cpp/result_black.cpp (renamed from test/unit/api/result_black.cpp)0
-rw-r--r--test/unit/api/cpp/solver_black.cpp (renamed from test/unit/api/solver_black.cpp)31
-rw-r--r--test/unit/api/cpp/solver_white.cpp (renamed from test/unit/api/solver_white.cpp)0
-rw-r--r--test/unit/api/cpp/sort_black.cpp (renamed from test/unit/api/sort_black.cpp)0
-rw-r--r--test/unit/api/cpp/term_black.cpp (renamed from test/unit/api/term_black.cpp)21
-rw-r--r--test/unit/api/cpp/term_white.cpp (renamed from test/unit/api/term_white.cpp)0
-rw-r--r--test/unit/api/java/SolverTest.java7
-rw-r--r--test/unit/api/java/TermTest.java15
-rw-r--r--test/unit/api/python/CMakeLists.txt40
-rw-r--r--test/unit/api/python/__init__.py (renamed from test/python/unit/api/__init__.py)0
-rw-r--r--test/unit/api/python/test_datatype_api.py (renamed from test/python/unit/api/test_datatype_api.py)0
-rw-r--r--test/unit/api/python/test_grammar.py (renamed from test/python/unit/api/test_grammar.py)0
-rw-r--r--test/unit/api/python/test_op.py (renamed from test/python/unit/api/test_op.py)0
-rw-r--r--test/unit/api/python/test_result.py (renamed from test/python/unit/api/test_result.py)0
-rw-r--r--test/unit/api/python/test_solver.py (renamed from test/python/unit/api/test_solver.py)10
-rw-r--r--test/unit/api/python/test_sort.py (renamed from test/python/unit/api/test_sort.py)0
-rw-r--r--test/unit/api/python/test_term.py (renamed from test/python/unit/api/test_term.py)17
-rw-r--r--test/unit/api/python/test_to_python_obj.py (renamed from test/python/unit/api/test_to_python_obj.py)0
-rw-r--r--test/unit/node/node_algorithm_black.cpp4
-rw-r--r--test/unit/node/node_black.cpp10
-rw-r--r--test/unit/node/node_builder_black.cpp2
-rw-r--r--test/unit/node/node_manager_black.cpp2
-rw-r--r--test/unit/node/node_manager_white.cpp5
-rw-r--r--test/unit/node/node_white.cpp2
-rw-r--r--test/unit/node/type_node_white.cpp3
-rw-r--r--test/unit/preprocessing/pass_foreign_theory_rewrite_white.cpp8
-rw-r--r--test/unit/theory/CMakeLists.txt1
-rw-r--r--test/unit/theory/arith_poly_white.cpp14
-rw-r--r--test/unit/theory/evaluator_white.cpp14
-rw-r--r--test/unit/theory/sequences_rewriter_white.cpp73
-rw-r--r--test/unit/theory/theory_arith_cad_white.cpp29
-rw-r--r--test/unit/theory/theory_arith_pow2_white.cpp2
-rw-r--r--test/unit/theory/theory_arith_white.cpp8
-rw-r--r--test/unit/theory/theory_bags_normal_form_white.cpp508
-rw-r--r--test/unit/theory/theory_bags_rewriter_white.cpp547
-rw-r--r--test/unit/theory/theory_bags_type_rules_white.cpp63
-rw-r--r--test/unit/theory/theory_black.cpp4
-rw-r--r--test/unit/theory/theory_bv_int_blaster_white.cpp4
-rw-r--r--test/unit/theory/theory_engine_white.cpp6
-rw-r--r--test/unit/theory/theory_int_opt_white.cpp26
-rw-r--r--test/unit/theory/theory_sets_rewriter_white.cpp93
-rw-r--r--test/unit/theory/theory_sets_type_rules_white.cpp8
-rw-r--r--test/unit/theory/theory_strings_skolem_cache_black.cpp8
-rw-r--r--test/unit/theory/type_enumerator_white.cpp130
-rw-r--r--test/unit/util/array_store_all_white.cpp24
-rw-r--r--test/unit/util/datatype_black.cpp4
330 files changed, 4276 insertions, 2467 deletions
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index f505a7fb4..e37183f90 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -16,6 +16,7 @@ find_package(Sphinx REQUIRED)
check_python_module(breathe)
check_python_module(sphinxcontrib.bibtex sphinxcontrib-bibtex)
check_python_module(sphinx_tabs.tabs sphinx-tabs)
+check_python_module(sphinxcontrib.programoutput sphinxcontrib.programoutput)
add_subdirectory(api)
diff --git a/docs/api/api.rst b/docs/api/api.rst
index a3acdda17..4a1fb7202 100644
--- a/docs/api/api.rst
+++ b/docs/api/api.rst
@@ -1,6 +1,11 @@
API Documentation
=================
+In addition to using cvc5 :doc:`as a binary <../binary/binary>`, cvc5 features APIs
+for several different programming languages.
+While the :doc:`C++ API <cpp/cpp>` is considered the primary interface to cvc5, both the :doc:`Java API <java/index>` and the :doc:`Python API <python/python>` implement a thin wrapper around it.
+Additionally, a more pythonic Python API is availble at https://github.com/cvc5/cvc5_z3py_compat.
+
.. toctree::
:maxdepth: 1
diff --git a/docs/api/cpp/class_hierarchy.rst b/docs/api/cpp/class_hierarchy.rst
deleted file mode 100644
index b441106ff..000000000
--- a/docs/api/cpp/class_hierarchy.rst
+++ /dev/null
@@ -1,47 +0,0 @@
-C++ API Class Hierarchy
-=======================
-
-``namespace cvc5::api {``
-
- * class :cpp:class:`CVC5ApiException <cvc5::api::CVC5ApiException>`
- * class :cpp:class:`CVC5ApiRecoverableException <cvc5::api::CVC5ApiRecoverableException>`
-
- * class :ref:`api/cpp/datatype:datatype`
-
- * class :cpp:class:`const_iterator <cvc5::api::Datatype::const_iterator>`
-
- * class :ref:`api/cpp/datatypeconstructor:datatypeconstructor`
-
- * class :cpp:class:`const_iterator <cvc5::api::DatatypeConstructor::const_iterator>`
-
- * class :ref:`api/cpp/datatypeconstructordecl:datatypeconstructordecl`
- * class :ref:`api/cpp/datatypedecl:datatypedecl`
- * class :ref:`api/cpp/datatypeselector:datatypeselector`
-
- * class :ref:`api/cpp/grammar:grammar`
-
- * class :ref:`api/cpp/kind:kind`
-
- * class :ref:`api/cpp/op:op`
-
- * class :ref:`api/cpp/optioninfo:optioninfo`
-
- * class :ref:`api/cpp/result:result`
-
- * enum :cpp:enum:`UnknownExplanation <cvc5::api::Result::UnknownExplanation>`
-
- * class :ref:`api/cpp/roundingmode:roundingmode`
-
- * class :ref:`api/cpp/solver:solver`
-
- * class :ref:`api/cpp/sort:sort`
-
- * class :cpp:class:`Stat <cvc5::api::Stat>`
-
- * class :cpp:class:`Statistics <cvc5::api::Statistics>`
-
- * class :ref:`api/cpp/term:term`
-
- * class :cpp:class:`const_iterator <cvc5::api::Term::const_iterator>`
-
-``}``
diff --git a/docs/api/cpp/cpp.rst b/docs/api/cpp/cpp.rst
index edcbbd87d..96177e7d8 100644
--- a/docs/api/cpp/cpp.rst
+++ b/docs/api/cpp/cpp.rst
@@ -1,25 +1,23 @@
-.. _cpp-api:
-
C++ API Documentation
=====================
-.. toctree::
- :maxdepth: 1
+The C++ API is the primary interface for cvc5 and exposes the full functionality of cvc5.
+The :doc:`quickstart guide <quickstart>` gives a short introduction, while the following class hierarchy of the ``cvc5::api`` namespace provides more details on the individual classes.
+For most applications, the :cpp:class:`Solver <cvc5::api::Solver>` class is the main entry point to cvc5.
- quickstart
- class_hierarchy
.. container:: hide-toctree
.. toctree::
:maxdepth: 0
+ quickstart
+ exceptions
datatype
datatypeconstructor
datatypeconstructordecl
datatypedecl
datatypeselector
- exceptions
grammar
kind
op
@@ -30,3 +28,41 @@ C++ API Documentation
sort
statistics
term
+
+
+Class hierarchy
+^^^^^^^^^^^^^^^
+
+``namespace cvc5::api {``
+
+ * class :cpp:class:`CVC5ApiException <cvc5::api::CVC5ApiException>`
+ * class :cpp:class:`CVC5ApiRecoverableException <cvc5::api::CVC5ApiRecoverableException>`
+ * class :ref:`api/cpp/datatype:datatype`
+
+ * class :cpp:class:`const_iterator <cvc5::api::Datatype::const_iterator>`
+
+ * class :ref:`api/cpp/datatypeconstructor:datatypeconstructor`
+
+ * class :cpp:class:`const_iterator <cvc5::api::DatatypeConstructor::const_iterator>`
+
+ * class :ref:`api/cpp/datatypeconstructordecl:datatypeconstructordecl`
+ * class :ref:`api/cpp/datatypedecl:datatypedecl`
+ * class :ref:`api/cpp/datatypeselector:datatypeselector`
+ * class :ref:`api/cpp/grammar:grammar`
+ * class :ref:`api/cpp/kind:kind`
+ * class :ref:`api/cpp/op:op`
+ * class :ref:`api/cpp/optioninfo:optioninfo`
+ * class :ref:`api/cpp/result:result`
+
+ * enum :cpp:enum:`UnknownExplanation <cvc5::api::Result::UnknownExplanation>`
+
+ * class :ref:`api/cpp/roundingmode:roundingmode`
+ * class :ref:`api/cpp/solver:solver`
+ * class :ref:`api/cpp/sort:sort`
+ * class :cpp:class:`Stat <cvc5::api::Stat>`
+ * class :cpp:class:`Statistics <cvc5::api::Statistics>`
+ * class :ref:`api/cpp/term:term`
+
+ * class :cpp:class:`const_iterator <cvc5::api::Term::const_iterator>`
+
+``}`` \ No newline at end of file
diff --git a/docs/api/java/CMakeLists.txt b/docs/api/java/CMakeLists.txt
index 7c897a354..8a728407f 100644
--- a/docs/api/java/CMakeLists.txt
+++ b/docs/api/java/CMakeLists.txt
@@ -23,19 +23,18 @@ if(BUILD_BINDINGS_JAVA)
# used to trigger the rebuild
set(JAVADOC_INDEX_FILE ${JAVADOC_OUTPUT_DIR}/index.html)
- get_target_property(SOURCES cvc5jar SOURCES)
-
+ get_target_property(CVC5_JAR_FILE cvc5jar JAR_FILE)
add_custom_command(
- OUTPUT "${JAVADOC_INDEX_FILE}"
- COMMAND
+ OUTPUT ${JAVADOC_INDEX_FILE}
+ COMMAND
${Java_JAVADOC_EXECUTABLE} io.github.cvc5.api
- -sourcepath ${CMAKE_SOURCE_DIR}/src/api/java/
+ -sourcepath ${CMAKE_SOURCE_DIR}/src/api/java/:${CMAKE_BINARY_DIR}/src/api/java/
-d ${JAVADOC_OUTPUT_DIR}
- -cp ${CMAKE_BINARY_DIR}/src/api/java/cvc5.jar
+ -cp ${CVC5_JAR_FILE}
-notimestamp
COMMAND find ${JAVADOC_OUTPUT_DIR} -type f -exec sed -i'orig' 's/<!-- Generated by javadoc [^>]* -->//' {} "\;"
COMMAND find ${SPHINX_GH_OUTPUT_DIR} -name '*orig' -delete
- DEPENDS cvc5jar ${SOURCES}
+ DEPENDS cvc5jar ${CVC5_JAR_FILE}
COMMENT "Generating javadocs"
)
diff --git a/docs/api/python/python.rst b/docs/api/python/python.rst
index f6258af2d..0cf78d0ce 100644
--- a/docs/api/python/python.rst
+++ b/docs/api/python/python.rst
@@ -1,5 +1,3 @@
-.. _python-api:
-
Python API Documentation
========================
diff --git a/docs/binary/binary.rst b/docs/binary/binary.rst
index 91e2493e7..44a177afb 100644
--- a/docs/binary/binary.rst
+++ b/docs/binary/binary.rst
@@ -1,11 +1,18 @@
Binary Documentation
====================
+The easiest way to use cvc5 is usually to invoke the cvc5 binary via the command line.
+The :doc:`quickstart guide <quickstart>` gives a short introduction on how to use cvc5 via the SMT-LIBv2
+interface, but cvc5 also supports other :doc:`input languages <languages>`.
+The behavior of cvc5 can be changed with a number of :doc:`options <options>`, and :doc:`output tags <output-tags>` allow to extract structured information about the solving process.
+
+Alternatively, cvc5 features :doc:`several APIs <../api/api>` for different programming languages.
.. toctree::
:maxdepth: 2
quickstart
+ languages
options
output-tags
diff --git a/docs/languages.rst b/docs/binary/languages.rst
index 34c536017..34c536017 100644
--- a/docs/languages.rst
+++ b/docs/binary/languages.rst
diff --git a/docs/binary/quickstart.rst b/docs/binary/quickstart.rst
index 67280ca45..f3c9c4ad8 100644
--- a/docs/binary/quickstart.rst
+++ b/docs/binary/quickstart.rst
@@ -119,7 +119,7 @@ Example
| The source code for this example can be found at `examples/api/smtlib/quickstart.smt2 <https://github.com/cvc5/cvc5/blob/master/examples/api/smtlib/quickstart.smt2>`_.
.. api-examples::
+ ../../examples/api/smtlib/quickstart.smt2
../../examples/api/cpp/quickstart.cpp
../../examples/api/java/QuickStart.java
../../examples/api/python/quickstart.py
- ../../examples/api/smtlib/quickstart.smt2
diff --git a/docs/examples/examples.rst b/docs/examples/examples.rst
index 0b2651851..accdd004f 100644
--- a/docs/examples/examples.rst
+++ b/docs/examples/examples.rst
@@ -1,7 +1,7 @@
Examples
===========
-The following examples show how the APIs (:ref:`cpp-api`, :ref:`python-api`)
+The following examples show how the APIs (:doc:`../api/cpp/cpp`, :doc:`../api/java/index`, :doc:`../api/python/python`)
and input languages can be used.
For every example, the same problem is constructed and solved using different
input mechanisms.
diff --git a/docs/index.rst b/docs/index.rst
index 5f0ede34f..27b7b728d 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -18,7 +18,6 @@ Table of Contents
binary/binary
api/api
examples/examples
- languages
theory
references
genindex
diff --git a/docs/theories/sets-and-relations.rst b/docs/theories/sets-and-relations.rst
index 423a5d4b1..8bce6b72c 100644
--- a/docs/theories/sets-and-relations.rst
+++ b/docs/theories/sets-and-relations.rst
@@ -42,7 +42,9 @@ a `cvc5::api::Solver solver` object.
| | | |
| | | ``Term t = solver.mkTerm(Kind::SET_UNION, X, Y);`` |
+----------------------+----------------------------------------------+-------------------------------------------------------------------------+
-| Intersection | ``(set.minus X Y)`` | ``Term t = solver.mkTerm(Kind::SET_MINUS, X, Y);`` |
+| Intersection | ``(set.inter X Y)`` | ``Term t = solver.mkTerm(Kind::SET_INTER, X, Y);`` |
++----------------------+----------------------------------------------+-------------------------------------------------------------------------+
+| Minus | ``(set.minus X Y)`` | ``Term t = solver.mkTerm(Kind::SET_MINUS, X, Y);`` |
+----------------------+----------------------------------------------+-------------------------------------------------------------------------+
| Membership | ``(set.member x X)`` | ``Term x = solver.mkConst(solver.getIntegerSort(), "x");`` |
| | | |
@@ -76,7 +78,7 @@ Semantics
^^^^^^^^^
The semantics of most of the above operators (e.g., ``set.union``,
-``set.intersection``, difference) are straightforward.
+``set.inter``, difference) are straightforward.
The semantics for the universe set and complement are more subtle and explained
in the following.
diff --git a/examples/api/cpp/sets.cpp b/examples/api/cpp/sets.cpp
index a4bc12ec8..ff3546b6f 100644
--- a/examples/api/cpp/sets.cpp
+++ b/examples/api/cpp/sets.cpp
@@ -43,10 +43,10 @@ int main()
Term C = slv.mkConst(set, "C");
Term unionAB = slv.mkTerm(SET_UNION, A, B);
- Term lhs = slv.mkTerm(SET_INTERSECTION, unionAB, C);
+ Term lhs = slv.mkTerm(SET_INTER, unionAB, C);
- Term intersectionAC = slv.mkTerm(SET_INTERSECTION, A, C);
- Term intersectionBC = slv.mkTerm(SET_INTERSECTION, B, C);
+ Term intersectionAC = slv.mkTerm(SET_INTER, A, C);
+ Term intersectionBC = slv.mkTerm(SET_INTER, B, C);
Term rhs = slv.mkTerm(SET_UNION, intersectionAC, intersectionBC);
Term theorem = slv.mkTerm(EQUAL, lhs, rhs);
@@ -77,7 +77,7 @@ int main()
Term singleton_three = slv.mkTerm(SET_SINGLETON, three);
Term one_two = slv.mkTerm(SET_UNION, singleton_one, singleton_two);
Term two_three = slv.mkTerm(SET_UNION, singleton_two, singleton_three);
- Term intersection = slv.mkTerm(SET_INTERSECTION, one_two, two_three);
+ Term intersection = slv.mkTerm(SET_INTER, one_two, two_three);
Term x = slv.mkConst(integer, "x");
diff --git a/examples/api/python/sets.py b/examples/api/python/sets.py
index bf487c617..31f20dfeb 100644
--- a/examples/api/python/sets.py
+++ b/examples/api/python/sets.py
@@ -40,10 +40,10 @@ if __name__ == "__main__":
C = slv.mkConst(set_, "C")
unionAB = slv.mkTerm(kinds.SetUnion, A, B)
- lhs = slv.mkTerm(kinds.SetIntersection, unionAB, C)
+ lhs = slv.mkTerm(kinds.SetInter, unionAB, C)
- intersectionAC = slv.mkTerm(kinds.SetIntersection, A, C)
- intersectionBC = slv.mkTerm(kinds.SetIntersection, B, C)
+ intersectionAC = slv.mkTerm(kinds.SetInter, A, C)
+ intersectionBC = slv.mkTerm(kinds.SetInter, B, C)
rhs = slv.mkTerm(kinds.SetUnion, intersectionAC, intersectionBC)
theorem = slv.mkTerm(kinds.Equal, lhs, rhs)
@@ -72,7 +72,7 @@ if __name__ == "__main__":
singleton_three = slv.mkTerm(kinds.SetSingleton, three)
one_two = slv.mkTerm(kinds.SetUnion, singleton_one, singleton_two)
two_three = slv.mkTerm(kinds.SetUnion, singleton_two, singleton_three)
- intersection = slv.mkTerm(kinds.SetIntersection, one_two, two_three)
+ intersection = slv.mkTerm(kinds.SetInter, one_two, two_three)
x = slv.mkConst(integer, "x")
diff --git a/examples/api/smtlib/sets.smt2 b/examples/api/smtlib/sets.smt2
index f8b30ae47..59d3cdc4f 100644
--- a/examples/api/smtlib/sets.smt2
+++ b/examples/api/smtlib/sets.smt2
@@ -10,8 +10,8 @@
(check-sat-assuming
(
(distinct
- (set.intersection (set.union A B) C)
- (set.union (set.intersection A C) (set.intersection B C)))
+ (set.inter (set.union A B) C)
+ (set.union (set.inter A C) (set.inter B C)))
)
)
@@ -27,7 +27,7 @@
(
(set.member
x
- (set.intersection
+ (set.inter
(set.union (set.singleton 1) (set.singleton 2))
(set.union (set.singleton 2) (set.singleton 3))))
)
diff --git a/examples/sets-translate/sets_translate.cpp b/examples/sets-translate/sets_translate.cpp
index 69fc07837..0e1b93146 100644
--- a/examples/sets-translate/sets_translate.cpp
+++ b/examples/sets-translate/sets_translate.cpp
@@ -146,7 +146,7 @@ class Mapper {
<< " ( (s1 " << name << ") (s2 " << name << ") )"
<< " " << name << ""
<< " ((_ map and) s1 s2))" << endl;
- setoperators[make_pair(t, kind::SET_INTERSECTION)] =
+ setoperators[make_pair(t, kind::SET_INTER)] =
em->mkVar(std::string("intersection") + elementTypeAsString,
em->mkFunctionType(t_t, t));
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index db18a4bc8..58ccd288c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -529,6 +529,8 @@ libcvc5_add_sources(
theory/assertion.h
theory/atom_requests.cpp
theory/atom_requests.h
+ theory/bags/bag_make_op.cpp
+ theory/bags/bag_make_op.h
theory/bags/bags_rewriter.cpp
theory/bags/bags_rewriter.h
theory/bags/bag_solver.cpp
@@ -541,8 +543,6 @@ libcvc5_add_sources(
theory/bags/inference_generator.h
theory/bags/inference_manager.cpp
theory/bags/inference_manager.h
- theory/bags/make_bag_op.cpp
- theory/bags/make_bag_op.h
theory/bags/normal_form.cpp
theory/bags/normal_form.h
theory/bags/rewrites.cpp
@@ -1129,6 +1129,8 @@ libcvc5_add_sources(
theory/uf/proof_equality_engine.h
theory/uf/ho_extension.cpp
theory/uf/ho_extension.h
+ theory/uf/lambda_lift.cpp
+ theory/uf/lambda_lift.h
theory/uf/symmetry_breaker.cpp
theory/uf/symmetry_breaker.h
theory/uf/theory_uf.cpp
diff --git a/src/api/cpp/cvc5.cpp b/src/api/cpp/cvc5.cpp
index 797d2e473..0c7e86c86 100644
--- a/src/api/cpp/cvc5.cpp
+++ b/src/api/cpp/cvc5.cpp
@@ -53,6 +53,7 @@
#include "expr/node_algorithm.h"
#include "expr/node_builder.h"
#include "expr/node_manager.h"
+#include "expr/node_manager_attributes.h"
#include "expr/sequence.h"
#include "expr/type_node.h"
#include "expr/uninterpreted_constant.h"
@@ -275,7 +276,7 @@ const static std::unordered_map<Kind, cvc5::Kind> s_kinds{
/* Sets ---------------------------------------------------------------- */
{SET_EMPTY, cvc5::Kind::SET_EMPTY},
{SET_UNION, cvc5::Kind::SET_UNION},
- {SET_INTERSECTION, cvc5::Kind::SET_INTERSECTION},
+ {SET_INTER, cvc5::Kind::SET_INTER},
{SET_MINUS, cvc5::Kind::SET_MINUS},
{SET_SUBSET, cvc5::Kind::SET_SUBSET},
{SET_MEMBER, cvc5::Kind::SET_MEMBER},
@@ -287,6 +288,7 @@ const static std::unordered_map<Kind, cvc5::Kind> s_kinds{
{SET_COMPREHENSION, cvc5::Kind::SET_COMPREHENSION},
{SET_CHOOSE, cvc5::Kind::SET_CHOOSE},
{SET_IS_SINGLETON, cvc5::Kind::SET_IS_SINGLETON},
+ {SET_MAP, cvc5::Kind::SET_MAP},
/* Relations ----------------------------------------------------------- */
{RELATION_JOIN, cvc5::Kind::RELATION_JOIN},
{RELATION_PRODUCT, cvc5::Kind::RELATION_PRODUCT},
@@ -295,16 +297,16 @@ const static std::unordered_map<Kind, cvc5::Kind> s_kinds{
{RELATION_JOIN_IMAGE, cvc5::Kind::RELATION_JOIN_IMAGE},
{RELATION_IDEN, cvc5::Kind::RELATION_IDEN},
/* Bags ---------------------------------------------------------------- */
- {UNION_MAX, cvc5::Kind::UNION_MAX},
- {UNION_DISJOINT, cvc5::Kind::UNION_DISJOINT},
- {INTERSECTION_MIN, cvc5::Kind::INTERSECTION_MIN},
- {DIFFERENCE_SUBTRACT, cvc5::Kind::DIFFERENCE_SUBTRACT},
- {DIFFERENCE_REMOVE, cvc5::Kind::DIFFERENCE_REMOVE},
- {SUBBAG, cvc5::Kind::SUBBAG},
+ {BAG_UNION_MAX, cvc5::Kind::BAG_UNION_MAX},
+ {BAG_UNION_DISJOINT, cvc5::Kind::BAG_UNION_DISJOINT},
+ {BAG_INTER_MIN, cvc5::Kind::BAG_INTER_MIN},
+ {BAG_DIFFERENCE_SUBTRACT, cvc5::Kind::BAG_DIFFERENCE_SUBTRACT},
+ {BAG_DIFFERENCE_REMOVE, cvc5::Kind::BAG_DIFFERENCE_REMOVE},
+ {BAG_SUBBAG, cvc5::Kind::BAG_SUBBAG},
{BAG_COUNT, cvc5::Kind::BAG_COUNT},
- {DUPLICATE_REMOVAL, cvc5::Kind::DUPLICATE_REMOVAL},
- {MK_BAG, cvc5::Kind::MK_BAG},
- {EMPTYBAG, cvc5::Kind::EMPTYBAG},
+ {BAG_DUPLICATE_REMOVAL, cvc5::Kind::BAG_DUPLICATE_REMOVAL},
+ {BAG_MAKE, cvc5::Kind::BAG_MAKE},
+ {BAG_EMPTY, cvc5::Kind::BAG_EMPTY},
{BAG_CARD, cvc5::Kind::BAG_CARD},
{BAG_CHOOSE, cvc5::Kind::BAG_CHOOSE},
{BAG_IS_SINGLETON, cvc5::Kind::BAG_IS_SINGLETON},
@@ -585,7 +587,7 @@ const static std::unordered_map<cvc5::Kind, Kind, cvc5::kind::KindHashFunction>
/* Sets ------------------------------------------------------------ */
{cvc5::Kind::SET_EMPTY, SET_EMPTY},
{cvc5::Kind::SET_UNION, SET_UNION},
- {cvc5::Kind::SET_INTERSECTION, SET_INTERSECTION},
+ {cvc5::Kind::SET_INTER, SET_INTER},
{cvc5::Kind::SET_MINUS, SET_MINUS},
{cvc5::Kind::SET_SUBSET, SET_SUBSET},
{cvc5::Kind::SET_MEMBER, SET_MEMBER},
@@ -597,6 +599,7 @@ const static std::unordered_map<cvc5::Kind, Kind, cvc5::kind::KindHashFunction>
{cvc5::Kind::SET_COMPREHENSION, SET_COMPREHENSION},
{cvc5::Kind::SET_CHOOSE, SET_CHOOSE},
{cvc5::Kind::SET_IS_SINGLETON, SET_IS_SINGLETON},
+ {cvc5::Kind::SET_MAP, SET_MAP},
/* Relations ------------------------------------------------------- */
{cvc5::Kind::RELATION_JOIN, RELATION_JOIN},
{cvc5::Kind::RELATION_PRODUCT, RELATION_PRODUCT},
@@ -605,16 +608,16 @@ const static std::unordered_map<cvc5::Kind, Kind, cvc5::kind::KindHashFunction>
{cvc5::Kind::RELATION_JOIN_IMAGE, RELATION_JOIN_IMAGE},
{cvc5::Kind::RELATION_IDEN, RELATION_IDEN},
/* Bags ------------------------------------------------------------ */
- {cvc5::Kind::UNION_MAX, UNION_MAX},
- {cvc5::Kind::UNION_DISJOINT, UNION_DISJOINT},
- {cvc5::Kind::INTERSECTION_MIN, INTERSECTION_MIN},
- {cvc5::Kind::DIFFERENCE_SUBTRACT, DIFFERENCE_SUBTRACT},
- {cvc5::Kind::DIFFERENCE_REMOVE, DIFFERENCE_REMOVE},
- {cvc5::Kind::SUBBAG, SUBBAG},
+ {cvc5::Kind::BAG_UNION_MAX, BAG_UNION_MAX},
+ {cvc5::Kind::BAG_UNION_DISJOINT, BAG_UNION_DISJOINT},
+ {cvc5::Kind::BAG_INTER_MIN, BAG_INTER_MIN},
+ {cvc5::Kind::BAG_DIFFERENCE_SUBTRACT, BAG_DIFFERENCE_SUBTRACT},
+ {cvc5::Kind::BAG_DIFFERENCE_REMOVE, BAG_DIFFERENCE_REMOVE},
+ {cvc5::Kind::BAG_SUBBAG, BAG_SUBBAG},
{cvc5::Kind::BAG_COUNT, BAG_COUNT},
- {cvc5::Kind::DUPLICATE_REMOVAL, DUPLICATE_REMOVAL},
- {cvc5::Kind::MK_BAG, MK_BAG},
- {cvc5::Kind::EMPTYBAG, EMPTYBAG},
+ {cvc5::Kind::BAG_DUPLICATE_REMOVAL, BAG_DUPLICATE_REMOVAL},
+ {cvc5::Kind::BAG_MAKE, BAG_MAKE},
+ {cvc5::Kind::BAG_EMPTY, BAG_EMPTY},
{cvc5::Kind::BAG_CARD, BAG_CARD},
{cvc5::Kind::BAG_CHOOSE, BAG_CHOOSE},
{cvc5::Kind::BAG_IS_SINGLETON, BAG_IS_SINGLETON},
@@ -1947,75 +1950,74 @@ Term Op::getIndexHelper(size_t index) const
{
case DIVISIBLE:
{
- t = d_solver->mkValHelper<Rational>(
+ t = d_solver->mkRationalValHelper(
Rational(d_node->getConst<Divisible>().k));
break;
}
case BITVECTOR_REPEAT:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<BitVectorRepeat>().d_repeatAmount);
break;
}
case BITVECTOR_ZERO_EXTEND:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<BitVectorZeroExtend>().d_zeroExtendAmount);
break;
}
case BITVECTOR_SIGN_EXTEND:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<BitVectorSignExtend>().d_signExtendAmount);
break;
}
case BITVECTOR_ROTATE_LEFT:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<BitVectorRotateLeft>().d_rotateLeftAmount);
break;
}
case BITVECTOR_ROTATE_RIGHT:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<BitVectorRotateRight>().d_rotateRightAmount);
break;
}
case INT_TO_BITVECTOR:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<IntToBitVector>().d_size);
break;
}
case IAND:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
- d_node->getConst<IntAnd>().d_size);
+ t = d_solver->mkRationalValHelper(d_node->getConst<IntAnd>().d_size);
break;
}
case FLOATINGPOINT_TO_UBV:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<FloatingPointToUBV>().d_bv_size.d_size);
break;
}
case FLOATINGPOINT_TO_SBV:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<FloatingPointToSBV>().d_bv_size.d_size);
break;
}
case REGEXP_REPEAT:
{
- t = d_solver->mkValHelper<cvc5::Rational>(
+ t = d_solver->mkRationalValHelper(
d_node->getConst<RegExpRepeat>().d_repeatAmount);
break;
}
case BITVECTOR_EXTRACT:
{
cvc5::BitVectorExtract ext = d_node->getConst<BitVectorExtract>();
- t = index == 0 ? d_solver->mkValHelper<cvc5::Rational>(ext.d_high)
- : d_solver->mkValHelper<cvc5::Rational>(ext.d_low);
+ t = index == 0 ? d_solver->mkRationalValHelper(ext.d_high)
+ : d_solver->mkRationalValHelper(ext.d_low);
break;
}
case FLOATINGPOINT_TO_FP_IEEE_BITVECTOR:
@@ -2023,20 +2025,18 @@ Term Op::getIndexHelper(size_t index) const
cvc5::FloatingPointToFPIEEEBitVector ext =
d_node->getConst<FloatingPointToFPIEEEBitVector>();
- t = index == 0 ? d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().exponentWidth())
- : d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().significandWidth());
+ t = index == 0
+ ? d_solver->mkRationalValHelper(ext.getSize().exponentWidth())
+ : d_solver->mkRationalValHelper(ext.getSize().significandWidth());
break;
}
case FLOATINGPOINT_TO_FP_FLOATINGPOINT:
{
cvc5::FloatingPointToFPFloatingPoint ext =
d_node->getConst<FloatingPointToFPFloatingPoint>();
- t = index == 0 ? d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().exponentWidth())
- : d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().significandWidth());
+ t = index == 0
+ ? d_solver->mkRationalValHelper(ext.getSize().exponentWidth())
+ : d_solver->mkRationalValHelper(ext.getSize().significandWidth());
break;
}
case FLOATINGPOINT_TO_FP_REAL:
@@ -2044,47 +2044,43 @@ Term Op::getIndexHelper(size_t index) const
cvc5::FloatingPointToFPReal ext =
d_node->getConst<FloatingPointToFPReal>();
- t = index == 0 ? d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().exponentWidth())
- : d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().significandWidth());
+ t = index == 0
+ ? d_solver->mkRationalValHelper(ext.getSize().exponentWidth())
+ : d_solver->mkRationalValHelper(ext.getSize().significandWidth());
break;
}
case FLOATINGPOINT_TO_FP_SIGNED_BITVECTOR:
{
cvc5::FloatingPointToFPSignedBitVector ext =
d_node->getConst<FloatingPointToFPSignedBitVector>();
- t = index == 0 ? d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().exponentWidth())
- : d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().significandWidth());
+ t = index == 0
+ ? d_solver->mkRationalValHelper(ext.getSize().exponentWidth())
+ : d_solver->mkRationalValHelper(ext.getSize().significandWidth());
break;
}
case FLOATINGPOINT_TO_FP_UNSIGNED_BITVECTOR:
{
cvc5::FloatingPointToFPUnsignedBitVector ext =
d_node->getConst<FloatingPointToFPUnsignedBitVector>();
- t = index == 0 ? d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().exponentWidth())
- : d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().significandWidth());
+ t = index == 0
+ ? d_solver->mkRationalValHelper(ext.getSize().exponentWidth())
+ : d_solver->mkRationalValHelper(ext.getSize().significandWidth());
break;
}
case FLOATINGPOINT_TO_FP_GENERIC:
{
cvc5::FloatingPointToFPGeneric ext =
d_node->getConst<FloatingPointToFPGeneric>();
- t = index == 0 ? d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().exponentWidth())
- : d_solver->mkValHelper<cvc5::Rational>(
- ext.getSize().significandWidth());
+ t = index == 0
+ ? d_solver->mkRationalValHelper(ext.getSize().exponentWidth())
+ : d_solver->mkRationalValHelper(ext.getSize().significandWidth());
break;
}
case REGEXP_LOOP:
{
cvc5::RegExpLoop ext = d_node->getConst<RegExpLoop>();
- t = index == 0 ? d_solver->mkValHelper<cvc5::Rational>(ext.d_loopMinOcc)
- : d_solver->mkValHelper<cvc5::Rational>(ext.d_loopMaxOcc);
+ t = index == 0 ? d_solver->mkRationalValHelper(ext.d_loopMinOcc)
+ : d_solver->mkRationalValHelper(ext.d_loopMaxOcc);
break;
}
@@ -2093,7 +2089,7 @@ Term Op::getIndexHelper(size_t index) const
{
const std::vector<uint32_t>& projectionIndices =
d_node->getConst<TupleProjectOp>().getIndices();
- t = d_solver->mkValHelper<cvc5::Rational>(projectionIndices[index]);
+ t = d_solver->mkRationalValHelper(projectionIndices[index]);
break;
}
default:
@@ -2535,6 +2531,29 @@ Op Term::getOp() const
CVC5_API_TRY_CATCH_END;
}
+bool Term::hasSymbol() const
+{
+ CVC5_API_TRY_CATCH_BEGIN;
+ CVC5_API_CHECK_NOT_NULL;
+ //////// all checks before this line
+ return d_node->hasAttribute(expr::VarNameAttr());
+ ////////
+ CVC5_API_TRY_CATCH_END;
+}
+
+std::string Term::getSymbol() const
+{
+ CVC5_API_TRY_CATCH_BEGIN;
+ CVC5_API_CHECK_NOT_NULL;
+ CVC5_API_CHECK(d_node->hasAttribute(expr::VarNameAttr()))
+ << "Invalid call to '" << __PRETTY_FUNCTION__
+ << "', expected the term to have a symbol.";
+ //////// all checks before this line
+ return d_node->getAttribute(expr::VarNameAttr());
+ ////////
+ CVC5_API_TRY_CATCH_END;
+}
+
bool Term::isNull() const
{
CVC5_API_TRY_CATCH_BEGIN;
@@ -4694,6 +4713,7 @@ void Grammar::addSygusConstructorVariables(DatatypeDecl& dt,
bool Grammar::containsFreeVariables(const Term& rule) const
{
+ // we allow the argument list and non-terminal symbols to be in scope
std::unordered_set<TNode> scope;
for (const Term& sygusVar : d_sygusVars)
@@ -4706,8 +4726,7 @@ bool Grammar::containsFreeVariables(const Term& rule) const
scope.emplace(*ntsymbol.d_node);
}
- std::unordered_set<Node> fvs;
- return expr::getFreeVariablesScope(*rule.d_node, fvs, scope, false);
+ return expr::hasFreeVariablesScope(*rule.d_node, scope);
}
std::ostream& operator<<(std::ostream& out, const Grammar& grammar)
@@ -5022,6 +5041,14 @@ Term Solver::mkValHelper(T t) const
return Term(this, res);
}
+Term Solver::mkRationalValHelper(const Rational& r) const
+{
+ //////// all checks before this line
+ Node res = getNodeManager()->mkConst(kind::CONST_RATIONAL, r);
+ (void)res.getType(true); /* kick off type checking */
+ return Term(this, res);
+}
+
Term Solver::mkRealFromStrHelper(const std::string& s) const
{
//////// all checks before this line
@@ -5030,7 +5057,7 @@ Term Solver::mkRealFromStrHelper(const std::string& s) const
cvc5::Rational r = s.find('/') != std::string::npos
? cvc5::Rational(s)
: cvc5::Rational::fromDecimal(s);
- return mkValHelper<cvc5::Rational>(r);
+ return mkRationalValHelper(r);
}
catch (const std::invalid_argument& e)
{
@@ -5079,8 +5106,12 @@ Term Solver::mkBVFromStrHelper(uint32_t size,
Term Solver::getValueHelper(const Term& term) const
{
// Note: Term is checked in the caller to avoid double checks
- CVC5_API_RECOVERABLE_CHECK(!expr::hasFreeVar(term.getNode()))
- << "Cannot get value of term containing free variables";
+ bool wasShadow = false;
+ bool freeOrShadowedVar =
+ expr::hasFreeOrShadowedVar(term.getNode(), wasShadow);
+ CVC5_API_RECOVERABLE_CHECK(!freeOrShadowedVar)
+ << "Cannot get value of term containing "
+ << (wasShadow ? "shadowed" : "free") << " variables";
//////// all checks before this line
Node value = d_slv->getValue(*term.d_node);
Term res = Term(this, value);
@@ -5190,7 +5221,7 @@ Term Solver::mkTermHelper(Kind kind, const std::vector<Term>& children) const
// element type can be used safely here.
res = getNodeManager()->mkSingleton(type, *children[0].d_node);
}
- else if (kind == api::MK_BAG)
+ else if (kind == api::BAG_MAKE)
{
// the type of the term is the same as the type of the internal node
// see Term::getSort()
@@ -5324,7 +5355,8 @@ Term Solver::ensureTermSort(const Term& term, const Sort& sort) const
res = Term(this,
d_nodeMgr->mkNode(extToIntKind(DIVISION),
*res.d_node,
- d_nodeMgr->mkConst(cvc5::Rational(1))));
+ d_nodeMgr->mkConst(kind::CONST_RATIONAL,
+ cvc5::Rational(1))));
}
Assert(res.getSort() == sort);
return res;
@@ -5754,7 +5786,7 @@ Term Solver::mkInteger(int64_t val) const
{
CVC5_API_TRY_CATCH_BEGIN;
//////// all checks before this line
- Term integer = mkValHelper<cvc5::Rational>(cvc5::Rational(val));
+ Term integer = mkRationalValHelper(cvc5::Rational(val));
Assert(integer.getSort() == getIntegerSort());
return integer;
////////
@@ -5780,7 +5812,7 @@ Term Solver::mkReal(int64_t val) const
{
CVC5_API_TRY_CATCH_BEGIN;
//////// all checks before this line
- Term rational = mkValHelper<cvc5::Rational>(cvc5::Rational(val));
+ Term rational = mkRationalValHelper(cvc5::Rational(val));
return ensureRealSort(rational);
////////
CVC5_API_TRY_CATCH_END;
@@ -5790,12 +5822,25 @@ Term Solver::mkReal(int64_t num, int64_t den) const
{
CVC5_API_TRY_CATCH_BEGIN;
//////// all checks before this line
- Term rational = mkValHelper<cvc5::Rational>(cvc5::Rational(num, den));
+ Term rational = mkRationalValHelper(cvc5::Rational(num, den));
return ensureRealSort(rational);
////////
CVC5_API_TRY_CATCH_END;
}
+Term Solver::mkRegexpAll() const
+{
+ CVC5_API_TRY_CATCH_BEGIN;
+ //////// all checks before this line
+ Node res = d_nodeMgr->mkNode(
+ cvc5::kind::REGEXP_STAR,
+ d_nodeMgr->mkNode(cvc5::kind::REGEXP_ALLCHAR, std::vector<cvc5::Node>()));
+ (void)res.getType(true); /* kick off type checking */
+ return Term(this, res);
+ ////////
+ CVC5_API_TRY_CATCH_END;
+}
+
Term Solver::mkRegexpNone() const
{
CVC5_API_TRY_CATCH_BEGIN;
diff --git a/src/api/cpp/cvc5.h b/src/api/cpp/cvc5.h
index 5b0cc0b45..ad6f4c7df 100644
--- a/src/api/cpp/cvc5.h
+++ b/src/api/cpp/cvc5.h
@@ -48,6 +48,7 @@ class SolverEngine;
class TypeNode;
class Options;
class Random;
+class Rational;
class Result;
class StatisticsRegistry;
@@ -1128,6 +1129,17 @@ class CVC5_EXPORT Term
Op getOp() const;
/**
+ * @return true if the term has a symbol.
+ */
+ bool hasSymbol() const;
+
+ /**
+ * Asserts hasSymbol().
+ * @return the raw symbol of the term.
+ */
+ std::string getSymbol() const;
+
+ /**
* @return true if this Term is a null term
*/
bool isNull() const;
@@ -2648,19 +2660,19 @@ enum RoundingMode
ROUND_NEAREST_TIES_TO_EVEN,
/**
* Round towards positive infinity (+oo).
- * The result shall be the format’s floating-point number (possibly +oo)
+ * The result shall be the format's floating-point number (possibly +oo)
* closest to and no less than the infinitely precise result.
*/
ROUND_TOWARD_POSITIVE,
/**
* Round towards negative infinity (-oo).
- * The result shall be the format’s floating-point number (possibly -oo)
+ * The result shall be the format's floating-point number (possibly -oo)
* closest to and no less than the infinitely precise result.
*/
ROUND_TOWARD_NEGATIVE,
/**
* Round towards zero.
- * The result shall be the format’s floating-point number closest to and no
+ * The result shall be the format's floating-point number closest to and no
* greater in magnitude than the infinitely precise result.
*/
ROUND_TOWARD_ZERO,
@@ -3443,18 +3455,24 @@ class CVC5_EXPORT Solver
Term mkReal(int64_t num, int64_t den) const;
/**
- * Create a regular expression none (re.none) term.
- * @return the empty term
+ * Create a regular expression all (re.all) term.
+ * @return the all term
*/
- Term mkRegexpNone() const;
+ Term mkRegexpAll() const;
/**
* Create a regular expression allchar (re.allchar) term.
- * @return the sigma term
+ * @return the allchar term
*/
Term mkRegexpAllchar() const;
/**
+ * Create a regular expression none (re.none) term.
+ * @return the none term
+ */
+ Term mkRegexpNone() const;
+
+ /**
* Create a constant representing an empty set of the given sort.
* @param sort the sort of the set elements.
* @return the empty set constant
@@ -4487,6 +4505,8 @@ class CVC5_EXPORT Solver
/** Helper for mk-functions that call d_nodeMgr->mkConst(). */
template <typename T>
Term mkValHelper(T t) const;
+ /** Helper for making rational values. */
+ Term mkRationalValHelper(const Rational& r) const;
/** Helper for mkReal functions that take a string as argument. */
Term mkRealFromStrHelper(const std::string& s) const;
/** Helper for mkBitVector functions that take a string as argument. */
diff --git a/src/api/cpp/cvc5_kind.h b/src/api/cpp/cvc5_kind.h
index 162ec24e7..29cb130d4 100644
--- a/src/api/cpp/cvc5_kind.h
+++ b/src/api/cpp/cvc5_kind.h
@@ -331,10 +331,6 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
CARDINALITY_CONSTRAINT,
-#if 0
- /* Partial uninterpreted function application. */
- PARTIAL_APPLY_UF,
-#endif
/**
* Higher-order applicative encoding of function application, left
* associative.
@@ -2139,7 +2135,7 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child1, const Term& child2) const`
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
- SET_INTERSECTION,
+ SET_INTER,
/**
* Set subtraction.
*
@@ -2256,9 +2252,9 @@ enum Kind : int32_t
SET_COMPREHENSION,
/**
* Returns an element from a given set.
- * If a set A = {x}, then the term (choose A) is equivalent to the term x.
- * If the set is empty, then (choose A) is an arbitrary value.
- * If the set has cardinality > 1, then (choose A) will deterministically
+ * If a set A = {x}, then the term (set.choose A) is equivalent to the term x.
+ * If the set is empty, then (set.choose A) is an arbitrary value.
+ * If the set has cardinality > 1, then (set.choose A) will deterministically
* return an element in A.
*
* Parameters:
@@ -2278,6 +2274,21 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child) const`
*/
SET_IS_SINGLETON,
+ /**
+ * set.map operator applies the first argument, a function of type (-> T1 T2),
+ * to every element of the second argument, a set of type (Set T1),
+ * and returns a set of type (Set T2).
+ *
+ * Parameters:
+ * - 1: a function of type (-> T1 T2)
+ * - 2: a set of type (Set T1)
+ *
+ * Create with:
+ * - `Solver::mkTerm(Kind kind, const Term& child1, const Term& child2)
+ * const`
+ * - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
+ */
+ SET_MAP,
/* Relations ------------------------------------------------------------- */
@@ -2356,7 +2367,7 @@ enum Kind : int32_t
* Create with:
* mkEmptyBag(const Sort& sort)
*/
- EMPTYBAG,
+ BAG_EMPTY,
/**
* Bag max union.
* Parameters:
@@ -2366,7 +2377,7 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child1, const Term& child2) const`
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
- UNION_MAX,
+ BAG_UNION_MAX,
/**
* Bag disjoint union (sum).
*
@@ -2377,7 +2388,7 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child1, const Term& child2) const`
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
- UNION_DISJOINT,
+ BAG_UNION_DISJOINT,
/**
* Bag intersection (min).
*
@@ -2388,7 +2399,7 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child1, const Term& child2) const`
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
- INTERSECTION_MIN,
+ BAG_INTER_MIN,
/**
* Bag difference subtract (subtracts multiplicities of the second from the
* first).
@@ -2400,7 +2411,7 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child1, const Term& child2) const`
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
- DIFFERENCE_SUBTRACT,
+ BAG_DIFFERENCE_SUBTRACT,
/**
* Bag difference 2 (removes shared elements in the two bags).
*
@@ -2411,7 +2422,7 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child1, const Term& child2) const`
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
- DIFFERENCE_REMOVE,
+ BAG_DIFFERENCE_REMOVE,
/**
* Inclusion predicate for bags
* (multiplicities of the first bag <= multiplicities of the second bag).
@@ -2423,7 +2434,7 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child1, const Term& child2) const`
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
- SUBBAG,
+ BAG_SUBBAG,
/**
* Element multiplicity in a bag
*
@@ -2446,7 +2457,7 @@ enum Kind : int32_t
* - `Solver::mkTerm(Kind kind, const Term& child) const`
* - `Solver::mkTerm(Kind kind, const std::vector<Term>& children) const`
*/
- DUPLICATE_REMOVAL,
+ BAG_DUPLICATE_REMOVAL,
/**
* The bag of the single element given as a parameter.
*
@@ -2456,7 +2467,7 @@ enum Kind : int32_t
* Create with:
* - `Solver::mkTerm(Kind kind, const Term& child) const`
*/
- MK_BAG,
+ BAG_MAKE,
/**
* Bag cardinality.
*
diff --git a/src/api/java/CMakeLists.txt b/src/api/java/CMakeLists.txt
index 58f9ee4b5..ecfec2109 100644
--- a/src/api/java/CMakeLists.txt
+++ b/src/api/java/CMakeLists.txt
@@ -140,6 +140,5 @@ add_jar(cvc5jar
VERSION ${CVC5_VERSION}
OUTPUT_NAME cvc5
)
-set_target_properties(cvc5jar PROPERTIES SOURCES "${JAVA_FILES}")
add_dependencies(cvc5jar generate-java-kinds cvc5jni cvc5)
diff --git a/src/api/java/genkinds.py.in b/src/api/java/genkinds.py.in
index a15472a1a..d44ae3c0d 100644
--- a/src/api/java/genkinds.py.in
+++ b/src/api/java/genkinds.py.in
@@ -97,7 +97,12 @@ CPP_JAVA_MAPPING = \
r"std::vector<Term>": "Term[]",
r"std::string": "String",
r"&": "",
- r"::": "."
+ r"::": ".",
+ r">": "&gt;",
+ r"<": "&lt;",
+ r"@f\[": "",
+ r"@f\]": "",
+ r"@note": "",
}
diff --git a/src/api/java/io/github/cvc5/api/RoundingMode.java b/src/api/java/io/github/cvc5/api/RoundingMode.java
index ecc01c342..6a3c274a1 100644
--- a/src/api/java/io/github/cvc5/api/RoundingMode.java
+++ b/src/api/java/io/github/cvc5/api/RoundingMode.java
@@ -25,19 +25,19 @@ public enum RoundingMode {
ROUND_NEAREST_TIES_TO_EVEN(0),
/**
* Round towards positive infinity (+oo).
- * The result shall be the format’s floating-point number (possibly +oo)
+ * The result shall be the format's floating-point number (possibly +oo)
* closest to and no less than the infinitely precise result.
*/
ROUND_TOWARD_POSITIVE(1),
/**
* Round towards negative infinity (-oo).
- * The result shall be the format’s floating-point number (possibly -oo)
+ * The result shall be the format's floating-point number (possibly -oo)
* closest to and no less than the infinitely precise result.
*/
ROUND_TOWARD_NEGATIVE(2),
/**
* Round towards zero.
- * The result shall be the format’s floating-point number closest to and no
+ * The result shall be the format's floating-point number closest to and no
* greater in magnitude than the infinitely precise result.
*/
ROUND_TOWARD_ZERO(3),
diff --git a/src/api/java/io/github/cvc5/api/Solver.java b/src/api/java/io/github/cvc5/api/Solver.java
index 09ad66f5b..16220228c 100644
--- a/src/api/java/io/github/cvc5/api/Solver.java
+++ b/src/api/java/io/github/cvc5/api/Solver.java
@@ -851,8 +851,8 @@ public class Solver implements IPointer, AutoCloseable
private native long mkReal(long pointer, long num, long den);
/**
- * Create a regular expression empty term.
- * @return the empty term
+ * Create a regular expression none (re.none) term.
+ * @return the none term
*/
public Term mkRegexpNone()
{
@@ -863,8 +863,20 @@ public class Solver implements IPointer, AutoCloseable
private native long mkRegexpNone(long pointer);
/**
- * Create a regular expression sigma term.
- * @return the sigma term
+ * Create a regular expression all (re.all) term.
+ * @return the all term
+ */
+ public Term mkRegexpAll()
+ {
+ long termPointer = mkRegexpAll(pointer);
+ return new Term(this, termPointer);
+ }
+
+ private native long mkRegexpAll(long pointer);
+
+ /**
+ * Create a regular expression allchar (re.allchar) term.
+ * @return the allchar term
*/
public Term mkRegexpAllchar()
{
diff --git a/src/api/java/io/github/cvc5/api/Term.java b/src/api/java/io/github/cvc5/api/Term.java
index bbed609f7..fc09767ed 100644
--- a/src/api/java/io/github/cvc5/api/Term.java
+++ b/src/api/java/io/github/cvc5/api/Term.java
@@ -201,6 +201,27 @@ public class Term extends AbstractPointer implements Comparable<Term>, Iterable<
private native long getOp(long pointer);
/**
+ * @return true if the term has a symbol.
+ */
+ public boolean hasSymbol()
+ {
+ return hasSymbol(pointer);
+ }
+
+ private native boolean hasSymbol(long pointer);
+
+ /**
+ * Asserts hasSymbol().
+ * @return the raw symbol of the term.
+ */
+ public String getSymbol()
+ {
+ return getSymbol(pointer);
+ }
+
+ private native String getSymbol(long pointer);
+
+ /**
* @return true if this Term is a null term
*/
public boolean isNull()
diff --git a/src/api/java/jni/solver.cpp b/src/api/java/jni/solver.cpp
index a3ce49f4e..2e4404362 100644
--- a/src/api/java/jni/solver.cpp
+++ b/src/api/java/jni/solver.cpp
@@ -992,6 +992,21 @@ JNIEXPORT jlong JNICALL Java_io_github_cvc5_api_Solver_mkRegexpNone(
/*
* Class: io_github_cvc5_api_Solver
+ * Method: mkRegexpAll
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL
+Java_io_github_cvc5_api_Solver_mkRegexpAll(JNIEnv* env, jobject, jlong pointer)
+{
+ CVC5_JAVA_API_TRY_CATCH_BEGIN;
+ Solver* solver = reinterpret_cast<Solver*>(pointer);
+ Term* retPointer = new Term(solver->mkRegexpAll());
+ return reinterpret_cast<jlong>(retPointer);
+ CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, 0);
+}
+
+/*
+ * Class: io_github_cvc5_api_Solver
* Method: mkRegexpAllchar
* Signature: (J)J
*/
diff --git a/src/api/java/jni/term.cpp b/src/api/java/jni/term.cpp
index d54b0a2b5..702a5064d 100644
--- a/src/api/java/jni/term.cpp
+++ b/src/api/java/jni/term.cpp
@@ -247,6 +247,36 @@ JNIEXPORT jlong JNICALL Java_io_github_cvc5_api_Term_getOp(JNIEnv* env,
/*
* Class: io_github_cvc5_api_Term
+ * Method: hasSymbol
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_io_github_cvc5_api_Term_hasSymbol(JNIEnv* env,
+ jobject,
+ jlong pointer)
+{
+ CVC5_JAVA_API_TRY_CATCH_BEGIN;
+ Term* current = reinterpret_cast<Term*>(pointer);
+ return static_cast<jboolean>(current->hasSymbol());
+ CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, static_cast<jboolean>(false));
+}
+
+/*
+ * Class: io_github_cvc5_api_Term
+ * Method: getSymbol
+ * Signature: (J)Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_io_github_cvc5_api_Term_getSymbol(JNIEnv* env,
+ jobject,
+ jlong pointer)
+{
+ CVC5_JAVA_API_TRY_CATCH_BEGIN;
+ Term* current = reinterpret_cast<Term*>(pointer);
+ return env->NewStringUTF(current->getSymbol().c_str());
+ CVC5_JAVA_API_TRY_CATCH_END_RETURN(env, nullptr);
+}
+
+/*
+ * Class: io_github_cvc5_api_Term
* Method: isNull
* Signature: (J)Z
*/
diff --git a/src/api/python/cvc5.pxd b/src/api/python/cvc5.pxd
index baee5899e..f5dc2aca2 100644
--- a/src/api/python/cvc5.pxd
+++ b/src/api/python/cvc5.pxd
@@ -215,8 +215,9 @@ cdef extern from "api/cpp/cvc5.h" namespace "cvc5::api":
Term mkInteger(const uint64_t i) except +
Term mkInteger(const string& s) except +
Term mkReal(const string& s) except +
- Term mkRegexpNone() except +
+ Term mkRegexpAll() except +
Term mkRegexpAllchar() except +
+ Term mkRegexpNone() except +
Term mkEmptySet(Sort s) except +
Term mkEmptyBag(Sort s) except +
Term mkSepEmp() except +
@@ -390,6 +391,8 @@ cdef extern from "api/cpp/cvc5.h" namespace "cvc5::api":
Term substitute(const vector[Term] & es, const vector[Term] & reps) except +
bint hasOp() except +
Op getOp() except +
+ bint hasSymbol() except +
+ string getSymbol() except +
bint isNull() except +
Term getConstArrayBase() except +
Term notTerm() except +
diff --git a/src/api/python/cvc5.pxi b/src/api/python/cvc5.pxi
index 9e1aeaca1..3d24b5dbd 100644
--- a/src/api/python/cvc5.pxi
+++ b/src/api/python/cvc5.pxi
@@ -1130,24 +1130,33 @@ cdef class Solver:
term.cterm = self.csolver.mkReal("{}/{}".format(val, den).encode())
return term
- def mkRegexpNone(self):
- """Create a regular expression empty term.
+ def mkRegexpAll(self):
+ """Create a regular expression all (re.all) term.
- :return: the empty term
+ :return: the all term
"""
cdef Term term = Term(self)
- term.cterm = self.csolver.mkRegexpNone()
+ term.cterm = self.csolver.mkRegexpAll()
return term
def mkRegexpAllchar(self):
- """Create a regular expression sigma term.
+ """Create a regular expression allchar (re.allchar) term.
- :return: the sigma term
+ :return: the allchar term
"""
cdef Term term = Term(self)
term.cterm = self.csolver.mkRegexpAllchar()
return term
+ def mkRegexpNone(self):
+ """Create a regular expression none (re.none) term.
+
+ :return: the none term
+ """
+ cdef Term term = Term(self)
+ term.cterm = self.csolver.mkRegexpNone()
+ return term
+
def mkEmptySet(self, Sort s):
"""Create a constant representing an empty set of the given sort.
@@ -2830,6 +2839,12 @@ cdef class Term:
op.cop = self.cterm.getOp()
return op
+ def hasSymbol(self):
+ return self.cterm.hasSymbol()
+
+ def getSymbol(self):
+ return self.cterm.getSymbol().decode()
+
def isNull(self):
return self.cterm.isNull()
diff --git a/src/expr/bound_var_manager.cpp b/src/expr/bound_var_manager.cpp
index 820c82d22..53c87fb97 100644
--- a/src/expr/bound_var_manager.cpp
+++ b/src/expr/bound_var_manager.cpp
@@ -18,6 +18,8 @@
#include "expr/node_manager_attributes.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
BoundVarManager::BoundVarManager() : d_keepCacheVals(false) {}
@@ -51,7 +53,7 @@ Node BoundVarManager::getCacheValue(TNode cv1, TNode cv2, size_t i)
Node BoundVarManager::getCacheValue(size_t i)
{
- return NodeManager::currentNM()->mkConst(Rational(i));
+ return NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(i));
}
Node BoundVarManager::getCacheValue(TNode cv, size_t i)
diff --git a/src/expr/dtype.cpp b/src/expr/dtype.cpp
index 4a0ed994f..a5719a7ff 100644
--- a/src/expr/dtype.cpp
+++ b/src/expr/dtype.cpp
@@ -866,7 +866,7 @@ Node DType::getSharedSelector(TypeNode dtt, TypeNode t, size_t index) const
ss << "sel_" << index;
SkolemManager* sm = nm->getSkolemManager();
TypeNode stype = nm->mkSelectorType(dtt, t);
- Node nindex = nm->mkConst(Rational(index));
+ Node nindex = nm->mkConst(CONST_RATIONAL, Rational(index));
s = sm->mkSkolemFunction(SkolemFunId::SHARED_SELECTOR, stype, nindex);
d_sharedSel[dtt][t][index] = s;
Trace("dt-shared-sel") << "Made " << s << " of type " << dtt << " -> " << t
diff --git a/src/expr/mkmetakind b/src/expr/mkmetakind
index f9b49fc0a..e651de433 100755
--- a/src/expr/mkmetakind
+++ b/src/expr/mkmetakind
@@ -57,6 +57,18 @@ metakind_operatorKinds=
seen_theory=false
seen_theory_builtin=false
+payloads_seen=()
+
+function contains {
+ elem=$1
+ shift
+ arr=("$@")
+ for e in "${arr[@]}"; do
+ [[ "$e" == "$elem" ]] && return 0
+ done
+ return 1
+}
+
function theory {
# theory ID T header
@@ -213,9 +225,25 @@ function constant {
echo "$kf:$lineno: warning: constant $1 hasher \`$4' isn't fully-qualified (e.g., ::cvc5::RationalHashFunction)" >&2
fi
+ if [[ "$3" =~ '+'$ ]]; then
+ # Remove last character
+ class="${3%?}"
+ skip_const_map=true
+ else
+ class="$3"
+ skip_const_map=false
+ fi
+
+ if contains "${class}" "${payloads_seen[@]}"; then
+ payload_seen=true
+ else
+ payload_seen=false
+ payloads_seen=(${payloads_seen[@]} "${class}")
+ fi
+
if [[ "$2" != "skip" ]]; then
metakind_fwd_decls="${metakind_fwd_decls}
-$2 $3;"
+$2 ${class};"
fi
# Avoid including the same header multiple times
@@ -224,62 +252,71 @@ $2 $3;"
#include \"$5\""
fi
register_metakind CONSTANT "$1" 0
- metakind_getConst_decls="${metakind_getConst_decls}
+
+ if [[ "${payload_seen}" != true ]]; then
+ metakind_getConst_decls="${metakind_getConst_decls}
template <>
-$3 const& NodeValue::getConst< $3 >() const;
+${class} const& NodeValue::getConst< ${class} >() const;
"
- metakind_constantMaps_decls="${metakind_constantMaps_decls}
-template <>
-struct ConstantMap< $3 > {
- // typedef $theory_class OwningTheory;
- enum { kind = ::cvc5::kind::$1 };
-};/* ConstantMap< $3 > */
-template <>
-struct ConstantMapReverse< ::cvc5::kind::$1 > {
- typedef $3 T;
-};/* ConstantMapReverse< ::cvc5::kind::$1 > */
- "
- metakind_constantMaps="${metakind_constantMaps}
-// The reinterpret_cast of d_children to \"$3 const*\"
+ metakind_constantMaps="${metakind_constantMaps}
+// The reinterpret_cast of d_children to \"${class} const*\"
// flags a \"strict aliasing\" warning; it's okay, because we never access
// the embedded constant as a NodeValue* child, and never access an embedded
// NodeValue* child as a constant.
#pragma GCC diagnostic ignored \"-Wstrict-aliasing\"
template <>
-$3 const& NodeValue::getConst< $3 >() const {
+${class} const& NodeValue::getConst< ${class} >() const {
AssertArgument(getKind() == ::cvc5::kind::$1, *this,
- \"Improper kind for getConst<$3>()\");
+ \"Improper kind for getConst<${class}>()\");
// To support non-inlined CONSTANT-kinded NodeValues (those that are
// \"constructed\" when initially checking them against the NodeManager
// pool), we must check d_nchildren here.
return d_nchildren == 0
- ? *reinterpret_cast< $3 const* >(d_children)
- : *reinterpret_cast< $3 const* >(d_children[0]);
+ ? *reinterpret_cast< ${class} const* >(d_children)
+ : *reinterpret_cast< ${class} const* >(d_children[0]);
}
// re-enable the warning
#pragma GCC diagnostic warning \"-Wstrict-aliasing\"
"
+ fi
+
+ if [ "${skip_const_map}" != true ]; then
+ metakind_constantMaps_decls="${metakind_constantMaps_decls}
+template <>
+struct ConstantMap< ${class} > {
+ static constexpr Kind kind = ::cvc5::kind::$1;
+};/* ConstantMap< ${class} > */
+"
+ fi
+
+ metakind_constantMaps_decls="${metakind_constantMaps_decls}
+template <>
+struct ConstantMapReverse< ::cvc5::kind::$1 > {
+ using T = ${class};
+};/* ConstantMapReverse< ::cvc5::kind::$1 > */
+"
+
metakind_compares="${metakind_compares}
case kind::$1:
return NodeValueConstCompare< kind::$1, pool >::compare(nv1, nv2);
"
metakind_constHashes="${metakind_constHashes}
case kind::$1:
- return $4()(nv->getConst< $3 >());
+ return $4()(nv->getConst< ${class} >());
"
metakind_constPrinters="${metakind_constPrinters}
case kind::$1:
- out << nv->getConst< $3 >();
+ out << nv->getConst< ${class} >();
break;
"
- cname=`echo "$3" | awk 'BEGIN {FS="::"} {print$NF}'`
+ cname=`echo "${class}" | awk 'BEGIN {FS="::"} {print$NF}'`
metakind_constDeleters="${metakind_constDeleters}
case kind::$1:
- std::destroy_at(reinterpret_cast< $3* >(nv->d_children));
+ std::destroy_at(reinterpret_cast< ${class}* >(nv->d_children));
break;
"
}
diff --git a/src/expr/nary_term_util.cpp b/src/expr/nary_term_util.cpp
index 4071e0d0e..a872c64c7 100644
--- a/src/expr/nary_term_util.cpp
+++ b/src/expr/nary_term_util.cpp
@@ -119,9 +119,11 @@ Node getNullTerminator(Kind k, TypeNode tn)
case OR: nullTerm = nm->mkConst(false); break;
case AND:
case SEP_STAR: nullTerm = nm->mkConst(true); break;
- case PLUS: nullTerm = nm->mkConst(Rational(0)); break;
+ case PLUS: nullTerm = nm->mkConst(CONST_RATIONAL, Rational(0)); break;
case MULT:
- case NONLINEAR_MULT: nullTerm = nm->mkConst(Rational(1)); break;
+ case NONLINEAR_MULT:
+ nullTerm = nm->mkConst(CONST_RATIONAL, Rational(1));
+ break;
case STRING_CONCAT:
// handles strings and sequences
nullTerm = theory::strings::Word::mkEmptyWord(tn);
diff --git a/src/expr/node_algorithm.cpp b/src/expr/node_algorithm.cpp
index 13265db71..badf0b75a 100644
--- a/src/expr/node_algorithm.cpp
+++ b/src/expr/node_algorithm.cpp
@@ -281,64 +281,32 @@ bool hasBoundVar(TNode n)
return n.getAttribute(HasBoundVarAttr());
}
-bool hasFreeVar(TNode n)
-{
- // optimization for variables and constants
- if (n.getNumChildren() == 0)
- {
- return n.getKind() == kind::BOUND_VARIABLE;
- }
- std::unordered_set<Node> fvs;
- return getFreeVariables(n, fvs, false);
-}
-
-struct HasClosureTag
-{
-};
-struct HasClosureComputedTag
-{
-};
-/** Attribute true for expressions with closures in them */
-typedef expr::Attribute<HasClosureTag, bool> HasClosureAttr;
-typedef expr::Attribute<HasClosureComputedTag, bool> HasClosureComputedAttr;
-
-bool hasClosure(Node n)
-{
- if (!n.getAttribute(HasClosureComputedAttr()))
- {
- bool hasC = false;
- if (n.isClosure())
- {
- hasC = true;
- }
- else
- {
- for (auto i = n.begin(); i != n.end() && !hasC; ++i)
- {
- hasC = hasClosure(*i);
- }
- }
- if (!hasC && n.hasOperator())
- {
- hasC = hasClosure(n.getOperator());
- }
- n.setAttribute(HasClosureAttr(), hasC);
- n.setAttribute(HasClosureComputedAttr(), true);
- return hasC;
- }
- return n.getAttribute(HasClosureAttr());
-}
-
-bool getFreeVariables(TNode n, std::unordered_set<Node>& fvs, bool computeFv)
-{
- std::unordered_set<TNode> scope;
- return getFreeVariablesScope(n, fvs, scope, computeFv);
-}
-
-bool getFreeVariablesScope(TNode n,
- std::unordered_set<Node>& fvs,
- std::unordered_set<TNode>& scope,
- bool computeFv)
+/**
+ * Check variables internal, which is used as a helper to implement many of the
+ * methods in this file.
+ *
+ * This computes the free variables in n, that is, the subterms of n of kind
+ * BOUND_VARIABLE that are not bound in n or occur in scope, adds these to fvs
+ * if computeFv is true.
+ *
+ * @param n The node under investigation
+ * @param fvs The set which free variables are added to
+ * @param scope The scope we are considering.
+ * @param wasShadow Flag set to true if variable shadowing was encountered.
+ * Only computed if checkShadow is true.
+ * @param computeFv If this flag is false, then we only return true/false and
+ * do not add to fvs.
+ * @param checkShadow If this flag is true, we immediately return true if a
+ * variable is shadowing. If this flag is false, we give an assertion failure
+ * when this occurs.
+ * @return true iff this node contains a free variable.
+ */
+bool checkVariablesInternal(TNode n,
+ std::unordered_set<Node>& fvs,
+ std::unordered_set<TNode>& scope,
+ bool& wasShadow,
+ bool computeFv = true,
+ bool checkShadow = false)
{
std::unordered_set<TNode> visited;
std::vector<TNode> visit;
@@ -376,13 +344,26 @@ bool getFreeVariablesScope(TNode n,
// add to scope
for (const TNode& cn : cur[0])
{
- // should not shadow
- Assert(scope.find(cn) == scope.end())
- << "Shadowed variable " << cn << " in " << cur << "\n";
+ if (checkShadow)
+ {
+ if (scope.find(cn) != scope.end())
+ {
+ wasShadow = true;
+ return true;
+ }
+ }
+ else
+ {
+ // should not shadow
+ Assert(scope.find(cn) == scope.end())
+ << "Shadowed variable " << cn << " in " << cur << "\n";
+ }
scope.insert(cn);
}
// must make recursive call to use separate cache
- if (getFreeVariablesScope(cur[1], fvs, scope, computeFv) && !computeFv)
+ if (checkVariablesInternal(
+ cur[1], fvs, scope, wasShadow, computeFv, checkShadow)
+ && !computeFv)
{
return true;
}
@@ -406,6 +387,95 @@ bool getFreeVariablesScope(TNode n,
return !fvs.empty();
}
+/** Same as above, without checking for shadowing */
+bool getVariablesInternal(TNode n,
+ std::unordered_set<Node>& fvs,
+ std::unordered_set<TNode>& scope,
+ bool computeFv = true)
+{
+ bool wasShadow = false;
+ return checkVariablesInternal(n, fvs, scope, wasShadow, computeFv, false);
+}
+
+bool hasFreeVar(TNode n)
+{
+ // optimization for variables and constants
+ if (n.getNumChildren() == 0)
+ {
+ return n.getKind() == kind::BOUND_VARIABLE;
+ }
+ std::unordered_set<Node> fvs;
+ std::unordered_set<TNode> scope;
+ return getVariablesInternal(n, fvs, scope, false);
+}
+
+bool hasFreeOrShadowedVar(TNode n, bool& wasShadow)
+{
+ // optimization for variables and constants
+ if (n.getNumChildren() == 0)
+ {
+ return n.getKind() == kind::BOUND_VARIABLE;
+ }
+ std::unordered_set<Node> fvs;
+ std::unordered_set<TNode> scope;
+ return checkVariablesInternal(n, fvs, scope, wasShadow, false, true);
+}
+
+struct HasClosureTag
+{
+};
+struct HasClosureComputedTag
+{
+};
+/** Attribute true for expressions with closures in them */
+typedef expr::Attribute<HasClosureTag, bool> HasClosureAttr;
+typedef expr::Attribute<HasClosureComputedTag, bool> HasClosureComputedAttr;
+
+bool hasClosure(Node n)
+{
+ if (!n.getAttribute(HasClosureComputedAttr()))
+ {
+ bool hasC = false;
+ if (n.isClosure())
+ {
+ hasC = true;
+ }
+ else
+ {
+ for (auto i = n.begin(); i != n.end() && !hasC; ++i)
+ {
+ hasC = hasClosure(*i);
+ }
+ }
+ if (!hasC && n.hasOperator())
+ {
+ hasC = hasClosure(n.getOperator());
+ }
+ n.setAttribute(HasClosureAttr(), hasC);
+ n.setAttribute(HasClosureComputedAttr(), true);
+ return hasC;
+ }
+ return n.getAttribute(HasClosureAttr());
+}
+
+bool getFreeVariables(TNode n, std::unordered_set<Node>& fvs)
+{
+ std::unordered_set<TNode> scope;
+ return getVariablesInternal(n, fvs, scope);
+}
+
+bool getFreeVariablesScope(TNode n,
+ std::unordered_set<Node>& fvs,
+ std::unordered_set<TNode>& scope)
+{
+ return getVariablesInternal(n, fvs, scope);
+}
+bool hasFreeVariablesScope(TNode n, std::unordered_set<TNode>& scope)
+{
+ std::unordered_set<Node> fvs;
+ return getVariablesInternal(n, fvs, scope, false);
+}
+
bool getVariables(TNode n, std::unordered_set<TNode>& vs)
{
std::unordered_set<TNode> visited;
diff --git a/src/expr/node_algorithm.h b/src/expr/node_algorithm.h
index 72ea03176..c3ee4b604 100644
--- a/src/expr/node_algorithm.h
+++ b/src/expr/node_algorithm.h
@@ -85,6 +85,16 @@ bool hasBoundVar(TNode n);
bool hasFreeVar(TNode n);
/**
+ * Returns true iff the node n contains a free variable, that is, a node
+ * of kind BOUND_VARIABLE that is not bound in n, or a BOUND_VARIABLE that
+ * is shadowed (e.g. it is bound twice in the same context).
+ * @param n The node under investigation
+ * @param wasShadow Set to true if n had a shadowed variable.
+ * @return true iff this node contains a free or shadowed variable.
+ */
+bool hasFreeOrShadowedVar(TNode n, bool& wasShadow);
+
+/**
* Returns true iff the node n contains a closure, that is, a node
* whose kind is FORALL, EXISTS, WITNESS, LAMBDA, or any other closure currently
* supported.
@@ -98,27 +108,27 @@ bool hasClosure(Node n);
* BOUND_VARIABLE that are not bound in n, adds these to fvs.
* @param n The node under investigation
* @param fvs The set which free variables are added to
- * @param computeFv If this flag is false, then we only return true/false and
- * do not add to fvs.
* @return true iff this node contains a free variable.
*/
-bool getFreeVariables(TNode n,
- std::unordered_set<Node>& fvs,
- bool computeFv = true);
+bool getFreeVariables(TNode n, std::unordered_set<Node>& fvs);
/**
* Get the free variables in n, that is, the subterms of n of kind
* BOUND_VARIABLE that are not bound in n or occur in scope, adds these to fvs.
* @param n The node under investigation
* @param fvs The set which free variables are added to
* @param scope The scope we are considering.
- * @param computeFv If this flag is false, then we only return true/false and
- * do not add to fvs.
* @return true iff this node contains a free variable.
*/
bool getFreeVariablesScope(TNode n,
std::unordered_set<Node>& fvs,
- std::unordered_set<TNode>& scope,
- bool computeFv = true);
+ std::unordered_set<TNode>& scope);
+/**
+ * Return true if n has any free variables in the given scope.
+ * @param n The node under investigation
+ * @param scope The scope we are considering.
+ * @return true iff this node contains a free variable.
+ */
+bool hasFreeVariablesScope(TNode n, std::unordered_set<TNode>& scope);
/**
* Get all variables in n.
diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp
index 6f614e927..62c718245 100644
--- a/src/expr/node_manager.cpp
+++ b/src/expr/node_manager.cpp
@@ -30,7 +30,7 @@
#include "expr/node_manager_attributes.h"
#include "expr/skolem_manager.h"
#include "expr/type_checker.h"
-#include "theory/bags/make_bag_op.h"
+#include "theory/bags/bag_make_op.h"
#include "theory/sets/singleton_op.h"
#include "util/abstract_value.h"
#include "util/bitvector.h"
@@ -1044,8 +1044,8 @@ Node NodeManager::mkBag(const TypeNode& t, const TNode n, const TNode m)
<< "Invalid operands for mkBag. The type '" << n.getType()
<< "' of node '" << n << "' is not a subtype of '" << t << "'."
<< std::endl;
- Node op = mkConst(MakeBagOp(t));
- Node bag = mkNode(kind::MK_BAG, op, n, m);
+ Node op = mkConst(BagMakeOp(t));
+ Node bag = mkNode(kind::BAG_MAKE, op, n, m);
return bag;
}
diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h
index 1208a0e03..d301c857c 100644
--- a/src/expr/node_manager.h
+++ b/src/expr/node_manager.h
@@ -522,11 +522,17 @@ class NodeManager
template <class T>
Node mkConst(const T&);
+ /**
+ * Create a constant of type `T` with an explicit kind `k`.
+ */
+ template <class T>
+ Node mkConst(Kind k, const T&);
+
template <class T>
TypeNode mkTypeConst(const T&);
template <class NodeClass, class T>
- NodeClass mkConstInternal(const T&);
+ NodeClass mkConstInternal(Kind k, const T&);
/** Create a node with children. */
TypeNode mkTypeNode(Kind kind, TypeNode child1);
@@ -1187,22 +1193,29 @@ inline TypeNode NodeManager::mkTypeNode(Kind kind,
template <class T>
Node NodeManager::mkConst(const T& val) {
- return mkConstInternal<Node, T>(val);
+ return mkConstInternal<Node, T>(kind::metakind::ConstantMap<T>::kind, val);
+}
+
+template <class T>
+Node NodeManager::mkConst(Kind k, const T& val)
+{
+ return mkConstInternal<Node, T>(k, val);
}
template <class T>
TypeNode NodeManager::mkTypeConst(const T& val) {
- return mkConstInternal<TypeNode, T>(val);
+ return mkConstInternal<TypeNode, T>(kind::metakind::ConstantMap<T>::kind,
+ val);
}
template <class NodeClass, class T>
-NodeClass NodeManager::mkConstInternal(const T& val) {
- // typedef typename kind::metakind::constantMap<T>::OwningTheory theory_t;
+NodeClass NodeManager::mkConstInternal(Kind k, const T& val)
+{
NVStorage<1> nvStorage;
expr::NodeValue& nvStack = reinterpret_cast<expr::NodeValue&>(nvStorage);
nvStack.d_id = 0;
- nvStack.d_kind = kind::metakind::ConstantMap<T>::kind;
+ nvStack.d_kind = k;
nvStack.d_rc = 0;
nvStack.d_nchildren = 1;
@@ -1230,11 +1243,10 @@ NodeClass NodeManager::mkConstInternal(const T& val) {
}
nv->d_nchildren = 0;
- nv->d_kind = kind::metakind::ConstantMap<T>::kind;
+ nv->d_kind = k;
nv->d_id = next_id++;// FIXME multithreading
nv->d_rc = 0;
- //OwningTheory::mkConst(val);
new (&nv->d_children) T(val);
poolInsert(nv);
diff --git a/src/expr/term_context_node.cpp b/src/expr/term_context_node.cpp
index dbf4cccae..3be9faad0 100644
--- a/src/expr/term_context_node.cpp
+++ b/src/expr/term_context_node.cpp
@@ -18,6 +18,8 @@
#include "expr/term_context.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
TCtxNode::TCtxNode(Node n, const TermContext* tctx)
@@ -52,7 +54,7 @@ Node TCtxNode::getNodeHash() const { return computeNodeHash(d_node, d_val); }
Node TCtxNode::computeNodeHash(Node n, uint32_t val)
{
NodeManager* nm = NodeManager::currentNM();
- return nm->mkNode(kind::SEXPR, n, nm->mkConst(Rational(val)));
+ return nm->mkNode(kind::SEXPR, n, nm->mkConst(CONST_RATIONAL, Rational(val)));
}
Node TCtxNode::decomposeNodeHash(Node h, uint32_t& val)
diff --git a/src/parser/antlr_input.cpp b/src/parser/antlr_input.cpp
index 89d56a108..236eb534c 100644
--- a/src/parser/antlr_input.cpp
+++ b/src/parser/antlr_input.cpp
@@ -34,7 +34,6 @@
using namespace std;
using namespace cvc5;
using namespace cvc5::parser;
-using namespace cvc5::kind;
namespace cvc5 {
namespace parser {
diff --git a/src/parser/input.cpp b/src/parser/input.cpp
index c8c005b36..0fb44b4a9 100644
--- a/src/parser/input.cpp
+++ b/src/parser/input.cpp
@@ -26,7 +26,6 @@
using namespace std;
using namespace cvc5;
using namespace cvc5::parser;
-using namespace cvc5::kind;
namespace cvc5 {
namespace parser {
diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp
index 83b1f5025..c94e39748 100644
--- a/src/parser/parser.cpp
+++ b/src/parser/parser.cpp
@@ -31,7 +31,6 @@
#include "smt/command.h"
using namespace std;
-using namespace cvc5::kind;
namespace cvc5 {
namespace parser {
@@ -535,7 +534,7 @@ api::Term Parser::applyTypeAscription(api::Term t, api::Sort s)
{
t = d_solver->mkEmptySet(s);
}
- else if (k == api::EMPTYBAG)
+ else if (k == api::BAG_EMPTY)
{
t = d_solver->mkEmptyBag(s);
}
diff --git a/src/parser/smt2/smt2.cpp b/src/parser/smt2/smt2.cpp
index 7add605c5..3c423674a 100644
--- a/src/parser/smt2/smt2.cpp
+++ b/src/parser/smt2/smt2.cpp
@@ -145,9 +145,7 @@ void Smt2::addDatatypesOperators()
}
void Smt2::addStringOperators() {
- defineVar(
- "re.all",
- getSolver()->mkTerm(api::REGEXP_STAR, getSolver()->mkRegexpAllchar()));
+ defineVar("re.all", getSolver()->mkRegexpAll());
addOperator(api::STRING_CONCAT, "str.++");
addOperator(api::STRING_LENGTH, "str.len");
addOperator(api::STRING_SUBSTR, "str.substr");
@@ -594,7 +592,7 @@ Command* Smt2::setLogic(std::string name, bool fromCommand)
d_solver->mkUniverseSet(d_solver->getBooleanSort()));
addOperator(api::SET_UNION, "set.union");
- addOperator(api::SET_INTERSECTION, "set.intersection");
+ addOperator(api::SET_INTER, "set.inter");
addOperator(api::SET_MINUS, "set.minus");
addOperator(api::SET_SUBSET, "set.subset");
addOperator(api::SET_MEMBER, "set.member");
@@ -604,6 +602,7 @@ Command* Smt2::setLogic(std::string name, bool fromCommand)
addOperator(api::SET_COMPLEMENT, "set.complement");
addOperator(api::SET_CHOOSE, "set.choose");
addOperator(api::SET_IS_SINGLETON, "set.is_singleton");
+ addOperator(api::SET_MAP, "set.map");
addOperator(api::RELATION_JOIN, "rel.join");
addOperator(api::RELATION_PRODUCT, "rel.product");
addOperator(api::RELATION_TRANSPOSE, "rel.transpose");
@@ -614,16 +613,16 @@ Command* Smt2::setLogic(std::string name, bool fromCommand)
if (d_logic.isTheoryEnabled(theory::THEORY_BAGS))
{
- defineVar("emptybag", d_solver->mkEmptyBag(d_solver->getNullSort()));
- addOperator(api::UNION_MAX, "union_max");
- addOperator(api::UNION_DISJOINT, "union_disjoint");
- addOperator(api::INTERSECTION_MIN, "intersection_min");
- addOperator(api::DIFFERENCE_SUBTRACT, "difference_subtract");
- addOperator(api::DIFFERENCE_REMOVE, "difference_remove");
- addOperator(api::SUBBAG, "subbag");
+ defineVar("bag.empty", d_solver->mkEmptyBag(d_solver->getNullSort()));
+ addOperator(api::BAG_UNION_MAX, "bag.union_max");
+ addOperator(api::BAG_UNION_DISJOINT, "bag.union_disjoint");
+ addOperator(api::BAG_INTER_MIN, "bag.inter_min");
+ addOperator(api::BAG_DIFFERENCE_SUBTRACT, "bag.difference_subtract");
+ addOperator(api::BAG_DIFFERENCE_REMOVE, "bag.difference_remove");
+ addOperator(api::BAG_SUBBAG, "bag.subbag");
addOperator(api::BAG_COUNT, "bag.count");
- addOperator(api::DUPLICATE_REMOVAL, "duplicate_removal");
- addOperator(api::MK_BAG, "bag");
+ addOperator(api::BAG_DUPLICATE_REMOVAL, "bag.duplicate_removal");
+ addOperator(api::BAG_MAKE, "bag");
addOperator(api::BAG_CARD, "bag.card");
addOperator(api::BAG_CHOOSE, "bag.choose");
addOperator(api::BAG_IS_SINGLETON, "bag.is_singleton");
@@ -1011,13 +1010,32 @@ api::Term Smt2::applyParseOp(ParseOp& p, std::vector<api::Term>& args)
// resulting rational here. This also is applied for integral real values
// like 5.0 which are converted to (/ 5 1) to distinguish them from
// integer constants. We must ensure numerator and denominator are
- // constant and the denominator is non-zero.
- if (constVal.getKind() == api::DIVISION)
+ // constant and the denominator is non-zero. A similar issue happens for
+ // negative integers and reals, with unary minus.
+ bool isNeg = false;
+ if (constVal.getKind() == api::UMINUS)
+ {
+ isNeg = true;
+ constVal = constVal[0];
+ }
+ if (constVal.getKind() == api::DIVISION
+ && constVal[0].getKind() == api::CONST_RATIONAL
+ && constVal[1].getKind() == api::CONST_RATIONAL)
{
std::stringstream sdiv;
- sdiv << constVal[0] << "/" << constVal[1];
+ sdiv << (isNeg ? "-" : "") << constVal[0] << "/" << constVal[1];
constVal = d_solver->mkReal(sdiv.str());
}
+ else if (constVal.getKind() == api::CONST_RATIONAL && isNeg)
+ {
+ std::stringstream sneg;
+ sneg << "-" << constVal;
+ constVal = d_solver->mkInteger(sneg.str());
+ }
+ else
+ {
+ constVal = args[0];
+ }
if (!p.d_type.getArrayElementSort().isComparableTo(constVal.getSort()))
{
diff --git a/src/preprocessing/passes/bv_to_int.cpp b/src/preprocessing/passes/bv_to_int.cpp
index 6515ef90a..33f3dd445 100644
--- a/src/preprocessing/passes/bv_to_int.cpp
+++ b/src/preprocessing/passes/bv_to_int.cpp
@@ -43,6 +43,7 @@ namespace preprocessing {
namespace passes {
using namespace std;
+using namespace cvc5::kind;
using namespace cvc5::theory;
using namespace cvc5::theory::bv;
@@ -67,18 +68,18 @@ Node BVToInt::maxInt(uint64_t k)
{
Assert(k > 0);
Rational max_value = intpow2(k) - 1;
- return d_nm->mkConst<Rational>(max_value);
+ return d_nm->mkConst(CONST_RATIONAL, max_value);
}
Node BVToInt::pow2(uint64_t k)
{
Assert(k >= 0);
- return d_nm->mkConst<Rational>(intpow2(k));
+ return d_nm->mkConst(CONST_RATIONAL, Rational(intpow2(k)));
}
Node BVToInt::modpow2(Node n, uint64_t exponent)
{
- Node p2 = d_nm->mkConst<Rational>(intpow2(exponent));
+ Node p2 = d_nm->mkConst(CONST_RATIONAL, Rational(intpow2(exponent)));
return d_nm->mkNode(kind::INTS_MODULUS_TOTAL, n, p2);
}
@@ -545,7 +546,7 @@ Node BVToInt::translateWithChildren(Node original,
Rational max_of_amount = intpow2(amount) - 1;
Rational mul = max_of_amount * intpow2(bvsize);
Rational sum = mul + c;
- returnNode = d_nm->mkConst(sum);
+ returnNode = d_nm->mkConst(CONST_RATIONAL, sum);
}
}
else
@@ -558,7 +559,7 @@ Node BVToInt::translateWithChildren(Node original,
else
{
Rational twoToKMinusOne(intpow2(bvsize - 1));
- Node minSigned = d_nm->mkConst(twoToKMinusOne);
+ Node minSigned = d_nm->mkConst(CONST_RATIONAL, twoToKMinusOne);
/* condition checks whether the msb is 1.
* This holds when the integer value is smaller than
* 100...0, which is 2^{bvsize-1}.
@@ -766,7 +767,7 @@ Node BVToInt::translateNoChildren(Node original)
// Bit-vector constants are transformed into their integer value.
BitVector constant(original.getConst<BitVector>());
Integer c = constant.toInteger();
- translation = d_nm->mkConst<Rational>(c);
+ translation = d_nm->mkConst(CONST_RATIONAL, Rational(c));
}
else
{
@@ -935,8 +936,8 @@ BVToInt::BVToInt(PreprocessingPassContext* preprocContext)
d_rangeAssertions(userContext())
{
d_nm = NodeManager::currentNM();
- d_zero = d_nm->mkConst<Rational>(0);
- d_one = d_nm->mkConst<Rational>(1);
+ d_zero = d_nm->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = d_nm->mkConst(CONST_RATIONAL, Rational(1));
};
PreprocessingPassResult BVToInt::applyInternal(
@@ -1002,10 +1003,12 @@ Node BVToInt::createShiftNode(vector<Node> children,
{
body = d_nm->mkNode(kind::INTS_DIVISION_TOTAL, x, pow2(i));
}
- ite = d_nm->mkNode(kind::ITE,
- d_nm->mkNode(kind::EQUAL, y, d_nm->mkConst<Rational>(i)),
- body,
- ite);
+ ite = d_nm->mkNode(
+ kind::ITE,
+ d_nm->mkNode(
+ kind::EQUAL, y, d_nm->mkConst(CONST_RATIONAL, Rational(i))),
+ body,
+ ite);
}
return ite;
}
diff --git a/src/preprocessing/passes/miplib_trick.cpp b/src/preprocessing/passes/miplib_trick.cpp
index 59f046262..66646b766 100644
--- a/src/preprocessing/passes/miplib_trick.cpp
+++ b/src/preprocessing/passes/miplib_trick.cpp
@@ -33,13 +33,14 @@
#include "theory/trust_substitutions.h"
#include "util/rational.h"
+using namespace std;
+using namespace cvc5::kind;
+using namespace cvc5::theory;
+
namespace cvc5 {
namespace preprocessing {
namespace passes {
-using namespace std;
-using namespace cvc5::theory;
-
namespace {
/**
@@ -212,7 +213,8 @@ PreprocessingPassResult MipLibTrick::applyInternal(
NodeManager* nm = NodeManager::currentNM();
SkolemManager* sm = nm->getSkolemManager();
- Node zero = nm->mkConst(Rational(0)), one = nm->mkConst(Rational(1));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0)),
+ one = nm->mkConst(CONST_RATIONAL, Rational(1));
Node trueNode = nm->mkConst(true);
unordered_map<TNode, Node> intVars;
@@ -571,15 +573,17 @@ PreprocessingPassResult MipLibTrick::applyInternal(
NodeBuilder sumb(kind::PLUS);
for (size_t jj = 0; jj < pos.getNumChildren(); ++jj)
{
- sumb << nm->mkNode(
- kind::MULT, nm->mkConst(coef[pos_var][jj]), newVars[jj]);
+ sumb << nm->mkNode(kind::MULT,
+ nm->mkConst(CONST_RATIONAL, coef[pos_var][jj]),
+ newVars[jj]);
}
sum = sumb;
}
else
{
- sum = nm->mkNode(
- kind::MULT, nm->mkConst(coef[pos_var][0]), newVars[0]);
+ sum = nm->mkNode(kind::MULT,
+ nm->mkConst(CONST_RATIONAL, coef[pos_var][0]),
+ newVars[0]);
}
Debug("miplib") << "vars[] " << var << endl
<< " eq " << rewrite(sum) << endl;
diff --git a/src/preprocessing/passes/real_to_int.cpp b/src/preprocessing/passes/real_to_int.cpp
index 9e2170ffd..5c4539808 100644
--- a/src/preprocessing/passes/real_to_int.cpp
+++ b/src/preprocessing/passes/real_to_int.cpp
@@ -27,6 +27,7 @@
#include "theory/theory_model.h"
#include "util/rational.h"
+using namespace cvc5::kind;
using namespace cvc5::theory;
namespace cvc5 {
@@ -78,6 +79,7 @@ Node RealToInt::realToIntInternal(TNode n, NodeMap& cache, std::vector<Node>& va
{
Assert(c.isConst());
coeffs.push_back(NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL,
Rational(c.getConst<Rational>().getDenominator())));
}
}
@@ -97,7 +99,8 @@ Node RealToInt::realToIntInternal(TNode n, NodeMap& cache, std::vector<Node>& va
Node s;
if (c.isNull())
{
- c = cc.isNull() ? NodeManager::currentNM()->mkConst(Rational(1))
+ c = cc.isNull() ? NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL, Rational(1))
: cc;
}
else
@@ -131,14 +134,15 @@ Node RealToInt::realToIntInternal(TNode n, NodeMap& cache, std::vector<Node>& va
}
Node sumt =
sum.empty()
- ? NodeManager::currentNM()->mkConst(Rational(0))
+ ? NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ Rational(0))
: (sum.size() == 1
? sum[0]
: NodeManager::currentNM()->mkNode(kind::PLUS, sum));
ret = NodeManager::currentNM()->mkNode(
ret_lit.getKind(),
sumt,
- NodeManager::currentNM()->mkConst(Rational(0)));
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0)));
if (!ret_pol)
{
ret = ret.negate();
diff --git a/src/preprocessing/passes/unconstrained_simplifier.cpp b/src/preprocessing/passes/unconstrained_simplifier.cpp
index db6cb8b72..ae05d6b87 100644
--- a/src/preprocessing/passes/unconstrained_simplifier.cpp
+++ b/src/preprocessing/passes/unconstrained_simplifier.cpp
@@ -30,13 +30,14 @@
#include "util/bitvector.h"
#include "util/rational.h"
+using namespace std;
+using namespace cvc5::kind;
+using namespace cvc5::theory;
+
namespace cvc5 {
namespace preprocessing {
namespace passes {
-using namespace std;
-using namespace cvc5::theory;
-
UnconstrainedSimplifier::UnconstrainedSimplifier(
PreprocessingPassContext* preprocContext)
: PreprocessingPass(preprocContext, "unconstrained-simplifier"),
@@ -514,9 +515,9 @@ void UnconstrainedSimplifier::processUnconstrained()
if (current.getType().isInteger())
{
// div/mult by 1 should have been simplified
- Assert(other != nm->mkConst<Rational>(1));
+ Assert(other != nm->mkConst(CONST_RATIONAL, Rational(1)));
// div by -1 should have been simplified
- if (other != nm->mkConst<Rational>(-1))
+ if (other != nm->mkConst(CONST_RATIONAL, Rational(-1)))
{
break;
}
@@ -529,7 +530,8 @@ void UnconstrainedSimplifier::processUnconstrained()
else
{
// TODO(#2377): could build ITE here
- Node test = other.eqNode(nm->mkConst<Rational>(0));
+ Node test =
+ other.eqNode(nm->mkConst(CONST_RATIONAL, Rational(0)));
if (rewrite(test) != nm->mkConst<bool>(false))
{
break;
diff --git a/src/printer/printer.cpp b/src/printer/printer.cpp
index b66ae5728..16b626e30 100644
--- a/src/printer/printer.cpp
+++ b/src/printer/printer.cpp
@@ -16,6 +16,7 @@
#include <string>
+#include "expr/node_manager_attributes.h"
#include "options/base_options.h"
#include "options/language.h"
#include "printer/ast/ast_printer.h"
@@ -201,9 +202,8 @@ void Printer::toStreamCmdDeclareFunction(std::ostream& out,
void Printer::toStreamCmdDeclareFunction(std::ostream& out, const Node& v) const
{
- std::stringstream vs;
- vs << v;
- toStreamCmdDeclareFunction(out, vs.str(), v.getType());
+ std::string vs = v.getAttribute(expr::VarNameAttr());
+ toStreamCmdDeclareFunction(out, vs, v.getType());
}
void Printer::toStreamCmdDeclarePool(std::ostream& out,
diff --git a/src/printer/smt2/smt2_printer.cpp b/src/printer/smt2/smt2_printer.cpp
index 5d4387658..30433ec1a 100644
--- a/src/printer/smt2/smt2_printer.cpp
+++ b/src/printer/smt2/smt2_printer.cpp
@@ -336,8 +336,8 @@ void Smt2Printer::toStream(std::ostream& out,
out << ")";
break;
- case kind::EMPTYBAG:
- out << "(as emptybag ";
+ case kind::BAG_EMPTY:
+ out << "(as bag.empty ";
toStreamType(out, n.getConst<EmptyBag>().getType());
out << ")";
break;
@@ -701,9 +701,9 @@ void Smt2Printer::toStream(std::ostream& out,
case kind::SET_UNIVERSE: out << "(as set.universe " << n.getType() << ")"; break;
// bags
- case kind::MK_BAG:
+ case kind::BAG_MAKE:
{
- // print (bag (mkBag_op Real) 1 3) as (bag 1.0 3)
+ // print (bag (BAG_MAKE_OP Real) 1 3) as (bag 1.0 3)
out << smtKindString(k, d_variant) << " ";
TypeNode elemType = n.getType().getBagElementType();
toStreamCastToType(
@@ -1061,7 +1061,7 @@ std::string Smt2Printer::smtKindString(Kind k, Variant v)
// set theory
case kind::SET_UNION: return "set.union";
- case kind::SET_INTERSECTION: return "set.intersection";
+ case kind::SET_INTER: return "set.inter";
case kind::SET_MINUS: return "set.minus";
case kind::SET_SUBSET: return "set.subset";
case kind::SET_MEMBER: return "set.member";
@@ -1073,6 +1073,7 @@ std::string Smt2Printer::smtKindString(Kind k, Variant v)
case kind::SET_COMPREHENSION: return "set.comprehension";
case kind::SET_CHOOSE: return "set.choose";
case kind::SET_IS_SINGLETON: return "set.is_singleton";
+ case kind::SET_MAP: return "set.map";
case kind::RELATION_JOIN: return "rel.join";
case kind::RELATION_PRODUCT: return "rel.product";
case kind::RELATION_TRANSPOSE: return "rel.transpose";
@@ -1082,15 +1083,15 @@ std::string Smt2Printer::smtKindString(Kind k, Variant v)
// bag theory
case kind::BAG_TYPE: return "Bag";
- case kind::UNION_MAX: return "union_max";
- case kind::UNION_DISJOINT: return "union_disjoint";
- case kind::INTERSECTION_MIN: return "intersection_min";
- case kind::DIFFERENCE_SUBTRACT: return "difference_subtract";
- case kind::DIFFERENCE_REMOVE: return "difference_remove";
- case kind::SUBBAG: return "subbag";
+ case kind::BAG_UNION_MAX: return "bag.union_max";
+ case kind::BAG_UNION_DISJOINT: return "bag.union_disjoint";
+ case kind::BAG_INTER_MIN: return "bag.inter_min";
+ case kind::BAG_DIFFERENCE_SUBTRACT: return "bag.difference_subtract";
+ case kind::BAG_DIFFERENCE_REMOVE: return "bag.difference_remove";
+ case kind::BAG_SUBBAG: return "bag.subbag";
case kind::BAG_COUNT: return "bag.count";
- case kind::DUPLICATE_REMOVAL: return "duplicate_removal";
- case kind::MK_BAG: return "bag";
+ case kind::BAG_DUPLICATE_REMOVAL: return "bag.duplicate_removal";
+ case kind::BAG_MAKE: return "bag";
case kind::BAG_CARD: return "bag.card";
case kind::BAG_CHOOSE: return "bag.choose";
case kind::BAG_IS_SINGLETON: return "bag.is_singleton";
diff --git a/src/proof/alethe/alethe_post_processor.cpp b/src/proof/alethe/alethe_post_processor.cpp
index c97dc2313..994fe83d2 100644
--- a/src/proof/alethe/alethe_post_processor.cpp
+++ b/src/proof/alethe/alethe_post_processor.cpp
@@ -22,6 +22,8 @@
#include "theory/builtin/proof_checker.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace proof {
@@ -456,7 +458,7 @@ bool AletheProofPostprocessCallback::update(Node res,
res,
nm->mkNode(kind::SEXPR, d_cl, res),
children,
- {nm->mkConst(Rational(1))},
+ {nm->mkConst(CONST_RATIONAL, Rational(1))},
*cdp);
}
default:
@@ -1363,6 +1365,117 @@ bool AletheProofPostprocessCallback::update(Node res,
{},
*cdp);
}
+ //================================================= Quantifiers rules
+ // ======== Instantiate
+ // See proof_rule.h for documentation on the INSTANTIATE rule. This
+ // comment uses variable names as introduced there.
+ //
+ // ----- FORALL_INST, (= x1 t1) ... (= xn tn)
+ // VP1
+ // ----- OR
+ // VP2 P
+ // -------------------- RESOLUTION
+ // (cl F*sigma)^
+ //
+ // VP1: (cl (or (not (forall ((x1 T1) ... (xn Tn)) F*sigma)
+ // VP2: (cl (not (forall ((x1 T1) ... (xn Tn)) F)) F*sigma)
+ //
+ // ^ the corresponding proof node is F*sigma
+ case PfRule::INSTANTIATE:
+ {
+ for (size_t i = 0, size = children[0][0].getNumChildren(); i < size; i++)
+ {
+ new_args.push_back(children[0][0][i].eqNode(args[i]));
+ }
+ Node vp1 = nm->mkNode(
+ kind::SEXPR, d_cl, nm->mkNode(kind::OR, children[0].notNode(), res));
+ Node vp2 = nm->mkNode(kind::SEXPR, d_cl, children[0].notNode(), res);
+ return addAletheStep(
+ AletheRule::FORALL_INST, vp1, vp1, {}, new_args, *cdp)
+ && addAletheStep(AletheRule::OR, vp2, vp2, {vp1}, {}, *cdp)
+ && addAletheStep(AletheRule::RESOLUTION,
+ res,
+ nm->mkNode(kind::SEXPR, d_cl, res),
+ {vp2, children[0]},
+ {},
+ *cdp);
+ }
+ //================================================= Arithmetic rules
+ // ======== Adding Inequalities
+ //
+ // ----- LIA_GENERIC
+ // VP1 P1 ... Pn
+ // ------------------------------- RESOLUTION
+ // (cl (>< t1 t2))*
+ //
+ // VP1: (cl (not l1) ... (not ln) (>< t1 t2))
+ //
+ // * the corresponding proof node is (>< t1 t2)
+ case PfRule::MACRO_ARITH_SCALE_SUM_UB:
+ {
+ std::vector<Node> vp1s{d_cl};
+ for (const Node& child : children)
+ {
+ vp1s.push_back(child.notNode());
+ }
+ vp1s.push_back(res);
+ Node vp1 = nm->mkNode(kind::SEXPR, vp1s);
+ std::vector<Node> new_children = {vp1};
+ new_children.insert(new_children.end(), children.begin(), children.end());
+ return addAletheStep(AletheRule::LIA_GENERIC, vp1, vp1, {}, args, *cdp)
+ && addAletheStep(AletheRule::RESOLUTION,
+ res,
+ nm->mkNode(kind::SEXPR, d_cl, res),
+ new_children,
+ {},
+ *cdp);
+ }
+ // ======== Tightening Strict Integer Upper Bounds
+ //
+ // ----- LA_GENERIC, 1
+ // VP1 P
+ // ------------------------------------- RESOLUTION
+ // (cl (<= i greatestIntLessThan(c)))*
+ //
+ // VP1: (cl (not (< i c)) (<= i greatestIntLessThan(c)))
+ //
+ // * the corresponding proof node is (<= i greatestIntLessThan(c))
+ case PfRule::INT_TIGHT_UB:
+ {
+ Node vp1 = nm->mkNode(kind::SEXPR, d_cl, children[0], res);
+ std::vector<Node> new_children = {vp1, children[0]};
+ new_args.push_back(nm->mkConst<Rational>(CONST_RATIONAL, 1));
+ return addAletheStep(AletheRule::LA_GENERIC, vp1, vp1, {}, new_args, *cdp)
+ && addAletheStep(AletheRule::RESOLUTION,
+ res,
+ nm->mkNode(kind::SEXPR, d_cl, res),
+ new_children,
+ {},
+ *cdp);
+ }
+ // ======== Tightening Strict Integer Lower Bounds
+ //
+ // ----- LA_GENERIC, 1
+ // VP1 P
+ // ------------------------------------- RESOLUTION
+ // (cl (>= i leastIntGreaterThan(c)))*
+ //
+ // VP1: (cl (not (> i c)) (>= i leastIntGreaterThan(c)))
+ //
+ // * the corresponding proof node is (>= i leastIntGreaterThan(c))
+ case PfRule::INT_TIGHT_LB:
+ {
+ Node vp1 = nm->mkNode(kind::SEXPR, d_cl, children[0], res);
+ std::vector<Node> new_children = {vp1, children[0]};
+ new_args.push_back(nm->mkConst<Rational>(CONST_RATIONAL, 1));
+ return addAletheStep(AletheRule::LA_GENERIC, vp1, vp1, {}, new_args, *cdp)
+ && addAletheStep(AletheRule::RESOLUTION,
+ res,
+ nm->mkNode(kind::SEXPR, d_cl, res),
+ new_children,
+ {},
+ *cdp);
+ }
default:
{
return addAletheStep(AletheRule::UNDEFINED,
@@ -1391,8 +1504,8 @@ bool AletheProofPostprocessCallback::addAletheStep(
}
std::vector<Node> new_args = std::vector<Node>();
- new_args.push_back(
- NodeManager::currentNM()->mkConst<Rational>(static_cast<unsigned>(rule)));
+ new_args.push_back(NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL, Rational(static_cast<unsigned>(rule))));
new_args.push_back(res);
new_args.push_back(sanitized_conclusion);
new_args.insert(new_args.end(), args.begin(), args.end());
diff --git a/src/proof/lfsc/lfsc_node_converter.cpp b/src/proof/lfsc/lfsc_node_converter.cpp
index 7ec0b2bd5..7f1d9e192 100644
--- a/src/proof/lfsc/lfsc_node_converter.cpp
+++ b/src/proof/lfsc/lfsc_node_converter.cpp
@@ -89,7 +89,7 @@ Node LfscNodeConverter::postConvert(Node n)
}
// bound variable v is (bvar x T)
TypeNode intType = nm->integerType();
- Node x = nm->mkConst(Rational(getOrAssignIndexForVar(n)));
+ Node x = nm->mkConst(CONST_RATIONAL, Rational(getOrAssignIndexForVar(n)));
Node tc = typeAsNode(convertType(tn));
TypeNode ftype = nm->mkFunctionType({intType, d_sortType}, tn);
Node bvarOp = getSymbolInternal(k, ftype, "bvar");
@@ -136,7 +136,8 @@ Node LfscNodeConverter::postConvert(Node n)
TypeNode intType = nm->integerType();
TypeNode varType = nm->mkFunctionType({intType, d_sortType}, tn);
Node var = mkInternalSymbol("var", varType);
- Node index = nm->mkConst(Rational(getOrAssignIndexForVar(n)));
+ Node index =
+ nm->mkConst(CONST_RATIONAL, Rational(getOrAssignIndexForVar(n)));
Node tc = typeAsNode(convertType(tn));
return nm->mkNode(APPLY_UF, var, index, tc);
}
@@ -197,7 +198,7 @@ Node LfscNodeConverter::postConvert(Node n)
{
// use LFSC syntax for mpz negation
Node mpzn = getSymbolInternal(k, nm->mkFunctionType(tn, tn), "~");
- arg = nm->mkNode(APPLY_UF, mpzn, nm->mkConst(r.abs()));
+ arg = nm->mkNode(APPLY_UF, mpzn, nm->mkConst(CONST_RATIONAL, r.abs()));
}
else
{
@@ -306,7 +307,7 @@ Node LfscNodeConverter::postConvert(Node n)
children.insert(children.end(), n.begin(), n.end());
return nm->mkNode(APPLY_UF, children);
}
- else if (k == SET_EMPTY || k == SET_UNIVERSE || k == EMPTYBAG)
+ else if (k == SET_EMPTY || k == SET_UNIVERSE || k == BAG_EMPTY)
{
Node t = typeAsNode(convertType(tn));
TypeNode etype = nm->mkFunctionType(d_sortType, tn);
@@ -314,7 +315,7 @@ Node LfscNodeConverter::postConvert(Node n)
k,
etype,
k == SET_EMPTY ? "set.empty"
- : (k == SET_UNIVERSE ? "set.universe" : "emptybag"));
+ : (k == SET_UNIVERSE ? "set.universe" : "bag.empty"));
return nm->mkNode(APPLY_UF, ef, t);
}
else if (n.isClosure())
@@ -343,8 +344,8 @@ Node LfscNodeConverter::postConvert(Node n)
Node rop = getSymbolInternal(
k, relType, printer::smt2::Smt2Printer::smtKindString(k));
RegExpLoop op = n.getOperator().getConst<RegExpLoop>();
- Node n1 = nm->mkConst(Rational(op.d_loopMinOcc));
- Node n2 = nm->mkConst(Rational(op.d_loopMaxOcc));
+ Node n1 = nm->mkConst(CONST_RATIONAL, Rational(op.d_loopMinOcc));
+ Node n2 = nm->mkConst(CONST_RATIONAL, Rational(op.d_loopMaxOcc));
return nm->mkNode(APPLY_UF, nm->mkNode(APPLY_UF, rop, n1, n2), n[0]);
}
else if (k == MATCH)
@@ -484,14 +485,16 @@ TypeNode LfscNodeConverter::postConvertType(TypeNode tn)
else if (k == BITVECTOR_TYPE)
{
tnn = d_typeKindToNodeCons[k];
- Node w = nm->mkConst(Rational(tn.getBitVectorSize()));
+ Node w = nm->mkConst(CONST_RATIONAL, Rational(tn.getBitVectorSize()));
tnn = nm->mkNode(APPLY_UF, tnn, w);
}
else if (k == FLOATINGPOINT_TYPE)
{
tnn = d_typeKindToNodeCons[k];
- Node e = nm->mkConst(Rational(tn.getFloatingPointExponentSize()));
- Node s = nm->mkConst(Rational(tn.getFloatingPointSignificandSize()));
+ Node e = nm->mkConst(CONST_RATIONAL,
+ Rational(tn.getFloatingPointExponentSize()));
+ Node s = nm->mkConst(CONST_RATIONAL,
+ Rational(tn.getFloatingPointSignificandSize()));
tnn = nm->mkNode(APPLY_UF, tnn, e, s);
}
else if (tn.getNumChildren() == 0)
@@ -719,7 +722,8 @@ void LfscNodeConverter::getCharVectorInternal(Node c, std::vector<Node>& chars)
Node aconstf = getSymbolInternal(CONST_STRING, tnc, "char");
for (unsigned i = 0, size = vec.size(); i < size; i++)
{
- Node cc = nm->mkNode(APPLY_UF, aconstf, nm->mkConst(Rational(vec[i])));
+ Node cc = nm->mkNode(
+ APPLY_UF, aconstf, nm->mkConst(CONST_RATIONAL, Rational(vec[i])));
chars.push_back(cc);
}
}
@@ -742,36 +746,42 @@ std::vector<Node> LfscNodeConverter::getOperatorIndices(Kind k, Node n)
case BITVECTOR_EXTRACT:
{
BitVectorExtract p = n.getConst<BitVectorExtract>();
- indices.push_back(nm->mkConst(Rational(p.d_high)));
- indices.push_back(nm->mkConst(Rational(p.d_low)));
+ indices.push_back(nm->mkConst(CONST_RATIONAL, Rational(p.d_high)));
+ indices.push_back(nm->mkConst(CONST_RATIONAL, Rational(p.d_low)));
break;
}
case BITVECTOR_REPEAT:
indices.push_back(
- nm->mkConst(Rational(n.getConst<BitVectorRepeat>().d_repeatAmount)));
+ nm->mkConst(CONST_RATIONAL,
+ Rational(n.getConst<BitVectorRepeat>().d_repeatAmount)));
break;
case BITVECTOR_ZERO_EXTEND:
indices.push_back(nm->mkConst(
+ CONST_RATIONAL,
Rational(n.getConst<BitVectorZeroExtend>().d_zeroExtendAmount)));
break;
case BITVECTOR_SIGN_EXTEND:
indices.push_back(nm->mkConst(
+ CONST_RATIONAL,
Rational(n.getConst<BitVectorSignExtend>().d_signExtendAmount)));
break;
case BITVECTOR_ROTATE_LEFT:
indices.push_back(nm->mkConst(
+ CONST_RATIONAL,
Rational(n.getConst<BitVectorRotateLeft>().d_rotateLeftAmount)));
break;
case BITVECTOR_ROTATE_RIGHT:
indices.push_back(nm->mkConst(
+ CONST_RATIONAL,
Rational(n.getConst<BitVectorRotateRight>().d_rotateRightAmount)));
break;
case INT_TO_BITVECTOR:
- indices.push_back(
- nm->mkConst(Rational(n.getConst<IntToBitVector>().d_size)));
+ indices.push_back(nm->mkConst(
+ CONST_RATIONAL, Rational(n.getConst<IntToBitVector>().d_size)));
break;
case IAND:
- indices.push_back(nm->mkConst(Rational(n.getConst<IntAnd>().d_size)));
+ indices.push_back(
+ nm->mkConst(CONST_RATIONAL, Rational(n.getConst<IntAnd>().d_size)));
break;
case APPLY_TESTER:
{
@@ -923,7 +933,7 @@ Node LfscNodeConverter::getOperatorOfTerm(Node n, bool macroApply)
ret = maybeMkSkolemFun(op, macroApply);
Assert(!ret.isNull());
}
- else if (k == SET_SINGLETON || k == MK_BAG)
+ else if (k == SET_SINGLETON || k == BAG_MAKE)
{
if (!macroApply)
{
@@ -1012,7 +1022,7 @@ Node LfscNodeConverter::getOperatorOfClosure(Node q, bool macroApply)
Node LfscNodeConverter::getOperatorOfBoundVar(Node cop, Node v)
{
NodeManager* nm = NodeManager::currentNM();
- Node x = nm->mkConst(Rational(getOrAssignIndexForVar(v)));
+ Node x = nm->mkConst(CONST_RATIONAL, Rational(getOrAssignIndexForVar(v)));
Node tc = typeAsNode(convertType(v.getType()));
return nm->mkNode(APPLY_UF, cop, x, tc);
}
diff --git a/src/proof/lfsc/lfsc_util.cpp b/src/proof/lfsc/lfsc_util.cpp
index d8bd8f548..06bedb895 100644
--- a/src/proof/lfsc/lfsc_util.cpp
+++ b/src/proof/lfsc/lfsc_util.cpp
@@ -18,6 +18,8 @@
#include "proof/proof_checker.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace proof {
@@ -66,7 +68,8 @@ LfscRule getLfscRule(Node n)
Node mkLfscRuleNode(LfscRule r)
{
- return NodeManager::currentNM()->mkConst(Rational(static_cast<uint32_t>(r)));
+ return NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ Rational(static_cast<uint32_t>(r)));
}
bool LfscProofLetifyTraverseCallback::shouldTraverse(const ProofNode* pn)
diff --git a/src/proof/method_id.cpp b/src/proof/method_id.cpp
index c5e8458cd..9567590a8 100644
--- a/src/proof/method_id.cpp
+++ b/src/proof/method_id.cpp
@@ -18,6 +18,8 @@
#include "proof/proof_checker.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
const char* toString(MethodId id)
@@ -49,7 +51,8 @@ std::ostream& operator<<(std::ostream& out, MethodId id)
Node mkMethodId(MethodId id)
{
- return NodeManager::currentNM()->mkConst(Rational(static_cast<uint32_t>(id)));
+ return NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ Rational(static_cast<uint32_t>(id)));
}
bool getMethodId(TNode n, MethodId& i)
diff --git a/src/proof/proof.cpp b/src/proof/proof.cpp
index dc370a04d..ffccd42ba 100644
--- a/src/proof/proof.cpp
+++ b/src/proof/proof.cpp
@@ -287,6 +287,24 @@ bool CDProof::addProof(std::shared_ptr<ProofNode> pn,
{
if (!doCopy)
{
+ // If we are automatically managing symmetry, we strip off SYMM steps.
+ // This avoids cyclic proofs in cases where P and (SYMM P) are added as
+ // proofs to the same CDProof.
+ if (d_autoSymm)
+ {
+ std::vector<std::shared_ptr<ProofNode>> processed;
+ while (pn->getRule() == PfRule::SYMM)
+ {
+ pn = pn->getChildren()[0];
+ if (std::find(processed.begin(), processed.end(), pn)
+ != processed.end())
+ {
+ Unreachable() << "Cyclic proof encountered when cancelling symmetry "
+ "steps during addProof";
+ }
+ processed.push_back(pn);
+ }
+ }
// If we aren't doing a deep copy, we either store pn or link its top
// node into the existing pointer
Node curFact = pn->getResult();
diff --git a/src/proof/proof_checker.cpp b/src/proof/proof_checker.cpp
index c178ccebf..5289d77ff 100644
--- a/src/proof/proof_checker.cpp
+++ b/src/proof/proof_checker.cpp
@@ -74,7 +74,8 @@ Node ProofRuleChecker::mkKindNode(Kind k)
// UNDEFINED_KIND is negative, hence return null to avoid cast
return Node::null();
}
- return NodeManager::currentNM()->mkConst(Rational(static_cast<uint32_t>(k)));
+ return NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ Rational(static_cast<uint32_t>(k)));
}
ProofCheckerStatistics::ProofCheckerStatistics()
diff --git a/src/proof/proof_node_manager.cpp b/src/proof/proof_node_manager.cpp
index 72c39c59f..e0a7f81c0 100644
--- a/src/proof/proof_node_manager.cpp
+++ b/src/proof/proof_node_manager.cpp
@@ -403,12 +403,20 @@ std::shared_ptr<ProofNode> ProofNodeManager::clone(
ProofNode* ProofNodeManager::cancelDoubleSymm(ProofNode* pn)
{
+ // processed is almost always size <= 1
+ std::vector<ProofNode*> processed;
while (pn->getRule() == PfRule::SYMM)
{
std::shared_ptr<ProofNode> pnc = pn->getChildren()[0];
if (pnc->getRule() == PfRule::SYMM)
{
pn = pnc->getChildren()[0].get();
+ if (std::find(processed.begin(), processed.end(), pn) != processed.end())
+ {
+ Unreachable()
+ << "Cyclic proof encountered when cancelling double symmetry";
+ }
+ processed.push_back(pn);
}
else
{
diff --git a/src/prop/proof_cnf_stream.cpp b/src/prop/proof_cnf_stream.cpp
index d09854bce..61a1a298c 100644
--- a/src/prop/proof_cnf_stream.cpp
+++ b/src/prop/proof_cnf_stream.cpp
@@ -20,6 +20,8 @@
#include "theory/builtin/proof_checker.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace prop {
@@ -171,7 +173,7 @@ void ProofCnfStream::convertAndAssertAnd(TNode node, bool negated)
for (unsigned i = 0, size = node.getNumChildren(); i < size; ++i)
{
// Create a proof step for each n_i
- Node iNode = nm->mkConst<Rational>(i);
+ Node iNode = nm->mkConst<Rational>(CONST_RATIONAL, i);
d_proof.addStep(node[i], PfRule::AND_ELIM, {node}, {iNode});
Trace("cnf") << "ProofCnfStream::convertAndAssertAnd: AND_ELIM " << i
<< " added norm " << node[i] << "\n";
@@ -230,7 +232,7 @@ void ProofCnfStream::convertAndAssertOr(TNode node, bool negated)
for (unsigned i = 0, size = node.getNumChildren(); i < size; ++i)
{
// Create a proof step for each (not n_i)
- Node iNode = nm->mkConst<Rational>(i);
+ Node iNode = nm->mkConst<Rational>(CONST_RATIONAL, i);
d_proof.addStep(
node[i].notNode(), PfRule::NOT_OR_ELIM, {node.notNode()}, {iNode});
Trace("cnf") << "ProofCnfStream::convertAndAssertOr: NOT_OR_ELIM " << i
@@ -685,7 +687,7 @@ SatLiteral ProofCnfStream::handleAnd(TNode node)
if (added)
{
Node clauseNode = nm->mkNode(kind::OR, node.notNode(), node[i]);
- Node iNode = nm->mkConst<Rational>(i);
+ Node iNode = nm->mkConst<Rational>(CONST_RATIONAL, i);
d_proof.addStep(clauseNode, PfRule::CNF_AND_POS, {}, {node, iNode});
Trace("cnf") << "ProofCnfStream::handleAnd: CNF_AND_POS " << i
<< " added " << clauseNode << "\n";
@@ -745,7 +747,7 @@ SatLiteral ProofCnfStream::handleOr(TNode node)
if (added)
{
Node clauseNode = nm->mkNode(kind::OR, node, node[i].notNode());
- Node iNode = nm->mkConst<Rational>(i);
+ Node iNode = nm->mkConst<Rational>(CONST_RATIONAL, i);
d_proof.addStep(clauseNode, PfRule::CNF_OR_NEG, {}, {node, iNode});
Trace("cnf") << "ProofCnfStream::handleOr: CNF_OR_NEG " << i << " added "
<< clauseNode << "\n";
diff --git a/src/smt/assertions.cpp b/src/smt/assertions.cpp
index 9c24dd690..8d066c1ba 100644
--- a/src/smt/assertions.cpp
+++ b/src/smt/assertions.cpp
@@ -190,16 +190,19 @@ void Assertions::addFormula(TNode n,
// Ensure that it does not contain free variables
if (maybeHasFv)
{
- if (expr::hasFreeVar(n))
+ bool wasShadow = false;
+ if (expr::hasFreeOrShadowedVar(n, wasShadow))
{
+ std::string varType(wasShadow ? "shadowed" : "free");
std::stringstream se;
if (isFunDef)
{
- se << "Cannot process function definition with free variable.";
+ se << "Cannot process function definition with " << varType
+ << " variable.";
}
else
{
- se << "Cannot process assertion with free variable.";
+ se << "Cannot process assertion with " << varType << " variable.";
if (language::isLangSygus(options().base.inputLanguage))
{
// Common misuse of SyGuS is to use top-level assert instead of
diff --git a/src/smt/difficulty_post_processor.cpp b/src/smt/difficulty_post_processor.cpp
index 748092238..31797ba5e 100644
--- a/src/smt/difficulty_post_processor.cpp
+++ b/src/smt/difficulty_post_processor.cpp
@@ -69,7 +69,7 @@ void DifficultyPostprocessCallback::getDifficultyMap(
NodeManager* nm = NodeManager::currentNM();
for (const std::pair<const Node, uint64_t>& d : d_accMap)
{
- dmap[d.first] = nm->mkConst(Rational(d.second));
+ dmap[d.first] = nm->mkConst(CONST_RATIONAL, Rational(d.second));
}
}
diff --git a/src/smt/proof_post_processor.cpp b/src/smt/proof_post_processor.cpp
index 56a759866..a292fec8f 100644
--- a/src/smt/proof_post_processor.cpp
+++ b/src/smt/proof_post_processor.cpp
@@ -855,7 +855,7 @@ Node ProofPostprocessCallback::expandMacros(PfRule id,
for (size_t j = 0, nchildi = children[i].getNumChildren(); j < nchildi;
j++)
{
- Node nodej = nm->mkConst(Rational(j));
+ Node nodej = nm->mkConst(CONST_RATIONAL, Rational(j));
cdp->addStep(
children[i][j], PfRule::AND_ELIM, {children[i]}, {nodej});
}
@@ -1086,8 +1086,8 @@ Node ProofPostprocessCallback::expandMacros(PfRule id,
TNode child = children[i];
TNode scalar = args[i];
bool isPos = scalar.getConst<Rational>() > 0;
- Node scalarCmp =
- nm->mkNode(isPos ? GT : LT, scalar, nm->mkConst(Rational(0)));
+ Node scalarCmp = nm->mkNode(
+ isPos ? GT : LT, scalar, nm->mkConst(CONST_RATIONAL, Rational(0)));
// (= scalarCmp true)
Node scalarCmpOrTrue = steps.tryStep(PfRule::EVALUATE, {}, {scalarCmp});
Assert(!scalarCmpOrTrue.isNull());
diff --git a/src/smt/term_formula_removal.cpp b/src/smt/term_formula_removal.cpp
index edf4e2761..341893a70 100644
--- a/src/smt/term_formula_removal.cpp
+++ b/src/smt/term_formula_removal.cpp
@@ -342,48 +342,6 @@ Node RemoveTermFormulas::runCurrentInternal(TNode node,
}
}
}
- else if (node.getKind() == kind::LAMBDA)
- {
- // if a lambda, do lambda-lifting
- if (!expr::hasFreeVar(node))
- {
- skolem = getSkolemForNode(node);
- if (skolem.isNull())
- {
- Trace("rtf-proof-debug")
- << "RemoveTermFormulas::run: make LAMBDA skolem" << std::endl;
- // Make the skolem to represent the lambda
- SkolemManager* sm = nodeManager->getSkolemManager();
- skolem = sm->mkPurifySkolem(
- node,
- "lambdaF",
- "a function introduced due to term-level lambda removal");
- d_skolem_cache.insert(node, skolem);
-
- // The new assertion
- std::vector<Node> children;
- // bound variable list
- children.push_back(node[0]);
- // body
- std::vector<Node> skolem_app_c;
- skolem_app_c.push_back(skolem);
- skolem_app_c.insert(skolem_app_c.end(), node[0].begin(), node[0].end());
- Node skolem_app = nodeManager->mkNode(kind::APPLY_UF, skolem_app_c);
- children.push_back(skolem_app.eqNode(node[1]));
- // axiom defining skolem
- newAssertion = nodeManager->mkNode(kind::FORALL, children);
-
- // Lambda lifting is trivial to justify, hence we don't set a proof
- // generator here. In particular, replacing the skolem introduced
- // here with its original lambda ensures the new assertion rewrites
- // to true.
- // For example, if (lambda y. t[y]) has skolem k, then this lemma is:
- // forall x. k(x)=t[x]
- // whose witness form rewrites
- // forall x. (lambda y. t[y])(x)=t[x] --> forall x. t[x]=t[x] --> true
- }
- }
- }
else if (node.getKind() == kind::WITNESS)
{
// If a witness choice
diff --git a/src/smt_util/nary_builder.cpp b/src/smt_util/nary_builder.cpp
index ff9f7ef03..6d6259d73 100644
--- a/src/smt_util/nary_builder.cpp
+++ b/src/smt_util/nary_builder.cpp
@@ -105,10 +105,8 @@ Node NaryBuilder::zeroArity(Kind k){
return nm->mkConst(true);
case OR:
return nm->mkConst(false);
- case PLUS:
- return nm->mkConst(Rational(0));
- case MULT:
- return nm->mkConst(Rational(1));
+ case PLUS: return nm->mkConst(CONST_RATIONAL, Rational(0));
+ case MULT: return nm->mkConst(CONST_RATIONAL, Rational(1));
default:
return Node::null();
}
diff --git a/src/theory/arith/arith_msum.cpp b/src/theory/arith/arith_msum.cpp
index 3ca649211..ac3780b36 100644
--- a/src/theory/arith/arith_msum.cpp
+++ b/src/theory/arith/arith_msum.cpp
@@ -103,16 +103,20 @@ bool ArithMSum::getMonomialSumLit(Node lit, std::map<Node, Node>& msum)
std::map<Node, Node>::iterator it2 = msum.find(it->first);
if (it2 != msum.end())
{
- Node r = nm->mkNode(
- MINUS,
- it2->second.isNull() ? nm->mkConst(Rational(1)) : it2->second,
- it->second.isNull() ? nm->mkConst(Rational(1)) : it->second);
+ Node r = nm->mkNode(MINUS,
+ it2->second.isNull()
+ ? nm->mkConst(CONST_RATIONAL, Rational(1))
+ : it2->second,
+ it->second.isNull()
+ ? nm->mkConst(CONST_RATIONAL, Rational(1))
+ : it->second);
msum[it->first] = Rewriter::rewrite(r);
}
else
{
- msum[it->first] = it->second.isNull() ? nm->mkConst(Rational(-1))
- : negate(it->second);
+ msum[it->first] = it->second.isNull()
+ ? nm->mkConst(CONST_RATIONAL, Rational(-1))
+ : negate(it->second);
}
}
return true;
@@ -142,9 +146,10 @@ Node ArithMSum::mkNode(const std::map<Node, Node>& msum)
}
children.push_back(m);
}
- return children.size() > 1
- ? nm->mkNode(PLUS, children)
- : (children.size() == 1 ? children[0] : nm->mkConst(Rational(0)));
+ return children.size() > 1 ? nm->mkNode(PLUS, children)
+ : (children.size() == 1
+ ? children[0]
+ : nm->mkConst(CONST_RATIONAL, Rational(0)));
}
int ArithMSum::isolate(
@@ -179,21 +184,22 @@ int ArithMSum::isolate(
}
val = children.size() > 1
? NodeManager::currentNM()->mkNode(PLUS, children)
- : (children.size() == 1
- ? children[0]
- : NodeManager::currentNM()->mkConst(Rational(0)));
+ : (children.size() == 1 ? children[0]
+ : NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL, Rational(0)));
if (!r.isOne() && !r.isNegativeOne())
{
if (v.getType().isInteger())
{
- veq_c = NodeManager::currentNM()->mkConst(r.abs());
+ veq_c = NodeManager::currentNM()->mkConst(CONST_RATIONAL, r.abs());
}
else
{
val = NodeManager::currentNM()->mkNode(
MULT,
val,
- NodeManager::currentNM()->mkConst(Rational(1) / r.abs()));
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ Rational(1) / r.abs()));
}
}
val = r.sgn() == 1 ? negate(val) : Rewriter::rewrite(val);
@@ -288,7 +294,7 @@ bool ArithMSum::decompose(Node n, Node v, Node& coeff, Node& rem)
Node ArithMSum::negate(Node t)
{
Node tt = NodeManager::currentNM()->mkNode(
- MULT, NodeManager::currentNM()->mkConst(Rational(-1)), t);
+ MULT, NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(-1)), t);
tt = Rewriter::rewrite(tt);
return tt;
}
@@ -296,7 +302,7 @@ Node ArithMSum::negate(Node t)
Node ArithMSum::offset(Node t, int i)
{
Node tt = NodeManager::currentNM()->mkNode(
- PLUS, NodeManager::currentNM()->mkConst(Rational(i)), t);
+ PLUS, NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(i)), t);
tt = Rewriter::rewrite(tt);
return tt;
}
diff --git a/src/theory/arith/arith_rewriter.cpp b/src/theory/arith/arith_rewriter.cpp
index 5baaaf317..19b5c1204 100644
--- a/src/theory/arith/arith_rewriter.cpp
+++ b/src/theory/arith/arith_rewriter.cpp
@@ -33,6 +33,8 @@
#include "util/divisible.h"
#include "util/iand.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -138,8 +140,9 @@ RewriteResponse ArithRewriter::preRewriteTerm(TNode t){
if(rat >= 0) {
return RewriteResponse(REWRITE_DONE, t[0]);
} else {
- return RewriteResponse(REWRITE_DONE,
- NodeManager::currentNM()->mkConst(-rat));
+ return RewriteResponse(
+ REWRITE_DONE,
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL, -rat));
}
}
return RewriteResponse(REWRITE_DONE, t);
@@ -202,8 +205,9 @@ RewriteResponse ArithRewriter::postRewriteTerm(TNode t){
if(rat >= 0) {
return RewriteResponse(REWRITE_DONE, t[0]);
} else {
- return RewriteResponse(REWRITE_DONE,
- NodeManager::currentNM()->mkConst(-rat));
+ return RewriteResponse(
+ REWRITE_DONE,
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL, -rat));
}
}
return RewriteResponse(REWRITE_DONE, t);
@@ -211,7 +215,10 @@ RewriteResponse ArithRewriter::postRewriteTerm(TNode t){
case kind::CAST_TO_REAL: return RewriteResponse(REWRITE_DONE, t[0]);
case kind::TO_INTEGER:
if(t[0].isConst()) {
- return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(Rational(t[0].getConst<Rational>().floor())));
+ return RewriteResponse(
+ REWRITE_DONE,
+ NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL, Rational(t[0].getConst<Rational>().floor())));
}
if(t[0].getType().isInteger()) {
return RewriteResponse(REWRITE_DONE, t[0]);
@@ -403,10 +410,11 @@ RewriteResponse ArithRewriter::postRewritePow2(TNode t)
{
return RewriteResponse(
REWRITE_DONE,
- nm->mkConst<Rational>(Rational(Integer(0), Integer(1))));
+ nm->mkConst(CONST_RATIONAL, Rational(Integer(0), Integer(1))));
}
unsigned long k = i.getUnsignedLong();
- Node ret = nm->mkConst<Rational>(Rational(Integer(2).pow(k), Integer(1)));
+ Node ret =
+ nm->mkConst(CONST_RATIONAL, Rational(Integer(2).pow(k), Integer(1)));
return RewriteResponse(REWRITE_DONE, ret);
}
return RewriteResponse(REWRITE_DONE, t);
@@ -464,7 +472,7 @@ RewriteResponse ArithRewriter::postRewriteTranscendental(TNode t) {
switch( t.getKind() ){
case kind::EXPONENTIAL: {
if(t[0].getKind() == kind::CONST_RATIONAL){
- Node one = nm->mkConst(Rational(1));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
if(t[0].getConst<Rational>().sgn()>=0 && t[0].getType().isInteger() && t[0]!=one){
return RewriteResponse(
REWRITE_AGAIN,
@@ -491,12 +499,14 @@ RewriteResponse ArithRewriter::postRewriteTranscendental(TNode t) {
if(t[0].getKind() == kind::CONST_RATIONAL){
const Rational& rat = t[0].getConst<Rational>();
if(rat.sgn() == 0){
- return RewriteResponse(REWRITE_DONE, nm->mkConst(Rational(0)));
+ return RewriteResponse(REWRITE_DONE,
+ nm->mkConst(CONST_RATIONAL, Rational(0)));
}
else if (rat.sgn() == -1)
{
- Node ret =
- nm->mkNode(kind::UMINUS, nm->mkNode(kind::SINE, nm->mkConst(-rat)));
+ Node ret = nm->mkNode(
+ kind::UMINUS,
+ nm->mkNode(kind::SINE, nm->mkConst(CONST_RATIONAL, -rat)));
return RewriteResponse(REWRITE_AGAIN_FULL, ret);
}
}else{
@@ -612,7 +622,8 @@ RewriteResponse ArithRewriter::postRewriteTranscendental(TNode t) {
nm->mkNode(kind::SINE,
nm->mkNode(kind::MINUS,
nm->mkNode(kind::MULT,
- nm->mkConst(Rational(1) / Rational(2)),
+ nm->mkConst(CONST_RATIONAL,
+ Rational(1) / Rational(2)),
mkPi()),
t[0])));
}
@@ -672,7 +683,17 @@ RewriteResponse ArithRewriter::postRewriteAtom(TNode atom){
if(atom.getOperator().getConst<Divisible>().k.isOne()) {
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(true));
}
- return RewriteResponse(REWRITE_AGAIN, NodeManager::currentNM()->mkNode(kind::EQUAL, NodeManager::currentNM()->mkNode(kind::INTS_MODULUS_TOTAL, atom[0], NodeManager::currentNM()->mkConst(Rational(atom.getOperator().getConst<Divisible>().k))), NodeManager::currentNM()->mkConst(Rational(0))));
+ return RewriteResponse(
+ REWRITE_AGAIN,
+ NodeManager::currentNM()->mkNode(
+ kind::EQUAL,
+ NodeManager::currentNM()->mkNode(
+ kind::INTS_MODULUS_TOTAL,
+ atom[0],
+ NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL,
+ Rational(atom.getOperator().getConst<Divisible>().k))),
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0))));
}
// left |><| right
@@ -804,7 +825,7 @@ RewriteResponse ArithRewriter::rewriteIntsDivMod(TNode t, bool pre)
{
NodeManager* nm = NodeManager::currentNM();
Kind k = t.getKind();
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
if (k == kind::INTS_MODULUS)
{
if (t[1].isConst() && !t[1].getConst<Rational>().isZero())
@@ -857,7 +878,8 @@ RewriteResponse ArithRewriter::rewriteIntsDivModTotal(TNode t, bool pre)
// pull negation
// (div x (- c)) ---> (- (div x c))
// (mod x (- c)) ---> (mod x c)
- Node nn = nm->mkNode(k, t[0], nm->mkConst(-t[1].getConst<Rational>()));
+ Node nn = nm->mkNode(
+ k, t[0], nm->mkConst(CONST_RATIONAL, -t[1].getConst<Rational>()));
Node ret = (k == kind::INTS_DIVISION || k == kind::INTS_DIVISION_TOTAL)
? nm->mkNode(kind::UMINUS, nn)
: nn;
diff --git a/src/theory/arith/arith_utilities.cpp b/src/theory/arith/arith_utilities.cpp
index 5645542d0..a9fd97079 100644
--- a/src/theory/arith/arith_utilities.cpp
+++ b/src/theory/arith/arith_utilities.cpp
@@ -164,7 +164,7 @@ Node getApproximateConstant(Node c, bool isLower, unsigned prec)
curr_r = Rational(curr - 1) / den;
}
curr_r = curr_r * pow_ten;
- cret = nm->mkConst(csign == 1 ? curr_r : -curr_r);
+ cret = nm->mkConst(CONST_RATIONAL, csign == 1 ? curr_r : -curr_r);
}
else
{
diff --git a/src/theory/arith/arith_utilities.h b/src/theory/arith/arith_utilities.h
index 0d7f214d7..b926af2e0 100644
--- a/src/theory/arith/arith_utilities.h
+++ b/src/theory/arith/arith_utilities.h
@@ -44,7 +44,7 @@ typedef std::unordered_map<Node, ArithVar> NodeToArithVarMap;
typedef DenseMap<Node> ArithVarToNodeMap;
inline Node mkRationalNode(const Rational& q){
- return NodeManager::currentNM()->mkConst<Rational>(q);
+ return NodeManager::currentNM()->mkConst(kind::CONST_RATIONAL, q);
}
inline Node mkBoolNode(bool b){
diff --git a/src/theory/arith/bound_inference.cpp b/src/theory/arith/bound_inference.cpp
index 5824d8239..cd688660a 100644
--- a/src/theory/arith/bound_inference.cpp
+++ b/src/theory/arith/bound_inference.cpp
@@ -18,6 +18,8 @@
#include "theory/arith/normal_form.h"
#include "theory/rewriter.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -76,16 +78,20 @@ bool BoundInference::add(const Node& n, bool onlyVariables)
auto* nm = NodeManager::currentNM();
switch (relation)
{
- case Kind::LEQ: bound = nm->mkConst<Rational>(br.floor()); break;
+ case Kind::LEQ:
+ bound = nm->mkConst<Rational>(CONST_RATIONAL, br.floor());
+ break;
case Kind::LT:
- bound = nm->mkConst<Rational>((br - 1).ceiling());
+ bound = nm->mkConst<Rational>(CONST_RATIONAL, (br - 1).ceiling());
relation = Kind::LEQ;
break;
case Kind::GT:
- bound = nm->mkConst<Rational>((br + 1).floor());
+ bound = nm->mkConst<Rational>(CONST_RATIONAL, (br + 1).floor());
relation = Kind::GEQ;
break;
- case Kind::GEQ: bound = nm->mkConst<Rational>(br.ceiling()); break;
+ case Kind::GEQ:
+ bound = nm->mkConst<Rational>(CONST_RATIONAL, br.ceiling());
+ break;
default:;
}
Trace("bound-inf") << "Strengthened " << n << " to " << lhs << " "
diff --git a/src/theory/arith/congruence_manager.cpp b/src/theory/arith/congruence_manager.cpp
index ae782eed2..de68a4987 100644
--- a/src/theory/arith/congruence_manager.cpp
+++ b/src/theory/arith/congruence_manager.cpp
@@ -32,6 +32,8 @@
#include "theory/uf/equality_engine.h"
#include "theory/uf/proof_equality_engine.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -329,11 +331,12 @@ void ArithCongruenceManager::watchedVariableCannotBeZero(ConstraintCP c){
TNode isZero = d_watchedEqualities[s];
const auto isZeroPf = d_pnm->mkAssume(isZero);
const auto nm = NodeManager::currentNM();
- const auto sumPf = d_pnm->mkNode(
- PfRule::MACRO_ARITH_SCALE_SUM_UB,
- {isZeroPf, pf},
- // Trick for getting correct, opposing signs.
- {nm->mkConst(Rational(-1 * cSign)), nm->mkConst(Rational(cSign))});
+ const auto sumPf =
+ d_pnm->mkNode(PfRule::MACRO_ARITH_SCALE_SUM_UB,
+ {isZeroPf, pf},
+ // Trick for getting correct, opposing signs.
+ {nm->mkConst(CONST_RATIONAL, Rational(-1 * cSign)),
+ nm->mkConst(CONST_RATIONAL, Rational(cSign))});
const auto botPf = d_pnm->mkNode(
PfRule::MACRO_SR_PRED_TRANSFORM, {sumPf}, {nm->mkConst(false)});
std::vector<Node> assumption = {isZero};
diff --git a/src/theory/arith/constraint.cpp b/src/theory/arith/constraint.cpp
index 2958b5f48..cffacdc39 100644
--- a/src/theory/arith/constraint.cpp
+++ b/src/theory/arith/constraint.cpp
@@ -1122,10 +1122,11 @@ TrustNode Constraint::split()
auto nGeqPf = d_database->d_pnm->mkAssume(geqNode.negate());
auto ltPf = d_database->d_pnm->mkNode(
PfRule::MACRO_SR_PRED_TRANSFORM, {nGeqPf}, {ltNode});
- auto sumPf = d_database->d_pnm->mkNode(
- PfRule::MACRO_ARITH_SCALE_SUM_UB,
- {gtPf, ltPf},
- {nm->mkConst<Rational>(-1), nm->mkConst<Rational>(1)});
+ auto sumPf =
+ d_database->d_pnm->mkNode(PfRule::MACRO_ARITH_SCALE_SUM_UB,
+ {gtPf, ltPf},
+ {nm->mkConst(CONST_RATIONAL, Rational(-1)),
+ nm->mkConst(CONST_RATIONAL, Rational(1))});
auto botPf = d_database->d_pnm->mkNode(
PfRule::MACRO_SR_PRED_TRANSFORM, {sumPf}, {nm->mkConst(false)});
std::vector<Node> a = {leqNode.negate(), geqNode.negate()};
@@ -1808,7 +1809,7 @@ std::shared_ptr<ProofNode> Constraint::externalExplain(
std::vector<Node> farkasCoeffs;
for (Rational r : *getFarkasCoefficients())
{
- farkasCoeffs.push_back(nm->mkConst<Rational>(r));
+ farkasCoeffs.push_back(nm->mkConst(CONST_RATIONAL, Rational(r)));
}
// Apply the scaled-sum rule.
@@ -2088,7 +2089,8 @@ Node Constraint::getProofLiteral() const
default: Unreachable() << d_type;
}
NodeManager* nm = NodeManager::currentNM();
- Node constPart = nm->mkConst<Rational>(d_value.getNoninfinitesimalPart());
+ Node constPart =
+ nm->mkConst(CONST_RATIONAL, Rational(d_value.getNoninfinitesimalPart()));
Node posLit = nm->mkNode(cmp, varPart, constPart);
return neg ? posLit.negate() : posLit;
}
@@ -2112,13 +2114,13 @@ void ConstraintDatabase::proveOr(std::vector<TrustNode>& out,
{d_pnm->mkAssume(lb.negate())},
{b->getNegation()->getProofLiteral()});
int sndSign = negateSecond ? -1 : 1;
- auto bot_pf =
- d_pnm->mkNode(PfRule::MACRO_SR_PRED_TRANSFORM,
- {d_pnm->mkNode(PfRule::MACRO_ARITH_SCALE_SUM_UB,
- {pf_neg_la, pf_neg_lb},
- {nm->mkConst<Rational>(-1 * sndSign),
- nm->mkConst<Rational>(sndSign)})},
- {nm->mkConst(false)});
+ auto bot_pf = d_pnm->mkNode(
+ PfRule::MACRO_SR_PRED_TRANSFORM,
+ {d_pnm->mkNode(PfRule::MACRO_ARITH_SCALE_SUM_UB,
+ {pf_neg_la, pf_neg_lb},
+ {nm->mkConst(CONST_RATIONAL, Rational(-1 * sndSign)),
+ nm->mkConst(CONST_RATIONAL, Rational(sndSign))})},
+ {nm->mkConst(false)});
std::vector<Node> as;
std::transform(orN.begin(), orN.end(), std::back_inserter(as), [](Node n) {
return n.negate();
diff --git a/src/theory/arith/infer_bounds.cpp b/src/theory/arith/infer_bounds.cpp
index 4cbb8211d..aae9bae62 100644
--- a/src/theory/arith/infer_bounds.cpp
+++ b/src/theory/arith/infer_bounds.cpp
@@ -19,6 +19,8 @@
#include "theory/arith/infer_bounds.h"
#include "theory/rewriter.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -149,7 +151,7 @@ Node InferBoundsResult::getTerm() const { return d_term; }
Node InferBoundsResult::getLiteral() const{
const Rational& q = getValue().getNoninfinitesimalPart();
NodeManager* nm = NodeManager::currentNM();
- Node qnode = nm->mkConst(q);
+ Node qnode = nm->mkConst(CONST_RATIONAL, q);
Kind k;
if(d_upperBound){
diff --git a/src/theory/arith/kinds b/src/theory/arith/kinds
index 0c93db90f..0f3e345ee 100644
--- a/src/theory/arith/kinds
+++ b/src/theory/arith/kinds
@@ -54,19 +54,19 @@ constant DIVISIBLE_OP \
sort REAL_TYPE \
Cardinality::REALS \
well-founded \
- "NodeManager::currentNM()->mkConst(Rational(0))" \
+ "NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0))" \
"expr/node_manager.h" \
"real type"
sort INTEGER_TYPE \
Cardinality::INTEGERS \
well-founded \
- "NodeManager::currentNM()->mkConst(Rational(0))" \
+ "NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0))" \
"expr/node_manager.h" \
"integer type"
constant CONST_RATIONAL \
class \
- Rational \
+ Rational+ \
::cvc5::RationalHashFunction \
"util/rational.h" \
"a multiple-precision rational constant; payload is an instance of the cvc5::Rational class"
diff --git a/src/theory/arith/nl/cad/cdcac.cpp b/src/theory/arith/nl/cad/cdcac.cpp
index 4a2709cf8..0c61c088a 100644
--- a/src/theory/arith/nl/cad/cdcac.cpp
+++ b/src/theory/arith/nl/cad/cdcac.cpp
@@ -25,6 +25,8 @@
#include "theory/arith/nl/nl_model.h"
#include "theory/rewriter.h"
+using namespace cvc5::kind;
+
namespace std {
/** Generic streaming operator for std::vector. */
template <typename T>
@@ -271,7 +273,7 @@ PolyVector requiredCoefficientsLazardModified(
// construct phi := (and (= p_i 0)) with p_i the coefficients of p
std::vector<Node> conditions;
- auto zero = NodeManager::currentNM()->mkConst(Rational(0));
+ auto zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
for (const auto& coeff : poly::coefficients(p))
{
conditions.emplace_back(NodeManager::currentNM()->mkNode(
diff --git a/src/theory/arith/nl/cad/proof_generator.cpp b/src/theory/arith/nl/cad/proof_generator.cpp
index b56c2755a..fcc07cbf0 100644
--- a/src/theory/arith/nl/cad/proof_generator.cpp
+++ b/src/theory/arith/nl/cad/proof_generator.cpp
@@ -21,6 +21,8 @@
#include "theory/arith/nl/poly_conversion.h"
#include "util/indexed_root_predicate.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -94,7 +96,7 @@ CADProofGenerator::CADProofGenerator(context::Context* ctx,
: d_pnm(pnm), d_proofs(pnm, ctx), d_current(nullptr)
{
d_false = NodeManager::currentNM()->mkConst<bool>(false);
- d_zero = NodeManager::currentNM()->mkConst<Rational>(0);
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
}
void CADProofGenerator::startNewProof()
diff --git a/src/theory/arith/nl/ext/ext_state.cpp b/src/theory/arith/nl/ext/ext_state.cpp
index b196f9990..172d09f31 100644
--- a/src/theory/arith/nl/ext/ext_state.cpp
+++ b/src/theory/arith/nl/ext/ext_state.cpp
@@ -25,6 +25,8 @@
#include "theory/arith/nl/nl_model.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -35,9 +37,9 @@ ExtState::ExtState(InferenceManager& im, NlModel& model, Env& env)
{
d_false = NodeManager::currentNM()->mkConst(false);
d_true = NodeManager::currentNM()->mkConst(true);
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
- d_one = NodeManager::currentNM()->mkConst(Rational(1));
- d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
+ d_neg_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(-1));
if (d_env.isTheoryProofProducing())
{
d_proof.reset(new CDProofSet<CDProof>(
diff --git a/src/theory/arith/nl/ext/factoring_check.cpp b/src/theory/arith/nl/ext/factoring_check.cpp
index e41639c58..06d6aeaab 100644
--- a/src/theory/arith/nl/ext/factoring_check.cpp
+++ b/src/theory/arith/nl/ext/factoring_check.cpp
@@ -25,6 +25,8 @@
#include "theory/rewriter.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -33,8 +35,8 @@ namespace nl {
FactoringCheck::FactoringCheck(Env& env, ExtState* data)
: EnvObj(env), d_data(data)
{
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
- d_one = NodeManager::currentNM()->mkConst(Rational(1));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
}
void FactoringCheck::check(const std::vector<Node>& asserts,
diff --git a/src/theory/arith/nl/ext/monomial.cpp b/src/theory/arith/nl/ext/monomial.cpp
index c969fe0e7..83d0ff71f 100644
--- a/src/theory/arith/nl/ext/monomial.cpp
+++ b/src/theory/arith/nl/ext/monomial.cpp
@@ -124,7 +124,7 @@ void MonomialIndex::addTerm(Node n,
MonomialDb::MonomialDb()
{
- d_one = NodeManager::currentNM()->mkConst(Rational(1));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
}
void MonomialDb::registerMonomial(Node n)
diff --git a/src/theory/arith/nl/ext/monomial_bounds_check.cpp b/src/theory/arith/nl/ext/monomial_bounds_check.cpp
index 1f50b3112..e97f8b772 100644
--- a/src/theory/arith/nl/ext/monomial_bounds_check.cpp
+++ b/src/theory/arith/nl/ext/monomial_bounds_check.cpp
@@ -25,6 +25,8 @@
#include "theory/arith/nl/nl_model.h"
#include "theory/rewriter.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -361,11 +363,11 @@ void MonomialBoundsCheck::checkBounds(const std::vector<Node>& asserts,
proof->addStep(exp[1][0],
PfRule::AND_ELIM,
{exp[1]},
- {nm->mkConst(Rational(0))});
+ {nm->mkConst(CONST_RATIONAL, Rational(0))});
proof->addStep(exp[1][1],
PfRule::AND_ELIM,
{exp[1]},
- {nm->mkConst(Rational(1))});
+ {nm->mkConst(CONST_RATIONAL, Rational(1))});
Node lb = nm->mkNode(Kind::GEQ, simpleeq[0], simpleeq[1]);
Node rb = nm->mkNode(Kind::LEQ, simpleeq[0], simpleeq[1]);
if (rew->rewrite(lb) == rew->rewrite(exp[1][0]))
diff --git a/src/theory/arith/nl/ext/proof_checker.cpp b/src/theory/arith/nl/ext/proof_checker.cpp
index 67679d7a6..7acee487d 100644
--- a/src/theory/arith/nl/ext/proof_checker.cpp
+++ b/src/theory/arith/nl/ext/proof_checker.cpp
@@ -37,9 +37,9 @@ Node ExtProofRuleChecker::checkInternal(PfRule id,
const std::vector<Node>& args)
{
NodeManager* nm = NodeManager::currentNM();
- auto zero = nm->mkConst<Rational>(0);
- auto one = nm->mkConst<Rational>(1);
- auto mone = nm->mkConst<Rational>(-1);
+ auto zero = nm->mkConst<Rational>(CONST_RATIONAL, 0);
+ auto one = nm->mkConst<Rational>(CONST_RATIONAL, 1);
+ auto mone = nm->mkConst<Rational>(CONST_RATIONAL, -1);
auto pi = nm->mkNullaryOperator(nm->realType(), Kind::PI);
auto mpi = nm->mkNode(Kind::MULT, mone, pi);
Trace("nl-ext-checker") << "Checking " << id << std::endl;
diff --git a/src/theory/arith/nl/ext/tangent_plane_check.cpp b/src/theory/arith/nl/ext/tangent_plane_check.cpp
index ebdca33dd..fbf8caf6a 100644
--- a/src/theory/arith/nl/ext/tangent_plane_check.cpp
+++ b/src/theory/arith/nl/ext/tangent_plane_check.cpp
@@ -24,6 +24,8 @@
#include "theory/rewriter.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -144,15 +146,16 @@ void TangentPlaneCheck::check(bool asWaitingLemmas)
if (d_data->isProofEnabled())
{
proof = d_data->getProof();
- proof->addStep(tlem,
- PfRule::ARITH_MULT_TANGENT,
- {},
- {t,
- a,
- b,
- a_v,
- b_v,
- nm->mkConst(Rational(d == 0 ? -1 : 1))});
+ proof->addStep(
+ tlem,
+ PfRule::ARITH_MULT_TANGENT,
+ {},
+ {t,
+ a,
+ b,
+ a_v,
+ b_v,
+ nm->mkConst(CONST_RATIONAL, Rational(d == 0 ? -1 : 1))});
}
d_data->d_im.addPendingLemma(tlem,
InferenceId::ARITH_NL_TANGENT_PLANE,
diff --git a/src/theory/arith/nl/ext_theory_callback.cpp b/src/theory/arith/nl/ext_theory_callback.cpp
index 02914f938..f2a4aa2e3 100644
--- a/src/theory/arith/nl/ext_theory_callback.cpp
+++ b/src/theory/arith/nl/ext_theory_callback.cpp
@@ -27,7 +27,7 @@ namespace nl {
NlExtTheoryCallback::NlExtTheoryCallback(eq::EqualityEngine* ee) : d_ee(ee)
{
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
}
bool NlExtTheoryCallback::getCurrentSubstitution(
diff --git a/src/theory/arith/nl/iand_solver.cpp b/src/theory/arith/nl/iand_solver.cpp
index b773f6baf..5d4862307 100644
--- a/src/theory/arith/nl/iand_solver.cpp
+++ b/src/theory/arith/nl/iand_solver.cpp
@@ -47,9 +47,9 @@ IAndSolver::IAndSolver(Env& env,
NodeManager* nm = NodeManager::currentNM();
d_false = nm->mkConst(false);
d_true = nm->mkConst(true);
- d_zero = nm->mkConst(Rational(0));
- d_one = nm->mkConst(Rational(1));
- d_two = nm->mkConst(Rational(2));
+ d_zero = nm->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = nm->mkConst(CONST_RATIONAL, Rational(1));
+ d_two = nm->mkConst(CONST_RATIONAL, Rational(2));
}
IAndSolver::~IAndSolver() {}
diff --git a/src/theory/arith/nl/iand_utils.cpp b/src/theory/arith/nl/iand_utils.cpp
index 45881e1bb..50e03bfa5 100644
--- a/src/theory/arith/nl/iand_utils.cpp
+++ b/src/theory/arith/nl/iand_utils.cpp
@@ -22,6 +22,8 @@
#include "theory/rewriter.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -36,7 +38,7 @@ Node pow2(uint64_t k)
{
Assert(k >= 0);
NodeManager* nm = NodeManager::currentNM();
- return nm->mkConst<Rational>(intpow2(k));
+ return nm->mkConst(CONST_RATIONAL, Rational(intpow2(k)));
}
bool oneBitAnd(bool a, bool b) { return (a && b); }
@@ -58,9 +60,9 @@ Node intExtract(Node x, uint64_t i, uint64_t size)
IAndUtils::IAndUtils()
{
NodeManager* nm = NodeManager::currentNM();
- d_zero = nm->mkConst(Rational(0));
- d_one = nm->mkConst(Rational(1));
- d_two = nm->mkConst(Rational(2));
+ d_zero = nm->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = nm->mkConst(CONST_RATIONAL, Rational(1));
+ d_two = nm->mkConst(CONST_RATIONAL, Rational(2));
}
Node IAndUtils::createITEFromTable(
@@ -78,7 +80,8 @@ Node IAndUtils::createITEFromTable(
Assert(table.size() == 1 + ((uint64_t)(num_of_values * num_of_values)));
// start with the default, most common value.
// this value is represented in the table by (-1, -1).
- Node ite = nm->mkConst<Rational>(table.at(std::make_pair(-1, -1)));
+ Node ite =
+ nm->mkConst(CONST_RATIONAL, Rational(table.at(std::make_pair(-1, -1))));
for (uint64_t i = 0; i < num_of_values; i++)
{
for (uint64_t j = 0; j < num_of_values; j++)
@@ -91,10 +94,13 @@ Node IAndUtils::createITEFromTable(
// append the current value to the ite.
ite = nm->mkNode(
kind::ITE,
- nm->mkNode(kind::AND,
- nm->mkNode(kind::EQUAL, x, nm->mkConst<Rational>(i)),
- nm->mkNode(kind::EQUAL, y, nm->mkConst<Rational>(j))),
- nm->mkConst<Rational>(table.at(std::make_pair(i, j))),
+ nm->mkNode(
+ kind::AND,
+ nm->mkNode(
+ kind::EQUAL, x, nm->mkConst(CONST_RATIONAL, Rational(i))),
+ nm->mkNode(
+ kind::EQUAL, y, nm->mkConst(CONST_RATIONAL, Rational(j)))),
+ nm->mkConst(CONST_RATIONAL, Rational(table.at(std::make_pair(i, j)))),
ite);
}
}
@@ -133,7 +139,7 @@ Node IAndUtils::createSumNode(Node x,
// number of elements in the sum expression
uint64_t sumSize = bvsize / granularity;
// initialize the sum
- Node sumNode = nm->mkConst<Rational>(0);
+ Node sumNode = nm->mkConst(CONST_RATIONAL, Rational(0));
// compute the table for the current granularity if needed
if (d_bvandTable.find(granularity) == d_bvandTable.end())
{
@@ -260,7 +266,8 @@ Node IAndUtils::twoToK(unsigned k) const
{
// could be faster
NodeManager* nm = NodeManager::currentNM();
- Node ret = nm->mkNode(kind::POW, d_two, nm->mkConst(Rational(k)));
+ Node ret =
+ nm->mkNode(kind::POW, d_two, nm->mkConst(CONST_RATIONAL, Rational(k)));
ret = Rewriter::rewrite(ret);
return ret;
}
diff --git a/src/theory/arith/nl/nl_model.cpp b/src/theory/arith/nl/nl_model.cpp
index 77a3ea530..8d06f41d0 100644
--- a/src/theory/arith/nl/nl_model.cpp
+++ b/src/theory/arith/nl/nl_model.cpp
@@ -36,9 +36,9 @@ NlModel::NlModel() : d_used_approx(false)
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
- d_one = NodeManager::currentNM()->mkConst(Rational(1));
- d_two = NodeManager::currentNM()->mkConst(Rational(2));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
+ d_two = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(2));
}
NlModel::~NlModel() {}
@@ -538,7 +538,8 @@ bool NlModel::solveEqualitySimple(Node eq,
Assert(false);
return false;
}
- Node val = nm->mkConst(-c.getConst<Rational>() / b.getConst<Rational>());
+ Node val = nm->mkConst(CONST_RATIONAL,
+ -c.getConst<Rational>() / b.getConst<Rational>());
if (Trace.isOn("nl-ext-cm"))
{
Trace("nl-ext-cm") << "check-model-bound : exact : " << var << " = ";
@@ -1069,8 +1070,9 @@ void NlModel::getModelValueRepair(
if (witnessToValue)
{
// witness is the midpoint
- witness = nm->mkNode(
- MULT, nm->mkConst(Rational(1, 2)), nm->mkNode(PLUS, l, u));
+ witness = nm->mkNode(MULT,
+ nm->mkConst(CONST_RATIONAL, Rational(1, 2)),
+ nm->mkNode(PLUS, l, u));
witness = Rewriter::rewrite(witness);
Trace("nl-model") << v << " witness is " << witness << std::endl;
}
diff --git a/src/theory/arith/nl/nonlinear_extension.cpp b/src/theory/arith/nl/nonlinear_extension.cpp
index 56bdd652a..e75741096 100644
--- a/src/theory/arith/nl/nonlinear_extension.cpp
+++ b/src/theory/arith/nl/nonlinear_extension.cpp
@@ -68,9 +68,9 @@ NonlinearExtension::NonlinearExtension(Env& env,
d_extTheory.addFunctionKind(kind::IAND);
d_extTheory.addFunctionKind(kind::POW2);
d_true = NodeManager::currentNM()->mkConst(true);
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
- d_one = NodeManager::currentNM()->mkConst(Rational(1));
- d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
+ d_neg_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(-1));
if (d_env.isTheoryProofProducing())
{
diff --git a/src/theory/arith/nl/poly_conversion.cpp b/src/theory/arith/nl/poly_conversion.cpp
index 7fbe08b9f..ebe76e018 100644
--- a/src/theory/arith/nl/poly_conversion.cpp
+++ b/src/theory/arith/nl/poly_conversion.cpp
@@ -22,6 +22,8 @@
#include "theory/arith/bound_inference.h"
#include "util/poly_util.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -70,13 +72,14 @@ cvc5::Node as_cvc_upolynomial(const poly::UPolynomial& p, const cvc5::Node& var)
auto* nm = NodeManager::currentNM();
- Node res = nm->mkConst(Rational(0));
- Node monomial = nm->mkConst(Rational(1));
+ Node res = nm->mkConst(CONST_RATIONAL, Rational(0));
+ Node monomial = nm->mkConst(CONST_RATIONAL, Rational(1));
for (std::size_t i = 0, n = coeffs.size(); i < n; ++i)
{
if (!is_zero(coeffs[i]))
{
- Node coeff = nm->mkConst(poly_utils::toRational(coeffs[i]));
+ Node coeff =
+ nm->mkConst(CONST_RATIONAL, poly_utils::toRational(coeffs[i]));
Node term = nm->mkNode(Kind::MULT, coeff, monomial);
res = nm->mkNode(Kind::PLUS, res, term);
}
@@ -235,15 +238,15 @@ void collect_monomials(const lp_polynomial_context_t* ctx,
{
CollectMonomialData* d = static_cast<CollectMonomialData*>(data);
// constant
- Node term =
- d->d_nm->mkConst<Rational>(poly_utils::toRational(poly::Integer(&m->a)));
+ Node term = d->d_nm->mkConst<Rational>(
+ CONST_RATIONAL, poly_utils::toRational(poly::Integer(&m->a)));
for (std::size_t i = 0; i < m->n; ++i)
{
// variable exponent pair
Node var = d->d_vm(m->p[i].x);
if (m->p[i].d > 1)
{
- Node exp = d->d_nm->mkConst<Rational>(m->p[i].d);
+ Node exp = d->d_nm->mkConst<Rational>(CONST_RATIONAL, m->p[i].d);
term = d->d_nm->mkNode(
Kind::NONLINEAR_MULT, term, d->d_nm->mkNode(Kind::POW, var, exp));
}
@@ -264,7 +267,7 @@ cvc5::Node as_cvc_polynomial(const poly::Polynomial& p, VariableMapper& vm)
if (cmd.d_terms.empty())
{
- return cmd.d_nm->mkConst<Rational>(0);
+ return cmd.d_nm->mkConst<Rational>(CONST_RATIONAL, 0);
}
if (cmd.d_terms.size() == 1)
{
@@ -371,23 +374,26 @@ Node ran_to_node(const poly::AlgebraicNumber& an, const Node& ran_variable)
const poly::DyadicInterval& di = get_isolating_interval(an);
if (is_point(di))
{
- return nm->mkConst(poly_utils::toRational(get_point(di)));
+ return nm->mkConst(CONST_RATIONAL, poly_utils::toRational(get_point(di)));
}
Assert(di.get_internal()->a_open && di.get_internal()->b_open)
<< "We assume an open interval here.";
Node poly = as_cvc_upolynomial(get_defining_polynomial(an), ran_variable);
- Node lower = nm->mkConst(poly_utils::toRational(get_lower(di)));
- Node upper = nm->mkConst(poly_utils::toRational(get_upper(di)));
+ Node lower =
+ nm->mkConst(CONST_RATIONAL, poly_utils::toRational(get_lower(di)));
+ Node upper =
+ nm->mkConst(CONST_RATIONAL, poly_utils::toRational(get_upper(di)));
// Construct witness:
- return nm->mkNode(Kind::AND,
- // poly(var) == 0
- nm->mkNode(Kind::EQUAL, poly, nm->mkConst(Rational(0))),
- // lower_bound < var
- nm->mkNode(Kind::LT, lower, ran_variable),
- // var < upper_bound
- nm->mkNode(Kind::LT, ran_variable, upper));
+ return nm->mkNode(
+ Kind::AND,
+ // poly(var) == 0
+ nm->mkNode(Kind::EQUAL, poly, nm->mkConst(CONST_RATIONAL, Rational(0))),
+ // lower_bound < var
+ nm->mkNode(Kind::LT, lower, ran_variable),
+ // var < upper_bound
+ nm->mkNode(Kind::LT, ran_variable, upper));
}
Node value_to_node(const poly::Value& v, const Node& ran_variable)
@@ -403,18 +409,19 @@ Node value_to_node(const poly::Value& v, const Node& ran_variable)
auto* nm = NodeManager::currentNM();
if (is_dyadic_rational(v))
{
- return nm->mkConst(poly_utils::toRational(as_dyadic_rational(v)));
+ return nm->mkConst(CONST_RATIONAL,
+ poly_utils::toRational(as_dyadic_rational(v)));
}
if (is_integer(v))
{
- return nm->mkConst(poly_utils::toRational(as_integer(v)));
+ return nm->mkConst(CONST_RATIONAL, poly_utils::toRational(as_integer(v)));
}
if (is_rational(v))
{
- return nm->mkConst(poly_utils::toRational(as_rational(v)));
+ return nm->mkConst(CONST_RATIONAL, poly_utils::toRational(as_rational(v)));
}
Assert(false) << "All cases should be covered.";
- return nm->mkConst(Rational(0));
+ return nm->mkConst(CONST_RATIONAL, Rational(0));
}
Node lower_bound_as_node(const Node& var,
@@ -425,16 +432,18 @@ Node lower_bound_as_node(const Node& var,
auto* nm = NodeManager::currentNM();
if (!poly::is_algebraic_number(lower))
{
- return nm->mkNode(open ? Kind::LEQ : Kind::LT,
- var,
- nm->mkConst(poly_utils::toRationalAbove(lower)));
+ return nm->mkNode(
+ open ? Kind::LEQ : Kind::LT,
+ var,
+ nm->mkConst(CONST_RATIONAL, poly_utils::toRationalAbove(lower)));
}
if (poly::represents_rational(lower))
{
return nm->mkNode(
open ? Kind::LEQ : Kind::LT,
var,
- nm->mkConst(poly_utils::toRationalAbove(poly::get_rational(lower))));
+ nm->mkConst(CONST_RATIONAL,
+ poly_utils::toRationalAbove(poly::get_rational(lower))));
}
if (!allowNonlinearLemma)
{
@@ -469,10 +478,12 @@ Node lower_bound_as_node(const Node& var,
}
return nm->mkNode(
Kind::OR,
- nm->mkNode(Kind::LEQ, var, nm->mkConst(l)),
- nm->mkNode(Kind::AND,
- nm->mkNode(Kind::LT, var, nm->mkConst(u)),
- nm->mkNode(relation, poly, nm->mkConst(Rational(0)))));
+ nm->mkNode(Kind::LEQ, var, nm->mkConst(CONST_RATIONAL, l)),
+ nm->mkNode(
+ Kind::AND,
+ nm->mkNode(Kind::LT, var, nm->mkConst(CONST_RATIONAL, u)),
+ nm->mkNode(
+ relation, poly, nm->mkConst(CONST_RATIONAL, Rational(0)))));
}
Node upper_bound_as_node(const Node& var,
@@ -483,16 +494,18 @@ Node upper_bound_as_node(const Node& var,
auto* nm = NodeManager::currentNM();
if (!poly::is_algebraic_number(upper))
{
- return nm->mkNode(open ? Kind::GEQ : Kind::GT,
- var,
- nm->mkConst(poly_utils::toRationalAbove(upper)));
+ return nm->mkNode(
+ open ? Kind::GEQ : Kind::GT,
+ var,
+ nm->mkConst(CONST_RATIONAL, poly_utils::toRationalAbove(upper)));
}
if (poly::represents_rational(upper))
{
return nm->mkNode(
open ? Kind::GEQ : Kind::GT,
var,
- nm->mkConst(poly_utils::toRationalAbove(poly::get_rational(upper))));
+ nm->mkConst(CONST_RATIONAL,
+ poly_utils::toRationalAbove(poly::get_rational(upper))));
}
if (!allowNonlinearLemma)
{
@@ -527,10 +540,12 @@ Node upper_bound_as_node(const Node& var,
}
return nm->mkNode(
Kind::OR,
- nm->mkNode(Kind::GEQ, var, nm->mkConst(u)),
- nm->mkNode(Kind::AND,
- nm->mkNode(Kind::GT, var, nm->mkConst(l)),
- nm->mkNode(relation, poly, nm->mkConst(Rational(0)))));
+ nm->mkNode(Kind::GEQ, var, nm->mkConst(CONST_RATIONAL, u)),
+ nm->mkNode(
+ Kind::AND,
+ nm->mkNode(Kind::GT, var, nm->mkConst(CONST_RATIONAL, l)),
+ nm->mkNode(
+ relation, poly, nm->mkConst(CONST_RATIONAL, Rational(0)))));
}
Node excluding_interval_to_lemma(const Node& variable,
@@ -552,10 +567,12 @@ Node excluding_interval_to_lemma(const Node& variable,
if (poly::is_rational(alg))
{
Trace("nl-cad") << "Rational point interval: " << interval << std::endl;
- return nm->mkNode(Kind::DISTINCT,
- variable,
- nm->mkConst(poly_utils::toRational(
- poly::to_rational_approximation(alg))));
+ return nm->mkNode(
+ Kind::DISTINCT,
+ variable,
+ nm->mkConst(
+ CONST_RATIONAL,
+ poly_utils::toRational(poly::to_rational_approximation(alg))));
}
Trace("nl-cad") << "Algebraic point interval: " << interval << std::endl;
// p(x) != 0 or x <= lb or ub <= x
@@ -564,22 +581,26 @@ Node excluding_interval_to_lemma(const Node& variable,
Node poly = as_cvc_upolynomial(get_defining_polynomial(alg), variable);
return nm->mkNode(
Kind::OR,
- nm->mkNode(Kind::DISTINCT, poly, nm->mkConst(Rational(0))),
- nm->mkNode(Kind::LT,
- variable,
- nm->mkConst(poly_utils::toRationalBelow(lv))),
- nm->mkNode(Kind::GT,
- variable,
- nm->mkConst(poly_utils::toRationalAbove(lv))));
+ nm->mkNode(
+ Kind::DISTINCT, poly, nm->mkConst(CONST_RATIONAL, Rational(0))),
+ nm->mkNode(
+ Kind::LT,
+ variable,
+ nm->mkConst(CONST_RATIONAL, poly_utils::toRationalBelow(lv))),
+ nm->mkNode(
+ Kind::GT,
+ variable,
+ nm->mkConst(CONST_RATIONAL, poly_utils::toRationalAbove(lv))));
}
return Node();
}
else
{
Trace("nl-cad") << "Rational point interval: " << interval << std::endl;
- return nm->mkNode(Kind::DISTINCT,
- variable,
- nm->mkConst(poly_utils::toRationalBelow(lv)));
+ return nm->mkNode(
+ Kind::DISTINCT,
+ variable,
+ nm->mkConst(CONST_RATIONAL, poly_utils::toRationalBelow(lv)));
}
}
if (li)
diff --git a/src/theory/arith/nl/pow2_solver.cpp b/src/theory/arith/nl/pow2_solver.cpp
index c91284be7..e3a26397e 100644
--- a/src/theory/arith/nl/pow2_solver.cpp
+++ b/src/theory/arith/nl/pow2_solver.cpp
@@ -42,9 +42,9 @@ Pow2Solver::Pow2Solver(Env& env,
NodeManager* nm = NodeManager::currentNM();
d_false = nm->mkConst(false);
d_true = nm->mkConst(true);
- d_zero = nm->mkConst(Rational(0));
- d_one = nm->mkConst(Rational(1));
- d_two = nm->mkConst(Rational(2));
+ d_zero = nm->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = nm->mkConst(CONST_RATIONAL, Rational(1));
+ d_two = nm->mkConst(CONST_RATIONAL, Rational(2));
}
Pow2Solver::~Pow2Solver() {}
diff --git a/src/theory/arith/nl/transcendental/exponential_solver.cpp b/src/theory/arith/nl/transcendental/exponential_solver.cpp
index 17b5d259c..c4f7f6ca9 100644
--- a/src/theory/arith/nl/transcendental/exponential_solver.cpp
+++ b/src/theory/arith/nl/transcendental/exponential_solver.cpp
@@ -29,6 +29,8 @@
#include "theory/arith/nl/transcendental/transcendental_state.h"
#include "theory/rewriter.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -228,7 +230,7 @@ void ExponentialSolver::doTangentLemma(TNode e,
proof->addStep(lem,
PfRule::ARITH_TRANS_EXP_APPROX_BELOW,
{},
- {nm->mkConst<Rational>(d), e[0]});
+ {nm->mkConst(CONST_RATIONAL, Rational(d)), e[0]});
}
d_data->d_im.addPendingLemma(
lem, InferenceId::ARITH_NL_T_TANGENT, proof, true);
diff --git a/src/theory/arith/nl/transcendental/proof_checker.cpp b/src/theory/arith/nl/transcendental/proof_checker.cpp
index ca62fe394..ca1afb9f6 100644
--- a/src/theory/arith/nl/transcendental/proof_checker.cpp
+++ b/src/theory/arith/nl/transcendental/proof_checker.cpp
@@ -83,9 +83,9 @@ Node TranscendentalProofRuleChecker::checkInternal(
PfRule id, const std::vector<Node>& children, const std::vector<Node>& args)
{
NodeManager* nm = NodeManager::currentNM();
- auto zero = nm->mkConst<Rational>(0);
- auto one = nm->mkConst<Rational>(1);
- auto mone = nm->mkConst<Rational>(-1);
+ auto zero = nm->mkConst<Rational>(CONST_RATIONAL, 0);
+ auto one = nm->mkConst<Rational>(CONST_RATIONAL, 1);
+ auto mone = nm->mkConst<Rational>(CONST_RATIONAL, -1);
auto pi = nm->mkNullaryOperator(nm->realType(), Kind::PI);
auto mpi = nm->mkNode(Kind::MULT, mone, pi);
Trace("nl-trans-checker") << "Checking " << id << std::endl;
@@ -237,10 +237,13 @@ Node TranscendentalProofRuleChecker::checkInternal(
nm->mkNode(Kind::LEQ, x, pi),
}),
x.eqNode(y),
- x.eqNode(nm->mkNode(
- Kind::PLUS,
- y,
- nm->mkNode(Kind::MULT, nm->mkConst<Rational>(2), s, pi)))),
+ x.eqNode(
+ nm->mkNode(Kind::PLUS,
+ y,
+ nm->mkNode(Kind::MULT,
+ nm->mkConst<Rational>(CONST_RATIONAL, 2),
+ s,
+ pi)))),
nm->mkNode(Kind::SINE, y).eqNode(nm->mkNode(Kind::SINE, x))});
}
else if (id == PfRule::ARITH_TRANS_SINE_SYMMETRY)
diff --git a/src/theory/arith/nl/transcendental/sine_solver.cpp b/src/theory/arith/nl/transcendental/sine_solver.cpp
index ed37ee91c..b6b5c92c1 100644
--- a/src/theory/arith/nl/transcendental/sine_solver.cpp
+++ b/src/theory/arith/nl/transcendental/sine_solver.cpp
@@ -30,6 +30,8 @@
#include "theory/arith/nl/transcendental/transcendental_state.h"
#include "theory/rewriter.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -73,12 +75,13 @@ void SineSolver::doPhaseShift(TNode a, TNode new_a, TNode y)
nm->mkNode(Kind::ITE,
mkValidPhase(a[0], d_data->d_pi),
a[0].eqNode(y),
- a[0].eqNode(nm->mkNode(Kind::PLUS,
- y,
- nm->mkNode(Kind::MULT,
- nm->mkConst(Rational(2)),
- shift,
- d_data->d_pi)))),
+ a[0].eqNode(nm->mkNode(
+ Kind::PLUS,
+ y,
+ nm->mkNode(Kind::MULT,
+ nm->mkConst(CONST_RATIONAL, Rational(2)),
+ shift,
+ d_data->d_pi)))),
new_a.eqNode(a));
CDProof* proof = nullptr;
if (d_data->isProofEnabled())
@@ -399,7 +402,7 @@ void SineSolver::doTangentLemma(
proof->addStep(lem,
PfRule::ARITH_TRANS_SINE_APPROX_BELOW_NEG,
{},
- {nm->mkConst<Rational>(2 * d),
+ {nm->mkConst(CONST_RATIONAL, Rational(2 * d)),
e[0],
c,
regionToLowerBound(region),
@@ -410,7 +413,7 @@ void SineSolver::doTangentLemma(
proof->addStep(lem,
PfRule::ARITH_TRANS_SINE_APPROX_BELOW_NEG,
{},
- {nm->mkConst<Rational>(2 * d),
+ {nm->mkConst(CONST_RATIONAL, Rational(2 * d)),
e[0],
c,
c,
@@ -424,7 +427,7 @@ void SineSolver::doTangentLemma(
proof->addStep(lem,
PfRule::ARITH_TRANS_SINE_APPROX_ABOVE_POS,
{},
- {nm->mkConst<Rational>(2 * d),
+ {nm->mkConst(CONST_RATIONAL, Rational(2 * d)),
e[0],
c,
regionToLowerBound(region),
@@ -435,7 +438,7 @@ void SineSolver::doTangentLemma(
proof->addStep(lem,
PfRule::ARITH_TRANS_SINE_APPROX_ABOVE_POS,
{},
- {nm->mkConst<Rational>(2 * d),
+ {nm->mkConst(CONST_RATIONAL, Rational(2 * d)),
e[0],
c,
c,
diff --git a/src/theory/arith/nl/transcendental/taylor_generator.cpp b/src/theory/arith/nl/transcendental/taylor_generator.cpp
index d64eb8f19..2a231bc2b 100644
--- a/src/theory/arith/nl/transcendental/taylor_generator.cpp
+++ b/src/theory/arith/nl/transcendental/taylor_generator.cpp
@@ -19,6 +19,8 @@
#include "theory/arith/nl/nl_model.h"
#include "theory/rewriter.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -48,7 +50,7 @@ std::pair<Node, Node> TaylorGenerator::getTaylor(Kind k, std::uint64_t n)
// the current factorial `counter!`
Integer factorial = 1;
// the current variable power `x^counter`
- Node varpow = nm->mkConst(Rational(1));
+ Node varpow = nm->mkConst(CONST_RATIONAL, Rational(1));
std::vector<Node> sum;
for (std::uint64_t counter = 1; counter <= n; ++counter)
{
@@ -57,7 +59,9 @@ std::pair<Node, Node> TaylorGenerator::getTaylor(Kind k, std::uint64_t n)
// Maclaurin series for exponential:
// \sum_{n=0}^\infty x^n / n!
sum.push_back(
- nm->mkNode(Kind::DIVISION, varpow, nm->mkConst<Rational>(factorial)));
+ nm->mkNode(Kind::DIVISION,
+ varpow,
+ nm->mkConst<Rational>(CONST_RATIONAL, factorial)));
}
else if (k == Kind::SINE)
{
@@ -66,11 +70,12 @@ std::pair<Node, Node> TaylorGenerator::getTaylor(Kind k, std::uint64_t n)
if (counter % 2 == 0)
{
int sign = (counter % 4 == 0 ? -1 : 1);
- sum.push_back(nm->mkNode(Kind::MULT,
- nm->mkNode(Kind::DIVISION,
- nm->mkConst<Rational>(sign),
- nm->mkConst<Rational>(factorial)),
- varpow));
+ sum.push_back(nm->mkNode(
+ Kind::MULT,
+ nm->mkNode(Kind::DIVISION,
+ nm->mkConst<Rational>(CONST_RATIONAL, sign),
+ nm->mkConst<Rational>(CONST_RATIONAL, factorial)),
+ varpow));
}
}
factorial *= counter;
@@ -80,7 +85,9 @@ std::pair<Node, Node> TaylorGenerator::getTaylor(Kind k, std::uint64_t n)
Node taylor_sum =
Rewriter::rewrite(sum.size() == 1 ? sum[0] : nm->mkNode(Kind::PLUS, sum));
Node taylor_rem = Rewriter::rewrite(
- nm->mkNode(Kind::DIVISION, varpow, nm->mkConst<Rational>(factorial)));
+ nm->mkNode(Kind::DIVISION,
+ varpow,
+ nm->mkConst<Rational>(CONST_RATIONAL, factorial)));
auto res = std::make_pair(taylor_sum, taylor_rem);
@@ -113,10 +120,11 @@ void TaylorGenerator::getPolynomialApproximationBounds(
pbounds.d_lower = taylor_sum;
pbounds.d_upperNeg =
Rewriter::rewrite(nm->mkNode(Kind::PLUS, taylor_sum, ru));
- pbounds.d_upperPos = Rewriter::rewrite(
- nm->mkNode(Kind::MULT,
- taylor_sum,
- nm->mkNode(Kind::PLUS, nm->mkConst(Rational(1)), ru)));
+ pbounds.d_upperPos = Rewriter::rewrite(nm->mkNode(
+ Kind::MULT,
+ taylor_sum,
+ nm->mkNode(
+ Kind::PLUS, nm->mkConst(CONST_RATIONAL, Rational(1)), ru)));
}
else
{
@@ -198,11 +206,11 @@ std::pair<Node, Node> TaylorGenerator::getTfModelBounds(Node tf,
// at zero, its trivial
if (k == Kind::SINE)
{
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
return std::pair<Node, Node>(zero, zero);
}
Assert(k == Kind::EXPONENTIAL);
- Node one = nm->mkConst(Rational(1));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
return std::pair<Node, Node>(one, one);
}
bool isNeg = csign == -1;
diff --git a/src/theory/arith/nl/transcendental/transcendental_state.cpp b/src/theory/arith/nl/transcendental/transcendental_state.cpp
index 2fcbcdb38..870eddc86 100644
--- a/src/theory/arith/nl/transcendental/transcendental_state.cpp
+++ b/src/theory/arith/nl/transcendental/transcendental_state.cpp
@@ -22,6 +22,8 @@
#include "theory/arith/nl/transcendental/taylor_generator.h"
#include "theory/rewriter.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -35,9 +37,9 @@ TranscendentalState::TranscendentalState(InferenceManager& im,
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
- d_one = NodeManager::currentNM()->mkConst(Rational(1));
- d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
+ d_neg_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(-1));
if (d_env.isTheoryProofProducing())
{
d_proof.reset(new CDProofSet<CDProof>(
@@ -203,14 +205,20 @@ void TranscendentalState::mkPi()
{
d_pi = nm->mkNullaryOperator(nm->realType(), Kind::PI);
d_pi_2 = Rewriter::rewrite(
- nm->mkNode(Kind::MULT, d_pi, nm->mkConst(Rational(1) / Rational(2))));
+ nm->mkNode(Kind::MULT,
+ d_pi,
+ nm->mkConst(CONST_RATIONAL, Rational(1) / Rational(2))));
d_pi_neg_2 = Rewriter::rewrite(
- nm->mkNode(Kind::MULT, d_pi, nm->mkConst(Rational(-1) / Rational(2))));
- d_pi_neg = Rewriter::rewrite(
- nm->mkNode(Kind::MULT, d_pi, nm->mkConst(Rational(-1))));
+ nm->mkNode(Kind::MULT,
+ d_pi,
+ nm->mkConst(CONST_RATIONAL, Rational(-1) / Rational(2))));
+ d_pi_neg = Rewriter::rewrite(nm->mkNode(
+ Kind::MULT, d_pi, nm->mkConst(CONST_RATIONAL, Rational(-1))));
// initialize bounds
- d_pi_bound[0] = nm->mkConst(Rational(103993) / Rational(33102));
- d_pi_bound[1] = nm->mkConst(Rational(104348) / Rational(33215));
+ d_pi_bound[0] =
+ nm->mkConst(CONST_RATIONAL, Rational(103993) / Rational(33102));
+ d_pi_bound[1] =
+ nm->mkConst(CONST_RATIONAL, Rational(104348) / Rational(33215));
}
}
@@ -336,19 +344,23 @@ NlLemma TranscendentalState::mkSecantLemma(TNode lower,
{
if (csign == 1)
{
- proof->addStep(
- lem,
- PfRule::ARITH_TRANS_EXP_APPROX_ABOVE_POS,
- {},
- {nm->mkConst<Rational>(2 * actual_d), tf[0], lower, upper});
+ proof->addStep(lem,
+ PfRule::ARITH_TRANS_EXP_APPROX_ABOVE_POS,
+ {},
+ {nm->mkConst<Rational>(CONST_RATIONAL, 2 * actual_d),
+ tf[0],
+ lower,
+ upper});
}
else
{
- proof->addStep(
- lem,
- PfRule::ARITH_TRANS_EXP_APPROX_ABOVE_NEG,
- {},
- {nm->mkConst<Rational>(2 * actual_d), tf[0], lower, upper});
+ proof->addStep(lem,
+ PfRule::ARITH_TRANS_EXP_APPROX_ABOVE_NEG,
+ {},
+ {nm->mkConst<Rational>(CONST_RATIONAL, 2 * actual_d),
+ tf[0],
+ lower,
+ upper});
}
}
else if (tf.getKind() == Kind::SINE)
@@ -358,7 +370,7 @@ NlLemma TranscendentalState::mkSecantLemma(TNode lower,
proof->addStep(lem,
PfRule::ARITH_TRANS_SINE_APPROX_BELOW_POS,
{},
- {nm->mkConst<Rational>(2 * actual_d),
+ {nm->mkConst<Rational>(CONST_RATIONAL, 2 * actual_d),
tf[0],
lower,
upper,
@@ -372,7 +384,7 @@ NlLemma TranscendentalState::mkSecantLemma(TNode lower,
proof->addStep(lem,
PfRule::ARITH_TRANS_SINE_APPROX_ABOVE_NEG,
{},
- {nm->mkConst<Rational>(2 * actual_d),
+ {nm->mkConst<Rational>(CONST_RATIONAL, 2 * actual_d),
tf[0],
lower,
upper,
diff --git a/src/theory/arith/operator_elim.cpp b/src/theory/arith/operator_elim.cpp
index 5c43189ea..17efa53a5 100644
--- a/src/theory/arith/operator_elim.cpp
+++ b/src/theory/arith/operator_elim.cpp
@@ -170,21 +170,25 @@ Node OperatorElim::eliminateOperators(Node node,
nm->mkNode(
LT,
num,
- nm->mkNode(MULT,
- den,
- nm->mkNode(PLUS, v, nm->mkConst(Rational(1))))));
+ nm->mkNode(
+ MULT,
+ den,
+ nm->mkNode(
+ PLUS, v, nm->mkConst(CONST_RATIONAL, Rational(1))))));
}
else
{
lem = nm->mkNode(
AND,
leqNum,
- nm->mkNode(
- LT,
- num,
- nm->mkNode(MULT,
- den,
- nm->mkNode(PLUS, v, nm->mkConst(Rational(-1))))));
+ nm->mkNode(LT,
+ num,
+ nm->mkNode(MULT,
+ den,
+ nm->mkNode(PLUS,
+ v,
+ nm->mkConst(CONST_RATIONAL,
+ Rational(-1))))));
}
}
else
@@ -194,30 +198,34 @@ Node OperatorElim::eliminateOperators(Node node,
AND,
nm->mkNode(
IMPLIES,
- nm->mkNode(GT, den, nm->mkConst(Rational(0))),
+ nm->mkNode(GT, den, nm->mkConst(CONST_RATIONAL, Rational(0))),
nm->mkNode(
AND,
leqNum,
nm->mkNode(
LT,
num,
- nm->mkNode(
- MULT,
- den,
- nm->mkNode(PLUS, v, nm->mkConst(Rational(1))))))),
+ nm->mkNode(MULT,
+ den,
+ nm->mkNode(PLUS,
+ v,
+ nm->mkConst(CONST_RATIONAL,
+ Rational(1))))))),
nm->mkNode(
IMPLIES,
- nm->mkNode(LT, den, nm->mkConst(Rational(0))),
+ nm->mkNode(LT, den, nm->mkConst(CONST_RATIONAL, Rational(0))),
nm->mkNode(
AND,
leqNum,
nm->mkNode(
LT,
num,
- nm->mkNode(
- MULT,
- den,
- nm->mkNode(PLUS, v, nm->mkConst(Rational(-1))))))));
+ nm->mkNode(MULT,
+ den,
+ nm->mkNode(PLUS,
+ v,
+ nm->mkConst(CONST_RATIONAL,
+ Rational(-1))))))));
}
Node intVar = mkWitnessTerm(
v, lem, "linearIntDiv", "the result of an intdiv-by-k term", lems);
@@ -251,9 +259,10 @@ Node OperatorElim::eliminateOperators(Node node,
checkNonLinearLogic(node);
Node rw = nm->mkNode(k, num, den);
Node v = bvm->mkBoundVar<ArithWitnessVarAttribute>(rw, nm->realType());
- Node lem = nm->mkNode(IMPLIES,
- den.eqNode(nm->mkConst(Rational(0))).negate(),
- nm->mkNode(MULT, den, v).eqNode(num));
+ Node lem = nm->mkNode(
+ IMPLIES,
+ den.eqNode(nm->mkConst(CONST_RATIONAL, Rational(0))).negate(),
+ nm->mkNode(MULT, den, v).eqNode(num));
return mkWitnessTerm(
v, lem, "nonlinearDiv", "the result of a non-linear div term", lems);
break;
@@ -267,7 +276,8 @@ Node OperatorElim::eliminateOperators(Node node,
{
checkNonLinearLogic(node);
Node divByZeroNum = getArithSkolemApp(num, SkolemFunId::DIV_BY_ZERO);
- Node denEq0 = nm->mkNode(EQUAL, den, nm->mkConst(Rational(0)));
+ Node denEq0 =
+ nm->mkNode(EQUAL, den, nm->mkConst(CONST_RATIONAL, Rational(0)));
ret = nm->mkNode(ITE, denEq0, divByZeroNum, ret);
}
return ret;
@@ -285,7 +295,8 @@ Node OperatorElim::eliminateOperators(Node node,
checkNonLinearLogic(node);
Node intDivByZeroNum =
getArithSkolemApp(num, SkolemFunId::INT_DIV_BY_ZERO);
- Node denEq0 = nm->mkNode(EQUAL, den, nm->mkConst(Rational(0)));
+ Node denEq0 =
+ nm->mkNode(EQUAL, den, nm->mkConst(CONST_RATIONAL, Rational(0)));
ret = nm->mkNode(ITE, denEq0, intDivByZeroNum, ret);
}
return ret;
@@ -302,7 +313,8 @@ Node OperatorElim::eliminateOperators(Node node,
{
checkNonLinearLogic(node);
Node modZeroNum = getArithSkolemApp(num, SkolemFunId::MOD_BY_ZERO);
- Node denEq0 = nm->mkNode(EQUAL, den, nm->mkConst(Rational(0)));
+ Node denEq0 =
+ nm->mkNode(EQUAL, den, nm->mkConst(CONST_RATIONAL, Rational(0)));
ret = nm->mkNode(ITE, denEq0, modZeroNum, ret);
}
return ret;
@@ -311,10 +323,11 @@ Node OperatorElim::eliminateOperators(Node node,
case ABS:
{
- return nm->mkNode(ITE,
- nm->mkNode(LT, node[0], nm->mkConst(Rational(0))),
- nm->mkNode(UMINUS, node[0]),
- node[0]);
+ return nm->mkNode(
+ ITE,
+ nm->mkNode(LT, node[0], nm->mkConst(CONST_RATIONAL, Rational(0))),
+ nm->mkNode(UMINUS, node[0]),
+ node[0]);
break;
}
case SQRT:
@@ -350,10 +363,11 @@ Node OperatorElim::eliminateOperators(Node node,
// satisfiable. On the original formula, this would require that we
// simultaneously interpret sqrt(1) as 1 and -1, which is not a valid
// model.
- lem = nm->mkNode(ITE,
- nm->mkNode(GEQ, node[0], nm->mkConst(Rational(0))),
- nonNeg,
- uf);
+ lem = nm->mkNode(
+ ITE,
+ nm->mkNode(GEQ, node[0], nm->mkConst(CONST_RATIONAL, Rational(0))),
+ nonNeg,
+ uf);
}
else
{
@@ -363,9 +377,10 @@ Node OperatorElim::eliminateOperators(Node node,
Node rlem;
if (k == ARCSINE || k == ARCTANGENT || k == ARCCOSECANT)
{
- Node half = nm->mkConst(Rational(1) / Rational(2));
+ Node half = nm->mkConst(CONST_RATIONAL, Rational(1) / Rational(2));
Node pi2 = nm->mkNode(MULT, half, pi);
- Node npi2 = nm->mkNode(MULT, nm->mkConst(Rational(-1)), pi2);
+ Node npi2 =
+ nm->mkNode(MULT, nm->mkConst(CONST_RATIONAL, Rational(-1)), pi2);
// -pi/2 < var <= pi/2
rlem = nm->mkNode(
AND, nm->mkNode(LT, npi2, var), nm->mkNode(LEQ, var, pi2));
@@ -373,9 +388,10 @@ Node OperatorElim::eliminateOperators(Node node,
else
{
// 0 <= var < pi
- rlem = nm->mkNode(AND,
- nm->mkNode(LEQ, nm->mkConst(Rational(0)), var),
- nm->mkNode(LT, var, pi));
+ rlem = nm->mkNode(
+ AND,
+ nm->mkNode(LEQ, nm->mkConst(CONST_RATIONAL, Rational(0)), var),
+ nm->mkNode(LT, var, pi));
}
Kind rk =
diff --git a/src/theory/arith/proof_checker.cpp b/src/theory/arith/proof_checker.cpp
index 171cdf182..69fe98734 100644
--- a/src/theory/arith/proof_checker.cpp
+++ b/src/theory/arith/proof_checker.cpp
@@ -25,6 +25,8 @@
#include "theory/arith/normal_form.h"
#include "theory/arith/operator_elim.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace arith {
@@ -47,7 +49,7 @@ Node ArithProofRuleChecker::checkInternal(PfRule id,
const std::vector<Node>& args)
{
NodeManager* nm = NodeManager::currentNM();
- auto zero = nm->mkConst<Rational>(0);
+ auto zero = nm->mkConst<Rational>(CONST_RATIONAL, 0);
if (Debug.isOn("arith::pf::check"))
{
Debug("arith::pf::check") << "Arith PfRule:" << id << std::endl;
@@ -241,10 +243,12 @@ Node ArithProofRuleChecker::checkInternal(PfRule id,
<< "Bad kind: " << children[i].getKind() << std::endl;
}
}
- leftSum << nm->mkNode(
- Kind::MULT, nm->mkConst<Rational>(scalar), children[i][0]);
- rightSum << nm->mkNode(
- Kind::MULT, nm->mkConst<Rational>(scalar), children[i][1]);
+ leftSum << nm->mkNode(Kind::MULT,
+ nm->mkConst<Rational>(CONST_RATIONAL, scalar),
+ children[i][0]);
+ rightSum << nm->mkNode(Kind::MULT,
+ nm->mkConst<Rational>(CONST_RATIONAL, scalar),
+ children[i][1]);
}
Node r = nm->mkNode(strict ? Kind::LT : Kind::LEQ,
leftSum.constructNode(),
@@ -271,7 +275,7 @@ Node ArithProofRuleChecker::checkInternal(PfRule id,
{
Rational originalBound = children[0][1].getConst<Rational>();
Rational newBound = leastIntGreaterThan(originalBound);
- Node rational = nm->mkConst<Rational>(newBound);
+ Node rational = nm->mkConst<Rational>(CONST_RATIONAL, newBound);
return nm->mkNode(kind::GEQ, children[0][0], rational);
}
}
@@ -296,7 +300,7 @@ Node ArithProofRuleChecker::checkInternal(PfRule id,
{
Rational originalBound = children[0][1].getConst<Rational>();
Rational newBound = greatestIntLessThan(originalBound);
- Node rational = nm->mkConst<Rational>(newBound);
+ Node rational = nm->mkConst<Rational>(CONST_RATIONAL, newBound);
return nm->mkNode(kind::LEQ, children[0][0], rational);
}
}
diff --git a/src/theory/arith/theory_arith_private.cpp b/src/theory/arith/theory_arith_private.cpp
index f49a295c7..6a43ed09b 100644
--- a/src/theory/arith/theory_arith_private.cpp
+++ b/src/theory/arith/theory_arith_private.cpp
@@ -1427,10 +1427,10 @@ TrustNode TheoryArithPrivate::dioCutting()
Pf pfNotGeq = d_pnm->mkAssume(geq.getNode().negate());
Pf pfLt =
d_pnm->mkNode(PfRule::MACRO_SR_PRED_TRANSFORM, {pfNotGeq}, {lt});
- Pf pfSum =
- d_pnm->mkNode(PfRule::MACRO_ARITH_SCALE_SUM_UB,
- {pfGt, pfLt},
- {nm->mkConst<Rational>(-1), nm->mkConst<Rational>(1)});
+ Pf pfSum = d_pnm->mkNode(PfRule::MACRO_ARITH_SCALE_SUM_UB,
+ {pfGt, pfLt},
+ {nm->mkConst<Rational>(CONST_RATIONAL, -1),
+ nm->mkConst<Rational>(CONST_RATIONAL, 1)});
Pf pfBot = d_pnm->mkNode(
PfRule::MACRO_SR_PRED_TRANSFORM, {pfSum}, {nm->mkConst<bool>(false)});
std::vector<Node> assumptions = {leq.getNode().negate(),
@@ -4474,11 +4474,12 @@ bool TheoryArithPrivate::rowImplicationCanBeApplied(RowIndex ridx, bool rowUp, C
std::vector<Node> farkasCoefficients;
farkasCoefficients.reserve(coeffs->size());
auto nm = NodeManager::currentNM();
- std::transform(
- coeffs->begin(),
- coeffs->end(),
- std::back_inserter(farkasCoefficients),
- [nm](const Rational& r) { return nm->mkConst<Rational>(r); });
+ std::transform(coeffs->begin(),
+ coeffs->end(),
+ std::back_inserter(farkasCoefficients),
+ [nm](const Rational& r) {
+ return nm->mkConst<Rational>(CONST_RATIONAL, r);
+ });
// Prove bottom.
auto sumPf = d_pnm->mkNode(
diff --git a/src/theory/arith/type_enumerator.h b/src/theory/arith/type_enumerator.h
index 2b5582956..d57c4ba24 100644
--- a/src/theory/arith/type_enumerator.h
+++ b/src/theory/arith/type_enumerator.h
@@ -39,7 +39,10 @@ class RationalEnumerator : public TypeEnumeratorBase<RationalEnumerator> {
&& type.getConst<TypeConstant>() == REAL_TYPE);
}
- Node operator*() override { return NodeManager::currentNM()->mkConst(d_rat); }
+ Node operator*() override
+ {
+ return NodeManager::currentNM()->mkConst(kind::CONST_RATIONAL, d_rat);
+ }
RationalEnumerator& operator++() override
{
// sequence is 0, then diagonal with negatives interleaved
@@ -82,7 +85,8 @@ class IntegerEnumerator : public TypeEnumeratorBase<IntegerEnumerator> {
Node operator*() override
{
- return NodeManager::currentNM()->mkConst(Rational(d_int));
+ return NodeManager::currentNM()->mkConst(kind::CONST_RATIONAL,
+ Rational(d_int));
}
IntegerEnumerator& operator++() override
diff --git a/src/theory/bags/make_bag_op.cpp b/src/theory/bags/bag_make_op.cpp
index c03b21236..786267976 100644
--- a/src/theory/bags/make_bag_op.cpp
+++ b/src/theory/bags/bag_make_op.cpp
@@ -10,10 +10,10 @@
* directory for licensing information.
* ****************************************************************************
*
- * A class for MK_BAG operator.
+ * A class for BAG_MAKE operator.
*/
-#include "make_bag_op.h"
+#include "bag_make_op.h"
#include <iostream>
@@ -21,28 +21,28 @@
namespace cvc5 {
-std::ostream& operator<<(std::ostream& out, const MakeBagOp& op)
+std::ostream& operator<<(std::ostream& out, const BagMakeOp& op)
{
- return out << "(mkBag_op " << op.getType() << ')';
+ return out << "(BagMakeOp " << op.getType() << ')';
}
-size_t MakeBagOpHashFunction::operator()(const MakeBagOp& op) const
+size_t BagMakeOpHashFunction::operator()(const BagMakeOp& op) const
{
return std::hash<TypeNode>()(op.getType());
}
-MakeBagOp::MakeBagOp(const TypeNode& elementType)
+BagMakeOp::BagMakeOp(const TypeNode& elementType)
: d_type(new TypeNode(elementType))
{
}
-MakeBagOp::MakeBagOp(const MakeBagOp& op) : d_type(new TypeNode(op.getType()))
+BagMakeOp::BagMakeOp(const BagMakeOp& op) : d_type(new TypeNode(op.getType()))
{
}
-const TypeNode& MakeBagOp::getType() const { return *d_type; }
+const TypeNode& BagMakeOp::getType() const { return *d_type; }
-bool MakeBagOp::operator==(const MakeBagOp& op) const
+bool BagMakeOp::operator==(const BagMakeOp& op) const
{
return getType() == op.getType();
}
diff --git a/src/theory/bags/make_bag_op.h b/src/theory/bags/bag_make_op.h
index 4756009ae..e4a7e9e8f 100644
--- a/src/theory/bags/make_bag_op.h
+++ b/src/theory/bags/bag_make_op.h
@@ -10,13 +10,13 @@
* directory for licensing information.
* ****************************************************************************
*
- * A class for MK_BAG operator.
+ * A class for BAG_MAKE operator.
*/
#include "cvc5_public.h"
-#ifndef CVC5__MAKE_BAG_OP_H
-#define CVC5__MAKE_BAG_OP_H
+#ifndef CVC5__BAG_MAKE_OP_H
+#define CVC5__BAG_MAKE_OP_H
#include <memory>
@@ -25,39 +25,39 @@ namespace cvc5 {
class TypeNode;
/**
- * The class is an operator for kind MK_BAG used to construct bags.
+ * The class is an operator for kind BAG_MAKE used to construct bags.
* It specifies the type of the element especially when it is a constant.
* e.g. the type of rational 1 is Int, however
- * (mkBag (mkBag_op Real) 1) is of type (Bag Real), not (Bag Int).
+ * (bag (BagMakeOp Real) 1) is of type (Bag Real), not (Bag Int).
* Note that the type passed to the constructor is the element's type, not the
* bag type.
*/
-class MakeBagOp
+class BagMakeOp
{
public:
- explicit MakeBagOp(const TypeNode& elementType);
- MakeBagOp(const MakeBagOp& op);
+ explicit BagMakeOp(const TypeNode& elementType);
+ BagMakeOp(const BagMakeOp& op);
/** return the type of the current object */
const TypeNode& getType() const;
- bool operator==(const MakeBagOp& op) const;
+ bool operator==(const BagMakeOp& op) const;
private:
/** a pointer to the type of the bag element */
std::unique_ptr<TypeNode> d_type;
-}; /* class MakeBagOp */
+}; /* class BagMakeOp */
-std::ostream& operator<<(std::ostream& out, const MakeBagOp& op);
+std::ostream& operator<<(std::ostream& out, const BagMakeOp& op);
/**
- * Hash function for the MakeBagOpHashFunction objects.
+ * Hash function for the BagMakeOpHashFunction objects.
*/
-struct MakeBagOpHashFunction
+struct BagMakeOpHashFunction
{
- size_t operator()(const MakeBagOp& op) const;
-}; /* struct MakeBagOpHashFunction */
+ size_t operator()(const BagMakeOp& op) const;
+}; /* struct BagMakeOpHashFunction */
} // namespace cvc5
-#endif /* CVC5__MAKE_BAG_OP_H */
+#endif /* CVC5__BAG_MAKE_OP_H */
diff --git a/src/theory/bags/bag_solver.cpp b/src/theory/bags/bag_solver.cpp
index 341798eb2..444878574 100644
--- a/src/theory/bags/bag_solver.cpp
+++ b/src/theory/bags/bag_solver.cpp
@@ -42,8 +42,8 @@ BagSolver::BagSolver(Env& env,
d_termReg(tr),
d_mapCache(userContext())
{
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
- d_one = NodeManager::currentNM()->mkConst(Rational(1));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
}
@@ -69,14 +69,14 @@ void BagSolver::postCheck()
Kind k = n.getKind();
switch (k)
{
- case kind::EMPTYBAG: checkEmpty(n); break;
- case kind::MK_BAG: checkMkBag(n); break;
- case kind::UNION_DISJOINT: checkUnionDisjoint(n); break;
- case kind::UNION_MAX: checkUnionMax(n); break;
- case kind::INTERSECTION_MIN: checkIntersectionMin(n); break;
- case kind::DIFFERENCE_SUBTRACT: checkDifferenceSubtract(n); break;
- case kind::DIFFERENCE_REMOVE: checkDifferenceRemove(n); break;
- case kind::DUPLICATE_REMOVAL: checkDuplicateRemoval(n); break;
+ case kind::BAG_EMPTY: checkEmpty(n); break;
+ case kind::BAG_MAKE: checkBagMake(n); break;
+ case kind::BAG_UNION_DISJOINT: checkUnionDisjoint(n); break;
+ case kind::BAG_UNION_MAX: checkUnionMax(n); break;
+ case kind::BAG_INTER_MIN: checkIntersectionMin(n); break;
+ case kind::BAG_DIFFERENCE_SUBTRACT: checkDifferenceSubtract(n); break;
+ case kind::BAG_DIFFERENCE_REMOVE: checkDifferenceRemove(n); break;
+ case kind::BAG_DUPLICATE_REMOVAL: checkDuplicateRemoval(n); break;
case kind::BAG_MAP: checkMap(n); break;
default: break;
}
@@ -112,7 +112,7 @@ set<Node> BagSolver::getElementsForBinaryOperator(const Node& n)
void BagSolver::checkEmpty(const Node& n)
{
- Assert(n.getKind() == EMPTYBAG);
+ Assert(n.getKind() == BAG_EMPTY);
for (const Node& e : d_state.getElements(n))
{
InferInfo i = d_ig.empty(n, e);
@@ -122,7 +122,7 @@ void BagSolver::checkEmpty(const Node& n)
void BagSolver::checkUnionDisjoint(const Node& n)
{
- Assert(n.getKind() == UNION_DISJOINT);
+ Assert(n.getKind() == BAG_UNION_DISJOINT);
std::set<Node> elements = getElementsForBinaryOperator(n);
for (const Node& e : elements)
{
@@ -133,7 +133,7 @@ void BagSolver::checkUnionDisjoint(const Node& n)
void BagSolver::checkUnionMax(const Node& n)
{
- Assert(n.getKind() == UNION_MAX);
+ Assert(n.getKind() == BAG_UNION_MAX);
std::set<Node> elements = getElementsForBinaryOperator(n);
for (const Node& e : elements)
{
@@ -144,7 +144,7 @@ void BagSolver::checkUnionMax(const Node& n)
void BagSolver::checkIntersectionMin(const Node& n)
{
- Assert(n.getKind() == INTERSECTION_MIN);
+ Assert(n.getKind() == BAG_INTER_MIN);
std::set<Node> elements = getElementsForBinaryOperator(n);
for (const Node& e : elements)
{
@@ -155,7 +155,7 @@ void BagSolver::checkIntersectionMin(const Node& n)
void BagSolver::checkDifferenceSubtract(const Node& n)
{
- Assert(n.getKind() == DIFFERENCE_SUBTRACT);
+ Assert(n.getKind() == BAG_DIFFERENCE_SUBTRACT);
std::set<Node> elements = getElementsForBinaryOperator(n);
for (const Node& e : elements)
{
@@ -164,15 +164,15 @@ void BagSolver::checkDifferenceSubtract(const Node& n)
}
}
-void BagSolver::checkMkBag(const Node& n)
+void BagSolver::checkBagMake(const Node& n)
{
- Assert(n.getKind() == MK_BAG);
+ Assert(n.getKind() == BAG_MAKE);
Trace("bags::BagSolver::postCheck")
- << "BagSolver::checkMkBag Elements of " << n
+ << "BagSolver::checkBagMake Elements of " << n
<< " are: " << d_state.getElements(n) << std::endl;
for (const Node& e : d_state.getElements(n))
{
- InferInfo i = d_ig.mkBag(n, e);
+ InferInfo i = d_ig.bagMake(n, e);
d_im.lemmaTheoryInference(&i);
}
}
@@ -184,7 +184,7 @@ void BagSolver::checkNonNegativeCountTerms(const Node& bag, const Node& element)
void BagSolver::checkDifferenceRemove(const Node& n)
{
- Assert(n.getKind() == DIFFERENCE_REMOVE);
+ Assert(n.getKind() == BAG_DIFFERENCE_REMOVE);
std::set<Node> elements = getElementsForBinaryOperator(n);
for (const Node& e : elements)
{
@@ -195,7 +195,7 @@ void BagSolver::checkDifferenceRemove(const Node& n)
void BagSolver::checkDuplicateRemoval(Node n)
{
- Assert(n.getKind() == DUPLICATE_REMOVAL);
+ Assert(n.getKind() == BAG_DUPLICATE_REMOVAL);
set<Node> elements;
const set<Node>& downwards = d_state.getElements(n);
const set<Node>& upwards = d_state.getElements(n[0]);
diff --git a/src/theory/bags/bag_solver.h b/src/theory/bags/bag_solver.h
index 9155c93d0..45a20e055 100644
--- a/src/theory/bags/bag_solver.h
+++ b/src/theory/bags/bag_solver.h
@@ -46,15 +46,15 @@ class BagSolver : protected EnvObj
/** apply inference rules for empty bags */
void checkEmpty(const Node& n);
/**
- * apply inference rules for MK_BAG operator.
+ * apply inference rules for BAG_MAKE operator.
* Example: Suppose n = (bag x c), and we have two count terms (bag.count x n)
* and (bag.count y n).
* This function will add inferences for the count terms as documented in
- * InferenceGenerator::mkBag.
+ * InferenceGenerator::bagMake.
* Note that element y may not be in bag n. See the documentation of
* SolverState::getElements.
*/
- void checkMkBag(const Node& n);
+ void checkBagMake(const Node& n);
/**
* @param n is a bag that has the form (op A B)
* @return the set union of known elements in (op A B) , A, and B.
diff --git a/src/theory/bags/bags_rewriter.cpp b/src/theory/bags/bags_rewriter.cpp
index 593145f6f..7093d52fc 100644
--- a/src/theory/bags/bags_rewriter.cpp
+++ b/src/theory/bags/bags_rewriter.cpp
@@ -45,8 +45,8 @@ BagsRewriter::BagsRewriter(HistogramStat<Rewrite>* statistics)
: d_statistics(statistics)
{
d_nm = NodeManager::currentNM();
- d_zero = d_nm->mkConst(Rational(0));
- d_one = d_nm->mkConst(Rational(1));
+ d_zero = d_nm->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = d_nm->mkConst(CONST_RATIONAL, Rational(1));
}
RewriteResponse BagsRewriter::postRewrite(TNode n)
@@ -75,14 +75,16 @@ RewriteResponse BagsRewriter::postRewrite(TNode n)
Kind k = n.getKind();
switch (k)
{
- case MK_BAG: response = rewriteMakeBag(n); break;
+ case BAG_MAKE: response = rewriteMakeBag(n); break;
case BAG_COUNT: response = rewriteBagCount(n); break;
- case DUPLICATE_REMOVAL: response = rewriteDuplicateRemoval(n); break;
- case UNION_MAX: response = rewriteUnionMax(n); break;
- case UNION_DISJOINT: response = rewriteUnionDisjoint(n); break;
- case INTERSECTION_MIN: response = rewriteIntersectionMin(n); break;
- case DIFFERENCE_SUBTRACT: response = rewriteDifferenceSubtract(n); break;
- case DIFFERENCE_REMOVE: response = rewriteDifferenceRemove(n); break;
+ case BAG_DUPLICATE_REMOVAL: response = rewriteDuplicateRemoval(n); break;
+ case BAG_UNION_MAX: response = rewriteUnionMax(n); break;
+ case BAG_UNION_DISJOINT: response = rewriteUnionDisjoint(n); break;
+ case BAG_INTER_MIN: response = rewriteIntersectionMin(n); break;
+ case BAG_DIFFERENCE_SUBTRACT:
+ response = rewriteDifferenceSubtract(n);
+ break;
+ case BAG_DIFFERENCE_REMOVE: response = rewriteDifferenceRemove(n); break;
case BAG_CARD: response = rewriteCard(n); break;
case BAG_IS_SINGLETON: response = rewriteIsSingleton(n); break;
case BAG_FROM_SET: response = rewriteFromSet(n); break;
@@ -113,7 +115,7 @@ RewriteResponse BagsRewriter::preRewrite(TNode n)
switch (k)
{
case EQUAL: response = preRewriteEqual(n); break;
- case SUBBAG: response = rewriteSubBag(n); break;
+ case BAG_SUBBAG: response = rewriteSubBag(n); break;
default: response = BagsRewriteResponse(n, Rewrite::NONE);
}
@@ -144,24 +146,24 @@ BagsRewriteResponse BagsRewriter::preRewriteEqual(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteSubBag(const TNode& n) const
{
- Assert(n.getKind() == SUBBAG);
+ Assert(n.getKind() == BAG_SUBBAG);
- // (bag.is_included A B) = ((difference_subtract A B) == emptybag)
+ // (bag.subbag A B) = ((bag.difference_subtract A B) == bag.empty)
Node emptybag = d_nm->mkConst(EmptyBag(n[0].getType()));
- Node subtract = d_nm->mkNode(DIFFERENCE_SUBTRACT, n[0], n[1]);
+ Node subtract = d_nm->mkNode(BAG_DIFFERENCE_SUBTRACT, n[0], n[1]);
Node equal = subtract.eqNode(emptybag);
return BagsRewriteResponse(equal, Rewrite::SUB_BAG);
}
BagsRewriteResponse BagsRewriter::rewriteMakeBag(const TNode& n) const
{
- Assert(n.getKind() == MK_BAG);
- // return emptybag for negative or zero multiplicity
+ Assert(n.getKind() == BAG_MAKE);
+ // return bag.empty for negative or zero multiplicity
if (n[1].isConst() && n[1].getConst<Rational>().sgn() != 1)
{
- // (mkBag x c) = emptybag where c <= 0
+ // (bag x c) = bag.empty where c <= 0
Node emptybag = d_nm->mkConst(EmptyBag(n.getType()));
- return BagsRewriteResponse(emptybag, Rewrite::MK_BAG_COUNT_NEGATIVE);
+ return BagsRewriteResponse(emptybag, Rewrite::BAG_MAKE_COUNT_NEGATIVE);
}
return BagsRewriteResponse(n, Rewrite::NONE);
}
@@ -169,68 +171,68 @@ BagsRewriteResponse BagsRewriter::rewriteMakeBag(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteBagCount(const TNode& n) const
{
Assert(n.getKind() == BAG_COUNT);
- if (n[1].isConst() && n[1].getKind() == EMPTYBAG)
+ if (n[1].isConst() && n[1].getKind() == BAG_EMPTY)
{
- // (bag.count x emptybag) = 0
+ // (bag.count x bag.empty) = 0
return BagsRewriteResponse(d_zero, Rewrite::COUNT_EMPTY);
}
- if (n[1].getKind() == MK_BAG && n[0] == n[1][0])
+ if (n[1].getKind() == BAG_MAKE && n[0] == n[1][0])
{
- // (bag.count x (mkBag x c)) = (ite (>= c 1) c 0)
+ // (bag.count x (bag x c)) = (ite (>= c 1) c 0)
Node c = n[1][1];
Node geq = d_nm->mkNode(GEQ, c, d_one);
Node ite = d_nm->mkNode(ITE, geq, c, d_zero);
- return BagsRewriteResponse(ite, Rewrite::COUNT_MK_BAG);
+ return BagsRewriteResponse(ite, Rewrite::COUNT_BAG_MAKE);
}
return BagsRewriteResponse(n, Rewrite::NONE);
}
BagsRewriteResponse BagsRewriter::rewriteDuplicateRemoval(const TNode& n) const
{
- Assert(n.getKind() == DUPLICATE_REMOVAL);
- if (n[0].getKind() == MK_BAG && n[0][1].isConst()
+ Assert(n.getKind() == BAG_DUPLICATE_REMOVAL);
+ if (n[0].getKind() == BAG_MAKE && n[0][1].isConst()
&& n[0][1].getConst<Rational>().sgn() == 1)
{
- // (duplicate_removal (mkBag x n)) = (mkBag x 1)
+ // (bag.duplicate_removal (bag x n)) = (bag x 1)
// where n is a positive constant
Node bag = d_nm->mkBag(n[0][0].getType(), n[0][0], d_one);
- return BagsRewriteResponse(bag, Rewrite::DUPLICATE_REMOVAL_MK_BAG);
+ return BagsRewriteResponse(bag, Rewrite::DUPLICATE_REMOVAL_BAG_MAKE);
}
return BagsRewriteResponse(n, Rewrite::NONE);
}
BagsRewriteResponse BagsRewriter::rewriteUnionMax(const TNode& n) const
{
- Assert(n.getKind() == UNION_MAX);
- if (n[1].getKind() == EMPTYBAG || n[0] == n[1])
+ Assert(n.getKind() == BAG_UNION_MAX);
+ if (n[1].getKind() == BAG_EMPTY || n[0] == n[1])
{
- // (union_max A A) = A
- // (union_max A emptybag) = A
+ // (bag.union_max A A) = A
+ // (bag.union_max A bag.empty) = A
return BagsRewriteResponse(n[0], Rewrite::UNION_MAX_SAME_OR_EMPTY);
}
- if (n[0].getKind() == EMPTYBAG)
+ if (n[0].getKind() == BAG_EMPTY)
{
- // (union_max emptybag A) = A
+ // (bag.union_max bag.empty A) = A
return BagsRewriteResponse(n[1], Rewrite::UNION_MAX_EMPTY);
}
- if ((n[1].getKind() == UNION_MAX || n[1].getKind() == UNION_DISJOINT)
+ if ((n[1].getKind() == BAG_UNION_MAX || n[1].getKind() == BAG_UNION_DISJOINT)
&& (n[0] == n[1][0] || n[0] == n[1][1]))
{
- // (union_max A (union_max A B)) = (union_max A B)
- // (union_max A (union_max B A)) = (union_max B A)
- // (union_max A (union_disjoint A B)) = (union_disjoint A B)
- // (union_max A (union_disjoint B A)) = (union_disjoint B A)
+ // (bag.union_max A (bag.union_max A B)) = (bag.union_max A B)
+ // (bag.union_max A (bag.union_max B A)) = (bag.union_max B A)
+ // (bag.union_max A (bag.union_disjoint A B)) = (bag.union_disjoint A B)
+ // (bag.union_max A (bag.union_disjoint B A)) = (bag.union_disjoint B A)
return BagsRewriteResponse(n[1], Rewrite::UNION_MAX_UNION_LEFT);
}
- if ((n[0].getKind() == UNION_MAX || n[0].getKind() == UNION_DISJOINT)
+ if ((n[0].getKind() == BAG_UNION_MAX || n[0].getKind() == BAG_UNION_DISJOINT)
&& (n[0][0] == n[1] || n[0][1] == n[1]))
{
- // (union_max (union_max A B) A)) = (union_max A B)
- // (union_max (union_max B A) A)) = (union_max B A)
- // (union_max (union_disjoint A B) A)) = (union_disjoint A B)
- // (union_max (union_disjoint B A) A)) = (union_disjoint B A)
+ // (bag.union_max (bag.union_max A B) A)) = (bag.union_max A B)
+ // (bag.union_max (bag.union_max B A) A)) = (bag.union_max B A)
+ // (bag.union_max (bag.union_disjoint A B) A)) = (bag.union_disjoint A B)
+ // (bag.union_max (bag.union_disjoint B A) A)) = (bag.union_disjoint B A)
return BagsRewriteResponse(n[0], Rewrite::UNION_MAX_UNION_RIGHT);
}
return BagsRewriteResponse(n, Rewrite::NONE);
@@ -238,29 +240,30 @@ BagsRewriteResponse BagsRewriter::rewriteUnionMax(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteUnionDisjoint(const TNode& n) const
{
- Assert(n.getKind() == UNION_DISJOINT);
- if (n[1].getKind() == EMPTYBAG)
+ Assert(n.getKind() == BAG_UNION_DISJOINT);
+ if (n[1].getKind() == BAG_EMPTY)
{
- // (union_disjoint A emptybag) = A
+ // (bag.union_disjoint A bag.empty) = A
return BagsRewriteResponse(n[0], Rewrite::UNION_DISJOINT_EMPTY_RIGHT);
}
- if (n[0].getKind() == EMPTYBAG)
+ if (n[0].getKind() == BAG_EMPTY)
{
- // (union_disjoint emptybag A) = A
+ // (bag.union_disjoint bag.empty A) = A
return BagsRewriteResponse(n[1], Rewrite::UNION_DISJOINT_EMPTY_LEFT);
}
- if ((n[0].getKind() == UNION_MAX && n[1].getKind() == INTERSECTION_MIN)
- || (n[1].getKind() == UNION_MAX && n[0].getKind() == INTERSECTION_MIN))
+ if ((n[0].getKind() == BAG_UNION_MAX && n[1].getKind() == BAG_INTER_MIN)
+ || (n[1].getKind() == BAG_UNION_MAX && n[0].getKind() == BAG_INTER_MIN))
{
- // (union_disjoint (union_max A B) (intersection_min A B)) =
- // (union_disjoint A B) // sum(a,b) = max(a,b) + min(a,b)
- // check if the operands of union_max and intersection_min are the same
+ // (bag.union_disjoint (bag.union_max A B) (bag.inter_min A B)) =
+ // (bag.union_disjoint A B) // sum(a,b) = max(a,b) + min(a,b)
+ // check if the operands of bag.union_max and bag.inter_min are the
+ // same
std::set<Node> left(n[0].begin(), n[0].end());
std::set<Node> right(n[1].begin(), n[1].end());
if (left == right)
{
- Node rewritten = d_nm->mkNode(UNION_DISJOINT, n[0][0], n[0][1]);
+ Node rewritten = d_nm->mkNode(BAG_UNION_DISJOINT, n[0][0], n[0][1]);
return BagsRewriteResponse(rewritten, Rewrite::UNION_DISJOINT_MAX_MIN);
}
}
@@ -269,42 +272,42 @@ BagsRewriteResponse BagsRewriter::rewriteUnionDisjoint(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteIntersectionMin(const TNode& n) const
{
- Assert(n.getKind() == INTERSECTION_MIN);
- if (n[0].getKind() == EMPTYBAG)
+ Assert(n.getKind() == BAG_INTER_MIN);
+ if (n[0].getKind() == BAG_EMPTY)
{
- // (intersection_min emptybag A) = emptybag
+ // (bag.inter_min bag.empty A) = bag.empty
return BagsRewriteResponse(n[0], Rewrite::INTERSECTION_EMPTY_LEFT);
}
- if (n[1].getKind() == EMPTYBAG)
+ if (n[1].getKind() == BAG_EMPTY)
{
- // (intersection_min A emptybag) = emptybag
+ // (bag.inter_min A bag.empty) = bag.empty
return BagsRewriteResponse(n[1], Rewrite::INTERSECTION_EMPTY_RIGHT);
}
if (n[0] == n[1])
{
- // (intersection_min A A) = A
+ // (bag.inter_min A A) = A
return BagsRewriteResponse(n[0], Rewrite::INTERSECTION_SAME);
}
- if (n[1].getKind() == UNION_DISJOINT || n[1].getKind() == UNION_MAX)
+ if (n[1].getKind() == BAG_UNION_DISJOINT || n[1].getKind() == BAG_UNION_MAX)
{
if (n[0] == n[1][0] || n[0] == n[1][1])
{
- // (intersection_min A (union_disjoint A B)) = A
- // (intersection_min A (union_disjoint B A)) = A
- // (intersection_min A (union_max A B)) = A
- // (intersection_min A (union_max B A)) = A
+ // (bag.inter_min A (bag.union_disjoint A B)) = A
+ // (bag.inter_min A (bag.union_disjoint B A)) = A
+ // (bag.inter_min A (bag.union_max A B)) = A
+ // (bag.inter_min A (bag.union_max B A)) = A
return BagsRewriteResponse(n[0], Rewrite::INTERSECTION_SHARED_LEFT);
}
}
- if (n[0].getKind() == UNION_DISJOINT || n[0].getKind() == UNION_MAX)
+ if (n[0].getKind() == BAG_UNION_DISJOINT || n[0].getKind() == BAG_UNION_MAX)
{
if (n[1] == n[0][0] || n[1] == n[0][1])
{
- // (intersection_min (union_disjoint A B) A) = A
- // (intersection_min (union_disjoint B A) A) = A
- // (intersection_min (union_max A B) A) = A
- // (intersection_min (union_max B A) A) = A
+ // (bag.inter_min (bag.union_disjoint A B) A) = A
+ // (bag.inter_min (bag.union_disjoint B A) A) = A
+ // (bag.inter_min (bag.union_max A B) A) = A
+ // (bag.inter_min (bag.union_max B A) A) = A
return BagsRewriteResponse(n[1], Rewrite::INTERSECTION_SHARED_RIGHT);
}
}
@@ -315,55 +318,55 @@ BagsRewriteResponse BagsRewriter::rewriteIntersectionMin(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteDifferenceSubtract(
const TNode& n) const
{
- Assert(n.getKind() == DIFFERENCE_SUBTRACT);
- if (n[0].getKind() == EMPTYBAG || n[1].getKind() == EMPTYBAG)
+ Assert(n.getKind() == BAG_DIFFERENCE_SUBTRACT);
+ if (n[0].getKind() == BAG_EMPTY || n[1].getKind() == BAG_EMPTY)
{
- // (difference_subtract A emptybag) = A
- // (difference_subtract emptybag A) = emptybag
+ // (bag.difference_subtract A bag.empty) = A
+ // (bag.difference_subtract bag.empty A) = bag.empty
return BagsRewriteResponse(n[0], Rewrite::SUBTRACT_RETURN_LEFT);
}
if (n[0] == n[1])
{
- // (difference_subtract A A) = emptybag
+ // (bag.difference_subtract A A) = bag.empty
Node emptyBag = d_nm->mkConst(EmptyBag(n.getType()));
return BagsRewriteResponse(emptyBag, Rewrite::SUBTRACT_SAME);
}
- if (n[0].getKind() == UNION_DISJOINT)
+ if (n[0].getKind() == BAG_UNION_DISJOINT)
{
if (n[1] == n[0][0])
{
- // (difference_subtract (union_disjoint A B) A) = B
+ // (bag.difference_subtract (bag.union_disjoint A B) A) = B
return BagsRewriteResponse(n[0][1],
Rewrite::SUBTRACT_DISJOINT_SHARED_LEFT);
}
if (n[1] == n[0][1])
{
- // (difference_subtract (union_disjoint B A) A) = B
+ // (bag.difference_subtract (bag.union_disjoint B A) A) = B
return BagsRewriteResponse(n[0][0],
Rewrite::SUBTRACT_DISJOINT_SHARED_RIGHT);
}
}
- if (n[1].getKind() == UNION_DISJOINT || n[1].getKind() == UNION_MAX)
+ if (n[1].getKind() == BAG_UNION_DISJOINT || n[1].getKind() == BAG_UNION_MAX)
{
if (n[0] == n[1][0] || n[0] == n[1][1])
{
- // (difference_subtract A (union_disjoint A B)) = emptybag
- // (difference_subtract A (union_disjoint B A)) = emptybag
- // (difference_subtract A (union_max A B)) = emptybag
- // (difference_subtract A (union_max B A)) = emptybag
+ // (bag.difference_subtract A (bag.union_disjoint A B)) = bag.empty
+ // (bag.difference_subtract A (bag.union_disjoint B A)) = bag.empty
+ // (bag.difference_subtract A (bag.union_max A B)) = bag.empty
+ // (bag.difference_subtract A (bag.union_max B A)) = bag.empty
Node emptyBag = d_nm->mkConst(EmptyBag(n.getType()));
return BagsRewriteResponse(emptyBag, Rewrite::SUBTRACT_FROM_UNION);
}
}
- if (n[0].getKind() == INTERSECTION_MIN)
+ if (n[0].getKind() == BAG_INTER_MIN)
{
if (n[1] == n[0][0] || n[1] == n[0][1])
{
- // (difference_subtract (intersection_min A B) A) = emptybag
- // (difference_subtract (intersection_min B A) A) = emptybag
+ // (bag.difference_subtract (bag.inter_min A B) A) = bag.empty
+ // (bag.difference_subtract (bag.inter_min B A) A) = bag.empty
Node emptyBag = d_nm->mkConst(EmptyBag(n.getType()));
return BagsRewriteResponse(emptyBag, Rewrite::SUBTRACT_MIN);
}
@@ -374,41 +377,41 @@ BagsRewriteResponse BagsRewriter::rewriteDifferenceSubtract(
BagsRewriteResponse BagsRewriter::rewriteDifferenceRemove(const TNode& n) const
{
- Assert(n.getKind() == DIFFERENCE_REMOVE);
+ Assert(n.getKind() == BAG_DIFFERENCE_REMOVE);
- if (n[0].getKind() == EMPTYBAG || n[1].getKind() == EMPTYBAG)
+ if (n[0].getKind() == BAG_EMPTY || n[1].getKind() == BAG_EMPTY)
{
- // (difference_remove A emptybag) = A
- // (difference_remove emptybag B) = emptybag
+ // (bag.difference_remove A bag.empty) = A
+ // (bag.difference_remove bag.empty B) = bag.empty
return BagsRewriteResponse(n[0], Rewrite::REMOVE_RETURN_LEFT);
}
if (n[0] == n[1])
{
- // (difference_remove A A) = emptybag
+ // (bag.difference_remove A A) = bag.empty
Node emptyBag = d_nm->mkConst(EmptyBag(n.getType()));
return BagsRewriteResponse(emptyBag, Rewrite::REMOVE_SAME);
}
- if (n[1].getKind() == UNION_DISJOINT || n[1].getKind() == UNION_MAX)
+ if (n[1].getKind() == BAG_UNION_DISJOINT || n[1].getKind() == BAG_UNION_MAX)
{
if (n[0] == n[1][0] || n[0] == n[1][1])
{
- // (difference_remove A (union_disjoint A B)) = emptybag
- // (difference_remove A (union_disjoint B A)) = emptybag
- // (difference_remove A (union_max A B)) = emptybag
- // (difference_remove A (union_max B A)) = emptybag
+ // (bag.difference_remove A (bag.union_disjoint A B)) = bag.empty
+ // (bag.difference_remove A (bag.union_disjoint B A)) = bag.empty
+ // (bag.difference_remove A (bag.union_max A B)) = bag.empty
+ // (bag.difference_remove A (bag.union_max B A)) = bag.empty
Node emptyBag = d_nm->mkConst(EmptyBag(n.getType()));
return BagsRewriteResponse(emptyBag, Rewrite::REMOVE_FROM_UNION);
}
}
- if (n[0].getKind() == INTERSECTION_MIN)
+ if (n[0].getKind() == BAG_INTER_MIN)
{
if (n[1] == n[0][0] || n[1] == n[0][1])
{
- // (difference_remove (intersection_min A B) A) = emptybag
- // (difference_remove (intersection_min B A) A) = emptybag
+ // (bag.difference_remove (bag.inter_min A B) A) = bag.empty
+ // (bag.difference_remove (bag.inter_min B A) A) = bag.empty
Node emptyBag = d_nm->mkConst(EmptyBag(n.getType()));
return BagsRewriteResponse(emptyBag, Rewrite::REMOVE_MIN);
}
@@ -420,11 +423,11 @@ BagsRewriteResponse BagsRewriter::rewriteDifferenceRemove(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteChoose(const TNode& n) const
{
Assert(n.getKind() == BAG_CHOOSE);
- if (n[0].getKind() == MK_BAG && n[0][1].isConst()
+ if (n[0].getKind() == BAG_MAKE && n[0][1].isConst()
&& n[0][1].getConst<Rational>() > 0)
{
- // (bag.choose (mkBag x c)) = x where c is a constant > 0
- return BagsRewriteResponse(n[0][0], Rewrite::CHOOSE_MK_BAG);
+ // (bag.choose (bag x c)) = x where c is a constant > 0
+ return BagsRewriteResponse(n[0][0], Rewrite::CHOOSE_BAG_MAKE);
}
return BagsRewriteResponse(n, Rewrite::NONE);
}
@@ -432,15 +435,15 @@ BagsRewriteResponse BagsRewriter::rewriteChoose(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteCard(const TNode& n) const
{
Assert(n.getKind() == BAG_CARD);
- if (n[0].getKind() == MK_BAG && n[0][1].isConst())
+ if (n[0].getKind() == BAG_MAKE && n[0][1].isConst())
{
- // (bag.card (mkBag x c)) = c where c is a constant > 0
- return BagsRewriteResponse(n[0][1], Rewrite::CARD_MK_BAG);
+ // (bag.card (bag x c)) = c where c is a constant > 0
+ return BagsRewriteResponse(n[0][1], Rewrite::CARD_BAG_MAKE);
}
- if (n[0].getKind() == UNION_DISJOINT)
+ if (n[0].getKind() == BAG_UNION_DISJOINT)
{
- // (bag.card (union-disjoint A B)) = (+ (bag.card A) (bag.card B))
+ // (bag.card (bag.union-disjoint A B)) = (+ (bag.card A) (bag.card B))
Node A = d_nm->mkNode(BAG_CARD, n[0][0]);
Node B = d_nm->mkNode(BAG_CARD, n[0][1]);
Node plus = d_nm->mkNode(PLUS, A, B);
@@ -453,11 +456,11 @@ BagsRewriteResponse BagsRewriter::rewriteCard(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteIsSingleton(const TNode& n) const
{
Assert(n.getKind() == BAG_IS_SINGLETON);
- if (n[0].getKind() == MK_BAG)
+ if (n[0].getKind() == BAG_MAKE)
{
- // (bag.is_singleton (mkBag x c)) = (c == 1)
+ // (bag.is_singleton (bag x c)) = (c == 1)
Node equal = n[0][1].eqNode(d_one);
- return BagsRewriteResponse(equal, Rewrite::IS_SINGLETON_MK_BAG);
+ return BagsRewriteResponse(equal, Rewrite::IS_SINGLETON_BAG_MAKE);
}
return BagsRewriteResponse(n, Rewrite::NONE);
}
@@ -467,7 +470,7 @@ BagsRewriteResponse BagsRewriter::rewriteFromSet(const TNode& n) const
Assert(n.getKind() == BAG_FROM_SET);
if (n[0].getKind() == SET_SINGLETON)
{
- // (bag.from_set (set.singleton (singleton_op Int) x)) = (mkBag x 1)
+ // (bag.from_set (set.singleton (SetSingletonOp Int) x)) = (bag x 1)
TypeNode type = n[0].getType().getSetElementType();
Node bag = d_nm->mkBag(type, n[0][0], d_one);
return BagsRewriteResponse(bag, Rewrite::FROM_SINGLETON);
@@ -478,10 +481,10 @@ BagsRewriteResponse BagsRewriter::rewriteFromSet(const TNode& n) const
BagsRewriteResponse BagsRewriter::rewriteToSet(const TNode& n) const
{
Assert(n.getKind() == BAG_TO_SET);
- if (n[0].getKind() == MK_BAG && n[0][1].isConst()
+ if (n[0].getKind() == BAG_MAKE && n[0][1].isConst()
&& n[0][1].getConst<Rational>().sgn() == 1)
{
- // (bag.to_set (mkBag x n)) = (singleton (singleton_op T) x)
+ // (bag.to_set (bag x n)) = (set.singleton (SetSingletonOp T) x)
// where n is a positive constant and T is the type of the bag's elements
Node set = d_nm->mkSingleton(n[0][0].getType(), n[0][0]);
return BagsRewriteResponse(set, Rewrite::TO_SINGLETON);
@@ -518,7 +521,7 @@ BagsRewriteResponse BagsRewriter::postRewriteMap(const TNode& n) const
Assert(n.getKind() == kind::BAG_MAP);
if (n[1].isConst())
{
- // (bag.map f emptybag) = emptybag
+ // (bag.map f (as bag.empty (Bag T1)) = (as bag.empty (Bag T2))
// (bag.map f (bag "a" 3)) = (bag (f "a") 3)
std::map<Node, Rational> elements = NormalForm::getBagElements(n[1]);
std::map<Node, Rational> mappedElements;
@@ -536,19 +539,22 @@ BagsRewriteResponse BagsRewriter::postRewriteMap(const TNode& n) const
Kind k = n[1].getKind();
switch (k)
{
- case MK_BAG:
+ case BAG_MAKE:
{
+ // (bag.map f (bag x y)) = (bag (apply f x) y)
Node mappedElement = d_nm->mkNode(APPLY_UF, n[0], n[1][0]);
Node ret =
d_nm->mkBag(n[0].getType().getRangeType(), mappedElement, n[1][1]);
- return BagsRewriteResponse(ret, Rewrite::MAP_MK_BAG);
+ return BagsRewriteResponse(ret, Rewrite::MAP_BAG_MAKE);
}
- case UNION_DISJOINT:
+ case BAG_UNION_DISJOINT:
{
- Node a = d_nm->mkNode(BAG_MAP, n[1][0]);
- Node b = d_nm->mkNode(BAG_MAP, n[1][1]);
- Node ret = d_nm->mkNode(UNION_DISJOINT, a, b);
+ // (bag.map f (bag.union_disjoint A B)) =
+ // (bag.union_disjoint (bag.map f A) (bag.map f B))
+ Node a = d_nm->mkNode(BAG_MAP, n[0], n[1][0]);
+ Node b = d_nm->mkNode(BAG_MAP, n[0], n[1][1]);
+ Node ret = d_nm->mkNode(BAG_UNION_DISJOINT, a, b);
return BagsRewriteResponse(ret, Rewrite::MAP_UNION_DISJOINT);
}
diff --git a/src/theory/bags/bags_rewriter.h b/src/theory/bags/bags_rewriter.h
index 3edd5af32..a938b3bd4 100644
--- a/src/theory/bags/bags_rewriter.h
+++ b/src/theory/bags/bags_rewriter.h
@@ -45,14 +45,14 @@ class BagsRewriter : public TheoryRewriter
BagsRewriter(HistogramStat<Rewrite>* statistics = nullptr);
/**
- * postRewrite nodes with kinds: MK_BAG, BAG_COUNT, UNION_MAX, UNION_DISJOINT,
- * INTERSECTION_MIN, DIFFERENCE_SUBTRACT, DIFFERENCE_REMOVE, BAG_CHOOSE,
- * BAG_CARD, BAG_IS_SINGLETON.
- * See the rewrite rules for these kinds below.
+ * postRewrite nodes with kinds: BAG_MAKE, BAG_COUNT, BAG_UNION_MAX,
+ * BAG_UNION_DISJOINT, BAG_INTER_MIN, BAG_DIFFERENCE_SUBTRACT,
+ * BAG_DIFFERENCE_REMOVE, BAG_CHOOSE, BAG_CARD, BAG_IS_SINGLETON. See the
+ * rewrite rules for these kinds below.
*/
RewriteResponse postRewrite(TNode n) override;
/**
- * preRewrite nodes with kinds: EQUAL, SUBBAG.
+ * preRewrite nodes with kinds: EQUAL, BGA_SUBBAG.
* See the rewrite rules for these kinds below.
*/
RewriteResponse preRewrite(TNode n) override;
@@ -66,14 +66,14 @@ class BagsRewriter : public TheoryRewriter
/**
* rewrites for n include:
- * - (bag.is_included A B) = ((difference_subtract A B) == emptybag)
+ * - (bag.subbag A B) = ((bag.difference_subtract A B) == bag.empty)
*/
BagsRewriteResponse rewriteSubBag(const TNode& n) const;
/**
* rewrites for n include:
- * - (bag x 0) = (emptybag T) where T is the type of x
- * - (bag x (-c)) = (emptybag T) where T is the type of x, and c > 0 is a
+ * - (bag x 0) = (bag.empty T) where T is the type of x
+ * - (bag x (-c)) = (bag.empty T) where T is the type of x, and c > 0 is a
* constant
* - otherwise = n
*/
@@ -81,7 +81,7 @@ class BagsRewriter : public TheoryRewriter
/**
* rewrites for n include:
- * - (bag.count x emptybag) = 0
+ * - (bag.count x bag.empty) = 0
* - (bag.count x (bag x c)) = (ite (>= c 1) c 0)
* - otherwise = n
*/
@@ -89,85 +89,85 @@ class BagsRewriter : public TheoryRewriter
/**
* rewrites for n include:
- * - (duplicate_removal (bag x n)) = (bag x 1)
+ * - (bag.duplicate_removal (bag x n)) = (bag x 1)
* where n is a positive constant
*/
BagsRewriteResponse rewriteDuplicateRemoval(const TNode& n) const;
/**
* rewrites for n include:
- * - (union_max A emptybag) = A
- * - (union_max emptybag A) = A
- * - (union_max A A) = A
- * - (union_max A (union_max A B)) = (union_max A B)
- * - (union_max A (union_max B A)) = (union_max B A)
- * - (union_max (union_max A B) A) = (union_max A B)
- * - (union_max (union_max B A) A) = (union_max B A)
- * - (union_max A (union_disjoint A B)) = (union_disjoint A B)
- * - (union_max A (union_disjoint B A)) = (union_disjoint B A)
- * - (union_max (union_disjoint A B) A) = (union_disjoint A B)
- * - (union_max (union_disjoint B A) A) = (union_disjoint B A)
+ * - (bag.union_max A bag.empty) = A
+ * - (bag.union_max bag.empty A) = A
+ * - (bag.union_max A A) = A
+ * - (bag.union_max A (bag.union_max A B)) = (bag.union_max A B)
+ * - (bag.union_max A (bag.union_max B A)) = (bag.union_max B A)
+ * - (bag.union_max (bag.union_max A B) A) = (bag.union_max A B)
+ * - (bag.union_max (bag.union_max B A) A) = (bag.union_max B A)
+ * - (bag.union_max A (bag.union_disjoint A B)) = (bag.union_disjoint A B)
+ * - (bag.union_max A (bag.union_disjoint B A)) = (bag.union_disjoint B A)
+ * - (bag.union_max (bag.union_disjoint A B) A) = (bag.union_disjoint A B)
+ * - (bag.union_max (bag.union_disjoint B A) A) = (bag.union_disjoint B A)
* - otherwise = n
*/
BagsRewriteResponse rewriteUnionMax(const TNode& n) const;
/**
* rewrites for n include:
- * - (union_disjoint A emptybag) = A
- * - (union_disjoint emptybag A) = A
- * - (union_disjoint (union_max A B) (intersection_min A B)) =
- * (union_disjoint A B) // sum(a,b) = max(a,b) + min(a,b)
+ * - (bag.union_disjoint A bag.empty) = A
+ * - (bag.union_disjoint bag.empty A) = A
+ * - (bag.union_disjoint (bag.union_max A B) (bag.inter_min A B)) =
+ * (bag.union_disjoint A B) // sum(a,b) = max(a,b) + min(a,b)
* - other permutations of the above like swapping A and B, or swapping
- * intersection_min and union_max
+ * bag.intersection_min and bag.union_max
* - otherwise = n
*/
BagsRewriteResponse rewriteUnionDisjoint(const TNode& n) const;
/**
* rewrites for n include:
- * - (intersection_min A emptybag) = emptybag
- * - (intersection_min emptybag A) = emptybag
- * - (intersection_min A A) = A
- * - (intersection_min A (union_disjoint A B)) = A
- * - (intersection_min A (union_disjoint B A)) = A
- * - (intersection_min (union_disjoint A B) A) = A
- * - (intersection_min (union_disjoint B A) A) = A
- * - (intersection_min A (union_max A B)) = A
- * - (intersection_min A (union_max B A)) = A
- * - (intersection_min (union_max A B) A) = A
- * - (intersection_min (union_max B A) A) = A
+ * - (bag.inter_min A bag.empty) = bag.empty
+ * - (bag.inter_min bag.empty A) = bag.empty
+ * - (bag.inter_min A A) = A
+ * - (bag.inter_min A (bag.union_disjoint A B)) = A
+ * - (bag.inter_min A (bag.union_disjoint B A)) = A
+ * - (bag.inter_min (bag.union_disjoint A B) A) = A
+ * - (bag.inter_min (bag.union_disjoint B A) A) = A
+ * - (bag.inter_min A (bag.union_max A B)) = A
+ * - (bag.inter_min A (bag.union_max B A)) = A
+ * - (bag.inter_min (bag.union_max A B) A) = A
+ * - (bag.inter_min (bag.union_max B A) A) = A
* - otherwise = n
*/
BagsRewriteResponse rewriteIntersectionMin(const TNode& n) const;
/**
* rewrites for n include:
- * - (difference_subtract A emptybag) = A
- * - (difference_subtract emptybag A) = emptybag
- * - (difference_subtract A A) = emptybag
- * - (difference_subtract (union_disjoint A B) A) = B
- * - (difference_subtract (union_disjoint B A) A) = B
- * - (difference_subtract A (union_disjoint A B)) = emptybag
- * - (difference_subtract A (union_disjoint B A)) = emptybag
- * - (difference_subtract A (union_max A B)) = emptybag
- * - (difference_subtract A (union_max B A)) = emptybag
- * - (difference_subtract (intersection_min A B) A) = emptybag
- * - (difference_subtract (intersection_min B A) A) = emptybag
+ * - (bag.difference_subtract A bag.empty) = A
+ * - (bag.difference_subtract bag.empty A) = bag.empty
+ * - (bag.difference_subtract A A) = bag.empty
+ * - (bag.difference_subtract (bag.union_disjoint A B) A) = B
+ * - (bag.difference_subtract (bag.union_disjoint B A) A) = B
+ * - (bag.difference_subtract A (bag.union_disjoint A B)) = bag.empty
+ * - (bag.difference_subtract A (bag.union_disjoint B A)) = bag.empty
+ * - (bag.difference_subtract A (bag.union_max A B)) = bag.empty
+ * - (bag.difference_subtract A (bag.union_max B A)) = bag.empty
+ * - (bag.difference_subtract (bag.inter_min A B) A) = bag.empty
+ * - (bag.difference_subtract (bag.inter_min B A) A) = bag.empty
* - otherwise = n
*/
BagsRewriteResponse rewriteDifferenceSubtract(const TNode& n) const;
/**
* rewrites for n include:
- * - (difference_remove A emptybag) = A
- * - (difference_remove emptybag A) = emptybag
- * - (difference_remove A A) = emptybag
- * - (difference_remove A (union_disjoint A B)) = emptybag
- * - (difference_remove A (union_disjoint B A)) = emptybag
- * - (difference_remove A (union_max A B)) = emptybag
- * - (difference_remove A (union_max B A)) = emptybag
- * - (difference_remove (intersection_min A B) A) = emptybag
- * - (difference_remove (intersection_min B A) A) = emptybag
+ * - (bag.difference_remove A bag.empty) = A
+ * - (bag.difference_remove bag.empty A) = bag.empty
+ * - (bag.difference_remove A A) = bag.empty
+ * - (bag.difference_remove A (bag.union_disjoint A B)) = bag.empty
+ * - (bag.difference_remove A (bag.union_disjoint B A)) = bag.empty
+ * - (bag.difference_remove A (bag.union_max A B)) = bag.empty
+ * - (bag.difference_remove A (bag.union_max B A)) = bag.empty
+ * - (bag.difference_remove (bag.inter_min A B) A) = bag.empty
+ * - (bag.difference_remove (bag.inter_min B A) A) = bag.empty
* - otherwise = n
*/
BagsRewriteResponse rewriteDifferenceRemove(const TNode& n) const;
@@ -193,13 +193,13 @@ class BagsRewriter : public TheoryRewriter
/**
* rewrites for n include:
- * - (bag.from_set (singleton (singleton_op Int) x)) = (bag x 1)
+ * - (bag.from_set (singleton (SetSingletonOp Int) x)) = (bag x 1)
*/
BagsRewriteResponse rewriteFromSet(const TNode& n) const;
/**
* rewrites for n include:
- * - (bag.to_set (bag x n)) = (singleton (singleton_op T) x)
+ * - (bag.to_set (bag x n)) = (singleton (SetSingletonOp T) x)
* where n is a positive constant and T is the type of the bag's elements
*/
BagsRewriteResponse rewriteToSet(const TNode& n) const;
@@ -214,14 +214,11 @@ class BagsRewriter : public TheoryRewriter
/**
* rewrites for n include:
- * - (bag.map (lambda ((x U)) t) emptybag) = emptybag
- * - (bag.map (lambda ((x U)) t) (bag y z)) = (bag (apply (lambda ((x U)) t)
- * y) z)
- * - (bag.map (lambda ((x U)) t) (union_disjoint A B)) =
- * (union_disjoint
- * (bag ((lambda ((x U)) t) "a") 3)
- * (bag ((lambda ((x U)) t) "b") 4))
- *
+ * - (bag.map f (as bag.empty (Bag T1)) = (as bag.empty (Bag T2))
+ * - (bag.map f (bag x y)) = (bag (apply f x) y)
+ * - (bag.map f (bag.union_disjoint A B)) =
+ * (bag.union_disjoint (bag.map f A) (bag.map f B))
+ * where f: T1 -> T2
*/
BagsRewriteResponse postRewriteMap(const TNode& n) const;
diff --git a/src/theory/bags/infer_info.h b/src/theory/bags/infer_info.h
index b0519993b..4fde553f0 100644
--- a/src/theory/bags/infer_info.h
+++ b/src/theory/bags/infer_info.h
@@ -32,7 +32,6 @@ class TheoryInferenceManager;
namespace bags {
-
/**
* An inference. This is a class to track an unprocessed call to either
* send a fact, lemma, or conflict that is waiting to be asserted to the
diff --git a/src/theory/bags/inference_generator.cpp b/src/theory/bags/inference_generator.cpp
index 66c38ab86..a433ceb2d 100644
--- a/src/theory/bags/inference_generator.cpp
+++ b/src/theory/bags/inference_generator.cpp
@@ -36,8 +36,8 @@ InferenceGenerator::InferenceGenerator(SolverState* state, InferenceManager* im)
d_nm = NodeManager::currentNM();
d_sm = d_nm->getSkolemManager();
d_true = d_nm->mkConst(true);
- d_zero = d_nm->mkConst(Rational(0));
- d_one = d_nm->mkConst(Rational(1));
+ d_zero = d_nm->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = d_nm->mkConst(CONST_RATIONAL, Rational(1));
}
InferInfo InferenceGenerator::nonNegativeCount(Node n, Node e)
@@ -53,46 +53,29 @@ InferInfo InferenceGenerator::nonNegativeCount(Node n, Node e)
return inferInfo;
}
-InferInfo InferenceGenerator::mkBag(Node n, Node e)
+InferInfo InferenceGenerator::bagMake(Node n, Node e)
{
- Assert(n.getKind() == MK_BAG);
+ Assert(n.getKind() == BAG_MAKE);
Assert(e.getType() == n.getType().getBagElementType());
+ /*
+ * (ite (and (= e x) (>= c 1))
+ * (= (bag.count e skolem) c)
+ * (= (bag.count e skolem) 0))
+ */
Node x = n[0];
Node c = n[1];
+ InferInfo inferInfo(d_im, InferenceId::BAGS_BAG_MAKE);
+ Node same = d_nm->mkNode(EQUAL, e, x);
Node geq = d_nm->mkNode(GEQ, c, d_one);
- if (d_state->areEqual(e, x))
- {
- // (= (bag.count e skolem) (ite (>= c 1) c 0)))
- InferInfo inferInfo(d_im, InferenceId::BAGS_MK_BAG_SAME_ELEMENT);
- Node skolem = getSkolem(n, inferInfo);
- Node count = getMultiplicityTerm(e, skolem);
- Node ite = d_nm->mkNode(ITE, geq, c, d_zero);
- inferInfo.d_conclusion = count.eqNode(ite);
- return inferInfo;
- }
- if (d_state->areDisequal(e, x))
- {
- //(= (bag.count e skolem) 0))
- InferInfo inferInfo(d_im, InferenceId::BAGS_MK_BAG_SAME_ELEMENT);
- Node skolem = getSkolem(n, inferInfo);
- Node count = getMultiplicityTerm(e, skolem);
- inferInfo.d_conclusion = count.eqNode(d_zero);
- return inferInfo;
- }
- else
- {
- // (= (bag.count e skolem) (ite (and (= e x) (>= c 1)) c 0)))
- InferInfo inferInfo(d_im, InferenceId::BAGS_MK_BAG);
- Node skolem = getSkolem(n, inferInfo);
- Node count = getMultiplicityTerm(e, skolem);
- Node same = d_nm->mkNode(EQUAL, e, x);
- Node andNode = same.andNode(geq);
- Node ite = d_nm->mkNode(ITE, andNode, c, d_zero);
- Node equal = count.eqNode(ite);
- inferInfo.d_conclusion = equal;
- return inferInfo;
- }
+ Node andNode = same.andNode(geq);
+ Node skolem = getSkolem(n, inferInfo);
+ Node count = getMultiplicityTerm(e, skolem);
+ Node equalC = d_nm->mkNode(EQUAL, count, c);
+ Node equalZero = d_nm->mkNode(EQUAL, count, d_zero);
+ Node ite = d_nm->mkNode(ITE, andNode, equalC, equalZero);
+ inferInfo.d_conclusion = ite;
+ return inferInfo;
}
/**
@@ -158,7 +141,7 @@ Node InferenceGenerator::getSkolem(Node& n, InferInfo& inferInfo)
InferInfo InferenceGenerator::empty(Node n, Node e)
{
- Assert(n.getKind() == EMPTYBAG);
+ Assert(n.getKind() == BAG_EMPTY);
Assert(e.getType() == n.getType().getBagElementType());
InferInfo inferInfo(d_im, InferenceId::BAGS_EMPTY);
@@ -172,7 +155,7 @@ InferInfo InferenceGenerator::empty(Node n, Node e)
InferInfo InferenceGenerator::unionDisjoint(Node n, Node e)
{
- Assert(n.getKind() == UNION_DISJOINT && n[0].getType().isBag());
+ Assert(n.getKind() == BAG_UNION_DISJOINT && n[0].getType().isBag());
Assert(e.getType() == n[0].getType().getBagElementType());
Node A = n[0];
@@ -194,7 +177,7 @@ InferInfo InferenceGenerator::unionDisjoint(Node n, Node e)
InferInfo InferenceGenerator::unionMax(Node n, Node e)
{
- Assert(n.getKind() == UNION_MAX && n[0].getType().isBag());
+ Assert(n.getKind() == BAG_UNION_MAX && n[0].getType().isBag());
Assert(e.getType() == n[0].getType().getBagElementType());
Node A = n[0];
@@ -217,7 +200,7 @@ InferInfo InferenceGenerator::unionMax(Node n, Node e)
InferInfo InferenceGenerator::intersection(Node n, Node e)
{
- Assert(n.getKind() == INTERSECTION_MIN && n[0].getType().isBag());
+ Assert(n.getKind() == BAG_INTER_MIN && n[0].getType().isBag());
Assert(e.getType() == n[0].getType().getBagElementType());
Node A = n[0];
@@ -238,7 +221,7 @@ InferInfo InferenceGenerator::intersection(Node n, Node e)
InferInfo InferenceGenerator::differenceSubtract(Node n, Node e)
{
- Assert(n.getKind() == DIFFERENCE_SUBTRACT && n[0].getType().isBag());
+ Assert(n.getKind() == BAG_DIFFERENCE_SUBTRACT && n[0].getType().isBag());
Assert(e.getType() == n[0].getType().getBagElementType());
Node A = n[0];
@@ -260,7 +243,7 @@ InferInfo InferenceGenerator::differenceSubtract(Node n, Node e)
InferInfo InferenceGenerator::differenceRemove(Node n, Node e)
{
- Assert(n.getKind() == DIFFERENCE_REMOVE && n[0].getType().isBag());
+ Assert(n.getKind() == BAG_DIFFERENCE_REMOVE && n[0].getType().isBag());
Assert(e.getType() == n[0].getType().getBagElementType());
Node A = n[0];
@@ -282,7 +265,7 @@ InferInfo InferenceGenerator::differenceRemove(Node n, Node e)
InferInfo InferenceGenerator::duplicateRemoval(Node n, Node e)
{
- Assert(n.getKind() == DUPLICATE_REMOVAL && n[0].getType().isBag());
+ Assert(n.getKind() == BAG_DUPLICATE_REMOVAL && n[0].getType().isBag());
Assert(e.getType() == n[0].getType().getBagElementType());
Node A = n[0];
diff --git a/src/theory/bags/inference_generator.h b/src/theory/bags/inference_generator.h
index 3f38d05b9..8ed3ead38 100644
--- a/src/theory/bags/inference_generator.h
+++ b/src/theory/bags/inference_generator.h
@@ -50,117 +50,115 @@ class InferenceGenerator
/**
* @param n is (bag x c) of type (Bag E)
* @param e is a node of type E
- * @return an inference that represents the following cases:
- * 1- e, x are in the same equivalent class, then we infer:
- * (= (bag.count e skolem) (ite (>= c 1) c 0)))
- * 2- e, x are known to be disequal, then we infer:
- * (= (bag.count e skolem) 0))
- * 3- if neither holds, we infer:
- * (= (bag.count e skolem) (ite (and (= e x) (>= c 1)) c 0)))
+ * @return an inference that represents the following lemma:
+ * (ite (and (= e x) (>= c 1))
+ * (= (bag.count e skolem) c)
+ * (= (bag.count e skolem) 0))
* where skolem = (bag x c) is a fresh variable
*/
- InferInfo mkBag(Node n, Node e);
+ InferInfo bagMake(Node n, Node e);
/**
* @param n is (= A B) where A, B are bags of type (Bag E), and
* (not (= A B)) is an assertion in the equality engine
* @return an inference that represents the following implication
* (=>
* (not (= A B))
- * (not (= (count e A) (count e B))))
+ * (not (= (bag.count e A) (bag.count e B))))
* where e is a fresh skolem of type E.
*/
InferInfo bagDisequality(Node n);
/**
- * @param n is (as emptybag (Bag E))
+ * @param n is (as bag.empty (Bag E))
* @param e is a node of Type E
* @return an inference that represents the following implication
* (=>
* true
- * (= 0 (count e skolem)))
- * where skolem = (as emptybag (Bag String))
+ * (= 0 (bag.count e skolem)))
+ * where skolem = (as bag.empty (Bag E))
*/
InferInfo empty(Node n, Node e);
/**
- * @param n is (union_disjoint A B) where A, B are bags of type (Bag E)
+ * @param n is (bag.union_disjoint A B) where A, B are bags of type (Bag E)
* @param e is a node of Type E
* @return an inference that represents the following implication
* (=>
* true
- * (= (count e skolem)
- * (+ (count e A) (count e B))))
- * where skolem is a fresh variable equals (union_disjoint A B)
+ * (= (bag.count e skolem)
+ * (+ (bag.count e A) (bag.count e B))))
+ * where skolem is a fresh variable equals (bag.union_disjoint A B)
*/
InferInfo unionDisjoint(Node n, Node e);
/**
- * @param n is (union_disjoint A B) where A, B are bags of type (Bag E)
+ * @param n is (bag.union_disjoint A B) where A, B are bags of type (Bag E)
* @param e is a node of Type E
* @return an inference that represents the following implication
* (=>
* true
* (=
- * (count e skolem)
+ * (bag.count e skolem)
* (ite
- * (> (count e A) (count e B))
- * (count e A)
- * (count e B)))))
- * where skolem is a fresh variable equals (union_max A B)
+ * (> (bag.count e A) (bag.count e B))
+ * (bag.count e A)
+ * (bag.count e B)))))
+ * where skolem is a fresh variable equals (bag.union_max A B)
*/
InferInfo unionMax(Node n, Node e);
/**
- * @param n is (intersection_min A B) where A, B are bags of type (Bag E)
+ * @param n is (bag.inter_min A B) where A, B are bags of type (Bag E)
* @param e is a node of Type E
* @return an inference that represents the following implication
* (=>
* true
* (=
- * (count e skolem)
+ * (bag.count e skolem)
* (ite(
- * (< (count e A) (count e B))
- * (count e A)
- * (count e B)))))
- * where skolem is a fresh variable equals (intersection_min A B)
+ * (< (bag.count e A) (bag.count e B))
+ * (bag.count e A)
+ * (bag.count e B)))))
+ * where skolem is a fresh variable equals (bag.inter_min A B)
*/
InferInfo intersection(Node n, Node e);
/**
- * @param n is (difference_subtract A B) where A, B are bags of type (Bag E)
+ * @param n is (bag.difference_subtract A B) where A, B are bags of type
+ * (Bag E)
* @param e is a node of Type E
* @return an inference that represents the following implication
* (=>
* true
* (=
- * (count e skolem)
+ * (bag.count e skolem)
* (ite
- * (>= (count e A) (count e B))
- * (- (count e A) (count e B))
+ * (>= (bag.count e A) (bag.count e B))
+ * (- (bag.count e A) (bag.count e B))
* 0))))
- * where skolem is a fresh variable equals (difference_subtract A B)
+ * where skolem is a fresh variable equals (bag.difference_subtract A B)
*/
InferInfo differenceSubtract(Node n, Node e);
/**
- * @param n is (difference_remove A B) where A, B are bags of type (Bag E)
+ * @param n is (bag.difference_remove A B) where A, B are bags of type (Bag E)
* @param e is a node of Type E
* @return an inference that represents the following implication
* (=>
* true
* (=
- * (count e skolem)
+ * (bag.count e skolem)
* (ite
- * (<= (count e B) 0)
- * (count e A)
+ * (<= (bag.count e B) 0)
+ * (bag.count e A)
* 0))))
- * where skolem is a fresh variable equals (difference_remove A B)
+ * where skolem is a fresh variable equals (bag.difference_remove A B)
*/
InferInfo differenceRemove(Node n, Node e);
/**
- * @param n is (duplicate_removal A) where A is a bag of type (Bag E)
+ * @param n is (bag.duplicate_removal A) where A is a bag of type (Bag E)
* @param e is a node of Type E
* @return an inference that represents the following implication
* (=>
* true
* (=
- * (count e skolem)
- * (ite (>= (count e A) 1) 1 0))))
- * where skolem is a fresh variable equals (duplicate_removal A)
+ * (bag.count e skolem)
+ * (ite (>= (bag.count e A) 1) 1 0))))
+ * where skolem is a fresh variable equals (bag.duplicate_removal A)
*/
InferInfo duplicateRemoval(Node n, Node e);
/**
@@ -174,7 +172,7 @@ class InferenceGenerator
* (>= preImageSize 0)
* (forall ((i Int))
* (let ((uf_i (uf i)))
- * (let ((count_uf_i (bag.count uf_i A)))
+ * (let ((bag.count_uf_i (bag.count uf_i A)))
* (=>
* (and (>= i 1) (<= i preImageSize))
* (and
diff --git a/src/theory/bags/kinds b/src/theory/bags/kinds
index 55fd28695..a5c6e75bf 100644
--- a/src/theory/bags/kinds
+++ b/src/theory/bags/kinds
@@ -15,7 +15,7 @@ properties parametric
properties check presolve
# constants
-constant EMPTYBAG \
+constant BAG_EMPTY \
class \
EmptyBag \
::cvc5::EmptyBagHashFunction \
@@ -36,27 +36,27 @@ enumerator BAG_TYPE \
"theory/bags/theory_bags_type_enumerator.h"
# operators
-operator UNION_MAX 2 "union for bags (max)"
-operator UNION_DISJOINT 2 "disjoint union for bags (sum)"
-operator INTERSECTION_MIN 2 "bag intersection (min)"
+operator BAG_UNION_MAX 2 "union for bags (max)"
+operator BAG_UNION_DISJOINT 2 "disjoint union for bags (sum)"
+operator BAG_INTER_MIN 2 "bag intersection (min)"
-# {("a", 2), ("b", 3)} \ {("a", 1)} = {("a", 1), ("b", 3)}
-operator DIFFERENCE_SUBTRACT 2 "bag difference1 (subtracts multiplicities)"
+# {|("a", 2), ("b", 3)} \ {("a", 1)|} = {|("a", 1), ("b", 3)|}
+operator BAG_DIFFERENCE_SUBTRACT 2 "bag difference1 (subtracts multiplicities)"
-# {("a", 2), ("b", 3)} \\ {("a", 1)} = {("b", 3)}
-operator DIFFERENCE_REMOVE 2 "bag difference remove (removes shared elements)"
+# {|("a", 2), ("b", 3)} \\ {("a", 1)|} = {|("b", 3)|}
+operator BAG_DIFFERENCE_REMOVE 2 "bag difference remove (removes shared elements)"
-operator SUBBAG 2 "inclusion predicate for bags (less than or equal multiplicities)"
-operator BAG_COUNT 2 "multiplicity of an element in a bag"
-operator DUPLICATE_REMOVAL 1 "eliminate duplicates in a bag (also known as the delta operator,or the squash operator)"
+operator BAG_SUBBAG 2 "inclusion predicate for bags (less than or equal multiplicities)"
+operator BAG_COUNT 2 "multiplicity of an element in a bag"
+operator BAG_DUPLICATE_REMOVAL 1 "eliminate duplicates in a bag (also known as the delta operator,or the squash operator)"
-constant MK_BAG_OP \
+constant BAG_MAKE_OP \
class \
- MakeBagOp \
- ::cvc5::MakeBagOpHashFunction \
- "theory/bags/make_bag_op.h" \
- "operator for MK_BAG; payload is an instance of the cvc5::MakeBagOp class"
-parameterized MK_BAG MK_BAG_OP 2 \
+ BagMakeOp \
+ ::cvc5::BagMakeOpHashFunction \
+ "theory/bags/bag_make_op.h" \
+ "operator for BAG_MAKE; payload is an instance of the cvc5::BagMakeOp class"
+parameterized BAG_MAKE BAG_MAKE_OP 2 \
"constructs a bag from one element along with its multiplicity"
# The operator bag-is-singleton returns whether the given bag is a singleton
@@ -76,25 +76,25 @@ operator BAG_CHOOSE 1 "return an element in the bag given as a parameter
# of the second argument, a bag of type (Bag T1), and returns a bag of type (Bag T2).
operator BAG_MAP 2 "bag map function"
-typerule UNION_MAX ::cvc5::theory::bags::BinaryOperatorTypeRule
-typerule UNION_DISJOINT ::cvc5::theory::bags::BinaryOperatorTypeRule
-typerule INTERSECTION_MIN ::cvc5::theory::bags::BinaryOperatorTypeRule
-typerule DIFFERENCE_SUBTRACT ::cvc5::theory::bags::BinaryOperatorTypeRule
-typerule DIFFERENCE_REMOVE ::cvc5::theory::bags::BinaryOperatorTypeRule
-typerule SUBBAG ::cvc5::theory::bags::SubBagTypeRule
-typerule BAG_COUNT ::cvc5::theory::bags::CountTypeRule
-typerule DUPLICATE_REMOVAL ::cvc5::theory::bags::DuplicateRemovalTypeRule
-typerule MK_BAG_OP "SimpleTypeRule<RBuiltinOperator>"
-typerule MK_BAG ::cvc5::theory::bags::MkBagTypeRule
-typerule EMPTYBAG ::cvc5::theory::bags::EmptyBagTypeRule
-typerule BAG_CARD ::cvc5::theory::bags::CardTypeRule
-typerule BAG_CHOOSE ::cvc5::theory::bags::ChooseTypeRule
-typerule BAG_IS_SINGLETON ::cvc5::theory::bags::IsSingletonTypeRule
-typerule BAG_FROM_SET ::cvc5::theory::bags::FromSetTypeRule
-typerule BAG_TO_SET ::cvc5::theory::bags::ToSetTypeRule
-typerule BAG_MAP ::cvc5::theory::bags::BagMapTypeRule
-
-construle UNION_DISJOINT ::cvc5::theory::bags::BinaryOperatorTypeRule
-construle MK_BAG ::cvc5::theory::bags::MkBagTypeRule
+typerule BAG_UNION_MAX ::cvc5::theory::bags::BinaryOperatorTypeRule
+typerule BAG_UNION_DISJOINT ::cvc5::theory::bags::BinaryOperatorTypeRule
+typerule BAG_INTER_MIN ::cvc5::theory::bags::BinaryOperatorTypeRule
+typerule BAG_DIFFERENCE_SUBTRACT ::cvc5::theory::bags::BinaryOperatorTypeRule
+typerule BAG_DIFFERENCE_REMOVE ::cvc5::theory::bags::BinaryOperatorTypeRule
+typerule BAG_SUBBAG ::cvc5::theory::bags::SubBagTypeRule
+typerule BAG_COUNT ::cvc5::theory::bags::CountTypeRule
+typerule BAG_DUPLICATE_REMOVAL ::cvc5::theory::bags::DuplicateRemovalTypeRule
+typerule BAG_MAKE_OP "SimpleTypeRule<RBuiltinOperator>"
+typerule BAG_MAKE ::cvc5::theory::bags::BagMakeTypeRule
+typerule BAG_EMPTY ::cvc5::theory::bags::EmptyBagTypeRule
+typerule BAG_CARD ::cvc5::theory::bags::CardTypeRule
+typerule BAG_CHOOSE ::cvc5::theory::bags::ChooseTypeRule
+typerule BAG_IS_SINGLETON ::cvc5::theory::bags::IsSingletonTypeRule
+typerule BAG_FROM_SET ::cvc5::theory::bags::FromSetTypeRule
+typerule BAG_TO_SET ::cvc5::theory::bags::ToSetTypeRule
+typerule BAG_MAP ::cvc5::theory::bags::BagMapTypeRule
+
+construle BAG_UNION_DISJOINT ::cvc5::theory::bags::BinaryOperatorTypeRule
+construle BAG_MAKE ::cvc5::theory::bags::BagMakeTypeRule
endtheory
diff --git a/src/theory/bags/normal_form.cpp b/src/theory/bags/normal_form.cpp
index 59344cf0b..12bf513b5 100644
--- a/src/theory/bags/normal_form.cpp
+++ b/src/theory/bags/normal_form.cpp
@@ -28,19 +28,19 @@ namespace bags {
bool NormalForm::isConstant(TNode n)
{
- if (n.getKind() == EMPTYBAG)
+ if (n.getKind() == BAG_EMPTY)
{
// empty bags are already normalized
return true;
}
- if (n.getKind() == MK_BAG)
+ if (n.getKind() == BAG_MAKE)
{
// see the implementation in MkBagTypeRule::computeIsConst
return n.isConst();
}
- if (n.getKind() == UNION_DISJOINT)
+ if (n.getKind() == BAG_UNION_DISJOINT)
{
- if (!(n[0].getKind() == kind::MK_BAG && n[0].isConst()))
+ if (!(n[0].getKind() == kind::BAG_MAKE && n[0].isConst()))
{
// the first child is not a constant
return false;
@@ -48,9 +48,9 @@ bool NormalForm::isConstant(TNode n)
// store the previous element to check the ordering of elements
Node previousElement = n[0][0];
Node current = n[1];
- while (current.getKind() == UNION_DISJOINT)
+ while (current.getKind() == BAG_UNION_DISJOINT)
{
- if (!(current[0].getKind() == kind::MK_BAG && current[0].isConst()))
+ if (!(current[0].getKind() == kind::BAG_MAKE && current[0].isConst()))
{
// the current element is not a constant
return false;
@@ -64,7 +64,7 @@ bool NormalForm::isConstant(TNode n)
current = current[1];
}
// check last element
- if (!(current.getKind() == kind::MK_BAG && current.isConst()))
+ if (!(current.getKind() == kind::BAG_MAKE && current.isConst()))
{
// the last element is not a constant
return false;
@@ -77,7 +77,7 @@ bool NormalForm::isConstant(TNode n)
return true;
}
- // only nodes with kinds EMPTY_BAG, MK_BAG, and UNION_DISJOINT can be
+ // only nodes with kinds EMPTY_BAG, BAG_MAKE, and BAG_UNION_DISJOINT can be
// constants
return false;
}
@@ -97,14 +97,14 @@ Node NormalForm::evaluate(TNode n)
}
switch (n.getKind())
{
- case MK_BAG: return evaluateMakeBag(n);
+ case BAG_MAKE: return evaluateMakeBag(n);
case BAG_COUNT: return evaluateBagCount(n);
- case DUPLICATE_REMOVAL: return evaluateDuplicateRemoval(n);
- case UNION_DISJOINT: return evaluateUnionDisjoint(n);
- case UNION_MAX: return evaluateUnionMax(n);
- case INTERSECTION_MIN: return evaluateIntersectionMin(n);
- case DIFFERENCE_SUBTRACT: return evaluateDifferenceSubtract(n);
- case DIFFERENCE_REMOVE: return evaluateDifferenceRemove(n);
+ case BAG_DUPLICATE_REMOVAL: return evaluateDuplicateRemoval(n);
+ case BAG_UNION_DISJOINT: return evaluateUnionDisjoint(n);
+ case BAG_UNION_MAX: return evaluateUnionMax(n);
+ case BAG_INTER_MIN: return evaluateIntersectionMin(n);
+ case BAG_DIFFERENCE_SUBTRACT: return evaluateDifferenceSubtract(n);
+ case BAG_DIFFERENCE_REMOVE: return evaluateDifferenceRemove(n);
case BAG_CARD: return evaluateCard(n);
case BAG_IS_SINGLETON: return evaluateIsSingleton(n);
case BAG_FROM_SET: return evaluateFromSet(n);
@@ -172,19 +172,19 @@ std::map<Node, Rational> NormalForm::getBagElements(TNode n)
Assert(n.isConst()) << "node " << n << " is not in a normal form"
<< std::endl;
std::map<Node, Rational> elements;
- if (n.getKind() == EMPTYBAG)
+ if (n.getKind() == BAG_EMPTY)
{
return elements;
}
- while (n.getKind() == kind::UNION_DISJOINT)
+ while (n.getKind() == kind::BAG_UNION_DISJOINT)
{
- Assert(n[0].getKind() == kind::MK_BAG);
+ Assert(n[0].getKind() == kind::BAG_MAKE);
Node element = n[0][0];
Rational count = n[0][1].getConst<Rational>();
elements[element] = count;
n = n[1];
}
- Assert(n.getKind() == kind::MK_BAG);
+ Assert(n.getKind() == kind::BAG_MAKE);
Node lastElement = n[0];
Rational lastCount = n[1].getConst<Rational>();
elements[lastElement] = lastCount;
@@ -202,13 +202,15 @@ Node NormalForm::constructConstantBagFromElements(
}
TypeNode elementType = t.getBagElementType();
std::map<Node, Rational>::const_reverse_iterator it = elements.rbegin();
- Node bag =
- nm->mkBag(elementType, it->first, nm->mkConst<Rational>(it->second));
+ Node bag = nm->mkBag(elementType,
+ it->first,
+ nm->mkConst<Rational>(CONST_RATIONAL, it->second));
while (++it != elements.rend())
{
- Node n =
- nm->mkBag(elementType, it->first, nm->mkConst<Rational>(it->second));
- bag = nm->mkNode(UNION_DISJOINT, n, bag);
+ Node n = nm->mkBag(elementType,
+ it->first,
+ nm->mkConst<Rational>(CONST_RATIONAL, it->second));
+ bag = nm->mkNode(BAG_UNION_DISJOINT, n, bag);
}
return bag;
}
@@ -228,7 +230,7 @@ Node NormalForm::constructBagFromElements(TypeNode t,
while (++it != elements.rend())
{
Node n = nm->mkBag(elementType, it->first, it->second);
- bag = nm->mkNode(UNION_DISJOINT, n, bag);
+ bag = nm->mkNode(BAG_UNION_DISJOINT, n, bag);
}
return bag;
}
@@ -237,7 +239,7 @@ Node NormalForm::evaluateMakeBag(TNode n)
{
// the case where n is const should be handled earlier.
// here we handle the case where the multiplicity is zero or negative
- Assert(n.getKind() == MK_BAG && !n.isConst()
+ Assert(n.getKind() == BAG_MAKE && !n.isConst()
&& n[1].getConst<Rational>().sgn() < 1);
Node emptybag = NodeManager::currentNM()->mkConst(EmptyBag(n.getType()));
return emptybag;
@@ -248,11 +250,11 @@ Node NormalForm::evaluateBagCount(TNode n)
Assert(n.getKind() == BAG_COUNT);
// Examples
// --------
- // - (bag.count "x" (emptybag String)) = 0
- // - (bag.count "x" (mkBag "y" 5)) = 0
- // - (bag.count "x" (mkBag "x" 4)) = 4
- // - (bag.count "x" (union_disjoint (mkBag "x" 4) (mkBag "y" 5)) = 4
- // - (bag.count "x" (union_disjoint (mkBag "y" 5) (mkBag "z" 5)) = 0
+ // - (bag.count "x" (as bag.empty (Bag String))) = 0
+ // - (bag.count "x" (bag "y" 5)) = 0
+ // - (bag.count "x" (bag "x" 4)) = 4
+ // - (bag.count "x" (bag.union_disjoint (bag "x" 4) (bag "y" 5)) = 4
+ // - (bag.count "x" (bag.union_disjoint (bag "y" 5) (bag "z" 5)) = 0
std::map<Node, Rational> elements = getBagElements(n[1]);
std::map<Node, Rational>::iterator it = elements.find(n[0]);
@@ -260,22 +262,23 @@ Node NormalForm::evaluateBagCount(TNode n)
NodeManager* nm = NodeManager::currentNM();
if (it != elements.end())
{
- Node count = nm->mkConst(it->second);
+ Node count = nm->mkConst(CONST_RATIONAL, it->second);
return count;
}
- return nm->mkConst(Rational(0));
+ return nm->mkConst(CONST_RATIONAL, Rational(0));
}
Node NormalForm::evaluateDuplicateRemoval(TNode n)
{
- Assert(n.getKind() == DUPLICATE_REMOVAL);
+ Assert(n.getKind() == BAG_DUPLICATE_REMOVAL);
// Examples
// --------
- // - (duplicate_removal (emptybag String)) = (emptybag String)
- // - (duplicate_removal (mkBag "x" 4)) = (emptybag "x" 1)
- // - (duplicate_removal (disjoint_union (mkBag "x" 3) (mkBag "y" 5)) =
- // (disjoint_union (mkBag "x" 1) (mkBag "y" 1)
+ // - (bag.duplicate_removal (as bag.empty (Bag String))) = (as bag.empty (Bag
+ // String))
+ // - (bag.duplicate_removal (bag "x" 4)) = (bag "x" 1)
+ // - (bag.duplicate_removal (bag.disjoint_union (bag "x" 3) (bag "y" 5)) =
+ // (bag.disjoint_union (bag "x" 1) (bag "y" 1)
std::map<Node, Rational> oldElements = getBagElements(n[0]);
// copy elements from the old bag
@@ -292,16 +295,16 @@ Node NormalForm::evaluateDuplicateRemoval(TNode n)
Node NormalForm::evaluateUnionDisjoint(TNode n)
{
- Assert(n.getKind() == UNION_DISJOINT);
+ Assert(n.getKind() == BAG_UNION_DISJOINT);
// Example
// -------
- // input: (union_disjoint A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.union_disjoint A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (union_disjoint A B)
- // where A = (MK_BAG "x" 7)
- // B = (union_disjoint (MK_BAG "y" 1) (MK_BAG "z" 2)))
+ // (bag.union_disjoint A B)
+ // where A = (bag "x" 7)
+ // B = (bag.union_disjoint (bag "y" 1) (bag "z" 2)))
auto equal = [](std::map<Node, Rational>& elements,
std::map<Node, Rational>::const_iterator& itA,
@@ -352,16 +355,16 @@ Node NormalForm::evaluateUnionDisjoint(TNode n)
Node NormalForm::evaluateUnionMax(TNode n)
{
- Assert(n.getKind() == UNION_MAX);
+ Assert(n.getKind() == BAG_UNION_MAX);
// Example
// -------
- // input: (union_max A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.union_max A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (union_disjoint A B)
- // where A = (MK_BAG "x" 4)
- // B = (union_disjoint (MK_BAG "y" 1) (MK_BAG "z" 2)))
+ // (bag.union_disjoint A B)
+ // where A = (bag "x" 4)
+ // B = (bag.union_disjoint (bag "y" 1) (bag "z" 2)))
auto equal = [](std::map<Node, Rational>& elements,
std::map<Node, Rational>::const_iterator& itA,
@@ -412,14 +415,14 @@ Node NormalForm::evaluateUnionMax(TNode n)
Node NormalForm::evaluateIntersectionMin(TNode n)
{
- Assert(n.getKind() == INTERSECTION_MIN);
+ Assert(n.getKind() == BAG_INTER_MIN);
// Example
// -------
- // input: (intersectionMin A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.inter_min A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (MK_BAG "x" 3)
+ // (bag "x" 3)
auto equal = [](std::map<Node, Rational>& elements,
std::map<Node, Rational>::const_iterator& itA,
@@ -458,14 +461,14 @@ Node NormalForm::evaluateIntersectionMin(TNode n)
Node NormalForm::evaluateDifferenceSubtract(TNode n)
{
- Assert(n.getKind() == DIFFERENCE_SUBTRACT);
+ Assert(n.getKind() == BAG_DIFFERENCE_SUBTRACT);
// Example
// -------
- // input: (difference_subtract A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.difference_subtract A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (union_disjoint (MK_BAG "x" 1) (MK_BAG "z" 2))
+ // (bag.union_disjoint (bag "x" 1) (bag "z" 2))
auto equal = [](std::map<Node, Rational>& elements,
std::map<Node, Rational>::const_iterator& itA,
@@ -510,14 +513,14 @@ Node NormalForm::evaluateDifferenceSubtract(TNode n)
Node NormalForm::evaluateDifferenceRemove(TNode n)
{
- Assert(n.getKind() == DIFFERENCE_REMOVE);
+ Assert(n.getKind() == BAG_DIFFERENCE_REMOVE);
// Example
// -------
- // input: (difference_subtract A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.difference_remove A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (MK_BAG "z" 2)
+ // (bag "z" 2)
auto equal = [](std::map<Node, Rational>& elements,
std::map<Node, Rational>::const_iterator& itA,
@@ -564,9 +567,9 @@ Node NormalForm::evaluateChoose(TNode n)
Assert(n.getKind() == BAG_CHOOSE);
// Examples
// --------
- // - (bag.choose (MK_BAG "x" 4)) = "x"
+ // - (bag.choose (bag "x" 4)) = "x"
- if (n[0].getKind() == MK_BAG)
+ if (n[0].getKind() == BAG_MAKE)
{
return n[0][0];
}
@@ -578,9 +581,9 @@ Node NormalForm::evaluateCard(TNode n)
Assert(n.getKind() == BAG_CARD);
// Examples
// --------
- // - (card (emptyBag String)) = 0
- // - (choose (MK_BAG "x" 4)) = 4
- // - (choose (union_disjoint (MK_BAG "x" 4) (MK_BAG "y" 1))) = 5
+ // - (card (as bag.empty (Bag String))) = 0
+ // - (bag.choose (bag "x" 4)) = 4
+ // - (bag.choose (bag.union_disjoint (bag "x" 4) (bag "y" 1))) = 5
std::map<Node, Rational> elements = getBagElements(n[0]);
Rational sum(0);
@@ -590,7 +593,7 @@ Node NormalForm::evaluateCard(TNode n)
}
NodeManager* nm = NodeManager::currentNM();
- Node sumNode = nm->mkConst(sum);
+ Node sumNode = nm->mkConst(CONST_RATIONAL, sum);
return sumNode;
}
@@ -599,12 +602,13 @@ Node NormalForm::evaluateIsSingleton(TNode n)
Assert(n.getKind() == BAG_IS_SINGLETON);
// Examples
// --------
- // - (bag.is_singleton (emptyBag String)) = false
- // - (bag.is_singleton (MK_BAG "x" 1)) = true
- // - (bag.is_singleton (MK_BAG "x" 4)) = false
- // - (bag.is_singleton (union_disjoint (MK_BAG "x" 1) (MK_BAG "y" 1))) = false
+ // - (bag.is_singleton (as bag.empty (Bag String))) = false
+ // - (bag.is_singleton (bag "x" 1)) = true
+ // - (bag.is_singleton (bag "x" 4)) = false
+ // - (bag.is_singleton (bag.union_disjoint (bag "x" 1) (bag "y" 1)))
+ // = false
- if (n[0].getKind() == MK_BAG && n[0][1].getConst<Rational>().isOne())
+ if (n[0].getKind() == BAG_MAKE && n[0][1].getConst<Rational>().isOne())
{
return NodeManager::currentNM()->mkConst(true);
}
@@ -617,10 +621,10 @@ Node NormalForm::evaluateFromSet(TNode n)
// Examples
// --------
- // - (bag.from_set (set.empty String)) = (emptybag String)
- // - (bag.from_set (singleton "x")) = (mkBag "x" 1)
- // - (bag.from_set (union (singleton "x") (singleton "y"))) =
- // (disjoint_union (mkBag "x" 1) (mkBag "y" 1))
+ // - (bag.from_set (as set.empty (Set String))) = (as bag.empty (Bag String))
+ // - (bag.from_set (set.singleton "x")) = (bag "x" 1)
+ // - (bag.from_set (set.union (set.singleton "x") (set.singleton "y"))) =
+ // (bag.disjoint_union (bag "x" 1) (bag "y" 1))
NodeManager* nm = NodeManager::currentNM();
std::set<Node> setElements =
@@ -642,10 +646,10 @@ Node NormalForm::evaluateToSet(TNode n)
// Examples
// --------
- // - (bag.to_set (emptybag String)) = (set.empty String)
- // - (bag.to_set (mkBag "x" 4)) = (singleton "x")
- // - (bag.to_set (disjoint_union (mkBag "x" 3) (mkBag "y" 5)) =
- // (union (singleton "x") (singleton "y")))
+ // - (bag.to_set (as bag.empty (Bag String))) = (as set.empty (Set String))
+ // - (bag.to_set (bag "x" 4)) = (set.singleton "x")
+ // - (bag.to_set (bag.disjoint_union (bag "x" 3) (bag "y" 5)) =
+ // (set.union (set.singleton "x") (set.singleton "y")))
NodeManager* nm = NodeManager::currentNM();
std::map<Node, Rational> bagElements = getBagElements(n[0]);
@@ -667,8 +671,8 @@ Node NormalForm::evaluateBagMap(TNode n)
// Examples
// --------
// - (bag.map ((lambda ((x String)) "z")
- // (union_disjoint (bag "a" 2) (bag "b" 3)) =
- // (union_disjoint
+ // (bag.union_disjoint (bag "a" 2) (bag "b" 3)) =
+ // (bag.union_disjoint
// (bag ((lambda ((x String)) "z") "a") 2)
// (bag ((lambda ((x String)) "z") "b") 3)) =
// (bag "z" 5)
diff --git a/src/theory/bags/normal_form.h b/src/theory/bags/normal_form.h
index bf96a1fba..8ceee2881 100644
--- a/src/theory/bags/normal_form.h
+++ b/src/theory/bags/normal_form.h
@@ -30,11 +30,11 @@ class NormalForm
/**
* Returns true if n is considered a to be a (canonical) constant bag value.
* A canonical bag value is one whose AST is:
- * (union_disjoint (mkBag e1 c1) ...
- * (union_disjoint (mkBag e_{n-1} c_{n-1}) (mkBag e_n c_n))))
+ * (bag.union_disjoint (bag e1 c1) ...
+ * (bag.union_disjoint (bag e_{n-1} c_{n-1}) (bag e_n c_n))))
* where c1 ... cn are positive integers, e1 ... en are constants, and the
* node identifier of these constants are such that: e1 < ... < en.
- * Also handles the corner cases of empty bag and bag constructed by mkBag
+ * Also handles the corner cases of empty bag and bag constructed by bag
*/
static bool isConstant(TNode n);
/**
@@ -83,9 +83,9 @@ class NormalForm
* and elements of B (elementsB with iterator itB).
* The arguments below specify how these iterators are used to generate the
* elements of the result (elements).
- * @param n a node whose kind is a binary operator (union_disjoint, union_max,
- * intersection_min, difference_subtract, difference_remove) and whose
- * children are constant bags.
+ * @param n a node whose kind is a binary operator (bag.union_disjoint,
+ * union_max, intersection_min, difference_subtract, difference_remove) and
+ * whose children are constant bags.
* @param equal a lambda expression that receives (elements, itA, itB) and
* specify the action that needs to be taken when the elements of itA, itB are
* equal.
@@ -112,8 +112,8 @@ class NormalForm
T5&& remainderOfB);
/**
* evaluate n as follows:
- * - (mkBag a 0) = (emptybag T) where T is the type of the original bag
- * - (mkBag a (-c)) = (emptybag T) where T is the type the original bag,
+ * - (bag a 0) = (as bag.empty T) where T is the type of the original bag
+ * - (bag a (-c)) = (as bag.empty T) where T is the type the original bag,
* and c > 0 is a constant
*/
static Node evaluateMakeBag(TNode n);
@@ -126,7 +126,7 @@ class NormalForm
static Node evaluateBagCount(TNode n);
/**
- * @param n has the form (duplicate_removal A) where A is a constant bag
+ * @param n has the form (bag.duplicate_removal A) where A is a constant bag
* @return a constant bag constructed from the elements in A where each
* element has multiplicity one
*/
@@ -135,32 +135,33 @@ class NormalForm
/**
* evaluates union disjoint node such that the returned node is a canonical
* bag that has the form
- * (union_disjoint (mkBag e1 c1) ...
- * (union_disjoint * (mkBag e_{n-1} c_{n-1}) (mkBag e_n c_n)))) where
+ * (bag.union_disjoint (bag e1 c1) ...
+ * (bag.union_disjoint * (bag e_{n-1} c_{n-1}) (bag e_n c_n)))) where
* c1... cn are positive integers, e1 ... en are constants, and the node
* identifier of these constants are such that: e1 < ... < en.
- * @param n has the form (union_disjoint A B) where A, B are constant bags
+ * @param n has the form (bag.union_disjoint A B) where A, B are constant bags
* @return the union disjoint of A and B
*/
static Node evaluateUnionDisjoint(TNode n);
/**
- * @param n has the form (union_max A B) where A, B are constant bags
+ * @param n has the form (bag.union_max A B) where A, B are constant bags
* @return the union max of A and B
*/
static Node evaluateUnionMax(TNode n);
/**
- * @param n has the form (intersection_min A B) where A, B are constant bags
+ * @param n has the form (bag.inter_min A B) where A, B are constant bags
* @return the intersection min of A and B
*/
static Node evaluateIntersectionMin(TNode n);
/**
- * @param n has the form (difference_subtract A B) where A, B are constant
+ * @param n has the form (bag.difference_subtract A B) where A, B are constant
* bags
* @return the difference subtract of A and B
*/
static Node evaluateDifferenceSubtract(TNode n);
/**
- * @param n has the form (difference_remove A B) where A, B are constant bags
+ * @param n has the form (bag.difference_remove A B) where A, B are constant
+ * bags
* @return the difference remove of A and B
*/
static Node evaluateDifferenceRemove(TNode n);
diff --git a/src/theory/bags/rewrites.cpp b/src/theory/bags/rewrites.cpp
index c8aeec147..896c4f251 100644
--- a/src/theory/bags/rewrites.cpp
+++ b/src/theory/bags/rewrites.cpp
@@ -27,12 +27,13 @@ const char* toString(Rewrite r)
{
case Rewrite::NONE: return "NONE";
case Rewrite::CARD_DISJOINT: return "CARD_DISJOINT";
- case Rewrite::CARD_MK_BAG: return "CARD_MK_BAG";
- case Rewrite::CHOOSE_MK_BAG: return "CHOOSE_MK_BAG";
+ case Rewrite::CARD_BAG_MAKE: return "CARD_BAG_MAKE";
+ case Rewrite::CHOOSE_BAG_MAKE: return "CHOOSE_BAG_MAKE";
case Rewrite::CONSTANT_EVALUATION: return "CONSTANT_EVALUATION";
case Rewrite::COUNT_EMPTY: return "COUNT_EMPTY";
- case Rewrite::COUNT_MK_BAG: return "COUNT_MK_BAG";
- case Rewrite::DUPLICATE_REMOVAL_MK_BAG: return "DUPLICATE_REMOVAL_MK_BAG";
+ case Rewrite::COUNT_BAG_MAKE: return "COUNT_BAG_MAKE";
+ case Rewrite::DUPLICATE_REMOVAL_BAG_MAKE:
+ return "DUPLICATE_REMOVAL_BAG_MAKE";
case Rewrite::EQ_CONST_FALSE: return "EQ_CONST_FALSE";
case Rewrite::EQ_REFL: return "EQ_REFL";
case Rewrite::EQ_SYM: return "EQ_SYM";
@@ -43,11 +44,11 @@ const char* toString(Rewrite r)
case Rewrite::INTERSECTION_SAME: return "INTERSECTION_SAME";
case Rewrite::INTERSECTION_SHARED_LEFT: return "INTERSECTION_SHARED_LEFT";
case Rewrite::INTERSECTION_SHARED_RIGHT: return "INTERSECTION_SHARED_RIGHT";
- case Rewrite::IS_SINGLETON_MK_BAG: return "IS_SINGLETON_MK_BAG";
+ case Rewrite::IS_SINGLETON_BAG_MAKE: return "IS_SINGLETON_BAG_MAKE";
case Rewrite::MAP_CONST: return "MAP_CONST";
- case Rewrite::MAP_MK_BAG: return "MAP_MK_BAG";
+ case Rewrite::MAP_BAG_MAKE: return "MAP_BAG_MAKE";
case Rewrite::MAP_UNION_DISJOINT: return "MAP_UNION_DISJOINT";
- case Rewrite::MK_BAG_COUNT_NEGATIVE: return "MK_BAG_COUNT_NEGATIVE";
+ case Rewrite::BAG_MAKE_COUNT_NEGATIVE: return "BAG_MAKE_COUNT_NEGATIVE";
case Rewrite::REMOVE_FROM_UNION: return "REMOVE_FROM_UNION";
case Rewrite::REMOVE_MIN: return "REMOVE_MIN";
case Rewrite::REMOVE_RETURN_LEFT: return "REMOVE_RETURN_LEFT";
diff --git a/src/theory/bags/rewrites.h b/src/theory/bags/rewrites.h
index 78eb502c8..c5050ea72 100644
--- a/src/theory/bags/rewrites.h
+++ b/src/theory/bags/rewrites.h
@@ -32,12 +32,12 @@ enum class Rewrite : uint32_t
{
NONE, // no rewrite happened
CARD_DISJOINT,
- CARD_MK_BAG,
- CHOOSE_MK_BAG,
+ CARD_BAG_MAKE,
+ CHOOSE_BAG_MAKE,
CONSTANT_EVALUATION,
COUNT_EMPTY,
- COUNT_MK_BAG,
- DUPLICATE_REMOVAL_MK_BAG,
+ COUNT_BAG_MAKE,
+ DUPLICATE_REMOVAL_BAG_MAKE,
EQ_CONST_FALSE,
EQ_REFL,
EQ_SYM,
@@ -48,11 +48,11 @@ enum class Rewrite : uint32_t
INTERSECTION_SAME,
INTERSECTION_SHARED_LEFT,
INTERSECTION_SHARED_RIGHT,
- IS_SINGLETON_MK_BAG,
+ IS_SINGLETON_BAG_MAKE,
MAP_CONST,
- MAP_MK_BAG,
+ MAP_BAG_MAKE,
MAP_UNION_DISJOINT,
- MK_BAG_COUNT_NEGATIVE,
+ BAG_MAKE_COUNT_NEGATIVE,
REMOVE_FROM_UNION,
REMOVE_MIN,
REMOVE_RETURN_LEFT,
diff --git a/src/theory/bags/solver_state.cpp b/src/theory/bags/solver_state.cpp
index 50c6919fa..5c7c1dd73 100644
--- a/src/theory/bags/solver_state.cpp
+++ b/src/theory/bags/solver_state.cpp
@@ -91,7 +91,7 @@ void SolverState::collectBagsAndCountTerms()
Node n = (*it);
Trace("bags-eqc") << (*it) << " ";
Kind k = n.getKind();
- if (k == MK_BAG)
+ if (k == BAG_MAKE)
{
// for terms (bag x c) we need to store x by registering the count term
// (bag.count x (bag x c))
diff --git a/src/theory/bags/solver_state.h b/src/theory/bags/solver_state.h
index 68fffacbd..d6f628537 100644
--- a/src/theory/bags/solver_state.h
+++ b/src/theory/bags/solver_state.h
@@ -29,8 +29,7 @@ namespace bags {
class SolverState : public TheoryState
{
public:
- SolverState(Env& env,
- Valuation val);
+ SolverState(Env& env, Valuation val);
/**
* This function adds the bag representative n to the set d_bags if it is not
diff --git a/src/theory/bags/theory_bags.cpp b/src/theory/bags/theory_bags.cpp
index 813f45669..861aaf862 100644
--- a/src/theory/bags/theory_bags.cpp
+++ b/src/theory/bags/theory_bags.cpp
@@ -66,14 +66,14 @@ void TheoryBags::finishInit()
d_valuation.setUnevaluatedKind(WITNESS);
// functions we are doing congruence over
- d_equalityEngine->addFunctionKind(UNION_MAX);
- d_equalityEngine->addFunctionKind(UNION_DISJOINT);
- d_equalityEngine->addFunctionKind(INTERSECTION_MIN);
- d_equalityEngine->addFunctionKind(DIFFERENCE_SUBTRACT);
- d_equalityEngine->addFunctionKind(DIFFERENCE_REMOVE);
+ d_equalityEngine->addFunctionKind(BAG_UNION_MAX);
+ d_equalityEngine->addFunctionKind(BAG_UNION_DISJOINT);
+ d_equalityEngine->addFunctionKind(BAG_INTER_MIN);
+ d_equalityEngine->addFunctionKind(BAG_DIFFERENCE_SUBTRACT);
+ d_equalityEngine->addFunctionKind(BAG_DIFFERENCE_REMOVE);
d_equalityEngine->addFunctionKind(BAG_COUNT);
- d_equalityEngine->addFunctionKind(DUPLICATE_REMOVAL);
- d_equalityEngine->addFunctionKind(MK_BAG);
+ d_equalityEngine->addFunctionKind(BAG_DUPLICATE_REMOVAL);
+ d_equalityEngine->addFunctionKind(BAG_MAKE);
d_equalityEngine->addFunctionKind(BAG_CARD);
d_equalityEngine->addFunctionKind(BAG_FROM_SET);
d_equalityEngine->addFunctionKind(BAG_TO_SET);
@@ -98,7 +98,7 @@ TrustNode TheoryBags::expandChooseOperator(const Node& node,
// (bag.choose A) is expanded as
// (witness ((x elementType))
// (ite
- // (= A (as emptybag (Bag E)))
+ // (= A (as bag.empty (Bag E)))
// (= x (uf A))
// (and (>= (bag.count x A) 1) (= x (uf A)))
// where uf: (Bag E) -> E is a skolem function, and E is the type of elements
@@ -119,7 +119,7 @@ TrustNode TheoryBags::expandChooseOperator(const Node& node,
Node emptyBag = nm->mkConst(EmptyBag(bagType));
Node isEmpty = A.eqNode(emptyBag);
Node count = nm->mkNode(BAG_COUNT, x, A);
- Node one = nm->mkConst(Rational(1));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
Node geqOne = nm->mkNode(GEQ, count, one);
Node geqOneAndEqual = geqOne.andNode(equal);
Node ite = nm->mkNode(ITE, isEmpty, equal, geqOneAndEqual);
diff --git a/src/theory/bags/theory_bags_type_enumerator.cpp b/src/theory/bags/theory_bags_type_enumerator.cpp
index be9e0cd4d..58a1b3291 100644
--- a/src/theory/bags/theory_bags_type_enumerator.cpp
+++ b/src/theory/bags/theory_bags_type_enumerator.cpp
@@ -20,6 +20,8 @@
#include "theory_bags_type_enumerator.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace bags {
@@ -55,17 +57,17 @@ Node BagEnumerator::operator*()
BagEnumerator& BagEnumerator::operator++()
{
// increase the multiplicity by one
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
TypeNode elementType = d_elementTypeEnumerator.getType();
Node singleton = d_nodeManager->mkBag(elementType, d_element, one);
- if (d_currentBag.getKind() == kind::EMPTYBAG)
+ if (d_currentBag.getKind() == kind::BAG_EMPTY)
{
d_currentBag = singleton;
}
else
{
- d_currentBag =
- d_nodeManager->mkNode(kind::UNION_DISJOINT, singleton, d_currentBag);
+ d_currentBag = d_nodeManager->mkNode(
+ kind::BAG_UNION_DISJOINT, singleton, d_currentBag);
}
d_currentBag = Rewriter::rewrite(d_currentBag);
diff --git a/src/theory/bags/theory_bags_type_rules.cpp b/src/theory/bags/theory_bags_type_rules.cpp
index 089038267..2623f3ed7 100644
--- a/src/theory/bags/theory_bags_type_rules.cpp
+++ b/src/theory/bags/theory_bags_type_rules.cpp
@@ -19,7 +19,7 @@
#include "base/check.h"
#include "expr/emptybag.h"
-#include "theory/bags/make_bag_op.h"
+#include "theory/bags/bag_make_op.h"
#include "theory/bags/normal_form.h"
#include "util/cardinality.h"
#include "util/rational.h"
@@ -32,10 +32,11 @@ TypeNode BinaryOperatorTypeRule::computeType(NodeManager* nodeManager,
TNode n,
bool check)
{
- Assert(n.getKind() == kind::UNION_MAX || n.getKind() == kind::UNION_DISJOINT
- || n.getKind() == kind::INTERSECTION_MIN
- || n.getKind() == kind::DIFFERENCE_SUBTRACT
- || n.getKind() == kind::DIFFERENCE_REMOVE);
+ Assert(n.getKind() == kind::BAG_UNION_MAX
+ || n.getKind() == kind::BAG_UNION_DISJOINT
+ || n.getKind() == kind::BAG_INTER_MIN
+ || n.getKind() == kind::BAG_DIFFERENCE_SUBTRACT
+ || n.getKind() == kind::BAG_DIFFERENCE_REMOVE);
TypeNode bagType = n[0].getType(check);
if (check)
{
@@ -61,7 +62,7 @@ bool BinaryOperatorTypeRule::computeIsConst(NodeManager* nodeManager, TNode n)
{
// only UNION_DISJOINT has a const rule in kinds.
// Other binary operators do not have const rules in kinds
- Assert(n.getKind() == kind::UNION_DISJOINT);
+ Assert(n.getKind() == kind::BAG_UNION_DISJOINT);
return NormalForm::isConstant(n);
}
@@ -69,13 +70,13 @@ TypeNode SubBagTypeRule::computeType(NodeManager* nodeManager,
TNode n,
bool check)
{
- Assert(n.getKind() == kind::SUBBAG);
+ Assert(n.getKind() == kind::BAG_SUBBAG);
TypeNode bagType = n[0].getType(check);
if (check)
{
if (!bagType.isBag())
{
- throw TypeCheckingExceptionPrivate(n, "SUBBAG operating on non-bag");
+ throw TypeCheckingExceptionPrivate(n, "BAG_SUBBAG operating on non-bag");
}
TypeNode secondBagType = n[1].getType(check);
if (secondBagType != bagType)
@@ -83,7 +84,7 @@ TypeNode SubBagTypeRule::computeType(NodeManager* nodeManager,
if (!bagType.isComparableTo(secondBagType))
{
throw TypeCheckingExceptionPrivate(
- n, "SUBBAG operating on bags of different types");
+ n, "BAG_SUBBAG operating on bags of different types");
}
}
}
@@ -104,8 +105,8 @@ TypeNode CountTypeRule::computeType(NodeManager* nodeManager,
n, "checking for membership in a non-bag");
}
TypeNode elementType = n[0].getType(check);
- // e.g. (count 1 (mkBag (mkBag_op Real) 1.0 3))) is 3 whereas
- // (count 1.0 (mkBag (mkBag_op Int) 1 3))) throws a typing error
+ // e.g. (bag.count 1 (bag (BagMakeOp Real) 1.0 3))) is 3 whereas
+ // (bag.count 1.0 (bag (BagMakeOp Int) 1 3)) throws a typing error
if (!elementType.isSubtypeOf(bagType.getBagElementType()))
{
std::stringstream ss;
@@ -123,25 +124,26 @@ TypeNode DuplicateRemovalTypeRule::computeType(NodeManager* nodeManager,
TNode n,
bool check)
{
- Assert(n.getKind() == kind::DUPLICATE_REMOVAL);
+ Assert(n.getKind() == kind::BAG_DUPLICATE_REMOVAL);
TypeNode bagType = n[0].getType(check);
if (check)
{
if (!bagType.isBag())
{
std::stringstream ss;
- ss << "Applying DUPLICATE_REMOVAL on a non-bag argument in term " << n;
+ ss << "Applying BAG_DUPLICATE_REMOVAL on a non-bag argument in term "
+ << n;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
}
return bagType;
}
-TypeNode MkBagTypeRule::computeType(NodeManager* nm, TNode n, bool check)
+TypeNode BagMakeTypeRule::computeType(NodeManager* nm, TNode n, bool check)
{
- Assert(n.getKind() == kind::MK_BAG && n.hasOperator()
- && n.getOperator().getKind() == kind::MK_BAG_OP);
- MakeBagOp op = n.getOperator().getConst<MakeBagOp>();
+ Assert(n.getKind() == kind::BAG_MAKE && n.hasOperator()
+ && n.getOperator().getKind() == kind::BAG_MAKE_OP);
+ BagMakeOp op = n.getOperator().getConst<BagMakeOp>();
TypeNode expectedElementType = op.getType();
if (check)
{
@@ -149,20 +151,20 @@ TypeNode MkBagTypeRule::computeType(NodeManager* nm, TNode n, bool check)
{
std::stringstream ss;
ss << "operands in term " << n << " are " << n.getNumChildren()
- << ", but MK_BAG expects 2 operands.";
+ << ", but BAG_MAKE expects 2 operands.";
throw TypeCheckingExceptionPrivate(n, ss.str());
}
TypeNode type1 = n[1].getType(check);
if (!type1.isInteger())
{
std::stringstream ss;
- ss << "MK_BAG expects an integer for " << n[1] << ". Found" << type1;
+ ss << "BAG_MAKE expects an integer for " << n[1] << ". Found" << type1;
throw TypeCheckingExceptionPrivate(n, ss.str());
}
TypeNode actualElementType = n[0].getType(check);
// the type of the element should be a subtype of the type of the operator
- // e.g. (mkBag (mkBag_op Real) 1 1) where 1 is an Int
+ // e.g. (bag (bag_op Real) 1 1) where 1 is an Int
if (!actualElementType.isSubtypeOf(expectedElementType))
{
std::stringstream ss;
@@ -176,9 +178,9 @@ TypeNode MkBagTypeRule::computeType(NodeManager* nm, TNode n, bool check)
return nm->mkBagType(expectedElementType);
}
-bool MkBagTypeRule::computeIsConst(NodeManager* nodeManager, TNode n)
+bool BagMakeTypeRule::computeIsConst(NodeManager* nodeManager, TNode n)
{
- Assert(n.getKind() == kind::MK_BAG);
+ Assert(n.getKind() == kind::BAG_MAKE);
// for a bag to be a constant, both the element and its multiplicity should
// be constants, and the multiplicity should be > 0.
return n[0].isConst() && n[1].isConst()
@@ -206,7 +208,7 @@ TypeNode EmptyBagTypeRule::computeType(NodeManager* nodeManager,
TNode n,
bool check)
{
- Assert(n.getKind() == kind::EMPTYBAG);
+ Assert(n.getKind() == kind::BAG_EMPTY);
EmptyBag emptyBag = n.getConst<EmptyBag>();
return emptyBag.getType();
}
diff --git a/src/theory/bags/theory_bags_type_rules.h b/src/theory/bags/theory_bags_type_rules.h
index 53a63a687..d7b8b2737 100644
--- a/src/theory/bags/theory_bags_type_rules.h
+++ b/src/theory/bags/theory_bags_type_rules.h
@@ -29,9 +29,9 @@ namespace theory {
namespace bags {
/**
- * Type rule for binary operators (union_max, union_disjoint, intersection_min
- * difference_subtract, difference_remove)
- * to check if the two arguments are of the same sort.
+ * Type rule for binary operators (bag.union_max, bag.union_disjoint,
+ * bag.inter_min bag.difference_subtract, bag.difference_remove) to check
+ * if the two arguments are bags of the same sort.
*/
struct BinaryOperatorTypeRule
{
@@ -40,8 +40,8 @@ struct BinaryOperatorTypeRule
}; /* struct BinaryOperatorTypeRule */
/**
- * Type rule for binary operator subbag to check if the two arguments have the
- * same sort.
+ * Type rule for binary operator bag.subbag to check if the two arguments are
+ * bags of the same sort.
*/
struct SubBagTypeRule
{
@@ -58,7 +58,7 @@ struct CountTypeRule
}; /* struct CountTypeRule */
/**
- * Type rule for duplicate_removal to check the argument is of a bag.
+ * Type rule for bag.duplicate_removal to check the argument is of a bag.
*/
struct DuplicateRemovalTypeRule
{
@@ -69,22 +69,22 @@ struct DuplicateRemovalTypeRule
* Type rule for (bag op e) operator to check the sort of e matches the sort
* stored in op.
*/
-struct MkBagTypeRule
+struct BagMakeTypeRule
{
static TypeNode computeType(NodeManager* nm, TNode n, bool check);
static bool computeIsConst(NodeManager* nodeManager, TNode n);
-}; /* struct MkBagTypeRule */
+}; /* struct BagMakeTypeRule */
/**
- * Type rule for bag.is_singleton to check the argument is of a bag.
+ * Type rule for (bag.is_singleton B) to check the argument B is a bag.
*/
struct IsSingletonTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
-}; /* struct IsMkBagTypeRule */
+}; /* struct IsSingletonTypeRule */
/**
- * Type rule for (as emptybag (Bag ...))
+ * Type rule for (as bag.empty (Bag T)) where T is a type
*/
struct EmptyBagTypeRule
{
@@ -92,7 +92,7 @@ struct EmptyBagTypeRule
}; /* struct EmptyBagTypeRule */
/**
- * Type rule for (bag.card ..) to check the argument is of a bag.
+ * Type rule for (bag.card B) to check the argument B is a bag.
*/
struct CardTypeRule
{
@@ -100,7 +100,7 @@ struct CardTypeRule
}; /* struct CardTypeRule */
/**
- * Type rule for (bag.choose ..) to check the argument is of a bag.
+ * Type rule for (bag.choose B) to check the argument B is a bag.
*/
struct ChooseTypeRule
{
diff --git a/src/theory/booleans/proof_circuit_propagator.cpp b/src/theory/booleans/proof_circuit_propagator.cpp
index 1ec8f7b67..9190f423f 100644
--- a/src/theory/booleans/proof_circuit_propagator.cpp
+++ b/src/theory/booleans/proof_circuit_propagator.cpp
@@ -21,6 +21,8 @@
#include "proof/proof_node_manager.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace booleans {
@@ -31,7 +33,7 @@ namespace {
template <typename T>
Node mkRat(T val)
{
- return NodeManager::currentNM()->mkConst<Rational>(val);
+ return NodeManager::currentNM()->mkConst<Rational>(CONST_RATIONAL, val);
}
/**
diff --git a/src/theory/builtin/proof_checker.cpp b/src/theory/builtin/proof_checker.cpp
index d5b856456..9c05407b7 100644
--- a/src/theory/builtin/proof_checker.cpp
+++ b/src/theory/builtin/proof_checker.cpp
@@ -400,7 +400,7 @@ bool BuiltinProofRuleChecker::getTheoryId(TNode n, TheoryId& tid)
Node BuiltinProofRuleChecker::mkTheoryIdNode(TheoryId tid)
{
return NodeManager::currentNM()->mkConst(
- Rational(static_cast<uint32_t>(tid)));
+ CONST_RATIONAL, Rational(static_cast<uint32_t>(tid)));
}
} // namespace builtin
diff --git a/src/theory/bv/int_blaster.cpp b/src/theory/bv/int_blaster.cpp
index ba0e51595..eff5ec611 100644
--- a/src/theory/bv/int_blaster.cpp
+++ b/src/theory/bv/int_blaster.cpp
@@ -32,9 +32,11 @@
#include "util/iand.h"
#include "util/rational.h"
-namespace cvc5 {
+using namespace cvc5::kind;
using namespace cvc5::theory;
+namespace cvc5 {
+
namespace {
// A helper function to compute 2^b as a Rational
@@ -57,8 +59,8 @@ IntBlaster::IntBlaster(Env& env,
d_introduceFreshIntVars(introduceFreshIntVars)
{
d_nm = NodeManager::currentNM();
- d_zero = d_nm->mkConst<Rational>(0);
- d_one = d_nm->mkConst<Rational>(1);
+ d_zero = d_nm->mkConst<Rational>(CONST_RATIONAL, 0);
+ d_one = d_nm->mkConst<Rational>(CONST_RATIONAL, 1);
};
IntBlaster::~IntBlaster() {}
@@ -80,18 +82,18 @@ Node IntBlaster::maxInt(uint64_t k)
{
Assert(k > 0);
Rational max_value = intpow2(k) - 1;
- return d_nm->mkConst<Rational>(max_value);
+ return d_nm->mkConst<Rational>(CONST_RATIONAL, max_value);
}
Node IntBlaster::pow2(uint64_t k)
{
Assert(k >= 0);
- return d_nm->mkConst<Rational>(intpow2(k));
+ return d_nm->mkConst<Rational>(CONST_RATIONAL, intpow2(k));
}
Node IntBlaster::modpow2(Node n, uint64_t exponent)
{
- Node p2 = d_nm->mkConst<Rational>(intpow2(exponent));
+ Node p2 = d_nm->mkConst<Rational>(CONST_RATIONAL, intpow2(exponent));
return d_nm->mkNode(kind::INTS_MODULUS_TOTAL, n, p2);
}
@@ -657,7 +659,7 @@ Node IntBlaster::translateNoChildren(Node original,
// Bit-vector constants are transformed into their integer value.
BitVector constant(original.getConst<BitVector>());
Integer c = constant.toInteger();
- translation = d_nm->mkConst<Rational>(c);
+ translation = d_nm->mkConst<Rational>(CONST_RATIONAL, c);
}
else
{
diff --git a/src/theory/bv/theory_bv_utils.cpp b/src/theory/bv/theory_bv_utils.cpp
index bc6096cbb..adb067045 100644
--- a/src/theory/bv/theory_bv_utils.cpp
+++ b/src/theory/bv/theory_bv_utils.cpp
@@ -23,6 +23,8 @@
#include "util/bitvector.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace bv {
@@ -465,7 +467,7 @@ Node eliminateBv2Nat(TNode node)
{
const unsigned size = utils::getSize(node[0]);
NodeManager* const nm = NodeManager::currentNM();
- const Node z = nm->mkConst(Rational(0));
+ const Node z = nm->mkConst(CONST_RATIONAL, Rational(0));
const Node bvone = utils::mkOne(1);
Integer i = 1;
@@ -476,8 +478,8 @@ Node eliminateBv2Nat(TNode node)
nm->mkNode(kind::EQUAL,
nm->mkNode(nm->mkConst(BitVectorExtract(bit, bit)), node[0]),
bvone);
- children.push_back(
- nm->mkNode(kind::ITE, cond, nm->mkConst(Rational(i)), z));
+ children.push_back(nm->mkNode(
+ kind::ITE, cond, nm->mkConst(CONST_RATIONAL, Rational(i)), z));
}
// avoid plus with one child
return children.size() == 1 ? children[0] : nm->mkNode(kind::PLUS, children);
@@ -494,10 +496,11 @@ Node eliminateInt2Bv(TNode node)
Integer i = 2;
while (v.size() < size)
{
- Node cond = nm->mkNode(
- kind::GEQ,
- nm->mkNode(kind::INTS_MODULUS_TOTAL, node[0], nm->mkConst(Rational(i))),
- nm->mkConst(Rational(i, 2)));
+ Node cond = nm->mkNode(kind::GEQ,
+ nm->mkNode(kind::INTS_MODULUS_TOTAL,
+ node[0],
+ nm->mkConst(CONST_RATIONAL, Rational(i))),
+ nm->mkConst(CONST_RATIONAL, Rational(i, 2)));
v.push_back(nm->mkNode(kind::ITE, cond, bvone, bvzero));
i *= 2;
}
diff --git a/src/theory/datatypes/datatypes_rewriter.cpp b/src/theory/datatypes/datatypes_rewriter.cpp
index fd957baaa..4cda9f728 100644
--- a/src/theory/datatypes/datatypes_rewriter.cpp
+++ b/src/theory/datatypes/datatypes_rewriter.cpp
@@ -78,7 +78,7 @@ RewriteResponse DatatypesRewriter::postRewrite(TNode in)
const DType& dt = utils::datatypeOf(constructor);
const DTypeConstructor& c = dt[constructorIndex];
unsigned weight = c.getWeight();
- children.push_back(nm->mkConst(Rational(weight)));
+ children.push_back(nm->mkConst(CONST_RATIONAL, Rational(weight)));
Node res =
children.size() == 1 ? children[0] : nm->mkNode(kind::PLUS, children);
Trace("datatypes-rewrite")
@@ -104,8 +104,9 @@ RewriteResponse DatatypesRewriter::postRewrite(TNode in)
res = nm->mkConst(false);
break;
}
- children.push_back(
- nm->mkNode(kind::DT_HEIGHT_BOUND, in[0][i], nm->mkConst(rmo)));
+ children.push_back(nm->mkNode(kind::DT_HEIGHT_BOUND,
+ in[0][i],
+ nm->mkConst(CONST_RATIONAL, rmo)));
}
}
if (res.isNull())
diff --git a/src/theory/datatypes/infer_proof_cons.cpp b/src/theory/datatypes/infer_proof_cons.cpp
index 4aace5f1c..7ca58905f 100644
--- a/src/theory/datatypes/infer_proof_cons.cpp
+++ b/src/theory/datatypes/infer_proof_cons.cpp
@@ -108,7 +108,7 @@ void InferProofCons::convert(InferenceId infer, TNode conc, TNode exp, CDProof*
}
if (argSuccess)
{
- narg = nm->mkConst(Rational(i));
+ narg = nm->mkConst(CONST_RATIONAL, Rational(i));
break;
}
}
@@ -141,7 +141,7 @@ void InferProofCons::convert(InferenceId infer, TNode conc, TNode exp, CDProof*
if (n >= 0)
{
Node t = exp[0];
- Node nn = nm->mkConst(Rational(n));
+ Node nn = nm->mkConst(CONST_RATIONAL, Rational(n));
Node eq = exp.eqNode(conc);
cdp->addStep(eq, PfRule::DT_INST, {}, {t, nn});
cdp->addStep(conc, PfRule::EQ_RESOLVE, {exp, eq}, {});
diff --git a/src/theory/datatypes/sygus_extension.cpp b/src/theory/datatypes/sygus_extension.cpp
index bacbf8c47..88a3e43d7 100644
--- a/src/theory/datatypes/sygus_extension.cpp
+++ b/src/theory/datatypes/sygus_extension.cpp
@@ -57,7 +57,7 @@ SygusExtension::SygusExtension(Env& env,
d_active_terms(context()),
d_currTermSize(context())
{
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
d_true = NodeManager::currentNM()->mkConst(true);
}
@@ -1772,8 +1772,8 @@ Node SygusExtension::SygusSizeDecisionStrategy::getOrMkMeasureValue()
NodeManager* nm = NodeManager::currentNM();
SkolemManager* sm = nm->getSkolemManager();
d_measure_value = sm->mkDummySkolem("mt", nm->integerType());
- Node mtlem =
- nm->mkNode(kind::GEQ, d_measure_value, nm->mkConst(Rational(0)));
+ Node mtlem = nm->mkNode(
+ kind::GEQ, d_measure_value, nm->mkConst(CONST_RATIONAL, Rational(0)));
d_im.lemma(mtlem, InferenceId::DATATYPES_SYGUS_MT_POS);
}
return d_measure_value;
@@ -1787,7 +1787,8 @@ Node SygusExtension::SygusSizeDecisionStrategy::getOrMkActiveMeasureValue(
NodeManager* nm = NodeManager::currentNM();
SkolemManager* sm = nm->getSkolemManager();
Node new_mt = sm->mkDummySkolem("mt", nm->integerType());
- Node mtlem = nm->mkNode(kind::GEQ, new_mt, nm->mkConst(Rational(0)));
+ Node mtlem =
+ nm->mkNode(kind::GEQ, new_mt, nm->mkConst(CONST_RATIONAL, Rational(0)));
d_measure_value_active = new_mt;
d_im.lemma(mtlem, InferenceId::DATATYPES_SYGUS_MT_POS);
}
@@ -1816,7 +1817,8 @@ Node SygusExtension::SygusSizeDecisionStrategy::mkLiteral(unsigned s)
NodeManager* nm = NodeManager::currentNM();
Trace("sygus-engine") << "******* Sygus : allocate size literal " << s
<< " for " << d_this << std::endl;
- return nm->mkNode(DT_SYGUS_BOUND, d_this, nm->mkConst(Rational(s)));
+ return nm->mkNode(
+ DT_SYGUS_BOUND, d_this, nm->mkConst(CONST_RATIONAL, Rational(s)));
}
int SygusExtension::getGuardStatus( Node g ) {
diff --git a/src/theory/datatypes/sygus_simple_sym.cpp b/src/theory/datatypes/sygus_simple_sym.cpp
index 63e60a478..1b5e37bc3 100644
--- a/src/theory/datatypes/sygus_simple_sym.cpp
+++ b/src/theory/datatypes/sygus_simple_sym.cpp
@@ -245,7 +245,7 @@ bool SygusSimpleSymBreak::considerArgKind(
rt.d_children[0].d_req_kind = PLUS;
rt.d_children[0].d_children[0].d_req_type = dt[c].getArgType(1);
rt.d_children[0].d_children[1].d_req_const =
- NodeManager::currentNM()->mkConst(Rational(1));
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
rt.d_children[1].d_req_type = dt[c].getArgType(0);
}
else if (k == LT || k == GEQ)
@@ -256,7 +256,7 @@ bool SygusSimpleSymBreak::considerArgKind(
rt.d_children[1].d_req_kind = PLUS;
rt.d_children[1].d_children[0].d_req_type = dt[c].getArgType(0);
rt.d_children[1].d_children[1].d_req_const =
- NodeManager::currentNM()->mkConst(Rational(1));
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
}
}
else if (pk == BITVECTOR_NOT)
diff --git a/src/theory/datatypes/theory_datatypes.cpp b/src/theory/datatypes/theory_datatypes.cpp
index 055b06c47..b19eb53af 100644
--- a/src/theory/datatypes/theory_datatypes.cpp
+++ b/src/theory/datatypes/theory_datatypes.cpp
@@ -68,7 +68,7 @@ TheoryDatatypes::TheoryDatatypes(Env& env,
{
d_true = NodeManager::currentNM()->mkConst( true );
- d_zero = NodeManager::currentNM()->mkConst( Rational(0) );
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
d_dtfCounter = 0;
// indicate we are using the default theory state object
diff --git a/src/theory/difficulty_manager.cpp b/src/theory/difficulty_manager.cpp
index 3df86383f..c09120771 100644
--- a/src/theory/difficulty_manager.cpp
+++ b/src/theory/difficulty_manager.cpp
@@ -20,6 +20,8 @@
#include "theory/theory_model.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
@@ -33,7 +35,7 @@ void DifficultyManager::getDifficultyMap(std::map<Node, Node>& dmap)
NodeManager* nm = NodeManager::currentNM();
for (const std::pair<const Node, uint64_t> p : d_dfmap)
{
- dmap[p.first] = nm->mkConst(Rational(p.second));
+ dmap[p.first] = nm->mkConst(CONST_RATIONAL, Rational(p.second));
}
}
diff --git a/src/theory/evaluator.cpp b/src/theory/evaluator.cpp
index f7c5ddf0f..27e67dd9f 100644
--- a/src/theory/evaluator.cpp
+++ b/src/theory/evaluator.cpp
@@ -21,6 +21,8 @@
#include "theory/theory.h"
#include "util/integer.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
@@ -115,7 +117,7 @@ Node EvalResult::toNode() const
{
case EvalResult::BOOL: return nm->mkConst(d_bool);
case EvalResult::BITVECTOR: return nm->mkConst(d_bv);
- case EvalResult::RATIONAL: return nm->mkConst(d_rat);
+ case EvalResult::RATIONAL: return nm->mkConst(CONST_RATIONAL, d_rat);
case EvalResult::STRING: return nm->mkConst(d_str);
case EvalResult::UCONST: return nm->mkConst(d_uc);
default:
diff --git a/src/theory/fp/theory_fp.cpp b/src/theory/fp/theory_fp.cpp
index 6f2ddbf63..d8e35d8e5 100644
--- a/src/theory/fp/theory_fp.cpp
+++ b/src/theory/fp/theory_fp.cpp
@@ -31,6 +31,7 @@
#include "util/floatingpoint.h"
using namespace std;
+using namespace cvc5::kind;
namespace cvc5 {
namespace theory {
@@ -363,7 +364,7 @@ bool TheoryFp::refineAbstraction(TheoryModel *m, TNode abstract, TNode concrete)
Node realValueOfAbstract =
rewrite(nm->mkNode(kind::FLOATINGPOINT_TO_REAL_TOTAL,
abstractValue,
- nm->mkConst(Rational(0U))));
+ nm->mkConst(CONST_RATIONAL, Rational(0U))));
Node bg = nm->mkNode(
kind::IMPLIES,
@@ -566,10 +567,11 @@ void TheoryFp::registerTerm(TNode node)
nm->mkNode(kind::EQUAL, node, node[1]));
handleLemma(pd, InferenceId::FP_REGISTER_TERM);
- Node z =
- nm->mkNode(kind::IMPLIES,
- nm->mkNode(kind::FLOATINGPOINT_ISZ, node[0]),
- nm->mkNode(kind::EQUAL, node, nm->mkConst(Rational(0U))));
+ Node z = nm->mkNode(
+ kind::IMPLIES,
+ nm->mkNode(kind::FLOATINGPOINT_ISZ, node[0]),
+ nm->mkNode(
+ kind::EQUAL, node, nm->mkConst(CONST_RATIONAL, Rational(0U))));
handleLemma(z, InferenceId::FP_REGISTER_TERM);
return;
@@ -590,7 +592,8 @@ void TheoryFp::registerTerm(TNode node)
Node z = nm->mkNode(
kind::IMPLIES,
- nm->mkNode(kind::EQUAL, node[1], nm->mkConst(Rational(0U))),
+ nm->mkNode(
+ kind::EQUAL, node[1], nm->mkConst(CONST_RATIONAL, Rational(0U))),
nm->mkNode(kind::EQUAL,
node,
nm->mkConst(FloatingPoint::makeZero(
diff --git a/src/theory/fp/theory_fp_rewriter.cpp b/src/theory/fp/theory_fp_rewriter.cpp
index 91fe183ec..32c3cff41 100644
--- a/src/theory/fp/theory_fp_rewriter.cpp
+++ b/src/theory/fp/theory_fp_rewriter.cpp
@@ -41,6 +41,8 @@
#include "theory/fp/fp_word_blaster.h"
#include "util/floatingpoint.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace fp {
@@ -913,7 +915,7 @@ RewriteResponse maxTotal(TNode node, bool isPreRewrite)
FloatingPoint::PartialRational res(arg.convertToRational());
if (res.second) {
- Node lit = NodeManager::currentNM()->mkConst(res.first);
+ Node lit = NodeManager::currentNM()->mkConst(CONST_RATIONAL, res.first);
return RewriteResponse(REWRITE_DONE, lit);
} else {
// Can't constant fold the underspecified case
@@ -996,15 +998,15 @@ RewriteResponse maxTotal(TNode node, bool isPreRewrite)
Rational partialValue(node[1].getConst<Rational>());
Rational folded(arg.convertToRationalTotal(partialValue));
- Node lit = NodeManager::currentNM()->mkConst(folded);
+ Node lit = NodeManager::currentNM()->mkConst(CONST_RATIONAL, folded);
return RewriteResponse(REWRITE_DONE, lit);
} else {
FloatingPoint::PartialRational res(arg.convertToRational());
if (res.second) {
- Node lit = NodeManager::currentNM()->mkConst(res.first);
- return RewriteResponse(REWRITE_DONE, lit);
+ Node lit = NodeManager::currentNM()->mkConst(CONST_RATIONAL, res.first);
+ return RewriteResponse(REWRITE_DONE, lit);
} else {
// Can't constant fold the underspecified case
return RewriteResponse(REWRITE_DONE, node);
diff --git a/src/theory/inference_id.cpp b/src/theory/inference_id.cpp
index 594834226..82ae674e2 100644
--- a/src/theory/inference_id.cpp
+++ b/src/theory/inference_id.cpp
@@ -19,6 +19,8 @@
#include "proof/proof_checker.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
@@ -104,16 +106,15 @@ const char* toString(InferenceId i)
case InferenceId::ARRAYS_EQ_TAUTOLOGY: return "ARRAYS_EQ_TAUTOLOGY";
case InferenceId::BAGS_NON_NEGATIVE_COUNT: return "BAGS_NON_NEGATIVE_COUNT";
- case InferenceId::BAGS_MK_BAG_DIFFERENT_ELEMENT: return "BAGS_MK_BAG_DIFFERENT_ELEMENT";
- case InferenceId::BAGS_MK_BAG_SAME_ELEMENT: return "BAGS_MK_BAG_SAME_ELEMENT";
- case InferenceId::BAGS_MK_BAG: return "BAGS_MK_BAG";
+ case InferenceId::BAGS_BAG_MAKE: return "BAGS_BAG_MAKE";
case InferenceId::BAGS_EQUALITY: return "BAGS_EQUALITY";
case InferenceId::BAGS_DISEQUALITY: return "BAGS_DISEQUALITY";
case InferenceId::BAGS_EMPTY: return "BAGS_EMPTY";
case InferenceId::BAGS_UNION_DISJOINT: return "BAGS_UNION_DISJOINT";
case InferenceId::BAGS_UNION_MAX: return "BAGS_UNION_MAX";
case InferenceId::BAGS_INTERSECTION_MIN: return "BAGS_INTERSECTION_MIN";
- case InferenceId::BAGS_DIFFERENCE_SUBTRACT: return "BAGS_DIFFERENCE_SUBTRACT";
+ case InferenceId::BAGS_DIFFERENCE_SUBTRACT:
+ return "BAGS_DIFFERENCE_SUBTRACT";
case InferenceId::BAGS_DIFFERENCE_REMOVE: return "BAGS_DIFFERENCE_REMOVE";
case InferenceId::BAGS_DUPLICATE_REMOVAL: return "BAGS_DUPLICATE_REMOVAL";
case InferenceId::BAGS_MAP: return "BAGS_MAP";
@@ -453,6 +454,8 @@ const char* toString(InferenceId i)
case InferenceId::UF_HO_MODEL_APP_ENCODE: return "UF_HO_MODEL_APP_ENCODE";
case InferenceId::UF_HO_MODEL_EXTENSIONALITY:
return "UF_HO_MODEL_EXTENSIONALITY";
+ case InferenceId::UF_HO_LAMBDA_UNIV_EQ: return "HO_LAMBDA_UNIV_EQ";
+ case InferenceId::UF_HO_LAMBDA_APP_REDUCE: return "HO_LAMBDA_APP_REDUCE";
default: return "?";
}
@@ -466,7 +469,8 @@ std::ostream& operator<<(std::ostream& out, InferenceId i)
Node mkInferenceIdNode(InferenceId i)
{
- return NodeManager::currentNM()->mkConst(Rational(static_cast<uint32_t>(i)));
+ return NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ Rational(static_cast<uint32_t>(i)));
}
bool getInferenceId(TNode n, InferenceId& i)
diff --git a/src/theory/inference_id.h b/src/theory/inference_id.h
index cebf02c9d..ad879d7ab 100644
--- a/src/theory/inference_id.h
+++ b/src/theory/inference_id.h
@@ -169,9 +169,7 @@ enum class InferenceId
// ---------------------------------- bags theory
BAGS_NON_NEGATIVE_COUNT,
- BAGS_MK_BAG_DIFFERENT_ELEMENT,
- BAGS_MK_BAG_SAME_ELEMENT,
- BAGS_MK_BAG,
+ BAGS_BAG_MAKE,
BAGS_EQUALITY,
BAGS_DISEQUALITY,
BAGS_EMPTY,
@@ -840,6 +838,15 @@ enum class InferenceId
// different applications
// (not (= (f sk1 .. skn) (g sk1 .. skn))
UF_HO_MODEL_EXTENSIONALITY,
+ // equivalence of lambda functions
+ // f = g => forall x. reduce(lambda(f)(x)) = reduce(lambda(g)(x))
+ // This is applied when lamda functions f and g are in the same eq class.
+ UF_HO_LAMBDA_UNIV_EQ,
+ // equivalence of a lambda function and an ordinary function
+ // f = h => h(t) = reduce(lambda(f)(t))
+ // This is applied when lamda function f and ordinary function h are in the
+ // same eq class.
+ UF_HO_LAMBDA_APP_REDUCE,
//-------------------- end model-construction specific part
//-------------------- end HO extension to UF
//-------------------------------------- end uf theory
diff --git a/src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp
index 163a49b8c..425ab0484 100644
--- a/src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp
+++ b/src/theory/quantifiers/cegqi/ceg_arith_instantiator.cpp
@@ -36,8 +36,8 @@ namespace quantifiers {
ArithInstantiator::ArithInstantiator(Env& env, TypeNode tn, VtsTermCache* vtc)
: Instantiator(env, tn), d_vtc(vtc)
{
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
- d_one = NodeManager::currentNM()->mkConst(Rational(1));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
}
void ArithInstantiator::reset(CegInstantiator* ci,
@@ -185,7 +185,8 @@ bool ArithInstantiator::processAssertion(CegInstantiator* ci,
uval = nm->mkNode(
PLUS,
val,
- nm->mkConst(Rational(isUpperBoundCTT(uires) ? 1 : -1)));
+ nm->mkConst(CONST_RATIONAL,
+ Rational(isUpperBoundCTT(uires) ? 1 : -1)));
uval = rewrite(uval);
}
else
@@ -252,8 +253,11 @@ bool ArithInstantiator::processAssertion(CegInstantiator* ci,
if (d_type.isInteger())
{
uires = is_upper ? CEG_TT_LOWER : CEG_TT_UPPER;
- uval = nm->mkNode(
- PLUS, val, nm->mkConst(Rational(isUpperBoundCTT(uires) ? 1 : -1)));
+ uval =
+ nm->mkNode(PLUS,
+ val,
+ nm->mkConst(CONST_RATIONAL,
+ Rational(isUpperBoundCTT(uires) ? 1 : -1)));
uval = rewrite(uval);
}
else
@@ -274,8 +278,8 @@ bool ArithInstantiator::processAssertion(CegInstantiator* ci,
{
if (options().quantifiers.cegqiModel)
{
- Node delta_coeff =
- nm->mkConst(Rational(isUpperBoundCTT(uires) ? 1 : -1));
+ Node delta_coeff = nm->mkConst(
+ CONST_RATIONAL, Rational(isUpperBoundCTT(uires) ? 1 : -1));
if (vts_coeff_delta.isNull())
{
vts_coeff_delta = delta_coeff;
@@ -451,8 +455,9 @@ bool ArithInstantiator::processAssertions(CegInstantiator* ci,
Assert(d_mbp_coeff[rr][j].isConst());
value[t] = nm->mkNode(
MULT,
- nm->mkConst(Rational(1)
- / d_mbp_coeff[rr][j].getConst<Rational>()),
+ nm->mkConst(
+ CONST_RATIONAL,
+ Rational(1) / d_mbp_coeff[rr][j].getConst<Rational>()),
value[t]);
value[t] = rewrite(value[t]);
}
@@ -606,9 +611,10 @@ bool ArithInstantiator::processAssertions(CegInstantiator* ci,
}
else
{
- val = nm->mkNode(MULT,
- nm->mkNode(PLUS, vals[0], vals[1]),
- nm->mkConst(Rational(1) / Rational(2)));
+ val =
+ nm->mkNode(MULT,
+ nm->mkNode(PLUS, vals[0], vals[1]),
+ nm->mkConst(CONST_RATIONAL, Rational(1) / Rational(2)));
val = rewrite(val);
}
}
@@ -803,7 +809,7 @@ CegTermType ArithInstantiator::solve_arith(CegInstantiator* ci,
vts_coeff[t] = itminf->second;
if (vts_coeff[t].isNull())
{
- vts_coeff[t] = nm->mkConst(Rational(1));
+ vts_coeff[t] = nm->mkConst(CONST_RATIONAL, Rational(1));
}
// negate if coefficient on variable is positive
std::map<Node, Node>::iterator itv = msum.find(pv);
@@ -820,7 +826,8 @@ CegTermType ArithInstantiator::solve_arith(CegInstantiator* ci,
{
vts_coeff[t] = nm->mkNode(
MULT,
- nm->mkConst(Rational(-1) / itv->second.getConst<Rational>()),
+ nm->mkConst(CONST_RATIONAL,
+ Rational(-1) / itv->second.getConst<Rational>()),
vts_coeff[t]);
vts_coeff[t] = rewrite(vts_coeff[t]);
}
@@ -880,7 +887,7 @@ CegTermType ArithInstantiator::solve_arith(CegInstantiator* ci,
}
}
// multiply everything by this coefficient
- Node rcoeff = nm->mkConst(Rational(coeff));
+ Node rcoeff = nm->mkConst(CONST_RATIONAL, Rational(coeff));
std::vector<Node> real_part;
for (std::map<Node, Node>::iterator it = msum.begin(); it != msum.end();
++it)
diff --git a/src/theory/quantifiers/cegqi/ceg_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_instantiator.cpp
index 9dc11955b..494ac8e53 100644
--- a/src/theory/quantifiers/cegqi/ceg_instantiator.cpp
+++ b/src/theory/quantifiers/cegqi/ceg_instantiator.cpp
@@ -138,7 +138,8 @@ void TermProperties::composeProperty(TermProperties& p)
else
{
NodeManager* nm = NodeManager::currentNM();
- d_coeff = nm->mkConst(Rational(d_coeff.getConst<Rational>()
+ d_coeff = nm->mkConst(CONST_RATIONAL,
+ Rational(d_coeff.getConst<Rational>()
* p.d_coeff.getConst<Rational>()));
}
}
@@ -165,7 +166,8 @@ void SolvedForm::push_back(Node pv, Node n, TermProperties& pv_prop)
Assert(new_theta.getKind() == CONST_RATIONAL);
Assert(pv_prop.d_coeff.getKind() == CONST_RATIONAL);
NodeManager* nm = NodeManager::currentNM();
- new_theta = nm->mkConst(Rational(new_theta.getConst<Rational>()
+ new_theta = nm->mkConst(CONST_RATIONAL,
+ Rational(new_theta.getConst<Rational>()
* pv_prop.d_coeff.getConst<Rational>()));
}
d_theta.push_back(new_theta);
@@ -1151,7 +1153,12 @@ Node CegInstantiator::applySubstitution( TypeNode tn, Node n, std::vector< Node
if( !prop[i].d_coeff.isNull() ){
Assert(vars[i].getType().isInteger());
Assert(prop[i].d_coeff.isConst());
- Node nn = NodeManager::currentNM()->mkNode( MULT, subs[i], NodeManager::currentNM()->mkConst( Rational(1)/prop[i].d_coeff.getConst<Rational>() ) );
+ Node nn = NodeManager::currentNM()->mkNode(
+ MULT,
+ subs[i],
+ NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL,
+ Rational(1) / prop[i].d_coeff.getConst<Rational>()));
nn = NodeManager::currentNM()->mkNode( kind::TO_INTEGER, nn );
nn = rewrite(nn);
nsubs.push_back( nn );
@@ -1199,8 +1206,9 @@ Node CegInstantiator::applySubstitution( TypeNode tn, Node n, std::vector< Node
Node c_coeff;
if( !msum_coeff[it->first].isNull() ){
c_coeff = rewrite(NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL,
pv_prop.d_coeff.getConst<Rational>()
- / msum_coeff[it->first].getConst<Rational>()));
+ / msum_coeff[it->first].getConst<Rational>()));
}else{
c_coeff = pv_prop.d_coeff;
}
@@ -1264,7 +1272,7 @@ Node CegInstantiator::applySubstitutionToLiteral( Node lit, std::vector< Node >&
}else{
atom_lhs = nm->mkNode(MINUS, atom[0], atom[1]);
atom_lhs = rewrite(atom_lhs);
- atom_rhs = nm->mkConst(Rational(0));
+ atom_rhs = nm->mkConst(CONST_RATIONAL, Rational(0));
}
//must be an eligible term
if( isEligible( atom_lhs ) ){
diff --git a/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp b/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp
index 6340e2a2a..65ad79e29 100644
--- a/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp
+++ b/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp
@@ -58,8 +58,8 @@ InstStrategyCegqi::InstStrategyCegqi(Env& env,
d_added_cbqi_lemma(userContext()),
d_vtsCache(new VtsTermCache(qim)),
d_bv_invert(nullptr),
- d_small_const_multiplier(
- NodeManager::currentNM()->mkConst(Rational(1) / Rational(1000000))),
+ d_small_const_multiplier(NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL, Rational(1) / Rational(1000000))),
d_small_const(d_small_const_multiplier)
{
d_check_vts_lemma_lc = false;
@@ -453,7 +453,12 @@ void InstStrategyCegqi::process( Node q, Theory::Effort effort, int e ) {
d_vtsCache->getVtsTerms(inf, true, false, false);
for( unsigned i=0; i<inf.size(); i++ ){
Trace("quant-vts-debug") << "Infinity lemma for " << inf[i] << " " << d_small_const << std::endl;
- Node inf_lem_lb = NodeManager::currentNM()->mkNode( GT, inf[i], NodeManager::currentNM()->mkConst( Rational(1)/d_small_const.getConst<Rational>() ) );
+ Node inf_lem_lb = NodeManager::currentNM()->mkNode(
+ GT,
+ inf[i],
+ NodeManager::currentNM()->mkConst(
+ CONST_RATIONAL,
+ Rational(1) / d_small_const.getConst<Rational>()));
d_qim.lemma(inf_lem_lb, InferenceId::QUANTIFIERS_CEGQI_VTS_LB_INF);
}
}
diff --git a/src/theory/quantifiers/cegqi/vts_term_cache.cpp b/src/theory/quantifiers/cegqi/vts_term_cache.cpp
index fe47f1dd1..37ded9b7f 100644
--- a/src/theory/quantifiers/cegqi/vts_term_cache.cpp
+++ b/src/theory/quantifiers/cegqi/vts_term_cache.cpp
@@ -30,7 +30,7 @@ namespace quantifiers {
VtsTermCache::VtsTermCache(QuantifiersInferenceManager& qim) : d_qim(qim)
{
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
}
void VtsTermCache::getVtsTerms(std::vector<Node>& t,
diff --git a/src/theory/quantifiers/ematching/inst_match_generator.cpp b/src/theory/quantifiers/ematching/inst_match_generator.cpp
index 075299583..8c2d8e6c4 100644
--- a/src/theory/quantifiers/ematching/inst_match_generator.cpp
+++ b/src/theory/quantifiers/ematching/inst_match_generator.cpp
@@ -364,7 +364,8 @@ int InstMatchGenerator::getMatch(Node f, Node t, InstMatch& m)
{
if (pat.getKind() == GT)
{
- t_match = nm->mkNode(MINUS, t, nm->mkConst(Rational(1)));
+ t_match =
+ nm->mkNode(MINUS, t, nm->mkConst(CONST_RATIONAL, Rational(1)));
}else{
t_match = t;
}
@@ -380,12 +381,13 @@ int InstMatchGenerator::getMatch(Node f, Node t, InstMatch& m)
else
{
Assert(t.getType().isReal());
- t_match = nm->mkNode(PLUS, t, nm->mkConst(Rational(1)));
+ t_match =
+ nm->mkNode(PLUS, t, nm->mkConst(CONST_RATIONAL, Rational(1)));
}
}
else if (pat.getKind() == GEQ)
{
- t_match = nm->mkNode(PLUS, t, nm->mkConst(Rational(1)));
+ t_match = nm->mkNode(PLUS, t, nm->mkConst(CONST_RATIONAL, Rational(1)));
}
else if (pat.getKind() == GT)
{
diff --git a/src/theory/quantifiers/ematching/pattern_term_selector.cpp b/src/theory/quantifiers/ematching/pattern_term_selector.cpp
index 332346f3f..0ab6e1098 100644
--- a/src/theory/quantifiers/ematching/pattern_term_selector.cpp
+++ b/src/theory/quantifiers/ematching/pattern_term_selector.cpp
@@ -678,7 +678,8 @@ Node PatternTermSelector::getInversion(Node n, Node x)
Assert(nc.isConst());
if (x.getType().isInteger())
{
- Node coeff = nm->mkConst(nc.getConst<Rational>().abs());
+ Node coeff =
+ nm->mkConst(CONST_RATIONAL, nc.getConst<Rational>().abs());
if (!nc.getConst<Rational>().abs().isOne())
{
x = nm->mkNode(INTS_DIVISION_TOTAL, x, coeff);
@@ -690,7 +691,8 @@ Node PatternTermSelector::getInversion(Node n, Node x)
}
else
{
- Node coeff = nm->mkConst(Rational(1) / nc.getConst<Rational>());
+ Node coeff = nm->mkConst(CONST_RATIONAL,
+ Rational(1) / nc.getConst<Rational>());
x = nm->mkNode(MULT, x, coeff);
}
}
diff --git a/src/theory/quantifiers/ematching/relational_match_generator.cpp b/src/theory/quantifiers/ematching/relational_match_generator.cpp
index 8981a7a2d..dc8f64f6d 100644
--- a/src/theory/quantifiers/ematching/relational_match_generator.cpp
+++ b/src/theory/quantifiers/ematching/relational_match_generator.cpp
@@ -94,7 +94,10 @@ int RelationalMatchGenerator::getNextMatch(Node q, InstMatch& m)
s = rhs;
if (!checkPol)
{
- s = nm->mkNode(PLUS, s, nm->mkConst(Rational(d_rel == GEQ ? -1 : 1)));
+ s = nm->mkNode(
+ PLUS,
+ s,
+ nm->mkConst(CONST_RATIONAL, Rational(d_rel == GEQ ? -1 : 1)));
}
d_counter++;
Trace("relational-match-gen")
diff --git a/src/theory/quantifiers/ematching/trigger_term_info.cpp b/src/theory/quantifiers/ematching/trigger_term_info.cpp
index 75a353dbe..24efc60c3 100644
--- a/src/theory/quantifiers/ematching/trigger_term_info.cpp
+++ b/src/theory/quantifiers/ematching/trigger_term_info.cpp
@@ -54,7 +54,7 @@ bool TriggerTermInfo::isAtomicTriggerKind(Kind k)
// where these two things require those kinds respectively.
return k == APPLY_UF || k == SELECT || k == STORE || k == APPLY_CONSTRUCTOR
|| k == APPLY_SELECTOR || k == APPLY_SELECTOR_TOTAL
- || k == APPLY_TESTER || k == SET_UNION || k == SET_INTERSECTION
+ || k == APPLY_TESTER || k == SET_UNION || k == SET_INTER
|| k == SET_SUBSET || k == SET_MINUS || k == SET_MEMBER
|| k == SET_SINGLETON || k == SEP_PTO || k == BITVECTOR_TO_NAT
|| k == INT_TO_BITVECTOR || k == HO_APPLY || k == STRING_LENGTH
diff --git a/src/theory/quantifiers/extended_rewrite.cpp b/src/theory/quantifiers/extended_rewrite.cpp
index 3d20f66b3..5aab618c0 100644
--- a/src/theory/quantifiers/extended_rewrite.cpp
+++ b/src/theory/quantifiers/extended_rewrite.cpp
@@ -49,7 +49,7 @@ ExtendedRewriter::ExtendedRewriter(Rewriter& rew, bool aggr)
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
}
void ExtendedRewriter::setCache(Node n, Node ret) const
diff --git a/src/theory/quantifiers/fmf/bounded_integers.cpp b/src/theory/quantifiers/fmf/bounded_integers.cpp
index 26b526315..b5b9e7d88 100644
--- a/src/theory/quantifiers/fmf/bounded_integers.cpp
+++ b/src/theory/quantifiers/fmf/bounded_integers.cpp
@@ -59,7 +59,7 @@ BoundedIntegers::IntRangeDecisionHeuristic::IntRangeDecisionHeuristic(
Node BoundedIntegers::IntRangeDecisionHeuristic::mkLiteral(unsigned n)
{
NodeManager* nm = NodeManager::currentNM();
- Node cn = nm->mkConst(Rational(n == 0 ? 0 : n - 1));
+ Node cn = nm->mkConst(CONST_RATIONAL, Rational(n == 0 ? 0 : n - 1));
return nm->mkNode(n == 0 ? LT : LEQ, d_proxy_range, cn);
}
@@ -81,12 +81,13 @@ Node BoundedIntegers::IntRangeDecisionHeuristic::proxyCurrentRangeLemma()
d_ranges_proxied[curr] = true;
NodeManager* nm = NodeManager::currentNM();
Node currLit = getLiteral(curr);
- Node lem =
- nm->mkNode(EQUAL,
- currLit,
- nm->mkNode(curr == 0 ? LT : LEQ,
- d_range,
- nm->mkConst(Rational(curr == 0 ? 0 : curr - 1))));
+ Node lem = nm->mkNode(
+ EQUAL,
+ currLit,
+ nm->mkNode(
+ curr == 0 ? LT : LEQ,
+ d_range,
+ nm->mkConst(CONST_RATIONAL, Rational(curr == 0 ? 0 : curr - 1))));
return lem;
}
@@ -692,7 +693,8 @@ Node BoundedIntegers::getSetRangeValue( Node q, Node v, RepSetIterator * rsi ) {
}
choices.pop_back();
Node bvl = nm->mkNode(BOUND_VAR_LIST, choice_i);
- Node cMinCard = nm->mkNode(LEQ, srCardN, nm->mkConst(Rational(i)));
+ Node cMinCard =
+ nm->mkNode(LEQ, srCardN, nm->mkConst(CONST_RATIONAL, Rational(i)));
choice_i = nm->mkNode(WITNESS, bvl, nm->mkNode(OR, cMinCard, cBody));
d_setm_choice[sro].push_back(choice_i);
}
@@ -816,7 +818,8 @@ bool BoundedIntegers::getBoundElements( RepSetIterator * rsi, bool initial, Node
Node range = rewrite(nm->mkNode(MINUS, u, l));
// 9999 is an arbitrary range past which we do not do exhaustive
// bounded instantation, based on the check below.
- Node ra = rewrite(nm->mkNode(LEQ, range, nm->mkConst(Rational(9999))));
+ Node ra = rewrite(nm->mkNode(
+ LEQ, range, nm->mkConst(CONST_RATIONAL, Rational(9999))));
Node tl = l;
Node tu = u;
getBounds( q, v, rsi, tl, tu );
@@ -827,7 +830,8 @@ bool BoundedIntegers::getBoundElements( RepSetIterator * rsi, bool initial, Node
Trace("bound-int-rsi") << "Actual bound range is " << rr << std::endl;
for (long k = 0; k < rr; k++)
{
- Node t = nm->mkNode(PLUS, tl, nm->mkConst(Rational(k)));
+ Node t =
+ nm->mkNode(PLUS, tl, nm->mkConst(CONST_RATIONAL, Rational(k)));
t = rewrite(t);
elements.push_back( t );
}
diff --git a/src/theory/quantifiers/quant_bound_inference.cpp b/src/theory/quantifiers/quant_bound_inference.cpp
index 83e48bf9c..af72e2a7c 100644
--- a/src/theory/quantifiers/quant_bound_inference.cpp
+++ b/src/theory/quantifiers/quant_bound_inference.cpp
@@ -61,9 +61,10 @@ bool QuantifiersBoundInference::mayComplete(TypeNode tn, unsigned maxCard)
if (!c.isLargeFinite())
{
NodeManager* nm = NodeManager::currentNM();
- Node card = nm->mkConst(Rational(c.getFiniteCardinality()));
+ Node card =
+ nm->mkConst(CONST_RATIONAL, Rational(c.getFiniteCardinality()));
// check if less than fixed upper bound
- Node oth = nm->mkConst(Rational(maxCard));
+ Node oth = nm->mkConst(CONST_RATIONAL, Rational(maxCard));
Node eq = nm->mkNode(LEQ, card, oth);
eq = Rewriter::rewrite(eq);
mc = eq.isConst() && eq.getConst<bool>();
diff --git a/src/theory/quantifiers/quant_conflict_find.cpp b/src/theory/quantifiers/quant_conflict_find.cpp
index f04514480..9f7b270de 100644
--- a/src/theory/quantifiers/quant_conflict_find.cpp
+++ b/src/theory/quantifiers/quant_conflict_find.cpp
@@ -2281,7 +2281,7 @@ TNode QuantConflictFind::getZero( Kind k ) {
if( it==d_zero.end() ){
Node nn;
if( k==PLUS ){
- nn = NodeManager::currentNM()->mkConst( Rational(0) );
+ nn = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
}
d_zero[k] = nn;
return nn;
diff --git a/src/theory/quantifiers/quantifiers_rewriter.cpp b/src/theory/quantifiers/quantifiers_rewriter.cpp
index 88c6cd96f..adb91fddd 100644
--- a/src/theory/quantifiers/quantifiers_rewriter.cpp
+++ b/src/theory/quantifiers/quantifiers_rewriter.cpp
@@ -920,7 +920,7 @@ bool QuantifiersRewriter::getVarElimLit(Node body,
for (size_t j = 0, nargs = c.getNumArgs(); j < nargs; j++)
{
TypeNode tn = tspec[j];
- Node rn = nm->mkConst(Rational(j));
+ Node rn = nm->mkConst(CONST_RATIONAL, Rational(j));
Node cacheVal = BoundVarManager::getCacheValue(body, lit, rn);
Node v = bvm->mkBoundVar<QRewDtExpandAttribute>(cacheVal, tn);
newChildren.push_back(v);
diff --git a/src/theory/quantifiers/skolemize.cpp b/src/theory/quantifiers/skolemize.cpp
index 6dcb318f3..4dea0dc22 100644
--- a/src/theory/quantifiers/skolemize.cpp
+++ b/src/theory/quantifiers/skolemize.cpp
@@ -285,10 +285,12 @@ Node Skolemize::mkSkolemizedBody(Node f,
}
else if (options::intWfInduction() && tn.isInteger())
{
- Node icond = nm->mkNode(GEQ, k, nm->mkConst(Rational(0)));
- Node iret = ret.substitute(ind_vars[0],
- nm->mkNode(MINUS, k, nm->mkConst(Rational(1))))
- .negate();
+ Node icond = nm->mkNode(GEQ, k, nm->mkConst(CONST_RATIONAL, Rational(0)));
+ Node iret =
+ ret.substitute(
+ ind_vars[0],
+ nm->mkNode(MINUS, k, nm->mkConst(CONST_RATIONAL, Rational(1))))
+ .negate();
n_str_ind = nm->mkNode(OR, icond.negate(), iret);
n_str_ind = nm->mkNode(AND, icond, n_str_ind);
}
diff --git a/src/theory/quantifiers/sygus/cegis_unif.cpp b/src/theory/quantifiers/sygus/cegis_unif.cpp
index b60bc2736..be80992ea 100644
--- a/src/theory/quantifiers/sygus/cegis_unif.cpp
+++ b/src/theory/quantifiers/sygus/cegis_unif.cpp
@@ -480,7 +480,7 @@ Node CegisUnifEnumDecisionStrategy::mkLiteral(unsigned n)
std::set<TypeNode> unresolvedTypes;
unresolvedTypes.insert(u);
std::vector<TypeNode> cargsEmpty;
- Node cr = nm->mkConst(Rational(1));
+ Node cr = nm->mkConst(CONST_RATIONAL, Rational(1));
sdt.addConstructor(cr, "1", cargsEmpty);
std::vector<TypeNode> cargsPlus;
cargsPlus.push_back(u);
@@ -503,8 +503,8 @@ Node CegisUnifEnumDecisionStrategy::mkLiteral(unsigned n)
if (pow_two > 0)
{
Node size_ve = nm->mkNode(DT_SIZE, d_virtual_enum);
- Node fair_lemma =
- nm->mkNode(GEQ, size_ve, nm->mkConst(Rational(pow_two - 1)));
+ Node fair_lemma = nm->mkNode(
+ GEQ, size_ve, nm->mkConst(CONST_RATIONAL, Rational(pow_two - 1)));
fair_lemma = nm->mkNode(OR, newLit, fair_lemma);
Trace("cegis-unif-enum-lemma")
<< "CegisUnifEnum::lemma, fairness size:" << fair_lemma << "\n";
diff --git a/src/theory/quantifiers/sygus/sygus_enumerator.cpp b/src/theory/quantifiers/sygus/sygus_enumerator.cpp
index 959532d98..674183b20 100644
--- a/src/theory/quantifiers/sygus/sygus_enumerator.cpp
+++ b/src/theory/quantifiers/sygus/sygus_enumerator.cpp
@@ -257,7 +257,7 @@ void SygusEnumerator::TermCache::initialize(SygusStatistics* s,
// more aggressive merging of constructor classes. On the negative side,
// this adds another level of indirection to remember which argument
// positions the argument types occur in, for each constructor.
- Node n = nm->mkConst(Rational(i));
+ Node n = nm->mkConst(CONST_RATIONAL, Rational(i));
nToC[n] = i;
tnit.add(n, argTypes[i]);
}
diff --git a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp
index 034f5f23c..cca1d76e2 100644
--- a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp
+++ b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp
@@ -84,7 +84,7 @@ void CegGrammarConstructor::collectTerms(
TypeNode tn = cur.getType();
Node c = cur;
if( tn.isReal() ){
- c = nm->mkConst( c.getConst<Rational>().abs() );
+ c = nm->mkConst(CONST_RATIONAL, c.getConst<Rational>().abs());
}
consts[tn].insert(c);
if (tn.isInteger())
@@ -409,8 +409,8 @@ void CegGrammarConstructor::mkSygusConstantsForType(TypeNode type,
NodeManager* nm = NodeManager::currentNM();
if (type.isReal())
{
- ops.push_back(nm->mkConst(Rational(0)));
- ops.push_back(nm->mkConst(Rational(1)));
+ ops.push_back(nm->mkConst(CONST_RATIONAL, Rational(0)));
+ ops.push_back(nm->mkConst(CONST_RATIONAL, Rational(1)));
}
else if (type.isBitVector())
{
@@ -555,7 +555,7 @@ Node CegGrammarConstructor::createLambdaWithZeroArg(
Assert(bArgType.isReal() || bArgType.isBitVector());
if (bArgType.isReal())
{
- zarg = nm->mkConst(Rational(0));
+ zarg = nm->mkConst(CONST_RATIONAL, Rational(0));
}
else
{
@@ -798,7 +798,8 @@ void CegGrammarConstructor::mkSygusDefaultGrammar(
/* Add operator 1 */
Trace("sygus-grammar-def") << "\t...add for 1 to Pos_Int\n";
std::vector<TypeNode> cargsEmpty;
- sdts.back().addConstructor(nm->mkConst(Rational(1)), "1", cargsEmpty);
+ sdts.back().addConstructor(
+ nm->mkConst(CONST_RATIONAL, Rational(1)), "1", cargsEmpty);
/* Add operator PLUS */
Kind kind = PLUS;
Trace("sygus-grammar-def") << "\t...add for PLUS to Pos_Int\n";
@@ -990,7 +991,7 @@ void CegGrammarConstructor::mkSygusDefaultGrammar(
sdts[i].addConstructor(lambda, "singleton", cargsSingleton);
// add for union, difference, intersection
- std::vector<Kind> bin_kinds = {SET_UNION, SET_INTERSECTION, SET_MINUS};
+ std::vector<Kind> bin_kinds = {SET_UNION, SET_INTER, SET_MINUS};
std::vector<TypeNode> cargsBinary;
cargsBinary.push_back(unres_t);
cargsBinary.push_back(unres_t);
diff --git a/src/theory/quantifiers/sygus_sampler.cpp b/src/theory/quantifiers/sygus_sampler.cpp
index 2fc7f0c29..89cee0145 100644
--- a/src/theory/quantifiers/sygus_sampler.cpp
+++ b/src/theory/quantifiers/sygus_sampler.cpp
@@ -32,6 +32,8 @@
#include "util/sampler.h"
#include "util/string.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace theory {
namespace quantifiers {
@@ -587,14 +589,14 @@ Node SygusSampler::getRandomValue(TypeNode tn)
std::vector<Node> sum;
for (unsigned j = 0, size = vec.size(); j < size; j++)
{
- Node digit = nm->mkConst(Rational(vec[j]) * curr);
+ Node digit = nm->mkConst(CONST_RATIONAL, Rational(vec[j]) * curr);
sum.push_back(digit);
curr = curr * baser;
}
Node ret;
if (sum.empty())
{
- ret = nm->mkConst(Rational(0));
+ ret = nm->mkConst(CONST_RATIONAL, Rational(0));
}
else if (sum.size() == 1)
{
@@ -629,7 +631,7 @@ Node SygusSampler::getRandomValue(TypeNode tn)
}
else
{
- return nm->mkConst(sr / rr);
+ return nm->mkConst(CONST_RATIONAL, sr / rr);
}
}
}
diff --git a/src/theory/quantifiers/term_database.cpp b/src/theory/quantifiers/term_database.cpp
index 5c9e91d32..0408d27da 100644
--- a/src/theory/quantifiers/term_database.cpp
+++ b/src/theory/quantifiers/term_database.cpp
@@ -186,7 +186,7 @@ Node TermDb::getOrMakeTypeFreshVariable(TypeNode tn)
Node TermDb::getMatchOperator( Node n ) {
Kind k = n.getKind();
//datatype operators may be parametric, always assume they are
- if (k == SELECT || k == STORE || k == SET_UNION || k == SET_INTERSECTION
+ if (k == SELECT || k == STORE || k == SET_UNION || k == SET_INTER
|| k == SET_SUBSET || k == SET_MINUS || k == SET_MEMBER
|| k == SET_SINGLETON || k == APPLY_SELECTOR_TOTAL || k == APPLY_SELECTOR
|| k == APPLY_TESTER || k == SEP_PTO || k == HO_APPLY || k == SEQ_NTH
diff --git a/src/theory/quantifiers/term_util.cpp b/src/theory/quantifiers/term_util.cpp
index de4c56552..cb8bad174 100644
--- a/src/theory/quantifiers/term_util.cpp
+++ b/src/theory/quantifiers/term_util.cpp
@@ -283,7 +283,7 @@ bool TermUtil::isAssoc(Kind k, bool reqNAry)
{
if (reqNAry)
{
- if (k == SET_UNION || k == SET_INTERSECTION)
+ if (k == SET_UNION || k == SET_INTER)
{
return false;
}
@@ -292,7 +292,7 @@ bool TermUtil::isAssoc(Kind k, bool reqNAry)
|| k == XOR || k == BITVECTOR_ADD || k == BITVECTOR_MULT
|| k == BITVECTOR_AND || k == BITVECTOR_OR || k == BITVECTOR_XOR
|| k == BITVECTOR_XNOR || k == BITVECTOR_CONCAT || k == STRING_CONCAT
- || k == SET_UNION || k == SET_INTERSECTION || k == RELATION_JOIN
+ || k == SET_UNION || k == SET_INTER || k == RELATION_JOIN
|| k == RELATION_PRODUCT || k == SEP_STAR;
}
@@ -300,7 +300,7 @@ bool TermUtil::isComm(Kind k, bool reqNAry)
{
if (reqNAry)
{
- if (k == SET_UNION || k == SET_INTERSECTION)
+ if (k == SET_UNION || k == SET_INTER)
{
return false;
}
@@ -308,7 +308,7 @@ bool TermUtil::isComm(Kind k, bool reqNAry)
return k == EQUAL || k == PLUS || k == MULT || k == NONLINEAR_MULT || k == AND
|| k == OR || k == XOR || k == BITVECTOR_ADD || k == BITVECTOR_MULT
|| k == BITVECTOR_AND || k == BITVECTOR_OR || k == BITVECTOR_XOR
- || k == BITVECTOR_XNOR || k == SET_UNION || k == SET_INTERSECTION
+ || k == BITVECTOR_XNOR || k == SET_UNION || k == SET_INTER
|| k == SEP_STAR;
}
@@ -332,7 +332,7 @@ Node TermUtil::mkTypeValue(TypeNode tn, int32_t val)
if (tn.isInteger() || tn.isReal())
{
Rational c(val);
- n = NodeManager::currentNM()->mkConst(c);
+ n = NodeManager::currentNM()->mkConst(CONST_RATIONAL, c);
}
else if (tn.isBitVector())
{
diff --git a/src/theory/sep/theory_sep.cpp b/src/theory/sep/theory_sep.cpp
index 218c09804..3ee4fa012 100644
--- a/src/theory/sep/theory_sep.cpp
+++ b/src/theory/sep/theory_sep.cpp
@@ -385,7 +385,7 @@ void TheorySep::reduceFact(TNode atom, bool polarity, TNode fact)
{
for (size_t j = (i + 1); j < lsize; j++)
{
- Node s = nm->mkNode(SET_INTERSECTION, labels[i], labels[j]);
+ Node s = nm->mkNode(SET_INTER, labels[i], labels[j]);
Node ilem = s.eqNode(empSet);
Trace("sep-lemma-debug")
<< "Sep::Lemma : star reduction, disjoint : " << ilem
@@ -401,7 +401,7 @@ void TheorySep::reduceFact(TNode atom, bool polarity, TNode fact)
Trace("sep-lemma-debug")
<< "Sep::Lemma : wand reduction, union : " << ulem << std::endl;
c_lems.push_back(ulem);
- Node s = nm->mkNode(SET_INTERSECTION, slbl, labels[0]);
+ Node s = nm->mkNode(SET_INTER, slbl, labels[0]);
Node ilem = s.eqNode(empSet);
Trace("sep-lemma-debug")
<< "Sep::Lemma : wand reduction, disjoint : " << ilem << std::endl;
@@ -1427,10 +1427,9 @@ Node TheorySep::instantiateLabel(Node n,
Node sub_lbl = itl->second;
Node lbl_mval = d_label_model[sub_lbl].getValue( rtn );
for( unsigned j=0; j<vs.size(); j++ ){
- bchildren.push_back(
- NodeManager::currentNM()
- ->mkNode(kind::SET_INTERSECTION, lbl_mval, vs[j])
- .eqNode(empSet));
+ bchildren.push_back(NodeManager::currentNM()
+ ->mkNode(kind::SET_INTER, lbl_mval, vs[j])
+ .eqNode(empSet));
}
vs.push_back( lbl_mval );
if( vsu.isNull() ){
@@ -1476,11 +1475,10 @@ Node TheorySep::instantiateLabel(Node n,
//disjoint constraints
Node sub_lbl_0 = d_label_map[n][lbl][0];
Node lbl_mval_0 = d_label_model[sub_lbl_0].getValue( rtn );
- wchildren.push_back(
- NodeManager::currentNM()
- ->mkNode(kind::SET_INTERSECTION, lbl_mval_0, lbl)
- .eqNode(empSet)
- .negate());
+ wchildren.push_back(NodeManager::currentNM()
+ ->mkNode(kind::SET_INTER, lbl_mval_0, lbl)
+ .eqNode(empSet)
+ .negate());
//return the lemma
wchildren.push_back( children[0].negate() );
diff --git a/src/theory/sets/cardinality_extension.cpp b/src/theory/sets/cardinality_extension.cpp
index f65c41b53..e2181b4c6 100644
--- a/src/theory/sets/cardinality_extension.cpp
+++ b/src/theory/sets/cardinality_extension.cpp
@@ -47,7 +47,7 @@ CardinalityExtension::CardinalityExtension(Env& env,
d_finite_type_constants_processed(false)
{
d_true = NodeManager::currentNM()->mkConst(true);
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
}
void CardinalityExtension::reset()
@@ -133,7 +133,8 @@ void CardinalityExtension::checkCardinalityExtended(TypeNode& t)
if (finiteType)
{
- Node typeCardinality = nm->mkConst(Rational(card.getFiniteCardinality()));
+ Node typeCardinality =
+ nm->mkConst(CONST_RATIONAL, Rational(card.getFiniteCardinality()));
Node cardUniv = nm->mkNode(kind::SET_CARD, proxy);
Node leq = nm->mkNode(kind::LEQ, cardUniv, typeCardinality);
@@ -242,7 +243,7 @@ void CardinalityExtension::checkRegister()
// if setminus, do for intersection instead
if (n.getKind() == SET_MINUS)
{
- n = rewrite(nm->mkNode(SET_INTERSECTION, n[0], n[1]));
+ n = rewrite(nm->mkNode(SET_INTER, n[0], n[1]));
}
registerCardinalityTerm(n);
}
@@ -268,7 +269,7 @@ void CardinalityExtension::registerCardinalityTerm(Node n)
NodeManager* nm = NodeManager::currentNM();
Trace("sets-card") << "Cardinality lemmas for " << n << " : " << std::endl;
std::vector<Node> cterms;
- if (n.getKind() == SET_INTERSECTION)
+ if (n.getKind() == SET_INTER)
{
for (unsigned e = 0; e < 2; e++)
{
@@ -381,7 +382,7 @@ void CardinalityExtension::checkCardCyclesRec(Node eqc,
for (const Node& n : nvsets)
{
Kind nk = n.getKind();
- if (nk != SET_INTERSECTION && nk != SET_MINUS)
+ if (nk != SET_INTER && nk != SET_MINUS)
{
continue;
}
@@ -389,7 +390,7 @@ void CardinalityExtension::checkCardCyclesRec(Node eqc,
<< std::endl;
std::vector<Node> sib;
unsigned true_sib = 0;
- if (n.getKind() == SET_INTERSECTION)
+ if (n.getKind() == SET_INTER)
{
d_localBase[n] = n;
for (unsigned e = 0; e < 2; e++)
@@ -401,7 +402,7 @@ void CardinalityExtension::checkCardCyclesRec(Node eqc,
}
else
{
- Node si = rewrite(nm->mkNode(SET_INTERSECTION, n[0], n[1]));
+ Node si = rewrite(nm->mkNode(SET_INTER, n[0], n[1]));
sib.push_back(si);
d_localBase[n] = si;
Node osm = rewrite(nm->mkNode(SET_MINUS, n[1], n[0]));
@@ -490,7 +491,7 @@ void CardinalityExtension::checkCardCyclesRec(Node eqc,
<< "Sibling " << sib[si] << " is already empty." << std::endl;
}
}
- if (!is_union && nk == SET_INTERSECTION && !u.isNull())
+ if (!is_union && nk == SET_INTER && !u.isNull())
{
// union is equal to other parent
if (!d_state.areEqual(u, n[1 - e]))
@@ -578,7 +579,7 @@ void CardinalityExtension::checkCardCyclesRec(Node eqc,
<< " are equal, ids = " << card_parent_ids[l]
<< " " << card_parent_ids[k] << std::endl;
dup = true;
- if (n.getKind() != SET_INTERSECTION)
+ if (n.getKind() != SET_INTER)
{
continue;
}
@@ -817,7 +818,7 @@ void CardinalityExtension::checkNormalForm(Node eqc,
Node r1 = e == 0 ? o0 : o1;
Node r2 = e == 0 ? o1 : o0;
// check if their intersection exists modulo equality
- Node r1r2i = d_state.getBinaryOpTerm(SET_INTERSECTION, r1, r2);
+ Node r1r2i = d_state.getBinaryOpTerm(SET_INTER, r1, r2);
if (!r1r2i.isNull())
{
Trace("sets-nf-debug")
@@ -838,7 +839,7 @@ void CardinalityExtension::checkNormalForm(Node eqc,
Assert(o0 != o1);
Node kca = d_treg.getProxy(o0);
Node kcb = d_treg.getProxy(o1);
- Node intro = rewrite(nm->mkNode(SET_INTERSECTION, kca, kcb));
+ Node intro = rewrite(nm->mkNode(SET_INTER, kca, kcb));
Trace("sets-nf") << " Intro split : " << o0 << " against " << o1
<< ", term is " << intro << std::endl;
intro_sets.push_back(intro);
@@ -979,8 +980,8 @@ void CardinalityExtension::checkMinCard()
}
if (!members.empty())
{
- Node conc =
- nm->mkNode(GEQ, cardTerm, nm->mkConst(Rational(members.size())));
+ Node conc = nm->mkNode(
+ GEQ, cardTerm, nm->mkConst(CONST_RATIONAL, Rational(members.size())));
Node expn = exp.size() == 1 ? exp[0] : nm->mkNode(AND, exp);
d_im.assertInference(conc, InferenceId::SETS_CARD_MINIMAL, expn, 1);
}
diff --git a/src/theory/sets/kinds b/src/theory/sets/kinds
index f5ed7cd87..0c1cc0452 100644
--- a/src/theory/sets/kinds
+++ b/src/theory/sets/kinds
@@ -37,7 +37,7 @@ enumerator SET_TYPE \
# operators
operator SET_UNION 2 "set union"
-operator SET_INTERSECTION 2 "set intersection"
+operator SET_INTER 2 "set intersection"
operator SET_MINUS 2 "set subtraction"
operator SET_SUBSET 2 "subset predicate; first parameter a subset of second"
operator SET_MEMBER 2 "set membership predicate; first parameter a member of second"
@@ -80,15 +80,19 @@ operator SET_CHOOSE 1 "return an element in the set given as a parameter
# The operator is_singleton returns whether the given set is a singleton
operator SET_IS_SINGLETON 1 "return whether the given set is a singleton"
+# The set.map operator applies the first argument, a function of type (-> T1 T2), to every element
+# of the second argument, a set of type (Set T1), and returns a set of type (Set T2).
+operator SET_MAP 2 "set map function"
+
operator RELATION_JOIN 2 "relation join"
operator RELATION_PRODUCT 2 "relation cartesian product"
-operator RELATION_TRANSPOSE 1 "relation transpose"
-operator RELATION_TCLOSURE 1 "relation transitive closure"
-operator RELATION_JOIN_IMAGE 2 "relation join image"
+operator RELATION_TRANSPOSE 1 "relation transpose"
+operator RELATION_TCLOSURE 1 "relation transitive closure"
+operator RELATION_JOIN_IMAGE 2 "relation join image"
operator RELATION_IDEN 1 "relation identity"
typerule SET_UNION ::cvc5::theory::sets::SetsBinaryOperatorTypeRule
-typerule SET_INTERSECTION ::cvc5::theory::sets::SetsBinaryOperatorTypeRule
+typerule SET_INTER ::cvc5::theory::sets::SetsBinaryOperatorTypeRule
typerule SET_MINUS ::cvc5::theory::sets::SetsBinaryOperatorTypeRule
typerule SET_SUBSET ::cvc5::theory::sets::SubsetTypeRule
typerule SET_MEMBER ::cvc5::theory::sets::MemberTypeRule
@@ -102,6 +106,7 @@ typerule SET_UNIVERSE ::cvc5::theory::sets::UniverseSetTypeRule
typerule SET_COMPREHENSION ::cvc5::theory::sets::ComprehensionTypeRule
typerule SET_CHOOSE ::cvc5::theory::sets::ChooseTypeRule
typerule SET_IS_SINGLETON ::cvc5::theory::sets::IsSingletonTypeRule
+typerule SET_MAP ::cvc5::theory::sets::SetMapTypeRule
typerule RELATION_JOIN ::cvc5::theory::sets::RelBinaryOperatorTypeRule
typerule RELATION_PRODUCT ::cvc5::theory::sets::RelBinaryOperatorTypeRule
diff --git a/src/theory/sets/singleton_op.cpp b/src/theory/sets/singleton_op.cpp
index fb64b01cd..327df6984 100644
--- a/src/theory/sets/singleton_op.cpp
+++ b/src/theory/sets/singleton_op.cpp
@@ -23,7 +23,7 @@ namespace cvc5 {
std::ostream& operator<<(std::ostream& out, const SetSingletonOp& op)
{
- return out << "(singleton_op " << op.getType() << ')';
+ return out << "(SetSingletonOp " << op.getType() << ')';
}
size_t SetSingletonOpHashFunction::operator()(const SetSingletonOp& op) const
diff --git a/src/theory/sets/solver_state.cpp b/src/theory/sets/solver_state.cpp
index 023a8a6af..3f619dcad 100644
--- a/src/theory/sets/solver_state.cpp
+++ b/src/theory/sets/solver_state.cpp
@@ -90,7 +90,7 @@ void SolverState::registerTerm(Node r, TypeNode tnn, Node n)
}
}
}
- else if (nk == SET_SINGLETON || nk == SET_UNION || nk == SET_INTERSECTION
+ else if (nk == SET_SINGLETON || nk == SET_UNION || nk == SET_INTER
|| nk == SET_MINUS || nk == SET_EMPTY || nk == SET_UNIVERSE)
{
if (nk == SET_SINGLETON)
diff --git a/src/theory/sets/term_registry.cpp b/src/theory/sets/term_registry.cpp
index 41fe0b4c8..d4b5aa824 100644
--- a/src/theory/sets/term_registry.cpp
+++ b/src/theory/sets/term_registry.cpp
@@ -44,7 +44,7 @@ TermRegistry::TermRegistry(Env& env,
Node TermRegistry::getProxy(Node n)
{
Kind nk = n.getKind();
- if (nk != SET_EMPTY && nk != SET_SINGLETON && nk != SET_INTERSECTION
+ if (nk != SET_EMPTY && nk != SET_SINGLETON && nk != SET_INTER
&& nk != SET_MINUS && nk != SET_UNION && nk != SET_UNIVERSE)
{
return n;
diff --git a/src/theory/sets/theory_sets.cpp b/src/theory/sets/theory_sets.cpp
index b2eb80f75..c3d0b9bbe 100644
--- a/src/theory/sets/theory_sets.cpp
+++ b/src/theory/sets/theory_sets.cpp
@@ -76,7 +76,7 @@ void TheorySets::finishInit()
// functions we are doing congruence over
d_equalityEngine->addFunctionKind(SET_SINGLETON);
d_equalityEngine->addFunctionKind(SET_UNION);
- d_equalityEngine->addFunctionKind(SET_INTERSECTION);
+ d_equalityEngine->addFunctionKind(SET_INTER);
d_equalityEngine->addFunctionKind(SET_MINUS);
d_equalityEngine->addFunctionKind(SET_MEMBER);
d_equalityEngine->addFunctionKind(SET_SUBSET);
diff --git a/src/theory/sets/theory_sets_private.cpp b/src/theory/sets/theory_sets_private.cpp
index 7b596be86..f06580292 100644
--- a/src/theory/sets/theory_sets_private.cpp
+++ b/src/theory/sets/theory_sets_private.cpp
@@ -59,7 +59,7 @@ TheorySetsPrivate::TheorySetsPrivate(Env& env,
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
}
TheorySetsPrivate::~TheorySetsPrivate()
@@ -523,7 +523,7 @@ void TheorySetsPrivate::checkUpwardsClosure()
// see if there are members in second argument
const std::map<Node, Node>& r2mem = d_state.getMembers(r2);
const std::map<Node, Node>& r2nmem = d_state.getNegativeMembers(r2);
- if (!r2mem.empty() || k != kind::SET_INTERSECTION)
+ if (!r2mem.empty() || k != kind::SET_INTER)
{
Trace("sets-debug")
<< "Checking " << term << ", members = " << (!r1mem.empty())
@@ -546,7 +546,7 @@ void TheorySetsPrivate::checkUpwardsClosure()
{
valid = true;
}
- else if (k == kind::SET_INTERSECTION)
+ else if (k == kind::SET_INTER)
{
// conclude x is in term
// if also existing in members of r2
diff --git a/src/theory/sets/theory_sets_rewriter.cpp b/src/theory/sets/theory_sets_rewriter.cpp
index 181a659c5..d603946c4 100644
--- a/src/theory/sets/theory_sets_rewriter.cpp
+++ b/src/theory/sets/theory_sets_rewriter.cpp
@@ -81,7 +81,7 @@ RewriteResponse TheorySetsRewriter::postRewrite(TNode node) {
nm->mkNode(kind::EQUAL, node[0], node[1][0]));
}
else if (node[1].getKind() == kind::SET_UNION
- || node[1].getKind() == kind::SET_INTERSECTION
+ || node[1].getKind() == kind::SET_INTER
|| node[1].getKind() == kind::SET_MINUS)
{
std::vector<Node> children;
@@ -157,7 +157,7 @@ RewriteResponse TheorySetsRewriter::postRewrite(TNode node) {
else if (node[1].getKind() == kind::SET_MINUS && node[1][0] == node[0])
{
// (setminus A (setminus A B)) = (intersection A B)
- Node intersection = nm->mkNode(SET_INTERSECTION, node[0], node[1][1]);
+ Node intersection = nm->mkNode(SET_INTER, node[0], node[1][1]);
return RewriteResponse(REWRITE_AGAIN, intersection);
}
else if (node[1].getKind() == kind::SET_UNIVERSE)
@@ -185,7 +185,7 @@ RewriteResponse TheorySetsRewriter::postRewrite(TNode node) {
break;
} // kind::SET_MINUS
- case kind::SET_INTERSECTION:
+ case kind::SET_INTER:
{
if(node[0] == node[1]) {
Trace("sets-postrewrite") << "Sets::postRewrite returning " << node[0] << std::endl;
@@ -272,11 +272,13 @@ RewriteResponse TheorySetsRewriter::postRewrite(TNode node) {
{
if(node[0].isConst()) {
std::set<Node> elements = NormalForm::getElementsFromNormalConstant(node[0]);
- return RewriteResponse(REWRITE_DONE, nm->mkConst(Rational(elements.size())));
+ return RewriteResponse(
+ REWRITE_DONE, nm->mkConst(CONST_RATIONAL, Rational(elements.size())));
}
else if (node[0].getKind() == kind::SET_SINGLETON)
{
- return RewriteResponse(REWRITE_DONE, nm->mkConst(Rational(1)));
+ return RewriteResponse(REWRITE_DONE,
+ nm->mkConst(CONST_RATIONAL, Rational(1)));
}
else if (node[0].getKind() == kind::SET_UNION)
{
@@ -289,7 +291,7 @@ RewriteResponse TheorySetsRewriter::postRewrite(TNode node) {
NodeManager::currentNM()->mkNode(
kind::SET_CARD,
NodeManager::currentNM()->mkNode(
- kind::SET_INTERSECTION, node[0][0], node[0][1])));
+ kind::SET_INTER, node[0][0], node[0][1])));
return RewriteResponse(REWRITE_DONE, ret );
}
else if (node[0].getKind() == kind::SET_MINUS)
@@ -300,7 +302,7 @@ RewriteResponse TheorySetsRewriter::postRewrite(TNode node) {
NodeManager::currentNM()->mkNode(
kind::SET_CARD,
NodeManager::currentNM()->mkNode(
- kind::SET_INTERSECTION, node[0][0], node[0][1])));
+ kind::SET_INTER, node[0][0], node[0][1])));
return RewriteResponse(REWRITE_DONE, ret );
}
break;
@@ -328,6 +330,8 @@ RewriteResponse TheorySetsRewriter::postRewrite(TNode node) {
break;
} // kind::SET_IS_SINGLETON
+ case SET_MAP: return postRewriteMap(node);
+
case kind::RELATION_TRANSPOSE:
{
if (node[0].getKind() == kind::RELATION_TRANSPOSE)
@@ -628,6 +632,40 @@ RewriteResponse TheorySetsRewriter::preRewrite(TNode node) {
return RewriteResponse(REWRITE_DONE, node);
}
+RewriteResponse TheorySetsRewriter::postRewriteMap(TNode n)
+{
+ Assert(n.getKind() == kind::SET_MAP);
+ NodeManager* nm = NodeManager::currentNM();
+ Kind k = n[1].getKind();
+ TypeNode rangeType = n[0].getType().getRangeType();
+ switch (k)
+ {
+ case SET_EMPTY:
+ {
+ // (set.map f (as set.empty (Set T1)) = (as set.empty (Set T2))
+ Node ret = nm->mkConst(EmptySet(nm->mkSetType(rangeType)));
+ return RewriteResponse(REWRITE_DONE, ret);
+ }
+ case SET_SINGLETON:
+ {
+ // (set.map f (set.singleton x)) = (set.singleton (f x))
+ Node mappedElement = nm->mkNode(APPLY_UF, n[0], n[1][0]);
+ Node ret = nm->mkSingleton(rangeType, mappedElement);
+ return RewriteResponse(REWRITE_AGAIN_FULL, ret);
+ }
+ case SET_UNION:
+ {
+ // (set.map f (set.union A B)) = (set.union (set.map f A) (set.map f B))
+ Node a = nm->mkNode(SET_MAP, n[0], n[1][0]);
+ Node b = nm->mkNode(SET_MAP, n[0], n[1][1]);
+ Node ret = nm->mkNode(SET_UNION, a, b);
+ return RewriteResponse(REWRITE_AGAIN_FULL, ret);
+ }
+
+ default: return RewriteResponse(REWRITE_DONE, n);
+ }
+}
+
} // namespace sets
} // namespace theory
} // namespace cvc5
diff --git a/src/theory/sets/theory_sets_rewriter.h b/src/theory/sets/theory_sets_rewriter.h
index 693731862..1d2f36255 100644
--- a/src/theory/sets/theory_sets_rewriter.h
+++ b/src/theory/sets/theory_sets_rewriter.h
@@ -74,6 +74,15 @@ private:
* Returns true if elementTerm is in setTerm, where both terms are constants.
*/
bool checkConstantMembership(TNode elementTerm, TNode setTerm);
+ /**
+ * rewrites for n include:
+ * - (set.map f (as set.empty (Set T1)) = (as set.empty (Set T2))
+ * - (set.map f (set.singleton x)) = (set.singleton (apply f x))
+ * - (set.map f (set.union A B)) =
+ * (set.union (set.map f A) (set.map f B))
+ * where f: T1 -> T2
+ */
+ RewriteResponse postRewriteMap(TNode n);
}; /* class TheorySetsRewriter */
} // namespace sets
diff --git a/src/theory/sets/theory_sets_type_rules.cpp b/src/theory/sets/theory_sets_type_rules.cpp
index 0793f011b..a8a79d5f9 100644
--- a/src/theory/sets/theory_sets_type_rules.cpp
+++ b/src/theory/sets/theory_sets_type_rules.cpp
@@ -30,7 +30,7 @@ TypeNode SetsBinaryOperatorTypeRule::computeType(NodeManager* nodeManager,
TNode n,
bool check)
{
- Assert(n.getKind() == kind::SET_UNION || n.getKind() == kind::SET_INTERSECTION
+ Assert(n.getKind() == kind::SET_UNION || n.getKind() == kind::SET_INTER
|| n.getKind() == kind::SET_MINUS);
TypeNode setType = n[0].getType(check);
if (check)
@@ -57,7 +57,7 @@ bool SetsBinaryOperatorTypeRule::computeIsConst(NodeManager* nodeManager,
TNode n)
{
// only SET_UNION has a const rule in kinds.
- // SET_INTERSECTION and SET_MINUS are not used in the canonical representation
+ // SET_INTER and SET_MINUS are not used in the canonical representation
// of sets and therefore they do not have const rules in kinds
Assert(n.getKind() == kind::SET_UNION);
return NormalForm::checkNormalConstant(n);
@@ -131,7 +131,7 @@ TypeNode SingletonTypeRule::computeType(NodeManager* nodeManager,
TypeNode type2 = n[0].getType(check);
TypeNode leastCommonType = TypeNode::leastCommonTypeNode(type1, type2);
// the type of the element should be a subtype of the type of the operator
- // e.g. (singleton (singleton_op Real) 1) where 1 is an Int
+ // e.g. (set.singleton (SetSingletonOp Real) 1) where 1 is an Int
if (leastCommonType.isNull() || leastCommonType != type1)
{
std::stringstream ss;
@@ -293,6 +293,48 @@ TypeNode InsertTypeRule::computeType(NodeManager* nodeManager,
return setType;
}
+TypeNode SetMapTypeRule::computeType(NodeManager* nodeManager,
+ TNode n,
+ bool check)
+{
+ Assert(n.getKind() == kind::SET_MAP);
+ TypeNode functionType = n[0].getType(check);
+ TypeNode setType = n[1].getType(check);
+ if (check)
+ {
+ if (!setType.isSet())
+ {
+ throw TypeCheckingExceptionPrivate(
+ n,
+ "set.map operator expects a set in the second argument, "
+ "a non-set is found");
+ }
+
+ TypeNode elementType = setType.getSetElementType();
+
+ if (!(functionType.isFunction()))
+ {
+ std::stringstream ss;
+ ss << "Operator " << n.getKind() << " expects a function of type (-> "
+ << elementType << " *) as a first argument. "
+ << "Found a term of type '" << functionType << "'.";
+ throw TypeCheckingExceptionPrivate(n, ss.str());
+ }
+ std::vector<TypeNode> argTypes = functionType.getArgTypes();
+ if (!(argTypes.size() == 1 && argTypes[0] == elementType))
+ {
+ std::stringstream ss;
+ ss << "Operator " << n.getKind() << " expects a function of type (-> "
+ << elementType << " *). "
+ << "Found a function of type '" << functionType << "'.";
+ throw TypeCheckingExceptionPrivate(n, ss.str());
+ }
+ }
+ TypeNode rangeType = n[0].getType().getRangeType();
+ TypeNode retType = nodeManager->mkSetType(rangeType);
+ return retType;
+}
+
TypeNode RelBinaryOperatorTypeRule::computeType(NodeManager* nodeManager,
TNode n,
bool check)
@@ -421,6 +463,13 @@ TypeNode JoinImageTypeRule::computeType(NodeManager* nodeManager,
throw TypeCheckingExceptionPrivate(
n, " JoinImage operates on a non-binary relation");
}
+ if (tupleTypes[0] != tupleTypes[1])
+ {
+ // TODO: Investigate supporting JoinImage for general binary
+ // relationshttps://github.com/cvc5/cvc5-projects/issues/346
+ throw TypeCheckingExceptionPrivate(
+ n, " JoinImage operates on a pair of different types");
+ }
TypeNode valType = n[1].getType(check);
if (valType != nodeManager->integerType())
{
diff --git a/src/theory/sets/theory_sets_type_rules.h b/src/theory/sets/theory_sets_type_rules.h
index f0d8991ce..dc473d145 100644
--- a/src/theory/sets/theory_sets_type_rules.h
+++ b/src/theory/sets/theory_sets_type_rules.h
@@ -25,23 +25,38 @@ namespace cvc5 {
namespace theory {
namespace sets {
+/**
+ * Type rule for binary operators (set.union, set.inter_min, set.minus) to check
+ * if the two arguments are sets of the same sort.
+ */
struct SetsBinaryOperatorTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
-
static bool computeIsConst(NodeManager* nodeManager, TNode n);
};
+/**
+ * Type rule for binary operator set.subset to check if the two arguments are
+ * sets of the same sort.
+ */
struct SubsetTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for binary operator set.member to check the sort of the first
+ * argument matches the element sort of the given set.
+ */
struct MemberTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (set.singleton (SetSingletonOp t) x) to check the sort of x
+ * matches the sort t.
+ */
struct SingletonTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
@@ -49,66 +64,131 @@ struct SingletonTypeRule
static bool computeIsConst(NodeManager* nodeManager, TNode n);
};
+/**
+ * Type rule for (as set.empty (Set T)) where T is a type
+ */
struct EmptySetTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (bag.card A) to check the argument A is a set.
+ */
struct CardTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (set.complement A) to check the argument A is a set.
+ */
struct ComplementTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (as set.universe (Set T)) where T is a type
+ */
struct UniverseSetTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (set.comprehension ((x1 T1) ... (xn Tn)) predicate body)
+ * that checks x1 ... xn are bound variables, predicate is a boolean term,
+ * and computes the type (Set T) where T is the type of body
+ */
struct ComprehensionTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (set.choose A) to check the argument A is a set.
+ */
struct ChooseTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (set.is_singleton A) to check the argument A is a set.
+ */
struct IsSingletonTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (set.insert e1 ... en A) that checks the sorts of e1, ..., en
+ * match the element sort of the set A
+ */
struct InsertTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for (set.map f S) to make sure f is a unary function of type
+ * (-> T1 T2) where S is a bag of type (Set T1)
+ */
+struct SetMapTypeRule
+{
+ static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
+}; /* struct SetMapTypeRule */
+
+/**
+ * Type rule for binary operators (rel.join, rel.product) to check
+ * if the two arguments are relations (set of tuples).
+ * For arguments A of type (Set (Tuple A1 ... Am)) and B of type
+ * (Set (Tuple B1 ... Bn)):
+ * - (rel.product A B): it computes the type (Set (Tuple (A1 ... Am B1 ... Bn)).
+ * - (rel.join A B) it checks that m, n > 1 and Am = B1 and computes the type
+ * (Set (Tuple (A1 ... Am-1 B2 ... Bn)).
+ */
struct RelBinaryOperatorTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for unary operator (rel.transpose A) to check that A is a relation
+ * (set of Tuples). For an argument A of type (Set (Tuple A1 ... An))
+ * it reveres A1 ... An and computes the type (Set (Tuple An ... A1)).
+ */
struct RelTransposeTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for unary operator (rel.tclosure A) to check that A is a binary
+ * relation of type (Set (Tuple T T)), where T is a type
+ */
struct RelTransClosureTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for operator (rel.join_image A c) that checks A is a binary
+ * relation of type (Set (Tuple T T)), where T is a type, and c is an integer
+ * term (in fact c should be a non-negative constant, otherwise a logic
+ * exception is thrown TheorySetsPrivate::preRegisterTerm).
+ */
struct JoinImageTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
};
+/**
+ * Type rule for unary operator (rel.iden A) to check that A is a unary relation
+ * of type (Set (Tuple T)) and computes the type (Set (Tuple T T)) for the
+ * identity
+ */
struct RelIdenTypeRule
{
static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check);
diff --git a/src/theory/strings/arith_entail.cpp b/src/theory/strings/arith_entail.cpp
index 9e3d8ad38..d8a4e85aa 100644
--- a/src/theory/strings/arith_entail.cpp
+++ b/src/theory/strings/arith_entail.cpp
@@ -32,7 +32,7 @@ namespace strings {
ArithEntail::ArithEntail(Rewriter* r) : d_rr(r)
{
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
}
Node ArithEntail::rewrite(Node a) { return d_rr->rewrite(a); }
@@ -77,7 +77,9 @@ bool ArithEntail::check(Node a, bool strict)
}
Node ar = strict ? NodeManager::currentNM()->mkNode(
- kind::MINUS, a, NodeManager::currentNM()->mkConst(Rational(1)))
+ kind::MINUS,
+ a,
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1)))
: a;
ar = d_rr->rewrite(ar);
@@ -131,7 +133,7 @@ bool ArithEntail::checkApprox(Node ar)
<< "Get approximations " << v << "..." << std::endl;
if (v.isNull())
{
- Node mn = c.isNull() ? nm->mkConst(Rational(1)) : c;
+ Node mn = c.isNull() ? nm->mkConst(CONST_RATIONAL, Rational(1)) : c;
aarSum.push_back(mn);
}
else
@@ -494,8 +496,8 @@ void ArithEntail::getArithApproximations(Node a,
{
// x >= 0 implies
// x+1 >= len( int.to.str( x ) )
- approx.push_back(
- nm->mkNode(PLUS, nm->mkConst(Rational(1)), a[0][0]));
+ approx.push_back(nm->mkNode(
+ PLUS, nm->mkConst(CONST_RATIONAL, Rational(1)), a[0][0]));
}
}
}
@@ -505,7 +507,7 @@ void ArithEntail::getArithApproximations(Node a,
{
// x >= 0 implies
// len( int.to.str( x ) ) >= 1
- approx.push_back(nm->mkConst(Rational(1)));
+ approx.push_back(nm->mkConst(CONST_RATIONAL, Rational(1)));
}
// other crazy things are possible here, e.g.
// len( int.to.str( len( y ) + 10 ) ) >= 2
@@ -539,7 +541,7 @@ void ArithEntail::getArithApproximations(Node a,
// ...hard to test, runs risk of non-termination
// -1 <= indexof( x, y, n )
- approx.push_back(nm->mkConst(Rational(-1)));
+ approx.push_back(nm->mkConst(CONST_RATIONAL, Rational(-1)));
}
}
else if (ak == STRING_STOI)
@@ -554,7 +556,7 @@ void ArithEntail::getArithApproximations(Node a,
else
{
// -1 <= str.to.int( x )
- approx.push_back(nm->mkConst(Rational(-1)));
+ approx.push_back(nm->mkConst(CONST_RATIONAL, Rational(-1)));
}
}
Trace("strings-ent-approx-debug") << "Return " << approx.size() << std::endl;
@@ -659,7 +661,9 @@ bool ArithEntail::checkWithAssumption(Node assumption,
// (not (>= s t)) --> (>= (t - 1) s)
Assert(assumption.getKind() == kind::NOT
&& assumption[0].getKind() == kind::GEQ);
- x = nm->mkNode(kind::MINUS, assumption[0][1], nm->mkConst(Rational(1)));
+ x = nm->mkNode(kind::MINUS,
+ assumption[0][1],
+ nm->mkConst(CONST_RATIONAL, Rational(1)));
y = assumption[0][0];
}
@@ -859,7 +863,7 @@ Node ArithEntail::getConstantBoundLength(Node s, bool isLower)
NodeManager* nm = NodeManager::currentNM();
if (s.isConst())
{
- ret = nm->mkConst(Rational(Word::getLength(s)));
+ ret = nm->mkConst(CONST_RATIONAL, Rational(Word::getLength(s)));
}
else if (s.getKind() == STRING_CONCAT)
{
@@ -883,7 +887,7 @@ Node ArithEntail::getConstantBoundLength(Node s, bool isLower)
}
if (success)
{
- ret = nm->mkConst(sum);
+ ret = nm->mkConst(CONST_RATIONAL, sum);
}
}
else if (isLower)
diff --git a/src/theory/strings/array_solver.cpp b/src/theory/strings/array_solver.cpp
index 09e3aefdd..65ff4cde4 100644
--- a/src/theory/strings/array_solver.cpp
+++ b/src/theory/strings/array_solver.cpp
@@ -15,8 +15,10 @@
#include "theory/strings/array_solver.h"
+#include "expr/sequence.h"
#include "theory/strings/arith_entail.h"
#include "theory/strings/theory_strings_utils.h"
+#include "theory/strings/word.h"
#include "util/rational.h"
using namespace cvc5::context;
@@ -42,7 +44,7 @@ ArraySolver::ArraySolver(Env& env,
d_eqProc(context())
{
NodeManager* nm = NodeManager::currentNM();
- d_zero = nm->mkConst(Rational(0));
+ d_zero = nm->mkConst(CONST_RATIONAL, Rational(0));
}
ArraySolver::~ArraySolver() {}
@@ -81,6 +83,7 @@ void ArraySolver::checkTerms(Kind k)
Node r = d_state.getRepresentative(t[0]);
NormalForm& nf = d_csolver.getNormalForm(r);
Trace("seq-array-debug") << "...normal form " << nf.d_nf << std::endl;
+ std::vector<Node> nfChildren;
if (nf.d_nf.empty())
{
// updates should have been reduced (UPD_EMPTYSTR)
@@ -92,8 +95,16 @@ void ArraySolver::checkTerms(Kind k)
{
Trace("seq-array-debug") << "...norm form size 1" << std::endl;
// NOTE: could split on n=0 if needed, do not introduce ITE
- if (nf.d_nf[0].getKind() == SEQ_UNIT)
+ Kind ck = nf.d_nf[0].getKind();
+ // Note that (seq.unit c) is rewritten to CONST_SEQUENCE{c}, hence we
+ // check two cases here. It is important for completeness of this schema
+ // to handle this differently from STRINGS_ARRAY_UPDATE_CONCAT /
+ // STRINGS_ARRAY_NTH_CONCAT. Otherwise we would conclude a trivial
+ // equality when update/nth is applied to a constant of length one.
+ if (ck == SEQ_UNIT
+ || (ck == CONST_SEQUENCE && Word::getLength(nf.d_nf[0]) == 1))
{
+ Trace("seq-array-debug") << "...unit case" << std::endl;
// do we know whether n = 0 ?
// x = (seq.unit m) => (seq.update x n z) = ite(n=0, z, (seq.unit m))
// x = (seq.unit m) => (seq.nth x n) = ite(n=0, m, Uf(x, n))
@@ -109,7 +120,15 @@ void ArraySolver::checkTerms(Kind k)
else
{
Assert(k == SEQ_NTH);
- thenBranch = nf.d_nf[0][0];
+ if (ck == CONST_SEQUENCE)
+ {
+ const Sequence& seq = nf.d_nf[0].getConst<Sequence>();
+ thenBranch = seq.getVec()[0];
+ }
+ else
+ {
+ thenBranch = nf.d_nf[0][0];
+ }
Node uf = SkolemCache::mkSkolemSeqNth(t[0].getType(), "Uf");
elseBranch = nm->mkNode(APPLY_UF, uf, t[0], t[1]);
iid = InferenceId::STRINGS_ARRAY_NTH_UNIT;
@@ -126,17 +145,33 @@ void ArraySolver::checkTerms(Kind k)
d_eqProc.insert(eq);
d_im.sendInference(exp, eq, iid);
}
+ continue;
}
- // otherwise, the equivalence class is pure wrt concatenation
- d_currTerms[k].push_back(t);
- continue;
+ else if (ck != CONST_SEQUENCE)
+ {
+ // otherwise, if the normal form is not a constant sequence, the
+ // equivalence class is pure wrt concatenation.
+ d_currTerms[k].push_back(t);
+ continue;
+ }
+ // if the normal form is a constant sequence, it is treated as a
+ // concatenation. We split per character and case split on whether the
+ // nth/update falls on each character below, which must have a size
+ // greater than one.
+ std::vector<Node> chars = Word::getChars(nf.d_nf[0]);
+ Assert (chars.size()>1);
+ nfChildren.insert(nfChildren.end(), chars.begin(), chars.end());
+ }
+ else
+ {
+ nfChildren.insert(nfChildren.end(), nf.d_nf.begin(), nf.d_nf.end());
}
// otherwise, we are the concatenation of the components
// NOTE: for nth, split on index vs component lengths, do not introduce ITE
std::vector<Node> cond;
std::vector<Node> cchildren;
std::vector<Node> lacc;
- for (const Node& c : nf.d_nf)
+ for (const Node& c : nfChildren)
{
Trace("seq-array-debug") << "...process " << c << std::endl;
Node clen = nm->mkNode(STRING_LENGTH, c);
@@ -146,26 +181,49 @@ void ArraySolver::checkTerms(Kind k)
Node currSum = lacc.size() == 1 ? lacc[0] : nm->mkNode(PLUS, lacc);
currIndex = nm->mkNode(MINUS, currIndex, currSum);
}
- if (k == STRING_UPDATE)
+ Node cc;
+ // If it is a constant of length one, then the update/nth is determined
+ // in this interval. Notice this is done here as
+ // an optimization to short cut introducing terms like
+ // (seq.nth (seq.unit c) i), which by construction is only relevant in
+ // the context where i = 0, hence we replace by c here.
+ if (c.getKind() == CONST_SEQUENCE)
{
- Node cc = nm->mkNode(STRING_UPDATE, c, currIndex, t[2]);
- Trace("seq-array-debug") << "......component " << cc << std::endl;
- cchildren.push_back(cc);
+ const Sequence& seq = c.getConst<Sequence>();
+ if (seq.size() == 1)
+ {
+ if (k == STRING_UPDATE)
+ {
+ cc = nm->mkNode(ITE, t[1].eqNode(d_zero), t[2], c);
+ }
+ else
+ {
+ cc = seq.getVec()[0];
+ }
+ }
}
- else
+ // if we did not process as a constant of length one
+ if (cc.isNull())
{
- Assert(k == SEQ_NTH);
- Node cc = nm->mkNode(SEQ_NTH, c, currIndex);
- Trace("seq-array-debug") << "......component " << cc << std::endl;
- cchildren.push_back(cc);
+ if (k == STRING_UPDATE)
+ {
+ cc = nm->mkNode(STRING_UPDATE, c, currIndex, t[2]);
+ }
+ else
+ {
+ Assert(k == SEQ_NTH);
+ cc = nm->mkNode(SEQ_NTH, c, currIndex);
+ }
}
+ Trace("seq-array-debug") << "......component " << cc << std::endl;
+ cchildren.push_back(cc);
lacc.push_back(clen);
if (k == SEQ_NTH)
{
Node currSumPost = lacc.size() == 1 ? lacc[0] : nm->mkNode(PLUS, lacc);
- Node cc = nm->mkNode(LT, t[1], currSumPost);
- Trace("seq-array-debug") << "......condition " << cc << std::endl;
- cond.push_back(cc);
+ Node cf = nm->mkNode(LT, t[1], currSumPost);
+ Trace("seq-array-debug") << "......condition " << cf << std::endl;
+ cond.push_back(cf);
}
}
// z = (seq.++ x y) =>
diff --git a/src/theory/strings/base_solver.cpp b/src/theory/strings/base_solver.cpp
index 1e30b1623..69d50a7d9 100644
--- a/src/theory/strings/base_solver.cpp
+++ b/src/theory/strings/base_solver.cpp
@@ -46,7 +46,7 @@ void BaseSolver::checkInit()
// build term index
d_eqcInfo.clear();
d_termIndex.clear();
- d_stringsEqc.clear();
+ d_stringLikeEqc.clear();
Trace("strings-base") << "BaseSolver::checkInit" << std::endl;
// count of congruent, non-congruent per operator (independent of type),
@@ -65,7 +65,7 @@ void BaseSolver::checkInit()
std::map<Kind, TermIndex>& tti = d_termIndex[tn];
if (tn.isStringLike())
{
- d_stringsEqc.push_back(eqc);
+ d_stringLikeEqc.push_back(eqc);
emps = Word::mkEmptyWord(tn);
}
Node var;
@@ -512,7 +512,7 @@ void BaseSolver::checkCardinality()
// between lengths of string terms that are disequal (DEQ-LENGTH-SP).
std::map<TypeNode, std::vector<std::vector<Node> > > cols;
std::map<TypeNode, std::vector<Node> > lts;
- d_state.separateByLength(d_stringsEqc, cols, lts);
+ d_state.separateByLength(d_stringLikeEqc, cols, lts);
for (std::pair<const TypeNode, std::vector<std::vector<Node> > >& c : cols)
{
checkCardinalityType(c.first, c.second, lts[c.first]);
@@ -604,7 +604,8 @@ void BaseSolver::checkCardinalityType(TypeNode tn,
if (lr.isConst())
{
// if constant, compare
- Node cmp = nm->mkNode(GEQ, lr, nm->mkConst(Rational(card_need)));
+ Node cmp =
+ nm->mkNode(GEQ, lr, nm->mkConst(CONST_RATIONAL, Rational(card_need)));
cmp = rewrite(cmp);
needsSplit = !cmp.getConst<bool>();
}
@@ -618,7 +619,7 @@ void BaseSolver::checkCardinalityType(TypeNode tn,
bool success = true;
while (r < card_need && success)
{
- Node rr = nm->mkConst(Rational(r));
+ Node rr = nm->mkConst(CONST_RATIONAL, Rational(r));
if (d_state.areDisequal(rr, lr))
{
r++;
@@ -668,7 +669,7 @@ void BaseSolver::checkCardinalityType(TypeNode tn,
<< std::endl;
if (int_k + 1 > ei->d_cardinalityLemK.get())
{
- Node k_node = nm->mkConst(Rational(int_k));
+ Node k_node = nm->mkConst(CONST_RATIONAL, Rational(int_k));
// add cardinality lemma
Node dist = nm->mkNode(DISTINCT, cols[i]);
std::vector<Node> expn;
@@ -758,9 +759,9 @@ Node BaseSolver::explainBestContentEqc(Node n, Node eqc, std::vector<Node>& exp)
return Node::null();
}
-const std::vector<Node>& BaseSolver::getStringEqc() const
+const std::vector<Node>& BaseSolver::getStringLikeEqc() const
{
- return d_stringsEqc;
+ return d_stringLikeEqc;
}
Node BaseSolver::TermIndex::add(TNode n,
diff --git a/src/theory/strings/base_solver.h b/src/theory/strings/base_solver.h
index bf61b93b2..96d275cd5 100644
--- a/src/theory/strings/base_solver.h
+++ b/src/theory/strings/base_solver.h
@@ -106,7 +106,7 @@ class BaseSolver : protected EnvObj
/**
* Get the set of equivalence classes of type string.
*/
- const std::vector<Node>& getStringEqc() const;
+ const std::vector<Node>& getStringLikeEqc() const;
//-----------------------end query functions
private:
@@ -236,8 +236,8 @@ class BaseSolver : protected EnvObj
* for more information.
*/
std::map<Node, BaseEqcInfo> d_eqcInfo;
- /** The list of equivalence classes of type string */
- std::vector<Node> d_stringsEqc;
+ /** The list of equivalence classes of string-like types */
+ std::vector<Node> d_stringLikeEqc;
/** A term index for each type, function kind pair */
std::map<TypeNode, std::map<Kind, TermIndex> > d_termIndex;
/** the cardinality of the alphabet */
diff --git a/src/theory/strings/core_solver.cpp b/src/theory/strings/core_solver.cpp
index 3cf08a8d6..46f75bd10 100644
--- a/src/theory/strings/core_solver.cpp
+++ b/src/theory/strings/core_solver.cpp
@@ -50,9 +50,9 @@ CoreSolver::CoreSolver(Env& env,
d_nfPairs(context()),
d_extDeq(userContext())
{
- d_zero = NodeManager::currentNM()->mkConst( Rational( 0 ) );
- d_one = NodeManager::currentNM()->mkConst( Rational( 1 ) );
- d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
+ d_neg_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(-1));
d_true = NodeManager::currentNM()->mkConst( true );
d_false = NodeManager::currentNM()->mkConst( false );
}
@@ -131,7 +131,7 @@ void CoreSolver::checkCycles()
d_eqc.clear();
// Rebuild strings eqc based on acyclic ordering, first copy the equivalence
// classes from the base solver.
- const std::vector<Node>& eqc = d_bsolver.getStringEqc();
+ const std::vector<Node>& eqc = d_bsolver.getStringLikeEqc();
d_strings_eqc.clear();
for (const Node& r : eqc)
{
@@ -776,12 +776,12 @@ Node CoreSolver::getConclusion(Node x,
{
// we can assume its length is greater than zero
Node emp = Word::mkEmptyWord(sk1.getType());
- conc = nm->mkNode(
- AND,
- conc,
- sk1.eqNode(emp).negate(),
- nm->mkNode(
- GT, nm->mkNode(STRING_LENGTH, sk1), nm->mkConst(Rational(0))));
+ conc = nm->mkNode(AND,
+ conc,
+ sk1.eqNode(emp).negate(),
+ nm->mkNode(GT,
+ nm->mkNode(STRING_LENGTH, sk1),
+ nm->mkConst(CONST_RATIONAL, Rational(0))));
}
}
else if (rule == PfRule::CONCAT_CSPLIT)
diff --git a/src/theory/strings/infer_proof_cons.cpp b/src/theory/strings/infer_proof_cons.cpp
index 5090b15cb..edfb91c64 100644
--- a/src/theory/strings/infer_proof_cons.cpp
+++ b/src/theory/strings/infer_proof_cons.cpp
@@ -499,7 +499,7 @@ void InferProofCons::convert(InferenceId infer,
{
// it should be the case that lenConstraint => lenReq
lenReq = nm->mkNode(STRING_LENGTH, t0)
- .eqNode(nm->mkConst(Rational(0)))
+ .eqNode(nm->mkConst(CONST_RATIONAL, Rational(0)))
.notNode();
lenSuccess = convertLengthPf(lenReq, lenConstraint, psb);
rule = PfRule::CONCAT_CSPLIT;
@@ -530,7 +530,7 @@ void InferProofCons::convert(InferenceId infer,
{
// it should be the case that lenConstraint => lenReq
lenReq = nm->mkNode(STRING_LENGTH, t0)
- .eqNode(nm->mkConst(Rational(0)))
+ .eqNode(nm->mkConst(CONST_RATIONAL, Rational(0)))
.notNode();
lenSuccess = convertLengthPf(lenReq, lenConstraint, psb);
rule = PfRule::CONCAT_CPROP;
@@ -837,7 +837,7 @@ void InferProofCons::convert(InferenceId infer,
std::vector<Node> childrenAE;
childrenAE.push_back(eunf);
std::vector<Node> argsAE;
- argsAE.push_back(nm->mkConst(Rational(0)));
+ argsAE.push_back(nm->mkConst(CONST_RATIONAL, Rational(0)));
Node eunfAE = psb.tryStep(PfRule::AND_ELIM, childrenAE, argsAE);
Trace("strings-ipc-prefix")
<< "--- and elim to " << eunfAE << std::endl;
diff --git a/src/theory/strings/inference_manager.cpp b/src/theory/strings/inference_manager.cpp
index 277cc72e1..5247e222d 100644
--- a/src/theory/strings/inference_manager.cpp
+++ b/src/theory/strings/inference_manager.cpp
@@ -51,8 +51,8 @@ InferenceManager::InferenceManager(Env& env,
: nullptr)
{
NodeManager* nm = NodeManager::currentNM();
- d_zero = nm->mkConst(Rational(0));
- d_one = nm->mkConst(Rational(1));
+ d_zero = nm->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = nm->mkConst(CONST_RATIONAL, Rational(1));
d_true = nm->mkConst(true);
d_false = nm->mkConst(false);
}
diff --git a/src/theory/strings/proof_checker.cpp b/src/theory/strings/proof_checker.cpp
index b9038e3c8..edb38e702 100644
--- a/src/theory/strings/proof_checker.cpp
+++ b/src/theory/strings/proof_checker.cpp
@@ -212,8 +212,8 @@ Node StringProofRuleChecker::checkInternal(PfRule id,
else if (id == PfRule::CONCAT_CSPLIT)
{
Assert(children.size() == 2);
- Node zero = nm->mkConst(Rational(0));
- Node one = nm->mkConst(Rational(1));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
if (children[1].getKind() != NOT || children[1][0].getKind() != EQUAL
|| children[1][0][0].getKind() != STRING_LENGTH
|| children[1][0][0][0] != t0 || children[1][0][1] != zero)
@@ -240,7 +240,7 @@ Node StringProofRuleChecker::checkInternal(PfRule id,
else if (id == PfRule::CONCAT_CPROP)
{
Assert(children.size() == 2);
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
Trace("pfcheck-strings-cprop")
<< "CONCAT_PROP, isRev=" << isRev << std::endl;
@@ -352,7 +352,7 @@ Node StringProofRuleChecker::checkInternal(PfRule id,
{
return Node::null();
}
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
Node clen = nm->mkNode(STRING_LENGTH, nemp[0][0]);
return clen.eqNode(zero).notNode();
}
@@ -462,7 +462,7 @@ Node StringProofRuleChecker::checkInternal(PfRule id,
&& args[1].getType().isStringLike());
Node c1 = nm->mkNode(STRING_TO_CODE, args[0]);
Node c2 = nm->mkNode(STRING_TO_CODE, args[1]);
- Node eqNegOne = c1.eqNode(nm->mkConst(Rational(-1)));
+ Node eqNegOne = c1.eqNode(nm->mkConst(CONST_RATIONAL, Rational(-1)));
Node deq = c1.eqNode(c2).negate();
Node eqn = args[0].eqNode(args[1]);
return nm->mkNode(kind::OR, eqNegOne, deq, eqn);
diff --git a/src/theory/strings/regexp_elim.cpp b/src/theory/strings/regexp_elim.cpp
index d5b7606f2..8a96e22d2 100644
--- a/src/theory/strings/regexp_elim.cpp
+++ b/src/theory/strings/regexp_elim.cpp
@@ -98,7 +98,7 @@ Node RegExpElimination::eliminateConcat(Node atom, bool isAgg)
Node x = atom[0];
Node lenx = nm->mkNode(STRING_LENGTH, x);
Node re = atom[1];
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
std::vector<Node> children;
utils::getConcat(re, children);
@@ -253,7 +253,9 @@ Node RegExpElimination::eliminateConcat(Node atom, bool isAgg)
{
// the gap to this child is at least gap_minsize[i]
prev_end =
- nm->mkNode(PLUS, prev_end, nm->mkConst(Rational(gap_minsize[i])));
+ nm->mkNode(PLUS,
+ prev_end,
+ nm->mkConst(CONST_RATIONAL, Rational(gap_minsize[i])));
}
prev_ends.push_back(prev_end);
Node sc = sep_children[i];
@@ -278,8 +280,8 @@ Node RegExpElimination::eliminateConcat(Node atom, bool isAgg)
}
// if the gap after this one is strict, we need a non-greedy find
// thus, we add a symbolic constant
- Node cacheVal =
- BoundVarManager::getCacheValue(atom, nm->mkConst(Rational(i)));
+ Node cacheVal = BoundVarManager::getCacheValue(
+ atom, nm->mkConst(CONST_RATIONAL, Rational(i)));
TypeNode intType = nm->integerType();
Node k =
bvm->mkBoundVar<ReElimConcatIndexAttribute>(cacheVal, intType);
@@ -287,7 +289,8 @@ Node RegExpElimination::eliminateConcat(Node atom, bool isAgg)
prev_end = nm->mkNode(PLUS, prev_end, k);
}
Node curr = nm->mkNode(STRING_INDEXOF, x, sc, prev_end);
- Node idofFind = curr.eqNode(nm->mkConst(Rational(-1))).negate();
+ Node idofFind =
+ curr.eqNode(nm->mkConst(CONST_RATIONAL, Rational(-1))).negate();
conj.push_back(idofFind);
prev_end = nm->mkNode(PLUS, curr, lensc);
}
@@ -302,7 +305,7 @@ Node RegExpElimination::eliminateConcat(Node atom, bool isAgg)
// then the last indexof/substr constraint entails the following
// constraint, so it is not necessary to add.
// Below, we may write "A" for (str.to.re "A") and _ for re.allchar:
- Node cEnd = nm->mkConst(Rational(gap_minsize_end));
+ Node cEnd = nm->mkConst(CONST_RATIONAL, Rational(gap_minsize_end));
if (gap_exact_end)
{
Assert(!sep_children.empty());
@@ -474,8 +477,8 @@ Node RegExpElimination::eliminateConcat(Node atom, bool isAgg)
}
else
{
- Node cacheVal =
- BoundVarManager::getCacheValue(atom, nm->mkConst(Rational(i)));
+ Node cacheVal = BoundVarManager::getCacheValue(
+ atom, nm->mkConst(CONST_RATIONAL, Rational(i)));
TypeNode intType = nm->integerType();
k = bvm->mkBoundVar<ReElimConcatIndexAttribute>(cacheVal, intType);
Node bound =
@@ -538,7 +541,7 @@ Node RegExpElimination::eliminateStar(Node atom, bool isAgg)
Node x = atom[0];
Node lenx = nm->mkNode(STRING_LENGTH, x);
Node re = atom[1];
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
// for regular expression star,
// if the period is a fixed constant, we can turn it into a bounded
// quantifier
@@ -558,8 +561,8 @@ Node RegExpElimination::eliminateStar(Node atom, bool isAgg)
std::vector<Node> char_constraints;
TypeNode intType = nm->integerType();
Node index = bvm->mkBoundVar<ReElimStarIndexAttribute>(atom, intType);
- Node substr_ch =
- nm->mkNode(STRING_SUBSTR, x, index, nm->mkConst(Rational(1)));
+ Node substr_ch = nm->mkNode(
+ STRING_SUBSTR, x, index, nm->mkConst(CONST_RATIONAL, Rational(1)));
substr_ch = Rewriter::rewrite(substr_ch);
// handle the case where it is purely characters
for (const Node& r : disj)
diff --git a/src/theory/strings/regexp_entail.cpp b/src/theory/strings/regexp_entail.cpp
index 530f34455..c9d890358 100644
--- a/src/theory/strings/regexp_entail.cpp
+++ b/src/theory/strings/regexp_entail.cpp
@@ -574,7 +574,7 @@ bool RegExpEntail::testConstStringInRegExp(cvc5::String& s,
}
else
{
- Node num2 = nm->mkConst(cvc5::Rational(u - 1));
+ Node num2 = nm->mkConst(CONST_RATIONAL, cvc5::Rational(u - 1));
Node r2 = nm->mkNode(REGEXP_LOOP, r[0], r[1], num2);
if (testConstStringInRegExp(s, index_start + len, r2))
{
@@ -606,7 +606,7 @@ bool RegExpEntail::testConstStringInRegExp(cvc5::String& s,
cvc5::String t = s.substr(index_start, len);
if (testConstStringInRegExp(t, 0, r[0]))
{
- Node num2 = nm->mkConst(cvc5::Rational(l - 1));
+ Node num2 = nm->mkConst(CONST_RATIONAL, cvc5::Rational(l - 1));
Node r2 = nm->mkNode(REGEXP_LOOP, r[0], num2, num2);
if (testConstStringInRegExp(s, index_start + len, r2))
{
@@ -657,7 +657,7 @@ Node RegExpEntail::getFixedLengthForRegexp(Node n)
}
else if (n.getKind() == REGEXP_ALLCHAR || n.getKind() == REGEXP_RANGE)
{
- return nm->mkConst(Rational(1));
+ return nm->mkConst(CONST_RATIONAL, Rational(1));
}
else if (n.getKind() == REGEXP_UNION || n.getKind() == REGEXP_INTER)
{
diff --git a/src/theory/strings/regexp_operation.cpp b/src/theory/strings/regexp_operation.cpp
index fff512f98..a7ba37b18 100644
--- a/src/theory/strings/regexp_operation.cpp
+++ b/src/theory/strings/regexp_operation.cpp
@@ -37,8 +37,10 @@ RegExpOpr::RegExpOpr(Env& env, SkolemCache* sc)
d_false(NodeManager::currentNM()->mkConst(false)),
d_emptyRegexp(NodeManager::currentNM()->mkNode(kind::REGEXP_NONE,
std::vector<Node>{})),
- d_zero(NodeManager::currentNM()->mkConst(::cvc5::Rational(0))),
- d_one(NodeManager::currentNM()->mkConst(::cvc5::Rational(1))),
+ d_zero(NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ ::cvc5::Rational(0))),
+ d_one(NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ ::cvc5::Rational(1))),
d_sigma(NodeManager::currentNM()->mkNode(kind::REGEXP_ALLCHAR,
std::vector<Node>{})),
d_sigma_star(
@@ -909,7 +911,7 @@ Node RegExpOpr::reduceRegExpNeg(Node mem)
Node r = mem[0][1];
NodeManager* nm = NodeManager::currentNM();
Kind k = r.getKind();
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
Node conc;
if (k == REGEXP_CONCAT)
{
@@ -953,7 +955,7 @@ Node RegExpOpr::reduceRegExpNegConcatFixed(Node mem, Node reLen, size_t index)
Node r = mem[0][1];
NodeManager* nm = NodeManager::currentNM();
Assert(r.getKind() == REGEXP_CONCAT);
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
// The following simplification states that
// ~( s in R1 ++ R2 ++... ++ Rn )
// is equivalent to
@@ -1038,7 +1040,7 @@ Node RegExpOpr::reduceRegExpPos(Node mem,
}
else
{
- Node ivalue = nm->mkConst(Rational(i));
+ Node ivalue = nm->mkConst(CONST_RATIONAL, Rational(i));
Node sk = sm->mkSkolemFunction(SkolemFunId::RE_UNFOLD_POS_COMPONENT,
s.getType(),
{mem[0], mem[1], ivalue});
@@ -1321,7 +1323,8 @@ Node RegExpOpr::intersectInternal( Node r1, Node r2, std::map< PairNodes, Node >
std::map< PairNodes, Node > cache2(cache);
cache2[p] = NodeManager::currentNM()->mkNode(
kind::REGEXP_RV,
- NodeManager::currentNM()->mkConst(cvc5::Rational(cnt)));
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL,
+ cvc5::Rational(cnt)));
rt = intersectInternal(r1l, r2l, cache2, cnt+1);
cacheX[ pp ] = rt;
}
diff --git a/src/theory/strings/rewrites.cpp b/src/theory/strings/rewrites.cpp
index 549d33efc..f73f78c24 100644
--- a/src/theory/strings/rewrites.cpp
+++ b/src/theory/strings/rewrites.cpp
@@ -76,6 +76,10 @@ const char* toString(Rewrite r)
case Rewrite::RE_AND_EMPTY: return "RE_AND_EMPTY";
case Rewrite::RE_ANDOR_FLATTEN: return "RE_ANDOR_FLATTEN";
case Rewrite::RE_ANDOR_INC_CONFLICT: return "RE_ANDOR_INC_CONFLICT";
+ case Rewrite::RE_INTER_CONST_CONST_CONFLICT:
+ return "RE_INTER_CONST_CONST_CONFLICT";
+ case Rewrite::RE_INTER_CONST_RE_CONFLICT:
+ return "RE_INTER_CONST_RE_CONFLICT";
case Rewrite::RE_CHAR_IN_STR_STAR: return "RE_CHAR_IN_STR_STAR";
case Rewrite::RE_CONCAT: return "RE_CONCAT";
case Rewrite::RE_CONCAT_FLATTEN: return "RE_CONCAT_FLATTEN";
diff --git a/src/theory/strings/rewrites.h b/src/theory/strings/rewrites.h
index 5e63c55c8..684ee0e8a 100644
--- a/src/theory/strings/rewrites.h
+++ b/src/theory/strings/rewrites.h
@@ -81,6 +81,8 @@ enum class Rewrite : uint32_t
RE_AND_EMPTY,
RE_ANDOR_FLATTEN,
RE_ANDOR_INC_CONFLICT,
+ RE_INTER_CONST_CONST_CONFLICT,
+ RE_INTER_CONST_RE_CONFLICT,
RE_CHAR_IN_STR_STAR,
RE_CONCAT,
RE_CONCAT_FLATTEN,
diff --git a/src/theory/strings/sequences_rewriter.cpp b/src/theory/strings/sequences_rewriter.cpp
index babf260fc..fbb40f212 100644
--- a/src/theory/strings/sequences_rewriter.cpp
+++ b/src/theory/strings/sequences_rewriter.cpp
@@ -352,7 +352,7 @@ Node SequencesRewriter::rewriteStrEqualityExt(Node node)
}
else if (ne.getKind() == STRING_SUBSTR)
{
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
if (d_arithEntail.check(ne[1], false)
&& d_arithEntail.check(ne[2], true))
@@ -586,7 +586,8 @@ Node SequencesRewriter::rewriteLength(Node node)
Kind nk0 = node[0].getKind();
if (node[0].isConst())
{
- Node retNode = nm->mkConst(Rational(Word::getLength(node[0])));
+ Node retNode =
+ nm->mkConst(CONST_RATIONAL, Rational(Word::getLength(node[0])));
return returnRewrite(node, retNode, Rewrite::LEN_EVAL);
}
else if (nk0 == kind::STRING_CONCAT)
@@ -599,8 +600,8 @@ Node SequencesRewriter::rewriteLength(Node node)
{
if (tmpNode[i].isConst())
{
- node_vec.push_back(
- nm->mkConst(Rational(Word::getLength(tmpNode[i]))));
+ node_vec.push_back(nm->mkConst(
+ CONST_RATIONAL, Rational(Word::getLength(tmpNode[i]))));
}
else
{
@@ -633,7 +634,7 @@ Node SequencesRewriter::rewriteLength(Node node)
}
else if (nk0 == SEQ_UNIT)
{
- Node retNode = nm->mkConst(Rational(1));
+ Node retNode = nm->mkConst(CONST_RATIONAL, Rational(1));
return returnRewrite(node, retNode, Rewrite::LEN_SEQ_UNIT);
}
return node;
@@ -978,11 +979,17 @@ Node SequencesRewriter::rewriteAndOrRegExp(TNode node)
Assert(nk == REGEXP_UNION || nk == REGEXP_INTER);
Trace("strings-rewrite-debug")
<< "Strings::rewriteAndOrRegExp start " << node << std::endl;
+ NodeManager* nm = NodeManager::currentNM();
std::vector<Node> node_vec;
std::vector<Node> polRegExp[2];
+ // list of constant string regular expressions (str.to_re c)
+ std::vector<Node> constStrRe;
+ // list of all other regular expressions
+ std::vector<Node> otherRe;
for (const Node& ni : node)
{
- if (ni.getKind() == nk)
+ Kind nik = ni.getKind();
+ if (nik == nk)
{
for (const Node& nic : ni)
{
@@ -992,7 +999,7 @@ Node SequencesRewriter::rewriteAndOrRegExp(TNode node)
}
}
}
- else if (ni.getKind() == REGEXP_NONE)
+ else if (nik == REGEXP_NONE)
{
if (nk == REGEXP_INTER)
{
@@ -1000,7 +1007,7 @@ Node SequencesRewriter::rewriteAndOrRegExp(TNode node)
}
// otherwise, can ignore
}
- else if (ni.getKind() == REGEXP_STAR && ni[0].getKind() == REGEXP_ALLCHAR)
+ else if (nik == REGEXP_STAR && ni[0].getKind() == REGEXP_ALLCHAR)
{
if (nk == REGEXP_UNION)
{
@@ -1010,13 +1017,103 @@ Node SequencesRewriter::rewriteAndOrRegExp(TNode node)
}
else if (std::find(node_vec.begin(), node_vec.end(), ni) == node_vec.end())
{
+ if (nik == STRING_TO_REGEXP && ni[0].isConst())
+ {
+ if (nk == REGEXP_INTER)
+ {
+ if (!constStrRe.empty())
+ {
+ Assert(constStrRe[0][0] != ni[0]);
+ // (re.inter .. (str.to_re c1) .. (str.to_re c2) ..) ---> re.none
+ // for distinct constant strings c1, c2.
+ Node ret = nm->mkNode(kind::REGEXP_NONE);
+ return returnRewrite(
+ node, ret, Rewrite::RE_INTER_CONST_CONST_CONFLICT);
+ }
+ }
+ else
+ {
+ Assert(nk == REGEXP_UNION);
+ }
+ constStrRe.push_back(ni);
+ }
+ else
+ {
+ otherRe.push_back(ni);
+ uint32_t pindex = nik == REGEXP_COMPLEMENT ? 1 : 0;
+ Node nia = pindex == 1 ? ni[0] : ni;
+ polRegExp[pindex].push_back(nia);
+ }
node_vec.push_back(ni);
- uint32_t pindex = ni.getKind() == REGEXP_COMPLEMENT ? 1 : 0;
- Node nia = pindex == 1 ? ni[0] : ni;
- polRegExp[pindex].push_back(nia);
}
}
- NodeManager* nm = NodeManager::currentNM();
+ Trace("strings-rewrite-debug")
+ << "Partition constant components " << constStrRe.size() << " / "
+ << otherRe.size() << std::endl;
+ // go back and process constant strings against the others
+ if (!constStrRe.empty())
+ {
+ std::unordered_set<Node> toRemove;
+ for (const Node& c : constStrRe)
+ {
+ Assert(c.getKind() == STRING_TO_REGEXP && c[0].getKind() == CONST_STRING);
+ cvc5::String s = c[0].getConst<String>();
+ for (const Node& r : otherRe)
+ {
+ Trace("strings-rewrite-debug")
+ << "Check " << c << " vs " << r << std::endl;
+ // skip if already removing, or not constant
+ if (!RegExpEntail::isConstRegExp(r)
+ || toRemove.find(r) != toRemove.end())
+ {
+ Trace("strings-rewrite-debug") << "...skip" << std::endl;
+ continue;
+ }
+ // test whether c from (str.to_re c) is in r
+ if (RegExpEntail::testConstStringInRegExp(s, 0, r))
+ {
+ Trace("strings-rewrite-debug") << "...included" << std::endl;
+ if (nk == REGEXP_INTER)
+ {
+ // (re.inter .. (str.to_re c) .. R ..) --->
+ // (re.inter .. (str.to_re c) .. ..) when c in R
+ toRemove.insert(r);
+ }
+ else
+ {
+ // (re.union .. (str.to_re c) .. R ..) --->
+ // (re.union .. .. R ..) when c in R
+ toRemove.insert(c);
+ break;
+ }
+ }
+ else
+ {
+ Trace("strings-rewrite-debug") << "...not included" << std::endl;
+ if (nk == REGEXP_INTER)
+ {
+ // (re.inter .. (str.to_re c) .. R ..) ---> re.none
+ // if c is not a member of R.
+ Node ret = nm->mkNode(kind::REGEXP_NONE);
+ return returnRewrite(
+ node, ret, Rewrite::RE_INTER_CONST_RE_CONFLICT);
+ }
+ }
+ }
+ }
+ if (!toRemove.empty())
+ {
+ std::vector<Node> nodeVecTmp;
+ node_vec.swap(nodeVecTmp);
+ for (const Node& nvt : nodeVecTmp)
+ {
+ if (toRemove.find(nvt) == toRemove.end())
+ {
+ node_vec.push_back(nvt);
+ }
+ }
+ }
+ }
// use inclusion tests
for (const Node& negMem : polRegExp[1])
{
@@ -1214,7 +1311,7 @@ Node SequencesRewriter::rewriteMembership(TNode node)
}
else if (r.getKind() == kind::REGEXP_ALLCHAR)
{
- Node one = nm->mkConst(Rational(1));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
Node retNode = one.eqNode(nm->mkNode(STRING_LENGTH, x));
return returnRewrite(node, retNode, Rewrite::RE_IN_SIGMA);
}
@@ -1247,7 +1344,7 @@ Node SequencesRewriter::rewriteMembership(TNode node)
Node flr = RegExpEntail::getFixedLengthForRegexp(r[0]);
if (!flr.isNull())
{
- Node one = nm->mkConst(Rational(1));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
if (flr == one)
{
NodeBuilder nb(AND);
@@ -1310,7 +1407,7 @@ Node SequencesRewriter::rewriteMembership(TNode node)
if (constStr.isNull())
{
// x in re.++(_*, _, _) ---> str.len(x) >= 2
- Node num = nm->mkConst(Rational(allSigmaMinSize));
+ Node num = nm->mkConst(CONST_RATIONAL, Rational(allSigmaMinSize));
Node lenx = nm->mkNode(STRING_LENGTH, x);
Node retNode = nm->mkNode(allSigmaStrict ? EQUAL : GEQ, lenx, num);
return returnRewrite(node, retNode, Rewrite::RE_CONCAT_PURE_ALLCHAR);
@@ -1602,9 +1699,10 @@ TrustNode SequencesRewriter::expandDefinition(Node node)
Node s = node[0];
Node n = node[1];
// seq.nth(s, n) --> ite(0 <= n < len(s), seq.nth_total(s,n), Uf(s, n))
- Node cond = nm->mkNode(AND,
- nm->mkNode(LEQ, nm->mkConst(Rational(0)), n),
- nm->mkNode(LT, n, nm->mkNode(STRING_LENGTH, s)));
+ Node cond =
+ nm->mkNode(AND,
+ nm->mkNode(LEQ, nm->mkConst(CONST_RATIONAL, Rational(0)), n),
+ nm->mkNode(LT, n, nm->mkNode(STRING_LENGTH, s)));
Node ss = nm->mkNode(SEQ_NTH_TOTAL, s, n);
Node uf = SkolemCache::mkSkolemSeqNth(s.getType(), "Uf");
Node u = nm->mkNode(APPLY_UF, uf, s, n);
@@ -1654,7 +1752,7 @@ Node SequencesRewriter::rewriteCharAt(Node node)
{
Assert(node.getKind() == STRING_CHARAT);
NodeManager* nm = NodeManager::currentNM();
- Node one = nm->mkConst(Rational(1));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
Node retNode = nm->mkNode(STRING_SUBSTR, node[0], node[1], one);
return returnRewrite(node, retNode, Rewrite::CHARAT_ELIM);
}
@@ -1732,7 +1830,7 @@ Node SequencesRewriter::rewriteSubstr(Node node)
}
}
}
- Node zero = nm->mkConst(cvc5::Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, cvc5::Rational(0));
// if entailed non-positive length or negative start point
if (d_arithEntail.check(zero, node[1], true))
@@ -2331,7 +2429,7 @@ Node SequencesRewriter::rewriteIndexof(Node node)
if (node[2].isConst() && node[2].getConst<Rational>().sgn() < 0)
{
// z<0 implies str.indexof( x, y, z ) --> -1
- Node negone = nm->mkConst(Rational(-1));
+ Node negone = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, negone, Rewrite::IDOF_NEG);
}
@@ -2349,7 +2447,7 @@ Node SequencesRewriter::rewriteIndexof(Node node)
// We know that, due to limitations on the size of string constants
// in our implementation, that accessing a position greater than
// rMaxInt is guaranteed to be out of bounds.
- Node negone = nm->mkConst(Rational(-1));
+ Node negone = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, negone, Rewrite::IDOF_MAX);
}
Assert(node[2].getConst<Rational>().sgn() >= 0);
@@ -2360,12 +2458,13 @@ Node SequencesRewriter::rewriteIndexof(Node node)
std::size_t ret = Word::find(s, t, start);
if (ret != std::string::npos)
{
- Node retv = nm->mkConst(Rational(static_cast<unsigned>(ret)));
+ Node retv =
+ nm->mkConst(CONST_RATIONAL, Rational(static_cast<unsigned>(ret)));
return returnRewrite(node, retv, Rewrite::IDOF_FIND);
}
else if (children0.size() == 1)
{
- Node negone = nm->mkConst(Rational(-1));
+ Node negone = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, negone, Rewrite::IDOF_NFIND);
}
}
@@ -2377,14 +2476,14 @@ Node SequencesRewriter::rewriteIndexof(Node node)
if (node[2].getConst<Rational>().sgn() == 0)
{
// indexof( x, x, 0 ) --> 0
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
return returnRewrite(node, zero, Rewrite::IDOF_EQ_CST_START);
}
}
if (d_arithEntail.check(node[2], true))
{
// y>0 implies indexof( x, x, y ) --> -1
- Node negone = nm->mkConst(Rational(-1));
+ Node negone = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, negone, Rewrite::IDOF_EQ_NSTART);
}
Node emp = Word::mkEmptyWord(stype);
@@ -2415,7 +2514,7 @@ Node SequencesRewriter::rewriteIndexof(Node node)
if (d_arithEntail.check(len1, len0m2, true))
{
// len(x)-z < len(y) implies indexof( x, y, z ) ----> -1
- Node negone = nm->mkConst(Rational(-1));
+ Node negone = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, negone, Rewrite::IDOF_LEN);
}
@@ -2497,7 +2596,7 @@ Node SequencesRewriter::rewriteIndexof(Node node)
else
{
// str.contains( x, y ) --> false implies str.indexof(x,y,z) --> -1
- Node negone = nm->mkConst(Rational(-1));
+ Node negone = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, negone, Rewrite::IDOF_NCTN);
}
}
@@ -2552,12 +2651,12 @@ Node SequencesRewriter::rewriteIndexofRe(Node node)
Node s = node[0];
Node r = node[1];
Node n = node[2];
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
Node slen = nm->mkNode(STRING_LENGTH, s);
if (d_arithEntail.check(zero, n, true) || d_arithEntail.check(n, slen, true))
{
- Node ret = nm->mkConst(Rational(-1));
+ Node ret = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, ret, Rewrite::INDEXOF_RE_INVALID_INDEX);
}
@@ -2572,7 +2671,7 @@ Node SequencesRewriter::rewriteIndexofRe(Node node)
// We know that, due to limitations on the size of string constants
// in our implementation, that accessing a position greater than
// rMaxInt is guaranteed to be out of bounds.
- Node negone = nm->mkConst(Rational(-1));
+ Node negone = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, negone, Rewrite::INDEXOF_RE_MAX_INDEX);
}
@@ -2580,6 +2679,7 @@ Node SequencesRewriter::rewriteIndexofRe(Node node)
Node rem = nm->mkConst(s.getConst<String>().substr(start));
std::pair<size_t, size_t> match = firstMatch(rem, r);
Node ret = nm->mkConst(
+ CONST_RATIONAL,
Rational(match.first == string::npos
? -1
: static_cast<int64_t>(start + match.first)));
@@ -2843,8 +2943,8 @@ Node SequencesRewriter::rewriteReplace(Node node)
nm->mkNode(kind::STRING_LENGTH, utils::mkConcat(children1, stype));
Node maxLen1 = nm->mkNode(kind::PLUS, partLen1, lastChild1[2]);
- Node zero = nm->mkConst(Rational(0));
- Node one = nm->mkConst(Rational(1));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
Node len0 = nm->mkNode(kind::STRING_LENGTH, node[0]);
Node len0_1 = nm->mkNode(kind::PLUS, len0, one);
// Check len(t) + j > len(x) + 1
@@ -3367,7 +3467,8 @@ Node SequencesRewriter::rewritePrefixSuffix(Node n)
Node val;
if (isPrefix)
{
- val = NodeManager::currentNM()->mkConst(::cvc5::Rational(0));
+ val =
+ NodeManager::currentNM()->mkConst(CONST_RATIONAL, ::cvc5::Rational(0));
}
else
{
diff --git a/src/theory/strings/skolem_cache.cpp b/src/theory/strings/skolem_cache.cpp
index dd4093e30..eb09ff187 100644
--- a/src/theory/strings/skolem_cache.cpp
+++ b/src/theory/strings/skolem_cache.cpp
@@ -54,7 +54,7 @@ SkolemCache::SkolemCache(Rewriter* rr) : d_rr(rr)
{
NodeManager* nm = NodeManager::currentNM();
d_strType = nm->stringType();
- d_zero = nm->mkConst(Rational(0));
+ d_zero = nm->mkConst(CONST_RATIONAL, Rational(0));
}
Node SkolemCache::mkSkolemCached(Node a, Node b, SkolemId id, const char* c)
@@ -217,26 +217,27 @@ SkolemCache::normalizeStringSkolem(SkolemId id, Node a, Node b)
{
// SK_ID_VC_SPT(x, y) ---> SK_SUFFIX_REM(x, 1)
id = SK_SUFFIX_REM;
- b = nm->mkConst(Rational(1));
+ b = nm->mkConst(CONST_RATIONAL, Rational(1));
}
else if (id == SK_ID_VC_SPT_REV)
{
// SK_ID_VC_SPT_REV(x, y) ---> SK_PREFIX(x, (- (str.len x) 1))
id = SK_PREFIX;
- b = nm->mkNode(
- MINUS, nm->mkNode(STRING_LENGTH, a), nm->mkConst(Rational(1)));
+ b = nm->mkNode(MINUS,
+ nm->mkNode(STRING_LENGTH, a),
+ nm->mkConst(CONST_RATIONAL, Rational(1)));
}
else if (id == SK_ID_DC_SPT)
{
// SK_ID_DC_SPT(x, y) ---> SK_PREFIX(x, 1)
id = SK_PREFIX;
- b = nm->mkConst(Rational(1));
+ b = nm->mkConst(CONST_RATIONAL, Rational(1));
}
else if (id == SK_ID_DC_SPT_REM)
{
// SK_ID_DC_SPT_REM(x, y) ---> SK_SUFFIX_REM(x, 1)
id = SK_SUFFIX_REM;
- b = nm->mkConst(Rational(1));
+ b = nm->mkConst(CONST_RATIONAL, Rational(1));
}
else if (id == SK_ID_DEQ_X)
{
diff --git a/src/theory/strings/solver_state.cpp b/src/theory/strings/solver_state.cpp
index dfb246954..045347cbb 100644
--- a/src/theory/strings/solver_state.cpp
+++ b/src/theory/strings/solver_state.cpp
@@ -34,7 +34,7 @@ SolverState::SolverState(Env& env, Valuation& v)
d_pendingConflictSet(env.getContext(), false),
d_pendingConflict(InferenceId::UNKNOWN)
{
- d_zero = NodeManager::currentNM()->mkConst(Rational(0));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
d_false = NodeManager::currentNM()->mkConst(false);
}
diff --git a/src/theory/strings/strings_entail.cpp b/src/theory/strings/strings_entail.cpp
index 3b90338fc..6e4ba25a5 100644
--- a/src/theory/strings/strings_entail.cpp
+++ b/src/theory/strings/strings_entail.cpp
@@ -123,7 +123,7 @@ bool StringsEntail::stripSymbolicLength(std::vector<Node>& n1,
Assert(dir == 1 || dir == -1);
Assert(nr.empty());
NodeManager* nm = NodeManager::currentNM();
- Node zero = nm->mkConst(cvc5::Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, cvc5::Rational(0));
bool ret = false;
bool success = true;
unsigned sindex = 0;
@@ -145,7 +145,7 @@ bool StringsEntail::stripSymbolicLength(std::vector<Node>& n1,
Assert(d_arithEntail.check(curr, true));
Node s = n1[sindex_use];
size_t slen = Word::getLength(s);
- Node ncl = nm->mkConst(cvc5::Rational(slen));
+ Node ncl = nm->mkConst(CONST_RATIONAL, cvc5::Rational(slen));
Node next_s = nm->mkNode(MINUS, lowerBound, ncl);
next_s = d_rr->rewrite(next_s);
Assert(next_s.isConst());
@@ -459,8 +459,10 @@ bool StringsEntail::componentContainsBase(
}
if (dir != -1)
{
- n1rb = nm->mkNode(
- STRING_SUBSTR, n2[0], nm->mkConst(Rational(0)), start_pos);
+ n1rb = nm->mkNode(STRING_SUBSTR,
+ n2[0],
+ nm->mkConst(CONST_RATIONAL, Rational(0)),
+ start_pos);
}
if (dir != 1)
{
@@ -712,7 +714,7 @@ bool StringsEntail::checkNonEmpty(Node a)
bool StringsEntail::checkLengthOne(Node s, bool strict)
{
NodeManager* nm = NodeManager::currentNM();
- Node one = nm->mkConst(Rational(1));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
Node len = nm->mkNode(STRING_LENGTH, s);
len = d_rr->rewrite(len);
return d_arithEntail.check(one, len)
diff --git a/src/theory/strings/strings_fmf.cpp b/src/theory/strings/strings_fmf.cpp
index b1050f480..2951c86a2 100644
--- a/src/theory/strings/strings_fmf.cpp
+++ b/src/theory/strings/strings_fmf.cpp
@@ -85,7 +85,8 @@ Node StringsFmf::StringSumLengthDecisionStrategy::mkLiteral(unsigned i)
return Node::null();
}
NodeManager* nm = NodeManager::currentNM();
- Node lit = nm->mkNode(LEQ, d_inputVarLsum.get(), nm->mkConst(Rational(i)));
+ Node lit = nm->mkNode(
+ LEQ, d_inputVarLsum.get(), nm->mkConst(CONST_RATIONAL, Rational(i)));
Trace("strings-fmf") << "StringsFMF::mkLiteral: " << lit << std::endl;
return lit;
}
diff --git a/src/theory/strings/strings_rewriter.cpp b/src/theory/strings/strings_rewriter.cpp
index 46b36986a..e4b91d4d8 100644
--- a/src/theory/strings/strings_rewriter.cpp
+++ b/src/theory/strings/strings_rewriter.cpp
@@ -100,11 +100,11 @@ Node StringsRewriter::rewriteStrToInt(Node node)
String s = node[0].getConst<String>();
if (s.isNumber())
{
- ret = nm->mkConst(s.toNumber());
+ ret = nm->mkConst(CONST_RATIONAL, s.toNumber());
}
else
{
- ret = nm->mkConst(Rational(-1));
+ ret = nm->mkConst(CONST_RATIONAL, Rational(-1));
}
return returnRewrite(node, ret, Rewrite::STOI_EVAL);
}
@@ -117,7 +117,7 @@ Node StringsRewriter::rewriteStrToInt(Node node)
String t = nc.getConst<String>();
if (!t.isNumber())
{
- Node ret = nm->mkConst(Rational(-1));
+ Node ret = nm->mkConst(CONST_RATIONAL, Rational(-1));
return returnRewrite(node, ret, Rewrite::STOI_CONCAT_NONNUM);
}
}
@@ -303,11 +303,11 @@ Node StringsRewriter::rewriteStringToCode(Node n)
{
std::vector<unsigned> vec = s.getVec();
Assert(vec.size() == 1);
- ret = nm->mkConst(Rational(vec[0]));
+ ret = nm->mkConst(CONST_RATIONAL, Rational(vec[0]));
}
else
{
- ret = nm->mkConst(Rational(-1));
+ ret = nm->mkConst(CONST_RATIONAL, Rational(-1));
}
return returnRewrite(n, ret, Rewrite::TO_CODE_EVAL);
}
@@ -320,9 +320,10 @@ Node StringsRewriter::rewriteStringIsDigit(Node n)
NodeManager* nm = NodeManager::currentNM();
// eliminate str.is_digit(s) ----> 48 <= str.to_code(s) <= 57
Node t = nm->mkNode(STRING_TO_CODE, n[0]);
- Node retNode = nm->mkNode(AND,
- nm->mkNode(LEQ, nm->mkConst(Rational(48)), t),
- nm->mkNode(LEQ, t, nm->mkConst(Rational(57))));
+ Node retNode =
+ nm->mkNode(AND,
+ nm->mkNode(LEQ, nm->mkConst(CONST_RATIONAL, Rational(48)), t),
+ nm->mkNode(LEQ, t, nm->mkConst(CONST_RATIONAL, Rational(57))));
return returnRewrite(n, retNode, Rewrite::IS_DIGIT_ELIM);
}
diff --git a/src/theory/strings/term_registry.cpp b/src/theory/strings/term_registry.cpp
index 1124be488..85027370e 100644
--- a/src/theory/strings/term_registry.cpp
+++ b/src/theory/strings/term_registry.cpp
@@ -60,9 +60,9 @@ TermRegistry::TermRegistry(Env& env,
: nullptr)
{
NodeManager* nm = NodeManager::currentNM();
- d_zero = nm->mkConst(Rational(0));
- d_one = nm->mkConst(Rational(1));
- d_negOne = NodeManager::currentNM()->mkConst(Rational(-1));
+ d_zero = nm->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = nm->mkConst(CONST_RATIONAL, Rational(1));
+ d_negOne = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(-1));
Assert(options().strings.stringsAlphaCard <= String::num_codes());
d_alphaCard = options().strings.stringsAlphaCard;
}
@@ -81,12 +81,13 @@ Node TermRegistry::eagerReduce(Node t, SkolemCache* sc, uint32_t alphaCard)
if (tk == STRING_TO_CODE)
{
// ite( str.len(s)==1, 0 <= str.code(s) < |A|, str.code(s)=-1 )
- Node code_len = utils::mkNLength(t[0]).eqNode(nm->mkConst(Rational(1)));
- Node code_eq_neg1 = t.eqNode(nm->mkConst(Rational(-1)));
- Node code_range =
- nm->mkNode(AND,
- nm->mkNode(GEQ, t, nm->mkConst(Rational(0))),
- nm->mkNode(LT, t, nm->mkConst(Rational(alphaCard))));
+ Node code_len =
+ utils::mkNLength(t[0]).eqNode(nm->mkConst(CONST_RATIONAL, Rational(1)));
+ Node code_eq_neg1 = t.eqNode(nm->mkConst(CONST_RATIONAL, Rational(-1)));
+ Node code_range = nm->mkNode(
+ AND,
+ nm->mkNode(GEQ, t, nm->mkConst(CONST_RATIONAL, Rational(0))),
+ nm->mkNode(LT, t, nm->mkConst(CONST_RATIONAL, Rational(alphaCard))));
lemma = nm->mkNode(ITE, code_len, code_range, code_eq_neg1);
}
else if (tk == STRING_INDEXOF || tk == STRING_INDEXOF_RE)
@@ -99,14 +100,15 @@ Node TermRegistry::eagerReduce(Node t, SkolemCache* sc, uint32_t alphaCard)
Node l = nm->mkNode(STRING_LENGTH, t[0]);
lemma = nm->mkNode(
AND,
- nm->mkNode(
- OR, t.eqNode(nm->mkConst(Rational(-1))), nm->mkNode(GEQ, t, t[2])),
+ nm->mkNode(OR,
+ t.eqNode(nm->mkConst(CONST_RATIONAL, Rational(-1))),
+ nm->mkNode(GEQ, t, t[2])),
nm->mkNode(LEQ, t, l));
}
else if (tk == STRING_STOI)
{
// (>= (str.to_int x) (- 1))
- lemma = nm->mkNode(GEQ, t, nm->mkConst(Rational(-1)));
+ lemma = nm->mkNode(GEQ, t, nm->mkConst(CONST_RATIONAL, Rational(-1)));
}
else if (tk == STRING_CONTAINS)
{
@@ -124,7 +126,7 @@ Node TermRegistry::eagerReduce(Node t, SkolemCache* sc, uint32_t alphaCard)
Node TermRegistry::lengthPositive(Node t)
{
NodeManager* nm = NodeManager::currentNM();
- Node zero = nm->mkConst(Rational(0));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
Node emp = Word::mkEmptyWord(t.getType());
Node tlen = nm->mkNode(STRING_LENGTH, t);
Node tlenEqZero = tlen.eqNode(zero);
@@ -414,7 +416,7 @@ TrustNode TermRegistry::getRegisterTermLemma(Node n)
}
else if (n.isConst())
{
- lsum = nm->mkConst(Rational(Word::getLength(n)));
+ lsum = nm->mkConst(CONST_RATIONAL, Rational(Word::getLength(n)));
}
Assert(!lsum.isNull());
d_proxyVarToLength[sk] = lsum;
@@ -484,7 +486,7 @@ bool TermRegistry::isHandledUpdate(Node n)
{
lenN = nm->mkNode(STRING_LENGTH, n[2]);
}
- Node one = nm->mkConst(Rational(1));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
return d_aent.checkEq(lenN, one);
}
diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp
index 17d9752c2..caeb8065e 100644
--- a/src/theory/strings/theory_strings.cpp
+++ b/src/theory/strings/theory_strings.cpp
@@ -83,9 +83,9 @@ TheoryStrings::TheoryStrings(Env& env, OutputChannel& out, Valuation valuation)
{
d_termReg.finishInit(&d_im);
- d_zero = NodeManager::currentNM()->mkConst( Rational( 0 ) );
- d_one = NodeManager::currentNM()->mkConst( Rational( 1 ) );
- d_neg_one = NodeManager::currentNM()->mkConst(Rational(-1));
+ d_zero = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(0));
+ d_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(1));
+ d_neg_one = NodeManager::currentNM()->mkConst(CONST_RATIONAL, Rational(-1));
d_true = NodeManager::currentNM()->mkConst( true );
d_false = NodeManager::currentNM()->mkConst( false );
@@ -421,7 +421,7 @@ bool TheoryStrings::collectModelInfoType(
lvalue++;
}
Trace("strings-model") << "*** Decide to make length of " << lvalue << std::endl;
- lts_values[i] = nm->mkConst(Rational(lvalue));
+ lts_values[i] = nm->mkConst(CONST_RATIONAL, Rational(lvalue));
values_used[lvalue] = Node::null();
}
Trace("strings-model") << "Need to assign values of length " << lts_values[i] << " to equivalence classes ";
@@ -930,7 +930,7 @@ void TheoryStrings::computeCareGraph(){
void TheoryStrings::checkRegisterTermsPreNormalForm()
{
- const std::vector<Node>& seqc = d_bsolver.getStringEqc();
+ const std::vector<Node>& seqc = d_bsolver.getStringLikeEqc();
for (const Node& eqc : seqc)
{
eq::EqClassIterator eqc_i = eq::EqClassIterator(eqc, d_equalityEngine);
@@ -959,9 +959,14 @@ void TheoryStrings::checkCodes()
// str.code applied to the proxy variables for each equivalence classes that
// are constants of size one
std::vector<Node> const_codes;
- const std::vector<Node>& seqc = d_bsolver.getStringEqc();
+ const std::vector<Node>& seqc = d_bsolver.getStringLikeEqc();
for (const Node& eqc : seqc)
{
+ if (!eqc.getType().isString())
+ {
+ continue;
+ }
+
NormalForm& nfe = d_csolver.getNormalForm(eqc);
if (nfe.d_nf.size() == 1 && nfe.d_nf[0].isConst())
{
@@ -1025,7 +1030,7 @@ void TheoryStrings::checkCodes()
void TheoryStrings::checkRegisterTermsNormalForms()
{
- const std::vector<Node>& seqc = d_bsolver.getStringEqc();
+ const std::vector<Node>& seqc = d_bsolver.getStringLikeEqc();
for (const Node& eqc : seqc)
{
NormalForm& nfi = d_csolver.getNormalForm(eqc);
@@ -1059,7 +1064,8 @@ TrustNode TheoryStrings::ppRewrite(TNode atom, std::vector<SkolemLemma>& lems)
SkolemCache* sc = d_termReg.getSkolemCache();
Node k = sc->mkSkolemCached(atom, SkolemCache::SK_PURIFY, "kFromCode");
Node t = atom[0];
- Node card = nm->mkConst(Rational(d_termReg.getAlphabetCardinality()));
+ Node card = nm->mkConst(CONST_RATIONAL,
+ Rational(d_termReg.getAlphabetCardinality()));
Node cond =
nm->mkNode(AND, nm->mkNode(LEQ, d_zero, t), nm->mkNode(LT, t, card));
Node emp = Word::mkEmptyWord(atom.getType());
diff --git a/src/theory/strings/theory_strings_preprocess.cpp b/src/theory/strings/theory_strings_preprocess.cpp
index 31f43d565..4f27371ff 100644
--- a/src/theory/strings/theory_strings_preprocess.cpp
+++ b/src/theory/strings/theory_strings_preprocess.cpp
@@ -53,9 +53,9 @@ Node StringsPreprocess::reduce(Node t,
<< "StringsPreprocess::reduce: " << t << std::endl;
Node retNode = t;
NodeManager* nm = NodeManager::currentNM();
- Node zero = nm->mkConst(Rational(0));
- Node one = nm->mkConst(Rational(1));
- Node negOne = nm->mkConst(Rational(-1));
+ Node zero = nm->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = nm->mkConst(CONST_RATIONAL, Rational(1));
+ Node negOne = nm->mkConst(CONST_RATIONAL, Rational(-1));
if( t.getKind() == kind::STRING_SUBSTR ) {
// processing term: substr( s, n, m )
@@ -184,7 +184,7 @@ Node StringsPreprocess::reduce(Node t,
Node skk = sc->mkTypedSkolemCached(
nm->integerType(), t, SkolemCache::SK_PURIFY, "iok");
- Node negone = nm->mkConst(Rational(-1));
+ Node negone = nm->mkConst(CONST_RATIONAL, Rational(-1));
// substr( x, n, len( x ) - n )
Node st = nm->mkNode(STRING_SUBSTR,
@@ -364,7 +364,7 @@ Node StringsPreprocess::reduce(Node t,
Node c0 = nm->mkNode(STRING_TO_CODE, nm->mkConst(String("0")));
Node c = nm->mkNode(MINUS, nm->mkNode(STRING_TO_CODE, sx), c0);
- Node ten = nm->mkConst(Rational(10));
+ Node ten = nm->mkConst(CONST_RATIONAL, Rational(10));
Node eq = ux1.eqNode(nm->mkNode(PLUS, c, nm->mkNode(MULT, ten, ux)));
Node leadingZeroPos =
nm->mkNode(AND, x.eqNode(zero), nm->mkNode(GT, leni, one));
@@ -431,7 +431,7 @@ Node StringsPreprocess::reduce(Node t,
MINUS,
nm->mkNode(STRING_TO_CODE, nm->mkNode(STRING_SUBSTR, s, k, one)),
c0);
- Node ten = nm->mkConst(Rational(10));
+ Node ten = nm->mkConst(CONST_RATIONAL, Rational(10));
Node kc3 = nm->mkNode(
OR, nm->mkNode(LT, codeSk, zero), nm->mkNode(GEQ, codeSk, ten));
conc1.push_back(nm->mkNode(OR, sEmpty, nm->mkNode(AND, kc1, kc2, kc3)));
@@ -865,10 +865,12 @@ Node StringsPreprocess::reduce(Node t,
Node ci = nm->mkNode(STRING_TO_CODE, nm->mkNode(STRING_SUBSTR, x, i, one));
Node ri = nm->mkNode(STRING_TO_CODE, nm->mkNode(STRING_SUBSTR, r, i, one));
- Node lb = nm->mkConst(Rational(t.getKind() == STRING_TOUPPER ? 97 : 65));
- Node ub = nm->mkConst(Rational(t.getKind() == STRING_TOUPPER ? 122 : 90));
- Node offset =
- nm->mkConst(Rational(t.getKind() == STRING_TOUPPER ? -32 : 32));
+ Node lb = nm->mkConst(CONST_RATIONAL,
+ Rational(t.getKind() == STRING_TOUPPER ? 97 : 65));
+ Node ub = nm->mkConst(CONST_RATIONAL,
+ Rational(t.getKind() == STRING_TOUPPER ? 122 : 90));
+ Node offset = nm->mkConst(
+ CONST_RATIONAL, Rational(t.getKind() == STRING_TOUPPER ? -32 : 32));
Node res = nm->mkNode(
ITE,
diff --git a/src/theory/strings/theory_strings_utils.cpp b/src/theory/strings/theory_strings_utils.cpp
index 59bb0755c..a133babba 100644
--- a/src/theory/strings/theory_strings_utils.cpp
+++ b/src/theory/strings/theory_strings_utils.cpp
@@ -165,7 +165,8 @@ Node mkNLength(Node t)
Node mkPrefix(Node t, Node n)
{
NodeManager* nm = NodeManager::currentNM();
- return nm->mkNode(STRING_SUBSTR, t, nm->mkConst(Rational(0)), n);
+ return nm->mkNode(
+ STRING_SUBSTR, t, nm->mkConst(CONST_RATIONAL, Rational(0)), n);
}
Node mkSuffix(Node t, Node n)
diff --git a/src/theory/uf/ho_extension.cpp b/src/theory/uf/ho_extension.cpp
index 96029eab8..aec223d66 100644
--- a/src/theory/uf/ho_extension.cpp
+++ b/src/theory/uf/ho_extension.cpp
@@ -19,6 +19,7 @@
#include "expr/skolem_manager.h"
#include "options/uf_options.h"
#include "theory/theory_model.h"
+#include "theory/uf/lambda_lift.h"
#include "theory/uf/theory_uf_rewriter.h"
using namespace std;
@@ -30,31 +31,83 @@ namespace uf {
HoExtension::HoExtension(Env& env,
TheoryState& state,
- TheoryInferenceManager& im)
+ TheoryInferenceManager& im,
+ LambdaLift& ll)
: EnvObj(env),
d_state(state),
d_im(im),
+ d_ll(ll),
d_extensionality(userContext()),
+ d_cachedLemmas(userContext()),
d_uf_std_skolem(userContext())
{
d_true = NodeManager::currentNM()->mkConst(true);
}
-Node HoExtension::ppRewrite(Node node)
+TrustNode HoExtension::ppRewrite(Node node, std::vector<SkolemLemma>& lems)
{
- // convert HO_APPLY to APPLY_UF if fully applied
- if (node.getKind() == HO_APPLY)
+ Kind k = node.getKind();
+ if (k == HO_APPLY)
{
+ // convert HO_APPLY to APPLY_UF if fully applied
if (node[0].getType().getNumChildren() == 2)
{
Trace("uf-ho") << "uf-ho : expanding definition : " << node << std::endl;
Node ret = getApplyUfForHoApply(node);
Trace("uf-ho") << "uf-ho : ppRewrite : " << node << " to " << ret
<< std::endl;
- return ret;
+ return TrustNode::mkTrustRewrite(node, ret);
}
+ // partial beta reduction
+ // f ---> (lambda ((x Int) (y Int)) s[x, y]) then (@ f t) is preprocessed
+ // to (lambda ((y Int)) s[t, y]).
+ if (options().uf.ufHoLazyLambdaLift)
+ {
+ Node op = node[0];
+ Node opl = d_ll.getLambdaFor(op);
+ if (!opl.isNull())
+ {
+ NodeManager* nm = NodeManager::currentNM();
+ Node app = nm->mkNode(HO_APPLY, opl, node[1]);
+ app = rewrite(app);
+ Trace("uf-lazy-ll")
+ << "Partial beta reduce: " << node << " -> " << app << std::endl;
+ return TrustNode::mkTrustRewrite(node, app, nullptr);
+ }
+ }
+ }
+ else if (k == APPLY_UF)
+ {
+ // Say (lambda ((x Int)) t[x]) occurs in the input. We replace this
+ // by k during ppRewrite. In the following, if we see (k s), we replace
+ // it by t[s]. This maintains the invariant that the *only* occurences
+ // of k are as arguments to other functions; k is not applied
+ // in any preprocessed constraints.
+ if (options().uf.ufHoLazyLambdaLift)
+ {
+ // if an application of the lambda lifted function, do beta reduction
+ // immediately
+ Node op = node.getOperator();
+ Node opl = d_ll.getLambdaFor(op);
+ if (!opl.isNull())
+ {
+ Assert(opl.getKind() == LAMBDA);
+ std::vector<Node> args(node.begin(), node.end());
+ Node app = d_ll.betaReduce(opl, args);
+ Trace("uf-lazy-ll")
+ << "Beta reduce: " << node << " -> " << app << std::endl;
+ return TrustNode::mkTrustRewrite(node, app, nullptr);
+ }
+ }
+ }
+ else if (k == kind::LAMBDA)
+ {
+ Trace("uf-lazy-ll") << "Preprocess lambda: " << node << std::endl;
+ TrustNode skTrn = d_ll.ppRewrite(node, lems);
+ Trace("uf-lazy-ll") << "...return " << skTrn.getNode() << std::endl;
+ return skTrn;
}
- return node;
+ return TrustNode::null();
}
Node HoExtension::getExtensionalityDeq(TNode deq, bool isCached)
@@ -217,7 +270,7 @@ unsigned HoExtension::checkExtensionality(TheoryModel* m)
{
Node eqc = (*eqcs_i);
TypeNode tn = eqc.getType();
- if (tn.isFunction())
+ if (tn.isFunction() && d_lambdaEqc.find(eqc) == d_lambdaEqc.end())
{
hasFunctions = true;
// if during collect model, must have an infinite type
@@ -413,6 +466,168 @@ unsigned HoExtension::checkAppCompletion()
return 0;
}
+unsigned HoExtension::checkLazyLambda()
+{
+ if (!options().uf.ufHoLazyLambdaLift)
+ {
+ // no lambdas are lazily lifted
+ return 0;
+ }
+ Trace("uf-ho") << "HoExtension::checkLazyLambda..." << std::endl;
+ NodeManager* nm = NodeManager::currentNM();
+ unsigned numLemmas = 0;
+ d_lambdaEqc.clear();
+ eq::EqualityEngine* ee = d_state.getEqualityEngine();
+ eq::EqClassesIterator eqcs_i = eq::EqClassesIterator(ee);
+ // normal functions equated to lambda functions
+ std::unordered_set<Node> normalEqFuns;
+ // mapping from functions to terms
+ while (!eqcs_i.isFinished())
+ {
+ Node eqc = (*eqcs_i);
+ ++eqcs_i;
+ if (!eqc.getType().isFunction())
+ {
+ continue;
+ }
+ eq::EqClassIterator eqc_i = eq::EqClassIterator(eqc, ee);
+ Node lamRep; // the first lambda function we encounter in the equivalence
+ // class
+ Node lamRepLam;
+ std::unordered_set<Node> normalEqFunWait;
+ while (!eqc_i.isFinished())
+ {
+ Node n = *eqc_i;
+ ++eqc_i;
+ Node lam = d_ll.getLambdaFor(n);
+ if (lam.isNull())
+ {
+ if (!lamRep.isNull())
+ {
+ // if we are equal to a lambda function, we must beta-reduce
+ // applications of this
+ normalEqFuns.insert(n);
+ }
+ else
+ {
+ // waiting to see if there is a lambda function in this equivalence
+ // class
+ normalEqFunWait.insert(n);
+ }
+ }
+ else if (lamRep.isNull())
+ {
+ // there is a lambda function in this equivalence class
+ lamRep = n;
+ lamRepLam = lam;
+ // must consider all normal functions we've seen so far
+ normalEqFuns.insert(normalEqFunWait.begin(), normalEqFunWait.end());
+ normalEqFunWait.clear();
+ }
+ else
+ {
+ // two lambda functions are in same equivalence class
+ Node f = lamRep < n ? lamRep : n;
+ Node g = lamRep < n ? n : lamRep;
+ Trace("uf-ho-debug") << " found equivalent lambda functions " << f
+ << " and " << g << std::endl;
+ Node flam = lamRep < n ? lamRepLam : lam;
+ Assert(!flam.isNull() && flam.getKind() == LAMBDA);
+ Node lhs = flam[1];
+ Node glam = lamRep < n ? lam : lamRepLam;
+ Trace("uf-ho-debug")
+ << " lambda are " << flam << " and " << glam << std::endl;
+ std::vector<Node> args(flam[0].begin(), flam[0].end());
+ Node rhs = d_ll.betaReduce(glam, args);
+ Node univ = nm->mkNode(FORALL, flam[0], lhs.eqNode(rhs));
+ // f = g => forall x. reduce(lambda(f)(x)) = reduce(lambda(g)(x))
+ //
+ // For example, if f -> lambda z. z+1, g -> lambda y. y+3, this
+ // will infer: f = g => forall x. x+1 = x+3, which simplifies to
+ // f != g.
+ Node lem = nm->mkNode(IMPLIES, f.eqNode(g), univ);
+ if (cacheLemma(lem))
+ {
+ d_im.lemma(lem, InferenceId::UF_HO_LAMBDA_UNIV_EQ);
+ numLemmas++;
+ }
+ }
+ }
+ if (!lamRep.isNull())
+ {
+ d_lambdaEqc[eqc] = lamRep;
+ }
+ }
+ Trace("uf-ho-debug")
+ << " found " << normalEqFuns.size()
+ << " ordinary functions that are equal to lambda functions" << std::endl;
+ if (normalEqFuns.empty())
+ {
+ return numLemmas;
+ }
+ // if we have normal functions that are equal to lambda functions, go back
+ // and ensure they are mapped properly
+ // mapping from functions to terms
+ eq::EqClassesIterator eqcs_i2 = eq::EqClassesIterator(ee);
+ while (!eqcs_i2.isFinished())
+ {
+ Node eqc = (*eqcs_i2);
+ ++eqcs_i2;
+ Trace("uf-ho-debug") << "Check equivalence class " << eqc << std::endl;
+ eq::EqClassIterator eqc_i = eq::EqClassIterator(eqc, ee);
+ while (!eqc_i.isFinished())
+ {
+ Node n = *eqc_i;
+ ++eqc_i;
+ Trace("uf-ho-debug") << "Check term " << n << std::endl;
+ Node op;
+ Kind k = n.getKind();
+ std::vector<Node> args;
+ if (k == APPLY_UF)
+ {
+ op = n.getOperator();
+ args.insert(args.end(), n.begin(), n.end());
+ }
+ else if (k == HO_APPLY)
+ {
+ op = n[0];
+ args.push_back(n[1]);
+ }
+ else
+ {
+ continue;
+ }
+ if (normalEqFuns.find(op) == normalEqFuns.end())
+ {
+ continue;
+ }
+ Trace("uf-ho-debug") << " found relevant ordinary application " << n
+ << std::endl;
+ Assert(ee->hasTerm(op));
+ Node r = ee->getRepresentative(op);
+ Assert(d_lambdaEqc.find(r) != d_lambdaEqc.end());
+ Node lf = d_lambdaEqc[r];
+ Node lam = d_ll.getLambdaFor(lf);
+ Assert(!lam.isNull() && lam.getKind() == LAMBDA);
+ // a normal function g equal to a lambda, say f --> lambda(f)
+ // need to infer f = g => g(t) = f(t) for all terms g(t)
+ // that occur in the equality engine.
+ Node premise = op.eqNode(lf);
+ args.insert(args.begin(), lam);
+ Node rhs = nm->mkNode(n.getKind(), args);
+ rhs = rewrite(rhs);
+ Node conc = n.eqNode(rhs);
+ Node lem = nm->mkNode(IMPLIES, premise, conc);
+ if (cacheLemma(lem))
+ {
+ d_im.lemma(lem, InferenceId::UF_HO_LAMBDA_APP_REDUCE);
+ numLemmas++;
+ }
+ }
+ }
+ return numLemmas;
+}
+
unsigned HoExtension::check()
{
Trace("uf-ho") << "HoExtension::checkHigherOrder..." << std::endl;
@@ -429,14 +644,24 @@ unsigned HoExtension::check()
}
} while (num_facts > 0);
- unsigned num_lemmas = 0;
-
- num_lemmas = checkExtensionality();
- if (num_lemmas > 0)
+ // Apply extensionality, lazy lambda schemas in order. We make lazy lambda
+ // handling come last as it may introduce quantifiers.
+ for (size_t i = 0; i < 2; i++)
{
- Trace("uf-ho") << "...extensionality returned " << num_lemmas << " lemmas."
- << std::endl;
- return num_lemmas;
+ unsigned num_lemmas = 0;
+ // apply the schema
+ switch (i)
+ {
+ case 0: num_lemmas = checkExtensionality(); break;
+ case 1: num_lemmas = checkLazyLambda(); break;
+ default: break;
+ }
+ // finish if we added lemmas
+ if (num_lemmas > 0)
+ {
+ Trace("uf-ho") << "...returned " << num_lemmas << " lemmas." << std::endl;
+ return num_lemmas;
+ }
}
Trace("uf-ho") << "...finished check higher order." << std::endl;
@@ -464,6 +689,16 @@ bool HoExtension::collectModelInfoHo(TheoryModel* m,
// non-standard alternative to using a type enumerator over function
// values to assign unique values.
int addedLemmas = checkExtensionality(m);
+ // for equivalence classes that we know to assign a lambda directly
+ for (const std::pair<const Node, Node>& p : d_lambdaEqc)
+ {
+ Node lam = d_ll.getLambdaFor(p.second);
+ Assert(!lam.isNull());
+ m->assertEquality(p.second, lam, true);
+ m->assertSkeleton(lam);
+ // assign it as the function definition for all variables in this class
+ m->assignFunctionDefinition(p.second, lam);
+ }
return addedLemmas == 0;
}
@@ -484,6 +719,17 @@ bool HoExtension::collectModelInfoHoTerm(Node n, TheoryModel* m)
return true;
}
+bool HoExtension::cacheLemma(TNode lem)
+{
+ Node rewritten = rewrite(lem);
+ if (d_cachedLemmas.find(rewritten) != d_cachedLemmas.end())
+ {
+ return false;
+ }
+ d_cachedLemmas.insert(rewritten);
+ return true;
+}
+
} // namespace uf
} // namespace theory
} // namespace cvc5
diff --git a/src/theory/uf/ho_extension.h b/src/theory/uf/ho_extension.h
index a646b57be..13d381622 100644
--- a/src/theory/uf/ho_extension.h
+++ b/src/theory/uf/ho_extension.h
@@ -15,14 +15,15 @@
#include "cvc5_private.h"
-#ifndef __CVC5__THEORY__UF__HO_EXTENSION_H
-#define __CVC5__THEORY__UF__HO_EXTENSION_H
+#ifndef CVC5__THEORY__UF__HO_EXTENSION_H
+#define CVC5__THEORY__UF__HO_EXTENSION_H
#include "context/cdhashmap.h"
#include "context/cdhashset.h"
#include "context/cdo.h"
#include "expr/node.h"
#include "smt/env_obj.h"
+#include "theory/skolem_lemma.h"
#include "theory/theory_inference_manager.h"
#include "theory/theory_model.h"
#include "theory/theory_state.h"
@@ -31,7 +32,7 @@ namespace cvc5 {
namespace theory {
namespace uf {
-class TheoryUF;
+class LambdaLift;
/** The higher-order extension of the theory of uninterpreted functions
*
@@ -54,7 +55,10 @@ class HoExtension : protected EnvObj
typedef context::CDHashMap<Node, Node> NodeNodeMap;
public:
- HoExtension(Env& env, TheoryState& state, TheoryInferenceManager& im);
+ HoExtension(Env& env,
+ TheoryState& state,
+ TheoryInferenceManager& im,
+ LambdaLift& ll);
/** ppRewrite
*
@@ -65,7 +69,7 @@ class HoExtension : protected EnvObj
* function variables for function heads that are not variables via the
* getApplyUfForHoApply method below.
*/
- Node ppRewrite(Node node);
+ TrustNode ppRewrite(Node node, std::vector<SkolemLemma>& lems);
/** check higher order
*
@@ -171,8 +175,20 @@ class HoExtension : protected EnvObj
/** check whether app-completion should be applied for any
* pair of terms in the equality engine.
+ *
+ * Returns the number of lemmas added on this call.
*/
unsigned checkAppCompletion();
+ /**
+ * Check lazy lambda.
+ *
+ * This assumes that lambdas are not eagerly lifted to quantified formulas.
+ * It processes two lemma schemas, UF_HO_LAMBDA_UNIV_EQ and
+ * UF_HO_LAMBDA_APP_REDUCE. For details on these, see inference_id.h.
+ *
+ * Returns the number of lemmas added on this call.
+ */
+ unsigned checkLazyLambda();
/** collect model info for higher-order term
*
* This adds required constraints to m for term n. In particular, if n is
@@ -182,24 +198,43 @@ class HoExtension : protected EnvObj
bool collectModelInfoHoTerm(Node n, TheoryModel* m);
private:
+ /** Cache lemma lem, return true if it does not already exist */
+ bool cacheLemma(TNode lem);
/** common constants */
Node d_true;
/** Reference to the state object */
TheoryState& d_state;
/** Reference to the inference manager */
TheoryInferenceManager& d_im;
+ /** Lambda lifting utility */
+ LambdaLift& d_ll;
/** extensionality has been applied to these disequalities */
NodeSet d_extensionality;
+ /**
+ * The lemmas we have sent. This is required since the UF inference manager
+ * does not cache lemmas.
+ */
+ NodeSet d_cachedLemmas;
+ /**
+ * In the following, we say that a "lambda function" is a variable k that was
+ * introduced by the lambda lifting utility, and has a corresponding lambda
+ * definition.
+ *
+ * This maps equivalence class representatives that have lambda functions in
+ * them to one such lambda function. This map is computed at each full effort
+ * and valid only during collectModelInfoHo.
+ */
+ std::unordered_map<Node, Node> d_lambdaEqc;
/** cache of getExtensionalityDeq below */
std::map<Node, Node> d_extensionality_deq;
/** map from non-standard operators to their skolems */
NodeNodeMap d_uf_std_skolem;
-}; /* class TheoryUF */
+};
} // namespace uf
} // namespace theory
} // namespace cvc5
-#endif /* __CVC5__THEORY__UF__HO_EXTENSION_H */
+#endif
diff --git a/src/theory/uf/kinds b/src/theory/uf/kinds
index a1db5120f..252020b88 100644
--- a/src/theory/uf/kinds
+++ b/src/theory/uf/kinds
@@ -33,8 +33,6 @@ typerule LAMBDA ::cvc5::theory::uf::LambdaTypeRule
variable BOOLEAN_TERM_VARIABLE "Boolean term variable"
-variable LAMBDA_VARIABLE "Lambda variable, used for lazy lambda lifting"
-
# lambda expressions that are isomorphic to array constants can be considered constants
construle LAMBDA ::cvc5::theory::uf::LambdaTypeRule
diff --git a/src/theory/uf/lambda_lift.cpp b/src/theory/uf/lambda_lift.cpp
index 3d51e6858..605e346af 100644
--- a/src/theory/uf/lambda_lift.cpp
+++ b/src/theory/uf/lambda_lift.cpp
@@ -90,6 +90,11 @@ Node LambdaLift::getLambdaFor(TNode skolem) const
return it->second;
}
+bool LambdaLift::isLambdaFunction(TNode n) const
+{
+ return !getLambdaFor(n).isNull();
+}
+
Node LambdaLift::getAssertionFor(TNode node)
{
TNode skolem = getSkolemFor(node);
diff --git a/src/theory/uf/lambda_lift.h b/src/theory/uf/lambda_lift.h
index f61007d1c..1e36dad31 100644
--- a/src/theory/uf/lambda_lift.h
+++ b/src/theory/uf/lambda_lift.h
@@ -60,6 +60,8 @@ class LambdaLift : protected EnvObj
/** Get the lambda term for skolem, if skolem is a lambda function. */
Node getLambdaFor(TNode skolem) const;
+ /** Is skolem a lambda function? */
+ bool isLambdaFunction(TNode n) const;
/**
* Beta-reduce node. If node is APPLY_UF and its operator is a lambda
diff --git a/src/theory/uf/theory_uf.cpp b/src/theory/uf/theory_uf.cpp
index 5c9446507..b6d789773 100644
--- a/src/theory/uf/theory_uf.cpp
+++ b/src/theory/uf/theory_uf.cpp
@@ -21,6 +21,7 @@
#include <sstream>
#include "expr/node_algorithm.h"
+#include "expr/skolem_manager.h"
#include "options/quantifiers_options.h"
#include "options/smt_options.h"
#include "options/theory_options.h"
@@ -31,6 +32,7 @@
#include "theory/type_enumerator.h"
#include "theory/uf/cardinality_extension.h"
#include "theory/uf/ho_extension.h"
+#include "theory/uf/lambda_lift.h"
#include "theory/uf/theory_uf_rewriter.h"
using namespace std;
@@ -46,6 +48,7 @@ TheoryUF::TheoryUF(Env& env,
std::string instanceName)
: Theory(THEORY_UF, env, out, valuation, instanceName),
d_thss(nullptr),
+ d_lambdaLift(new LambdaLift(env)),
d_ho(nullptr),
d_functionsTerms(context()),
d_symb(env, instanceName),
@@ -100,7 +103,7 @@ void TheoryUF::finishInit() {
if (isHo)
{
d_equalityEngine->addFunctionKind(kind::HO_APPLY);
- d_ho.reset(new HoExtension(d_env, d_state, d_im));
+ d_ho.reset(new HoExtension(d_env, d_state, d_im, *d_lambdaLift.get()));
}
}
@@ -212,38 +215,41 @@ TrustNode TheoryUF::ppRewrite(TNode node, std::vector<SkolemLemma>& lems)
Trace("uf-exp-def") << "TheoryUF::ppRewrite: expanding definition : " << node
<< std::endl;
Kind k = node.getKind();
+ bool isHol = logicInfo().isHigherOrder();
if (k == kind::HO_APPLY || (node.isVar() && node.getType().isFunction()))
{
- if (!logicInfo().isHigherOrder())
+ if (!isHol)
{
std::stringstream ss;
ss << "Partial function applications are only supported with "
"higher-order logic. Try adding the logic prefix HO_.";
throw LogicException(ss.str());
}
- Node ret = d_ho->ppRewrite(node);
- if (ret != node)
- {
- Trace("uf-exp-def") << "TheoryUF::ppRewrite: higher-order: " << node
- << " to " << ret << std::endl;
- return TrustNode::mkTrustRewrite(node, ret, nullptr);
- }
}
else if (k == kind::APPLY_UF)
{
- // check for higher-order
- // logic exception if higher-order is not enabled
- if (isHigherOrderType(node.getOperator().getType())
- && !logicInfo().isHigherOrder())
+ if (!isHol && isHigherOrderType(node.getOperator().getType()))
{
+ // check for higher-order
+ // logic exception if higher-order is not enabled
std::stringstream ss;
ss << "UF received an application whose operator has higher-order type "
<< node
- << ", which is only supported with higher-order logic. Try adding the "
- "logic prefix HO_.";
+ << ", which is only supported with higher-order logic. Try adding "
+ "the logic prefix HO_.";
throw LogicException(ss.str());
}
}
+ if (isHol)
+ {
+ TrustNode ret = d_ho->ppRewrite(node, lems);
+ if (!ret.isNull())
+ {
+ Trace("uf-exp-def") << "TheoryUF::ppRewrite: higher-order: " << node
+ << " to " << ret.getNode() << std::endl;
+ return ret;
+ }
+ }
return TrustNode::null();
}
@@ -308,6 +314,18 @@ void TheoryUF::preRegisterTerm(TNode node)
d_equalityEngine->addTerm(node);
break;
}
+
+ if (logicInfo().isHigherOrder())
+ {
+ // When using lazy lambda handling, if node is a lambda function, it must
+ // be marked as a shared term. This is to ensure we split on the equality
+ // of lambda functions with other functions when doing care graph
+ // based theory combination.
+ if (d_lambdaLift->isLambdaFunction(node))
+ {
+ addSharedTerm(node);
+ }
+ }
}
void TheoryUF::explain(TNode literal, Node& exp)
@@ -523,7 +541,20 @@ bool TheoryUF::areCareDisequal(TNode x, TNode y)
TNode y_shared =
d_equalityEngine->getTriggerTermRepresentative(y, THEORY_UF);
EqualityStatus eqStatus = d_valuation.getEqualityStatus(x_shared, y_shared);
- if( eqStatus==EQUALITY_FALSE_AND_PROPAGATED || eqStatus==EQUALITY_FALSE || eqStatus==EQUALITY_FALSE_IN_MODEL ){
+ if (eqStatus == EQUALITY_FALSE || eqStatus == EQUALITY_FALSE_AND_PROPAGATED)
+ {
+ return true;
+ }
+ else if (eqStatus == EQUALITY_FALSE_IN_MODEL)
+ {
+ // if x or y is a lambda function, and they are neither entailed to
+ // be equal or disequal, then we return false. This ensures the pair
+ // (x,y) may be considered for the care graph.
+ if (d_lambdaLift->isLambdaFunction(x)
+ || d_lambdaLift->isLambdaFunction(y))
+ {
+ return false;
+ }
return true;
}
}
diff --git a/src/theory/uf/theory_uf.h b/src/theory/uf/theory_uf.h
index 6f04035ed..b72262164 100644
--- a/src/theory/uf/theory_uf.h
+++ b/src/theory/uf/theory_uf.h
@@ -35,6 +35,7 @@ namespace uf {
class CardinalityExtension;
class HoExtension;
+class LambdaLift;
class TheoryUF : public Theory {
public:
@@ -74,6 +75,8 @@ class TheoryUF : public Theory {
private:
/** The associated cardinality extension (or nullptr if it does not exist) */
std::unique_ptr<CardinalityExtension> d_thss;
+ /** the lambda lifting utility */
+ std::unique_ptr<LambdaLift> d_lambdaLift;
/** the higher-order solver extension (or nullptr if it does not exist) */
std::unique_ptr<HoExtension> d_ho;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d3ff709ca..5f96d2b9b 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -41,8 +41,3 @@ add_subdirectory(api EXCLUDE_FROM_ALL)
if(ENABLE_UNIT_TESTING)
add_subdirectory(unit EXCLUDE_FROM_ALL)
endif()
-
-# add Python bindings tests if building with Python bindings
-if (BUILD_BINDINGS_PYTHON)
- add_subdirectory(python)
-endif()
diff --git a/test/python/CMakeLists.txt b/test/python/CMakeLists.txt
deleted file mode 100644
index 5b681ca36..000000000
--- a/test/python/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-###############################################################################
-# Top contributors (to current version):
-# Yoni Zohar, Aina Niemetz, Mathias Preiner
-#
-# 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.
-# #############################################################################
-#
-# The build system configuration.
-##
-
-# Check if the pytest Python module is installed.
-check_python_module("pytest")
-
-# Add Python bindings API tests.
-macro(cvc5_add_python_api_test name filename)
-# We create test target 'python/unit/api/myapitest' and run it with
-# 'ctest -R "python/unit/api/myapitest"'.
-add_test (NAME python/unit/api/${name}
- COMMAND ${PYTHON_EXECUTABLE} -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
- # directory for importing the python bindings
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/api/python)
-endmacro()
-
-# add specific test files
-cvc5_add_python_api_test(pytest_solver unit/api/test_solver.py)
-cvc5_add_python_api_test(pytest_sort unit/api/test_sort.py)
-cvc5_add_python_api_test(pytest_term unit/api/test_term.py)
-cvc5_add_python_api_test(pytest_datatype_api unit/api/test_datatype_api.py)
-cvc5_add_python_api_test(pytest_grammar unit/api/test_grammar.py)
-cvc5_add_python_api_test(pytest_to_python_obj unit/api/test_to_python_obj.py)
-cvc5_add_python_api_test(pytest_op unit/api/test_op.py)
-cvc5_add_python_api_test(pytest_result unit/api/test_result.py)
diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt
index b08b2f6f5..bffb3e8cb 100644
--- a/test/regress/CMakeLists.txt
+++ b/test/regress/CMakeLists.txt
@@ -109,6 +109,7 @@ set(regress_0_tests
regress0/arrays/issue3813-massign-assert.smt2
regress0/arrays/issue3814.smt2
regress0/arrays/issue4927-unsat-cores.smt2
+ regress0/arrays/issue7596-define-array-uminus.smt2
regress0/arrays/swap_t1_np_nf_ai_00005_007.cvc.smtv1.smt2
regress0/arrays/x2.smtv1.smt2
regress0/arrays/x3.smtv1.smt2
@@ -659,11 +660,14 @@ set(regress_0_tests
regress0/ho/issue6536.smt2
regress0/ho/ite-apply-eq.smt2
regress0/ho/lambda-equality-non-canon.smt2
+ regress0/ho/lazy-lambda-model.smt2
regress0/ho/match-middle.smt2
regress0/ho/modulo-func-equality.smt2
regress0/ho/qgu-fuzz-ho-1-dd.smt2
regress0/ho/qgu-fuzz-ho-2-dd-no-ext.smt2
regress0/ho/shadowing-defs.smt2
+ regress0/ho/simple-conf-lazy-lambda-lift.smt2
+ regress0/ho/simple-conf-lazy-lambda-lift-app.smt2
regress0/ho/simple-matching-partial.smt2
regress0/ho/simple-matching.smt2
regress0/ho/trans.smt2
@@ -1083,6 +1087,7 @@ set(regress_0_tests
regress0/seq/issue5665-invalid-model.smt2
regress0/seq/issue6337-seq.smt2
regress0/seq/len_simplify.smt2
+ regress0/seq/proj-issue340.smt2
regress0/seq/seq-2var.smt2
regress0/seq/seq-ex1.smt2
regress0/seq/seq-ex2.smt2
@@ -1599,9 +1604,11 @@ set(regress_1_tests
regress1/bags/fuzzy3.smt2
regress1/bags/fuzzy4.smt2
regress1/bags/fuzzy5.smt2
+ regress1/bags/fuzzy6.smt2
regress1/bags/intersection_min1.smt2
regress1/bags/intersection_min2.smt2
regress1/bags/issue5759.smt2
+ regress1/bags/map-lazy-lam.smt2
regress1/bags/map1.smt2
regress1/bags/map2.smt2
regress1/bags/map3.smt2
@@ -1726,8 +1733,10 @@ set(regress_1_tests
regress1/fmf/with-ind-104-core.smt2
regress1/gensys_brn001.smt2
regress1/ho/bug_freeVar_BDD_General_data_270.p
+ regress1/ho/bug_freevar_PHI004^4-delta.smt2
regress1/ho/bound_var_bug.p
regress1/ho/fta0328.lfho.p
+ regress1/ho/ho-fun-sharing-dd.smt2
regress1/ho/issue3136-fconst-bool-bool.smt2
regress1/ho/issue4065-no-rep.smt2
regress1/ho/issue4092-sinf.smt2
@@ -2803,8 +2812,6 @@ set(regression_disabled_tests
###
regress1/bug472.smt2
regress1/datatypes/non-simple-rec-set.smt2
- # disabled temporarily until lazy lambda handling is merged
- regress1/ho/bug_freevar_PHI004^4-delta.smt2
# results in an assertion failure (see issue #1650).
regress1/ho/hoa0102.smt2
# after disallowing solving for terms with quantifiers
diff --git a/test/regress/regress0/arrays/issue7596-define-array-uminus.smt2 b/test/regress/regress0/arrays/issue7596-define-array-uminus.smt2
new file mode 100644
index 000000000..da21db28e
--- /dev/null
+++ b/test/regress/regress0/arrays/issue7596-define-array-uminus.smt2
@@ -0,0 +1,5 @@
+(set-logic ALL)
+(set-info :status sat)
+(define-fun foo () (Array Int Int) ((as const (Array Int Int)) (- 1)))
+(assert (= (select foo 0) (- 1)))
+(check-sat)
diff --git a/test/regress/regress0/ho/lazy-lambda-model.smt2 b/test/regress/regress0/ho/lazy-lambda-model.smt2
new file mode 100644
index 000000000..71df017e9
--- /dev/null
+++ b/test/regress/regress0/ho/lazy-lambda-model.smt2
@@ -0,0 +1,16 @@
+; COMMAND-LINE: --uf-lazy-ll
+; EXPECT: sat
+(set-logic HO_ALL)
+(declare-fun g (Int) Int)
+(declare-fun h (Int) Int)
+(define-fun f ((x Int)) Int (ite (> x 0) (* 2 x) x))
+
+(declare-fun a () Int)
+(declare-fun b () Int)
+
+
+(assert (or (= f g) (= f h)))
+
+(assert (and (= (h a) 26) (= (g b) 26)))
+
+(check-sat)
diff --git a/test/regress/regress0/ho/simple-conf-lazy-lambda-lift-app.smt2 b/test/regress/regress0/ho/simple-conf-lazy-lambda-lift-app.smt2
new file mode 100644
index 000000000..ab949c40c
--- /dev/null
+++ b/test/regress/regress0/ho/simple-conf-lazy-lambda-lift-app.smt2
@@ -0,0 +1,14 @@
+; COMMAND-LINE: --uf-lazy-ll
+; EXPECT: unsat
+(set-logic HO_ALL)
+(set-info :status unsat)
+(define-fun f ((x Int)) Int (+ x 1))
+(declare-fun g (Int) Int)
+(declare-fun h (Int) Int)
+
+(assert (or (= f g) (= f h)))
+
+(assert (= (g 4) 0))
+(assert (= (h 4) 8))
+
+(check-sat)
diff --git a/test/regress/regress0/ho/simple-conf-lazy-lambda-lift.smt2 b/test/regress/regress0/ho/simple-conf-lazy-lambda-lift.smt2
new file mode 100644
index 000000000..d11a4418b
--- /dev/null
+++ b/test/regress/regress0/ho/simple-conf-lazy-lambda-lift.smt2
@@ -0,0 +1,11 @@
+; COMMAND-LINE: --uf-lazy-ll
+; EXPECT: unsat
+(set-logic HO_ALL)
+(set-info :status unsat)
+(define-fun f ((x Int)) Int (+ x 1))
+(define-fun g ((x Int)) Int (+ x 2))
+(define-fun h ((x Int)) Int 6)
+
+(assert (or (= f g) (= f h)))
+
+(check-sat)
diff --git a/test/regress/regress0/rels/addr_book_0.cvc.smt2 b/test/regress/regress0/rels/addr_book_0.cvc.smt2
index 70488b4eb..9bc85f268 100644
--- a/test/regress/regress0/rels/addr_book_0.cvc.smt2
+++ b/test/regress/regress0/rels/addr_book_0.cvc.smt2
@@ -33,7 +33,7 @@
(assert (set.member t_tup Target))
(assert (set.subset (rel.join (rel.join Book addr) Target) Name))
(assert (set.subset (rel.join Book names) Name))
-(assert (= (set.intersection Name Addr) (as set.empty (Set (Tuple Atom)))))
+(assert (= (set.inter Name Addr) (as set.empty (Set (Tuple Atom)))))
(assert (= (rel.join (set.singleton n_tup) (rel.join (set.singleton b1_tup) addr)) (as set.empty (Set (Tuple Atom)))))
(assert (let ((_let_1 (set.singleton n_tup))) (= (rel.join _let_1 (rel.join (set.singleton b2_tup) addr)) (set.union (rel.join _let_1 (rel.join (set.singleton b1_tup) addr)) (set.singleton t_tup)))))
(assert (let ((_let_1 (set.singleton n_tup))) (= (rel.join _let_1 (rel.join (set.singleton b3_tup) addr)) (set.minus (rel.join _let_1 (rel.join (set.singleton b2_tup) addr)) (set.singleton t_tup)))))
diff --git a/test/regress/regress0/rels/iden_0.cvc.smt2 b/test/regress/regress0/rels/iden_0.cvc.smt2
index 1cdeffbff..75dc80d22 100644
--- a/test/regress/regress0/rels/iden_0.cvc.smt2
+++ b/test/regress/regress0/rels/iden_0.cvc.smt2
@@ -21,5 +21,5 @@
(assert (set.member v x))
(assert (set.member a x))
(assert (= id (rel.iden t)))
-(assert (not (set.member (tuple 1 1) (set.intersection id x))))
+(assert (not (set.member (tuple 1 1) (set.inter id x))))
(check-sat)
diff --git a/test/regress/regress0/seq/proj-issue340.smt2 b/test/regress/regress0/seq/proj-issue340.smt2
new file mode 100644
index 000000000..75a4fb3a6
--- /dev/null
+++ b/test/regress/regress0/seq/proj-issue340.smt2
@@ -0,0 +1,9 @@
+(set-logic QF_SLIA)
+(declare-const x0 Bool)
+(declare-const x2 (Seq Bool))
+(declare-const i Int)
+(assert (= i (str.to_int (str.from_code (seq.len x2)))))
+(assert (not (seq.nth x2 i)))
+(assert (>= i 0))
+(set-info :status sat)
+(check-sat)
diff --git a/test/regress/regress0/sets/complement3.cvc.smt2 b/test/regress/regress0/sets/complement3.cvc.smt2
index 20cfb36f8..2046b2fc9 100644
--- a/test/regress/regress0/sets/complement3.cvc.smt2
+++ b/test/regress/regress0/sets/complement3.cvc.smt2
@@ -8,7 +8,7 @@
(declare-fun C4 () (Set (Tuple Atom)))
(declare-fun ATOM_UNIV () (Set (Tuple Atom)))
(declare-fun V1 () Atom)
-(assert (= C32 (set.intersection (set.complement C2) (set.complement C4))))
+(assert (= C32 (set.inter (set.complement C2) (set.complement C4))))
(assert (set.member (tuple V1) (set.complement C32)))
(assert (= ATOM_UNIV (as set.universe (Set (Tuple Atom)))))
(assert (set.member (tuple V1) ATOM_UNIV))
diff --git a/test/regress/regress0/sets/cvc-sample.cvc.smt2 b/test/regress/regress0/sets/cvc-sample.cvc.smt2
index 9ee199b43..9c89df0c6 100644
--- a/test/regress/regress0/sets/cvc-sample.cvc.smt2
+++ b/test/regress/regress0/sets/cvc-sample.cvc.smt2
@@ -20,12 +20,12 @@
(declare-fun e () Int)
(assert (= a (set.singleton 5)))
(assert (= c (set.union a b)))
-(assert (not (= c (set.intersection a b))))
+(assert (not (= c (set.inter a b))))
(assert (= c (set.minus a b)))
(assert (set.subset a b))
(assert (set.member e c))
(assert (set.member e a))
-(assert (set.member e (set.intersection a b)))
+(assert (set.member e (set.inter a b)))
(push 1)
(assert true)
diff --git a/test/regress/regress0/sets/eqtest.smt2 b/test/regress/regress0/sets/eqtest.smt2
index 0ecd32bf8..c93b18857 100644
--- a/test/regress/regress0/sets/eqtest.smt2
+++ b/test/regress/regress0/sets/eqtest.smt2
@@ -10,9 +10,9 @@
(declare-fun H () (Set Int) )
(declare-fun I () (Set Int) )
(declare-fun x () Int)
-(assert (set.member x (set.intersection (set.union A B) C)))
+(assert (set.member x (set.inter (set.union A B) C)))
(assert (not (set.member x G)))
(assert (= (set.union A B) D))
-(assert (= C (set.intersection E F)))
+(assert (= C (set.inter E F)))
(assert (and (= F H) (= G H) (= H I)))
(check-sat)
diff --git a/test/regress/regress0/sets/jan24/deepmeas0.hs.fqout.cvc4.47.smt2 b/test/regress/regress0/sets/jan24/deepmeas0.hs.fqout.cvc4.47.smt2
index 7e2f627ae..76592a691 100644
--- a/test/regress/regress0/sets/jan24/deepmeas0.hs.fqout.cvc4.47.smt2
+++ b/test/regress/regress0/sets/jan24/deepmeas0.hs.fqout.cvc4.47.smt2
@@ -6,7 +6,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
diff --git a/test/regress/regress0/sets/jan27/ListConcat.hs.fqout.cvc4.177.smt2 b/test/regress/regress0/sets/jan27/ListConcat.hs.fqout.cvc4.177.smt2
index f6fd4bd53..b0172db39 100644
--- a/test/regress/regress0/sets/jan27/ListConcat.hs.fqout.cvc4.177.smt2
+++ b/test/regress/regress0/sets/jan27/ListConcat.hs.fqout.cvc4.177.smt2
@@ -6,7 +6,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
;(define-fun smt_set_com ((s mySet)) mySet ((_ map not) s))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
;(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (= smt_set_emp (smt_set_dif s1 s2)))
diff --git a/test/regress/regress0/sets/rec_copy_loop_check_heap_access_43_4.smt2 b/test/regress/regress0/sets/rec_copy_loop_check_heap_access_43_4.smt2
index f70d59b16..1538a2e9f 100644
--- a/test/regress/regress0/sets/rec_copy_loop_check_heap_access_43_4.smt2
+++ b/test/regress/regress0/sets/rec_copy_loop_check_heap_access_43_4.smt2
@@ -66,7 +66,7 @@
(assert (! (= sk_?X_36$0 FP$0) :named precondition_of_rec_copy_loop_34_11_18))
-(assert (! (= (as set.empty SetLoc) (set.intersection sk_?X_38$0 sk_?X_37$0))
+(assert (! (= (as set.empty SetLoc) (set.inter sk_?X_38$0 sk_?X_37$0))
:named precondition_of_rec_copy_loop_34_11_19))
(assert (! (= old_cp_2$0 cp$0) :named assign_41_4))
diff --git a/test/regress/regress0/sets/sets-inter.smt2 b/test/regress/regress0/sets/sets-inter.smt2
index 6857e5147..66f843c9d 100644
--- a/test/regress/regress0/sets/sets-inter.smt2
+++ b/test/regress/regress0/sets/sets-inter.smt2
@@ -5,7 +5,7 @@
(declare-fun b () (Set Int))
(declare-fun x () Int)
;(assert (not (set.member x a)))
-(assert (set.member x (set.intersection a b)))
+(assert (set.member x (set.inter a b)))
(assert (not (set.member x b)))
(check-sat)
(exit)
diff --git a/test/regress/regress0/sets/sets-new.smt2 b/test/regress/regress0/sets/sets-new.smt2
index 4a49bef07..0020e5c55 100644
--- a/test/regress/regress0/sets/sets-new.smt2
+++ b/test/regress/regress0/sets/sets-new.smt2
@@ -8,7 +8,7 @@
(declare-fun x () Int)
(assert (set.member x (set.union A B)))
-(assert (not (set.member x (set.intersection A B))))
+(assert (not (set.member x (set.inter A B))))
(assert (not (set.member x (set.minus A B))))
;(assert (not (set.member x (set.minus B A))))
;(assert (set.member x B))
diff --git a/test/regress/regress0/sets/sets-poly-int-real.smt2 b/test/regress/regress0/sets/sets-poly-int-real.smt2
index 20832c573..00546eee2 100644
--- a/test/regress/regress0/sets/sets-poly-int-real.smt2
+++ b/test/regress/regress0/sets/sets-poly-int-real.smt2
@@ -11,7 +11,7 @@
(assert (= t1 (set.union s (set.singleton 2.5))))
(assert (= t2 (set.union s (set.singleton 2.0))))
(assert (= t3 (set.union r3 (set.singleton 2.5))))
-(assert (= (set.intersection r1 r2) (set.intersection s (set.singleton 0.0))))
+(assert (= (set.inter r1 r2) (set.inter s (set.singleton 0.0))))
(assert (not (= r1 (as set.empty (Set Real)))))
(check-sat)
diff --git a/test/regress/regress0/sets/sets-sample.smt2 b/test/regress/regress0/sets/sets-sample.smt2
index 3dcafae08..4a11bcc78 100644
--- a/test/regress/regress0/sets/sets-sample.smt2
+++ b/test/regress/regress0/sets/sets-sample.smt2
@@ -15,12 +15,12 @@
(declare-fun e () Int)
(assert (= a (set.singleton 5)))
(assert (= c (set.union a b) ))
-(assert (not (= c (set.intersection a b) )))
+(assert (not (= c (set.inter a b) )))
(assert (= c (set.minus a b) ))
(assert (set.subset a b))
(assert (set.member e c))
(assert (set.member e a))
-(assert (set.member e (set.intersection a b)))
+(assert (set.member e (set.inter a b)))
(check-sat)
(pop 1)
diff --git a/test/regress/regress0/sets/sharing-simp.smt2 b/test/regress/regress0/sets/sharing-simp.smt2
index be746be1d..a591792cf 100644
--- a/test/regress/regress0/sets/sharing-simp.smt2
+++ b/test/regress/regress0/sets/sharing-simp.smt2
@@ -9,7 +9,7 @@
(assert (set.member x A))
(assert (set.member y B))
-(assert (or (= C (set.intersection A B)) (= D (set.intersection A B))))
+(assert (or (= C (set.inter A B)) (= D (set.inter A B))))
(check-sat)
diff --git a/test/regress/regress1/bags/choose1.smt2 b/test/regress/regress1/bags/choose1.smt2
index b157bbc70..53cd7c771 100644
--- a/test/regress/regress1/bags/choose1.smt2
+++ b/test/regress/regress1/bags/choose1.smt2
@@ -3,7 +3,7 @@
(set-info :status sat)
(declare-fun A () (Bag Int))
(declare-fun a () Int)
-(assert (not (= A (as emptybag (Bag Int)))))
+(assert (not (= A (as bag.empty (Bag Int)))))
(assert (= (bag.choose A) 10))
(assert (= a (bag.choose A)))
(assert (exists ((x Int)) (and (= x (bag.choose A)) (= x a))))
diff --git a/test/regress/regress1/bags/choose3.smt2 b/test/regress/regress1/bags/choose3.smt2
index ffa9ae9a7..adf1a3e21 100644
--- a/test/regress/regress1/bags/choose3.smt2
+++ b/test/regress/regress1/bags/choose3.smt2
@@ -4,5 +4,5 @@
(set-info :status sat)
(declare-fun A () (Bag Int))
(assert (= (bag.choose A) 10))
-(assert (= A (as emptybag (Bag Int))))
+(assert (= A (as bag.empty (Bag Int))))
(check-sat)
diff --git a/test/regress/regress1/bags/choose4.smt2 b/test/regress/regress1/bags/choose4.smt2
index a0290b90b..cdf4065d4 100644
--- a/test/regress/regress1/bags/choose4.smt2
+++ b/test/regress/regress1/bags/choose4.smt2
@@ -3,7 +3,7 @@
(set-info :status sat)
(declare-fun A () (Bag Int))
(declare-fun a () Int)
-(assert (not (= A (as emptybag (Bag Int)))))
+(assert (not (= A (as bag.empty (Bag Int)))))
(assert (> (bag.count 10 A) 0))
(assert (= a (bag.choose A)))
(check-sat)
diff --git a/test/regress/regress1/bags/difference_remove1.smt2 b/test/regress/regress1/bags/difference_remove1.smt2
index f5a87c149..82f6ec53d 100644
--- a/test/regress/regress1/bags/difference_remove1.smt2
+++ b/test/regress/regress1/bags/difference_remove1.smt2
@@ -4,7 +4,7 @@
(declare-fun B () (Bag Int))
(declare-fun x () Int)
(declare-fun y () Int)
-(assert (= A (union_max (bag x 1) (bag y 2))))
-(assert (= A (union_disjoint B (bag y 2))))
+(assert (= A (bag.union_max (bag x 1) (bag y 2))))
+(assert (= A (bag.union_disjoint B (bag y 2))))
(assert (= x y))
(check-sat)
diff --git a/test/regress/regress1/bags/duplicate_removal1.smt2 b/test/regress/regress1/bags/duplicate_removal1.smt2
index 2b662c6e5..27ce2360b 100644
--- a/test/regress/regress1/bags/duplicate_removal1.smt2
+++ b/test/regress/regress1/bags/duplicate_removal1.smt2
@@ -3,6 +3,6 @@
(set-option :produce-models true)
(declare-fun A () (Bag String))
(declare-fun B () (Bag String))
-(assert (= B (duplicate_removal A)))
-(assert (distinct (as emptybag (Bag String)) A B))
+(assert (= B (bag.duplicate_removal A)))
+(assert (distinct (as bag.empty (Bag String)) A B))
(check-sat)
diff --git a/test/regress/regress1/bags/duplicate_removal2.smt2 b/test/regress/regress1/bags/duplicate_removal2.smt2
index 7dacaae43..5382f773f 100644
--- a/test/regress/regress1/bags/duplicate_removal2.smt2
+++ b/test/regress/regress1/bags/duplicate_removal2.smt2
@@ -2,7 +2,7 @@
(set-info :status unsat)
(declare-fun A () (Bag String))
(declare-fun B () (Bag String))
-(assert (= B (duplicate_removal A)))
-(assert (distinct (as emptybag (Bag String)) A B))
-(assert (= B (union_max A B)))
+(assert (= B (bag.duplicate_removal A)))
+(assert (distinct (as bag.empty (Bag String)) A B))
+(assert (= B (bag.union_max A B)))
(check-sat) \ No newline at end of file
diff --git a/test/regress/regress1/bags/emptybag1.smt2 b/test/regress/regress1/bags/emptybag1.smt2
index f7f92599d..61b29f414 100644
--- a/test/regress/regress1/bags/emptybag1.smt2
+++ b/test/regress/regress1/bags/emptybag1.smt2
@@ -4,7 +4,7 @@
(declare-fun x () String)
(declare-fun y () Int)
(assert (= x "x"))
-(assert (= A (as emptybag (Bag String))))
+(assert (= A (as bag.empty (Bag String))))
(assert (= (bag.count x A) y))
(assert(> y 1))
(check-sat)
diff --git a/test/regress/regress1/bags/fuzzy1.smt2 b/test/regress/regress1/bags/fuzzy1.smt2
index f9fee0ec4..79ccc4b82 100644
--- a/test/regress/regress1/bags/fuzzy1.smt2
+++ b/test/regress/regress1/bags/fuzzy1.smt2
@@ -5,6 +5,6 @@
(declare-fun c () Int) ; c here is zero
(assert
(and
- (= b (difference_subtract b a)) ; b is empty
+ (= b (bag.difference_subtract b a)) ; b is empty
(= a (bag (tuple c 0) 1)))) ; a = {|(<0, 0>, 1)|}
(check-sat)
diff --git a/test/regress/regress1/bags/fuzzy2.smt2 b/test/regress/regress1/bags/fuzzy2.smt2
index 31da47f53..c7968b274 100644
--- a/test/regress/regress1/bags/fuzzy2.smt2
+++ b/test/regress/regress1/bags/fuzzy2.smt2
@@ -8,8 +8,8 @@
(let ((D (bag d c))) ; when c = zero, then D is empty
(and
(= a (bag (tuple 1 1) c)) ; when c = zero, then a is empty
- (= a (union_max a D))
- (= a (difference_subtract a (bag d 1)))
- (= a (union_disjoint a D))
- (= a (intersection_min a D)))))
+ (= a (bag.union_max a D))
+ (= a (bag.difference_subtract a (bag d 1)))
+ (= a (bag.union_disjoint a D))
+ (= a (bag.inter_min a D)))))
(check-sat)
diff --git a/test/regress/regress1/bags/fuzzy3.smt2 b/test/regress/regress1/bags/fuzzy3.smt2
index dd6dd02dc..a457bf9ae 100644
--- a/test/regress/regress1/bags/fuzzy3.smt2
+++ b/test/regress/regress1/bags/fuzzy3.smt2
@@ -8,6 +8,6 @@
(assert
(not
(=
- (= A (difference_remove (bag d c) A))
+ (= A (bag.difference_remove (bag d c) A))
(= A (bag (tuple c c) c)))))
(check-sat)
diff --git a/test/regress/regress1/bags/fuzzy4.smt2 b/test/regress/regress1/bags/fuzzy4.smt2
index b733a4862..5b24b8d6e 100644
--- a/test/regress/regress1/bags/fuzzy4.smt2
+++ b/test/regress/regress1/bags/fuzzy4.smt2
@@ -7,8 +7,8 @@
(assert
(not
(=
- (= A (bag d (+ c (bag.count d (union_disjoint A A)))))
- (= A (difference_remove (bag d c) A)))))
+ (= A (bag d (+ c (bag.count d (bag.union_disjoint A A)))))
+ (= A (bag.difference_remove (bag d c) A)))))
(assert (= A (bag (tuple 0 0) 5)))
(assert (= c (- 5)))
(assert (= d (tuple 0 0)))
diff --git a/test/regress/regress1/bags/fuzzy5.smt2 b/test/regress/regress1/bags/fuzzy5.smt2
index 2dea236a5..0674fad9c 100644
--- a/test/regress/regress1/bags/fuzzy5.smt2
+++ b/test/regress/regress1/bags/fuzzy5.smt2
@@ -10,7 +10,7 @@
(and
(not
(= (= A (bag (tuple 0 c) (+ c c)))
- (= A (difference_remove (bag d c) A))))
+ (= A (bag.difference_remove (bag d c) A))))
(not
(= (= A (bag (tuple 0 1) c_plus_1))
(= A (bag (tuple c 1) c_plus_1)))))))
diff --git a/test/regress/regress1/bags/fuzzy6.smt2 b/test/regress/regress1/bags/fuzzy6.smt2
new file mode 100644
index 000000000..2bcc024dd
--- /dev/null
+++ b/test/regress/regress1/bags/fuzzy6.smt2
@@ -0,0 +1,13 @@
+(set-logic ALL)
+(set-info :status sat)
+(set-option :produce-models true)
+(declare-fun A () (Bag (Tuple Int Int)))
+(declare-fun c () Int)
+(declare-fun d () (Tuple Int Int))
+(assert
+ (let ((double_c (+ c c)))
+ (let ((formula (= A (bag (tuple c double_c) c))))
+ (and (not (= formula (= A (bag (tuple c c) c))))
+ (not (= formula (= A (bag (tuple 0 c) double_c))))))))
+
+(check-sat)
diff --git a/test/regress/regress1/bags/intersection_min1.smt2 b/test/regress/regress1/bags/intersection_min1.smt2
index f5a515b9c..0ced4aa89 100644
--- a/test/regress/regress1/bags/intersection_min1.smt2
+++ b/test/regress/regress1/bags/intersection_min1.smt2
@@ -4,7 +4,7 @@
(declare-fun A () (Bag String))
(declare-fun B () (Bag String))
(declare-fun C () (Bag String))
-(assert (= C (intersection_min A B)))
-(assert (distinct (as emptybag (Bag String)) C))
+(assert (= C (bag.inter_min A B)))
+(assert (distinct (as bag.empty (Bag String)) C))
(assert (distinct A B C))
(check-sat) \ No newline at end of file
diff --git a/test/regress/regress1/bags/intersection_min2.smt2 b/test/regress/regress1/bags/intersection_min2.smt2
index 66afa2f3a..119f34665 100644
--- a/test/regress/regress1/bags/intersection_min2.smt2
+++ b/test/regress/regress1/bags/intersection_min2.smt2
@@ -3,7 +3,7 @@
(declare-fun A () (Bag String))
(declare-fun B () (Bag String))
(declare-fun C () (Bag String))
-(assert (= C (intersection_min A B)))
-(assert (= C (union_disjoint A B)))
-(assert (distinct (as emptybag (Bag String)) C))
+(assert (= C (bag.inter_min A B)))
+(assert (= C (bag.union_disjoint A B)))
+(assert (distinct (as bag.empty (Bag String)) C))
(check-sat)
diff --git a/test/regress/regress1/bags/issue5759.smt2 b/test/regress/regress1/bags/issue5759.smt2
index ba3752e09..1c29afea6 100644
--- a/test/regress/regress1/bags/issue5759.smt2
+++ b/test/regress/regress1/bags/issue5759.smt2
@@ -4,7 +4,7 @@
(declare-fun A () (Bag Int))
(declare-fun B () (Bag Int))
(declare-fun x () Int)
-(assert (not (= A (union_max (bag x 1) (bag 0 1)))))
-(assert (= A (union_disjoint B (bag 0 1))))
+(assert (not (= A (bag.union_max (bag x 1) (bag 0 1)))))
+(assert (= A (bag.union_disjoint B (bag 0 1))))
(assert (= x 1))
(check-sat) \ No newline at end of file
diff --git a/test/regress/regress1/bags/map-lazy-lam.smt2 b/test/regress/regress1/bags/map-lazy-lam.smt2
new file mode 100644
index 000000000..c99bab7c9
--- /dev/null
+++ b/test/regress/regress1/bags/map-lazy-lam.smt2
@@ -0,0 +1,9 @@
+; COMMAND-LINE: --fmf-bound --uf-lazy-ll
+; EXPECT: sat
+(set-logic HO_ALL)
+(define-fun f ((x String)) Int 1)
+(define-fun cardinality ((A (Bag String))) Int
+ (bag.count 1 (bag.map f A)))
+(declare-fun A () (Bag String))
+(assert (= (cardinality A) 20))
+(check-sat)
diff --git a/test/regress/regress1/bags/map1.smt2 b/test/regress/regress1/bags/map1.smt2
index 54d671415..c7dc3d636 100644
--- a/test/regress/regress1/bags/map1.smt2
+++ b/test/regress/regress1/bags/map1.smt2
@@ -5,8 +5,8 @@
(declare-fun x () Int)
(declare-fun y () Int)
(declare-fun f (Int) Int)
-(assert (= A (union_max (bag x 1) (bag y 2))))
-(assert (= A (union_max (bag x 1) (bag y 2))))
+(assert (= A (bag.union_max (bag x 1) (bag y 2))))
+(assert (= A (bag.union_max (bag x 1) (bag y 2))))
(assert (= B (bag.map f A)))
(assert (distinct (f x) (f y) x y))
(check-sat)
diff --git a/test/regress/regress1/bags/map3.smt2 b/test/regress/regress1/bags/map3.smt2
index 637815fa5..ae0184008 100644
--- a/test/regress/regress1/bags/map3.smt2
+++ b/test/regress/regress1/bags/map3.smt2
@@ -6,5 +6,5 @@
(define-fun f ((x Int)) Int (+ x 1))
(assert (= B (bag.map f A)))
(assert (= (bag.count (- 2) B) 57))
-(assert (= A (as emptybag (Bag Int)) ))
+(assert (= A (as bag.empty (Bag Int)) ))
(check-sat)
diff --git a/test/regress/regress1/bags/subbag1.smt2 b/test/regress/regress1/bags/subbag1.smt2
index 055e47a17..7a6bf66d7 100644
--- a/test/regress/regress1/bags/subbag1.smt2
+++ b/test/regress/regress1/bags/subbag1.smt2
@@ -4,8 +4,8 @@
(declare-fun B () (Bag Int))
(declare-fun x () Int)
(assert (= x 1))
-(assert (subbag A B))
-(assert (subbag B A))
+(assert (bag.subbag A B))
+(assert (bag.subbag B A))
(assert (= (bag.count x A) 5))
(assert (= (bag.count x B) 10))
(check-sat) \ No newline at end of file
diff --git a/test/regress/regress1/bags/subbag2.smt2 b/test/regress/regress1/bags/subbag2.smt2
index 6d5cde362..abdb3b7d9 100644
--- a/test/regress/regress1/bags/subbag2.smt2
+++ b/test/regress/regress1/bags/subbag2.smt2
@@ -4,8 +4,8 @@
(declare-fun B () (Bag Int))
(declare-fun x () Int)
(declare-fun y () Int)
-(assert (subbag A B))
-(assert (subbag B A))
+(assert (bag.subbag A B))
+(assert (bag.subbag B A))
(assert (= (bag.count x A) x))
(assert (= (bag.count y A) x))
(assert (distinct x y))
diff --git a/test/regress/regress1/bags/union_disjoint.smt2 b/test/regress/regress1/bags/union_disjoint.smt2
index d30ed4b14..fdb9d16d3 100644
--- a/test/regress/regress1/bags/union_disjoint.smt2
+++ b/test/regress/regress1/bags/union_disjoint.smt2
@@ -4,7 +4,7 @@
(declare-fun B () (Bag Int))
(declare-fun x () Int)
(declare-fun y () Int)
-(assert (= A (union_disjoint (bag x 1) (bag y 2))))
-(assert (= A (union_disjoint B (bag y 2))))
+(assert (= A (bag.union_disjoint (bag x 1) (bag y 2))))
+(assert (= A (bag.union_disjoint B (bag y 2))))
(assert (= x y))
(check-sat)
diff --git a/test/regress/regress1/bags/union_max1.smt2 b/test/regress/regress1/bags/union_max1.smt2
index d278527b9..d41e1425a 100644
--- a/test/regress/regress1/bags/union_max1.smt2
+++ b/test/regress/regress1/bags/union_max1.smt2
@@ -4,7 +4,7 @@
(declare-fun B () (Bag Int))
(declare-fun x () Int)
(declare-fun y () Int)
-(assert (= A (union_max (bag x 1) (bag y 2))))
-(assert (= A (union_disjoint B (bag y 2))))
+(assert (= A (bag.union_max (bag x 1) (bag y 2))))
+(assert (= A (bag.union_disjoint B (bag y 2))))
(assert (= x y))
(check-sat) \ No newline at end of file
diff --git a/test/regress/regress1/bags/union_max2.smt2 b/test/regress/regress1/bags/union_max2.smt2
index dd4bceff5..1366130bf 100644
--- a/test/regress/regress1/bags/union_max2.smt2
+++ b/test/regress/regress1/bags/union_max2.smt2
@@ -4,8 +4,8 @@
(declare-fun B () (Bag Int))
(declare-fun x () Int)
(declare-fun y () Int)
-(assert (= A (union_max (bag x 1) (bag y 2))))
-(assert (= A (union_disjoint B (bag y 2))))
+(assert (= A (bag.union_max (bag x 1) (bag y 2))))
+(assert (= A (bag.union_disjoint B (bag y 2))))
(assert (= x y))
-(assert (distinct (as emptybag (Bag Int)) B))
+(assert (distinct (as bag.empty (Bag Int)) B))
(check-sat) \ No newline at end of file
diff --git a/test/regress/regress1/ho/bug_freevar_PHI004^4-delta.smt2 b/test/regress/regress1/ho/bug_freevar_PHI004^4-delta.smt2
index 7c9de4c49..0155eecb2 100644
--- a/test/regress/regress1/ho/bug_freevar_PHI004^4-delta.smt2
+++ b/test/regress/regress1/ho/bug_freevar_PHI004^4-delta.smt2
@@ -1,4 +1,4 @@
-; COMMAND-LINE: --finite-model-find -q --decision=justification-old
+; COMMAND-LINE: --finite-model-find --decision=justification-old --uf-lazy-ll -q
; EXPECT: sat
(set-logic HO_ALL)
diff --git a/test/regress/regress1/ho/ho-fun-sharing-dd.smt2 b/test/regress/regress1/ho/ho-fun-sharing-dd.smt2
new file mode 100644
index 000000000..300dc26de
--- /dev/null
+++ b/test/regress/regress1/ho/ho-fun-sharing-dd.smt2
@@ -0,0 +1,10 @@
+; COMMAND-LINE: --finite-model-find
+; EXPECT: unsat
+(set-logic HO_ALL)
+(declare-sort n 0)
+(declare-fun x () n)
+(declare-fun s (n) n)
+(declare-fun t ((-> n Bool)) Bool)
+(assert (forall ((X n)) (t (lambda ((Xu n)) (= X (s Xu))))))
+(assert (not (t (lambda ((Xu n)) (= x (s Xu))))))
+(check-sat)
diff --git a/test/regress/regress1/quantifiers/set8.smt2 b/test/regress/regress1/quantifiers/set8.smt2
index 209b213c1..17eea7b0a 100644
--- a/test/regress/regress1/quantifiers/set8.smt2
+++ b/test/regress/regress1/quantifiers/set8.smt2
@@ -15,12 +15,12 @@
(assert (forall ((?s1 Set) (?s2 Set)) (= (seteq ?s1 ?s2) (and (set.subset ?s1 ?s2) (set.subset ?s2 ?s1)))))
(declare-fun union (Set Set) Set)
(assert (forall ((?x Elem) (?s1 Set) (?s2 Set)) (= (set.member ?x (union ?s1 ?s2)) (or (set.member ?x ?s1) (set.member ?x ?s2)))))
-(declare-fun set.intersection (Set Set) Set)
-(assert (forall ((?x Elem) (?s1 Set) (?s2 Set)) (= (set.member ?x (set.intersection ?s1 ?s2)) (and (set.member ?x ?s1) (set.member ?x ?s2)))))
+(declare-fun set.inter (Set Set) Set)
+(assert (forall ((?x Elem) (?s1 Set) (?s2 Set)) (= (set.member ?x (set.inter ?s1 ?s2)) (and (set.member ?x ?s1) (set.member ?x ?s2)))))
(declare-fun difference (Set Set) Set)
(assert (forall ((?x Elem) (?s1 Set) (?s2 Set)) (= (set.member ?x (difference ?s1 ?s2)) (and (set.member ?x ?s1) (not (set.member ?x ?s2))))))
(declare-fun a () Set)
(declare-fun b () Set)
-(assert (not (seteq (set.intersection a b) (set.intersection b a))))
+(assert (not (seteq (set.inter a b) (set.inter b a))))
(check-sat)
(exit)
diff --git a/test/regress/regress1/rels/rel_complex_3.cvc.smt2 b/test/regress/regress1/rels/rel_complex_3.cvc.smt2
index 7e80fdd70..8269daf42 100644
--- a/test/regress/regress1/rels/rel_complex_3.cvc.smt2
+++ b/test/regress/regress1/rels/rel_complex_3.cvc.smt2
@@ -20,12 +20,12 @@
(assert (= r (rel.join x y)))
(declare-fun e () (Tuple Int Int))
(assert (not (set.member e r)))
-(assert (not (= z (set.intersection x y))))
+(assert (not (= z (set.inter x y))))
(assert (= z (set.minus x y)))
(assert (set.subset x y))
(assert (set.member e (rel.join r z)))
(assert (set.member e x))
-(assert (set.member e (set.intersection x y)))
+(assert (set.member e (set.inter x y)))
(push 1)
(assert true)
diff --git a/test/regress/regress1/rels/rel_complex_4.cvc.smt2 b/test/regress/regress1/rels/rel_complex_4.cvc.smt2
index 9a35f336e..134a99c73 100644
--- a/test/regress/regress1/rels/rel_complex_4.cvc.smt2
+++ b/test/regress/regress1/rels/rel_complex_4.cvc.smt2
@@ -24,12 +24,12 @@
(assert (= w (set.singleton e)))
(assert (set.subset (rel.transpose w) y))
(assert (not (set.member e r)))
-(assert (not (= z (set.intersection x y))))
+(assert (not (= z (set.inter x y))))
(assert (= z (set.minus x y)))
(assert (set.subset x y))
(assert (set.member e (rel.join r z)))
(assert (set.member e x))
-(assert (set.member e (set.intersection x y)))
+(assert (set.member e (set.inter x y)))
(push 1)
(assert true)
diff --git a/test/regress/regress1/rels/rel_complex_5.cvc.smt2 b/test/regress/regress1/rels/rel_complex_5.cvc.smt2
index fc2d73235..ed894518e 100644
--- a/test/regress/regress1/rels/rel_complex_5.cvc.smt2
+++ b/test/regress/regress1/rels/rel_complex_5.cvc.smt2
@@ -26,12 +26,12 @@
(assert (let ((_let_1 (set.singleton a))) (= w (rel.product _let_1 _let_1))))
(assert (set.subset (rel.transpose w) y))
(assert (not (set.member e r)))
-(assert (not (= z (set.intersection x y))))
+(assert (not (= z (set.inter x y))))
(assert (= z (set.minus x y)))
(assert (set.subset x y))
(assert (set.member e (rel.join r z)))
(assert (set.member e x))
-(assert (set.member e (set.intersection x y)))
+(assert (set.member e (set.inter x y)))
(push 1)
(assert true)
diff --git a/test/regress/regress1/sets/ListElem.hs.fqout.cvc4.38.smt2 b/test/regress/regress1/sets/ListElem.hs.fqout.cvc4.38.smt2
index 144566fc5..e5b92a4fc 100644
--- a/test/regress/regress1/sets/ListElem.hs.fqout.cvc4.38.smt2
+++ b/test/regress/regress1/sets/ListElem.hs.fqout.cvc4.38.smt2
@@ -12,7 +12,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
;(define-fun smt_set_com ((s mySet)) mySet ((_ map not) s))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
;(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (= smt_set_emp (smt_set_dif s1 s2)))
diff --git a/test/regress/regress1/sets/ListElts.hs.fqout.cvc4.317.smt2 b/test/regress/regress1/sets/ListElts.hs.fqout.cvc4.317.smt2
index 9a2521520..206450142 100644
--- a/test/regress/regress1/sets/ListElts.hs.fqout.cvc4.317.smt2
+++ b/test/regress/regress1/sets/ListElts.hs.fqout.cvc4.317.smt2
@@ -7,7 +7,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
;(define-fun smt_set_com ((s mySet)) mySet ((_ map not) s))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
;(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (= smt_set_emp (smt_set_dif s1 s2)))
diff --git a/test/regress/regress1/sets/TalkingAboutSets.hs.fqout.cvc4.3577.smt2 b/test/regress/regress1/sets/TalkingAboutSets.hs.fqout.cvc4.3577.smt2
index b2732dbd2..fe7e7d7ac 100644
--- a/test/regress/regress1/sets/TalkingAboutSets.hs.fqout.cvc4.3577.smt2
+++ b/test/regress/regress1/sets/TalkingAboutSets.hs.fqout.cvc4.3577.smt2
@@ -7,7 +7,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
;(define-fun smt_set_com ((s mySet)) mySet ((_ map not) s))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
;(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (= smt_set_emp (smt_set_dif s1 s2)))
diff --git a/test/regress/regress1/sets/UniqueZipper.hs.1030minimized.cvc4.smt2 b/test/regress/regress1/sets/UniqueZipper.hs.1030minimized.cvc4.smt2
index ee24367c3..078b98eef 100644
--- a/test/regress/regress1/sets/UniqueZipper.hs.1030minimized.cvc4.smt2
+++ b/test/regress/regress1/sets/UniqueZipper.hs.1030minimized.cvc4.smt2
@@ -6,7 +6,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (set.subset s1 s2))
diff --git a/test/regress/regress1/sets/UniqueZipper.hs.1030minimized2.cvc4.smt2 b/test/regress/regress1/sets/UniqueZipper.hs.1030minimized2.cvc4.smt2
index b0cfe4888..756f0430c 100644
--- a/test/regress/regress1/sets/UniqueZipper.hs.1030minimized2.cvc4.smt2
+++ b/test/regress/regress1/sets/UniqueZipper.hs.1030minimized2.cvc4.smt2
@@ -6,7 +6,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (set.subset s1 s2))
diff --git a/test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.10.smt2 b/test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.10.smt2
index 9ac15e9a4..1e45c21e9 100644
--- a/test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.10.smt2
+++ b/test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.10.smt2
@@ -6,7 +6,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (set.subset s1 s2))
(declare-fun z3v66 () Int)
diff --git a/test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.1832.smt2 b/test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.1832.smt2
index 68ed72a93..a3fd883b6 100644
--- a/test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.1832.smt2
+++ b/test/regress/regress1/sets/UniqueZipper.hs.fqout.cvc4.1832.smt2
@@ -6,7 +6,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
;(define-fun smt_set_com ((s mySet)) mySet ((_ map not) s))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
;(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (= smt_set_emp (smt_set_dif s1 s2)))
diff --git a/test/regress/regress1/sets/card-3.smt2 b/test/regress/regress1/sets/card-3.smt2
index 383395b0d..bbcf1c489 100644
--- a/test/regress/regress1/sets/card-3.smt2
+++ b/test/regress/regress1/sets/card-3.smt2
@@ -8,5 +8,5 @@
(assert (>= (set.card (set.union s u)) 8))
(assert (<= (set.card (set.union t u)) 5))
(assert (<= (set.card s) 5))
-(assert (= (as set.empty (Set E)) (set.intersection t u)))
+(assert (= (as set.empty (Set E)) (set.inter t u)))
(check-sat)
diff --git a/test/regress/regress1/sets/card-4.smt2 b/test/regress/regress1/sets/card-4.smt2
index 019b16a09..9f0e96dc5 100644
--- a/test/regress/regress1/sets/card-4.smt2
+++ b/test/regress/regress1/sets/card-4.smt2
@@ -8,7 +8,7 @@
(assert (>= (set.card (set.union s u)) 8))
;(assert (<= (set.card (set.union t u)) 5))
(assert (<= (set.card s) 5))
-(assert (= (as set.empty (Set E)) (set.intersection t u)))
+(assert (= (as set.empty (Set E)) (set.inter t u)))
(declare-fun x1 () E)
(declare-fun x2 () E)
(declare-fun x3 () E)
diff --git a/test/regress/regress1/sets/card-5.smt2 b/test/regress/regress1/sets/card-5.smt2
index c24ca974a..51ad7971c 100644
--- a/test/regress/regress1/sets/card-5.smt2
+++ b/test/regress/regress1/sets/card-5.smt2
@@ -8,7 +8,7 @@
(assert (>= (set.card (set.union s u)) 8))
;(assert (<= (set.card (set.union t u)) 5))
(assert (<= (set.card s) 5))
-(assert (= (as set.empty (Set E)) (set.intersection t u)))
+(assert (= (as set.empty (Set E)) (set.inter t u)))
(declare-fun x1 () E)
(declare-fun x2 () E)
(declare-fun x3 () E)
diff --git a/test/regress/regress1/sets/card-6.smt2 b/test/regress/regress1/sets/card-6.smt2
index b0ef3a3b9..fc2d34acc 100644
--- a/test/regress/regress1/sets/card-6.smt2
+++ b/test/regress/regress1/sets/card-6.smt2
@@ -7,7 +7,7 @@
(assert
(and
(= (as set.empty (Set E))
- (set.intersection A B))
+ (set.inter A B))
(set.subset C (set.union A B))
(>= (set.card C) 5)
(<= (set.card A) 2)
diff --git a/test/regress/regress1/sets/comp-intersect.smt2 b/test/regress/regress1/sets/comp-intersect.smt2
index 60d9046bd..5f6f7576b 100644
--- a/test/regress/regress1/sets/comp-intersect.smt2
+++ b/test/regress/regress1/sets/comp-intersect.smt2
@@ -9,6 +9,6 @@
(assert (= x (set.comprehension ((z Int)) (> z 4) (* 5 z))))
(assert (= y (set.comprehension ((z Int)) (< z 10) (+ (* 5 z) 1))))
-(assert (not (= (set.intersection x y) (as set.empty (Set Int)))))
+(assert (not (= (set.inter x y) (as set.empty (Set Int)))))
(check-sat)
diff --git a/test/regress/regress1/sets/deepmeas0.hs.fqout.cvc4.41.smt2 b/test/regress/regress1/sets/deepmeas0.hs.fqout.cvc4.41.smt2
index 7c5e09b5a..93d359b60 100644
--- a/test/regress/regress1/sets/deepmeas0.hs.fqout.cvc4.41.smt2
+++ b/test/regress/regress1/sets/deepmeas0.hs.fqout.cvc4.41.smt2
@@ -7,7 +7,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
;(define-fun smt_set_com ((s mySet)) mySet ((_ map not) s))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
;(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (= smt_set_emp (smt_set_dif s1 s2)))
diff --git a/test/regress/regress1/sets/finite-type/sets-card-bool-1.smt2 b/test/regress/regress1/sets/finite-type/sets-card-bool-1.smt2
index aa5b62d09..ec82ddb8b 100644
--- a/test/regress/regress1/sets/finite-type/sets-card-bool-1.smt2
+++ b/test/regress/regress1/sets/finite-type/sets-card-bool-1.smt2
@@ -7,6 +7,6 @@
(declare-fun universe () (Set Bool))
(assert (= (set.card A) 2))
(assert (= (set.card B) 2))
-(assert (= (set.intersection A B) (as set.empty (Set Bool))))
+(assert (= (set.inter A B) (as set.empty (Set Bool))))
(assert (= universe (as set.universe (Set Bool))))
(check-sat)
diff --git a/test/regress/regress1/sets/finite-type/sets-card-bv-2.smt2 b/test/regress/regress1/sets/finite-type/sets-card-bv-2.smt2
index 91bf1905a..0003349b3 100644
--- a/test/regress/regress1/sets/finite-type/sets-card-bv-2.smt2
+++ b/test/regress/regress1/sets/finite-type/sets-card-bv-2.smt2
@@ -8,7 +8,7 @@
(assert (= (set.card A) 5))
(assert (= (set.card B) 5))
(assert (not (= A B)))
-(assert (= (set.card (set.intersection A B)) 2))
+(assert (= (set.card (set.inter A B)) 2))
(assert (= (set.card (set.minus A B)) 3))
(assert (= (set.card (set.minus B A)) 3))
(assert (= universe (as set.universe (Set (_ BitVec 3)))))
diff --git a/test/regress/regress1/sets/finite-type/sets-card-bv-3.smt2 b/test/regress/regress1/sets/finite-type/sets-card-bv-3.smt2
index adbe51507..5808c4ec7 100644
--- a/test/regress/regress1/sets/finite-type/sets-card-bv-3.smt2
+++ b/test/regress/regress1/sets/finite-type/sets-card-bv-3.smt2
@@ -9,7 +9,7 @@
(assert (= (set.card A) 3))
(assert (= (set.card B) 3))
(assert (not (= A B)))
-(assert (= (set.card (set.intersection A B)) 1))
+(assert (= (set.card (set.inter A B)) 1))
(assert (= (set.card (set.minus A B)) 2))
(assert (= (set.card (set.minus B A)) 2))
(assert (not (set.member x A)))
diff --git a/test/regress/regress1/sets/finite-type/sets-card-bv-4.smt2 b/test/regress/regress1/sets/finite-type/sets-card-bv-4.smt2
index 2ccbc8a58..81c49e1e3 100644
--- a/test/regress/regress1/sets/finite-type/sets-card-bv-4.smt2
+++ b/test/regress/regress1/sets/finite-type/sets-card-bv-4.smt2
@@ -9,7 +9,7 @@
(assert (= (set.card A) 5))
(assert (= (set.card B) 5))
(assert (not (= A B)))
-(assert (= (set.card (set.intersection A B)) 2))
+(assert (= (set.card (set.inter A B)) 2))
(assert (= (set.card (set.minus A B)) 3))
(assert (= (set.card (set.minus B A)) 3))
(assert (= universe (as set.universe (Set (_ BitVec 3)))))
diff --git a/test/regress/regress1/sets/finite-type/sets-card-datatype-1.smt2 b/test/regress/regress1/sets/finite-type/sets-card-datatype-1.smt2
index 4c113c84b..62c0bc224 100644
--- a/test/regress/regress1/sets/finite-type/sets-card-datatype-1.smt2
+++ b/test/regress/regress1/sets/finite-type/sets-card-datatype-1.smt2
@@ -9,6 +9,6 @@
(declare-fun x () Rec)
(assert (= (set.card A) 5))
(assert (= (set.card B) 5))
-(assert (= (set.card (set.intersection A B)) 1))
+(assert (= (set.card (set.inter A B)) 1))
(assert (= universe (as set.universe (Set Rec))))
(check-sat)
diff --git a/test/regress/regress1/sets/finite-type/sets-card-datatype-2.smt2 b/test/regress/regress1/sets/finite-type/sets-card-datatype-2.smt2
index 4c9bdadd5..70e3a88d8 100644
--- a/test/regress/regress1/sets/finite-type/sets-card-datatype-2.smt2
+++ b/test/regress/regress1/sets/finite-type/sets-card-datatype-2.smt2
@@ -8,6 +8,6 @@
(declare-fun universe () (Set Rec))
(assert (= (set.card A) 9))
(assert (= (set.card B) 9))
-(assert (= (set.card (set.intersection A B)) 1))
+(assert (= (set.card (set.inter A B)) 1))
(assert (= universe (as set.universe (Set Rec))))
(check-sat)
diff --git a/test/regress/regress1/sets/fuzz14418.smt2 b/test/regress/regress1/sets/fuzz14418.smt2
index 2fb60cb72..b09cf1151 100644
--- a/test/regress/regress1/sets/fuzz14418.smt2
+++ b/test/regress/regress1/sets/fuzz14418.smt2
@@ -34,7 +34,7 @@
(let ((e14 (set.minus v2 v2)))
(let ((e15 (f1 v1 v4 v1)))
(let ((e16 (f1 e14 v1 v4)))
-(let ((e17 (set.intersection e16 e15)))
+(let ((e17 (set.inter e16 e15)))
(let ((e18 (f1 v4 e15 v2)))
(let ((e19 (ite (p1 e13) (set.singleton 1) (set.singleton 0))))
(let ((e20 (set.member v0 e17)))
diff --git a/test/regress/regress1/sets/fuzz15201.smt2 b/test/regress/regress1/sets/fuzz15201.smt2
index 3094a8d84..bdcbe7d59 100644
--- a/test/regress/regress1/sets/fuzz15201.smt2
+++ b/test/regress/regress1/sets/fuzz15201.smt2
@@ -29,9 +29,9 @@
(let ((e16 (set.minus v2 v1)))
(let ((e17 (set.minus v1 v2)))
(let ((e18 (set.union e17 e17)))
-(let ((e19 (set.intersection e17 v1)))
-(let ((e20 (set.intersection e17 e18)))
-(let ((e21 (set.intersection v1 e16)))
+(let ((e19 (set.inter e17 v1)))
+(let ((e20 (set.inter e17 e18)))
+(let ((e21 (set.inter v1 e16)))
(let ((e22 (set.minus e20 e16)))
(let ((e23 (ite (p1 v2 e18 e21) (set.singleton 1) (set.singleton 0))))
(let ((e24 (set.minus e17 e23)))
diff --git a/test/regress/regress1/sets/fuzz31811.smt2 b/test/regress/regress1/sets/fuzz31811.smt2
index e86901f9a..ca028488a 100644
--- a/test/regress/regress1/sets/fuzz31811.smt2
+++ b/test/regress/regress1/sets/fuzz31811.smt2
@@ -28,19 +28,19 @@
(let ((e10 (f0 v0 e8 e8)))
(let ((e11 (ite (p1 v1) (set.singleton 1) (set.singleton 0))))
(let ((e12 (set.union v3 v3)))
-(let ((e13 (set.intersection v3 v1)))
+(let ((e13 (set.inter v3 v1)))
(let ((e14 (ite (p1 v3) (set.singleton 1) (set.singleton 0))))
-(let ((e15 (set.intersection v2 e14)))
+(let ((e15 (set.inter v2 e14)))
(let ((e16 (ite (p1 e11) (set.singleton 1) (set.singleton 0))))
(let ((e17 (ite (p1 v4) (set.singleton 1) (set.singleton 0))))
(let ((e18 (set.union e15 v2)))
(let ((e19 (ite (p1 e16) (set.singleton 1) (set.singleton 0))))
-(let ((e20 (set.intersection e18 v3)))
+(let ((e20 (set.inter e18 v3)))
(let ((e21 (set.minus v4 e12)))
(let ((e22 (set.union v3 v2)))
(let ((e23 (set.minus e12 v4)))
(let ((e24 (set.minus v3 e16)))
-(let ((e25 (set.intersection e19 e20)))
+(let ((e25 (set.inter e19 e20)))
(let ((e26 (ite (p1 e15) (set.singleton 1) (set.singleton 0))))
(let ((e27 (set.minus e17 e15)))
(let ((e28 (f1 e23 e12)))
diff --git a/test/regress/regress1/sets/infinite-type/sets-card-array-int-1.smt2 b/test/regress/regress1/sets/infinite-type/sets-card-array-int-1.smt2
index f6d032f11..57f4344c6 100644
--- a/test/regress/regress1/sets/infinite-type/sets-card-array-int-1.smt2
+++ b/test/regress/regress1/sets/infinite-type/sets-card-array-int-1.smt2
@@ -7,6 +7,6 @@
(assert (= (set.card universe) 3))
(assert (= (set.card A) 2))
(assert (= (set.card B) 2))
-(assert (= (set.intersection A B) (as set.empty (Set (Array Int Int)))))
+(assert (= (set.inter A B) (as set.empty (Set (Array Int Int)))))
(assert (= universe (as set.universe (Set (Array Int Int)))))
(check-sat)
diff --git a/test/regress/regress1/sets/infinite-type/sets-card-array-int-2.smt2 b/test/regress/regress1/sets/infinite-type/sets-card-array-int-2.smt2
index d7e6a758c..76828576e 100644
--- a/test/regress/regress1/sets/infinite-type/sets-card-array-int-2.smt2
+++ b/test/regress/regress1/sets/infinite-type/sets-card-array-int-2.smt2
@@ -7,6 +7,6 @@
(assert (= (set.card universe) 3))
(assert (= (set.card A) 1))
(assert (= (set.card B) 2))
-(assert (= (set.intersection A B) (as set.empty (Set (Array Int Int)))))
+(assert (= (set.inter A B) (as set.empty (Set (Array Int Int)))))
(assert (= universe (as set.universe (Set (Array Int Int)))))
(check-sat)
diff --git a/test/regress/regress1/sets/infinite-type/sets-card-int-1.smt2 b/test/regress/regress1/sets/infinite-type/sets-card-int-1.smt2
index c649c9be2..2cf5e566d 100644
--- a/test/regress/regress1/sets/infinite-type/sets-card-int-1.smt2
+++ b/test/regress/regress1/sets/infinite-type/sets-card-int-1.smt2
@@ -7,6 +7,6 @@
(declare-const B (Set Int))
(assert (= (set.card A) 6))
(assert (= (set.card B) 5))
-(assert (= (set.intersection A B) (as set.empty (Set Int))))
+(assert (= (set.inter A B) (as set.empty (Set Int))))
(assert (= universe (as set.universe (Set Int))))
(check-sat)
diff --git a/test/regress/regress1/sets/infinite-type/sets-card-int-2.smt2 b/test/regress/regress1/sets/infinite-type/sets-card-int-2.smt2
index b3958e79e..8668b9c27 100644
--- a/test/regress/regress1/sets/infinite-type/sets-card-int-2.smt2
+++ b/test/regress/regress1/sets/infinite-type/sets-card-int-2.smt2
@@ -7,6 +7,6 @@
(declare-const B (Set Int))
(assert (= (set.card A) 5))
(assert (= (set.card B) 5))
-(assert (= (set.intersection A B) (as set.empty (Set Int))))
+(assert (= (set.inter A B) (as set.empty (Set Int))))
(assert (= universe (as set.universe (Set Int))))
(check-sat)
diff --git a/test/regress/regress1/sets/insert_invariant_37_2.smt2 b/test/regress/regress1/sets/insert_invariant_37_2.smt2
index cac805531..a8f117062 100644
--- a/test/regress/regress1/sets/insert_invariant_37_2.smt2
+++ b/test/regress/regress1/sets/insert_invariant_37_2.smt2
@@ -723,7 +723,7 @@
(assert (! (not (set.member null$0 Alloc$0)) :named initial_footprint_of_insert_27_11_1))
(assert (! (or (= prev_2$0 curr_2$0)
- (set.member sk_?e_1$0 (set.intersection sk_?X_4$0 sk_?X_3$0))
+ (set.member sk_?e_1$0 (set.inter sk_?X_4$0 sk_?X_3$0))
(and (set.member sk_?e_1$0 sk_FP$0) (not (set.member sk_?e_1$0 FP$0)))
(and (set.member sk_?e$0 (set.union c1_2$0 c2_2$0)) (not (set.member sk_?e$0 content$0)))
(and (set.member sk_?e$0 c1_2$0)
diff --git a/test/regress/regress1/sets/issue2904.smt2 b/test/regress/regress1/sets/issue2904.smt2
index c39ea09ba..d2ffdbd7c 100644
--- a/test/regress/regress1/sets/issue2904.smt2
+++ b/test/regress/regress1/sets/issue2904.smt2
@@ -21,6 +21,6 @@
(assert (> n (+ (* 2 f) m)))
-(assert (>= (set.card (set.minus UNIVERALSET (set.intersection (set.minus UNIVERALSET b) (set.minus UNIVERALSET c)))) n))
+(assert (>= (set.card (set.minus UNIVERALSET (set.inter (set.minus UNIVERALSET b) (set.minus UNIVERALSET c)))) n))
(check-sat)
diff --git a/test/regress/regress1/sets/issue4370-2-lemma-ee-iter.smt2 b/test/regress/regress1/sets/issue4370-2-lemma-ee-iter.smt2
index fd3bd62eb..f57837d05 100644
--- a/test/regress/regress1/sets/issue4370-2-lemma-ee-iter.smt2
+++ b/test/regress/regress1/sets/issue4370-2-lemma-ee-iter.smt2
@@ -2,6 +2,6 @@
(set-info :status unsat)
(declare-fun st1 () (Set Int))
(declare-fun st7 () (Set Int))
-(assert (> 0 (set.card (set.intersection st1 (set.union st7 st1)))))
+(assert (> 0 (set.card (set.inter st1 (set.union st7 st1)))))
(assert (set.subset st1 st7))
(check-sat)
diff --git a/test/regress/regress1/sets/issue4370-4-lemma-ee-iter.smt2 b/test/regress/regress1/sets/issue4370-4-lemma-ee-iter.smt2
index bc2f103d2..55b4ac581 100644
--- a/test/regress/regress1/sets/issue4370-4-lemma-ee-iter.smt2
+++ b/test/regress/regress1/sets/issue4370-4-lemma-ee-iter.smt2
@@ -2,7 +2,7 @@
(set-info :status unsat)
(declare-fun st3 () (Set String))
(declare-fun st9 () (Set String))
-(assert (set.is_singleton (set.intersection st3 st9)))
-(assert (< 1 (set.card (set.intersection st3 st9))))
+(assert (set.is_singleton (set.inter st3 st9)))
+(assert (< 1 (set.card (set.inter st3 st9))))
(assert (set.is_singleton st9))
(check-sat)
diff --git a/test/regress/regress1/sets/issue4391-card-lasso.smt2 b/test/regress/regress1/sets/issue4391-card-lasso.smt2
index f7a720436..76e27f5b0 100644
--- a/test/regress/regress1/sets/issue4391-card-lasso.smt2
+++ b/test/regress/regress1/sets/issue4391-card-lasso.smt2
@@ -11,6 +11,6 @@
(assert (= (set.card b) d))
(assert (= (set.card c) 0))
(assert (= 0 (mod 0 d)))
-(assert (> (set.card (set.minus e (set.intersection (set.intersection e b) (set.minus e c)))) 1))
+(assert (> (set.card (set.minus e (set.inter (set.inter e b) (set.minus e c)))) 1))
(check-sat)
diff --git a/test/regress/regress1/sets/lemmabug-ListElts317minimized.smt2 b/test/regress/regress1/sets/lemmabug-ListElts317minimized.smt2
index ae71a1edb..a5ee519f5 100644
--- a/test/regress/regress1/sets/lemmabug-ListElts317minimized.smt2
+++ b/test/regress/regress1/sets/lemmabug-ListElts317minimized.smt2
@@ -27,7 +27,7 @@
(define-fun smt_set_mem ((x Elt) (s mySet)) Bool (set.member x s))
(define-fun smt_set_add ((s mySet) (x Elt)) mySet (set.union s (set.singleton x)))
(define-fun smt_set_cup ((s1 mySet) (s2 mySet)) mySet (set.union s1 s2))
-(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.intersection s1 s2))
+(define-fun smt_set_cap ((s1 mySet) (s2 mySet)) mySet (set.inter s1 s2))
;(define-fun smt_set_com ((s mySet)) mySet ((_ map not) s))
(define-fun smt_set_dif ((s1 mySet) (s2 mySet)) mySet (set.minus s1 s2))
;(define-fun smt_set_sub ((s1 mySet) (s2 mySet)) Bool (= smt_set_emp (smt_set_dif s1 s2)))
diff --git a/test/regress/regress1/sets/remove_check_free_31_6.smt2 b/test/regress/regress1/sets/remove_check_free_31_6.smt2
index c2ff1da23..9c2bc9be7 100644
--- a/test/regress/regress1/sets/remove_check_free_31_6.smt2
+++ b/test/regress/regress1/sets/remove_check_free_31_6.smt2
@@ -230,7 +230,7 @@
(assert (! (= sk_?X_28$0 (lseg_domain$0 next$0 curr_3$0 null$0))
:named invariant_18_4_69))
-(assert (! (= (as set.empty SetLoc) (set.intersection sk_?X_27$0 sk_?X_28$0))
+(assert (! (= (as set.empty SetLoc) (set.inter sk_?X_27$0 sk_?X_28$0))
:named invariant_18_4_70))
(assert (! (= Alloc$0 (set.union FP_Caller$0 Alloc$0))
@@ -246,7 +246,7 @@
(assert (! (= FP_2$0
(set.union (set.minus FP$0 FP_1$0)
- (set.union (set.intersection Alloc$0 FP_1$0) (set.minus Alloc$0 Alloc$0))))
+ (set.union (set.inter Alloc$0 FP_1$0) (set.minus Alloc$0 Alloc$0))))
:named framecondition_of_remove_loop_18_4_17))
(assert (! (or (Btwn$0 next$0 lst$0 curr_2$0 curr_2$0)
@@ -311,7 +311,7 @@
(assert (! (= sk_?X_30$0 FP_1$0) :named invariant_18_4_74))
-(assert (! (= (as set.empty SetLoc) (set.intersection sk_?X_32$0 sk_?X_31$0))
+(assert (! (= (as set.empty SetLoc) (set.inter sk_?X_32$0 sk_?X_31$0))
:named invariant_18_4_75))
(assert (! (not (= curr_3$0 null$0)) :named invariant_18_4_76))
@@ -320,7 +320,7 @@
:named invariant_18_4_77))
(assert (! (= sk_?X_29$0
- (set.union (set.intersection Alloc$0 FP_1$0) (set.minus Alloc$0 Alloc$0)))
+ (set.union (set.inter Alloc$0 FP_1$0) (set.minus Alloc$0 Alloc$0)))
:named invariant_18_4_78))
(assert (! (= sk_?X_27$0 (lseg_domain$0 next$0 lst_1$0 curr_3$0))
diff --git a/test/regress/regress1/sym/sym5.smt2 b/test/regress/regress1/sym/sym5.smt2
index cf9cbe092..16b44d115 100644
--- a/test/regress/regress1/sym/sym5.smt2
+++ b/test/regress/regress1/sym/sym5.smt2
@@ -13,6 +13,6 @@
(assert (set.subset A (set.insert g h i (set.singleton f))))
(assert (= C (set.minus A B) ))
(assert (set.subset B A))
-(assert (= C (set.intersection A B)))
+(assert (= C (set.inter A B)))
(assert (set.member j C))
(check-sat)
diff --git a/test/regress/regress1/trim.cvc.smt2 b/test/regress/regress1/trim.cvc.smt2
index f05e08572..d823e565d 100644
--- a/test/regress/regress1/trim.cvc.smt2
+++ b/test/regress/regress1/trim.cvc.smt2
@@ -18,9 +18,9 @@
(declare-fun ic0_c () (Set myType))
(assert (forall ((r myType)) (=> (set.member r ic0_i) (forall ((r2 myType)) (=> (set.member r2 (neg (select d r))) (set.member r2 ic0_c))))))
(assert (set.subset (set.singleton A) ic0_i))
-(assert (or (exists ((e0 myType)) (=> (set.member e0 ic0_i) (set.subset (select l A) (select l e0)))) (set.subset (set.intersection ic0_i ic0_c) emptymyTypeSet)))
+(assert (or (exists ((e0 myType)) (=> (set.member e0 ic0_i) (set.subset (select l A) (select l e0)))) (set.subset (set.inter ic0_i ic0_c) emptymyTypeSet)))
(declare-fun ic1_i () (Set myType))
(declare-fun ic1_c () (Set myType))
(assert (forall ((r myType)) (=> (set.member r (pos (select d B))) (set.member r ic1_i))))
-(assert (or (exists ((e1 myType)) (=> (set.member e1 ic1_i) (set.subset (select l B) (select l e1)))) (set.subset (set.intersection ic1_i ic1_c) emptymyTypeSet)))
+(assert (or (exists ((e1 myType)) (=> (set.member e1 ic1_i) (set.subset (select l B) (select l e1)))) (set.subset (set.inter ic1_i ic1_c) emptymyTypeSet)))
(check-sat)
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 11c2e8514..9be9dcefa 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -70,7 +70,11 @@ macro(cvc5_add_unit_test is_white name output_dir)
if("${output_dir}" STREQUAL "")
set(test_name unit/${name})
else()
- set(test_name unit/${output_dir}/${name})
+ if("${output_dir}" STREQUAL "api")
+ set(test_name unit/${output_dir}/cpp/${name})
+ else()
+ set(test_name unit/${output_dir}/${name})
+ endif()
endif()
add_test(${test_name} ${test_bin_dir}/${name})
set_tests_properties(${test_name} PROPERTIES LABELS "unit")
diff --git a/test/unit/api/CMakeLists.txt b/test/unit/api/CMakeLists.txt
index ae6db51ef..0701c3ca6 100644
--- a/test/unit/api/CMakeLists.txt
+++ b/test/unit/api/CMakeLists.txt
@@ -13,17 +13,10 @@
# The build system configuration.
##
-# Add unit tests.
-cvc5_add_unit_test_black(datatype_api_black api)
-cvc5_add_unit_test_black(grammar_black api)
-cvc5_add_unit_test_black(op_black api)
-cvc5_add_unit_test_white(op_white api)
-cvc5_add_unit_test_black(result_black api)
-cvc5_add_unit_test_black(solver_black api)
-cvc5_add_unit_test_white(solver_white api)
-cvc5_add_unit_test_black(sort_black api)
-cvc5_add_unit_test_black(term_black api)
-cvc5_add_unit_test_white(term_white api)
+add_subdirectory(cpp)
+if (BUILD_BINDINGS_PYTHON)
+ add_subdirectory(python)
+endif()
if (BUILD_BINDINGS_JAVA)
add_subdirectory(java)
endif()
diff --git a/test/unit/api/cpp/CMakeLists.txt b/test/unit/api/cpp/CMakeLists.txt
new file mode 100644
index 000000000..e99732ca4
--- /dev/null
+++ b/test/unit/api/cpp/CMakeLists.txt
@@ -0,0 +1,24 @@
+###############################################################################
+# Top contributors (to current version):
+# Aina Niemetz
+#
+# 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.
+# #############################################################################
+#
+# The build system configuration.
+##
+cvc5_add_unit_test_black(datatype_api_black api)
+cvc5_add_unit_test_black(grammar_black api)
+cvc5_add_unit_test_black(op_black api)
+cvc5_add_unit_test_white(op_white api)
+cvc5_add_unit_test_black(result_black api)
+cvc5_add_unit_test_black(solver_black api)
+cvc5_add_unit_test_white(solver_white api)
+cvc5_add_unit_test_black(sort_black api)
+cvc5_add_unit_test_black(term_black api)
+cvc5_add_unit_test_white(term_white api)
diff --git a/test/unit/api/datatype_api_black.cpp b/test/unit/api/cpp/datatype_api_black.cpp
index 745abc17c..745abc17c 100644
--- a/test/unit/api/datatype_api_black.cpp
+++ b/test/unit/api/cpp/datatype_api_black.cpp
diff --git a/test/unit/api/grammar_black.cpp b/test/unit/api/cpp/grammar_black.cpp
index 7b7556539..7b7556539 100644
--- a/test/unit/api/grammar_black.cpp
+++ b/test/unit/api/cpp/grammar_black.cpp
diff --git a/test/unit/api/op_black.cpp b/test/unit/api/cpp/op_black.cpp
index fd45b1c22..fd45b1c22 100644
--- a/test/unit/api/op_black.cpp
+++ b/test/unit/api/cpp/op_black.cpp
diff --git a/test/unit/api/op_white.cpp b/test/unit/api/cpp/op_white.cpp
index 39952739b..39952739b 100644
--- a/test/unit/api/op_white.cpp
+++ b/test/unit/api/cpp/op_white.cpp
diff --git a/test/unit/api/result_black.cpp b/test/unit/api/cpp/result_black.cpp
index 9bf6b8491..9bf6b8491 100644
--- a/test/unit/api/result_black.cpp
+++ b/test/unit/api/cpp/result_black.cpp
diff --git a/test/unit/api/solver_black.cpp b/test/unit/api/cpp/solver_black.cpp
index 79a4aa63e..51a0f38b5 100644
--- a/test/unit/api/solver_black.cpp
+++ b/test/unit/api/cpp/solver_black.cpp
@@ -15,8 +15,8 @@
#include <algorithm>
-#include "test_api.h"
#include "base/output.h"
+#include "test_api.h"
namespace cvc5 {
@@ -341,9 +341,12 @@ TEST_F(TestApiBlackSolver, mkBitVector)
ASSERT_EQ(d_solver.mkBitVector(8, "0101", 2),
d_solver.mkBitVector(8, "00000101", 2));
- ASSERT_EQ(d_solver.mkBitVector(4, "-1", 2), d_solver.mkBitVector(4, "1111", 2));
- ASSERT_EQ(d_solver.mkBitVector(4, "-1", 16), d_solver.mkBitVector(4, "1111", 2));
- ASSERT_EQ(d_solver.mkBitVector(4, "-1", 10), d_solver.mkBitVector(4, "1111", 2));
+ ASSERT_EQ(d_solver.mkBitVector(4, "-1", 2),
+ d_solver.mkBitVector(4, "1111", 2));
+ ASSERT_EQ(d_solver.mkBitVector(4, "-1", 16),
+ d_solver.mkBitVector(4, "1111", 2));
+ ASSERT_EQ(d_solver.mkBitVector(4, "-1", 10),
+ d_solver.mkBitVector(4, "1111", 2));
ASSERT_EQ(d_solver.mkBitVector(8, "01010101", 2).toString(), "#b01010101");
ASSERT_EQ(d_solver.mkBitVector(8, "F", 16).toString(), "#b00001111");
ASSERT_EQ(d_solver.mkBitVector(8, "-1", 10),
@@ -592,12 +595,11 @@ TEST_F(TestApiBlackSolver, mkReal)
ASSERT_NO_THROW(d_solver.mkReal(val4, val4));
}
-TEST_F(TestApiBlackSolver, mkRegexpNone)
+TEST_F(TestApiBlackSolver, mkRegexpAll)
{
Sort strSort = d_solver.getStringSort();
Term s = d_solver.mkConst(strSort, "s");
- ASSERT_NO_THROW(
- d_solver.mkTerm(STRING_IN_REGEXP, s, d_solver.mkRegexpNone()));
+ ASSERT_NO_THROW(d_solver.mkTerm(STRING_IN_REGEXP, s, d_solver.mkRegexpAll()));
}
TEST_F(TestApiBlackSolver, mkRegexpAllchar)
@@ -608,6 +610,14 @@ TEST_F(TestApiBlackSolver, mkRegexpAllchar)
d_solver.mkTerm(STRING_IN_REGEXP, s, d_solver.mkRegexpAllchar()));
}
+TEST_F(TestApiBlackSolver, mkRegexpNone)
+{
+ Sort strSort = d_solver.getStringSort();
+ Term s = d_solver.mkConst(strSort, "s");
+ ASSERT_NO_THROW(
+ d_solver.mkTerm(STRING_IN_REGEXP, s, d_solver.mkRegexpNone()));
+}
+
TEST_F(TestApiBlackSolver, mkSepEmp) { ASSERT_NO_THROW(d_solver.mkSepEmp()); }
TEST_F(TestApiBlackSolver, mkSepNil)
@@ -1351,7 +1361,8 @@ TEST_F(TestApiBlackSolver, getOptionInfo)
api::OptionInfo info = d_solver.getOptionInfo("verbosity");
EXPECT_EQ("verbosity", info.name);
EXPECT_EQ(std::vector<std::string>{}, info.aliases);
- EXPECT_TRUE(std::holds_alternative<OptionInfo::NumberInfo<int64_t>>(info.valueInfo));
+ EXPECT_TRUE(std::holds_alternative<OptionInfo::NumberInfo<int64_t>>(
+ info.valueInfo));
auto numInfo = std::get<OptionInfo::NumberInfo<int64_t>>(info.valueInfo);
EXPECT_EQ(0, numInfo.defaultValue);
EXPECT_EQ(0, numInfo.currentValue);
@@ -1362,7 +1373,8 @@ TEST_F(TestApiBlackSolver, getOptionInfo)
auto info = d_solver.getOptionInfo("random-freq");
ASSERT_EQ(info.name, "random-freq");
ASSERT_EQ(info.aliases, std::vector<std::string>{"random-frequency"});
- ASSERT_TRUE(std::holds_alternative<api::OptionInfo::NumberInfo<double>>(info.valueInfo));
+ ASSERT_TRUE(std::holds_alternative<api::OptionInfo::NumberInfo<double>>(
+ info.valueInfo));
auto ni = std::get<api::OptionInfo::NumberInfo<double>>(info.valueInfo);
ASSERT_EQ(ni.currentValue, 0.0);
ASSERT_EQ(ni.defaultValue, 0.0);
@@ -2540,7 +2552,6 @@ TEST_F(TestApiBlackSolver, Output)
ASSERT_NE(cvc5::null_os.rdbuf(), d_solver.getOutput("inst").rdbuf());
}
-
TEST_F(TestApiBlackSolver, issue7000)
{
Sort s1 = d_solver.getIntegerSort();
diff --git a/test/unit/api/solver_white.cpp b/test/unit/api/cpp/solver_white.cpp
index 5d7b9eacf..5d7b9eacf 100644
--- a/test/unit/api/solver_white.cpp
+++ b/test/unit/api/cpp/solver_white.cpp
diff --git a/test/unit/api/sort_black.cpp b/test/unit/api/cpp/sort_black.cpp
index d0c755cf7..d0c755cf7 100644
--- a/test/unit/api/sort_black.cpp
+++ b/test/unit/api/cpp/sort_black.cpp
diff --git a/test/unit/api/term_black.cpp b/test/unit/api/cpp/term_black.cpp
index 9e52174b4..c76182e47 100644
--- a/test/unit/api/term_black.cpp
+++ b/test/unit/api/cpp/term_black.cpp
@@ -212,6 +212,21 @@ TEST_F(TestApiBlackTerm, getOp)
ASSERT_EQ(headTerm, d_solver.mkTerm(headTerm.getOp(), children));
}
+TEST_F(TestApiBlackTerm, hasGetSymbol)
+{
+ Term n;
+ Term t = d_solver.mkBoolean(true);
+ Term c = d_solver.mkConst(d_solver.getBooleanSort(), "|\\|");
+
+ ASSERT_THROW(n.hasSymbol(), CVC5ApiException);
+ ASSERT_FALSE(t.hasSymbol());
+ ASSERT_TRUE(c.hasSymbol());
+
+ ASSERT_THROW(n.getSymbol(), CVC5ApiException);
+ ASSERT_THROW(t.getSymbol(), CVC5ApiException);
+ ASSERT_EQ(c.getSymbol(), "|\\|");
+}
+
TEST_F(TestApiBlackTerm, isNull)
{
Term x;
@@ -807,10 +822,12 @@ TEST_F(TestApiBlackTerm, getReal)
ASSERT_EQ((std::pair<int64_t, uint64_t>(127, 10)), real5.getReal64Value());
ASSERT_EQ("127/10", real5.getRealValue());
- ASSERT_EQ((std::pair<int64_t, uint64_t>(1, 4294967297)), real6.getReal64Value());
+ ASSERT_EQ((std::pair<int64_t, uint64_t>(1, 4294967297)),
+ real6.getReal64Value());
ASSERT_EQ("1/4294967297", real6.getRealValue());
- ASSERT_EQ((std::pair<int64_t, uint64_t>(4294967297, 1)), real7.getReal64Value());
+ ASSERT_EQ((std::pair<int64_t, uint64_t>(4294967297, 1)),
+ real7.getReal64Value());
ASSERT_EQ("4294967297/1", real7.getRealValue());
ASSERT_EQ("1/18446744073709551617", real8.getRealValue());
diff --git a/test/unit/api/term_white.cpp b/test/unit/api/cpp/term_white.cpp
index ace5645dc..ace5645dc 100644
--- a/test/unit/api/term_white.cpp
+++ b/test/unit/api/cpp/term_white.cpp
diff --git a/test/unit/api/java/SolverTest.java b/test/unit/api/java/SolverTest.java
index 161854421..6a08d79c6 100644
--- a/test/unit/api/java/SolverTest.java
+++ b/test/unit/api/java/SolverTest.java
@@ -639,6 +639,13 @@ class SolverTest
assertDoesNotThrow(() -> d_solver.mkTerm(STRING_IN_REGEXP, s, d_solver.mkRegexpNone()));
}
+ @Test void mkRegexpAll()
+ {
+ Sort strSort = d_solver.getStringSort();
+ Term s = d_solver.mkConst(strSort, "s");
+ assertDoesNotThrow(() -> d_solver.mkTerm(STRING_IN_REGEXP, s, d_solver.mkRegexpAll()));
+ }
+
@Test void mkRegexpAllchar()
{
Sort strSort = d_solver.getStringSort();
diff --git a/test/unit/api/java/TermTest.java b/test/unit/api/java/TermTest.java
index bf0beb024..b7f111428 100644
--- a/test/unit/api/java/TermTest.java
+++ b/test/unit/api/java/TermTest.java
@@ -219,6 +219,21 @@ class TermTest
Term nilOpTerm = list.getConstructorTerm("nil");
}
+ @Test void hasGetSymbol() throws CVC5ApiException
+ {
+ Term n = d_solver.getNullTerm();
+ Term t = d_solver.mkBoolean(true);
+ Term c = d_solver.mkConst(d_solver.getBooleanSort(), "|\\|");
+
+ assertThrows(CVC5ApiException.class, () -> n.hasSymbol());
+ assertFalse(t.hasSymbol());
+ assertTrue(c.hasSymbol());
+
+ assertThrows(CVC5ApiException.class, () -> n.getSymbol());
+ assertThrows(CVC5ApiException.class, () -> t.getSymbol());
+ assertEquals(c.getSymbol(), "|\\|");
+ }
+
@Test void isNull() throws CVC5ApiException
{
Term x = d_solver.getNullTerm();
diff --git a/test/unit/api/python/CMakeLists.txt b/test/unit/api/python/CMakeLists.txt
new file mode 100644
index 000000000..cbf9629ce
--- /dev/null
+++ b/test/unit/api/python/CMakeLists.txt
@@ -0,0 +1,40 @@
+###############################################################################
+# Top contributors (to current version):
+# Yoni Zohar, Aina Niemetz, Mathias Preiner
+#
+# 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.
+# #############################################################################
+#
+# The build system configuration.
+##
+
+# Check if the pytest Python module is installed.
+check_python_module("pytest")
+
+# Add Python bindings API tests.
+macro(cvc5_add_python_api_unit_test name filename)
+# We create test target 'python/unit/api/myapitest' and run it with
+# 'ctest -R "python/unit/api/myapitest"'.
+ set(test_name unit/api/python/${name})
+ add_test (NAME ${test_name}
+ COMMAND ${PYTHON_EXECUTABLE}
+ -m pytest ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
+ # directory for importing the python bindings
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/src/api/python)
+ set_tests_properties(${test_name} PROPERTIES LABELS "unit")
+endmacro()
+
+# add specific test files
+cvc5_add_python_api_unit_test(pytest_solver test_solver.py)
+cvc5_add_python_api_unit_test(pytest_sort test_sort.py)
+cvc5_add_python_api_unit_test(pytest_term test_term.py)
+cvc5_add_python_api_unit_test(pytest_datatype_api test_datatype_api.py)
+cvc5_add_python_api_unit_test(pytest_grammar test_grammar.py)
+cvc5_add_python_api_unit_test(pytest_to_python_obj test_to_python_obj.py)
+cvc5_add_python_api_unit_test(pytest_op test_op.py)
+cvc5_add_python_api_unit_test(pytest_result test_result.py)
diff --git a/test/python/unit/api/__init__.py b/test/unit/api/python/__init__.py
index e69de29bb..e69de29bb 100644
--- a/test/python/unit/api/__init__.py
+++ b/test/unit/api/python/__init__.py
diff --git a/test/python/unit/api/test_datatype_api.py b/test/unit/api/python/test_datatype_api.py
index d8a4c26f7..d8a4c26f7 100644
--- a/test/python/unit/api/test_datatype_api.py
+++ b/test/unit/api/python/test_datatype_api.py
diff --git a/test/python/unit/api/test_grammar.py b/test/unit/api/python/test_grammar.py
index db567a6ba..db567a6ba 100644
--- a/test/python/unit/api/test_grammar.py
+++ b/test/unit/api/python/test_grammar.py
diff --git a/test/python/unit/api/test_op.py b/test/unit/api/python/test_op.py
index 5126a481d..5126a481d 100644
--- a/test/python/unit/api/test_op.py
+++ b/test/unit/api/python/test_op.py
diff --git a/test/python/unit/api/test_result.py b/test/unit/api/python/test_result.py
index bd97646f9..bd97646f9 100644
--- a/test/python/unit/api/test_result.py
+++ b/test/unit/api/python/test_result.py
diff --git a/test/python/unit/api/test_solver.py b/test/unit/api/python/test_solver.py
index 71ab17465..89e99bd9e 100644
--- a/test/python/unit/api/test_solver.py
+++ b/test/unit/api/python/test_solver.py
@@ -643,13 +643,19 @@ def test_mk_real(solver):
solver.mkReal(val4, val4)
-def test_mk_regexp_empty(solver):
+def test_mk_regexp_none(solver):
strSort = solver.getStringSort()
s = solver.mkConst(strSort, "s")
solver.mkTerm(kinds.StringInRegexp, s, solver.mkRegexpNone())
-def test_mk_regexp_sigma(solver):
+def test_mk_regexp_all(solver):
+ strSort = solver.getStringSort()
+ s = solver.mkConst(strSort, "s")
+ solver.mkTerm(kinds.StringInRegexp, s, solver.mkRegexpAll())
+
+
+def test_mk_regexp_allchar(solver):
strSort = solver.getStringSort()
s = solver.mkConst(strSort, "s")
solver.mkTerm(kinds.StringInRegexp, s, solver.mkRegexpAllchar())
diff --git a/test/python/unit/api/test_sort.py b/test/unit/api/python/test_sort.py
index 98cf76d76..98cf76d76 100644
--- a/test/python/unit/api/test_sort.py
+++ b/test/unit/api/python/test_sort.py
diff --git a/test/python/unit/api/test_term.py b/test/unit/api/python/test_term.py
index 34a79d597..49314638f 100644
--- a/test/python/unit/api/test_term.py
+++ b/test/unit/api/python/test_term.py
@@ -208,6 +208,23 @@ def test_get_op(solver):
assert headTerm == solver.mkTerm(headTerm.getOp(), children)
+def test_has_get_symbol(solver):
+ n = Term(solver)
+ t = solver.mkBoolean(True)
+ c = solver.mkConst(solver.getBooleanSort(), "|\\|")
+
+ with pytest.raises(RuntimeError):
+ n.hasSymbol()
+ assert not t.hasSymbol()
+ assert c.hasSymbol()
+
+ with pytest.raises(RuntimeError):
+ n.getSymbol()
+ with pytest.raises(RuntimeError):
+ t.getSymbol()
+ assert c.getSymbol() == "|\\|"
+
+
def test_is_null(solver):
x = Term(solver)
assert x.isNull()
diff --git a/test/python/unit/api/test_to_python_obj.py b/test/unit/api/python/test_to_python_obj.py
index bb30fae8f..bb30fae8f 100644
--- a/test/python/unit/api/test_to_python_obj.py
+++ b/test/unit/api/python/test_to_python_obj.py
diff --git a/test/unit/node/node_algorithm_black.cpp b/test/unit/node/node_algorithm_black.cpp
index df8fb9383..8dac2cfda 100644
--- a/test/unit/node/node_algorithm_black.cpp
+++ b/test/unit/node/node_algorithm_black.cpp
@@ -140,8 +140,8 @@ TEST_F(TestNodeBlackNodeAlgorithm, match)
{
TypeNode integer = d_nodeManager->integerType();
- Node one = d_nodeManager->mkConst(Rational(1));
- Node two = d_nodeManager->mkConst(Rational(2));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
Node x = d_nodeManager->mkBoundVar(integer);
Node a = d_skolemManager->mkDummySkolem("a", integer);
diff --git a/test/unit/node/node_black.cpp b/test/unit/node/node_black.cpp
index b170ccbb6..50e766e61 100644
--- a/test/unit/node/node_black.cpp
+++ b/test/unit/node/node_black.cpp
@@ -732,15 +732,15 @@ TEST_F(TestNodeBlackNode, isConst)
Node cons_1_nil =
d_nodeManager->mkNode(APPLY_CONSTRUCTOR,
cons,
- d_nodeManager->mkConst(Rational(1)),
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)),
d_nodeManager->mkNode(APPLY_CONSTRUCTOR, nil));
Node cons_1_cons_2_nil = d_nodeManager->mkNode(
APPLY_CONSTRUCTOR,
cons,
- d_nodeManager->mkConst(Rational(1)),
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)),
d_nodeManager->mkNode(APPLY_CONSTRUCTOR,
cons,
- d_nodeManager->mkConst(Rational(2)),
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(2)),
d_nodeManager->mkNode(APPLY_CONSTRUCTOR, nil)));
ASSERT_TRUE(d_nodeManager->mkNode(APPLY_CONSTRUCTOR, nil).isConst());
ASSERT_FALSE(cons_x_nil.isConst());
@@ -749,8 +749,8 @@ TEST_F(TestNodeBlackNode, isConst)
TypeNode arrType = d_nodeManager->mkArrayType(d_nodeManager->integerType(),
d_nodeManager->integerType());
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
Node storeAll = d_nodeManager->mkConst(ArrayStoreAll(arrType, zero));
ASSERT_TRUE(storeAll.isConst());
diff --git a/test/unit/node/node_builder_black.cpp b/test/unit/node/node_builder_black.cpp
index 05ccfc90c..779397e04 100644
--- a/test/unit/node/node_builder_black.cpp
+++ b/test/unit/node/node_builder_black.cpp
@@ -312,7 +312,7 @@ TEST_F(TestNodeBlackNodeBuilder, append)
Node p = d_nodeManager->mkNode(
EQUAL,
- d_nodeManager->mkConst<Rational>(0),
+ d_nodeManager->mkConst<Rational>(CONST_RATIONAL, 0),
d_nodeManager->mkNode(PLUS, r, d_nodeManager->mkNode(UMINUS, s), t));
Node q = d_nodeManager->mkNode(AND, x, z, d_nodeManager->mkNode(NOT, y));
diff --git a/test/unit/node/node_manager_black.cpp b/test/unit/node/node_manager_black.cpp
index b02790cb5..ad41155c3 100644
--- a/test/unit/node/node_manager_black.cpp
+++ b/test/unit/node/node_manager_black.cpp
@@ -140,7 +140,7 @@ TEST_F(TestNodeBlackNodeManager, mkConst_bool)
TEST_F(TestNodeBlackNodeManager, mkConst_rational)
{
Rational r("3/2");
- Node n = d_nodeManager->mkConst(r);
+ Node n = d_nodeManager->mkConst(CONST_RATIONAL, r);
ASSERT_EQ(n.getConst<Rational>(), r);
}
diff --git a/test/unit/node/node_manager_white.cpp b/test/unit/node/node_manager_white.cpp
index fe06f85d3..64f6a70f5 100644
--- a/test/unit/node/node_manager_white.cpp
+++ b/test/unit/node/node_manager_white.cpp
@@ -23,6 +23,7 @@
namespace cvc5 {
using namespace cvc5::expr;
+using namespace cvc5::kind;
namespace test {
@@ -33,8 +34,8 @@ class TestNodeWhiteNodeManager : public TestNode
TEST_F(TestNodeWhiteNodeManager, mkConst_rational)
{
Rational i("3");
- Node n = d_nodeManager->mkConst(i);
- Node m = d_nodeManager->mkConst(i);
+ Node n = d_nodeManager->mkConst(CONST_RATIONAL, i);
+ Node m = d_nodeManager->mkConst(CONST_RATIONAL, i);
ASSERT_EQ(n.getId(), m.getId());
}
diff --git a/test/unit/node/node_white.cpp b/test/unit/node/node_white.cpp
index eb6f77bdc..8061526d5 100644
--- a/test/unit/node/node_white.cpp
+++ b/test/unit/node/node_white.cpp
@@ -49,7 +49,7 @@ TEST_F(TestNodeWhiteNode, iterators)
Node x = d_nodeManager->mkVar("x", d_nodeManager->integerType());
Node y = d_nodeManager->mkVar("y", d_nodeManager->integerType());
Node x_plus_y = d_nodeManager->mkNode(PLUS, x, y);
- Node two = d_nodeManager->mkConst(Rational(2));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
Node x_times_2 = d_nodeManager->mkNode(MULT, x, two);
Node n = d_nodeManager->mkNode(PLUS, x_times_2, x_plus_y, y);
diff --git a/test/unit/node/type_node_white.cpp b/test/unit/node/type_node_white.cpp
index 9f93017f0..424fee989 100644
--- a/test/unit/node/type_node_white.cpp
+++ b/test/unit/node/type_node_white.cpp
@@ -50,7 +50,8 @@ TEST_F(TestNodeWhiteTypeNode, sub_types)
TypeNode bvType = d_nodeManager->mkBitVectorType(32);
Node x = d_nodeManager->mkBoundVar("x", realType);
- Node xPos = d_nodeManager->mkNode(GT, x, d_nodeManager->mkConst(Rational(0)));
+ Node xPos = d_nodeManager->mkNode(
+ GT, x, d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)));
TypeNode funtype = d_nodeManager->mkFunctionType(integerType, booleanType);
Node lambda = d_nodeManager->mkVar("lambda", funtype);
std::vector<Node> formals;
diff --git a/test/unit/preprocessing/pass_foreign_theory_rewrite_white.cpp b/test/unit/preprocessing/pass_foreign_theory_rewrite_white.cpp
index a6af29315..6687f2459 100644
--- a/test/unit/preprocessing/pass_foreign_theory_rewrite_white.cpp
+++ b/test/unit/preprocessing/pass_foreign_theory_rewrite_white.cpp
@@ -19,10 +19,10 @@
#include "test_smt.h"
#include "util/rational.h"
-namespace cvc5 {
-
-using namespace preprocessing::passes;
+using namespace cvc5::kind;
+using namespace cvc5::preprocessing::passes;
+namespace cvc5 {
namespace test {
class TestPPWhiteForeignTheoryRewrite : public TestSmt
@@ -35,7 +35,7 @@ TEST_F(TestPPWhiteForeignTheoryRewrite, simplify)
std::cout << "len(x) >= 0 is simplified to true" << std::endl;
Node x = d_nodeManager->mkVar("x", d_nodeManager->stringType());
Node len_x = d_nodeManager->mkNode(kind::STRING_LENGTH, x);
- Node zero = d_nodeManager->mkConst<Rational>(0);
+ Node zero = d_nodeManager->mkConst<Rational>(CONST_RATIONAL, 0);
Node geq1 = d_nodeManager->mkNode(kind::GEQ, len_x, zero);
Node tt = d_nodeManager->mkConst<bool>(true);
Node simplified1 = ftr.foreignRewrite(geq1);
diff --git a/test/unit/theory/CMakeLists.txt b/test/unit/theory/CMakeLists.txt
index 15c5e8570..9a0a3e26d 100644
--- a/test/unit/theory/CMakeLists.txt
+++ b/test/unit/theory/CMakeLists.txt
@@ -35,6 +35,7 @@ cvc5_add_unit_test_white(theory_int_opt_white theory)
cvc5_add_unit_test_white(theory_opt_multigoal_white theory)
cvc5_add_unit_test_white(theory_quantifiers_bv_instantiator_white theory)
cvc5_add_unit_test_white(theory_quantifiers_bv_inverter_white theory)
+cvc5_add_unit_test_white(theory_sets_rewriter_white theory)
cvc5_add_unit_test_white(theory_sets_type_enumerator_white theory)
cvc5_add_unit_test_white(theory_sets_type_rules_white theory)
cvc5_add_unit_test_white(theory_strings_skolem_cache_black theory)
diff --git a/test/unit/theory/arith_poly_white.cpp b/test/unit/theory/arith_poly_white.cpp
index 3e0bb6c17..9127fadff 100644
--- a/test/unit/theory/arith_poly_white.cpp
+++ b/test/unit/theory/arith_poly_white.cpp
@@ -40,9 +40,9 @@ class TestTheoryWhiteArithPolyNorm : public TestSmt
TEST_F(TestTheoryWhiteArithPolyNorm, check_poly_norm_int)
{
TypeNode intType = d_nodeManager->integerType();
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node two = d_nodeManager->mkConst(Rational(2));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
Node x = d_nodeManager->mkVar("x", intType);
Node y = d_nodeManager->mkVar("y", intType);
Node z = d_nodeManager->mkVar("z", intType);
@@ -101,10 +101,10 @@ TEST_F(TestTheoryWhiteArithPolyNorm, check_poly_norm_int)
TEST_F(TestTheoryWhiteArithPolyNorm, check_poly_norm_real)
{
TypeNode realType = d_nodeManager->realType();
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node half = d_nodeManager->mkConst(Rational(1) / Rational(2));
- Node two = d_nodeManager->mkConst(Rational(2));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node half = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1) / Rational(2));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
Node x = d_nodeManager->mkVar("x", realType);
Node y = d_nodeManager->mkVar("y", realType);
diff --git a/test/unit/theory/evaluator_white.cpp b/test/unit/theory/evaluator_white.cpp
index 438f28c2d..4ff6d174f 100644
--- a/test/unit/theory/evaluator_white.cpp
+++ b/test/unit/theory/evaluator_white.cpp
@@ -25,10 +25,10 @@
#include "theory/rewriter.h"
#include "util/rational.h"
-namespace cvc5 {
-
-using namespace theory;
+using namespace cvc5::kind;
+using namespace cvc5::theory;
+namespace cvc5 {
namespace test {
class TestTheoryWhiteEvaluator : public TestSmt
@@ -103,8 +103,8 @@ TEST_F(TestTheoryWhiteEvaluator, strIdOf)
{
Node a = d_nodeManager->mkConst(String("A"));
Node empty = d_nodeManager->mkConst(String(""));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node two = d_nodeManager->mkConst(Rational(2));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
std::vector<Node> args;
std::vector<Node> vals;
@@ -150,14 +150,14 @@ TEST_F(TestTheoryWhiteEvaluator, code)
{
Node n = d_nodeManager->mkNode(kind::STRING_TO_CODE, a);
Node r = eval.eval(n, args, vals);
- ASSERT_EQ(r, d_nodeManager->mkConst(Rational(65)));
+ ASSERT_EQ(r, d_nodeManager->mkConst(CONST_RATIONAL, Rational(65)));
}
// (str.code "") ---> -1
{
Node n = d_nodeManager->mkNode(kind::STRING_TO_CODE, empty);
Node r = eval.eval(n, args, vals);
- ASSERT_EQ(r, d_nodeManager->mkConst(Rational(-1)));
+ ASSERT_EQ(r, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1)));
}
}
} // namespace test
diff --git a/test/unit/theory/sequences_rewriter_white.cpp b/test/unit/theory/sequences_rewriter_white.cpp
index 165479b78..005e5cc3f 100644
--- a/test/unit/theory/sequences_rewriter_white.cpp
+++ b/test/unit/theory/sequences_rewriter_white.cpp
@@ -28,11 +28,11 @@
#include "util/rational.h"
#include "util/string.h"
-namespace cvc5 {
-
-using namespace theory;
-using namespace theory::strings;
+using namespace cvc5::kind;
+using namespace cvc5::theory;
+using namespace cvc5::theory::strings;
+namespace cvc5 {
namespace test {
class TestTheoryWhiteSequencesRewriter : public TestSmt
@@ -93,11 +93,11 @@ TEST_F(TestTheoryWhiteSequencesRewriter, check_entail_length_one)
Node b = d_nodeManager->mkConst(::cvc5::String("B"));
Node x = d_nodeManager->mkVar("x", strType);
Node y = d_nodeManager->mkVar("y", strType);
- Node negOne = d_nodeManager->mkConst(Rational(-1));
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node two = d_nodeManager->mkConst(Rational(2));
- Node three = d_nodeManager->mkConst(Rational(3));
+ Node negOne = d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
+ Node three = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
Node i = d_nodeManager->mkVar("i", intType);
ASSERT_TRUE(se.checkLengthOne(a));
@@ -128,7 +128,7 @@ TEST_F(TestTheoryWhiteSequencesRewriter, check_entail_arith)
Node z = d_nodeManager->mkVar("z", strType);
Node n = d_nodeManager->mkVar("n", intType);
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
// 1 >= (str.len (str.substr z n 1)) ---> true
Node substr_z = d_nodeManager->mkNode(
@@ -150,8 +150,8 @@ TEST_F(TestTheoryWhiteSequencesRewriter, check_entail_with_with_assumption)
Node y = d_nodeManager->mkVar("y", strType);
Node z = d_nodeManager->mkVar("z", intType);
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
Node empty = d_nodeManager->mkConst(::cvc5::String(""));
Node a = d_nodeManager->mkConst(::cvc5::String("A"));
@@ -184,8 +184,8 @@ TEST_F(TestTheoryWhiteSequencesRewriter, check_entail_with_with_assumption)
ASSERT_TRUE(ae.checkWithAssumption(
x_plus_slen_y_plus_slen_y_eq_zero, zero, x, false));
- Node five = d_nodeManager->mkConst(Rational(5));
- Node six = d_nodeManager->mkConst(Rational(6));
+ Node five = d_nodeManager->mkConst(CONST_RATIONAL, Rational(5));
+ Node six = d_nodeManager->mkConst(CONST_RATIONAL, Rational(6));
Node x_plus_five = d_nodeManager->mkNode(kind::PLUS, x, five);
Node x_plus_five_lt_six =
d_rewriter->rewrite(d_nodeManager->mkNode(kind::LT, x_plus_five, six));
@@ -226,11 +226,11 @@ TEST_F(TestTheoryWhiteSequencesRewriter, rewrite_substr)
Node a = d_nodeManager->mkConst(::cvc5::String("A"));
Node b = d_nodeManager->mkConst(::cvc5::String("B"));
Node abcd = d_nodeManager->mkConst(::cvc5::String("ABCD"));
- Node negone = d_nodeManager->mkConst(Rational(-1));
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node two = d_nodeManager->mkConst(Rational(2));
- Node three = d_nodeManager->mkConst(Rational(3));
+ Node negone = d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
+ Node three = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
Node s = d_nodeManager->mkVar("s", strType);
Node s2 = d_nodeManager->mkVar("s2", strType);
@@ -246,7 +246,8 @@ TEST_F(TestTheoryWhiteSequencesRewriter, rewrite_substr)
n = d_nodeManager->mkNode(
kind::STRING_SUBSTR,
a,
- d_nodeManager->mkNode(kind::PLUS, x, d_nodeManager->mkConst(Rational(1))),
+ d_nodeManager->mkNode(
+ kind::PLUS, x, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1))),
x);
sameNormalForm(n, empty);
@@ -362,8 +363,8 @@ TEST_F(TestTheoryWhiteSequencesRewriter, rewrite_concat)
Node empty = d_nodeManager->mkConst(::cvc5::String(""));
Node a = d_nodeManager->mkConst(::cvc5::String("A"));
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node three = d_nodeManager->mkConst(Rational(3));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node three = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
Node i = d_nodeManager->mkVar("i", intType);
Node s = d_nodeManager->mkVar("s", strType);
@@ -468,11 +469,11 @@ TEST_F(TestTheoryWhiteSequencesRewriter, rewrite_indexOf)
Node ccc = d_nodeManager->mkConst(::cvc5::String("CCC"));
Node x = d_nodeManager->mkVar("x", strType);
Node y = d_nodeManager->mkVar("y", strType);
- Node negOne = d_nodeManager->mkConst(Rational(-1));
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node two = d_nodeManager->mkConst(Rational(2));
- Node three = d_nodeManager->mkConst(Rational(3));
+ Node negOne = d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
+ Node three = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
Node i = d_nodeManager->mkVar("i", intType);
Node j = d_nodeManager->mkVar("j", intType);
@@ -549,8 +550,8 @@ TEST_F(TestTheoryWhiteSequencesRewriter, rewrite_replace)
Node x = d_nodeManager->mkVar("x", strType);
Node y = d_nodeManager->mkVar("y", strType);
Node z = d_nodeManager->mkVar("z", strType);
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
Node n = d_nodeManager->mkVar("n", intType);
// (str.replace (str.replace x "B" x) x "A") -->
@@ -970,10 +971,10 @@ TEST_F(TestTheoryWhiteSequencesRewriter, rewrite_contains)
Node z = d_nodeManager->mkVar("z", strType);
Node n = d_nodeManager->mkVar("n", intType);
Node m = d_nodeManager->mkVar("m", intType);
- Node one = d_nodeManager->mkConst(Rational(1));
- Node two = d_nodeManager->mkConst(Rational(2));
- Node three = d_nodeManager->mkConst(Rational(3));
- Node four = d_nodeManager->mkConst(Rational(4));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
+ Node three = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
+ Node four = d_nodeManager->mkConst(CONST_RATIONAL, Rational(4));
Node t = d_nodeManager->mkConst(true);
Node f = d_nodeManager->mkConst(false);
@@ -1396,9 +1397,9 @@ TEST_F(TestTheoryWhiteSequencesRewriter, rewrite_equality_ext)
Node xxa = d_nodeManager->mkNode(kind::STRING_CONCAT, x, x, a);
Node f = d_nodeManager->mkConst(false);
Node n = d_nodeManager->mkVar("n", intType);
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node three = d_nodeManager->mkConst(Rational(3));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node three = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
// Same normal form for:
//
diff --git a/test/unit/theory/theory_arith_cad_white.cpp b/test/unit/theory/theory_arith_cad_white.cpp
index 719b76cab..8d5ca9923 100644
--- a/test/unit/theory/theory_arith_cad_white.cpp
+++ b/test/unit/theory/theory_arith_cad_white.cpp
@@ -37,6 +37,7 @@
namespace cvc5::test {
using namespace cvc5;
+using namespace cvc5::kind;
using namespace cvc5::theory;
using namespace cvc5::theory::arith;
using namespace cvc5::theory::arith::nl;
@@ -54,7 +55,10 @@ class TestTheoryWhiteArithCAD : public TestSmt
nodeManager = d_nodeManager;
}
- Node dummy(int i) const { return d_nodeManager->mkConst(Rational(i)); }
+ Node dummy(int i) const
+ {
+ return d_nodeManager->mkConst(CONST_RATIONAL, Rational(i));
+ }
Theory::Effort d_level = Theory::EFFORT_FULL;
std::unique_ptr<TypeNode> d_realType;
@@ -181,14 +185,15 @@ TEST_F(TestTheoryWhiteArithCAD, lazard_simp)
Node a = d_nodeManager->mkVar(*d_realType);
Node c = d_nodeManager->mkVar(*d_realType);
Node orig = d_nodeManager->mkAnd(std::vector<Node>{
- d_nodeManager->mkNode(Kind::EQUAL, a, d_nodeManager->mkConst(d_zero)),
+ d_nodeManager->mkNode(
+ Kind::EQUAL, a, d_nodeManager->mkConst(CONST_RATIONAL, d_zero)),
d_nodeManager->mkNode(
Kind::EQUAL,
d_nodeManager->mkNode(
Kind::PLUS,
d_nodeManager->mkNode(Kind::NONLINEAR_MULT, a, c),
- d_nodeManager->mkConst(d_one)),
- d_nodeManager->mkConst(d_zero))});
+ d_nodeManager->mkConst(CONST_RATIONAL, d_one)),
+ d_nodeManager->mkConst(CONST_RATIONAL, d_zero))});
{
Node rewritten = Rewriter::rewrite(orig);
@@ -356,10 +361,10 @@ void test_delta(const std::vector<Node>& a)
TEST_F(TestTheoryWhiteArithCAD, test_delta_one)
{
std::vector<Node> a;
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node mone = d_nodeManager->mkConst(Rational(-1));
- Node fifth = d_nodeManager->mkConst(Rational(1, 2));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node mone = d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1));
+ Node fifth = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 2));
Node g = make_real_variable("g");
Node l = make_real_variable("l");
Node q = make_real_variable("q");
@@ -379,10 +384,10 @@ TEST_F(TestTheoryWhiteArithCAD, test_delta_one)
TEST_F(TestTheoryWhiteArithCAD, test_delta_two)
{
std::vector<Node> a;
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node mone = d_nodeManager->mkConst(Rational(-1));
- Node fifth = d_nodeManager->mkConst(Rational(1, 2));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node mone = d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1));
+ Node fifth = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 2));
Node g = make_real_variable("g");
Node l = make_real_variable("l");
Node q = make_real_variable("q");
diff --git a/test/unit/theory/theory_arith_pow2_white.cpp b/test/unit/theory/theory_arith_pow2_white.cpp
index 697073434..fd942c5b5 100644
--- a/test/unit/theory/theory_arith_pow2_white.cpp
+++ b/test/unit/theory/theory_arith_pow2_white.cpp
@@ -37,7 +37,7 @@ class TestTheoryWhiteArithPow2 : public TestSmtNoFinishInit
d_slvEngine->setOption("produce-models", "true");
d_slvEngine->finishInit();
d_true = d_nodeManager->mkConst<bool>(true);
- d_one = d_nodeManager->mkConst<Rational>(Rational(1));
+ d_one = d_nodeManager->mkConst<Rational>(CONST_RATIONAL, Rational(1));
}
Node d_true;
Node d_one;
diff --git a/test/unit/theory/theory_arith_white.cpp b/test/unit/theory/theory_arith_white.cpp
index a41378106..8805c7119 100644
--- a/test/unit/theory/theory_arith_white.cpp
+++ b/test/unit/theory/theory_arith_white.cpp
@@ -68,7 +68,7 @@ class TestTheoryWhiteArith : public TestSmtNoFinishInit
TEST_F(TestTheoryWhiteArith, assert)
{
Node x = d_nodeManager->mkVar(*d_realType);
- Node c = d_nodeManager->mkConst<Rational>(d_zero);
+ Node c = d_nodeManager->mkConst<Rational>(CONST_RATIONAL, d_zero);
Node gt = d_nodeManager->mkNode(GT, x, c);
Node leq = Rewriter::rewrite(gt.notNode());
@@ -83,9 +83,9 @@ TEST_F(TestTheoryWhiteArith, int_normal_form)
{
Node x = d_nodeManager->mkVar(*d_intType);
Node xr = d_nodeManager->mkVar(*d_realType);
- Node c0 = d_nodeManager->mkConst<Rational>(d_zero);
- Node c1 = d_nodeManager->mkConst<Rational>(d_one);
- Node c2 = d_nodeManager->mkConst<Rational>(Rational(2));
+ Node c0 = d_nodeManager->mkConst<Rational>(CONST_RATIONAL, d_zero);
+ Node c1 = d_nodeManager->mkConst<Rational>(CONST_RATIONAL, d_one);
+ Node c2 = d_nodeManager->mkConst<Rational>(CONST_RATIONAL, Rational(2));
Node geq0 = d_nodeManager->mkNode(GEQ, x, c0);
Node geq1 = d_nodeManager->mkNode(GEQ, x, c1);
diff --git a/test/unit/theory/theory_bags_normal_form_white.cpp b/test/unit/theory/theory_bags_normal_form_white.cpp
index 9634d55c2..5f3abfcee 100644
--- a/test/unit/theory/theory_bags_normal_form_white.cpp
+++ b/test/unit/theory/theory_bags_normal_form_white.cpp
@@ -72,15 +72,18 @@ TEST_F(TestTheoryWhiteBagsNormalForm, empty_bag_normal_form)
TEST_F(TestTheoryWhiteBagsNormalForm, mkBag_constant_element)
{
std::vector<Node> elements = getNStrings(1);
- Node negative = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(-1)));
- Node zero = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(0)));
- Node positive = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(1)));
+ Node negative = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1)));
+ Node zero =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)));
+ Node positive =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
Node emptybag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
@@ -95,25 +98,31 @@ TEST_F(TestTheoryWhiteBagsNormalForm, bag_count)
{
// Examples
// -------
- // (bag.count "x" (emptybag String)) = 0
- // (bag.count "x" (mkBag "y" 5)) = 0
- // (bag.count "x" (mkBag "x" 4)) = 4
- // (bag.count "x" (union_disjoint (mkBag "x" 4) (mkBag "y" 5)) = 4
- // (bag.count "x" (union_disjoint (mkBag "y" 5) (mkBag "z" 5)) = 0
-
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node four = d_nodeManager->mkConst(Rational(4));
+ // (bag.count "x" (as bag.empty (Bag String))) = 0
+ // (bag.count "x" (bag "y" 5)) = 0
+ // (bag.count "x" (bag "x" 4)) = 4
+ // (bag.count "x" (bag.union_disjoint (bag "x" 4) (bag "y" 5)) = 4
+ // (bag.count "x" (bag.union_disjoint (bag "y" 5) (bag "z" 5)) = 0
+
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node four = d_nodeManager->mkConst(CONST_RATIONAL, Rational(4));
Node empty = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
Node z = d_nodeManager->mkConst(String("z"));
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node y_5 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(5)));
- Node z_5 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), z, d_nodeManager->mkConst(Rational(5)));
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node y_5 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(5)));
+ Node z_5 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ z,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(5)));
Node input1 = d_nodeManager->mkNode(BAG_COUNT, x, empty);
Node output1 = zero;
@@ -127,12 +136,12 @@ TEST_F(TestTheoryWhiteBagsNormalForm, bag_count)
Node output3 = four;
ASSERT_EQ(output2, NormalForm::evaluate(input2));
- Node unionDisjointXY = d_nodeManager->mkNode(UNION_DISJOINT, x_4, y_5);
+ Node unionDisjointXY = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, y_5);
Node input4 = d_nodeManager->mkNode(BAG_COUNT, x, unionDisjointXY);
Node output4 = four;
ASSERT_EQ(output3, NormalForm::evaluate(input3));
- Node unionDisjointYZ = d_nodeManager->mkNode(UNION_DISJOINT, y_5, z_5);
+ Node unionDisjointYZ = d_nodeManager->mkNode(BAG_UNION_DISJOINT, y_5, z_5);
Node input5 = d_nodeManager->mkNode(BAG_COUNT, x, unionDisjointYZ);
Node output5 = zero;
ASSERT_EQ(output4, NormalForm::evaluate(input4));
@@ -142,37 +151,46 @@ TEST_F(TestTheoryWhiteBagsNormalForm, duplicate_removal)
{
// Examples
// --------
- // - (duplicate_removal (emptybag String)) = (emptybag String)
- // - (duplicate_removal (mkBag "x" 4)) = (emptybag "x" 1)
- // - (duplicate_removal (disjoint_union (mkBag "x" 3) (mkBag "y" 5)) =
- // (disjoint_union (mkBag "x" 1) (mkBag "y" 1)
+ // - (bag.duplicate_removal (as bag.empty (Bag String))) = (as bag.empty (Bag
+ // String))
+ // - (bag.duplicate_removal (bag "x" 4)) = (bag.empty"x" 1)
+ // - (bag.duplicate_removal (bag.union_disjoint(bag "x" 3) (bag "y" 5)) =
+ // (bag.union_disjoint(bag "x" 1) (bag "y" 1)
Node emptybag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
- Node input1 = d_nodeManager->mkNode(DUPLICATE_REMOVAL, emptybag);
+ Node input1 = d_nodeManager->mkNode(BAG_DUPLICATE_REMOVAL, emptybag);
Node output1 = emptybag;
ASSERT_EQ(output1, NormalForm::evaluate(input1));
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
- Node x_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(1)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
-
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node y_5 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(5)));
-
- Node input2 = d_nodeManager->mkNode(DUPLICATE_REMOVAL, x_4);
+ Node x_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node y_5 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(5)));
+
+ Node input2 = d_nodeManager->mkNode(BAG_DUPLICATE_REMOVAL, x_4);
Node output2 = x_1;
ASSERT_EQ(output2, NormalForm::evaluate(input2));
- Node normalBag = d_nodeManager->mkNode(UNION_DISJOINT, x_4, y_5);
- Node input3 = d_nodeManager->mkNode(DUPLICATE_REMOVAL, normalBag);
- Node output3 = d_nodeManager->mkNode(UNION_DISJOINT, x_1, y_1);
+ Node normalBag = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, y_5);
+ Node input3 = d_nodeManager->mkNode(BAG_DUPLICATE_REMOVAL, normalBag);
+ Node output3 = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_1, y_1);
ASSERT_EQ(output3, NormalForm::evaluate(input3));
}
@@ -180,35 +198,47 @@ TEST_F(TestTheoryWhiteBagsNormalForm, union_max)
{
// Example
// -------
- // input: (union_max A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.union_max A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (union_disjoint A B)
- // where A = (MK_BAG "x" 4)
- // B = (union_disjoint (MK_BAG "y" 1) (MK_BAG "z" 2)))
+ // (bag.union_disjoint A B)
+ // where A = (bag "x" 4)
+ // B = (bag.union_disjoint (bag "y" 1) (bag "z" 2)))
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
Node z = d_nodeManager->mkConst(String("z"));
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node x_3 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(3)));
- Node x_7 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(7)));
- Node z_2 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), z, d_nodeManager->mkConst(Rational(2)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
-
- Node A = d_nodeManager->mkNode(UNION_DISJOINT, x_4, z_2);
- Node B = d_nodeManager->mkNode(UNION_DISJOINT, x_3, y_1);
- Node input = d_nodeManager->mkNode(UNION_MAX, A, B);
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node x_3 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(3)));
+ Node x_7 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(7)));
+ Node z_2 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ z,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(2)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+
+ Node A = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, z_2);
+ Node B = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_3, y_1);
+ Node input = d_nodeManager->mkNode(BAG_UNION_MAX, A, B);
// output
Node output = d_nodeManager->mkNode(
- UNION_DISJOINT, x_4, d_nodeManager->mkNode(UNION_DISJOINT, y_1, z_2));
+ BAG_UNION_DISJOINT,
+ x_4,
+ d_nodeManager->mkNode(BAG_UNION_DISJOINT, y_1, z_2));
ASSERT_TRUE(output.isConst());
ASSERT_EQ(output, NormalForm::evaluate(input));
@@ -219,40 +249,44 @@ TEST_F(TestTheoryWhiteBagsNormalForm, union_disjoint1)
std::vector<Node> elements = getNStrings(3);
Node emptybag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
- Node A = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(2)));
- Node B = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[1],
- d_nodeManager->mkConst(Rational(3)));
- Node C = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[2],
- d_nodeManager->mkConst(Rational(4)));
-
- Node unionDisjointAB = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
+ Node A =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(2)));
+ Node B =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[1],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(3)));
+ Node C =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[2],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+
+ Node unionDisjointAB = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
// unionDisjointAB is already in a normal form
ASSERT_TRUE(unionDisjointAB.isConst());
ASSERT_EQ(unionDisjointAB, NormalForm::evaluate(unionDisjointAB));
- Node unionDisjointBA = d_nodeManager->mkNode(UNION_DISJOINT, B, A);
- // unionDisjointAB is is the normal form of unionDisjointBA
+ Node unionDisjointBA = d_nodeManager->mkNode(BAG_UNION_DISJOINT, B, A);
+ // unionDisjointAB is the normal form of unionDisjointBA
ASSERT_FALSE(unionDisjointBA.isConst());
ASSERT_EQ(unionDisjointAB, NormalForm::evaluate(unionDisjointBA));
Node unionDisjointAB_C =
- d_nodeManager->mkNode(UNION_DISJOINT, unionDisjointAB, C);
- Node unionDisjointBC = d_nodeManager->mkNode(UNION_DISJOINT, B, C);
+ d_nodeManager->mkNode(BAG_UNION_DISJOINT, unionDisjointAB, C);
+ Node unionDisjointBC = d_nodeManager->mkNode(BAG_UNION_DISJOINT, B, C);
Node unionDisjointA_BC =
- d_nodeManager->mkNode(UNION_DISJOINT, A, unionDisjointBC);
+ d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, unionDisjointBC);
// unionDisjointA_BC is the normal form of unionDisjointAB_C
ASSERT_FALSE(unionDisjointAB_C.isConst());
ASSERT_TRUE(unionDisjointA_BC.isConst());
ASSERT_EQ(unionDisjointA_BC, NormalForm::evaluate(unionDisjointAB_C));
- Node unionDisjointAA = d_nodeManager->mkNode(UNION_DISJOINT, A, A);
- Node AA = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(4)));
+ Node unionDisjointAA = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, A);
+ Node AA =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
ASSERT_FALSE(unionDisjointAA.isConst());
ASSERT_TRUE(AA.isConst());
ASSERT_EQ(AA, NormalForm::evaluate(unionDisjointAA));
@@ -262,35 +296,47 @@ TEST_F(TestTheoryWhiteBagsNormalForm, union_disjoint2)
{
// Example
// -------
- // input: (union_disjoint A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.union_disjoint A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (union_disjoint A B)
- // where A = (MK_BAG "x" 7)
- // B = (union_disjoint (MK_BAG "y" 1) (MK_BAG "z" 2)))
+ // (bag.union_disjoint A B)
+ // where A = (bag "x" 7)
+ // B = (bag.union_disjoint (bag "y" 1) (bag "z" 2)))
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
Node z = d_nodeManager->mkConst(String("z"));
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node x_3 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(3)));
- Node x_7 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(7)));
- Node z_2 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), z, d_nodeManager->mkConst(Rational(2)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
-
- Node A = d_nodeManager->mkNode(UNION_DISJOINT, x_4, z_2);
- Node B = d_nodeManager->mkNode(UNION_DISJOINT, x_3, y_1);
- Node input = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node x_3 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(3)));
+ Node x_7 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(7)));
+ Node z_2 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ z,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(2)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+
+ Node A = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, z_2);
+ Node B = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_3, y_1);
+ Node input = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
// output
Node output = d_nodeManager->mkNode(
- UNION_DISJOINT, x_7, d_nodeManager->mkNode(UNION_DISJOINT, y_1, z_2));
+ BAG_UNION_DISJOINT,
+ x_7,
+ d_nodeManager->mkNode(BAG_UNION_DISJOINT, y_1, z_2));
ASSERT_TRUE(output.isConst());
ASSERT_EQ(output, NormalForm::evaluate(input));
@@ -300,29 +346,39 @@ TEST_F(TestTheoryWhiteBagsNormalForm, intersection_min)
{
// Example
// -------
- // input: (intersection_min A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.inter_min A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (MK_BAG "x" 3)
+ // (bag "x" 3)
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
Node z = d_nodeManager->mkConst(String("z"));
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node x_3 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(3)));
- Node x_7 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(7)));
- Node z_2 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), z, d_nodeManager->mkConst(Rational(2)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
-
- Node A = d_nodeManager->mkNode(UNION_DISJOINT, x_4, z_2);
- Node B = d_nodeManager->mkNode(UNION_DISJOINT, x_3, y_1);
- Node input = d_nodeManager->mkNode(INTERSECTION_MIN, A, B);
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node x_3 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(3)));
+ Node x_7 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(7)));
+ Node z_2 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ z,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(2)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+
+ Node A = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, z_2);
+ Node B = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_3, y_1);
+ Node input = d_nodeManager->mkNode(BAG_INTER_MIN, A, B);
// output
Node output = x_3;
@@ -335,34 +391,46 @@ TEST_F(TestTheoryWhiteBagsNormalForm, difference_subtract)
{
// Example
// -------
- // input: (difference_subtract A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.difference_subtract A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (union_disjoint (MK_BAG "x" 1) (MK_BAG "z" 2))
+ // (bag.union_disjoint (bag "x" 1) (bag "z" 2))
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
Node z = d_nodeManager->mkConst(String("z"));
- Node x_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(1)));
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node x_3 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(3)));
- Node x_7 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(7)));
- Node z_2 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), z, d_nodeManager->mkConst(Rational(2)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
-
- Node A = d_nodeManager->mkNode(UNION_DISJOINT, x_4, z_2);
- Node B = d_nodeManager->mkNode(UNION_DISJOINT, x_3, y_1);
- Node input = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, A, B);
+ Node x_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node x_3 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(3)));
+ Node x_7 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(7)));
+ Node z_2 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ z,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(2)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+
+ Node A = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, z_2);
+ Node B = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_3, y_1);
+ Node input = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, A, B);
// output
- Node output = d_nodeManager->mkNode(UNION_DISJOINT, x_1, z_2);
+ Node output = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_1, z_2);
ASSERT_TRUE(output.isConst());
ASSERT_EQ(output, NormalForm::evaluate(input));
@@ -372,31 +440,43 @@ TEST_F(TestTheoryWhiteBagsNormalForm, difference_remove)
{
// Example
// -------
- // input: (difference_remove A B)
- // where A = (union_disjoint (MK_BAG "x" 4) (MK_BAG "z" 2)))
- // B = (union_disjoint (MK_BAG "x" 3) (MK_BAG "y" 1)))
+ // input: (bag.difference_remove A B)
+ // where A = (bag.union_disjoint (bag "x" 4) (bag "z" 2)))
+ // B = (bag.union_disjoint (bag "x" 3) (bag "y" 1)))
// output:
- // (MK_BAG "z" 2)
+ // (bag "z" 2)
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
Node z = d_nodeManager->mkConst(String("z"));
- Node x_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(1)));
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node x_3 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(3)));
- Node x_7 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(7)));
- Node z_2 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), z, d_nodeManager->mkConst(Rational(2)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
-
- Node A = d_nodeManager->mkNode(UNION_DISJOINT, x_4, z_2);
- Node B = d_nodeManager->mkNode(UNION_DISJOINT, x_3, y_1);
- Node input = d_nodeManager->mkNode(DIFFERENCE_REMOVE, A, B);
+ Node x_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node x_3 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(3)));
+ Node x_7 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(7)));
+ Node z_2 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ z,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(2)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+
+ Node A = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, z_2);
+ Node B = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_3, y_1);
+ Node input = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, A, B);
// output
Node output = z_2;
@@ -409,31 +489,35 @@ TEST_F(TestTheoryWhiteBagsNormalForm, bag_card)
{
// Examples
// --------
- // - (card (emptybag String)) = 0
- // - (choose (MK_BAG "x" 4)) = 4
- // - (choose (union_disjoint (MK_BAG "x" 4) (MK_BAG "y" 1))) = 5
+ // - (bag.card (as bag.empty (Bag String))) = 0
+ // - (bag.choose (bag "x" 4)) = 4
+ // - (bag.choose (bag.union_disjoint (bag "x" 4) (bag "y" 1))) = 5
Node empty = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
Node z = d_nodeManager->mkConst(String("z"));
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
Node input1 = d_nodeManager->mkNode(BAG_CARD, empty);
- Node output1 = d_nodeManager->mkConst(Rational(0));
+ Node output1 = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
ASSERT_EQ(output1, NormalForm::evaluate(input1));
Node input2 = d_nodeManager->mkNode(BAG_CARD, x_4);
- Node output2 = d_nodeManager->mkConst(Rational(4));
+ Node output2 = d_nodeManager->mkConst(CONST_RATIONAL, Rational(4));
ASSERT_EQ(output2, NormalForm::evaluate(input2));
- Node union_disjoint = d_nodeManager->mkNode(UNION_DISJOINT, x_4, y_1);
+ Node union_disjoint = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, y_1);
Node input3 = d_nodeManager->mkNode(BAG_CARD, union_disjoint);
- Node output3 = d_nodeManager->mkConst(Rational(5));
+ Node output3 = d_nodeManager->mkConst(CONST_RATIONAL, Rational(5));
ASSERT_EQ(output3, NormalForm::evaluate(input3));
}
@@ -441,10 +525,10 @@ TEST_F(TestTheoryWhiteBagsNormalForm, is_singleton)
{
// Examples
// --------
- // - (bag.is_singleton (emptybag String)) = false
- // - (bag.is_singleton (MK_BAG "x" 1)) = true
- // - (bag.is_singleton (MK_BAG "x" 4)) = false
- // - (bag.is_singleton (union_disjoint (MK_BAG "x" 1) (MK_BAG "y" 1))) =
+ // - (bag.is_singleton (as bag.empty (Bag String))) = false
+ // - (bag.is_singleton (bag "x" 1)) = true
+ // - (bag.is_singleton (bag "x" 4)) = false
+ // - (bag.is_singleton (bag.union_disjoint (bag "x" 1) (bag "y" 1))) =
// false
Node falseNode = d_nodeManager->mkConst(false);
Node trueNode = d_nodeManager->mkConst(true);
@@ -453,12 +537,18 @@ TEST_F(TestTheoryWhiteBagsNormalForm, is_singleton)
Node x = d_nodeManager->mkConst(String("x"));
Node y = d_nodeManager->mkConst(String("y"));
Node z = d_nodeManager->mkConst(String("z"));
- Node x_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(1)));
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
+ Node x_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
Node input1 = d_nodeManager->mkNode(BAG_IS_SINGLETON, empty);
Node output1 = falseNode;
@@ -472,7 +562,7 @@ TEST_F(TestTheoryWhiteBagsNormalForm, is_singleton)
Node output3 = falseNode;
ASSERT_EQ(output2, NormalForm::evaluate(input2));
- Node union_disjoint = d_nodeManager->mkNode(UNION_DISJOINT, x_1, y_1);
+ Node union_disjoint = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_1, y_1);
Node input4 = d_nodeManager->mkNode(BAG_IS_SINGLETON, union_disjoint);
Node output4 = falseNode;
ASSERT_EQ(output3, NormalForm::evaluate(input3));
@@ -482,10 +572,10 @@ TEST_F(TestTheoryWhiteBagsNormalForm, from_set)
{
// Examples
// --------
- // - (bag.from_set (emptyset String)) = (emptybag String)
- // - (bag.from_set (singleton "x")) = (mkBag "x" 1)
- // - (bag.to_set (union (singleton "x") (singleton "y"))) =
- // (disjoint_union (mkBag "x" 1) (mkBag "y" 1))
+ // - (bag.from_set (as set.empty (Bag String))) = (as bag.empty (Bag String))
+ // - (bag.from_set (set.singleton "x")) = (bag "x" 1)
+ // - (bag.from_set (set.union (set.singleton "x") (set.singleton "y"))) =
+ // (bag.union_disjoint (bag "x" 1) (bag "y" 1))
Node emptyset = d_nodeManager->mkConst(
EmptySet(d_nodeManager->mkSetType(d_nodeManager->stringType())));
@@ -501,10 +591,14 @@ TEST_F(TestTheoryWhiteBagsNormalForm, from_set)
Node xSingleton = d_nodeManager->mkSingleton(d_nodeManager->stringType(), x);
Node ySingleton = d_nodeManager->mkSingleton(d_nodeManager->stringType(), y);
- Node x_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(1)));
- Node y_1 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(1)));
+ Node x_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
+ Node y_1 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
Node input2 = d_nodeManager->mkNode(BAG_FROM_SET, xSingleton);
Node output2 = x_1;
@@ -513,7 +607,7 @@ TEST_F(TestTheoryWhiteBagsNormalForm, from_set)
// for normal sets, the first node is the largest, not smallest
Node normalSet = d_nodeManager->mkNode(SET_UNION, ySingleton, xSingleton);
Node input3 = d_nodeManager->mkNode(BAG_FROM_SET, normalSet);
- Node output3 = d_nodeManager->mkNode(UNION_DISJOINT, x_1, y_1);
+ Node output3 = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_1, y_1);
ASSERT_EQ(output3, NormalForm::evaluate(input3));
}
@@ -521,10 +615,10 @@ TEST_F(TestTheoryWhiteBagsNormalForm, to_set)
{
// Examples
// --------
- // - (bag.to_set (emptybag String)) = (emptyset String)
- // - (bag.to_set (mkBag "x" 4)) = (singleton "x")
- // - (bag.to_set (disjoint_union (mkBag "x" 3) (mkBag "y" 5)) =
- // (union (singleton "x") (singleton "y")))
+ // - (bag.to_set (as bag.empty (Bag String))) = (as set.empty (Bag String))
+ // - (bag.to_set (bag "x" 4)) = (set.singleton "x")
+ // - (bag.to_set (bag.union_disjoint(bag "x" 3) (bag "y" 5)) =
+ // (set.union (set.singleton "x") (set.singleton "y")))
Node emptyset = d_nodeManager->mkConst(
EmptySet(d_nodeManager->mkSetType(d_nodeManager->stringType())));
@@ -540,17 +634,21 @@ TEST_F(TestTheoryWhiteBagsNormalForm, to_set)
Node xSingleton = d_nodeManager->mkSingleton(d_nodeManager->stringType(), x);
Node ySingleton = d_nodeManager->mkSingleton(d_nodeManager->stringType(), y);
- Node x_4 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(4)));
- Node y_5 = d_nodeManager->mkBag(
- d_nodeManager->stringType(), y, d_nodeManager->mkConst(Rational(5)));
+ Node x_4 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node y_5 =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ y,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(5)));
Node input2 = d_nodeManager->mkNode(BAG_TO_SET, x_4);
Node output2 = xSingleton;
ASSERT_EQ(output2, NormalForm::evaluate(input2));
// for normal sets, the first node is the largest, not smallest
- Node normalBag = d_nodeManager->mkNode(UNION_DISJOINT, x_4, y_5);
+ Node normalBag = d_nodeManager->mkNode(BAG_UNION_DISJOINT, x_4, y_5);
Node input3 = d_nodeManager->mkNode(BAG_TO_SET, normalBag);
Node output3 = d_nodeManager->mkNode(SET_UNION, ySingleton, xSingleton);
ASSERT_EQ(output3, NormalForm::evaluate(input3));
diff --git a/test/unit/theory/theory_bags_rewriter_white.cpp b/test/unit/theory/theory_bags_rewriter_white.cpp
index 7250f581c..ee1e89448 100644
--- a/test/unit/theory/theory_bags_rewriter_white.cpp
+++ b/test/unit/theory/theory_bags_rewriter_white.cpp
@@ -75,9 +75,10 @@ TEST_F(TestTheoryWhiteBagsRewriter, bag_equality)
Node emptyBag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
Node emptyString = d_nodeManager->mkConst(String(""));
- Node constantBag = d_nodeManager->mkBag(d_nodeManager->stringType(),
- emptyString,
- d_nodeManager->mkConst(Rational(1)));
+ Node constantBag =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ emptyString,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
// (= A A) = true where A is a bag
Node n1 = A.eqNode(A);
@@ -106,15 +107,18 @@ TEST_F(TestTheoryWhiteBagsRewriter, bag_equality)
TEST_F(TestTheoryWhiteBagsRewriter, mkBag_constant_element)
{
std::vector<Node> elements = getNStrings(1);
- Node negative = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(-1)));
- Node zero = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(0)));
- Node positive = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(1)));
+ Node negative = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1)));
+ Node zero =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)));
+ Node positive =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
Node emptybag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
RewriteResponse negativeResponse = d_rewriter->postRewrite(negative);
@@ -136,16 +140,22 @@ TEST_F(TestTheoryWhiteBagsRewriter, mkBag_variable_element)
{
Node skolem =
d_skolemManager->mkDummySkolem("x", d_nodeManager->stringType());
- Node variable = d_nodeManager->mkBag(d_nodeManager->stringType(),
- skolem,
- d_nodeManager->mkConst(Rational(-1)));
- Node negative = d_nodeManager->mkBag(d_nodeManager->stringType(),
- skolem,
- d_nodeManager->mkConst(Rational(-1)));
- Node zero = d_nodeManager->mkBag(
- d_nodeManager->stringType(), skolem, d_nodeManager->mkConst(Rational(0)));
- Node positive = d_nodeManager->mkBag(
- d_nodeManager->stringType(), skolem, d_nodeManager->mkConst(Rational(1)));
+ Node variable = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ skolem,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1)));
+ Node negative = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ skolem,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1)));
+ Node zero =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ skolem,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)));
+ Node positive =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ skolem,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
Node emptybag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
RewriteResponse negativeResponse = d_rewriter->postRewrite(negative);
@@ -165,21 +175,21 @@ TEST_F(TestTheoryWhiteBagsRewriter, mkBag_variable_element)
TEST_F(TestTheoryWhiteBagsRewriter, bag_count)
{
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node three = d_nodeManager->mkConst(Rational(3));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node three = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
Node skolem =
d_skolemManager->mkDummySkolem("x", d_nodeManager->stringType());
Node emptyBag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(skolem.getType())));
- // (bag.count x emptybag) = 0
+ // (bag.count x (as bag.empty (Bag String))) = 0
Node n1 = d_nodeManager->mkNode(BAG_COUNT, skolem, emptyBag);
RewriteResponse response1 = d_rewriter->postRewrite(n1);
ASSERT_TRUE(response1.d_status == REWRITE_AGAIN_FULL
&& response1.d_node == zero);
- // (bag.count x (mkBag x c) = (ite (>= c 1) c 0)
+ // (bag.count x (bag x c) = (ite (>= c 1) c 0)
Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(), skolem, three);
Node n2 = d_nodeManager->mkNode(BAG_COUNT, skolem, bag);
RewriteResponse response2 = d_rewriter->postRewrite(n2);
@@ -193,14 +203,18 @@ TEST_F(TestTheoryWhiteBagsRewriter, bag_count)
TEST_F(TestTheoryWhiteBagsRewriter, duplicate_removal)
{
Node x = d_skolemManager->mkDummySkolem("x", d_nodeManager->stringType());
- Node bag = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(5)));
+ Node bag =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(5)));
- // (duplicate_removal (mkBag x n)) = (mkBag x 1)
- Node n = d_nodeManager->mkNode(DUPLICATE_REMOVAL, bag);
+ // (bag.duplicate_removal (bag x n)) = (bag x 1)
+ Node n = d_nodeManager->mkNode(BAG_DUPLICATE_REMOVAL, bag);
RewriteResponse response = d_rewriter->postRewrite(n);
- Node noDuplicate = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(1)));
+ Node noDuplicate =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
ASSERT_TRUE(response.d_node == noDuplicate
&& response.d_status == REWRITE_AGAIN_FULL);
}
@@ -211,79 +225,81 @@ TEST_F(TestTheoryWhiteBagsRewriter, union_max)
std::vector<Node> elements = getNStrings(2);
Node emptyBag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
- Node A = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(n)));
- Node B = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[1],
- d_nodeManager->mkConst(Rational(n + 1)));
- Node unionMaxAB = d_nodeManager->mkNode(UNION_MAX, A, B);
- Node unionMaxBA = d_nodeManager->mkNode(UNION_MAX, B, A);
- Node unionDisjointAB = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
- Node unionDisjointBA = d_nodeManager->mkNode(UNION_DISJOINT, B, A);
-
- // (union_max A emptybag) = A
- Node unionMax1 = d_nodeManager->mkNode(UNION_MAX, A, emptyBag);
+ Node A =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n)));
+ Node B = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[1],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n + 1)));
+ Node unionMaxAB = d_nodeManager->mkNode(BAG_UNION_MAX, A, B);
+ Node unionMaxBA = d_nodeManager->mkNode(BAG_UNION_MAX, B, A);
+ Node unionDisjointAB = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
+ Node unionDisjointBA = d_nodeManager->mkNode(BAG_UNION_DISJOINT, B, A);
+
+ // (bag.union_max A (as bag.empty (Bag String))) = A
+ Node unionMax1 = d_nodeManager->mkNode(BAG_UNION_MAX, A, emptyBag);
RewriteResponse response1 = d_rewriter->postRewrite(unionMax1);
ASSERT_TRUE(response1.d_node == A
&& response1.d_status == REWRITE_AGAIN_FULL);
- // (union_max emptybag A) = A
- Node unionMax2 = d_nodeManager->mkNode(UNION_MAX, emptyBag, A);
+ // (bag.union_max (as bag.empty (Bag String)) A) = A
+ Node unionMax2 = d_nodeManager->mkNode(BAG_UNION_MAX, emptyBag, A);
RewriteResponse response2 = d_rewriter->postRewrite(unionMax2);
ASSERT_TRUE(response2.d_node == A
&& response2.d_status == REWRITE_AGAIN_FULL);
- // (union_max A A) = A
- Node unionMax3 = d_nodeManager->mkNode(UNION_MAX, A, A);
+ // (bag.union_max A A) = A
+ Node unionMax3 = d_nodeManager->mkNode(BAG_UNION_MAX, A, A);
RewriteResponse response3 = d_rewriter->postRewrite(unionMax3);
ASSERT_TRUE(response3.d_node == A
&& response3.d_status == REWRITE_AGAIN_FULL);
- // (union_max A (union_max A B)) = (union_max A B)
- Node unionMax4 = d_nodeManager->mkNode(UNION_MAX, A, unionMaxAB);
+ // (bag.union_max A (bag.union_max A B)) = (bag.union_max A B)
+ Node unionMax4 = d_nodeManager->mkNode(BAG_UNION_MAX, A, unionMaxAB);
RewriteResponse response4 = d_rewriter->postRewrite(unionMax4);
ASSERT_TRUE(response4.d_node == unionMaxAB
&& response4.d_status == REWRITE_AGAIN_FULL);
- // (union_max A (union_max B A)) = (union_max B A)
- Node unionMax5 = d_nodeManager->mkNode(UNION_MAX, A, unionMaxBA);
+ // (bag.union_max A (bag.union_max B A)) = (bag.union_max B A)
+ Node unionMax5 = d_nodeManager->mkNode(BAG_UNION_MAX, A, unionMaxBA);
RewriteResponse response5 = d_rewriter->postRewrite(unionMax5);
ASSERT_TRUE(response5.d_node == unionMaxBA
&& response4.d_status == REWRITE_AGAIN_FULL);
- // (union_max (union_max A B) A) = (union_max A B)
- Node unionMax6 = d_nodeManager->mkNode(UNION_MAX, unionMaxAB, A);
+ // (bag.union_max (bag.union_max A B) A) = (bag.union_max A B)
+ Node unionMax6 = d_nodeManager->mkNode(BAG_UNION_MAX, unionMaxAB, A);
RewriteResponse response6 = d_rewriter->postRewrite(unionMax6);
ASSERT_TRUE(response6.d_node == unionMaxAB
&& response6.d_status == REWRITE_AGAIN_FULL);
- // (union_max (union_max B A) A) = (union_max B A)
- Node unionMax7 = d_nodeManager->mkNode(UNION_MAX, unionMaxBA, A);
+ // (bag.union_max (bag.union_max B A) A) = (bag.union_max B A)
+ Node unionMax7 = d_nodeManager->mkNode(BAG_UNION_MAX, unionMaxBA, A);
RewriteResponse response7 = d_rewriter->postRewrite(unionMax7);
ASSERT_TRUE(response7.d_node == unionMaxBA
&& response7.d_status == REWRITE_AGAIN_FULL);
- // (union_max A (union_disjoint A B)) = (union_disjoint A B)
- Node unionMax8 = d_nodeManager->mkNode(UNION_MAX, A, unionDisjointAB);
+ // (bag.union_max A (bag.union_disjoint A B)) = (bag.union_disjoint A B)
+ Node unionMax8 = d_nodeManager->mkNode(BAG_UNION_MAX, A, unionDisjointAB);
RewriteResponse response8 = d_rewriter->postRewrite(unionMax8);
ASSERT_TRUE(response8.d_node == unionDisjointAB
&& response8.d_status == REWRITE_AGAIN_FULL);
- // (union_max A (union_disjoint B A)) = (union_disjoint B A)
- Node unionMax9 = d_nodeManager->mkNode(UNION_MAX, A, unionDisjointBA);
+ // (bag.union_max A (bag.union_disjoint B A)) = (bag.union_disjoint B A)
+ Node unionMax9 = d_nodeManager->mkNode(BAG_UNION_MAX, A, unionDisjointBA);
RewriteResponse response9 = d_rewriter->postRewrite(unionMax9);
ASSERT_TRUE(response9.d_node == unionDisjointBA
&& response9.d_status == REWRITE_AGAIN_FULL);
- // (union_max (union_disjoint A B) A) = (union_disjoint A B)
- Node unionMax10 = d_nodeManager->mkNode(UNION_MAX, unionDisjointAB, A);
+ // (bag.union_max (bag.union_disjoint A B) A) = (bag.union_disjoint A B)
+ Node unionMax10 = d_nodeManager->mkNode(BAG_UNION_MAX, unionDisjointAB, A);
RewriteResponse response10 = d_rewriter->postRewrite(unionMax10);
ASSERT_TRUE(response10.d_node == unionDisjointAB
&& response10.d_status == REWRITE_AGAIN_FULL);
- // (union_max (union_disjoint B A) A) = (union_disjoint B A)
- Node unionMax11 = d_nodeManager->mkNode(UNION_MAX, unionDisjointBA, A);
+ // (bag.union_max (bag.union_disjoint B A) A) = (bag.union_disjoint B A)
+ Node unionMax11 = d_nodeManager->mkNode(BAG_UNION_MAX, unionDisjointBA, A);
RewriteResponse response11 = d_rewriter->postRewrite(unionMax11);
ASSERT_TRUE(response11.d_node == unionDisjointBA
&& response11.d_status == REWRITE_AGAIN_FULL);
@@ -295,56 +311,59 @@ TEST_F(TestTheoryWhiteBagsRewriter, union_disjoint)
std::vector<Node> elements = getNStrings(3);
Node emptyBag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
- Node A = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(n)));
- Node B = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[1],
- d_nodeManager->mkConst(Rational(n + 1)));
- Node C = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[2],
- d_nodeManager->mkConst(Rational(n + 2)));
-
- Node unionDisjointAB = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
- Node unionDisjointBA = d_nodeManager->mkNode(UNION_DISJOINT, B, A);
- Node unionMaxAB = d_nodeManager->mkNode(UNION_MAX, A, B);
- Node unionMaxAC = d_nodeManager->mkNode(UNION_MAX, A, C);
- Node unionMaxBA = d_nodeManager->mkNode(UNION_MAX, B, A);
- Node intersectionAB = d_nodeManager->mkNode(INTERSECTION_MIN, A, B);
- Node intersectionBA = d_nodeManager->mkNode(INTERSECTION_MIN, B, A);
-
- // (union_disjoint A emptybag) = A
- Node unionDisjoint1 = d_nodeManager->mkNode(UNION_DISJOINT, A, emptyBag);
+ Node A =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n)));
+ Node B = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[1],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n + 1)));
+ Node C = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[2],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n + 2)));
+
+ Node unionDisjointAB = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
+ Node unionDisjointBA = d_nodeManager->mkNode(BAG_UNION_DISJOINT, B, A);
+ Node unionMaxAB = d_nodeManager->mkNode(BAG_UNION_MAX, A, B);
+ Node unionMaxAC = d_nodeManager->mkNode(BAG_UNION_MAX, A, C);
+ Node unionMaxBA = d_nodeManager->mkNode(BAG_UNION_MAX, B, A);
+ Node intersectionAB = d_nodeManager->mkNode(BAG_INTER_MIN, A, B);
+ Node intersectionBA = d_nodeManager->mkNode(BAG_INTER_MIN, B, A);
+
+ // (bag.union_disjoint A (as bag.empty (Bag String))) = A
+ Node unionDisjoint1 = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, emptyBag);
RewriteResponse response1 = d_rewriter->postRewrite(unionDisjoint1);
ASSERT_TRUE(response1.d_node == A
&& response1.d_status == REWRITE_AGAIN_FULL);
- // (union_disjoint emptybag A) = A
- Node unionDisjoint2 = d_nodeManager->mkNode(UNION_DISJOINT, emptyBag, A);
+ // (bag.union_disjoint (as bag.empty (Bag String)) A) = A
+ Node unionDisjoint2 = d_nodeManager->mkNode(BAG_UNION_DISJOINT, emptyBag, A);
RewriteResponse response2 = d_rewriter->postRewrite(unionDisjoint2);
ASSERT_TRUE(response2.d_node == A
&& response2.d_status == REWRITE_AGAIN_FULL);
- // (union_disjoint (union_max A B) (intersection_min B A)) =
- // (union_disjoint A B) // sum(a,b) = max(a,b) + min(a,b)
+ // (bag.union_disjoint (bag.union_max A B) (bag.inter_min B A)) =
+ // (bag.union_disjoint A B) // sum(a,b) = max(a,b) + min(a,b)
Node unionDisjoint3 =
- d_nodeManager->mkNode(UNION_DISJOINT, unionMaxAB, intersectionBA);
+ d_nodeManager->mkNode(BAG_UNION_DISJOINT, unionMaxAB, intersectionBA);
RewriteResponse response3 = d_rewriter->postRewrite(unionDisjoint3);
ASSERT_TRUE(response3.d_node == unionDisjointAB
&& response3.d_status == REWRITE_AGAIN_FULL);
- // (union_disjoint (intersection_min B A)) (union_max A B) =
- // (union_disjoint B A) // sum(a,b) = max(a,b) + min(a,b)
+ // (bag.union_disjoint (bag.inter_min B A)) (bag.union_max A B) =
+ // (bag.union_disjoint B A) // sum(a,b) = max(a,b) + min(a,b)
Node unionDisjoint4 =
- d_nodeManager->mkNode(UNION_DISJOINT, unionMaxBA, intersectionBA);
+ d_nodeManager->mkNode(BAG_UNION_DISJOINT, unionMaxBA, intersectionBA);
RewriteResponse response4 = d_rewriter->postRewrite(unionDisjoint4);
ASSERT_TRUE(response4.d_node == unionDisjointBA
&& response4.d_status == REWRITE_AGAIN_FULL);
- // (union_disjoint (intersection_min B A)) (union_max A B) =
- // (union_disjoint B A) // sum(a,b) = max(a,b) + min(a,b)
+ // (bag.union_disjoint (bag.inter_min B A)) (bag.union_max A B) =
+ // (bag.union_disjoint B A) // sum(a,b) = max(a,b) + min(a,b)
Node unionDisjoint5 =
- d_nodeManager->mkNode(UNION_DISJOINT, unionMaxAC, intersectionAB);
+ d_nodeManager->mkNode(BAG_UNION_DISJOINT, unionMaxAC, intersectionAB);
RewriteResponse response5 = d_rewriter->postRewrite(unionDisjoint5);
ASSERT_TRUE(response5.d_node == unionDisjoint5
&& response5.d_status == REWRITE_DONE);
@@ -356,79 +375,83 @@ TEST_F(TestTheoryWhiteBagsRewriter, intersection_min)
std::vector<Node> elements = getNStrings(2);
Node emptyBag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
- Node A = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(n)));
- Node B = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[1],
- d_nodeManager->mkConst(Rational(n + 1)));
- Node unionMaxAB = d_nodeManager->mkNode(UNION_MAX, A, B);
- Node unionMaxBA = d_nodeManager->mkNode(UNION_MAX, B, A);
- Node unionDisjointAB = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
- Node unionDisjointBA = d_nodeManager->mkNode(UNION_DISJOINT, B, A);
-
- // (intersection_min A emptybag) = emptyBag
- Node n1 = d_nodeManager->mkNode(INTERSECTION_MIN, A, emptyBag);
+ Node A =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n)));
+ Node B = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[1],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n + 1)));
+ Node unionMaxAB = d_nodeManager->mkNode(BAG_UNION_MAX, A, B);
+ Node unionMaxBA = d_nodeManager->mkNode(BAG_UNION_MAX, B, A);
+ Node unionDisjointAB = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
+ Node unionDisjointBA = d_nodeManager->mkNode(BAG_UNION_DISJOINT, B, A);
+
+ // (bag.inter_min A (as bag.empty (Bag String)) =
+ // (as bag.empty (Bag String))
+ Node n1 = d_nodeManager->mkNode(BAG_INTER_MIN, A, emptyBag);
RewriteResponse response1 = d_rewriter->postRewrite(n1);
ASSERT_TRUE(response1.d_node == emptyBag
&& response1.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min emptybag A) = emptyBag
- Node n2 = d_nodeManager->mkNode(INTERSECTION_MIN, emptyBag, A);
+ // (bag.inter_min (as bag.empty (Bag String)) A) =
+ // (as bag.empty (Bag String))
+ Node n2 = d_nodeManager->mkNode(BAG_INTER_MIN, emptyBag, A);
RewriteResponse response2 = d_rewriter->postRewrite(n2);
ASSERT_TRUE(response2.d_node == emptyBag
&& response2.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min A A) = A
- Node n3 = d_nodeManager->mkNode(INTERSECTION_MIN, A, A);
+ // (bag.inter_min A A) = A
+ Node n3 = d_nodeManager->mkNode(BAG_INTER_MIN, A, A);
RewriteResponse response3 = d_rewriter->postRewrite(n3);
ASSERT_TRUE(response3.d_node == A
&& response3.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min A (union_max A B) = A
- Node n4 = d_nodeManager->mkNode(INTERSECTION_MIN, A, unionMaxAB);
+ // (bag.inter_min A (bag.union_max A B) = A
+ Node n4 = d_nodeManager->mkNode(BAG_INTER_MIN, A, unionMaxAB);
RewriteResponse response4 = d_rewriter->postRewrite(n4);
ASSERT_TRUE(response4.d_node == A
&& response4.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min A (union_max B A) = A
- Node n5 = d_nodeManager->mkNode(INTERSECTION_MIN, A, unionMaxBA);
+ // (bag.inter_min A (bag.union_max B A) = A
+ Node n5 = d_nodeManager->mkNode(BAG_INTER_MIN, A, unionMaxBA);
RewriteResponse response5 = d_rewriter->postRewrite(n5);
ASSERT_TRUE(response5.d_node == A
&& response4.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min (union_max A B) A) = A
- Node n6 = d_nodeManager->mkNode(INTERSECTION_MIN, unionMaxAB, A);
+ // (bag.inter_min (bag.union_max A B) A) = A
+ Node n6 = d_nodeManager->mkNode(BAG_INTER_MIN, unionMaxAB, A);
RewriteResponse response6 = d_rewriter->postRewrite(n6);
ASSERT_TRUE(response6.d_node == A
&& response6.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min (union_max B A) A) = A
- Node n7 = d_nodeManager->mkNode(INTERSECTION_MIN, unionMaxBA, A);
+ // (bag.inter_min (bag.union_max B A) A) = A
+ Node n7 = d_nodeManager->mkNode(BAG_INTER_MIN, unionMaxBA, A);
RewriteResponse response7 = d_rewriter->postRewrite(n7);
ASSERT_TRUE(response7.d_node == A
&& response7.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min A (union_disjoint A B) = A
- Node n8 = d_nodeManager->mkNode(INTERSECTION_MIN, A, unionDisjointAB);
+ // (bag.inter_min A (bag.union_disjoint A B) = A
+ Node n8 = d_nodeManager->mkNode(BAG_INTER_MIN, A, unionDisjointAB);
RewriteResponse response8 = d_rewriter->postRewrite(n8);
ASSERT_TRUE(response8.d_node == A
&& response8.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min A (union_disjoint B A) = A
- Node n9 = d_nodeManager->mkNode(INTERSECTION_MIN, A, unionDisjointBA);
+ // (bag.inter_min A (bag.union_disjoint B A) = A
+ Node n9 = d_nodeManager->mkNode(BAG_INTER_MIN, A, unionDisjointBA);
RewriteResponse response9 = d_rewriter->postRewrite(n9);
ASSERT_TRUE(response9.d_node == A
&& response9.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min (union_disjoint A B) A) = A
- Node n10 = d_nodeManager->mkNode(INTERSECTION_MIN, unionDisjointAB, A);
+ // (bag.inter_min (bag.union_disjoint A B) A) = A
+ Node n10 = d_nodeManager->mkNode(BAG_INTER_MIN, unionDisjointAB, A);
RewriteResponse response10 = d_rewriter->postRewrite(n10);
ASSERT_TRUE(response10.d_node == A
&& response10.d_status == REWRITE_AGAIN_FULL);
- // (intersection_min (union_disjoint B A) A) = A
- Node n11 = d_nodeManager->mkNode(INTERSECTION_MIN, unionDisjointBA, A);
+ // (bag.inter_min (bag.union_disjoint B A) A) = A
+ Node n11 = d_nodeManager->mkNode(BAG_INTER_MIN, unionDisjointBA, A);
RewriteResponse response11 = d_rewriter->postRewrite(n11);
ASSERT_TRUE(response11.d_node == A
&& response11.d_status == REWRITE_AGAIN_FULL);
@@ -440,81 +463,90 @@ TEST_F(TestTheoryWhiteBagsRewriter, difference_subtract)
std::vector<Node> elements = getNStrings(2);
Node emptyBag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
- Node A = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(n)));
- Node B = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[1],
- d_nodeManager->mkConst(Rational(n + 1)));
- Node unionMaxAB = d_nodeManager->mkNode(UNION_MAX, A, B);
- Node unionMaxBA = d_nodeManager->mkNode(UNION_MAX, B, A);
- Node unionDisjointAB = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
- Node unionDisjointBA = d_nodeManager->mkNode(UNION_DISJOINT, B, A);
- Node intersectionAB = d_nodeManager->mkNode(INTERSECTION_MIN, A, B);
- Node intersectionBA = d_nodeManager->mkNode(INTERSECTION_MIN, B, A);
-
- // (difference_subtract A emptybag) = A
- Node n1 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, A, emptyBag);
+ Node A =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n)));
+ Node B = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[1],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n + 1)));
+ Node unionMaxAB = d_nodeManager->mkNode(BAG_UNION_MAX, A, B);
+ Node unionMaxBA = d_nodeManager->mkNode(BAG_UNION_MAX, B, A);
+ Node unionDisjointAB = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
+ Node unionDisjointBA = d_nodeManager->mkNode(BAG_UNION_DISJOINT, B, A);
+ Node intersectionAB = d_nodeManager->mkNode(BAG_INTER_MIN, A, B);
+ Node intersectionBA = d_nodeManager->mkNode(BAG_INTER_MIN, B, A);
+
+ // (bag.difference_subtract A (as bag.empty (Bag String)) = A
+ Node n1 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, A, emptyBag);
RewriteResponse response1 = d_rewriter->postRewrite(n1);
ASSERT_TRUE(response1.d_node == A
&& response1.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract emptybag A) = emptyBag
- Node n2 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, emptyBag, A);
+ // (bag.difference_subtract (as bag.empty (Bag String)) A) =
+ // (as bag.empty (Bag String))
+ Node n2 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, emptyBag, A);
RewriteResponse response2 = d_rewriter->postRewrite(n2);
ASSERT_TRUE(response2.d_node == emptyBag
&& response2.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract A A) = emptybag
- Node n3 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, A, A);
+ // (bag.difference_subtract A A) = (as bag.empty (Bag String))
+ Node n3 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, A, A);
RewriteResponse response3 = d_rewriter->postRewrite(n3);
ASSERT_TRUE(response3.d_node == emptyBag
&& response3.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract (union_disjoint A B) A) = B
- Node n4 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, unionDisjointAB, A);
+ // (bag.difference_subtract (bag.union_disjoint A B) A) = B
+ Node n4 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, unionDisjointAB, A);
RewriteResponse response4 = d_rewriter->postRewrite(n4);
ASSERT_TRUE(response4.d_node == B
&& response4.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract (union_disjoint B A) A) = B
- Node n5 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, unionDisjointBA, A);
+ // (bag.difference_subtract (bag.union_disjoint B A) A) = B
+ Node n5 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, unionDisjointBA, A);
RewriteResponse response5 = d_rewriter->postRewrite(n5);
ASSERT_TRUE(response5.d_node == B
&& response4.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract A (union_disjoint A B)) = emptybag
- Node n6 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, A, unionDisjointAB);
+ // (bag.difference_subtract A (bag.union_disjoint A B)) =
+ // (as bag.empty (Bag String))
+ Node n6 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, A, unionDisjointAB);
RewriteResponse response6 = d_rewriter->postRewrite(n6);
ASSERT_TRUE(response6.d_node == emptyBag
&& response6.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract A (union_disjoint B A)) = emptybag
- Node n7 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, A, unionDisjointBA);
+ // (bag.difference_subtract A (bag.union_disjoint B A)) =
+ // (as bag.empty (Bag String))
+ Node n7 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, A, unionDisjointBA);
RewriteResponse response7 = d_rewriter->postRewrite(n7);
ASSERT_TRUE(response7.d_node == emptyBag
&& response7.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract A (union_max A B)) = emptybag
- Node n8 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, A, unionMaxAB);
+ // (bag.difference_subtract A (bag.union_max A B)) =
+ // (as bag.empty (Bag String))
+ Node n8 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, A, unionMaxAB);
RewriteResponse response8 = d_rewriter->postRewrite(n8);
ASSERT_TRUE(response8.d_node == emptyBag
&& response8.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract A (union_max B A)) = emptybag
- Node n9 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, A, unionMaxBA);
+ // (bag.difference_subtract A (bag.union_max B A)) =
+ // (as bag.empty (Bag String))
+ Node n9 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, A, unionMaxBA);
RewriteResponse response9 = d_rewriter->postRewrite(n9);
ASSERT_TRUE(response9.d_node == emptyBag
&& response9.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract (intersection_min A B) A) = emptybag
- Node n10 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, intersectionAB, A);
+ // (bag.difference_subtract (bag.inter_min A B) A) =
+ // (as bag.empty (Bag String))
+ Node n10 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, intersectionAB, A);
RewriteResponse response10 = d_rewriter->postRewrite(n10);
ASSERT_TRUE(response10.d_node == emptyBag
&& response10.d_status == REWRITE_AGAIN_FULL);
- // (difference_subtract (intersection_min B A) A) = emptybag
- Node n11 = d_nodeManager->mkNode(DIFFERENCE_SUBTRACT, intersectionBA, A);
+ // (bag.difference_subtract (bag.inter_min B A) A) =
+ // (as bag.empty (Bag String))
+ Node n11 = d_nodeManager->mkNode(BAG_DIFFERENCE_SUBTRACT, intersectionBA, A);
RewriteResponse response11 = d_rewriter->postRewrite(n11);
ASSERT_TRUE(response11.d_node == emptyBag
&& response11.d_status == REWRITE_AGAIN_FULL);
@@ -526,69 +558,78 @@ TEST_F(TestTheoryWhiteBagsRewriter, difference_remove)
std::vector<Node> elements = getNStrings(2);
Node emptyBag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
- Node A = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(n)));
- Node B = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[1],
- d_nodeManager->mkConst(Rational(n + 1)));
- Node unionMaxAB = d_nodeManager->mkNode(UNION_MAX, A, B);
- Node unionMaxBA = d_nodeManager->mkNode(UNION_MAX, B, A);
- Node unionDisjointAB = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
- Node unionDisjointBA = d_nodeManager->mkNode(UNION_DISJOINT, B, A);
- Node intersectionAB = d_nodeManager->mkNode(INTERSECTION_MIN, A, B);
- Node intersectionBA = d_nodeManager->mkNode(INTERSECTION_MIN, B, A);
-
- // (difference_remove A emptybag) = A
- Node n1 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, A, emptyBag);
+ Node A =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n)));
+ Node B = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[1],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(n + 1)));
+ Node unionMaxAB = d_nodeManager->mkNode(BAG_UNION_MAX, A, B);
+ Node unionMaxBA = d_nodeManager->mkNode(BAG_UNION_MAX, B, A);
+ Node unionDisjointAB = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
+ Node unionDisjointBA = d_nodeManager->mkNode(BAG_UNION_DISJOINT, B, A);
+ Node intersectionAB = d_nodeManager->mkNode(BAG_INTER_MIN, A, B);
+ Node intersectionBA = d_nodeManager->mkNode(BAG_INTER_MIN, B, A);
+
+ // (bag.difference_remove A (as bag.empty (Bag String)) = A
+ Node n1 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, A, emptyBag);
RewriteResponse response1 = d_rewriter->postRewrite(n1);
ASSERT_TRUE(response1.d_node == A
&& response1.d_status == REWRITE_AGAIN_FULL);
- // (difference_remove emptybag A) = emptyBag
- Node n2 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, emptyBag, A);
+ // (bag.difference_remove (as bag.empty (Bag String)) A)=
+ // (as bag.empty (Bag String))
+ Node n2 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, emptyBag, A);
RewriteResponse response2 = d_rewriter->postRewrite(n2);
ASSERT_TRUE(response2.d_node == emptyBag
&& response2.d_status == REWRITE_AGAIN_FULL);
- // (difference_remove A A) = emptybag
- Node n3 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, A, A);
+ // (bag.difference_remove A A) = (as bag.empty (Bag String))
+ Node n3 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, A, A);
RewriteResponse response3 = d_rewriter->postRewrite(n3);
ASSERT_TRUE(response3.d_node == emptyBag
&& response3.d_status == REWRITE_AGAIN_FULL);
- // (difference_remove A (union_disjoint A B)) = emptybag
- Node n6 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, A, unionDisjointAB);
+ // (bag.difference_remove A (bag.union_disjoint A B)) =
+ // (as bag.empty (Bag String))
+ Node n6 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, A, unionDisjointAB);
RewriteResponse response6 = d_rewriter->postRewrite(n6);
ASSERT_TRUE(response6.d_node == emptyBag
&& response6.d_status == REWRITE_AGAIN_FULL);
- // (difference_remove A (union_disjoint B A)) = emptybag
- Node n7 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, A, unionDisjointBA);
+ // (bag.difference_remove A (bag.union_disjoint B A)) =
+ // (as bag.empty (Bag String))
+ Node n7 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, A, unionDisjointBA);
RewriteResponse response7 = d_rewriter->postRewrite(n7);
ASSERT_TRUE(response7.d_node == emptyBag
&& response7.d_status == REWRITE_AGAIN_FULL);
- // (difference_remove A (union_max A B)) = emptybag
- Node n8 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, A, unionMaxAB);
+ // (bag.difference_remove A (bag.union_max A B)) =
+ // (as bag.empty (Bag String))
+ Node n8 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, A, unionMaxAB);
RewriteResponse response8 = d_rewriter->postRewrite(n8);
ASSERT_TRUE(response8.d_node == emptyBag
&& response8.d_status == REWRITE_AGAIN_FULL);
- // (difference_remove A (union_max B A)) = emptybag
- Node n9 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, A, unionMaxBA);
+ // (bag.difference_remove A (bag.union_max B A)) =
+ // (as bag.empty (Bag String))
+ Node n9 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, A, unionMaxBA);
RewriteResponse response9 = d_rewriter->postRewrite(n9);
ASSERT_TRUE(response9.d_node == emptyBag
&& response9.d_status == REWRITE_AGAIN_FULL);
- // (difference_remove (intersection_min A B) A) = emptybag
- Node n10 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, intersectionAB, A);
+ // (bag.difference_remove (bag.inter_min A B) A) =
+ // (as bag.empty (Bag String))
+ Node n10 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, intersectionAB, A);
RewriteResponse response10 = d_rewriter->postRewrite(n10);
ASSERT_TRUE(response10.d_node == emptyBag
&& response10.d_status == REWRITE_AGAIN_FULL);
- // (difference_remove (intersection_min B A) A) = emptybag
- Node n11 = d_nodeManager->mkNode(DIFFERENCE_REMOVE, intersectionBA, A);
+ // (bag.difference_remove (bag.inter_min B A) A) =
+ // (as bag.empty (Bag String))
+ Node n11 = d_nodeManager->mkNode(BAG_DIFFERENCE_REMOVE, intersectionBA, A);
RewriteResponse response11 = d_rewriter->postRewrite(n11);
ASSERT_TRUE(response11.d_node == emptyBag
&& response11.d_status == REWRITE_AGAIN_FULL);
@@ -597,10 +638,10 @@ TEST_F(TestTheoryWhiteBagsRewriter, difference_remove)
TEST_F(TestTheoryWhiteBagsRewriter, choose)
{
Node x = d_skolemManager->mkDummySkolem("x", d_nodeManager->stringType());
- Node c = d_nodeManager->mkConst(Rational(3));
+ Node c = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(), x, c);
- // (bag.choose (mkBag x c)) = x where c is a constant > 0
+ // (bag.choose (bag x c)) = x where c is a constant > 0
Node n1 = d_nodeManager->mkNode(BAG_CHOOSE, bag);
RewriteResponse response1 = d_rewriter->postRewrite(n1);
ASSERT_TRUE(response1.d_node == x
@@ -612,32 +653,33 @@ TEST_F(TestTheoryWhiteBagsRewriter, bag_card)
Node x = d_skolemManager->mkDummySkolem("x", d_nodeManager->stringType());
Node emptyBag = d_nodeManager->mkConst(
EmptyBag(d_nodeManager->mkBagType(d_nodeManager->stringType())));
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node c = d_nodeManager->mkConst(Rational(3));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node c = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(), x, c);
std::vector<Node> elements = getNStrings(2);
- Node A = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(4)));
- Node B = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[1],
- d_nodeManager->mkConst(Rational(5)));
- Node unionDisjointAB = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
-
- // TODO(projects#223): enable this test after implementing bags normal form
- // // (bag.card emptybag) = 0
- // Node n1 = d_nodeManager->mkNode(BAG_CARD, emptyBag);
- // RewriteResponse response1 = d_rewriter->postRewrite(n1);
- // ASSERT_TRUE(response1.d_node == zero && response1.d_status ==
- // REWRITE_AGAIN_FULL);
-
- // (bag.card (mkBag x c)) = c where c is a constant > 0
+ Node A =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node B =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[1],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(5)));
+ Node unionDisjointAB = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
+
+ // (bag.card (as bag.empty (Bag String)) = 0
+ Node n1 = d_nodeManager->mkNode(BAG_CARD, emptyBag);
+ RewriteResponse response1 = d_rewriter->postRewrite(n1);
+ ASSERT_TRUE(response1.d_node == zero
+ && response1.d_status == REWRITE_AGAIN_FULL);
+
+ // (bag.card (bag x c)) = c where c is a constant > 0
Node n2 = d_nodeManager->mkNode(BAG_CARD, bag);
RewriteResponse response2 = d_rewriter->postRewrite(n2);
ASSERT_TRUE(response2.d_node == c
&& response2.d_status == REWRITE_AGAIN_FULL);
- // (bag.card (union-disjoint A B)) = (+ (bag.card A) (bag.card B))
+ // (bag.card (bag.union_disjoint A B)) = (+ (bag.card A) (bag.card B))
Node n3 = d_nodeManager->mkNode(BAG_CARD, unionDisjointAB);
Node cardA = d_nodeManager->mkNode(BAG_CARD, A);
Node cardB = d_nodeManager->mkNode(BAG_CARD, B);
@@ -655,17 +697,16 @@ TEST_F(TestTheoryWhiteBagsRewriter, is_singleton)
Node c = d_skolemManager->mkDummySkolem("c", d_nodeManager->integerType());
Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(), x, c);
- // TODO(projects#223): complete this function
- // (bag.is_singleton emptybag) = false
- // Node n1 = d_nodeManager->mkNode(BAG_IS_SINGLETON, emptybag);
- // RewriteResponse response1 = d_rewriter->postRewrite(n1);
- // ASSERT_TRUE(response1.d_node == d_nodeManager->mkConst(false)
- // && response1.d_status == REWRITE_AGAIN_FULL);
+ // (bag.is_singleton (as bag.empty (Bag String)) = false
+ Node n1 = d_nodeManager->mkNode(BAG_IS_SINGLETON, emptybag);
+ RewriteResponse response1 = d_rewriter->postRewrite(n1);
+ ASSERT_TRUE(response1.d_node == d_nodeManager->mkConst(false)
+ && response1.d_status == REWRITE_AGAIN_FULL);
- // (bag.is_singleton (mkBag x c) = (c == 1)
+ // (bag.is_singleton (bag x c) = (c == 1)
Node n2 = d_nodeManager->mkNode(BAG_IS_SINGLETON, bag);
RewriteResponse response2 = d_rewriter->postRewrite(n2);
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
Node equal = c.eqNode(one);
ASSERT_TRUE(response2.d_node == equal
&& response2.d_status == REWRITE_AGAIN_FULL);
@@ -676,10 +717,10 @@ TEST_F(TestTheoryWhiteBagsRewriter, from_set)
Node x = d_skolemManager->mkDummySkolem("x", d_nodeManager->stringType());
Node singleton = d_nodeManager->mkSingleton(d_nodeManager->stringType(), x);
- // (bag.from_set (singleton (singleton_op Int) x)) = (mkBag x 1)
+ // (bag.from_set (set.singleton (set.singleton_op Int) x)) = (bag x 1)
Node n = d_nodeManager->mkNode(BAG_FROM_SET, singleton);
RewriteResponse response = d_rewriter->postRewrite(n);
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(), x, one);
ASSERT_TRUE(response.d_node == bag
&& response.d_status == REWRITE_AGAIN_FULL);
@@ -688,10 +729,12 @@ TEST_F(TestTheoryWhiteBagsRewriter, from_set)
TEST_F(TestTheoryWhiteBagsRewriter, to_set)
{
Node x = d_skolemManager->mkDummySkolem("x", d_nodeManager->stringType());
- Node bag = d_nodeManager->mkBag(
- d_nodeManager->stringType(), x, d_nodeManager->mkConst(Rational(5)));
+ Node bag =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ x,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(5)));
- // (bag.to_set (mkBag x n)) = (singleton (singleton_op T) x)
+ // (bag.to_set (bag x n)) = (set.singleton (set.singleton_op T) x)
Node n = d_nodeManager->mkNode(BAG_TO_SET, bag);
RewriteResponse response = d_rewriter->postRewrite(n);
Node singleton = d_nodeManager->mkSingleton(d_nodeManager->stringType(), x);
@@ -710,7 +753,8 @@ TEST_F(TestTheoryWhiteBagsRewriter, map)
Node bound = d_nodeManager->mkNode(kind::BOUND_VAR_LIST, xString);
Node lambda = d_nodeManager->mkNode(LAMBDA, bound, empty);
- // (bag.map (lambda ((x U)) t) emptybag) = emptybag
+ // (bag.map (lambda ((x U)) t) (as bag.empty (Bag String)) =
+ // (as bag.empty (Bag String))
Node n1 = d_nodeManager->mkNode(BAG_MAP, lambda, emptybagString);
RewriteResponse response1 = d_rewriter->postRewrite(n1);
ASSERT_TRUE(response1.d_node == emptybagString
@@ -719,22 +763,41 @@ TEST_F(TestTheoryWhiteBagsRewriter, map)
std::vector<Node> elements = getNStrings(2);
Node a = d_nodeManager->mkConst(String("a"));
Node b = d_nodeManager->mkConst(String("b"));
- Node A = d_nodeManager->mkBag(
- d_nodeManager->stringType(), a, d_nodeManager->mkConst(Rational(3)));
- Node B = d_nodeManager->mkBag(
- d_nodeManager->stringType(), b, d_nodeManager->mkConst(Rational(4)));
- Node unionDisjointAB = d_nodeManager->mkNode(UNION_DISJOINT, A, B);
+ Node A =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ a,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(3)));
+ Node B =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ b,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(4)));
+ Node unionDisjointAB = d_nodeManager->mkNode(BAG_UNION_DISJOINT, A, B);
ASSERT_TRUE(unionDisjointAB.isConst());
- // (bag.map (lambda ((x Int)) "") (union_disjoint (bag "a" 3) (bag "b" 4))) =
- // (bag "" 7))
+ // (bag.map
+ // (lambda ((x Int)) "")
+ // (bag.union_disjoint (bag "a" 3) (bag "b" 4))) =
+ // (bag "" 7))
Node n2 = d_nodeManager->mkNode(BAG_MAP, lambda, unionDisjointAB);
-
Node rewritten = Rewriter::rewrite(n2);
- Node bag = d_nodeManager->mkBag(
- d_nodeManager->stringType(), empty, d_nodeManager->mkConst(Rational(7)));
- ASSERT_TRUE(rewritten == bag);
+ Node bag =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ empty,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(7)));
+ // - (bag.map f (bag.union_disjoint K1 K2)) =
+ // (bag.union_disjoint (bag.map f K1) (bag.map f K2))
+ Node k1 = d_skolemManager->mkDummySkolem("K1", A.getType());
+ Node k2 = d_skolemManager->mkDummySkolem("K2", A.getType());
+ Node f = d_skolemManager->mkDummySkolem("f", lambda.getType());
+ Node unionDisjointK1K2 = d_nodeManager->mkNode(BAG_UNION_DISJOINT, k1, k2);
+ Node n3 = d_nodeManager->mkNode(BAG_MAP, f, unionDisjointK1K2);
+ Node rewritten3 = Rewriter::rewrite(n3);
+ Node mapK1 = d_nodeManager->mkNode(BAG_MAP, f, k1);
+ Node mapK2 = d_nodeManager->mkNode(BAG_MAP, f, k2);
+ Node unionDisjointMapK1K2 =
+ d_nodeManager->mkNode(BAG_UNION_DISJOINT, mapK1, mapK2);
+ ASSERT_TRUE(rewritten3 == unionDisjointMapK1K2);
}
} // namespace test
diff --git a/test/unit/theory/theory_bags_type_rules_white.cpp b/test/unit/theory/theory_bags_type_rules_white.cpp
index 682ae5bb2..7b5b3be2c 100644
--- a/test/unit/theory/theory_bags_type_rules_white.cpp
+++ b/test/unit/theory/theory_bags_type_rules_white.cpp
@@ -51,12 +51,13 @@ class TestTheoryWhiteBagsTypeRule : public TestSmt
TEST_F(TestTheoryWhiteBagsTypeRule, count_operator)
{
std::vector<Node> elements = getNStrings(1);
- Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(100)));
+ Node bag = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(100)));
Node count = d_nodeManager->mkNode(BAG_COUNT, elements[0], bag);
- Node node = d_nodeManager->mkConst(Rational(10));
+ Node node = d_nodeManager->mkConst(CONST_RATIONAL, Rational(10));
// node of type Int is not compatible with bag of type (Bag String)
ASSERT_THROW(d_nodeManager->mkNode(BAG_COUNT, node, bag).getType(true),
@@ -66,31 +67,35 @@ TEST_F(TestTheoryWhiteBagsTypeRule, count_operator)
TEST_F(TestTheoryWhiteBagsTypeRule, duplicate_removal_operator)
{
std::vector<Node> elements = getNStrings(1);
- Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(10)));
- ASSERT_NO_THROW(d_nodeManager->mkNode(DUPLICATE_REMOVAL, bag));
- ASSERT_EQ(d_nodeManager->mkNode(DUPLICATE_REMOVAL, bag).getType(),
+ Node bag = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(10)));
+ ASSERT_NO_THROW(d_nodeManager->mkNode(BAG_DUPLICATE_REMOVAL, bag));
+ ASSERT_EQ(d_nodeManager->mkNode(BAG_DUPLICATE_REMOVAL, bag).getType(),
bag.getType());
}
TEST_F(TestTheoryWhiteBagsTypeRule, mkBag_operator)
{
std::vector<Node> elements = getNStrings(1);
- Node negative = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(-1)));
- Node zero = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(0)));
- Node positive = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(1)));
+ Node negative = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1)));
+ Node zero =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)));
+ Node positive =
+ d_nodeManager->mkBag(d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)));
// only positive multiplicity are constants
- ASSERT_FALSE(MkBagTypeRule::computeIsConst(d_nodeManager, negative));
- ASSERT_FALSE(MkBagTypeRule::computeIsConst(d_nodeManager, zero));
- ASSERT_TRUE(MkBagTypeRule::computeIsConst(d_nodeManager, positive));
+ ASSERT_FALSE(BagMakeTypeRule::computeIsConst(d_nodeManager, negative));
+ ASSERT_FALSE(BagMakeTypeRule::computeIsConst(d_nodeManager, zero));
+ ASSERT_TRUE(BagMakeTypeRule::computeIsConst(d_nodeManager, positive));
}
TEST_F(TestTheoryWhiteBagsTypeRule, from_set_operator)
@@ -105,9 +110,10 @@ TEST_F(TestTheoryWhiteBagsTypeRule, from_set_operator)
TEST_F(TestTheoryWhiteBagsTypeRule, to_set_operator)
{
std::vector<Node> elements = getNStrings(1);
- Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(10)));
+ Node bag = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(10)));
ASSERT_NO_THROW(d_nodeManager->mkNode(BAG_TO_SET, bag));
ASSERT_TRUE(d_nodeManager->mkNode(BAG_TO_SET, bag).getType().isSet());
}
@@ -115,9 +121,10 @@ TEST_F(TestTheoryWhiteBagsTypeRule, to_set_operator)
TEST_F(TestTheoryWhiteBagsTypeRule, map_operator)
{
std::vector<Node> elements = getNStrings(1);
- Node bag = d_nodeManager->mkBag(d_nodeManager->stringType(),
- elements[0],
- d_nodeManager->mkConst(Rational(10)));
+ Node bag = d_nodeManager->mkBag(
+ d_nodeManager->stringType(),
+ elements[0],
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(10)));
Node set =
d_nodeManager->mkSingleton(d_nodeManager->stringType(), elements[0]);
@@ -134,7 +141,7 @@ TEST_F(TestTheoryWhiteBagsTypeRule, map_operator)
ASSERT_EQ(d_nodeManager->integerType(),
mappedBag.getType().getBagElementType());
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
Node x2 = d_nodeManager->mkBoundVar("x", d_nodeManager->integerType());
std::vector<Node> args2;
args2.push_back(x2);
diff --git a/test/unit/theory/theory_black.cpp b/test/unit/theory/theory_black.cpp
index d8ae8e468..1aea9e481 100644
--- a/test/unit/theory/theory_black.cpp
+++ b/test/unit/theory/theory_black.cpp
@@ -41,8 +41,8 @@ TEST_F(TestTheoryBlack, array_const)
{
TypeNode arrType = d_nodeManager->mkArrayType(d_nodeManager->integerType(),
d_nodeManager->integerType());
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
Node storeAll = d_nodeManager->mkConst(ArrayStoreAll(arrType, zero));
ASSERT_TRUE(storeAll.isConst());
diff --git a/test/unit/theory/theory_bv_int_blaster_white.cpp b/test/unit/theory/theory_bv_int_blaster_white.cpp
index 39ae835e0..106a0a39e 100644
--- a/test/unit/theory/theory_bv_int_blaster_white.cpp
+++ b/test/unit/theory/theory_bv_int_blaster_white.cpp
@@ -40,7 +40,7 @@ class TestTheoryWhiteBvIntblaster : public TestSmtNoFinishInit
d_slvEngine->setOption("produce-models", "true");
d_slvEngine->finishInit();
d_true = d_nodeManager->mkConst<bool>(true);
- d_one = d_nodeManager->mkConst<Rational>(Rational(1));
+ d_one = d_nodeManager->mkConst<Rational>(CONST_RATIONAL, Rational(1));
}
Node d_true;
Node d_one;
@@ -64,7 +64,7 @@ TEST_F(TestTheoryWhiteBvIntblaster, intblaster_constants)
IntBlaster intBlaster(
env, options::SolveBVAsIntMode::SUM, 1, false);
Node result = intBlaster.translateNoChildren(bv7_4, lemmas, skolems);
- Node seven = d_nodeManager->mkConst(Rational(7));
+ Node seven = d_nodeManager->mkConst(CONST_RATIONAL, Rational(7));
ASSERT_EQ(seven, result);
// translating integer constants should not change them
diff --git a/test/unit/theory/theory_engine_white.cpp b/test/unit/theory/theory_engine_white.cpp
index 8185c2354..9aeedbfe6 100644
--- a/test/unit/theory/theory_engine_white.cpp
+++ b/test/unit/theory/theory_engine_white.cpp
@@ -80,7 +80,7 @@ TEST_F(TestTheoryWhiteEngine, rewriter_simple)
Node z = d_nodeManager->mkVar("z", d_nodeManager->integerType());
// make the expression (PLUS x y (MULT z 0))
- Node zero = d_nodeManager->mkConst(Rational("0"));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational("0"));
Node zTimesZero = d_nodeManager->mkNode(MULT, z, zero);
Node n = d_nodeManager->mkNode(PLUS, x, y, zTimesZero);
@@ -111,8 +111,8 @@ TEST_F(TestTheoryWhiteEngine, rewriter_complex)
"g",
d_nodeManager->mkFunctionType(d_nodeManager->realType(),
d_nodeManager->integerType()));
- Node one = d_nodeManager->mkConst(Rational("1"));
- Node two = d_nodeManager->mkConst(Rational("2"));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational("1"));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational("2"));
Node f1 = d_nodeManager->mkNode(APPLY_UF, f, one);
Node f2 = d_nodeManager->mkNode(APPLY_UF, f, two);
diff --git a/test/unit/theory/theory_int_opt_white.cpp b/test/unit/theory/theory_int_opt_white.cpp
index 5f440006b..aee6a249b 100644
--- a/test/unit/theory/theory_int_opt_white.cpp
+++ b/test/unit/theory/theory_int_opt_white.cpp
@@ -18,11 +18,11 @@
#include "test_smt.h"
#include "util/rational.h"
-namespace cvc5 {
-
-using namespace theory;
-using namespace smt;
+using namespace cvc5::kind;
+using namespace cvc5::theory;
+using namespace cvc5::smt;
+namespace cvc5 {
namespace test {
class TestTheoryWhiteIntOpt : public TestSmtNoFinishInit
@@ -44,8 +44,8 @@ class TestTheoryWhiteIntOpt : public TestSmtNoFinishInit
TEST_F(TestTheoryWhiteIntOpt, max)
{
- Node ub = d_nodeManager->mkConst(Rational("100"));
- Node lb = d_nodeManager->mkConst(Rational("0"));
+ Node ub = d_nodeManager->mkConst(CONST_RATIONAL, Rational("100"));
+ Node lb = d_nodeManager->mkConst(CONST_RATIONAL, Rational("0"));
// Objectives to be optimized max_cost is max objective
Node max_cost = d_nodeManager->mkVar(*d_intType);
@@ -75,8 +75,8 @@ TEST_F(TestTheoryWhiteIntOpt, max)
TEST_F(TestTheoryWhiteIntOpt, min)
{
- Node ub = d_nodeManager->mkConst(Rational("100"));
- Node lb = d_nodeManager->mkConst(Rational("0"));
+ Node ub = d_nodeManager->mkConst(CONST_RATIONAL, Rational("100"));
+ Node lb = d_nodeManager->mkConst(CONST_RATIONAL, Rational("0"));
// Objectives to be optimized max_cost is max objective
Node max_cost = d_nodeManager->mkVar(*d_intType);
@@ -106,8 +106,8 @@ TEST_F(TestTheoryWhiteIntOpt, min)
TEST_F(TestTheoryWhiteIntOpt, result)
{
- Node ub = d_nodeManager->mkConst(Rational("100"));
- Node lb = d_nodeManager->mkConst(Rational("0"));
+ Node ub = d_nodeManager->mkConst(CONST_RATIONAL, Rational("100"));
+ Node lb = d_nodeManager->mkConst(CONST_RATIONAL, Rational("0"));
// Objectives to be optimized max_cost is max objective
Node max_cost = d_nodeManager->mkVar(*d_intType);
@@ -134,9 +134,9 @@ TEST_F(TestTheoryWhiteIntOpt, result)
TEST_F(TestTheoryWhiteIntOpt, open_interval)
{
- Node ub1 = d_nodeManager->mkConst(Rational("100"));
- Node lb1 = d_nodeManager->mkConst(Rational("0"));
- Node lb2 = d_nodeManager->mkConst(Rational("110"));
+ Node ub1 = d_nodeManager->mkConst(CONST_RATIONAL, Rational("100"));
+ Node lb1 = d_nodeManager->mkConst(CONST_RATIONAL, Rational("0"));
+ Node lb2 = d_nodeManager->mkConst(CONST_RATIONAL, Rational("110"));
Node cost1 = d_nodeManager->mkVar(*d_intType);
Node cost2 = d_nodeManager->mkVar(*d_intType);
diff --git a/test/unit/theory/theory_sets_rewriter_white.cpp b/test/unit/theory/theory_sets_rewriter_white.cpp
new file mode 100644
index 000000000..49dbe0c73
--- /dev/null
+++ b/test/unit/theory/theory_sets_rewriter_white.cpp
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * Top contributors (to current version):
+ * Mudathir Mohamed
+ *
+ * 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.
+ * ****************************************************************************
+ *
+ * White box testing of sets rewriter
+ */
+
+#include "expr/dtype.h"
+#include "expr/emptyset.h"
+#include "test_smt.h"
+#include "theory/sets/theory_sets_rewriter.h"
+#include "util/rational.h"
+#include "util/string.h"
+
+namespace cvc5 {
+
+using namespace theory;
+using namespace kind;
+using namespace theory::sets;
+
+namespace test {
+
+typedef expr::Attribute<Node, Node> attribute;
+
+class TestTheoryWhiteSetsRewriter : public TestSmt
+{
+ protected:
+ void SetUp() override
+ {
+ TestSmt::SetUp();
+ d_rewriter.reset(new TheorySetsRewriter());
+ }
+ std::unique_ptr<TheorySetsRewriter> d_rewriter;
+};
+
+TEST_F(TestTheoryWhiteSetsRewriter, map)
+{
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ TypeNode stringType = d_nodeManager->stringType();
+ TypeNode integerType = d_nodeManager->integerType();
+ Node emptysetInteger =
+ d_nodeManager->mkConst(EmptySet(d_nodeManager->mkSetType(integerType)));
+ Node emptysetString =
+ d_nodeManager->mkConst(EmptySet(d_nodeManager->mkSetType(stringType)));
+ Node x = d_nodeManager->mkBoundVar("x", stringType);
+ Node bound = d_nodeManager->mkNode(kind::BOUND_VAR_LIST, x);
+ Node lambda = d_nodeManager->mkNode(LAMBDA, bound, one);
+
+ // (set.map (lambda ((x U)) t) (as set.empty (Set String)) =
+ // (as set.empty (Set Int))
+ Node n1 = d_nodeManager->mkNode(SET_MAP, lambda, emptysetString);
+ RewriteResponse response1 = d_rewriter->postRewrite(n1);
+ ASSERT_TRUE(response1.d_node == emptysetInteger
+ && response1.d_status == REWRITE_DONE);
+
+ Node a = d_nodeManager->mkConst(String("a"));
+ Node b = d_nodeManager->mkConst(String("b"));
+ Node A = d_nodeManager->mkSingleton(d_nodeManager->stringType(), a);
+ Node B = d_nodeManager->mkSingleton(d_nodeManager->stringType(), b);
+ Node unionAB = d_nodeManager->mkNode(SET_UNION, A, B);
+
+ // (set.map
+ // (lambda ((x String)) 1)
+ // (set.union (set.singleton "a") (set.singleton "b"))) = (set.singleton 1))
+ Node n2 = d_nodeManager->mkNode(SET_MAP, lambda, unionAB);
+ Node rewritten2 = Rewriter::rewrite(n2);
+ Node bag = d_nodeManager->mkSingleton(d_nodeManager->integerType(), one);
+ ASSERT_TRUE(rewritten2 == bag);
+
+ // - (set.map f (set.union K1 K2)) =
+ // (set.union (set.map f K1) (set.map f K2))
+ Node k1 = d_skolemManager->mkDummySkolem("K1", A.getType());
+ Node k2 = d_skolemManager->mkDummySkolem("K2", A.getType());
+ Node f = d_skolemManager->mkDummySkolem("f", lambda.getType());
+ Node unionK1K2 = d_nodeManager->mkNode(SET_UNION, k1, k2);
+ Node n3 = d_nodeManager->mkNode(SET_MAP, f, unionK1K2);
+ Node rewritten3 = Rewriter::rewrite(n3);
+ Node mapK1 = d_nodeManager->mkNode(SET_MAP, f, k1);
+ Node mapK2 = d_nodeManager->mkNode(SET_MAP, f, k2);
+ Node unionMapK1K2 = d_nodeManager->mkNode(SET_UNION, mapK1, mapK2);
+ ASSERT_TRUE(rewritten3 == unionMapK1K2);
+}
+
+} // namespace test
+} // namespace cvc5
diff --git a/test/unit/theory/theory_sets_type_rules_white.cpp b/test/unit/theory/theory_sets_type_rules_white.cpp
index 2fcd626e3..f5ca53451 100644
--- a/test/unit/theory/theory_sets_type_rules_white.cpp
+++ b/test/unit/theory/theory_sets_type_rules_white.cpp
@@ -19,10 +19,9 @@
#include "theory/sets/singleton_op.h"
#include "util/rational.h"
-namespace cvc5 {
-
using namespace cvc5::api;
+namespace cvc5 {
namespace test {
class TestTheoryWhiteSetsTypeRuleApi : public TestApi
@@ -68,8 +67,9 @@ TEST_F(TestTheoryWhiteSetsTypeRuleInternal, singleton_node)
d_nodeManager->mkConst(SetSingletonOp(d_nodeManager->integerType()));
Node singletonReal =
d_nodeManager->mkConst(SetSingletonOp(d_nodeManager->realType()));
- Node intConstant = d_nodeManager->mkConst(Rational(1));
- Node realConstant = d_nodeManager->mkConst(Rational(1, 5));
+ Node intConstant = d_nodeManager->mkConst(kind::CONST_RATIONAL, Rational(1));
+ Node realConstant =
+ d_nodeManager->mkConst(kind::CONST_RATIONAL, Rational(1, 5));
// (singleton (singleton_op Real) 1)
ASSERT_NO_THROW(
d_nodeManager->mkSingleton(d_nodeManager->realType(), intConstant));
diff --git a/test/unit/theory/theory_strings_skolem_cache_black.cpp b/test/unit/theory/theory_strings_skolem_cache_black.cpp
index 24ed0cd06..bb4b8122b 100644
--- a/test/unit/theory/theory_strings_skolem_cache_black.cpp
+++ b/test/unit/theory/theory_strings_skolem_cache_black.cpp
@@ -21,10 +21,10 @@
#include "util/rational.h"
#include "util/string.h"
-namespace cvc5 {
-
-using namespace theory::strings;
+using namespace cvc5::kind;
+using namespace cvc5::theory::strings;
+namespace cvc5 {
namespace test {
class TestTheoryBlackStringsSkolemCache : public TestSmt
@@ -33,7 +33,7 @@ class TestTheoryBlackStringsSkolemCache : public TestSmt
TEST_F(TestTheoryBlackStringsSkolemCache, mkSkolemCached)
{
- Node zero = d_nodeManager->mkConst(Rational(0));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
Node n = d_skolemManager->mkDummySkolem("n", d_nodeManager->integerType());
Node a = d_skolemManager->mkDummySkolem("a", d_nodeManager->stringType());
Node b = d_skolemManager->mkDummySkolem("b", d_nodeManager->stringType());
diff --git a/test/unit/theory/type_enumerator_white.cpp b/test/unit/theory/type_enumerator_white.cpp
index bb7ef871c..ac7472560 100644
--- a/test/unit/theory/type_enumerator_white.cpp
+++ b/test/unit/theory/type_enumerator_white.cpp
@@ -75,64 +75,64 @@ TEST_F(TestTheoryWhiteTypeEnumerator, arith)
{
TypeEnumerator te(d_nodeManager->integerType());
ASSERT_FALSE(te.isFinished());
- ASSERT_EQ(*te, d_nodeManager->mkConst(Rational(0)));
+ ASSERT_EQ(*te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)));
for (int i = 1; i <= 100; ++i)
{
ASSERT_FALSE(te.isFinished());
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(i)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(i)));
ASSERT_FALSE(te.isFinished());
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-i)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-i)));
}
ASSERT_FALSE(te.isFinished());
te = TypeEnumerator(d_nodeManager->realType());
ASSERT_FALSE(te.isFinished());
- ASSERT_EQ(*te, d_nodeManager->mkConst(Rational(0, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(1, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-1, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(2, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-2, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(1, 2)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-1, 2)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(3, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-3, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(1, 3)));
+ ASSERT_EQ(*te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(0, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(2, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-2, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 2)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1, 2)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(3, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-3, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 3)));
ASSERT_FALSE(te.isFinished());
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-1, 3)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(4, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-4, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(3, 2)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-3, 2)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(2, 3)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-2, 3)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(1, 4)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-1, 4)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(5, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-5, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1, 3)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(4, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-4, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(3, 2)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-3, 2)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(2, 3)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-2, 3)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 4)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1, 4)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(5, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-5, 1)));
ASSERT_FALSE(te.isFinished());
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(1, 5)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-1, 5)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(6, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-6, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(5, 2)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-5, 2)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(4, 3)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-4, 3)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(3, 4)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-3, 4)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(2, 5)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-2, 5)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(1, 6)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 5)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1, 5)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(6, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-6, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(5, 2)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-5, 2)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(4, 3)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-4, 3)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(3, 4)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-3, 4)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(2, 5)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-2, 5)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 6)));
ASSERT_FALSE(te.isFinished());
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-1, 6)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(7, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-7, 1)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(5, 3)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-5, 3)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(3, 5)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-3, 5)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(1, 7)));
- ASSERT_EQ(*++te, d_nodeManager->mkConst(Rational(-1, 7)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1, 6)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(7, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-7, 1)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(5, 3)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-5, 3)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(3, 5)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-3, 5)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1, 7)));
+ ASSERT_EQ(*++te, d_nodeManager->mkConst(CONST_RATIONAL, Rational(-1, 7)));
ASSERT_FALSE(te.isFinished());
}
@@ -265,26 +265,26 @@ TEST_F(TestTheoryWhiteTypeEnumerator, arrays_infinite)
// ensure that certain items were found
TypeNode arrayType = d_nodeManager->mkArrayType(d_nodeManager->integerType(),
d_nodeManager->integerType());
- Node zeroes = d_nodeManager->mkConst(
- ArrayStoreAll(arrayType, d_nodeManager->mkConst(Rational(0))));
- Node ones = d_nodeManager->mkConst(
- ArrayStoreAll(arrayType, d_nodeManager->mkConst(Rational(1))));
- Node twos = d_nodeManager->mkConst(
- ArrayStoreAll(arrayType, d_nodeManager->mkConst(Rational(2))));
- Node threes = d_nodeManager->mkConst(
- ArrayStoreAll(arrayType, d_nodeManager->mkConst(Rational(3))));
- Node fours = d_nodeManager->mkConst(
- ArrayStoreAll(arrayType, d_nodeManager->mkConst(Rational(4))));
- Node tens = d_nodeManager->mkConst(
- ArrayStoreAll(arrayType, d_nodeManager->mkConst(Rational(10))));
+ Node zeroes = d_nodeManager->mkConst(ArrayStoreAll(
+ arrayType, d_nodeManager->mkConst(CONST_RATIONAL, Rational(0))));
+ Node ones = d_nodeManager->mkConst(ArrayStoreAll(
+ arrayType, d_nodeManager->mkConst(CONST_RATIONAL, Rational(1))));
+ Node twos = d_nodeManager->mkConst(ArrayStoreAll(
+ arrayType, d_nodeManager->mkConst(CONST_RATIONAL, Rational(2))));
+ Node threes = d_nodeManager->mkConst(ArrayStoreAll(
+ arrayType, d_nodeManager->mkConst(CONST_RATIONAL, Rational(3))));
+ Node fours = d_nodeManager->mkConst(ArrayStoreAll(
+ arrayType, d_nodeManager->mkConst(CONST_RATIONAL, Rational(4))));
+ Node tens = d_nodeManager->mkConst(ArrayStoreAll(
+ arrayType, d_nodeManager->mkConst(CONST_RATIONAL, Rational(10))));
- Node zero = d_nodeManager->mkConst(Rational(0));
- Node one = d_nodeManager->mkConst(Rational(1));
- Node two = d_nodeManager->mkConst(Rational(2));
- Node three = d_nodeManager->mkConst(Rational(3));
- Node four = d_nodeManager->mkConst(Rational(4));
- Node five = d_nodeManager->mkConst(Rational(5));
- Node eleven = d_nodeManager->mkConst(Rational(11));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
+ Node one = d_nodeManager->mkConst(CONST_RATIONAL, Rational(1));
+ Node two = d_nodeManager->mkConst(CONST_RATIONAL, Rational(2));
+ Node three = d_nodeManager->mkConst(CONST_RATIONAL, Rational(3));
+ Node four = d_nodeManager->mkConst(CONST_RATIONAL, Rational(4));
+ Node five = d_nodeManager->mkConst(CONST_RATIONAL, Rational(5));
+ Node eleven = d_nodeManager->mkConst(CONST_RATIONAL, Rational(11));
ASSERT_EQ(elts.find(d_nodeManager->mkNode(STORE, ones, zero, zero)),
elts.end());
diff --git a/test/unit/util/array_store_all_white.cpp b/test/unit/util/array_store_all_white.cpp
index 1272926db..887a214dd 100644
--- a/test/unit/util/array_store_all_white.cpp
+++ b/test/unit/util/array_store_all_white.cpp
@@ -18,6 +18,8 @@
#include "test_smt.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace test {
@@ -30,15 +32,15 @@ TEST_F(TestUtilWhiteArrayStoreAll, store_all)
TypeNode usort = d_nodeManager->mkSort("U");
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->integerType(),
d_nodeManager->realType()),
- d_nodeManager->mkConst(Rational(9, 2)));
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(9, 2)));
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->mkSort("U"), usort),
d_nodeManager->mkConst(UninterpretedConstant(usort, 0)));
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->mkBitVectorType(8),
d_nodeManager->realType()),
- d_nodeManager->mkConst(Rational(0)));
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)));
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->mkBitVectorType(8),
d_nodeManager->integerType()),
- d_nodeManager->mkConst(Rational(0)));
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)));
}
TEST_F(TestUtilWhiteArrayStoreAll, type_errors)
@@ -47,13 +49,14 @@ TEST_F(TestUtilWhiteArrayStoreAll, type_errors)
d_nodeManager->mkConst(UninterpretedConstant(
d_nodeManager->mkSort("U"), 0))),
IllegalArgumentException);
- ASSERT_THROW(ArrayStoreAll(d_nodeManager->integerType(),
- d_nodeManager->mkConst(Rational(9, 2))),
- IllegalArgumentException);
+ ASSERT_THROW(
+ ArrayStoreAll(d_nodeManager->integerType(),
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(9, 2))),
+ IllegalArgumentException);
ASSERT_THROW(
ArrayStoreAll(d_nodeManager->mkArrayType(d_nodeManager->integerType(),
d_nodeManager->mkSort("U")),
- d_nodeManager->mkConst(Rational(9, 2))),
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(9, 2))),
IllegalArgumentException);
}
@@ -70,9 +73,10 @@ TEST_F(TestUtilWhiteArrayStoreAll, const_error)
IllegalArgumentException);
ASSERT_THROW(
ArrayStoreAll(d_nodeManager->integerType(),
- d_nodeManager->mkNode(kind::PLUS,
- d_nodeManager->mkConst(Rational(1)),
- d_nodeManager->mkConst(Rational(0)))),
+ d_nodeManager->mkNode(
+ kind::PLUS,
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(1)),
+ d_nodeManager->mkConst(CONST_RATIONAL, Rational(0)))),
IllegalArgumentException);
}
} // namespace test
diff --git a/test/unit/util/datatype_black.cpp b/test/unit/util/datatype_black.cpp
index 760bb2f75..15dde0cc2 100644
--- a/test/unit/util/datatype_black.cpp
+++ b/test/unit/util/datatype_black.cpp
@@ -21,6 +21,8 @@
#include "test_smt.h"
#include "util/rational.h"
+using namespace cvc5::kind;
+
namespace cvc5 {
namespace test {
@@ -247,7 +249,7 @@ TEST_F(TestUtilBlackDatatype, listIntUpdate)
const DType& ldt = listType.getDType();
Node updater = ldt[0][0].getUpdater();
Node gt = listType.mkGroundTerm();
- Node zero = d_nodeManager->mkConst(Rational(0));
+ Node zero = d_nodeManager->mkConst(CONST_RATIONAL, Rational(0));
Node truen = d_nodeManager->mkConst(true);
// construct an update term
Node uterm = d_nodeManager->mkNode(kind::APPLY_UPDATER, updater, gt, zero);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback