Preserve types in rewriter and make core type rules strict (#8740)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Thu, 12 May 2022 17:48:27 +0000 (12:48 -0500)
committerGitHub <noreply@github.com>
Thu, 12 May 2022 17:48:27 +0000 (17:48 +0000)
commita2f5753469c7404a2893ce72425ada6b842915a5
tree98d34dce5bb8cb1bb34739a569c89b20810f4707
parent181fd2fab2b969401ba0d2c69a1daa418c3f505d
Preserve types in rewriter and make core type rules strict (#8740)

This is the key step for eliminating the use of subtyping.

This makes several changes:
(1) CONST_INTEGER is now used for integer constants, which is now exported in the API. The type rule for CONST_RATIONAL is changed to always return Real, even if its value is integral. This means we can distinguish real and integer versions of the integers. Note this also implies that the rewriter now fully preserves types, as rewriting TO_REAL applied to a constant integer will return a constant integral rational.
(2) The type rules for EQUAL, DISTINCT, ITE and APPLY_UF are made strict, in other words, we given a type exception for equalities between an Int and a Real. This restriction impacts the API.
(3) The arithmetic rewrite for (Real) equality casts integers to reals as needed to ensure Reals are only made equal to Reals. The net effect is that TO_REAL may appear on either side of equalities.
(4) The core arithmetic theory solver is modified in several places to be made robust to TO_REAL occurring as the top symbol of sides of equality.

Several assertions are strengthened or added to ensure that equalities and substitutions are between terms of the same type, when it is necessary to do so.

Two quantifiers regressions are modified since the solving techniques are not robust to TO_REAL. A few unit tests are fixed to use proper types.
39 files changed:
NEWS.md
src/api/cpp/cvc5.cpp
src/api/cpp/cvc5.h
src/api/cpp/cvc5_kind.h
src/expr/mkmetakind
src/expr/node_manager_template.cpp
src/parser/smt2/smt2.cpp
src/printer/smt2/smt2_printer.cpp
src/prop/prop_engine.cpp
src/theory/arith/arith_msum.cpp
src/theory/arith/linear/congruence_manager.cpp
src/theory/arith/linear/constraint.cpp
src/theory/arith/linear/normal_form.cpp
src/theory/arith/nl/nl_model.cpp
src/theory/arith/rewriter/rewrite_atom.cpp
src/theory/arith/theory_arith.cpp
src/theory/arith/theory_arith_type_rules.cpp
src/theory/booleans/theory_bool_type_rules.cpp
src/theory/builtin/theory_builtin_type_rules.cpp
src/theory/datatypes/sygus_datatype_utils.cpp
src/theory/quantifiers/cegqi/ceg_instantiator.cpp
src/theory/quantifiers/fmf/full_model_check.cpp
src/theory/quantifiers/fmf/full_model_check.h
src/theory/quantifiers/sygus/type_info.cpp
src/theory/rewriter.cpp
src/theory/theory_engine.cpp
src/theory/theory_model.cpp
src/theory/uf/theory_uf_type_rules.cpp
test/regress/cli/regress0/nl/issue8744-int.smt2
test/regress/cli/regress0/nl/issue8744-real-cov.smt2
test/regress/cli/regress0/nl/issue8744-real.smt2
test/regress/cli/regress0/nl/nta/issue8147-unc-model.smt2
test/regress/cli/regress1/fmf/issue3626.smt2
test/regress/cli/regress1/fmf/sort-inf-int-real.smt2
test/regress/cli/regress1/nl/bad-050217.smt2
test/unit/api/cpp/solver_black.cpp
test/unit/api/java/SolverTest.java
test/unit/api/python/test_solver.py
test/unit/theory/theory_arith_white.cpp