Andres Noetzli [Fri, 5 Jun 2020 12:22:18 +0000 (05:22 -0700)]
Fix handling of Boolean term variables (#4550)
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.
Andres Noetzli [Fri, 5 Jun 2020 12:03:16 +0000 (05:03 -0700)]
Fix lifetime and copy issues with NodeDfsIterable (#4569)
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
Andrew V. Jones [Fri, 5 Jun 2020 02:18:16 +0000 (03:18 +0100)]
If using 'ninja', tell the user to run 'ninja' not 'make' (#4568)
## Issue
If you call CVC4's `configure` script with `--ninja`, then you get a misleading status message:
```
[avj@tempvm CVC4]$ ./configure.sh --ninja --python3 | tail -n 5
Now change to 'build' and type make, followed by make check or make install.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/avj/working/CVC4/build
```
## Solution
This commit simply fixes the status message to tell the user to run the correct command based on the specified generator:
```
[avj@tempvm CVC4]$ ./configure.sh --ninja --python3 | tail -n 5
Now change to 'build' and type 'ninja', followed by 'ninja check' or 'ninja install'.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/avj/working/CVC4/build
```
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
makaimann [Fri, 5 Jun 2020 01:21:37 +0000 (18:21 -0700)]
Add a method for retrieving base of a constant array through API (#4494)
Andres Noetzli [Fri, 5 Jun 2020 00:27:33 +0000 (17:27 -0700)]
Update Java tests to match changes in API (#4535)
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.
makaimann [Thu, 4 Jun 2020 22:18:35 +0000 (15:18 -0700)]
Wrap Result in Python API (#4473)
This PR would change the Python API to wrap the C++ Result class instead of translating it to a pure Python class. This is more convenient because there are several possibilities other than sat/unsat/unknown. Furthermore, this PR updates the bitvectors.py example which had an incorrect function name "checkEntailment" and adds a floating point example contributed by Eva Darulova.
Aina Niemetz [Thu, 4 Jun 2020 18:07:41 +0000 (11:07 -0700)]
New C++ Api: Second and last batch of API guards. (#4563)
This adds the remaining API guards in the Solver object (incl. unit tests).
Andrew Reynolds [Thu, 4 Jun 2020 17:38:36 +0000 (12:38 -0500)]
Add sygus datatype substitution utility method (#4390)
This makes the method for substiutiton and generalization of sygus datatypes a generic utility method. It updates the abduction method to use it. Interpolation is another target user of this utility.
Andrew Reynolds [Thu, 4 Jun 2020 16:31:55 +0000 (11:31 -0500)]
Fix abduction with datatypes (#4566)
Previously we were treating constructor/selector/tester symbols as arguments to the abduct-to-synthesize.
Andrew Reynolds [Thu, 4 Jun 2020 14:52:55 +0000 (09:52 -0500)]
Theory strings preprocess (#4534)
This makes it so that the main reduce function in TheoryStringsPreprocess is static, so that it can be used both by the solver and the proof checker.
It also updates the functions to make use of IndexVar for constructing canonical universal variables.
Aina Niemetz [Thu, 4 Jun 2020 03:56:24 +0000 (20:56 -0700)]
New C++ Api: First batch of API guards. (#4557)
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.
Haniel Barbosa [Wed, 3 Jun 2020 23:52:49 +0000 (20:52 -0300)]
(proof-new) Adding rules and proof checker for EUF (#4559)
Haniel Barbosa [Wed, 3 Jun 2020 21:54:47 +0000 (18:54 -0300)]
(proof-new) Adding rules and proof checker for Boolean reasoning (#4560)
Andrew Reynolds [Wed, 3 Jun 2020 19:01:13 +0000 (14:01 -0500)]
(proof-new) Add builtin proof checker (#4537)
This adds the proof checker for TheoryBuiltin, which handles the core proof rules (SCOPE and ASSUME) and all proof rules corresponding to generic operations on Node objects. This includes proof rules for rewriting and substitution, which are added in this PR.
Mathias Preiner [Wed, 3 Jun 2020 14:12:07 +0000 (07:12 -0700)]
Fix normalization of author names in contrib/get-authors. (#4553)
Andrew Reynolds [Wed, 3 Jun 2020 13:47:46 +0000 (08:47 -0500)]
Do not apply unconstrained simplification when quantifiers are present (#4532)
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.
Andrew Reynolds [Wed, 3 Jun 2020 13:08:04 +0000 (08:08 -0500)]
Update CEGQI to use lemma status instead of forcing preprocess (#4551)
This PR removes a hack in counterexample-guided quantifier instantiation.
The issue is the CEGQI needs to know the form of certain lemmas, after theory preprocessing. CEGQI needs to know this since it must construct solutions (e.g. solved form of equalities) for free variables in these lemmas, which includes fresh variables in the lemma after postprocess like ITE skolems.
Previously, CEGQI was hacked so that it applied the preprocessing eagerly so that it had full knowledge of the postprocessed lemma. This PR updates CEGQI so that it uses the returned LemmaStatus as the way of getting the lemma after postprocess. It also fixes the lemma status returned by TheoryEngine so that all lemmas not just the "main lemma" are returned as a conjunction.
This PR is in preparation for major refactoring to theory preprocessing for the sake of proofs.
Andrew Reynolds [Wed, 3 Jun 2020 01:57:58 +0000 (20:57 -0500)]
Use prenex normal form when using cegqi-nested-qe (#4522)
Previously, we used a specialized variant of prenex normal form that allowed top level disjunctions. However, the method to put quantifiers into this form led to variable shadowing on some benchmarks in SMT-LIB LRA.
This simplifies the code so that we use standard prenex normal form when cegqi-nested-qe is used and deletes the old variant (DISJ_NORMAL).
makaimann [Wed, 3 Jun 2020 01:10:18 +0000 (18:10 -0700)]
Add Term::substitute to Python bindings (#4499)
makaimann [Tue, 2 Jun 2020 22:18:15 +0000 (15:18 -0700)]
Add hash Op, Sort and Term in Python bindings (#4498)
Andrew Reynolds [Tue, 2 Jun 2020 20:55:49 +0000 (15:55 -0500)]
Fix scope issue with pulling ITEs in extended rewriter. (#4547)
Fixes #4476.
Andrew Reynolds [Tue, 2 Jun 2020 17:22:17 +0000 (12:22 -0500)]
Do not handle universal quantification on functions in model-based FMF (#4226)
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.
Aina Niemetz [Tue, 2 Jun 2020 16:09:15 +0000 (09:09 -0700)]
New C++ API: Keep reference to solver object in non-solver objects. (#4549)
This is in preparation for adding guards to ensure that sort and term
arguments belong to the same solver.
Andrew Reynolds [Mon, 1 Jun 2020 23:34:21 +0000 (18:34 -0500)]
(proof-new) Proof step buffer utilities (#4533)
This class is used for delaying proof node creation until it is necessary.
Andrew Reynolds [Mon, 1 Jun 2020 19:31:48 +0000 (14:31 -0500)]
Move non-linear files to src/theory/arith/nl (#4548)
Also makes CVC4::theory::arith::nl namespace.
This includes some formatting changes.
Andres Noetzli [Mon, 1 Jun 2020 17:14:56 +0000 (10:14 -0700)]
Set theoryof-mode after theory widening (#4545)
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.
Andres Noetzli [Mon, 1 Jun 2020 16:41:16 +0000 (09:41 -0700)]
Do not parse ->/lambda unless --uf-ho enabled (#4544)
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.
Andrew Reynolds [Mon, 1 Jun 2020 14:14:23 +0000 (09:14 -0500)]
Incorporate sequences into the word interface (#4543)
Also renames a function mkWord -> mkWordFlatten.
Andres Noetzli [Sun, 31 May 2020 16:13:39 +0000 (09:13 -0700)]
Do not cache operator eliminations in arith (#4542)
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`.
yoni206 [Sun, 31 May 2020 04:17:59 +0000 (21:17 -0700)]
update example in README to use ctest. (#4540)
An example for restricting timeout in tests uses the old `make regress0` instead of the new `ctest -L regress0`
Andrew Reynolds [Sat, 30 May 2020 18:10:54 +0000 (13:10 -0500)]
Add the sequence type (#4539)
This adds basic infrastructure for the sequence type, including its type rules, type enumerator and extensions to type functions.
The next step will be to finalize the support in TheoryStrings for sequences and then add front end support for sequences in the API/parsers.
Andrew Reynolds [Thu, 28 May 2020 20:05:06 +0000 (15:05 -0500)]
Fix term registry for constant case, simplify. (#4538)
We were getting an assertion failure (causing nightlies to fail) due to the recent optimization to the strings skolem cache (
978f455). This ensures we ignore constant strings in TermRegistry::getRegisterTermAtomicLemma.
It also removes a deprecated option that is deleted in the proof-new branch.
Andrew Reynolds [Wed, 27 May 2020 23:05:07 +0000 (18:05 -0500)]
Add the Expr-level sequence datatype (#4526)
This adds the expr-level sequence datatypes. This is required for further progress on sequences. However, note that this class may be deleted in the further when the Expr level is replaced.
Martin [Wed, 27 May 2020 18:26:51 +0000 (19:26 +0100)]
Tweak the use of static_assert to support older compilers. (#4536)
C++11 introduces static_assert(bool, string).
C++17 introduces static_assert(bool)
By adding a message we can support older compilers such as those
used by our nightly build system...
Martin [Tue, 26 May 2020 18:49:01 +0000 (19:49 +0100)]
Fix an incorrect limit in conversion from real to float (#4418)
This error is a bit inexplicable but very very definitely wrong.
A test case from the original bug report is included.
Andrew Reynolds [Tue, 26 May 2020 17:41:31 +0000 (12:41 -0500)]
Convert more uses of strings to words (#4527)
Mathias Preiner [Tue, 26 May 2020 16:44:51 +0000 (09:44 -0700)]
Fix mismatched iterators (CID
1493892). (#4531)
Issue found by coverity.
Andrew Reynolds [Tue, 26 May 2020 15:27:45 +0000 (10:27 -0500)]
(proof-new) Update proof checker. (#4511)
This adds new required features to proof checker and the base class of proof rule checker.
This is required as the first dependency towards merging further infrastructure related to proofs.
Andrew Reynolds [Tue, 26 May 2020 14:51:13 +0000 (09:51 -0500)]
(proof-new) Updates to strings skolem cache. (#4524)
This PR makes strings skolem cache call the ProofSkolemCache. This is required for proper proof checking, as it makes all skolems be associated with their formal definition, encapsulated by a witness term.
It furthermore makes skolem sharing more uniform and aggressive by noting that most string skolems correspond to purification variables (typically for some substr term). A purification variable for a term that rewrites to a constant can be replaced by the constant itself.
It also introduces an attribute IndexVarAttribute which is used to ensure reductions involving universal variables are deterministic.
Mathias Preiner [Tue, 26 May 2020 01:56:39 +0000 (18:56 -0700)]
Update to CaDiCaL version 1.2.1. (#4530)
Andres Noetzli [Sun, 24 May 2020 03:52:29 +0000 (20:52 -0700)]
[SMT-COMP] Redirect non-answers to /dev/null (#4528)
Commit
00badd3a63a2fa568373d5c58553944b579d42bb changed our run script
to write output other than `sat`/`unsat` to a file if `$2` is passed to
it. However, it looks like StarExec does not pass that parameter to our
script despite the documentation claiming that it does [0]. This commit
makes our check more defensive by redirecting our unnecessary output to
`/dev/null` if `STAREXEC_WALLCLOCK_LIMIT` is set. I've done a quick test
run on StarExec and it looks like this does the trick.
[0]
https://wiki.uiowa.edu/display/stardev/User+Guide#UserGuide-SpecialVariables
mudathirmahgoub [Sat, 23 May 2020 15:28:50 +0000 (10:28 -0500)]
remove unused field d_emp_exp in TheorySetsPrivate (#4521)
Remove unused field d_emp_exp in TheorySetsPrivate
Andrew Reynolds [Sat, 23 May 2020 12:13:42 +0000 (07:13 -0500)]
Add the sequence datatype (#4153)
This class is the Node-level representation of a sequence. It is analogous to CVC4::String.
Abdalrhman Mohamed [Sat, 23 May 2020 04:55:29 +0000 (23:55 -0500)]
Fix mistakes in sygus API comments. (#4520)
Andrew Reynolds [Sat, 23 May 2020 03:39:16 +0000 (22:39 -0500)]
Refactor operator elimination in arithmetic (#4519)
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.
Andres Noetzli [Fri, 22 May 2020 22:33:04 +0000 (15:33 -0700)]
[SMT-COMP] Use tear-down-incremental for arithmetic (#4518)
This commit changes the run-script for the incremental track to use
`--tear-down-incremental=1` for all logics that involve arithmetic. The
main motivation for this change is avoid issues that we have with the
lemmas generated for `mod`/`div` during `ppRewrite` that cause
model-soundness issues.
Aina Niemetz [Fri, 22 May 2020 21:09:54 +0000 (14:09 -0700)]
CaDiCaL: Clean up initialization on creation. (#4516)
Andrew Reynolds [Fri, 22 May 2020 19:27:13 +0000 (14:27 -0500)]
(proof-new) Add rewrite corresponding to regular expression inclusion (#4513)
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.
Aina Niemetz [Fri, 22 May 2020 16:47:55 +0000 (09:47 -0700)]
Cryptominisat: Clean up initialization on creation. (#4515)
Aina Niemetz [Fri, 22 May 2020 13:41:50 +0000 (06:41 -0700)]
Add support for SAT solver Kissat. (#4514)
Andrew Reynolds [Fri, 22 May 2020 13:01:59 +0000 (08:01 -0500)]
(proof-new) Proof node to SExpr utility. (#4512)
This is required for dag-ifying ProofNode output.
Andrew Reynolds [Fri, 22 May 2020 04:40:44 +0000 (23:40 -0500)]
Update string kind names in new API (#4509)
To match the smt2 Unicode standard. The internal ones are left unchanged for now.
Andrew Reynolds [Fri, 22 May 2020 04:10:24 +0000 (23:10 -0500)]
(proof-new) Minor update to strings solver state (#4510)
Andrew Reynolds [Thu, 21 May 2020 23:33:14 +0000 (18:33 -0500)]
Disable re-elim by default (#4508)
Disabling re-elim performs better overall in many recent experiments.
Abdalrhman Mohamed [Thu, 21 May 2020 18:01:14 +0000 (13:01 -0500)]
Make Grammar reusable. (#4506)
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.
Andrew Reynolds [Thu, 21 May 2020 03:27:04 +0000 (22:27 -0500)]
Throw logic exception for equality between regular expressions (#4505)
Fixes #4503.
Andrew Reynolds [Thu, 21 May 2020 02:22:25 +0000 (21:22 -0500)]
Fix missing check for cardinality one in unconstrained simplifier (#4504)
Fixes #4482.
Andrew Reynolds [Wed, 20 May 2020 15:20:34 +0000 (10:20 -0500)]
Normal form equality conflicts and uniqueness check (#4497)
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.
Andrew Reynolds [Wed, 20 May 2020 14:14:54 +0000 (09:14 -0500)]
Add proof skolem cache (#4485)
This adds the general utility for maintaining mappings from Skolems to their witness form via attributes.
I am sending this as a PR now since it would be helpful to use this class for fixing some of the recent unconstrained-simp bugs.
Andrew Reynolds [Wed, 20 May 2020 12:47:24 +0000 (07:47 -0500)]
Fix parametric datatype instantiation (#4493)
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.
Aina Niemetz [Wed, 20 May 2020 07:08:43 +0000 (00:08 -0700)]
CegqiBv: Clean up after renaming options. (#4487)
Andrew Reynolds [Wed, 20 May 2020 05:05:58 +0000 (00:05 -0500)]
Use debug-check-model to enable internal debugging in check-model (#4480)
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.
Abdalrhman Mohamed [Wed, 20 May 2020 03:33:03 +0000 (22:33 -0500)]
Add a simple script to convert sygus v1 files to v2. (#4409)
Andrew Reynolds [Wed, 20 May 2020 02:48:01 +0000 (21:48 -0500)]
Do not eliminate variables that are equal to unevaluatable terms (#4267)
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.
Andrew Reynolds [Wed, 20 May 2020 00:34:18 +0000 (19:34 -0500)]
Fix cached free variable identifiers in sygus term database (#4394)
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.
mudathirmahgoub [Tue, 19 May 2020 21:24:59 +0000 (16:24 -0500)]
Renamed operator CHOICE to WITNESS (#4207)
Renamed operator CHOICE to WITNESS, and removed it from the front end
Andrew Reynolds [Tue, 19 May 2020 20:38:05 +0000 (15:38 -0500)]
Use fresh variables when miniscoping (#4296)
Fixes #4288.
When applying miniscoping, we previously were reusing variables across quantified formulas in the resulting conjunction. This ensures our miniscoping ensures fresh variables.
Andrew Reynolds [Tue, 19 May 2020 19:51:19 +0000 (14:51 -0500)]
Update enum and option names for sygus languages (#4388)
This ensures sygus is interpreted as sygus version 2; sygus1 must be used to specify sygus version 1.
Required for the 1.8 release.
Andres Noetzli [Tue, 19 May 2020 18:31:42 +0000 (11:31 -0700)]
Make SolveEq and PlusCombineLikeTerms idempotent (#4438)
Fixes #3692 and an assertion failure that came up during the test runs
for SMT-COMP. The bit-vector rewrites `SolveEq` and
`PlusCombineLikeTerms` were not always idempotent. At a high level,
`SolveEq` combines common terms from two sides of an equality and
`PlusCombineLikeTerms` combines common terms within an addition.
However, in doing so, these rewrites were reordering the operands of the
bit-vector addition based on the node ids of the terms that were
multiplied with their coefficients. Consider the addition `3 * x * y + 5
* y * z` (the bit-width does not matter). `PlusCombineLikeTerms` would
reorder this addition to `5 * y * z + 3 * x * y` if the node id of `y *
z` was smaller than the node id of `x * y`. The issue is that node ids
are not fixed for a given term: If we have a term `x * y` and that term
reaches ref count 0, we may get a different id for that same term if we
recreate it later on. When terms reach ref count 0, we don't immediately
delete them but add them to our set of zombies to be deleted whenever
the list of zombies grows larger than some fixed size. When applying
`SolveEq` and `PlusCombineLikeTerms` multiple times (even in direct
succession without doing anything else), the node order may change
because some of the terms like `x * y` may be zombies while others have
been deleted and get new ids, leading to the relative order of node ids
changing. I suspect that we could construct a case where we get into an
infinite rewrite loop.
This commit addresses the issue as follows: It does not perform the
rewrites `SolveEq` and `PlusCombineLikeTerms` if none of the operands
change. This makes the rewrites idempotent. Note however that we are
still not guaranteeing that a term has the same rewritten form
throughout an execution because the node ids may change if the term has
been freed in the meantime. However, this limitation is consistent with
other rewrites such as the reordering of equalities.
I am including the minimized test case from our run on SMT-LIB. I am
ommittin the test case from #3692 because I couldn't trigger it on
master (not surprising since the issue requires very specific
circumstances to actually occur). However, I was able to reproduce the
issue on the CVC4 version mentioned in the issue and confirmed that this
fix worked for that older version.
Andrew Reynolds [Tue, 12 May 2020 16:47:47 +0000 (11:47 -0500)]
Do not enable unconstrained simplification if arithmetic is present (#4489)
For now we do not enable unconstrained simplification when arithmetic is present. Post SMT COMP, we should investigate making arithmetic not output lemmas during preprocessing (CVC4/cvc4-wishues#71).
Andres Noetzli [Wed, 6 May 2020 18:44:34 +0000 (11:44 -0700)]
Update run scripts for SMT-COMP 2020 (#4454)
This commit adds additional options for the model validation track and
makes sure that non-"sat"/"unsat" outputs from the sequential porfolio
approaches are written to a file instead of stderr when running on
StarExec.
Andrew Reynolds [Tue, 5 May 2020 21:35:44 +0000 (16:35 -0500)]
Always introduce fresh variable for unconstrained APPLY_UF (#4472)
Fixes an unsoundness in unconstrained simplification, fixes #4469.
Aina Niemetz [Tue, 5 May 2020 19:56:57 +0000 (12:56 -0700)]
Update copyright year and AUTHORS/THANKS files. (#4468)
Aina Niemetz [Sat, 2 May 2020 04:18:55 +0000 (21:18 -0700)]
SMT-COMP 2020: Enable --fp-exp for new FP logics. (#4432)
Andrew Reynolds [Sat, 2 May 2020 03:07:45 +0000 (22:07 -0500)]
Move slow regression to regress3 (#4430)
Andrew Reynolds [Fri, 1 May 2020 00:59:45 +0000 (19:59 -0500)]
Fix regression (#4424)
Fixes regress1.
Andrew Reynolds [Thu, 30 Apr 2020 23:48:21 +0000 (18:48 -0500)]
Remove skolem share involving pre_first_ctn. (#4423)
This fixes a soundness issue in strings caused by an incorrect skolem share.
This adds a regression that corresponds to the rewrite that this skolem share was justified by, which is "sat" (the rewrite does not hold). This benchmark in fact was answered "unsat" by CVC4 prior to this PR.
Andrew Reynolds [Thu, 30 Apr 2020 18:18:26 +0000 (13:18 -0500)]
Do not mark congruent terms are reduced (#4419)
This fixes a potential model soundness issue in strings where a justification for why a string term was reduced relied on a circular argument. The issue involved "reduced by congruence" which states that when f(a) = f(b) ^ a = b in the current context, then one of f(a) or f(b) can be ignored.
However, it may be the case that a is an extended function whose reduction relies on f(b). If we were to assume that f(b) can be ignored due to f(a), then our reduction of f(a) is circular: the reduction of f(a) in the context where a=b relies on itself.
This was causing an incorrect model for QF_S/2020-sygus-qgen/queries/query3214.smt2. The sequence of dependencies was:
[1] (str.contains (str.substr x 1 (+ (- 1) (str.len x))) "CA")
is congruent to
(str.contains (str.substr x (+ 2 (str.indexof x "CA" 1)) (+ (- 2) (str.len x) (* (- 1) (str.indexof x "CA" 1)))) "CA")
in the current context since they are equal and their arguments are equal.
[2] (str.substr x (+ 2 (str.indexof x "CA" 1)) (+ (- 2) (str.len x) (* (- 1) (str.indexof x "CA" 1))))
reduction relies on the length constraint:
(= (str.indexof x "CA" 1) (+ (- 2) (str.len sspre_66)))
[3] (str.indexof x "CA" 1)
reduction relies on:
(not (str.contains (str.substr x 1 (+ (- 1) (str.len x))) "CA"))
which was marked congruent above.
The benchmark now solves in 5 minutes 30 seconds (sat, with a correct model):
andrew@andrew-Latitude-7480:~/misc/strings$ time ajr-cvc4 query3214.smt2 --strings-exp --rewrite-divk --check-models --dump-models
sat
(model
(define-fun x () String "QACOACA")
)
Aina Niemetz [Wed, 29 Apr 2020 20:14:46 +0000 (13:14 -0700)]
SMT-COMP 2020: Fix scripts to use --no-type-checking instead of --no-checking. (#4417)
Andrew Reynolds [Wed, 29 Apr 2020 18:02:02 +0000 (13:02 -0500)]
Avoid circular dependencies for justifying reductions in strings extf eval (#4415)
An incorrect answer of "sat" could be found after 8 seconds on the given benchmark (with --strings-fmf) due to a circular justification for why an extended function was reduced. In particular, we ran checkExtfInference on the same term twice and then marked it as reduced since we had already seen it. This makes the code more conservative.
Notice I'm making the code doubly conservative in case there is any chance for duplication again (e.g. if ExtTheory provides duplicate terms).
Andrew Reynolds [Wed, 29 Apr 2020 17:00:19 +0000 (12:00 -0500)]
Fix strings 2.6 regression (#4413)
Fixes nightlies.
Andres Noetzli [Tue, 28 Apr 2020 20:10:16 +0000 (13:10 -0700)]
Register lower bound for str.to_int (#4408)
This commit changes the term registration for str.to_int terms. Before, we were not sending out any lemmas when registering str.to_int terms. Now, we send a simple lemma that asserts that the value is greater or equal to negative one.
Andrew Reynolds [Tue, 28 Apr 2020 19:37:51 +0000 (14:37 -0500)]
Updates to SMT COMP script for 20 minute timeout (#4406)
Changes run script to be consistent for 20 minute timeout. This divides most of the previous time allocation by 2, with a few exceptions (for non-linear).
It adds a configuration involving --no-arith-brab to QF_NIA and reallocates some time.
Haniel Barbosa [Tue, 28 Apr 2020 19:02:06 +0000 (16:02 -0300)]
update Haniel's affiliation (#4404)
Aina Niemetz [Tue, 28 Apr 2020 17:43:48 +0000 (10:43 -0700)]
contrib/get-gmp: Rename and update install instructions with a warning. (#4407)
Andrew Reynolds [Tue, 28 Apr 2020 16:15:00 +0000 (11:15 -0500)]
Support the SMT-LIB Unicode string standard by default (#4378)
This PR merges --lang=smt2.6.1 and --lang=smt2.6 (default). It makes it so that 2.6 always expects the syntax of the string standard http://smtlib.cs.uiowa.edu/theories-UnicodeStrings.shtml.
I've updated the regressions so that the 2.6 benchmarks are now compliant with the standard. Some of the <=2.5 benchmarks I've updated to 2.6. Others I have left for now, in particular the ones that rely on special characters or ad-hoc escape sequences. The old formats will be supported in the release but removed shortly afterwards.
This PR is a prerequisite for the release, but not necessarily SMT-COMP (which will use --lang=smt2.6.1 if needed). Notice that we still do not have parsing support for str.replace_re or str.replace_re_all. This is required to be fully compliant.
Andrew Reynolds [Tue, 28 Apr 2020 13:07:54 +0000 (08:07 -0500)]
Update cardinality in strings to unicode standard (#4402)
This updates the default cardinality in strings to match the Unicode standard, 196608.
This avoids a check-model failure from 25 benchmarks in SMT-LIB, which were related to a split due to insufficient constants being required during collectModelInfo.
This also makes a few places throw an AlwaysAssert(false) that otherwise would lead to incorrect models. These regardless should never throw, but it would be better to have an assertion failure.
Andrew Reynolds [Mon, 27 Apr 2020 22:04:49 +0000 (17:04 -0500)]
Fix sygus unit (#4371)
Mathias Preiner [Mon, 27 Apr 2020 20:42:28 +0000 (13:42 -0700)]
Fix examples instructions in INSTALL.md. (#4397)
Andrew Reynolds [Sun, 26 Apr 2020 05:05:28 +0000 (00:05 -0500)]
Fix sets cardinality cycle rule (#4392)
Fixes #4391.
The sets cardinality cycle rule is analogous to the S-Cycle rule for strings (see Liang et al CAV 2014). This rule is typically never applied but can be applied in rare cases where theory combination does not determine a correct arrangement of equalities over sets terms that is consistent with the arithmetic arrangement of their cardinalities at full effort. Notice the regression from #4391 has non-linear arithmetic, (mod 0 d), which is translated to UF.
The cardinality cycle rule had a bug: it assumed that cycles that were encountered were loops e1 = e2 = ... = e1 but in general they can be lassos e1 = ... = e2 = ... = e2. This ensures the Venn region cycle e2 = ... = e2 is the conclusion in this case, instead of unsoundly concluding e1 = ... = e2.
Strings does not have a similar issue:
https://github.com/CVC4/CVC4/blob/master/src/theory/strings/core_solver.cpp#L488
Here, when a cycle is encountered, it is processed at the point in traversal where the loop is closed.
This is not critical for SMT-COMP but should be in the 1.8 release.
Andres Noetzli [Thu, 23 Apr 2020 12:58:00 +0000 (05:58 -0700)]
Introduce best content heuristic for strings (#4382)
* Introduce best content heuristic for strings
This commit introduces a "best content heuristic" to perform
context-dependent simplifications. The high-level idea is that for each
equivalence class for strings, we compute a representation that is a
string concatentation of constants and other string terms. For this
representation, we try to get as many letters in the string constants as
we can (i.e. the best approximation of the content). This "best content"
representation is then used by `EXTF_EVAL` to perform simplifications.
Co-authored-by: Andrew Reynolds <andrew.j.reynolds@gmail.com>
Andres Noetzli [Thu, 23 Apr 2020 00:55:33 +0000 (17:55 -0700)]
Strings: Register skolems before sending lemma (#4381)
This commit fixes a performance regression introduced by commit
6255c03. The issue seems to be that registering terms manually after sending the lemma on the output channel is too late because the output channel processes the lemma eagerly.
Andrew Reynolds [Wed, 22 Apr 2020 18:32:20 +0000 (13:32 -0500)]
Ensure disequality splits are processed as lemmas (#4380)
Fixes #4379. This was caused by a splitting lemma rewriting to a conjunction, being processed as a fact, and having a pending phase requirement sent out assuming the inference was to be processed as a lemma. This forces 2 of the splits in the core solver to be always processed as lemmas.
Andrew Reynolds [Wed, 22 Apr 2020 13:45:52 +0000 (08:45 -0500)]
Allow eager bitblasting with solve bv as int in QF_NIA (#4373)
This also updates the SMT COMP script to revert to our previous behavior.
This is required for SMT COMP. It should be beneficial for satisfiable QF_NIA instances. I will revisit/test this independently.
Abdalrhman Mohamed [Wed, 22 Apr 2020 12:06:24 +0000 (07:06 -0500)]
Convert V2.5 SMT regressions to V2.6. (#4319)
This commit converts all v2.5 smt2 regressions to v2.6 (except for regress/regress0/lang_opts_2_5.smt2).
Andres Noetzli [Wed, 22 Apr 2020 11:32:06 +0000 (04:32 -0700)]
Reinstantiate support for conjunctions in facts (#4377)
Fixes #4376. Commit
6255c0356bd78140a9cf075491c1d4608ac27704 removed
support for conjunctions in the conclusion of facts. However,
`F_ENDPOINT_EMP` generates a conjunction in the conclusion of the
inference if multiple components are inferred to be empty. This commit
reinstantiates support for conjunctions in the conclusion of facts.
Andrew Reynolds [Tue, 21 Apr 2020 18:40:02 +0000 (13:40 -0500)]
Update to sygus version 2 (#4372)
Andrew Reynolds [Tue, 21 Apr 2020 05:33:50 +0000 (00:33 -0500)]
Fix for parse options related to binary name (#4368)
Possible fix for the nightlies.
In some configurations, a unit test fails when using the function for parsing options via manual argv construction
https://github.com/CVC4/CVC4/blob/master/test/unit/expr/expr_public.h#L58
This reverts a behavior change from
3dfb48b.
In particular, we always parse and ignore the binary name instead of skipping it outright. This more accurately reflects the original code.
Abdalrhman Mohamed [Tue, 21 Apr 2020 03:07:42 +0000 (22:07 -0500)]
Introduce a public interface for Sygus commands. (#4204)
This commit addresses issue #38 in cvc4-projects by introducing public API for Sygus commands. It also includes two simple examples of how to use the API.
Andrew Reynolds [Tue, 21 Apr 2020 00:47:35 +0000 (19:47 -0500)]
Make option names related to CEGQI consistent (#4316)
This updates option names to be consistent across uses of counterexample-guided quantifier instantiation (ceqgi), which was previously called "counterexample-based quantifier instantiation" (cbqi), and sygus.
Notably, the trace "cegqi-engine" is changed to "sygus-engine" by this commit.
The changes were done by these commands in the given directories:
src/:
for f in $(find -name '.'); do sed -i 's/options::cbqi/options::cegqi/g' $f;sed -i 's/cegqi-engine/sygus-engine/g' $f; done;sed -i 's/"cbqi/"cegqi/g' $f; done
test/regress/:
for f in $(find -name '.'); do sed -i 's/--cbqi/--cegqi/g' $f; done
src/: and test/regress/:
for f in $(find -name '.'); do sed -i 's/cegqi-si/sygus-si/g' $f; done
test/regress/:
for f in $(find -name '.'); do sed -i 's/no-cbqi/no-cegqi/g' $f; done
test/regress/:
for f in $(find -name '.'); do sed -i 's/:cbqi/:cegqi/g' $f; done
And a few minor fixes afterwards.
This should be merged close to the time of the next stable release.