cvc5.git
4 years agoMake option names related to CEGQI consistent (#4316)
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.

4 years agoRefactor inference manager in strings to be amenable to proofs (#4363)
Andrew Reynolds [Mon, 20 Apr 2020 20:16:18 +0000 (15:16 -0500)]
Refactor inference manager in strings to be amenable to proofs (#4363)

This is a key refactoring towards proofs for strings.

This ensures that InferInfo is maintained until just before facts, lemmas and conflicts are processed. This allows us both to:
(1) track more accurate stats and debug information,
(2) have enough information to ensure that proofs can be constructed at the moment facts, lemmas, and conflicts are processed.

Changes in this PR:

PendingInfer and InferInfo were merged, CoreInferInfo is now the previous equivalent of InferInfo, extended with core-solver-specific information, which is only used by CoreSolver.
sendInference( const InferInfo& info, ... ) is now the central method for sending inferences which is called by the other variants, not the other way around.
sendLemma is inlined into sendInference(...) for clarity.
doPendingLemmas and doPendingFacts are extended to process the side effects of the inference infos.
There is actually a further issue with pending inferences related to eagerly processing the side effect of CoreInferInfo before we know the lemma is sent. I believe this issue does not occur in practice based on our strategy. Further refactoring could tighten this, e.g. virtual void InferInfo::processSideEffect. I will do this in another PR.

Further refactoring can address whether asLemma should be a field of InferInfo (it probably should), and whether we should explicitly check for AND in conclusions instead of making it the responsibility of the user of this class.

4 years agoAdd SCOPE proof rule (#4332)
Andrew Reynolds [Mon, 20 Apr 2020 19:53:07 +0000 (14:53 -0500)]
Add SCOPE proof rule (#4332)

This rule is dual to ASSUME. It is a way of closing free assumptions to conclude an implication.

It also changes getId -> getRule.

4 years agoDisable unsat cores on nec regression (#4330)
Andrew Reynolds [Sun, 19 Apr 2020 00:48:04 +0000 (19:48 -0500)]
Disable unsat cores on nec regression (#4330)

Should fix the nightlies.

4 years agoTrack inference id for pending facts in strings (#4331)
Andrew Reynolds [Sat, 18 Apr 2020 22:47:31 +0000 (17:47 -0500)]
Track inference id for pending facts in strings (#4331)

This improves our tracking of pending inferences in strings so that we record pending inferences as a triple (id, fact, exp). This will ensure that proof steps can be constructed at the time we decide to process facts. It also inlines the sendInfer method into sendInference for simplicity.

This also improves the policy for reference counting facts and their explanations: we add them to d_keep when they are added to the equality engine. Previously, we were adding them when they were registered as pending. This means we would collect facts in this pending set that were added but later abandoned, which is unnecessary.

4 years agoImproving EqProof printing (#4329)
Haniel Barbosa [Sat, 18 Apr 2020 12:22:37 +0000 (09:22 -0300)]
Improving EqProof printing (#4329)

4 years agoAdd (context-dependent) Proof (#4323)
Andrew Reynolds [Fri, 17 Apr 2020 16:57:07 +0000 (11:57 -0500)]
Add (context-dependent) Proof (#4323)

A (context-dependent) collection of proof steps that are linked to together to form a ProofNode dag.

Note that the name "Proof" is currently taken. I am calling this class "CDProof", although it is optionally context dependent.

4 years agoantlr: Use relative path in ANTLR script. (#4324)
Mathias Preiner [Fri, 17 Apr 2020 05:50:05 +0000 (22:50 -0700)]
antlr: Use relative path in ANTLR script. (#4324)

This will fix the CI caching issues we sometimes encountered on GH actions.

4 years agoSyGuS instantiation quantifiers module (#3910)
Mathias Preiner [Fri, 17 Apr 2020 02:31:42 +0000 (19:31 -0700)]
SyGuS instantiation quantifiers module (#3910)

4 years agoAdd ProofNodeManager and ProofChecker (#4317)
Andrew Reynolds [Thu, 16 Apr 2020 21:00:25 +0000 (16:00 -0500)]
Add ProofNodeManager and ProofChecker (#4317)

Further work on adding core utilities for ProofNode objects, in support of the new proof infrastructure.

ProofNodeManager is analogous to NodeManager. It is a trusted way of generating only "well-formed" ProofNode pointers (according to a checker).

ProofChecker is analogous to TypeChecker. It is intended to be infrastructure for our internal proof checker.

This PR (and 1 more) is required to get to a place where Haniel and I can collaborate on further development for proofs.

4 years agoEliminate remaining references to parent TheoryStrings object (#4315)
Andrew Reynolds [Thu, 16 Apr 2020 14:50:43 +0000 (09:50 -0500)]
Eliminate remaining references to parent TheoryStrings object (#4315)

This PR makes it so that the module dependencies in the theory of strings are acyclic. This is important for further organization towards proofs for strings.

The main change in this PR is to ensure that InferenceManager has a pointer to ExtTheory, which is needed for several of its methods. This required changing several solvers into unique_ptr to properly initialize.

4 years agoAdd ProofNode data structure (#4311)
Andrew Reynolds [Wed, 15 Apr 2020 22:09:40 +0000 (17:09 -0500)]
Add ProofNode data structure (#4311)

This is the core data structure for proofs in the new proofs infrastructure. PfRule is a global enumeration of ids of proof nodes (analogous to Kind for Nodes).

4 years agoMove regular expression inclusion test to RegExpEntail (#4310)
Andrew Reynolds [Wed, 15 Apr 2020 14:00:47 +0000 (09:00 -0500)]
Move regular expression inclusion test to RegExpEntail (#4310)

In preparation for rephrasing this inference as a rewrite.

4 years agoChange option names --default-dag-thresh and --default-expr-depth (#4309)
Andrew Reynolds [Wed, 15 Apr 2020 13:37:46 +0000 (08:37 -0500)]
Change option names --default-dag-thresh and --default-expr-depth (#4309)

4 years agoSplit TermRegistry object from TheoryStrings (#4312)
Andrew Reynolds [Wed, 15 Apr 2020 13:23:27 +0000 (08:23 -0500)]
Split TermRegistry object from TheoryStrings (#4312)

This consolidates functionalities from TheoryStrings and InferenceManager related to registering terms, including sending "preregistration lemmas" for them. The main purpose of this PR is to detangle this module from InferenceManager so that these two modules have exactly one call to OutputChannel::lemma each.

For the purposes of the theory solvers, TermRegistry contains the official SkolemCache of TheoryStrings, and can be seen as subsuming the previous interface for this class.

This PR is needed for further progress on strings proofs, marking as major since this will be a blocker shortly for this project.

A few things were cleaned in this PR. One function changed name InferenceManager::registerTerm --> TermRegistry::getRegisterTermLemma. No major behavior changes.

4 years agoDo not mark string extended functions as eliminated after reduction lemmas (#4306)
Andrew Reynolds [Wed, 15 Apr 2020 12:55:41 +0000 (07:55 -0500)]
Do not mark string extended functions as eliminated after reduction lemmas (#4306)

The current policy marked extended functions in strings as "reduced" (eliminated) when we generated their reduction lemma. The upside is that the solver can effectively ignore them. The downside is that we cannot do context-dependent simplification on them, and hence we miss out conflicts during the remainder of the check-sat call.

This changes the policy so they are not marked as reduced. Instead, reduction lemmas are cached in the standard way while allowing context-dependent simplification.

4 years agoFix assertion in enumerative instantiation (#4313)
Andrew Reynolds [Wed, 15 Apr 2020 08:02:50 +0000 (03:02 -0500)]
Fix assertion in enumerative instantiation (#4313)

Fixes regress1.

4 years agoConvert more cases of strings to words (#4206)
Andrew Reynolds [Wed, 15 Apr 2020 07:34:33 +0000 (02:34 -0500)]
Convert more cases of strings to words (#4206)

4 years agoAbort if in conflict in enumerative instantiation (#4298)
Andrew Reynolds [Wed, 15 Apr 2020 06:28:18 +0000 (01:28 -0500)]
Abort if in conflict in enumerative instantiation (#4298)

In very rare cases, quantifiers engine can be the first to detect a quantifier-free conflict while constructing term indices. When this occurs, instantiation modules can quit immediately. This was not happening in a case of enumerative instantiation.

Fixes #4293.

4 years agoAlways flush lemmas from downwards closure in sets (#4297)
Andrew Reynolds [Wed, 15 Apr 2020 05:52:33 +0000 (00:52 -0500)]
Always flush lemmas from downwards closure in sets (#4297)

Fixes #4283.

This also makes a few minor improvements to how lemmas are sent in sets. In particular, lemmas are not sent if we are already in conflict.

4 years agoDo not normalize to representatives for variable equalities in conflict-based instant...
Andrew Reynolds [Wed, 15 Apr 2020 05:15:10 +0000 (00:15 -0500)]
Do not normalize to representatives for variable equalities in conflict-based instantiation (#4280)

Conflict-based instantiation would sometimes initialize a match x -> getRepresentative(t) when a quantified formula contained x = t. This leads to issues where getRepresentative(t) is an illegal term (say, in combination with CEGQI). This makes it so the representative is accessed when necessary instead of being set as part of the match.

Fixes #4275.

4 years agoAlways assign function values in higher order (#4279)
Andrew Reynolds [Wed, 15 Apr 2020 03:02:31 +0000 (22:02 -0500)]
Always assign function values in higher order (#4279)

Fixes #4277.

4 years agoFix combinations of cegqi and non-standard triggers (#4271)
Andrew Reynolds [Wed, 15 Apr 2020 02:28:57 +0000 (21:28 -0500)]
Fix combinations of cegqi and non-standard triggers (#4271)

Counterexample-guided instantiation may produce quantified formulas with INST_CONSTANT nodes, which are also used as patterns for non-standard triggers for E-matching. This fixes a few combinations that were problematic.

Fixes #4250, fixes #4254, fixes #4269 and fixes #4281.

4 years agoDisable preregistration of instantiations for cegqi in incremental (#4251)
Andrew Reynolds [Wed, 15 Apr 2020 01:54:54 +0000 (20:54 -0500)]
Disable preregistration of instantiations for cegqi in incremental (#4251)

Fixes #4243.

4 years agoDisable macros when higher-order (#4266)
Andrew Reynolds [Tue, 14 Apr 2020 23:19:06 +0000 (18:19 -0500)]
Disable macros when higher-order (#4266)

Fixes #4160.

4 years agoFix relevant domain computation for nested quantifiers coming from CEGQI (#4235)
Andrew Reynolds [Tue, 14 Apr 2020 21:27:29 +0000 (16:27 -0500)]
Fix relevant domain computation for nested quantifiers coming from CEGQI (#4235)

Fixes #4228. That benchmark now times out.

4 years agoRemove a few options (#4295)
Andrew Reynolds [Tue, 14 Apr 2020 20:27:33 +0000 (15:27 -0500)]
Remove a few options (#4295)

These options are not robust and are not used.

Fixes #4282 and fixes #4291.

4 years agoRemove a few spurious assertions (#4294)
Andrew Reynolds [Tue, 14 Apr 2020 19:38:01 +0000 (14:38 -0500)]
Remove a few spurious assertions (#4294)

Fixes #4290 and fixes #4292.

4 years agoRemove early type check option (#4234)
Andrew Reynolds [Tue, 14 Apr 2020 18:38:20 +0000 (13:38 -0500)]
Remove early type check option (#4234)

Required to decouple options from NodeManager.

This option is now always enabled in debug, and disabled in production.

4 years agoRemove argument extender (#4223)
Andrew Reynolds [Tue, 14 Apr 2020 17:37:26 +0000 (12:37 -0500)]
Remove argument extender (#4223)

This was a utility class for dynamically changing argc/argv.

4 years agoRemove mergePredicates from EqualityEngine interface (#4305)
Andrew Reynolds [Tue, 14 Apr 2020 16:42:00 +0000 (11:42 -0500)]
Remove mergePredicates from EqualityEngine interface (#4305)

This function was equivalent to asserting an equality. Removing it for the sake of simplicity.

4 years agoFix dump-unsat-cores-full (#4303)
Andrew Reynolds [Tue, 14 Apr 2020 15:52:01 +0000 (10:52 -0500)]
Fix dump-unsat-cores-full (#4303)

This adds a fix to ensure dump-unsat-cores-full works by modifying the public options function. This options currently does not work since dumpUnsatCores is only set internally now. This fix is only required until options are refactored so that SmtEngine owns the authoritative copy of options.

4 years agoFix SyGuS define-fun printing from benchmarks coming from v1 parser (#4256)
Andrew Reynolds [Mon, 13 Apr 2020 21:27:48 +0000 (16:27 -0500)]
Fix SyGuS define-fun printing from benchmarks coming from v1 parser (#4256)

A recent change made it so that defined functions would print as the anonymous lambda corresponding to their definition if the SyGuS v1 parser was used. This was caused by comparison with the wrong kind in the new API.

Notice that the v2 parser does not have this issue.

This also adds a regression to ensure this behavior is maintained by the SyGuS v2 parser.

4 years agoFixes for extended rewriter (#4278)
Andrew Reynolds [Sun, 12 Apr 2020 20:10:31 +0000 (15:10 -0500)]
Fixes for extended rewriter (#4278)

Fixes #4273 and fixes #4274 .

This also removes a spurious assertion from the Node::substitute method that the result node is not equal to the domain. This is violated for f(f(x)) { f(x) -> x }.

4 years agoMove slow nl regression to regress3 (#4276)
Andrew Reynolds [Sun, 12 Apr 2020 16:01:24 +0000 (11:01 -0500)]
Move slow nl regression to regress3 (#4276)

Should fix nightlies.

4 years agoAdd skip predicate to node traversal. (#4222)
Alex Ozdemir [Sat, 11 Apr 2020 17:16:05 +0000 (10:16 -0700)]
Add skip predicate to node traversal. (#4222)

Sometime you want to skip specific sub-DAGs when traversing a node. For example, you might be doing a transformation with a cache, and want to skip sub-DAGs that you've already processed.

This PR would add a skipIf builder method to NodeDfsIterable, which allows the user to provide a predicate according to which nodes will be omitted from the subsequent traversal.

4 years agoEnsure exported sygus solutions match grammar (#4270)
Andrew Reynolds [Sat, 11 Apr 2020 04:37:43 +0000 (23:37 -0500)]
Ensure exported sygus solutions match grammar (#4270)

Previously we were doing rewriting/expand definitions during grammar normalization, which overwrote the original sygus operators. The connection to the original grammar was maintained via the SygusPrintCallback utility, which ensured that a sygus term printed in a way that matched the grammar.

We now have several use cases where solutions from SyGuS will be directly exported to the user, including the current use of get-abduct. This means that the terms must match the grammar, and we cannot simply rely on the print callback.

This moves the code to normalize sygus operators to datatypes utils, where the conversion between sygus and builtin terms takes place. This allows a version of this function where isExternal = true, which constructs terms matching the original grammar.

This PR enables the SyGuS API to have an accurate getSynthSolution method. It also will eliminate the need for SygusPrintCallback altogether, once the v1 parser is deleted.

4 years agoSplit the non-linear solver (#4219)
Andrew Reynolds [Sat, 11 Apr 2020 00:15:18 +0000 (19:15 -0500)]
Split the non-linear solver (#4219)

This splits the "non-linear solver" from "NonlinearExtension". The non-linear solver is the module that implements the inference schemas whereas NonlinearExtension is the glue code that manages the solver(s) for non-linear.

This also involves moving utilities from the non-linear solver to their own file.

4 years agoExplain non-emptiness by non-zero length in strings (#4257)
Andrew Reynolds [Fri, 10 Apr 2020 16:15:22 +0000 (11:15 -0500)]
Explain non-emptiness by non-zero length in strings (#4257)

Several kinds of splitting lemmas in the strings solver can sometimes be avoided by observing that str.len(x) != 0 implies that x is non-empty. This generalizes the check for whether x is non-empty is explainable in the current context.

4 years agoAdd a few stats to strings (#4252)
Andrew Reynolds [Fri, 10 Apr 2020 15:45:52 +0000 (10:45 -0500)]
Add a few stats to strings (#4252)

To give an idea of the high-level behavior.

4 years agoTowards proper use of resource managers (#4233)
Andrew Reynolds [Fri, 10 Apr 2020 00:19:40 +0000 (19:19 -0500)]
Towards proper use of resource managers (#4233)

Resource manager will be owned by SmtEngine in the future. This passes the resource manager cached by SmtEnginePrivate to the PropEngine created by SmtEngine instead of using the global pointer. It also makes a few preprocessing passes use the resource manager they already have access to and should use.

4 years agoCI: Add a step to list dependencies. (#4255)
Mathias Preiner [Thu, 9 Apr 2020 22:57:45 +0000 (15:57 -0700)]
CI: Add a step to list dependencies. (#4255)

4 years agoDisable slow sygus regression (#4232)
Andrew Reynolds [Thu, 9 Apr 2020 18:53:06 +0000 (13:53 -0500)]
Disable slow sygus regression (#4232)

A regress2 SyGuS benchmark is taking 110 seconds in production on my machine. This was likely caused by the recent update v1 -> v2, which impacts the internal representation and hence the search. Disabling for now.

4 years agoSplit ProcessAssertions module from SmtEngine (#4210)
Andrew Reynolds [Thu, 9 Apr 2020 01:26:11 +0000 (20:26 -0500)]
Split ProcessAssertions module from SmtEngine (#4210)

This is a step towards refactoring the SmtEngine. It splits several core components of SmtEnginePrivate to its own independent module, ProcessAssertions which is responsible for applying preprocessing passes , simplification and expand definitions.

The main change involved moving these functions from SmtEnginePrivate to this new class. A few other minor changes were done to make this move:

A few things changed order within processAssertions to allow SmtEnginePrivate-specific things to happen outside of the main scope of processAssertions.
processAssertions had some logic to catch incompatible options and silently disable options. This was moved to setDefaults.
A few data members in SmtEngine were moved to ProcessAssertions.
Two utilities that were sitting in smt_engine.cpp were moved to their own files.
Another refactoring step will be to make ProcessAssertions take only the utilities it needs instead of taking a SmtEngine reference. This requires further detangling of Options.

4 years agoAdded CHOOSE operator for sets (#4211)
mudathirmahgoub [Wed, 8 Apr 2020 23:24:16 +0000 (18:24 -0500)]
Added CHOOSE operator for sets (#4211)

This PR enables THEORY_UF by default for sets and adds the operator CHOOSE for sets which returns an element from a given set. The semantics is as follows:

If a set A = {x}, then the term (choose A) is equivalent to the term x.
If the set is empty, then (choose A) is an arbitrary value.
If the set has cardinality > 1, then (choose A) will deterministically return an element in A.

4 years agoPerform theory widening eagerly (#4044)
Andres Noetzli [Wed, 8 Apr 2020 21:38:09 +0000 (14:38 -0700)]
Perform theory widening eagerly (#4044)

Fixes #3971 and fixes #3991. In incremental mode, the logic can change from one
(check-sat) call to another. In the reported issue, we start with QF_NIA
but then switch to QF_UFNIA because there is a div term (which has a UF in
its expanded form). Dealing with this issue is challenging in general. As a
result, we have decided not to allow theory widening in
Theory::expandDefinitions() anymore but instead to do it eagerly in
SmtEngine::setDefaults().

4 years agoFix dump models and dump proofs (#4230)
Andrew Reynolds [Wed, 8 Apr 2020 20:24:55 +0000 (15:24 -0500)]
Fix dump models and dump proofs (#4230)

A recent commit (45e489e) made it so that dump-models did not automatically enable produce-models in the global options object, but instead the SmtEngine enabled produce-models internally. The code for dump-models and dump-proofs was (perhaps out of paranoia) checking produce-models and produce-proofs. This removes this check, which is the correct thing to do since SmtEngine internally ensures produce-models is set.

4 years agoEliminate call to currentNM within NodeManager (#4227)
Andrew Reynolds [Wed, 8 Apr 2020 13:50:14 +0000 (08:50 -0500)]
Eliminate call to currentNM within NodeManager (#4227)

Eliminates 2 unintentional calls to the global access function.

4 years agoCleanup deprecated quantifiers attribute features (#4215)
Andrew Reynolds [Tue, 7 Apr 2020 03:48:13 +0000 (22:48 -0500)]
Cleanup deprecated quantifiers attribute features (#4215)

4 years agoDisable slow regression (#4221)
Andrew Reynolds [Tue, 7 Apr 2020 01:58:17 +0000 (20:58 -0500)]
Disable slow regression (#4221)

Benchmark recently became slow, disable for now.

4 years agoEnum for all remaining string inferences (#4220)
Andrew Reynolds [Tue, 7 Apr 2020 00:00:13 +0000 (19:00 -0500)]
Enum for all remaining string inferences (#4220)

Merges the Flat Form inferences enum into Inferences. Adds documentation for (most of) these inferences. Removes the old infrastructure for inferences based on a debug string in InferenceManager.

4 years agoRemove links field in all toml files (#4201)
Andrew Reynolds [Mon, 6 Apr 2020 21:44:01 +0000 (16:44 -0500)]
Remove links field in all toml files (#4201)

This includes:

All options pertaining to SMTEngine are now handled at the top of setDefaults.
smtlibStrict was deleted in favor of a script.
statsEveryQuery enables stats by modifying a public option function. This is a slight hack but this code will likely get refactored as well soon.
A few other changes:

Fix a bug in SMTEngine: defineFunction should finalize options.
Call setDefaults before initilizing the TheoryEngine and ProofManager. This is necessary so that the PROOF(...) macro works earlier during initialization.
The next step will be to remove the links infrastructure for the options infrastructure. This will enable further detangling of our options dependencies.

4 years agoRefactor disequality processing in string solver (#4209)
Andres Noetzli [Mon, 6 Apr 2020 20:56:35 +0000 (13:56 -0700)]
Refactor disequality processing in string solver (#4209)

This commit refactors disequality processing in the core string solver.
It also adds statistics for the inferences and splits in those methods.
No semantic changes intended.

4 years agoNew C++ API: Rename Solver::mkTermInternal. (#4217)
Aina Niemetz [Mon, 6 Apr 2020 20:29:05 +0000 (13:29 -0700)]
New C++ API: Rename Solver::mkTermInternal. (#4217)

This is for consistency with the other helper functions.

4 years agoAdd missing stat for lemmas based on inferences (#4214)
Andrew Reynolds [Sun, 5 Apr 2020 20:51:20 +0000 (15:51 -0500)]
Add missing stat for lemmas based on inferences (#4214)

4 years agoAdd safe_print() support for Kind enum (#4213)
Andres Noetzli [Sun, 5 Apr 2020 16:42:59 +0000 (09:42 -0700)]
Add safe_print() support for Kind enum (#4213)

This commit changes the mkkind script to generate a toString()
method for the Kind enum. This method can be used by the
safe_print() function to print statistics if CVC4 has been terminated
before solving a problem. The stats for strings include statistics that
rely on printing kinds (e.g. the number of reductions done of each
kind).

4 years agoType-independent preregistration of empty word (#4205)
Andrew Reynolds [Sun, 5 Apr 2020 06:52:37 +0000 (01:52 -0500)]
Type-independent preregistration of empty word (#4205)

Also removes another instance of empty string in TheoryStrings for consistency sake.

4 years agoNew C++ API: Remove Op::getSort(). (#4208)
Aina Niemetz [Sat, 4 Apr 2020 01:53:41 +0000 (18:53 -0700)]
New C++ API: Remove Op::getSort(). (#4208)

4 years agoUpdate theory rewriter ownership, add stats to strings (#4202)
Andres Noetzli [Fri, 3 Apr 2020 21:52:45 +0000 (14:52 -0700)]
Update theory rewriter ownership, add stats to strings (#4202)

This commit adds statistics for string rewrites. This is work towards proof
support in the string solver. At a high level, this commit adds a pointer to a
`SequenceStatistics` in the rewriters and modifies
`SequencesRewriter::returnRewrite()` to count the rewrites done. In practice,
to make this work requires a couple of changes, some of them temporary:

- We can't have a single `Rewriter` instance shared between different
  `SmtEngine` instances anymore. Thus the `Rewriter` is now owned by the
  `SmtEngine` and calling the rewriter retrieves the rewriter associated with
  the current `SmtEngine`. This is a temporary workaround before we get rid of
  singletons.
- Methods in the `SequencesRewriter` and the `StringsRewriter` are made
  non-`static` because they need access to the statistics instance.
- `StringsEntail` now has non-`static` methods because it needs a reference to
  the sequences rewriter that it can call.
- The interaction between the `StringsRewriter` and the `SequencesRewriter`
  changed: the `StringsRewriter` is now a proper `TheoryRewriter` that inherits
  from `SequencesRewriter` and calls its `postRewrite()` before applying its
  own rewrites (this is essentially a reversal of roles from before: the
  `SequencesRewriter` used to call `static` methods in the `StringsRewriter`).
- The theory rewriters are now owned by the individual theories. This design
  mirrors the `EqualityEngine`s owned by the individual theories.

4 years agoOnly rewrite lambdas via array representations when constant (#4203)
Andrew Reynolds [Fri, 3 Apr 2020 18:07:56 +0000 (13:07 -0500)]
Only rewrite lambdas via array representations when constant (#4203)

Fixes #4170.

4 years agoSplit sequences rewriter (#4194)
Andrew Reynolds [Fri, 3 Apr 2020 14:43:12 +0000 (09:43 -0500)]
Split sequences rewriter (#4194)

This is in preparation for making the strings rewriter configurable for stats.

This moves all utility functions from SequencesRewriter to a proper place. This includes three new groupings of utility functions: those involving arithmetic entailments, those involving string entailments, those involving regular expression entailments. Here, "entailments" loosely means any question regarding a (set of) terms or formulas.

No major code changes. Added some missing documentation and lightly cleaned a few blocks of code in cpp.

4 years agoRemove undocumented/uncommon aliases (#4177)
Andres Noetzli [Thu, 2 Apr 2020 18:59:34 +0000 (11:59 -0700)]
Remove undocumented/uncommon aliases (#4177)

This commit removes aliases that are either undocumented or associated
with uncommon options.

Note: The removal of --statistics, --language, and --output-language may be controversial. The options were undocumented previously and I am in favor of simplifying the options as much as possible, however. Please let me know what you think.

4 years agoIntroduce enums for all string inferences, excluding the core solver (#4195)
Andrew Reynolds [Thu, 2 Apr 2020 05:01:21 +0000 (00:01 -0500)]
Introduce enums for all string inferences, excluding the core solver (#4195)

Introduce enum values for all calls to sendInference outside of the core solver.

This included some minor refactoring.

4 years agoInitialize theory rewriters in theories (#4197)
Andres Noetzli [Thu, 2 Apr 2020 02:35:25 +0000 (19:35 -0700)]
Initialize theory rewriters in theories (#4197)

Until now, the `Rewriter` was responsible for creating `TheoryRewriter`
instances. This commit adds a method `mkTheoryRewriter()` that theories
override to create an instance of their corresponding theory rewriter.
The advantage is that the theories can pass additional information to
their theory rewriter (e.g. a statistics object).

4 years agoSupport char smt-lib syntax (#4188)
Andrew Reynolds [Wed, 1 Apr 2020 05:30:44 +0000 (00:30 -0500)]
Support char smt-lib syntax (#4188)

Towards support for the strings standard.

Adds support to (_ char #x ... ) syntax for characters.

4 years agoFix install for ANTLR contrib script and CI dependency caching. (#4196)
Mathias Preiner [Wed, 1 Apr 2020 04:31:13 +0000 (21:31 -0700)]
Fix install for ANTLR contrib script and CI dependency caching. (#4196)

4 years agoRename checkValid/query to checkEntailed. (#4191)
Aina Niemetz [Wed, 1 Apr 2020 01:12:16 +0000 (18:12 -0700)]
Rename checkValid/query to checkEntailed. (#4191)

This renames api::Solver::checkValidAssuming to checkEntailed and
removes api::Solver::checkValid. Internally, SmtEngine::query is renamed
to SmtEngine::checkEntailed, and these changes are further propagated to
the Result class.

4 years agoSwitch to GitHub actions for CI (#4190)
Mathias Preiner [Tue, 31 Mar 2020 23:44:03 +0000 (16:44 -0700)]
Switch to GitHub actions for CI (#4190)

Enable CI with GitHub actions, add macOS builds and disable Travis CI.

4 years agoFix fmf benchmark (#4193)
Andrew Reynolds [Tue, 31 Mar 2020 20:25:01 +0000 (15:25 -0500)]
Fix fmf benchmark (#4193)

Fixes regress1.

This benchmark is too delicate in the current state.

4 years agoRemove replay and use-theory options and idl (#4186)
Andrew Reynolds [Tue, 31 Mar 2020 19:27:04 +0000 (14:27 -0500)]
Remove replay and use-theory options and idl (#4186)

Towards disentangling Options / NodeManager / SmtEngine.

This PR removes options --use-theory=NAME and --replay/--replay-log. Both of these options are highly complex, unused, and lead to complications when implementing the way options and our build system work.

The first is motivated by making TheoryEngine use an "alternate" theory, which appears to e.g. make it so that TheoryIdl could entirely replace TheoryArith. I believe this is too heavy handed of a solution: there should a consistent TheoryArith class, and options should be used to enable/disable alternate modules within it.

The second attempts to replay low level decisions from the SAT solver. It is documented as not working (in 1.0). I do not believe this is worth salvaging.

It also removes the solver in src/theory/idl, which cannot be enabled after this commit.

4 years agoFix strange bound regression (#4192)
Andrew Reynolds [Tue, 31 Mar 2020 16:49:02 +0000 (11:49 -0500)]
Fix strange bound regression (#4192)

Several things have happened with this regression lately, in chronological order:
(1) Instantiations involving bounded set quantifiers were changed to use choice to represent symbolic instantiations,
(2) fmf-bound was decoupled from finite-model-find (the latter is not enabled when the former is),
(3) choice was set to be an "unevaluated" kind (in 0060de3).

After (1) and (2), for the regression test/regress/regress1/fmf/fmf-strange-bounds.smt2, CVC4 was answering "sat" correctly but internally there was a source of incompleteness. In particular, a choice term was being generated in an instantiation that was later incorrectly evaluated, thus allowing CVC4 to skip an instantiation it shouldn't have.

The recent commit of (3) resolved this issue, making it so that choice is not an evaluated kind. This meant the benchmark went "sat" -> "unknown".

This PR fixes this issue by enabling --finite-model-find, which is now necessary to answer "sat".

It also adds a further test quantifier that was used in debugging this issue.

Fixes regress1.

4 years agoConvert more uses of string-specific functions (#4158)
Andrew Reynolds [Tue, 31 Mar 2020 15:07:29 +0000 (10:07 -0500)]
Convert more uses of string-specific functions (#4158)

Towards theory of sequences.

4 years agoFixing regressions (#4189)
Andrew Reynolds [Tue, 31 Mar 2020 13:39:21 +0000 (08:39 -0500)]
Fixing regressions (#4189)

An option was recently deleted, forgot to disable it from a regression. Fixes a failure in regress1.

4 years agoRewrites for all remaining return statements in strings rewriter (#4178)
Andrew Reynolds [Mon, 30 Mar 2020 23:15:07 +0000 (18:15 -0500)]
Rewrites for all remaining return statements in strings rewriter (#4178)

Towards proofs for string rewrites. All return statements all now associated with an enum value.

An indentation in a block of code changed in rewriteMembership.

4 years agoSupport indexed operators re.loop and re.^ (#4167)
Andrew Reynolds [Mon, 30 Mar 2020 21:29:23 +0000 (16:29 -0500)]
Support indexed operators re.loop and re.^ (#4167)

Towards support for the strings standard.

This modifies our interface so that we accept the SMT-LIB standard versions of re.loop and re.^. This means re.loop no longer accepts 3 arguments but 1 (with 2 indices).

This means we no longer accept re.loop with only a lower bound and no upper bound on the number of repetitions.

Also fixes #4161.

4 years agoRemove ref skolem datatype option (#4185)
Andrew Reynolds [Mon, 30 Mar 2020 19:52:55 +0000 (14:52 -0500)]
Remove ref skolem datatype option (#4185)

Fixes #4180, fixes CVC4/cvc4-projects#133, fixes CVC4/cvc4-projects#134.

4 years agoAdd coverage badge. (#4187)
Mathias Preiner [Mon, 30 Mar 2020 18:08:52 +0000 (11:08 -0700)]
Add coverage badge. (#4187)

Coverage information is updated nightly.

4 years agoFix arguments to print callback (#4171)
Andrew Reynolds [Mon, 30 Mar 2020 15:46:45 +0000 (10:46 -0500)]
Fix arguments to print callback (#4171)

The method applyParseOp may modify the argument vector. In the case of the sygus V1 parser, this argument vector was then being used to set up a print callback, leading to incorrect printing and failures.

Work towards having a working V1 -> V2 conversion for the release.

FYI @abdoo8080

4 years agoFrontend support for the choice operator (#4175)
mudathirmahgoub [Mon, 30 Mar 2020 14:04:52 +0000 (09:04 -0500)]
Frontend support for the choice operator (#4175)

Added the operator choice to Smt2.g and Cvc.g.
Removed the unused parameter hasBoundVars from TheoryModel::getModelValue

4 years agoEnumeration for String rewrites (#4173)
Andrew Reynolds [Sun, 29 Mar 2020 00:50:35 +0000 (19:50 -0500)]
Enumeration for String rewrites (#4173)

In preparation for string proof infrastructure.

This introduces an enumeration type to track string rewrites.

It also makes inference printing more consistent.

4 years agoChange is-cons to (_ is cons) in Sygus benchmarks. (#4174)
Abdalrhman Mohamed [Sat, 28 Mar 2020 19:31:37 +0000 (14:31 -0500)]
Change is-cons to (_ is cons) in Sygus benchmarks. (#4174)

4 years agoConvert the last few Sygus benchmarks to V2. (#4172)
Abdalrhman Mohamed [Sat, 28 Mar 2020 17:39:47 +0000 (12:39 -0500)]
Convert the last few Sygus benchmarks to V2. (#4172)

4 years agoStop printing datatype declaration for Sygus V1 grammar. (#4168)
Abdalrhman Mohamed [Sat, 28 Mar 2020 16:41:22 +0000 (11:41 -0500)]
Stop printing datatype declaration for Sygus V1 grammar. (#4168)

4 years agoNode traversal iterator (#3845)
Alex Ozdemir [Sat, 28 Mar 2020 06:22:41 +0000 (23:22 -0700)]
Node traversal iterator (#3845)

Implement an iterator for pre- and post-order traversals.

I believe that this will be useful in pre-processing passes, many of
which do postorder traversals that they implement by hand.

Right now this iterator does not support modification of the traversal
pattern, but we could add this later on, if we want it.

Co-authored-by: Andres Noetzli <andres.noetzli@gmail.com>
Co-authored-by: Mathias Preiner <mathias.preiner@gmail.com>
4 years agoSplit transcendental solver to its own file (#4156)
Andrew Reynolds [Sat, 28 Mar 2020 00:53:59 +0000 (19:53 -0500)]
Split transcendental solver to its own file (#4156)

* Attempting to split transcendental function solver

* Clean

* Format

* More

* Format

* Attempt link

* Format

* Fix

* Another refactor

* More

* More

* Rename

* Format

Co-authored-by: Ahmed Irfan <43099566+ahmed-irfan@users.noreply.github.com>
Co-authored-by: Aina Niemetz <aina.niemetz@gmail.com>
4 years agoFix issues with unsat cores and reset-assertions (#4159)
Andres Noetzli [Fri, 27 Mar 2020 23:37:14 +0000 (16:37 -0700)]
Fix issues with unsat cores and reset-assertions (#4159)

Fixes #4151. Commit e9f4cec2cad02e270747759223090c16b9d2d44c fixed how
`(reset-assertions)` is handled by destroying and recreating the
`PropEngine` owned by `SmtEngine`. When unsat cores are enabled,
creating a `PropEngine` triggers the creation of a SAT proof and a CNF
proof. In the `ProofManager`, we had assertions that checked that those
kinds of proofs were only created once, which is not true anymore. This
commit removes the assertions, cleans up the memory management in
`ProofManager` to use `std::unique_ptr` and makes all the
`ProofManager::init*` methods non-static for consistency.

The commit also fixes an additional issue that I encountered while
testing the fix: When creating the new `PropEngine`, we were not
asserting `true` and `(not false)`, which lead to an error if we tried
to get the unsat core after a `(reset-assertion)` command and we had
asserted `(assert false)`. The commit fixes this by asserting `true` and
`(not false)` in the constructor of `PropEngine`.

The regression test is an extension of the example in #4151 and covers
both issues.

4 years agoFix expected output on arith regression (#4162)
Andrew Reynolds [Fri, 27 Mar 2020 22:45:30 +0000 (17:45 -0500)]
Fix expected output on arith regression (#4162)

A benchmark went unknown -> sat, likely due to the arith-brab commit, thus leading to a failure on regress1.This updates the status on this benchmark (also adds --nl-ext-tplanes to it).

4 years agoMove string utility file (#4164)
Andrew Reynolds [Fri, 27 Mar 2020 19:04:44 +0000 (14:04 -0500)]
Move string utility file (#4164)

Moves the string file to string.h. This is required since other required utilities will soon need to be added to regexp.h.

4 years agoDo not require that function sorts are first class internally (#4128)
Andrew Reynolds [Fri, 27 Mar 2020 15:23:42 +0000 (10:23 -0500)]
Do not require that function sorts are first class internally (#4128)

This PR removes the requirement in the NodeManager that argument types to the function sort are first class.

Notice that the new API does this check (as it should): https://github.com/CVC4/CVC4/blob/master/src/api/cvc4cpp.cpp#L2633

Moreover, SyGuS v2 internally requires constructing function types having arguments that are not first class (e.g. regular expression type). This is required to update the regression https://github.com/CVC4/CVC4/blob/master/test/regress/regress1/sygus/re-concat.sy to SyGuS v2.

FYI @abdoo8080 .

4 years agoSupport unicode internal representation and escape sequences (#3852)
Andrew Reynolds [Fri, 27 Mar 2020 14:01:38 +0000 (09:01 -0500)]
Support unicode internal representation and escape sequences (#3852)

Work towards support for the strings standard.

This updates the string solver and parser such that:

The internal representation of strings is vectors of code points,
Generation of the previous internal representation of strings has been relegated to the type enumerator. This is the code that ensures that "A" is the first character chosen for values of strings in models,
The previous ad-hoc escape sequence handling is moved from the String class to the parser. It will live there for at least one version of CVC4, until we no longer support non-smt-lib complaint escape sequences or non-printable characters in strings,
Handle unicode escape sequences according to the SMT-LIB standard in String,
Simplify a number of calls to String utility functions, since the conversion between the previous internal format and code points is now unnecessary,
Fixed a bug in the handling of TO_CODE: it should be based on the alphabet cardinality, not the number of internal code points.

4 years agoMove set defaults function to its own file (#4154)
Andrew Reynolds [Fri, 27 Mar 2020 04:13:39 +0000 (23:13 -0500)]
Move set defaults function to its own file (#4154)

This moves SmtEngine::setDefaults to its own file.

This design is not final. One could imagine this being a part of a "OptionsSetter" utility. I am leaving this as is until we refactor the relationship between SmtEngine and Options.

Regardless, the general file structure should be such that this method is separate from SmtEngine, since setting default options is a large task that should be addressed independently from the core of SmtEngine.

This is initial preparation towards converting the SmtEngine from Expr -> Node.

A few very minor changes were made to the code to make the separation possible.

4 years agoAdded unit-cube-like test for branch and bound (#3922)
Amalee [Thu, 26 Mar 2020 23:32:51 +0000 (16:32 -0700)]
Added unit-cube-like test for branch and bound (#3922)

* unit-cude test wip

* test for wip unit cube test

* fixed simple rounding

* wip

* Passing tests except for sat vs unknown ones

* added flag for cube test

* put example back to normal

* Fixed for style guidelines.

* fixed rewrite bug

* removed extra comments

* unit-cude test wip

* test for wip unit cube test

* fixed simple rounding

* wip

* Passing tests except for sat vs unknown ones

* added flag for cube test

* put example back to normal

* Fixed for style guidelines.

* fixed rewrite bug

* removed extra comments

* Small fixes based on PR feedback

* replace NodeManager::currentNM with nm and clang formatted

* renamed test

* Added a regression test that triggers branch and bound

* Added ; COMMAND-LINE: --arith-brab

* Updated arith-brab test

* arith-brab enabled by default

* Added --nl-ext-tplanes to regress0/nl/ext-rew-aggr-test.smt2

Co-authored-by: Amalee Wilson <amalee@cis.uab.edu>
Co-authored-by: Ahmed Irfan <43099566+ahmed-irfan@users.noreply.github.com>
Co-authored-by: Andrew Reynolds <andrew.j.reynolds@gmail.com>
4 years agoDisable slow regression (#4157)
Andrew Reynolds [Thu, 26 Mar 2020 19:42:49 +0000 (14:42 -0500)]
Disable slow regression (#4157)

Should fix timeout in asan build.

4 years agoAdd stats for string reductions, lemmas and conflicts (#4149)
Andrew Reynolds [Thu, 26 Mar 2020 14:52:28 +0000 (09:52 -0500)]
Add stats for string reductions, lemmas and conflicts (#4149)

This PR adds comprehensive stats for reductions, lemmas and conflicts in TheoryStrings. Remaining stats will track all inferences (which are finer grained steps that may lead to lemmas/conflicts).

Additionally this PR refactors calls to OutputChannel::lemma in TheoryStrings / InferenceManager. There are now only 2 calls to lemma(...) during registerTerm(...), one for "atomic" string terms (corresponding to length splits typically) and one for non-atomic terms.

4 years agoGeneralize more string-specific functions (#4152)
Andrew Reynolds [Thu, 26 Mar 2020 13:37:13 +0000 (08:37 -0500)]
Generalize more string-specific functions (#4152)

Towards theory of sequences.

Note this PR also changes design in core/base solver. Previously I had estimated that we should have separate instances per type for these solvers, but I think it is better to have these classes handle all string-like types simultaneously. This means they should not have a d_type field.

4 years agoCare graphs based on polymorphic operators in strings (#4150)
Andrew Reynolds [Thu, 26 Mar 2020 06:38:08 +0000 (01:38 -0500)]
Care graphs based on polymorphic operators in strings (#4150)

Towards theory of sequences.

To compute a care graphs, we need to group function applications by the string type they are associated with. This PR introduces a utility to function to get the "owning string type" for a function application, and updates the care graph computation so that it partitions function applications according to this type.

4 years agoSupport async-signal-safe printing of inferences (#4148)
Andres Noetzli [Wed, 25 Mar 2020 19:22:25 +0000 (12:22 -0700)]
Support async-signal-safe printing of inferences (#4148)

Commit c9b7c3d introduced code for
counting the number of string inferences done per type of inference.
However, it did not add support for printing the inference names in an
async-signal-safe manner via safe_print() (note that printing in
signal handlers is done differently from the regular stats printing).
This commit adds the corresponding code, s.t. we get the inference names
when printing the stats when CVC4 is interrupted or crashes.

4 years agobv2int : linear mult opt (#4142)
Ahmed Irfan [Wed, 25 Mar 2020 16:37:57 +0000 (09:37 -0700)]
bv2int : linear mult opt (#4142)

4 years ago Generalize more uses of string-specific functions (#4145)
Andrew Reynolds [Wed, 25 Mar 2020 13:48:14 +0000 (08:48 -0500)]
 Generalize more uses of string-specific functions (#4145)

Towards theory of sequences.

4 years agoInt2BV fail on demand (#4079)
yoni206 [Tue, 24 Mar 2020 17:53:18 +0000 (10:53 -0700)]
Int2BV fail on demand (#4079)

This PR delays error on unsupported symbols as much as possible, by only throwing the error when actually constructing the node.