summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2020-06-18Bv to int elimination bugfix (#4435)yoni206
fix 1: ------ The wrong flag was checked in the traversal, causing an assertion error [here](https://github.com/CVC4/CVC4/blob/8236d7f9bff3aef4f7b37a15d509b8a11551401f/src/preprocessing/passes/bv_to_int.cpp#L247) This is fixed in this PR. A test was added as well. fix 2: ------ It is desirable that bv-to-bool runs before bv-to-int, but this was not the case, and is fixed in this PR. Do not merge until after competition release (label added).
2020-06-18Add logic check for define-fun(s)-rec (#4577)Andres Noetzli
This commit adds a logic check for `define-fun-rec`/`define-funs-rec` at the level of the new API that checks whether the logic is quantified and includes UF. To make sure that the parser actually executes that check, this commit converts the `DefineFunctionRecCommand` command to use the new API instead of the old one. This temporarily breaks the `exportTo` functionality for `DefineFunctionRecCommand` but this is not currently used within the CVC4 code base (and it seems unlikely that users use commands).
2020-06-18Improve memory management in Java bindings (#4629)Andres Noetzli
Fixes #2846. One of the challenges of the Java bindings is that the garbage collector can delete unused objects at any time in any order. This is an issue with CVC4's API because we require all `Expr`s to be deleted before the corresponding `ExprManager`. In the past, we were using `NewGlobalRef`/`DeleteGlobalRef` on the wrapper object of `ExprManager`. The problem is that we can have multiple instances of the wrapper that internally all refer to the same `ExprManager`. This commit implements a different approach where the Java wrappers hold an explicit reference to the `ExprManager`. The commit also removes some unused or unimportant API bits from the bindings.
2020-06-17Do not traverse WITNESS for partial substitutions in extended rewriter (#4630)Andrew Reynolds
Fixes #4620. The extended rewrite (and A B) ---> (and A (B * { A -> true } ) triggers an unsoundness when B contains witness terms. More generally, contextual substitution into witness terms is unsound since the skolemization of witness terms is added globally whereas the substitution corresponds to a fact that holds locally. This means that A -> true above may be added as a global constraint indirectly through witness skolemization. A general example of this unsoundness: (or (and (>= x 0) (P (witness ((z Int)) (=> (>= x 0) (= (* z z) x))))) F) rewrites to (or (and (>= x 0) (P (witness ((z Int)) (= (* z z) x)))) F) preprocesses to (and (or (and (>= x 0) (P k)) F) (= (* k k) x)) which now implies that (>= x 0) by the last conjunct, whereas this was not implied in the original formula This PR limits the kinds that can be traversed when applying substitutions in the extended rewriter, including from the rewrite above. In particular, the fix ensures that the partialSubstitute method is used in the extended rewriter when applicable, which now explicitly disallows recursion on WITNESS. Notice that this fixes contextual substitutions in the extended rewriter, but does not fix the more general issue. In particular, we still should be careful to check if contextual substitutions are applied by any other preprocessing passes.
2020-06-17Improve polynomial anyterm grammar (#3566)Haniel Barbosa
This changes the grammar construction in the case of anyterm + polynomial grammar so that the binary predicates EQUAL and LEQ are changed to unary predicates lambda x : ANYTERM. P(x, ZERO) rather than lambda xy. P(ANYTERM, ANYTERM), in which ZERO is a 0 constant of the respective type. Currently integer and bit-vectors are supported for this transformation. This avoid enumerating spurious terms and can lead to significant improvements in enumeration (although not necessarily in solving speed given the current unstable nature of ANYTERM usage).
2020-06-16Update copyright headers.Aina Niemetz
2020-06-16Add missing REQUIRES to new regressions. (#4625)Aina Niemetz
2020-06-16BV: Fix querying equality status in lazy bit-blaster. (#4618)Aina Niemetz
Fixes #4076. In the lazy bit-blaster, when querying the equality status, if the SAT solver has a full model, it is queried for the model values of the operands of the equality. However, the check if the bit-blaster has a full model did not consider the case where no assertions have yet been added, which leads to querying values of bits that are still unassigned in the SAT solver. Co-authored-by: <mathias.preiner@gmail.com>
2020-06-15Fix regressions in regress1 after #4613. (#4616)Aina Niemetz
2020-06-15BV: Add missing type check for BITVECTOR_REPEAT_OP. (#4614)Aina Niemetz
Fixes #4075.
2020-06-15BV: Add missing type check for INT_TO_BITVECTOR. (#4613)Aina Niemetz
Fixes #4130. This further makes an attempt at more consistent error printing.
2020-06-15 Do RE derivation inference only for concrete constant RE (#4609)Andrew Reynolds
The RE derive inference was not designed to handle re.comp. This makes the application of this inference more conservative.
2020-06-10(proof-new) Remove arith-snorm option. (#4591)Andrew Reynolds
This option only marginally helped and will be difficult to support with the new proof infrastructure.
2020-06-10Add support for str.replace_re/str.replace_re_all (#4594)Andres Noetzli
This commit adds support for the last remaining string operators from the new SMT-LIB standard for the theory of strings. The commit adds the kinds, type checking, reductions, and evaluation rewrites for `str.replace_re` and `str.replace_re_all`.
2020-06-10Fix getKind for Python bindings (#4496)makaimann
I noticed recently that getKind for Op and Term was not correct in the python bindings. This PR would add maps to keep track of the Kind objects and the Python names (which are different from the C++ Kind names). Then a Python `kind` only needs the integer representation of a `Kind` to be constructed. Now, in `getKind` it can just pass the integer representation when constructing a `kind`.
2020-06-08Fix ambiguous overload in unit test (#4582)Andres Noetzli
Fixes nightlies. The compiler version used for our nightlies (GCC 5.4.0) complains about mkFunctionSort({bSort}, bSort) being ambiguous because we have two variants of mkFunctionSort(): one that takes a single Sort and one that takes a vector of Sorts. This commit makes the function call unambiguous by removing the use of list initializations.
2020-06-06Fix destruction order in NodeManager (#4578)Andres Noetzli
Fixes #4576. ASan was reporting memory leaks because the skolem manager was being destroyed after the attributes and zombies were already cleaned up in the destructor of NodeManager. This commit changes the destruction order to ensure that the skolem manager is destroyed before the rest of the cleanup. Note: this issue did not only make the benchmark in #4576 fail but several tests in our regressions.
2020-06-06Keep definitions when global-declarations enabled (#4572)Andres Noetzli
Fixes #4552. Fixes #4555. The SMT-LIB standard mandates that definitions are kept when `:global-declarations` are enabled. Until now, CVC4 was keeping track of the symbols of a definition correctly but lost the body of the definition when the user context was popped. This commit fixes the issue by adding a `global` parameter to `SmtEngine::defineFunction()` and `SmtEngine::defineFunctionRec()`. If that parameter is set, the definitions of functions are added at level 0 to `d_definedFunctions` and the lemmas for recursive function definitions are kept in an additional list and asserted during each `checkSat` call. The commit also updates new API, the commands, and the parsers to reflect this change.
2020-06-05Smt2 parsing support for nested recursive datatypes (#4575)Andrew Reynolds
Also includes some minor improvement to expand definitions in TheoryDatatypes leftover from the branch. Adds 3 regressions using the option --dt-nested-rec.
2020-06-05Datatypes with nested recursion are not handled in TheoryDatatypes unless ↵Andrew Reynolds
option is set (#3707) Towards experimental support for non-simply recursive datatypes (https://github.com/ajreynol/CVC4/tree/dtNonSimpleRec). Builds a check for non-simple recursion in the DType class. If a term of a datatype type is registered to TheoryDatatypes for a datatype that has nested recursion, we throw a LogicException unless the option dtNestedRec is set to true. Also includes a bug discovered in the TypeMatcher utility and another in expr::getComponentTypes. It also adds a unit test using the new API for a simple parametric datatype example as well, not related to nested recursion, as this was previously missing.
2020-06-05Skip parse-error regression for comp builds (#4567)Andres Noetzli
Fixes nightlies. Competition builds do not report parsing errors like other builds. As a result, one of the regression tests that is testing for parse errors was failing for competition builds. In this particular example, we just report `unknown`. This commit marks the regression to be skipped for competition builds.
2020-06-05Changing default language (#4561)Haniel Barbosa
Useful to avoid issues when a language is not set and it cannot be easily inferred (for example via the API). Since the language that covers most operators in CVC4 is the SMT one we use that as default now.
2020-06-05Printing FP values as binary or indexed BVs according to option (#4554)Haniel Barbosa
2020-06-05Fix handling of Boolean term variables (#4550)Andres Noetzli
Fixes #4446. This commit fixes two issues related to the handling of Boolean term variables: Removing Boolean subterms and replacing them with a Boolean term variable introduces an equality of the form (= v t) where v is the Boolean term variable and t is the term. It is important that these equalities do not get removed. This commit changes Theory::isLegalElimination() to take this into account. The incorrect model reported in the issue was caused by some of the Boolean term variables not being assigned values by the SAT solver when we decided that the benchmark is satisfiable. Our justification heuristic (correctly) decided that it is enough to satisfy one of the disjuncts in the assertion to satisfy the whole assertion. However, the assignments that we received from the SAT solver restricted us to pick a specific value for one of the Boolean constants: Literal | Value | Expr --------------------------------------------------------- '7 ' 0 c '0 ' 1 true '1 ' 0 false '2 ' 0 (a BOOLEAN_TERM_VARIABLE_274) '5 ' _ b '3 ' 1 (a BOOLEAN_TERM_VARIABLE_277) '4 ' _ BOOLEAN_TERM_VARIABLE_274 '6 ' 0 BOOLEAN_TERM_VARIABLE_277 This meant that we had to pick true for BOOLEAN_TERM_VARIABLE_274 but we picked false since we simply treated it as an unassigned variable. In general, the justification heuristic handles embedded skolems introduced by term removal first and asks the SAT solver to decide on Boolean term variables. However, for some logics, such as QF_AUFLIA, we use the justification heuristic not for decisions but only to decide when to stop, so those decisions were not done. This commit introduces a conservative fix that adds a check after satsifying all the assertions that makes sure that the equalities introduced for Boolean terms are satisfied as well. Due to the eager treatment of Boolean term variables when we use the justification heuristic also for decisions, it is likely that we don't really have the problem in that case but it doesn't hurt to enable the fix. It is also possible that this fix is only required with models but it is definitely safer to just always enable it (there could be tricky corner cases involving the theory combination between UF and Boolean terms). Additionally, this commit changes the ITE-specific naming in the justification heuristic to reflect more accurately that we are in general dealing with skolems introduced by term removals and not only due to ITE removal.
2020-06-05Fix lifetime and copy issues with NodeDfsIterable (#4569)Andres Noetzli
When running node_traversal_black with ASan and UBSan, there were two distinct issues being reported. UBSan was complaining that we were assigning an invalid value to a Boolean. This happened because d_initialized in NodeDfsIterator was uninitialized and the default copy constructor tried to copy it. This commit removes that data member. ASan was complainig that NodeDfsIterator::begin() was trying to access a skip function that had been freed. In particular, this happened when NodeDfsIterable was used in a range-based for loop like so: for (auto n : NodeDfsIterable(n).inPostorder()) { ... } The problem here is that the lifetime of a temporary within the range expression is not extended (the lifetime of the result of the range expression is extended, however) [0]. This is a problem because NodeDfsIterable(n) is a temporary and inPostorder() returns a reference to that temporary. It makes sense that the compiler cannot possibly know that the reference from inPostorder() corresponds to NodeDfsIterable(n), so it cannot extend its lifetime. See [1] for more details on the problem with chained functions. This commit fixes the issue by replacing the fluent interface of NodeDfsIterable by a constructor with default arguments. Additionally, it introduces an enum to represent the visit order to avoid having a nondescript Boolean argument. [0] https://en.cppreference.com/w/cpp/language/range-for#Temporary_range_expression [1] http://cpptruths.blogspot.com/2018/10/chained-functions-break-reference.html?m=1
2020-06-04Add a method for retrieving base of a constant array through API (#4494)makaimann
2020-06-04Update Java tests to match changes in API (#4535)Andres Noetzli
Commit cfeaf40ed6a9d4d7fec925352e30d2470a1ca567 renamed `Result::Validity` and `SmtEngine::query()` to `Result::Entailment` and `SmtEngine::checkEntailed()`, respectively. The commit did not update the Java tests which lead to issues in debug builds with Java bindings. The commit also adds a corresponding `NEWS` entry.
2020-06-04New C++ Api: Second and last batch of API guards. (#4563)Aina Niemetz
This adds the remaining API guards in the Solver object (incl. unit tests).
2020-06-04Fix abduction with datatypes (#4566)Andrew Reynolds
Previously we were treating constructor/selector/tester symbols as arguments to the abduct-to-synthesize.
2020-06-03New C++ Api: First batch of API guards. (#4557)Aina Niemetz
This is the first batch of API guards, mainly extending existing guards in the Solver object with checks that Ops, Terms, Sorts, and datatype objects are associated to this solver object. This further changes how DatatypeConstructorDecl objects are created. Previously, they were not created via the Solver object (while DatatypeDecl was). Now, they are created via Solver::mkDatatypeConstructorDecl, consistent with how DatatypeDecl objects are created.
2020-06-03Do not apply unconstrained simplification when quantifiers are present (#4532)Andrew Reynolds
Fixes #4437. This is a simpler fix that aborts the preprocessing pass when a quantifier is encountered. It also updates our smt2 parser to throw a logic exception when forall/exists is used in non-quantified logics. This is required to ensure that unconstrained simplification does not throw an exception to a user as a result of accidentally setting the wrong logic.
2020-06-02Fix scope issue with pulling ITEs in extended rewriter. (#4547)Andrew Reynolds
Fixes #4476.
2020-06-02Do not handle universal quantification on functions in model-based FMF (#4226)Andrew Reynolds
Fixes #4225, fixes CVC4/cvc4-projects#159, fixes CVC4/cvc4-projects#157, fixes #4289, fixes #4483. This makes it so that the main model-based instantiation algorithm is not applied to quantified formulas with universally quantified functions. Identation changed in a FMF function, this was refactored to conform to guidelines, and further cleaned.
2020-06-02New C++ API: Keep reference to solver object in non-solver objects. (#4549)Aina Niemetz
This is in preparation for adding guards to ensure that sort and term arguments belong to the same solver.
2020-06-01Set theoryof-mode after theory widening (#4545)Andres Noetzli
Fixes #4367. We set the theoryof-mode depending on whether sharing is enabled or not. However, we were checking whether sharing was enabled before theory widening, leading to unexpected results. This commit moves the check after widening the theories. For the benchmark in the issue, setting the theoryof-mode before theory widening lead to problems because of the following: The main solver checks the condition for enabling term-based theoryof-mode, decides not to do it because sharing is not enabled Main solver adds UF to the logic Main solver does a check-sat all Unsat core check runs, sees both UF and NRA enabled, and switches to term-based mode Main solver gets to second check-sat call, now the theoryof-mode is suddenly changed, which leads to problems in the equality engine This commit fixes the issue in this particular instance but it is important to note that it does not address the issue of the subsolver changing settings in general. This can only really be solved by separating the options from the ExprManager/NodeManager and having separate options for each SmtEngine/Solver instance.
2020-06-01Do not parse ->/lambda unless --uf-ho enabled (#4544)Andres Noetzli
Fixes #4477. Logic ALL includes higher-order but we currently do not support solving higher-order problems unless --uf-ho is enabled. This commit changes the condition under which we parse -> and lambda to only enabled parsing of those symbols if the logic allows higher-order constraints and --uf-ho is enabled.
2020-06-01Incorporate sequences into the word interface (#4543)Andrew Reynolds
Also renames a function mkWord -> mkWordFlatten.
2020-05-31Do not cache operator eliminations in arith (#4542)Andres Noetzli
Fixes #4525. The actual problem in the issue is not that the unsat core is satisfiable but that our unsat core check is not working as intended. Our unsat core check uses the same `ExprManager` as the main `SmtEngine` and thus also shares the same attributes for nodes. However, since we have a different `SmtEngine` instance for the check, we also have different instances of `TheoryArith`. This leads to the check failing due to the following: - Our only input assertion is `(> (cot 0.0) (/ 1 0)))`. - `TheoryArith::expandDefinition()` gets called on `(> (cot 0.0) (/ 1 0))` but nothing happens. - `TheoryArith::expandDefinition()` gets called on `(/ 1 0)`, which gets expanded as expected but no attribute is set because it happens in a simple `TheoryArith::eliminateOperators()` call. - `TheoryArith::expandDefinition()` on `(cot (/ 0 1))` first expands to `(/ 1 0)` (not cached) and then we expand it recursively to the expected term and cache `(/ 1 0) ---> (ite (= 0 0) (divByZero 1.0) (/ 1 0))`. Up to this point, things are suboptimal but there are no correctness issues. The problem starts when we do the same process in the unsat core check: - Our only input assertion is again `(> (cot 0.0) (/ 1 0)))`. - `TheoryArith::expandDefinition()` gets called on `(> (cot 0.0) (/ 1 0))` but nothing happens. - `TheoryArith::expandDefinition()` gets called on `(/ 1 0)`, which gets expanded as expected but no attribute is set or checked because it happens in a simple `TheoryArith::eliminateOperators()` call. Note that the skolem introduced here for the division-by-zero case is different from the skolem introduced above because this is in a different `TheoryArith` instance that does not know the existing skolems. - `TheoryArith::expandDefinition()` on `(cot (/ 0 1))` first expands to `(/ 1 0)` (not cached) and then we use the cache from our solving call to expand it `(/ 1 0) ---> (ite (= 0 0) (divByZero 1.0) (/ 1 0))`. Note that `divByZero` here is the skolem from the main solver. As a result, the preprocessed assertions mix skolems from the main `SmtEngine` with the `SmtEngine` of the unsat core check, making the constraints satisfiable. To solve this problem, this commit removes the caching-by-attribute mechanism. The reason for removing it is that it is currently ineffective (since most eliminations do not seem to be cached) and there are caches at other levels, e.g. when expanding definitions. If we deem the operator elimination to be a bottleneck, we can introduce a similar mechanism at the level of `TheoryArith`.
2020-05-30update example in README to use ctest. (#4540)yoni206
An example for restricting timeout in tests uses the old `make regress0` instead of the new `ctest -L regress0`
2020-05-26Fix an incorrect limit in conversion from real to float (#4418)Martin
This error is a bit inexplicable but very very definitely wrong. A test case from the original bug report is included.
2020-05-22Refactor operator elimination in arithmetic (#4519)Andrew Reynolds
This is a major refactor of how operators are eliminated in arithmetic. Currently there were (at least) two things wrong: (1) ppRewriteTerm sent lemmas on the output channel. This behavior is incompatible with how preprocessing works. In particular, this caused unconstrained simplification to be unaware of terms from such lemmas, leading to incorrect "sat" answers. (2) Lemmas used to eliminate certain "div-like" terms were processed in a context-independent way. However, lemmas should be cached in a user-context-dependent way. This was leading to incorrect "sat" answers in incremental. The solution to these issues is to eliminate operators via the construction of witness terms. No lemmas are sent out, and instead these lemmas are the consequence of term formula removal in the standard way. As a result of the refactor, 2 quantifiers regressions time out due to infinite branch and bound issues (one only during --check-unsat-cores). These appear to be random and I've changed the options to avoid these issues. 3 others now have check-model warnings, which I've added --quiet to. Improving check-model will be addressed on a future PR. This PR is not required for SMT COMP since we have workarounds that avoid both the incorrect behaviors in our scripts. Also notice that --rewrite-divk is effectively now enabled by default always. Fixes #4484, fixes #4486, fixes #4481.
2020-05-22(proof-new) Add rewrite corresponding to regular expression inclusion (#4513)Andrew Reynolds
This introduces a rewrite based on regular expression inclusion (using calls to the RegExpEntail utility function). This allows us to justify the regular expression inclusion inference as a rewrite.
2020-05-21Disable re-elim by default (#4508)Andrew Reynolds
Disabling re-elim performs better overall in many recent experiments.
2020-05-21Make Grammar reusable. (#4506)Abdalrhman Mohamed
This PR modifies the Grammar implementation to make it reusable (i.e., can be copied or passed multiple times to synthFun/synthInv) with the catch that it becomes read-only after the first use.
2020-05-20Fix missing check for cardinality one in unconstrained simplifier (#4504)Andrew Reynolds
Fixes #4482.
2020-05-20Normal form equality conflicts and uniqueness check (#4497)Andrew Reynolds
This adds a new inference schema to strings that was discovered by the internal proof checker. It says that we are in conflict when an equality between the normal forms of two terms in the same equivalence class rewrites to false. It also improves the efficiency of processing normal forms by only considering normal forms that are unique up to rewriting.
2020-05-20Fix parametric datatype instantiation (#4493)Andrew Reynolds
A bug was introduced when adding the Node-level datatype implementation in d803e7f. The code did not probably get the arity of a sort constructor. This adds TypeNode::getSortConstructorArity and uses it during parametric datatype type resolution.
2020-05-20Use debug-check-model to enable internal debugging in check-model (#4480)Andrew Reynolds
Notice this also updates our regression script to use --debug-check-model, preserving previous behavior. Fixes #4461, fixes #4470, fixes #4471, fixes #4475, fixes #4448, fixes #4466, fixes #4460, fixes #4458, fixes #4455, fixes #4456, fixes #4386, fixes #4385, fixes #4478, fixes #4474.
2020-05-19Do not eliminate variables that are equal to unevaluatable terms (#4267)Andrew Reynolds
When we eliminate a variable x -> v during simplification, it may be the case that v contains "unevaluated" operators like forall, choice, etc. Thus, we do not produce correct models for such inputs unless simplification is disabled. This PR ensures we only eliminate variables when v contains only evaluated operators. Additionally, the kinds registered as unevaluated were slightly modified so that when we are in a logic like QF_LIA, there are no registered unevaluated operators, hence the check above is unnecessary. This is to minimize the performance impact of this change. Fixes #4500.
2020-05-19Fix cached free variable identifiers in sygus term database (#4394)Andrew Reynolds
Fixes an issue with over-pruning in SyGuS where using multiple sygus types that map to the same builtin type. Our mapping sygusToBuiltin did not ensure that free variables were unique. Fixes #4383.
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback