Andrew Reynolds [Tue, 18 Aug 2020 16:17:26 +0000 (11:17 -0500)]
Add the relevance manager module (#4894)
This PR adds the relevance manager module, which will be used in forthcoming PRs to query assignments for whether a literal is "relevant" (e.g. critical for satisfying the input formula). Leveraging this technique has led to noticeable improvements for non-linear arithmetic (https://github.com/ajreynol/CVC4/tree/relManager).
This PR does not enable it, but adds the module only.
Andrew Reynolds [Tue, 18 Aug 2020 15:29:46 +0000 (10:29 -0500)]
(proof-new) Callbacks for term-context-sensitive terms (#4842)
Callbacks for term-context-sensitive terms.
It gives two examples of such callbacks, "remove term formula (rtf) context" to be used in the remove term formulas pass and "polarity context" which is a highly common pattern in preprocessing.
These utilities will be critical for maintain proofs for term-context-sensitive rewrites. An example user of these utilities is TermFormulaRemoval, which rewrites terms depending on whether they occur beneath quantifiers/terms. This utility currently has bugs in its proof generation since its proof cache does not consider the term context. This PR updates that class to use this utility. Its proof generator will be similarly extended in proof-new to synchronize its cache, relative to term context identifiers. Concretely, a TermContext callback will be passed to TConvProofGenerator, which will put together proof skeletons in a term-context-sensitive manner.
Alex Ozdemir [Mon, 17 Aug 2020 23:28:58 +0000 (16:28 -0700)]
Add identifier name for side condition. (#4902)
```
(! sc (^ ...)
^ this is the identifier!
```
We require that side-conditions have an identifier. We usually provide
this identifier, but in this one case we did not.
The old lexer accepted the side condition without the identifier. The
new one does not.
Andres Noetzli [Mon, 17 Aug 2020 22:22:34 +0000 (15:22 -0700)]
[CI] Update package list (#4906)
Since
https://github.com/CVC4/LFSC/commit/
1d1c55fa17b08e2bc8cb686b9d07ec63bf0dd4a2
LFSC requires Flex, so we need to install the corresponding packages in
our CI environment. This commit also removes SWIG from the list of
packages to install since we do not use it anymore.
Andrew Reynolds [Mon, 17 Aug 2020 19:38:16 +0000 (14:38 -0500)]
Dynamic allocation of equality engine in Theory (#4890)
This commit updates Theory so that equality engines are allocated dynamically. The plan is to make this configurable based on the theory combination method.
The fundamental changes include:
- Add `d_equalityEngine` (raw) pointer to Theory, which is the "official" equality engine of the theory.
- Standardize methods for initializing Theory. This is now made more explicit in the documentation in theory.h, and includes a method `finishInitStandalone` for users of Theory that don't have an associated TheoryEngine.
- Refactor TheoryEngine::finishInit, including how Theory is initialized to incorporate the new policy.
- Things related to master equality engine are now specific to EqEngineManagerDistributed and hence can be removed from TheoryEngine. This will be further refactored in forthcoming PRs.
Note that the majority of changes are due to changing `d_equalityEngine.` to `d_equalityEngine->` throughout.
Andrew Reynolds [Mon, 17 Aug 2020 18:07:13 +0000 (13:07 -0500)]
(proof-new) Prepare the theory of strings for proof reconstruction (#4885)
This updates the internal data structure for strings inferences "InferInfo" such that it is amenable to proof reconstruction.
Currently, the explanation for a conclusion is in two parts:
(1) d_ant, the antecedents that can be explained by the current equality engine,
(2) d_antn, the antecedents that cannot.
For proof reconstruction, the order of some antecedents matters. This is difficult with the above data structure since elements in these two vectors are not given an ordering relative to each other. After this PR, we store:
(1) d_ant, all antecedants, which are ordered in a way that is amenable to proofs (to be introduced on following PRs),
(2) d_noExplain, the subset of d_ant that cannot be explained by the current equality engine.
This PR modifies calls to InferenceManager in preparation for extending it with a proof reconstructor InferProofCons which will convert strings::InferInfo into instructions for building ProofNode.
Andrew Reynolds [Sun, 16 Aug 2020 12:17:53 +0000 (07:17 -0500)]
Add non-emptiness to conclusion of positive RE star unfolding. (#4899)
A recent commit (
77e9881) simplified the form of the conclusion in regular expression star unfolding for the sake of uniformity in our internal proof calculus. However, this led to a noticeable drop in performance on a few specific RE benchmarks (the Norn set). This preserves the old behavior by extending the core rule for RE unfolding.
It also makes one minor change to the strings proof checker carried over from the proof-new branch.
Gereon Kremer [Sun, 16 Aug 2020 00:28:27 +0000 (02:28 +0200)]
(cad solver) Use the current model as initial assignment (#4893)
This PR implements a first naive way to employ the linear model (obtained from the nonlinear extension) to guide the initial sampling within the cad solver.
Andrew Reynolds [Sat, 15 Aug 2020 12:07:28 +0000 (07:07 -0500)]
Minor cleanup related to notifications (#4898)
This includes eliminating TheoryBV's call to eqNotifyNewEqClass and fixing an issue with string's eqNotifyNewEqClass method, which was registering constant integers.
It also removes some unnecessary methods in Theory.
Andrew Reynolds [Sat, 15 Aug 2020 11:41:28 +0000 (06:41 -0500)]
Add finishInit method to PropEngine (#4895)
This changes an initialization issue in regarding PropEngine and TheoryEngine.
In the constructor for PropEngine, we convert and assert literals for true and false to CNF stream. Doing so triggers several things, including calls that preregister these literals with the associated TheoryEngine. This means that literals are preregistered to TheoryEngine before it has been fully initialized (TheoryEngine::finishInit). This is not currently an issue since this only involves modules that are constructed statically (e.g. SharedTermsDatabase), but this will lead to issues when the TheoryEngine is more configurable.
The solution is to additionally have a PropEngine::finishInit, which is called after TheoryEngine::finishInit, which does this step. The PropEngine should not assert anything to CNF before this method is called.
Andrew Reynolds [Sat, 15 Aug 2020 11:06:28 +0000 (06:06 -0500)]
(proof-new) Add the strings proof checker (#4858)
It also adds enumeration for two new rules that have been recently added.
Andrew Reynolds [Fri, 14 Aug 2020 18:07:17 +0000 (13:07 -0500)]
Simplify equality engine notifications (#4896)
Previously, there was methods for being informed just before and just after equivalence classes are merged (eqNotifyPreMerge and eqNotifyPostMerge). The purpose of this was to allow e.g. the theory to inspect the equivalence classes in question before the equality engine modified them. However this is no longer used, and moreover is discouraged since Theory should generally buffer their usage of EqualityEngine while it is making internal calls.
TheoryStrings was the only theory to use eqNotifyPreMerge (somewhat arbitrarily), all others used eqNotifyPostMerge. This makes post-merge the default, renames it to eqNotifyMerge and removes pre notifications.
This will simplify the work of the new theory combination methods as well as leading to fewer spurious calls to callbacks in equality engine.
E Polgreen [Fri, 14 Aug 2020 17:19:09 +0000 (10:19 -0700)]
correctly parse sygus lang option (#4884)
--lang sygus is a synonym for --lang sygus2
also fixes typo in error message for language options parsing
Signed-off-by: polgreen <epolgreen@gmail.com>
Gereon Kremer [Fri, 14 Aug 2020 12:01:57 +0000 (14:01 +0200)]
Inspect roots to avoid certain resultants (Algorithm 4, lines 8,9). (#4892)
This PR adds a small improvement to the CAD solver.
In Algorithm 4 of https://arxiv.org/pdf/2003.05633.pdf in lines 8 and 9, we only consider polynomials for resultant computations that have roots outside of the current interval.
This PR implements this check.
Fixes CVC4/cvc4-projects#210.
Andrew Reynolds [Thu, 13 Aug 2020 20:22:59 +0000 (15:22 -0500)]
Split SmtSolver from SmtEngine (#4880)
This class is responsible for maintaining TheoryEngine and PropEngine and implementing the check-sat command. It also has an interface for processing/pushing the current assertions into the PropEngine.
This class will be used directly by other extension solvers (for abduction, interpolation, qe, sygus, etc.).
Andrew Reynolds [Thu, 13 Aug 2020 19:15:17 +0000 (14:15 -0500)]
Fixes for corner case of decision tree learning with different types (#4887)
There was a last minute change was a typo when merging
103b5ea .
Also the fix in that commit needed to be slightly more robust to the case when either branch of an ITE had a different sygus type.
Fixes regress1.
Andrew Reynolds [Thu, 13 Aug 2020 18:14:41 +0000 (13:14 -0500)]
More basic fix for dumping synth-fun (#4886)
The commit (
079a04b) appears to have broken the nightlies due to compile issues related a necessary addition to the Dump class (so that std::string could be printing on Dump streams).
This changes the temporary solution so that we simply print a string on the standard output, when the Dump is enabled. This is required for temporarily keeping dump=raw-benchmark working for synth-fun commands.
Andrew Reynolds [Thu, 13 Aug 2020 16:34:04 +0000 (11:34 -0500)]
Add the distributed equality engine manager (#4867)
This is the first step towards making the approach for theory combination in CVC4 configurable.
This PR introduces the "distributed equality engine manager", which encapsulates the current policy that TheoryEngine uses regarding equality engines: each Theory creates a separate copy of an equality engine. The eventual plan is that the official equality engine of Theory is not necessarily unique to the theory, if equality engines are shared. A variant of this class could implement that policy.
This PR does not impact the code, it simply adds the definition of the class. A forthcoming PR will integrate this class into TheoryEngine, which will use dynamic allocation for equality engine objects.
FYI @barrettcw
Haniel Barbosa [Thu, 13 Aug 2020 00:01:40 +0000 (21:01 -0300)]
[proof-new] Adding support for corner case of transitivity simulating MERGED_THROUGH_CONSTANTS (#4879)
Haniel Barbosa [Wed, 12 Aug 2020 23:18:16 +0000 (20:18 -0300)]
generalize handling MERGED_THROUGH_CONSTANST in EqProof conversion (#4878)
Now that we are using the constant folding in equality engine for more than equality it is necessary to generalize the previously-hard-coded handling of MERGED_THROUGH_CONSTANTS.
Abdalrhman Mohamed [Wed, 12 Aug 2020 22:51:48 +0000 (17:51 -0500)]
Refactor functions that print commands (Part 1) (#4869)
This PR is a step towards migrating commands to the Term/Sort level. The functions for printing synth-fun command and its grammar were modified to remove their dependency on command objects and use nodes instead of exprs and types. Similar changes to other functions that print commands will follow.
Andrew Reynolds [Wed, 12 Aug 2020 22:13:14 +0000 (17:13 -0500)]
Fixes for degenerate case of sygus decision tree learning (#4800)
Fixes #4790.
Fixes two bugs in the decision tree learning solver for sygus, one involving evaluation of "templated" enumerators, and one involving ITE strategies where child types are different than the root.
Andrew Reynolds [Wed, 12 Aug 2020 21:34:47 +0000 (16:34 -0500)]
(proof-new) Improve robustness of CONG rule (#4882)
This makes it so that the explicit Kind is wrapped in a Node as an argument to the CONG proof rule. This allows us to distinguish applications with the same parameterized operator but different kinds (e.g. APPLY_SELECTOR vs APPLY_SELECTOR_TOTAL).
Andrew Reynolds [Wed, 12 Aug 2020 20:51:15 +0000 (15:51 -0500)]
(proof-new) Proof support in the strings term registry. (#4876)
Adds basic support for proofs in the strings term registry. This code is not yet active until further parts of proof-new are merged.
Andrew Reynolds [Wed, 12 Aug 2020 19:48:31 +0000 (14:48 -0500)]
(proof-new) Improve interfaces to proof generators (#4803)
This includes configurable naming and a caching policy for term conversion proof generator.
Also corrects a subtle issue in LazyCDProof related to making getProofFor idempotent using the notion of owned proofs.
makaimann [Wed, 12 Aug 2020 19:03:45 +0000 (12:03 -0700)]
Add option to only build library (#4801)
This PR would add an option to only build the CVC4 library and not the parser or executable. This can be used for projects that only intend to use CVC4 through the API.
It seems to be working now, but it's not necessarily the cleanest solution. In particular, if you'd like the polarity to be different I'm happy to change that. Polarity meaning something like "${WITH_BINARY}" STREQUAL "YES" instead of NOT "${LIB_ONLY} STREQUAL "YES" which is admittedly a little strange.
Andrew Reynolds [Wed, 12 Aug 2020 16:41:26 +0000 (11:41 -0500)]
(proof-new) Witness form proof generator (#4782)
This class is responsible for the connection between terms and their witness form in the final proof.
Gereon Kremer [Wed, 12 Aug 2020 15:01:58 +0000 (17:01 +0200)]
Add naive support for integer variables. (#4835)
This PR adds naive support for integer reasoning to the CAD-based solver.
Essentially, it checks whether the sampled value is integral. If this is not the case, we "invent" a new interval covering the area between the two neighbouring integers with appropriate border polynomials.
Haniel Barbosa [Wed, 12 Aug 2020 14:31:30 +0000 (11:31 -0300)]
(proof-new) Improving proof-production in Equality Engine (#4871)
This commit improves functionalities of the equality engine so that it is easier to produce proofs for its reasoning. They are:
avoiding assertion of already entailed predicates/equalities.
better EqProof of disequalities with constants
correct EqProof involving n-ary congruence kinds
Andrew Reynolds [Wed, 12 Aug 2020 14:18:24 +0000 (09:18 -0500)]
Fix connection to master equality engine in sets (#4877)
This corrects an issue introduced by a merge of a previous commit (
b5b2858) which dropped the connection from sets to its master equality engine.
Fixes several issues in sets regressions, including a timeout in regress0.
Gereon Kremer [Wed, 12 Aug 2020 13:17:18 +0000 (15:17 +0200)]
Fix infinite loop in arith_ite_simp (#4805)
We have an open issue with an infinite loop with --ite-simp for a long time in #789 , for example on
(declare-fun a () Int)
(declare-fun b () Int)
(assert
(and
(= 1 (+ a b))
(or (= 0 a) (= 0 b))
(or (= 0 b) (>= b 8))
(or (= 0 a) (not (>= b 8)))
)
)
(check-sat)
The problem goes back to arith_ite_utils.cpp and roughly is as follows:
The method solveBinOr looks for patterns like (or (= b 0) (= b 1)). It introduces a new Boolean variable deor_1 and substitutes b -> (ite deor_1 1 0).
The method also stores another mapping in d_skolems: deor_1 -> (>= b 8) here which is also used in selectForCmp. However, these skolems are also used to add even more substitutions here after applying the already added substitutions to it. Eventually, we have a substitution deor_1 -> (>= (ite deor_1 1 0) 8) which inevitably leads to an infinite loop.
I have found no reason for the second mapping (deor_1 -> (>= b 8)) to be added as a substitution, and thus this PR removes it.
Benchmarks are running to check whether there are further issues with this, and whether this simplification is beneficial.
Fixes #789.
Andrew Reynolds [Wed, 12 Aug 2020 06:41:45 +0000 (01:41 -0500)]
Fix unsupported option in regress1. (#4874)
Fixes regress1.
Andrew Reynolds [Wed, 12 Aug 2020 05:08:32 +0000 (00:08 -0500)]
Split SmtEngineState from SmtEngine (#4855)
This splits a utility for tracking the "basic" state of the SmtEngine. This class tracks its high-level state, including the "SMT mode", last/expected status and manages the contexts. It is not responsible more detailed state information (e.g. the assertions).
Andrew Reynolds [Wed, 12 Aug 2020 03:53:58 +0000 (22:53 -0500)]
Prepare theory of sets for dynamic allocation of equality engine (#4868)
In forthcoming PRs, Theory objects will be assigned equality engine objects dynamically.
This PR prepares the theory of sets for this update, which involves refactoring of its internal members.
Andrew Reynolds [Wed, 12 Aug 2020 02:53:13 +0000 (21:53 -0500)]
Final preparations for changing API to use the Node-level datatype (#4863)
This includes all fixes encountered while fixing unit tests with the Term -> Node version of Datatypes in the API.
After all pending PRs are merged, the next step will be to convert the new API to use e.g. CVC4::DType instead of CVC4::Datatype everywhere.
Andrew Reynolds [Wed, 12 Aug 2020 02:06:17 +0000 (21:06 -0500)]
(proof-new) Extensions to proof checker interface (#4857)
This includes support for pedantic levels, as well as a utility for wrapping Kind in a Node (for the updated CONG rule, to be updated in a later PR).
Andrew Reynolds [Tue, 11 Aug 2020 20:56:24 +0000 (15:56 -0500)]
Update Expr-level unit tests that depend on datatypes to Node (#4860)
In preparation for eliminating the Expr-level datatype.
Andrew Reynolds [Tue, 11 Aug 2020 20:36:38 +0000 (15:36 -0500)]
Remove instantiation model true option (#4861)
This was an option that rejected instantiations that are true according to the current
model's equality engine.
This option was never helpful and will be burdensome to maintain with new updates
to equality engine infrastructure.
Aina Niemetz [Tue, 11 Aug 2020 19:58:28 +0000 (12:58 -0700)]
New C++ API: Remove redundant API functions for mkReal. (#4870)
This further removes redundant API functions with a `const char*`
parameter. These are redundant (and can create ambiguity) since they
have `const string&` counterparts.
Andrew Reynolds [Sun, 9 Aug 2020 22:36:22 +0000 (17:36 -0500)]
Make valuation class more robust to null underlying TheoryEngine. (#4864)
In some use cases (unit tests, old proofs infrastructure), we use a Theory with no associated TheoryEngine. This PR makes the Valuation class more robust to this case.
This includes making the "unevaluated kinds" a no-op in this case (this is necessary for Theory::finishInit with no TheoryEngine) and adding some assertions to cases that the Theory should never call without TheoryEngine.
This is required for a new policy for dynamically configuring equality engine infrastructure in Theory.
Andrew Reynolds [Sun, 9 Aug 2020 21:50:09 +0000 (16:50 -0500)]
Splitting a few utility classes from EqualityEngine to their own file (#4862)
Includes iterators and notification callbacks. These classes will be highly relevant for planned extensions to the core theory engine infrastructure.
Andrew Reynolds [Sat, 8 Aug 2020 01:22:55 +0000 (20:22 -0500)]
Move datatype index constant to its own file (#4859)
Towards removing the Expr-level datatype.
Moves DatatypeIndex to its own file, which is the only thing that is necessary remaining from expr/datatype.h.
Also updates the datatype kinds file in preparation for the removal.
Aina Niemetz [Fri, 7 Aug 2020 21:56:28 +0000 (14:56 -0700)]
GH Actions: Remove cancel action. (#4843)
The previously introduced action to cancel running builds is not able to
cancel builds on other branches, only on the same branch. As a consequence,
when pushing to a branch for which a PR has been submitted, builds on the
main repository are not cancelled.
This removes the cancel build. If we want behavior similar to how it was
on Travis, we need a workaround / more sophisticated solution since GH
Actions doesn't really allow / support this (due to permission issues).
Andrew Reynolds [Thu, 6 Aug 2020 18:41:24 +0000 (13:41 -0500)]
Updates not related to creation for eliminating Expr-level datatype (#4838)
This updates remaining uses of the Expr-level Datatype that are not related to their creation / memory management in ExprManager.
This required updating a unit test from Expr -> Node.
Andrew Reynolds [Thu, 6 Aug 2020 13:29:17 +0000 (08:29 -0500)]
Split preprocessor from SmtEngine (#4854)
This splits a collection of utilities from SmtEngine that work in cooperation to preprocess assertions (Boolean circuit propagator, preprocessing context, process assertions, term formula removal).
It updates various interfaces in SmtEngine from Expr -> Node and simplifies SmtEngine to use this utility.
Andrew Reynolds [Thu, 6 Aug 2020 11:48:45 +0000 (06:48 -0500)]
(proof-new) Refactor regular expression operation (#4596)
This refactors the regular expression operation class so that some of its key methods are static, so that they can used by both the regular expression solver and the strings proof checker.
Notice that many cases of regular expression unfolding are deleted by this PR, since they are unnecessary. This is due to the fact that all regular expression memberships are rewritten except those whose RHS are re.++ or re.*.
Andrew Reynolds [Wed, 5 Aug 2020 19:14:23 +0000 (14:14 -0500)]
Split Assertions from SmtEngine (#4788)
This splits all things related to storing assertions in the SmtEngine into a separate class "Assertions". It also converts the interface for its methods from Expr to Node.
Gereon Kremer [Wed, 5 Aug 2020 18:55:00 +0000 (20:55 +0200)]
Improve error message for unsupported exponents (#4852)
We have had a few issues where essentially users misinterpreted the error message about which types of exponents are supported for (^ base exp). Given that this is rewritten to a multiplication of length exp, we only support reasonably small natural numbers.
This PR improves the error message.
Fixes #4692
Andrew V. Jones [Wed, 5 Aug 2020 17:38:15 +0000 (18:38 +0100)]
When checking models, ensure that error message is correctly formatted (#4853)
Issue
When CVC4 is checking models and encounters an issue, it presents an message like this:
Internal error detectedTHEORY_ARITH has an asserted fact that the model doesn't satisfy.
Notice: there's no space between detected and THEORY_ARITH.
Resolution
This PR ensures that the error message is correctly formatted.
Signed-off-by: Andrew V. Jones andrew.jones@vector.com
Andres Noetzli [Wed, 5 Aug 2020 14:18:10 +0000 (07:18 -0700)]
[Strings] Add eager context-dependent evaluation (#4847)
This commit adds eager evaluation of string terms based on the current
context. To do so, it declares the string kinds to be "interpreted" in
the equality engine. This allows us to avoid making a series of
decisions such as:
** (= "describe" (str.substr actionName 0 8)) :DE-DECISION:
*** (= actionName "deletecertificate") :DE-DECISION:
**** (= resource_partition "aws") :DE-DECISION:
***** (= resource_region "af-south-1") :DE-DECISION:
****** (= resource_account "") :DE-DECISION:
******* (= (str.len (str.substr actionName 0 3)) 0) :DE-DECISION:
******** (= (str.len (str.substr actionName 0 4)) 0) :DE-DECISION:
********* (= (str.len (str.substr actionName 0 6)) 0) :DE-DECISION:
********** (= (str.len (str.substr actionName 0 5)) 0) :DE-DECISION:
*********** (= (str.len (str.substr actionName 0 9)) 0) :DE-DECISION:
************ (= (str.len (str.substr actionName 0 7)) 0) :DE-DECISION:
************* (= (str.len (str.substr actionName 0 10)) 0) :DE-DECISION:
************** (= (str.len (str.substr actionName 0 2)) 0) :DE-DECISION:
*************** (= (str.len (str.substr actionName 0 13)) 0) :DE-DECISION:
**************** (= (str.len (str.substr actionName 0 12)) 0) :DE-DECISION:
***************** (= (str.len resource_service) 0) :DE-DECISION:
****************** (= (str.len resource_account) 0) :DE-DECISION:
In such a case, we can detect that there is a conflict after the first
two decisions because (str.substr "deletecertificate" 0 8) is
deletece which is different from describe. The equality engine uses
the rewriter to evaluate interpreted kinds with constant arguments.
This technique leads to a significant speedup on some of the newer
Amazon benchmarks.
Gereon Kremer [Wed, 5 Aug 2020 02:32:10 +0000 (04:32 +0200)]
Add dummy returns if libpoly is unavailable. (#4845)
This PR adds dummy return statements do CadSolver in case libpoly is not available.
Andrew Reynolds [Tue, 4 Aug 2020 23:27:27 +0000 (18:27 -0500)]
Fixes for getInterpolant and getAbduct API methods (#4846)
This fixes three issues in the getInterpolant method in the API, which was also copied to the getAbduct method:
(1) Use Node not Expr
(2) Must set up ExprManager scope
(3) The wrong solver pointer was passed to the returned term, which was causing segfaults on all abduction regressions.
We should also consider changing the interface of this method to return the term instead of a Boolean. This could be done as future work.
This fixes regress1.
Mathias Preiner [Tue, 4 Aug 2020 21:03:36 +0000 (14:03 -0700)]
Add documentation and build instructions for recompilation (LGPL). (#4844)
Abdalrhman Mohamed [Tue, 4 Aug 2020 20:23:54 +0000 (15:23 -0500)]
Modify the smt2 parser to use the Sygus grammar. (#4829)
Andrew Reynolds [Tue, 4 Aug 2020 19:01:47 +0000 (14:01 -0500)]
Add API interface for specialized constructor term (#4817)
This is an interface to get the instantiated parametric datatype constructor operator to apply when the type of this operator cannot be inferred without a cast.
This is required for eliminating the Expr-level datatype and calls to ExprManager from the parsers.
Gereon Kremer [Tue, 4 Aug 2020 11:32:21 +0000 (13:32 +0200)]
Properly initialize d_fullyInited. (#4840)
Fixed #4839.
The Boolean flag d_fullyInited is not properly initialized and is thus flagged by --ubsan.
Gereon Kremer [Tue, 4 Aug 2020 10:57:34 +0000 (12:57 +0200)]
Add CAD-based solver (#4834)
Based on #4774, this PR adds a new CadSolver class that allows the NonlinearExtension to actually employ the CAD-based method. In more detail:
add --nl-cad option
add CadSolver class that wraps cad::CDCAC with support for checks, model construction and conflict generation
add new Inference types for the NlLemma class
use CadSolver in NonlinearExtension (if --nl-cad is given)
Andres Noetzli [Mon, 3 Aug 2020 23:26:42 +0000 (16:26 -0700)]
Update documentation for Solver::mkVar() (#4833)
The documentation of `Solver::mkVar()` was not very clear regarding what
it could be used for. This lead to some confusion (see e.g. #4828).
This commit makes the documentation more explicit.
Ying Sheng [Mon, 3 Aug 2020 23:26:08 +0000 (16:26 -0700)]
Add implementation for SyGuS interpolation module (step4) (#4811)
This is the 4th step of adding interface for SyGuS Interpolation module. The whole change will be adding the API for (get-interpol s B), which is aim for computes an I that A->I and I->B. Here A is the assertions in the stack.
The 4th step finished the implementation of the interpolation module.
yoni206 [Mon, 3 Aug 2020 22:28:29 +0000 (15:28 -0700)]
New BV rewrite rules aimed at bv_to_int preprocessing pass (#4769)
This PR adds new rewrite rules for BV.
None of them is meant to be used by the default BV rewriter.
However, they are planned to be used in bv_to_int preprocessing pass.
In the pass we use FixpointRewriteStrategy to call various rewrite rules.
After consulting @4tXJ7f , we thought that the best way to include more rewrite rules in that call is to implement them using the existing BV rewrites infrastructure.
Andrew Reynolds [Mon, 3 Aug 2020 22:05:35 +0000 (17:05 -0500)]
Generalize interface for candidate rewrite database (#4797)
This class will be used as a utility in a new algorithm for solution reconstruction and requires a generalized interface.
FYI @abdoo8080
Andrew Reynolds [Mon, 3 Aug 2020 21:35:19 +0000 (16:35 -0500)]
Update datatypes in cvc parser to the new API (#4826)
This is leftover from the parser conversion. This is towards eliminating all remaining Expr-level calls in the parser.
Notice that 2 parser-level checks for records are eliminated in this PR, since we do not export record objects in the new API.
yoni206 [Mon, 3 Aug 2020 21:02:35 +0000 (14:02 -0700)]
Examples for using sygus python api (#4822)
This PR adds examples for using the sygus python api.
The examples are obtained from the examples of the cpp sygus api.
makaimann [Mon, 3 Aug 2020 20:39:44 +0000 (13:39 -0700)]
Delete solver pointer in Cython __dealloc__ (#4799)
Andrew Reynolds [Mon, 3 Aug 2020 18:42:17 +0000 (13:42 -0500)]
Split expression names from SmtEngine (#4832)
Towards splitting SmtEngine / deleting SmtEnginePrivate.
Andrew Reynolds [Mon, 3 Aug 2020 14:40:52 +0000 (09:40 -0500)]
Split dump manager from SmtEngine (#4824)
Towards splitting SmtEngine.
This moves utilities related to managing information for dumping to its own utility, DumpManager.
Its current responsibilities are to track information about how to print a model, and the implementation of some dumping traces, although its responsibilities should be extended further so that SmtEngine is not responsible for any command dumping. This is future work.
Andrew Reynolds [Sun, 2 Aug 2020 13:50:57 +0000 (08:50 -0500)]
Updates to dtype constructor in preparation for eliminating Expr-level datatype (#4825)
Andres Noetzli [Sun, 2 Aug 2020 12:57:24 +0000 (05:57 -0700)]
Fix ASan failure in interactive_shell_black (#4827)
This commit fixes an issue reported by ASan for unit test
interactive_shell_black. The unit test was failing because nodes were
created in the wrong node manager. The issue was likely introduced with
e8bbee7.
Andres Noetzli [Sun, 2 Aug 2020 06:56:27 +0000 (23:56 -0700)]
Ensure strict length constraint for decompose rule (#4821)
Fixes #4820. The performance issue was caused by
0988217562006d3f59e01dc261f39121df6d75f5. That commit introduced an
option (`--strings-len-conc`) that optionally moves the length
constraint for skolems to the conclusion of an inference instead of
making it part of the term registration. However, for
`DEQ_DISL_STRINGS_SPLIT`, we were only asserting that `LENGTH_GEQ_ONE`
in the case where this option was not enabled, instead of asserting that
the length of the skolem is equal to the component on the other side of
the disequality. This lead to an infinite loop of inferences because we
effectively were just splitting a component into two skolems and the
only restriction was that the first one was non-empty. We guessed the
second skolem to be empty, so the first skolem was equal to the
component, the skolem was marked congruent, and we ended up with the
same normal form as before.
The commit fixes the issue by adding an argument to
`getDecomposeConclusion()` that specifies whether to add the length
constraint or not. This option is used to always add the length
constraint in the case of `DEQ_DISL_STRINGS_SPLIT`.
Andrew Reynolds [Sun, 2 Aug 2020 03:27:08 +0000 (22:27 -0500)]
Add methods for constructing datatype types from NodeManager (#4823)
This is work towards eliminating the Expr-level datatype.
This PR implements the required methods for constructing datatype types from NodeManager.
In particular, this PR copies the "mkMutualDatatypeTypes" methods and converts them to Node-level.
The next PRs will be in preparation for using these methods instead of the Expr-level ones.
It also adds a flag d_isRecord to DType, which is required for supporting record printing in the cvc printer, which will be updated in another PR.
It also eliminates an interface for constructing constructor types via Expr-level DatatypeConstructor objects, which was unused.
Andrew V. Jones [Sat, 1 Aug 2020 07:34:37 +0000 (08:34 +0100)]
Ensure that we only find '.a's when building statically (#4785)
## Issue
When trying to building statically, and if your machine *does not* have static libraries (e.g., there is [no static GMP on CentOS 8](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/considerations_in_adopting_rhel_8/index#removed-packages_changes-to-packages)), then CVC4's CMake does not detect this:
```
FAILED: bin/cvc4
: && /usr/bin/c++ -O3 -Wall -Wno-deprecated -Wsuggest-override -Wnon-virtual-dtor -Wimplicit-fallthrough -Wshadow -Wno-class-memaccess -fuse-ld=gold -static src/main/CMakeFiles/main.dir/command_executor.cpp.o src/main/CMakeFiles/main.dir/interactive_shell.cpp.o src/main/CMakeFiles/main.dir/signal_handlers.cpp.o src/main/CMakeFiles/main.dir/time_limit.cpp.o src/main/CMakeFiles/cvc4-bin.dir/driver_unified.cpp.o src/main/CMakeFiles/cvc4-bin.dir/main.cpp.o -o bin/cvc4 src/libcvc4.a src/parser/libcvc4parser.a src/libcvc4.a -Wl,-Bdynamic /usr/lib64/libgmp.so -Wl,-Bstatic ../deps/install/lib/libantlr3c.a && :
/usr/bin/ld.gold: error: cannot mix -static with dynamic object /usr/lib64/libgmp.so
```
## Resolution
This PR changes CVC4's CMakeLists such that, if you're building statically, it *only* allows for linking against `.a`s (or `.a`s + `.lib`s on Windows).
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
Andrew Reynolds [Sat, 1 Aug 2020 07:20:24 +0000 (02:20 -0500)]
Fix component contains for splicing due to substring. (#4705)
Fixes #4701. That benchmark now times out.
yoni206 [Sat, 1 Aug 2020 06:50:40 +0000 (23:50 -0700)]
Add SyGuS Python API (#4812)
This commit extends the Python API with support for SyGuS functionality.
This required the addition of a nullary constructor for `Grammar` in the C++ API.
A unit test is also included, and is a translation of the corresponding C++ API unit test.
Examples are not added yet, but are ready and planned for a next PR (in order to keep this one shorter).
Andrew Reynolds [Fri, 31 Jul 2020 12:19:35 +0000 (07:19 -0500)]
Split listener classes from SmtEngine (#4816)
This moves listener classes owned by SmtEngine to their own file.
The SmtEnginePrivate class previously what itself a NodeManagerListener. This class will be deleted. Instead a new NodeManagerListener is introduced here whose sole responsibility is to do the work required for node manager listening.
Note I had to add a (temporary) friend relationship to SmtEngine, which will be removed in an upcoming PR to split the management of dumping to its own utility.
Andrew Reynolds [Fri, 31 Jul 2020 00:35:22 +0000 (19:35 -0500)]
Standardize explanations in arrays (#4804)
Some internal inferences had a non-standard way of providing (disjunctive) reasons and a custom way of explaining them.
This PR simplifies the array solver so that its explanations are analogous to the other equality engine based theory solvers (strings, datatypes, sets, ...). This is done in preparation for the incorporation of the proof equality engine in arrays, which follows a standard design for reasons/explanations.
The performance impact on QF arrays is negligible
Andres Noetzli [Thu, 30 Jul 2020 23:56:33 +0000 (16:56 -0700)]
Python API: Add support for sequences (#4757)
Commit
9678f58a7fedab4fc061761c58382f4023686108 added front end support
for sequences. This commit extends that support to the Python API. It
also adds simple C++ and Python examples that demonstrate how the API
works for sequences.
Gereon Kremer [Thu, 30 Jul 2020 21:59:40 +0000 (23:59 +0200)]
Cad implementation (#4774)
This commit implements the CAD interface added in #4773.
Gereon Kremer [Thu, 30 Jul 2020 16:16:25 +0000 (18:16 +0200)]
Adds the interface for the CAD-based arithmetic solver. (#4773)
This PR adds some utilities and, most importantly, the interface of the new
CAD-based solver.
The approach is based on https://arxiv.org/pdf/2003.05633.pdf and the code
structure follows the paper rather closely.
Andrew V. Jones [Thu, 30 Jul 2020 15:51:42 +0000 (16:51 +0100)]
When linking Editline, use 'pkg-config' to correctly find the link-time dependencies (#4809)
Signed-off-by: Andrew V. Jones <andrew.jones@vector.com>
Andrew Reynolds [Thu, 30 Jul 2020 14:54:57 +0000 (09:54 -0500)]
Fix null case for sygus printing (#4793)
Avoids crashing on some of our debug traces.
Andrew Reynolds [Thu, 30 Jul 2020 14:18:06 +0000 (09:18 -0500)]
(proof-new) Stream output for ProofNode (#4789)
Andrew Reynolds [Thu, 30 Jul 2020 01:15:44 +0000 (20:15 -0500)]
(proof-new) Fixes for getFreeAssumptions (#4802)
Free assumptions weren't getting cleaned up due to not doing a postorder traversal. This issue came up when doing subproof sharing involving SCOPE proofs.
Ying Sheng [Tue, 28 Jul 2020 22:35:06 +0000 (15:35 -0700)]
fixing issue #4808. (#4810)
fixing issue #4808. Remove structural binding, which only supported by c++17.
Andrew Reynolds [Tue, 28 Jul 2020 21:02:41 +0000 (16:02 -0500)]
Remove arrays lazy rintro option (#4806)
This option has model soundness issues (#4771) and moreover is overall worse performance on SMT-LIB {QF_ABV QF_ABVFP QF_ABVFPLRA QF_ALIA QF_ANIA QF_AUFBV QF_AUFLIA QF_AUFNIA QF_AX}:
Configuration #unsat time #sat time #solved #total
CVC4-072720_def 9428 9405.46 24932 16631.6 34360 35399
CVC4-072720_nalr1 9446 9536.41 24924 16146.3 34370 35399
where def = default, nalr1 = --no-arrays-lazy-rintro1.
Fixes #4771.
FYI @barrettcw
Andres Noetzli [Tue, 28 Jul 2020 18:59:28 +0000 (11:59 -0700)]
Replace Expr with Node in Term/Op (#4781)
This commit changes Term and Op to use Nodes internally instead of
Exprs. This is a step towards removing the Expr-layer. This commit also
adds some missing checks regarding the number of arguments for a given
kind that were previously missing, which caused issues in unit tests when
using Node instead of Expr.
Andrew Reynolds [Tue, 28 Jul 2020 18:25:40 +0000 (13:25 -0500)]
Fix regular expression delta for complement (#4765)
Fixes #4759 .
Also refactors this method.
yoni206 [Tue, 28 Jul 2020 17:44:55 +0000 (10:44 -0700)]
Supporting seq.nth (#4723)
This PR adds support for seq.nth operator by eliminating it during expandDefinitions, based on sub-sequences.
Tests that use this operator are also included.
Ying Sheng [Tue, 28 Jul 2020 16:55:52 +0000 (09:55 -0700)]
Interpolation: Add interface for SyGuS interpolation module (step3) (#4726)
This is the 3rd step of adding interface for SyGuS Interpolation module. The whole change will be adding the API for (get-interpol s B), which is aim for computes an I that A->I and I->B. Here A is the assertions in the stack.
The 3rd step partially implemented the interpolation module.
Andrew Reynolds [Tue, 28 Jul 2020 16:03:33 +0000 (11:03 -0500)]
Use lemma property enum for OutputChannel::lemma (#4755)
There are 3 Boolean flags for OutputChannel::lemma, and plans to add another for relevance.
This makes them into a enum.
Andrew Reynolds [Mon, 27 Jul 2020 20:33:12 +0000 (15:33 -0500)]
(proof-new) Proof production for term formula removal (#4687)
This adds proof support in the term formula removal pass.
It also refactors this class heavily so that its interface is more intuitive and does not depend on AssertionPipeline.
Andrew Reynolds [Mon, 27 Jul 2020 19:44:49 +0000 (14:44 -0500)]
(proof-new) Arithmetic operator elim proof producing (#4783)
This updates the interface for arithmetic operator elimination for the new proof format.
The actual proof production of the operator elimination class (providing proofs for
introduced witness terms) will be done in a separate PR.
This also changes the witness terms introduced by this class so their body is in
Skolem form, which simplifies term formula removal.
Co-authored-by: Alex Ozdemir <aozdemir@hmc.edu>
Alex Ozdemir [Mon, 27 Jul 2020 17:20:07 +0000 (10:20 -0700)]
Consider negation's proof before triggering arith pfs. (#4776)
The current arith proof machinery can prove conflicts which are
explained by assumptions and tightened assumptions.
Previously we verified that the conflict constraint was explained in
terms of assumptions and tightened assumptions, before trying to
save/produce a proof.
We did not verify that the negated constraint was an assumption or
tightened assumption.
This caused us to attempt to prove conflicts around constraints whose
negations where proven by general means (in the case of #4714, by the
equality engine), which the proof machinery was not prepared to handle.
This PR also checks that the negate constraint is an assumption or
tightened assumption, before saving the proof.
Thanks, Gereon, for doing the initial investigation into this!
fixes 4714
Co-authored-by: Gereon Kremer <nafur42@gmail.com>
Aina Niemetz [Tue, 21 Jul 2020 17:50:54 +0000 (10:50 -0700)]
GH Actions: Cancel builds on push, remove redundant mac OS build. (#4779)
Andrew Reynolds [Tue, 21 Jul 2020 16:15:39 +0000 (11:15 -0500)]
Support uninterpreted constants in the evaluator (#4777)
Gereon Kremer [Tue, 21 Jul 2020 13:28:38 +0000 (15:28 +0200)]
Preparations for a CAD-based arithmetic solver (#4762)
Based on #4679, this PR contains further preparations for a CAD-based arithmetic solver that extends the current NonlinearExtension.
In detail, it provides:
a Constraints class that manages all (polynomial) constraints visible to the cad solver,
a collection of methods used for cad projections,
a VariableOrdering class that provides different variable ordering heuristics tailored to cad,
an extension to the NlModel class, allowing for witness terms,
further conversion methods, in particular between Node and poly::Polynomial, poly::Value and RealAlgebraicNumber.
Alex Ozdemir [Mon, 20 Jul 2020 20:21:06 +0000 (13:21 -0700)]
Fix a deadlock in the signature tests. (#4772)
* wait() deadlocks if the OS pipe fills
* communicate() does not
This is essentially a duplicate of [this](https://github.com/CVC4/LFSC/pull/38).
Haniel Barbosa [Sat, 18 Jul 2020 05:20:19 +0000 (02:20 -0300)]
Improving equality engine tracing (#4770)
To keep track of the reasoning in the equality engine for n-ary kinds, for which partial applications amount to valid fully-applied terms, it's imperative to be able to see the IDs of the internal representation of the equality engine nodes. This commit updates tracing messages to print these IDs. It also improves the tracing for explanation generation.
Andrew Reynolds [Sat, 18 Jul 2020 04:16:18 +0000 (23:16 -0500)]
(proof-new) Proof recording for assertions pipeline (#4766)
Adds explicit steps to preprocess proof generator if one is provided.
Andrew Reynolds [Sat, 18 Jul 2020 02:24:22 +0000 (21:24 -0500)]
Enumerate shapes feature in fast sygus enumerator (#4742)
This adds the feature of enumerating shapes in the fast sygus enumerator, which is required for a new algorithm for sygus solution reconstruction.
This also adds a builtinToSygus backwards mapping that is required for that algorithm as well.
Note this also changes the implementation of mkFreeVar in sygus term database from skolem to bound variable, which is required to do proper caching for expr::hasBoundVar.
Andres Noetzli [Fri, 17 Jul 2020 22:25:54 +0000 (15:25 -0700)]
Add NodeManagerScopes to fix use-after-free issues (#4768)
This commit fixes our current ASan issues. Some methods in `NodeManager`
were not creating a `NodeManagerScope` for `this` but were indirectly
calling methods that get the `NodeManager` from the current scope, so we
ended up calling methods on a `NodeManager` that had already been
destroyed.