cvc5.git
3 years agoAllow to pass ProofGenerator to arithmetic inference manager. (#5488)
Gereon Kremer [Fri, 20 Nov 2020 13:08:45 +0000 (14:08 +0100)]
Allow to pass ProofGenerator to arithmetic inference manager. (#5488)

This PR prepares the addition of proofs for the arithmetic theory by making addPendingArithLemma() accept a ProofGenerator*.

3 years agoEnable new implementation of CEGQI based on nested quantifier elimination (#5477)
Andrew Reynolds [Thu, 19 Nov 2020 22:53:48 +0000 (16:53 -0600)]
Enable new implementation of CEGQI based on nested quantifier elimination (#5477)

This replaces the old implementation of CEGQI based on nested quantifier elimination (--cegqi-nested-qe) with the new implementation.

The previous implementation used some convoluted internal attributes to manage dependencies between quantified formulas, the new implementation is much simpler: it simply eliminates nested quantification eagerly.

Fixes #5365, fixes #5279, fixes #4849, fixes #4433.

This PR also required fixes related to how quantifier elimination is computed.

3 years agofloatingpoint.h: Split in preparation to cleanly separate symFPU glue code. (#5478)
Aina Niemetz [Thu, 19 Nov 2020 22:05:31 +0000 (14:05 -0800)]
floatingpoint.h: Split in preparation to cleanly separate symFPU glue code. (#5478)

3 years agoUse new let binding utility in smt2 printer (#5472)
Andrew Reynolds [Thu, 19 Nov 2020 21:06:41 +0000 (15:06 -0600)]
Use new let binding utility in smt2 printer (#5472)

Also fixes some whitespace issues in printing quantified formulas.

3 years agoInclude stddef.h (needed for size_t) in cvc4_public.h (#5476)
Aina Niemetz [Thu, 19 Nov 2020 19:30:52 +0000 (11:30 -0800)]
Include stddef.h (needed for size_t) in cvc4_public.h (#5476)

This further removes obsolete explicit includes of stdint.h.

3 years agoAdd nested quantifier elimination module (#5422)
Andrew Reynolds [Thu, 19 Nov 2020 18:27:40 +0000 (12:27 -0600)]
Add nested quantifier elimination module (#5422)

This has static utilities for doing nested quantifier elimination and some data structures for maintaining a context-dependent set of quantified formulas that have been processed.

This is work towards CVC4/cvc4-wishues#26, and work reimplementation of the option --ceqgi-nested-qe.

3 years agoFix issues related to eliminating extended arithmetic operators (#5475)
Andrew Reynolds [Thu, 19 Nov 2020 17:44:35 +0000 (11:44 -0600)]
Fix issues related to eliminating extended arithmetic operators (#5475)

This fixes 2 issues related to eliminating arithmetic operators:
(1) counterexample lemmas in CEGQI were not being preprocessed
(2) ensureLiteral was not doing term formula removal.
This corrects these two issues. Now ensureLiteral does full theory preprocessing on the term we are ensuring literal for, meaning this may trigger lemmas if the term contains extended arithmetic operators like div.

Fixes #5469, fixes #5470, fixes #5471.

This adds --sygus-inst to 2 of these benchmarks which moreover makes them solvable.

This also improves our assertions and trace messages.

3 years agoUse symbol manager for unsat cores (#5468)
Andrew Reynolds [Thu, 19 Nov 2020 12:42:04 +0000 (06:42 -0600)]
Use symbol manager for unsat cores (#5468)

This PR uses the symbol manager for handling names for unsat cores.

This replaces interfaces in SmtEngine for managing expression names. It removes the SetExpressionName command.

3 years agoAdd -> operator overload for cd* iterators. (#5464)
Mathias Preiner [Wed, 18 Nov 2020 22:45:52 +0000 (14:45 -0800)]
Add -> operator overload for cd* iterators. (#5464)

3 years agoDisable slow nl regression (#5467)
Andrew Reynolds [Wed, 18 Nov 2020 21:45:16 +0000 (15:45 -0600)]
Disable slow nl regression (#5467)

3 years agoAdd let binding utility (#5444)
Andrew Reynolds [Wed, 18 Nov 2020 20:30:07 +0000 (14:30 -0600)]
Add let binding utility (#5444)

This utility will replace the dagification visitor for printing lets for Node in the smt2 printer, and will be used further in e.g. LFSC proof printing.

3 years agoMinor cleanup of SmtEngine (#5450)
Andrew Reynolds [Wed, 18 Nov 2020 16:20:18 +0000 (10:20 -0600)]
Minor cleanup of SmtEngine (#5450)

3 years agoDo not expand definitions of extended arithmetic operators (#5433)
Andrew Reynolds [Wed, 18 Nov 2020 15:07:08 +0000 (09:07 -0600)]
Do not expand definitions of extended arithmetic operators (#5433)

This PR makes it so that extended arithmetic operators are not expanded during expand definitions. Instead they are eliminated at theory preprocessing, which occurs as the last step of preprocessing.

The motivation for this is three fold:
(1) Some quantified LIA benchmarks lead to CVC4 failing to eliminate div functions from quantifier instantiation, this leads to spurious logic failures. A regression is included, which now is correctly solved.
(2) We should allow better rewriting and preprocessing for extended arithmetic functions, especially for div/mod which is important for many users of QF_NIA.
(3) More generally,Theory::expandDefinitions will be deleted. All functionalities in expandDefinitions should move to Theory::ppRewrite.

This changes impacts many benchmarks that involve non-linear and quantifiers:

Many benchmarks (as expected) give a warning during check-models since (/ n 0) cannot be evaluated. I've added -q to disable these warnings. Fully addressing this is part of an agenda to improve our support for --check-models.
Several fuzzing benchmarks involving NL+quantifiers now time out. However, several can be solved by --sygus-inst, which is now the preferred instantiation strategy for NL+quantifiers.
2 other non-linear regressions time out, which are disabled in this PR.
one sygus-inference benchmark (regress1/sygus/issue3498.smt2), now correctly times out (previously it did not timeout since the preprocessor was unable to apply sygus-inference and resorted to normal methods, now sygus-inference can apply but as expected times out).
Fixes #5237.

3 years agoUse symbol manager for get assignment (#5451)
Andrew Reynolds [Wed, 18 Nov 2020 14:34:12 +0000 (08:34 -0600)]
Use symbol manager for get assignment (#5451)

This replaces the previous methods for get-assignment which involving making a DefinedNamedFunctIonCommand and storing the expression names map in the SmtEngine.

Note: we now limit :named terms to those not beneath quantifiers and let-bindings.

3 years agoFix asan issues related to solver and symbol manager (#5457)
Andrew Reynolds [Wed, 18 Nov 2020 14:05:31 +0000 (08:05 -0600)]
Fix asan issues related to solver and symbol manager (#5457)

Should fix the nightlies.

3 years agoFloatingPoint: Use uint32_t instead of unsigned. (#5459)
Aina Niemetz [Wed, 18 Nov 2020 01:54:19 +0000 (17:54 -0800)]
FloatingPoint: Use uint32_t instead of unsigned. (#5459)

3 years agoFloatingPoint: Clean up and document header, format. (#5453)
Aina Niemetz [Wed, 18 Nov 2020 00:45:39 +0000 (16:45 -0800)]
FloatingPoint: Clean up and document header, format. (#5453)

This cleans up the src/util/floatingpoint.h.in header to conform to the
code style guidelines of CVC4. This further attempts to fully document
the header. The main changes (except for added documentation) are
renames of member variables, getting rid of the redundant functions
FloatingPointSize::exponent() and FloatingPointSize::significand(),
and a more explicit naming of CVC4 wrapper types vs symFPU trait
types. Else, it's mainly reordering and formatting.

3 years agoci: Simplify Python dependency installs for Linux and macOS. (#5458)
Mathias Preiner [Wed, 18 Nov 2020 00:01:55 +0000 (16:01 -0800)]
ci: Simplify Python dependency installs for Linux and macOS. (#5458)

3 years agoFix tangent plane lemmas (#5455)
Gereon Kremer [Tue, 17 Nov 2020 13:43:15 +0000 (14:43 +0100)]
Fix tangent plane lemmas (#5455)

The previous refactoring of tangent plane lemmas introduced incorrect lemmas.
This PR fixes this issue and actually generated the lemmas described in the comment.
Fixes #5452.

3 years agoRefactor tangent plane lemmas (#5449)
Gereon Kremer [Mon, 16 Nov 2020 17:51:58 +0000 (18:51 +0100)]
Refactor tangent plane lemmas (#5449)

The original lemma only proposed an implication for the tangent plane lemmas, while our implementation adds the inverse implication as well (in a somewhat verbose way).
This PR replaces this by simply constructing the equivalence.

3 years agoCleaning up scopes in preparation for symbol manager (#5442)
Andrew Reynolds [Mon, 16 Nov 2020 16:40:30 +0000 (10:40 -0600)]
Cleaning up scopes in preparation for symbol manager (#5442)

This changes the default of Parser::pushScope and prepares symbol manager further for maintaining expression names.

3 years agoImprove accuracy of resource limitation (#4763)
Gereon Kremer [Mon, 16 Nov 2020 10:15:19 +0000 (11:15 +0100)]
Improve accuracy of resource limitation (#4763)

The main goal of the resource limitation mechanism (via `--rlimit`) is to have a deterministic limitation on runtime. The ultimate goal would be that the actual runtime grows linearly with the spent resources.
To achieve this, this PR does the following:
- introduce new resources spent in places that are not yet covered
- find resource weights that best approximate the runtime

It provides a contrib script `learn_resource_weights.py` that uses statistics from a given benchmark run and uses linear regression to find good resource weights. The script also evaluates this estimate and identifies outliers, benchmarks for which this approximation is particularly bad. This probably indicates that on such a benchmark, some part of the code takes a significant amount of time but is not yet represented by a resource.

Eventually, we should use the resulting resource weights as defaults for the options like `--rewrite-step`, `--theory-check-step`, etc.

3 years agoFix double conflict in extended string solver (#5435)
Andrew Reynolds [Sat, 14 Nov 2020 14:57:39 +0000 (08:57 -0600)]
Fix double conflict in extended string solver (#5435)

Fixes #5384.

Previously we were not breaking on conflict in all cases.

3 years ago(proof-new) Proofs for non-clausal simplification (#5409)
Andrew Reynolds [Sat, 14 Nov 2020 14:17:15 +0000 (08:17 -0600)]
(proof-new) Proofs for non-clausal simplification (#5409)

Adds proof support in non-clausal simplification, connecting the proofs from circuit propagator.

3 years ago(proof-new) Enable proofs for datatypes (#5436)
Andrew Reynolds [Fri, 13 Nov 2020 21:12:35 +0000 (15:12 -0600)]
(proof-new) Enable proofs for datatypes (#5436)

This enables initial proof support in datatypes, which includes connecting the inference-to-proof constructor to the inference manager and making the proper calls to the inference manager using TheoryDatatypes.

3 years agoModel declarations printing options (#5432)
yoni206 [Fri, 13 Nov 2020 19:23:49 +0000 (11:23 -0800)]
Model declarations printing options (#5432)

This PR relates to #4987 .
Our plan is to:

delete the model keyword
avoid printing extra declarations by default
wrap UF values with as expressions.
This PR is step 2. It allows the user to choose the model printing style in case of uninterpreted elements: either using datatypes, or using declare-sorts and declare-funs or just using declare-funs.

The default option, which is closest to the standard, is just using declare-funs. In step 3, these will be replaced by abstract values using as.

3 years agoAdd more features to symbol manager (#5434)
Andrew Reynolds [Fri, 13 Nov 2020 15:49:36 +0000 (09:49 -0600)]
Add more features to symbol manager (#5434)

This is in preparation for having the symbol manager manage expression names at the parser level instead of inside SmtEngine.

This adds some necessary features regarding scopes and global declarations.

This PR still does not change the behavior of the parser.

3 years agoMake regular expression difference left associative (#5430)
Andrew Reynolds [Fri, 13 Nov 2020 02:02:20 +0000 (20:02 -0600)]
Make regular expression difference left associative (#5430)

Fixes #5428.

3 years agoSimplify sygus solver and sygus stream (#5389)
Andrew Reynolds [Thu, 12 Nov 2020 23:34:22 +0000 (17:34 -0600)]
Simplify sygus solver and sygus stream (#5389)

This simplifies the sygus solver based on the fact that verification lemmas are always processed in a separate subsolver.

In particular, this means that the implementation of --sygus-stream can be simplified signficantly.

3 years agoFix printing of define named function (#5425)
Andrew Reynolds [Thu, 12 Nov 2020 23:03:30 +0000 (17:03 -0600)]
Fix printing of define named function (#5425)

Fixes the case where the type of the function is not a function type.

3 years agoModels standard (#5415)
yoni206 [Thu, 12 Nov 2020 22:00:14 +0000 (14:00 -0800)]
Models standard (#5415)

This PR relates to #4987 .
Our plan is to:

delete the model keyword
avoid printing extra declarations by default
wrap UF values with as expressions.
This PR does step 1, and fixes regressions accordingly.

3 years ago(proof-new) Separate explanation stages in proof equality engine (#5356)
Andrew Reynolds [Thu, 12 Nov 2020 18:15:54 +0000 (12:15 -0600)]
(proof-new) Separate explanation stages in proof equality engine (#5356)

This fixes potential cycles in assertLemma commands in the proof equality engine by using separate proof data structures for the topmost 2 stages of proof generation for equality engine proofs. This fix is required to support datatype proofs for lemmas.

This PR also removes support for the ProofStepBuffer interface in ProofEqEngine, since it is unused, and suffers similar issues and would require a different unique fix.

3 years agoFix redundant refinement lemma in sygus solver (#5399)
Andrew Reynolds [Thu, 12 Nov 2020 16:56:25 +0000 (10:56 -0600)]
Fix redundant refinement lemma in sygus solver (#5399)

This ensures we do manual exclusion of candidate solutions that have counterexamples that are repeated, in particular in the case where the synthesis conjecture has no free variables.

This PR removes special casing for ground synthesis conjectures and fixes the exclusion during the refinement stage of sygus.

This is a prerequisite for updating arithmetic to not eliminate extended operators at expand definitions, which forces this feature to be exercised in a number of regressions.

3 years ago(proof-new) Proofs for skolemization (#5339)
Andrew Reynolds [Thu, 12 Nov 2020 16:33:32 +0000 (10:33 -0600)]
(proof-new) Proofs for skolemization (#5339)

This adds support for proofs in the quantifiers module that performs skolemization.

Also fixes a bug in the proof checker for skolemization.

3 years ago(proof-new) Fix true explanations of propagations in pf equality engine (#5338)
Andrew Reynolds [Thu, 12 Nov 2020 16:00:36 +0000 (10:00 -0600)]
(proof-new) Fix true explanations of propagations in pf equality engine (#5338)

This ensures we construct proper proofs for propagations whose conclusions are of the form (=> true lit). Literals may be propagated with "true" as an explanation in datatypes, e.g. discriminators for datatypes with 1 constructor.

3 years ago(proof-new) Improve printing and debugging for pedantic checking (#5337)
Andrew Reynolds [Thu, 12 Nov 2020 15:08:13 +0000 (09:08 -0600)]
(proof-new) Improve printing and debugging for pedantic checking  (#5337)

This improves trace/error messages for proof-new-pedantic, and also merges the proof-new-pedantic-eager with the proof-new-eager-checking option.

3 years ago(proof-new) Add datatypes inference to proof constructor (#5408)
Andrew Reynolds [Thu, 12 Nov 2020 14:36:28 +0000 (08:36 -0600)]
(proof-new) Add datatypes inference to proof constructor (#5408)

This adds the module that constructs proofs from inference steps.

A followup PR will integrate proof support into the datatypes inference manager.

3 years agoMake symbol manager context dependent (#5424)
Andrew Reynolds [Thu, 12 Nov 2020 13:21:09 +0000 (07:21 -0600)]
Make symbol manager context dependent (#5424)

This follows a similar style to symbol_table.h/cpp. This is required since context dependent data structures are cvc4_private, and symbol manager is cvc4_public.

3 years agoMove symbol manager to src/expr/ (#5420)
Andrew Reynolds [Wed, 11 Nov 2020 18:56:03 +0000 (12:56 -0600)]
Move symbol manager to src/expr/ (#5420)

This is required since symbol manager will use context dependent data structures (in its cpp).

This is required since classes in src/parser/ are not allowed to include private headers.

3 years agoRewrite witness terms at prerewrite (#5419)
Andrew Reynolds [Wed, 11 Nov 2020 18:39:38 +0000 (12:39 -0600)]
Rewrite witness terms at prerewrite (#5419)

Ensures (witness ((x Int)) (= x (+ 1 a)) is rewritten to (+ 1 a), instead of e.g. (witness ((x Int)) (= a (- x 1)).

This is required for supporting purification skolems for arithmetic terms in the new proof architecture.

3 years agoAdd simple substitution utility (#5397)
Andrew Reynolds [Wed, 11 Nov 2020 18:15:44 +0000 (12:15 -0600)]
Add simple substitution utility (#5397)

A few new algorithms for CEGQI and single invocation sygus will use this utility for managing transformations.

3 years agoPass symbol manager to commands (#5410)
Andrew Reynolds [Wed, 11 Nov 2020 13:44:25 +0000 (07:44 -0600)]
Pass symbol manager to commands (#5410)

This PR passes the symbol manager to Command::invoke.

There are no behavior changes in this PR. This is in preparation for reimplementing several features in the parser related to symbols.

3 years agoFix preregistration in TheorySep before declare-heap (#5411)
Andrew Reynolds [Wed, 11 Nov 2020 02:27:38 +0000 (20:27 -0600)]
Fix preregistration in TheorySep before declare-heap (#5411)

Followup to fix for #5343. This catches cases where separation logic constraints are preregistered to TheorySep before the heap has been declared, which should also result in an error.

3 years agoDo not mark extended functions as reduced based on decomposing contains (#5407)
Andrew Reynolds [Tue, 10 Nov 2020 21:48:05 +0000 (15:48 -0600)]
Do not mark extended functions as reduced based on decomposing contains (#5407)

Fixes #5381.

3 years agoPin LFSC version (#5412)
Alex Ozdemir [Tue, 10 Nov 2020 21:00:06 +0000 (13:00 -0800)]
Pin LFSC version (#5412)

I chose commit 61ef1dc55d2bc909656f905699b28c99ddcfc518,
which is missing:

any changes to the OSX build process
(We're still figuring this out)
change to top-level identifier shadowing
(we have a few versions of the signatures floating around, and I
worry that they may not all be fixed w.r.t. no re-using identifiers)

3 years agoMake mkGroundTerm deterministic (#5347)
Andrew Reynolds [Tue, 10 Nov 2020 20:09:10 +0000 (14:09 -0600)]
Make mkGroundTerm deterministic (#5347)

This ensures mkGroundTerm is deterministic using attributes.

This was uncovered by failures in the proof checker for datatypes.

3 years agoAdd getSubtermKinds to node algorithm (#5398)
Andrew Reynolds [Tue, 10 Nov 2020 19:33:41 +0000 (13:33 -0600)]
Add getSubtermKinds to node algorithm (#5398)

Required for a new algorithm for nested quantifier elimination.

3 years agoAdd proper support for the declare-heap command for separation logic (#5405)
Andrew Reynolds [Tue, 10 Nov 2020 13:43:19 +0000 (07:43 -0600)]
Add proper support for the declare-heap command for separation logic (#5405)

This adds proper support for the (declare-heap (T U)) command, which declares the type of the heap in separation logic. This command is part of the standard for separation logic.

This previous was handled in an ad-hoc way where the type of the heap would be inferred on demand. This was a poor solution and has led to a number of issues related to when the heap is inferred.

Fixes #5343, fixes #4926.

Work towards CVC4/cvc4-wishues#22.

3 years agoMigrate some documentation about attributes (#5390)
Andrew Reynolds [Tue, 10 Nov 2020 02:09:02 +0000 (20:09 -0600)]
Migrate some documentation about attributes (#5390)

From old wiki.

3 years agoAdd symbol manager (#5380)
Andrew Reynolds [Mon, 9 Nov 2020 22:51:04 +0000 (16:51 -0600)]
Add symbol manager (#5380)

This add the symbol manager class, which is a Term-level utility, separate of the API. This class manages things like expression and assertion names, which is intentionally done outside the solver.

The symbol manager is intended to live at the same level as the Solver. When parsing input, the symbol manager will be used to model any interaction of e.g. named expressions and assertions. It also stores the symbol table of the parser.

This PR adds the basic interface for the symbol manager and passes it to the parser.

Later PRs will migrate the functionality for named expression out of e.g. SmtEngine and into SymbolManager. Commands will take Solver+SymbolManager instead of Solver. This will allow the parser to be fully migrated to the new API.

Marking "complex" since this impacts further design of the parser and the code that lives in src/main.

FYI @4tXJ7f

3 years agoSimplify handling of subtypes in smt2 printer (#5401)
Andrew Reynolds [Mon, 9 Nov 2020 20:38:54 +0000 (14:38 -0600)]
Simplify handling of subtypes in smt2 printer (#5401)

This makes major simplifications to how subtypes are enforced in the smt2 printer.

It is now the principle that the smt2 prints things faithfully to the AST, regardless of whether it conforms to the smt2 standard.

It also fixes the current smt2 printing of to_real.

Conversely, this removes a hack from GetValueCommand which forced casting via x -> (/ x 1). This is now properly handled in Solver::getValue.

Some regressions change expected output as a result. Notice that internally generated Node may not conform to the smt2 standard, but user-level terms will.

3 years agoProperly clear interrupt for solve() as well. (#5403)
Gereon Kremer [Mon, 9 Nov 2020 16:46:23 +0000 (17:46 +0100)]
Properly clear interrupt for solve() as well. (#5403)

The minisat solver stores whether it has been interrupted in asynch_interrupt and expects it to be reset before another call to solve(). MinisatSatSolver::solve() failed to do this, leading to incorrect unknown results as observed in CVC4/cvc4-projects#106. The alternative MinisatSatSolver::solve(unsigned long& resource) already did the correct thing.
Fixes CVC4/cvc4-projects#106.

3 years agoDo not regress explanations of datatype lemmas (#5376)
Andrew Reynolds [Mon, 9 Nov 2020 13:42:03 +0000 (07:42 -0600)]
Do not regress explanations of datatype lemmas (#5376)

This modifies datatypes to not regress explanations for lemmas. This avoids segfaults in some corner cases of sygus (see attached) and leads to slightly better performance on Facebook verification benchmarks.

3 years agoFix issue #5342 (#5349)
mudathirmahgoub [Fri, 6 Nov 2020 21:28:38 +0000 (15:28 -0600)]
Fix issue #5342 (#5349)

This PR fixes issue #5342 by adding the rewrite rule (setminus A (setminus A B)) = (intersection A B).

3 years ago(proof-new) Miscellaneous changes to strings for proofs (#5362)
Andrew Reynolds [Fri, 6 Nov 2020 19:47:22 +0000 (13:47 -0600)]
(proof-new) Miscellaneous changes to strings for proofs (#5362)

This includes all minor remaining changes from proof-new for strings that were not merged to master.

This includes mostly minor changes to make proofs pass, including reordering assertions. It also removes some non-standard pedantic checks as these are now subsumed by standard ones.

It also makes the strings rewriter slightly more safe when checking arithmetic entailment under assumptions. This code used substitution, which was not safe when quantifiers were involved. This is replaced by capture avoiding substitution here.

3 years agoSplit sygus template inference to its own file (#5388)
Andrew Reynolds [Fri, 6 Nov 2020 05:06:13 +0000 (23:06 -0600)]
Split sygus template inference to its own file (#5388)

This splits techniques for inferring templates for functions-to-synthesize to their own file.

This is work towards cleaning up the single invocation utility, which will be undergoing some additions.

3 years agoSimplify printing with respect to expression types (#5394)
Andrew Reynolds [Fri, 6 Nov 2020 04:28:18 +0000 (22:28 -0600)]
Simplify printing with respect to expression types (#5394)

This removes infrastructure for stream property related to printing type annotations on all variables.

This is towards refactoring the printers.

3 years agoRemove mkSingleton from the API (#5366)
mudathirmahgoub [Thu, 5 Nov 2020 23:13:44 +0000 (17:13 -0600)]
Remove mkSingleton from the API (#5366)

This PR removes mkSingleton from the API after removing subtyping from set theory and introducing mkInteger to the API.
Instead the user needs to use Solver::mkTerm(api::SINGLETON, element) where element has the right type.
Internally NodeManager::mkSingleton(type, element) is still needed to determine the type of the set.
Other changes:

Renamed Solver::mkTerm(Op op, .. functions to Solver::mkTermFromOp(Op op, ...
Added mkTermFromOp to the python API

3 years agoAdd constants from equality engine evaluation to model (#5391)
Andres Noetzli [Wed, 4 Nov 2020 00:30:12 +0000 (16:30 -0800)]
Add constants from equality engine evaluation to model (#5391)

Fixes #5330. The issue mentions to related model checking failures:

When the theory of strings computes a model, there is a step that
chooses a constant that is different from other constants of the same
length in other equivalence classes. In the example, the issue was
that the constant "A" was introduced by doing evaluation in the
equality engine of the theory of strings. The constant was then not
added to the term set and was skipped while asserting the equality
engine to the theory model. As a result, an equivalence class was
assigned "A" even though it already existed, which made the model
invalid. The fix ensures that all constants in the equality engine are
added to the theory model. It should be ok to handle the issue during
model construction because other theories shouldn't have to care about
the constants that we computed internally within the theory of
strings.
When an equivalence class has a normal form that consists of a single
seq.unit, then we need to make sure that the value for the argument
is consistent with the rest of the model and we have to make sure that
we choose different values for different equivalence classes. The
commit adds code for retrieving the value of the argument to
seq.unit from the model and adds the resulting constant to the
theory model to block it for other equivalence classes. Previously,
this was not done and we ended up with two different equivalence
classes being assigned the same constant.

3 years agoAdd scope methods constructing types in API (#5393)
Andrew Reynolds [Tue, 3 Nov 2020 23:47:15 +0000 (17:47 -0600)]
Add scope methods constructing types in API (#5393)

This addresses the nightly failures. It ensures a node manager is in scope when constructing type nodes.

It also simplifies the construction of atomic type nodes to avoid an extra TypeNode(...) constructor.

3 years agoAdd support for printing `re.loop` and `re.^` (#5392)
Andres Noetzli [Tue, 3 Nov 2020 19:55:52 +0000 (11:55 -0800)]
Add support for printing `re.loop` and `re.^` (#5392)

In the new SMT-LIB string standard, re.loop and re.^ are indexed
operators but the printer was not updated to print them correctly. This
commit adds support for printing re.loop and re.^.

3 years agoReset built model flag at presolve in nonlinear (#5386)
Andrew Reynolds [Tue, 3 Nov 2020 18:17:32 +0000 (12:17 -0600)]
Reset built model flag at presolve in nonlinear (#5386)

Fixes a bug in incremental with non-linear where the built model flag would still be true on the first call to check in a 2nd call to check-sat in incremental mode. This occurs when we are under the same SAT context when the model was built (likely level 0) on the subsequent check-sat call.

Fixes #5372

3 years agoMove sygus qe preproc to its own file (#5375)
Andrew Reynolds [Tue, 3 Nov 2020 01:56:32 +0000 (19:56 -0600)]
Move sygus qe preproc to its own file (#5375)

3 years agoRun python tests during make check (#5226)
makaimann [Tue, 3 Nov 2020 00:17:21 +0000 (16:17 -0800)]
Run python tests during make check (#5226)

If building with python bindings, check the pytest is installed, and adds a command to run pytest after the existing make check tests. If built without python bindings, it just uses a null command. Note: the current semantics are such that the pytest tests will not run if the ctest run fails (unless you pass the correct flag to make to continue --ignore-errors I believe). I can look into changing this semantics if that would be preferred.

3 years agocontrib: Remove dependency directories. (#5367)
Aina Niemetz [Mon, 2 Nov 2020 22:10:34 +0000 (14:10 -0800)]
contrib: Remove dependency directories. (#5367)

This automatically removes dependency directories for scripts that get
external dependencies instead of aborting with an error.

3 years agoUpdate strings proxy variable map to be context independent (#5377)
Andrew Reynolds [Mon, 2 Nov 2020 19:46:05 +0000 (13:46 -0600)]
Update strings proxy variable map to be context independent (#5377)

This makes strings proxy variables map to be context-independent. They should be context independent since we are using attributes to mark proxy variables, which are context-independent. This led to the crash reported on #5374 since proxy variables would persist across multiple user contexts, but would be missing in the user-context dependent map.

This fixes #5374.

3 years agoMiscellaneous cleaning of parser (#5369)
Andrew Reynolds [Mon, 2 Nov 2020 14:26:13 +0000 (08:26 -0600)]
Miscellaneous cleaning of parser (#5369)

3 years agoAvoid dynamic allocation in symbol table implementation (#5368)
Andrew Reynolds [Mon, 2 Nov 2020 13:01:19 +0000 (07:01 -0600)]
Avoid dynamic allocation in symbol table implementation (#5368)

Encountered this while debugging the new symbol manager. This is not essential but probably a good idea to refactor.

3 years agoUse BoundInference in nonlinear extension (#5359)
Gereon Kremer [Fri, 30 Oct 2020 08:07:53 +0000 (09:07 +0100)]
Use BoundInference in nonlinear extension (#5359)

Currently the NonlinearExtensions uses a custom logic to eliminate redundant bounds and perform tightening on bound integer terms. As these replacements are not recorded, incorrect conflicts are being sent to the InferenceManager.
This PR replaces this logic by the BoundInference class and fixes the issues with conflicts by
- allowing BoundInference to collect bounds on arbitrary left hand sides (instead of only variables),
- improving origin tracking in BoundInference by explicitly constructing the new bound constraints,
- adding tightening of integer bounds,
- emitting lemmas instead of conflicts, and finally
- replacing the current logic by using the BoundInference class.

3 years agoUpdate api::Sort to use TypeNode instead of Type (#5363)
Andrew Reynolds [Fri, 30 Oct 2020 02:51:18 +0000 (21:51 -0500)]
Update api::Sort to use TypeNode instead of Type (#5363)

This is work towards removing the old API.

This makes TypeNode the backend for Sort instead of Type.

It also updates a unit test for methods isUninterpretedSortParameterized and getUninterpretedSortParamSorts whose implementation was previously buggy due to the implementation of Type-level SortType.

3 years agoSet strings pending conflict flag (#5364)
Andrew Reynolds [Thu, 29 Oct 2020 22:17:48 +0000 (17:17 -0500)]
Set strings pending conflict flag (#5364)

While addressing the review on 6898ab9, strings eager conflicts were accidentally disabled, this reenables them.

3 years agoAdd mkInteger to the API (#5274)
mudathirmahgoub [Thu, 29 Oct 2020 18:26:51 +0000 (13:26 -0500)]
Add mkInteger to the API (#5274)

This PR adds mkInteger to the API and update mkReal to ensure that the returned term has real sort.
The parsers are modified to parse numbers like "0" "5" as integers and "0.0" and "15.0" as reals.
This means subtyping is effectively eliminated from all theories except arithmetic.
Other changes:

Term::isValue is removed which was introduced to support parsing for constant arrays. It is no longer needed after this PR.
Benchmarks are updated to match the changes in the parsers
Co-authored-by: Andrew Reynolds andrew-reynolds@uiowa.edu
3 years ago(proof-new) Update the strings inference manager for proofs (#5220)
Andrew Reynolds [Thu, 29 Oct 2020 15:00:08 +0000 (10:00 -0500)]
(proof-new) Update the strings inference manager for proofs (#5220)

This updates the inference manager in strings in two ways:
(1) It now inherits from InferenceManagerBuffered, meaning that the custom methods for process the current pending lemma/fact vectors are removed in favor of the standard ones.
(2) It has support for proof generation via the InferProofCons utility.

This PR standardizes three methods processFact, processLemma, and processConflict which take InferInfo and processes any string-specific behavior pertaining to processing facts, lemmas and conflicts with the inference manager. These methods are intended to preserve the previous behavior of this class.

3 years agoAdd NodeManager::mkOr() (#5360)
Gereon Kremer [Thu, 29 Oct 2020 14:25:42 +0000 (15:25 +0100)]
Add NodeManager::mkOr() (#5360)

This PR adds a convenience method mkOr() just like mkAnd().

3 years agorun_regression.py to fail on invalid requirements (#5264)
yoni206 [Wed, 28 Oct 2020 21:52:18 +0000 (14:52 -0700)]
run_regression.py to fail on invalid requirements (#5264)

Currently, the following test is skipped when running ctest:

 ; REQUIRES: symfpuuuu
 ; EXPECT: sat
 (set-logic ALL)
 (assert true)
 (check-sat)
I think it is better for such a test to fail, because otherwise it might never run without anyone noticing (this almost happened to me here: c7e277b).

This PR makes such tests to fail by checking whether the REQUIRES value is valid. No regressions fail as a result.

Co-authored-by: Mathias Preiner mathias.preiner@gmail.com
3 years agoRemove more uses of Expr (#5357)
Andrew Reynolds [Wed, 28 Oct 2020 21:21:53 +0000 (16:21 -0500)]
Remove more uses of Expr (#5357)

This PR removes more uses of Expr, mostly related to UnsatCore.

It makes UnsatCore a cvc4_private object storing Node instead of Expr.

3 years agoFixes for unconstrained variables in nonlinear model (#5351)
Andrew Reynolds [Wed, 28 Oct 2020 20:17:05 +0000 (15:17 -0500)]
Fixes for unconstrained variables in nonlinear model (#5351)

This ensures that we explicitly mark x -> 0 as part of the arithmetic model coming from nonlinear for unconstrained variables x that nonlinear extension assumes to be 0.

This fixes #5348.

3 years agoConvert symbol table from Expr-level to Term-level (#5355)
Andrew Reynolds [Wed, 28 Oct 2020 19:51:41 +0000 (14:51 -0500)]
Convert symbol table from Expr-level to Term-level (#5355)

This task is left over from parser migration.

This PR also drops support for a case of symbol overloading, in particular symbols (constructors, selectors) for parametric datatypes cannot be overloaded. One regression is disabled as a result.

3 years agoSplit NlSolver in multiple subsolvers (#5315)
Gereon Kremer [Wed, 28 Oct 2020 18:35:35 +0000 (19:35 +0100)]
Split NlSolver in multiple subsolvers (#5315)

The NlSolver started as one place for nonlinear reasoning, but has grown significantly since. This PR splits the NlSolver class into multiple smaller classes.

3 years agoAdd rewrites for div/mod in the arithmetic rewriter (#5352)
Andrew Reynolds [Wed, 28 Oct 2020 17:35:43 +0000 (12:35 -0500)]
Add rewrites for div/mod in the arithmetic rewriter (#5352)

This adds some basic rewrites for integer div/mod in the rewriter.

This is in preparation for improved preprocessing and rewriting for NIA problems with heavy use of div/mod.

3 years agorun_regression: Add --skip-timeout option, lower timeout to 600 seconds. (#5353)
Mathias Preiner [Tue, 27 Oct 2020 19:02:38 +0000 (12:02 -0700)]
run_regression: Add --skip-timeout option, lower timeout to 600 seconds.  (#5353)

3 years agoRefactor DeclareSygusVarCommand and SynthFunCommand to use the API. (#5334)
Abdalrhman Mohamed [Tue, 27 Oct 2020 18:19:11 +0000 (13:19 -0500)]
Refactor DeclareSygusVarCommand and SynthFunCommand to use the API. (#5334)

This PR is part of migrating commands. DeclareSygusVarCommand and SynthFunCommand now call public API function instead of their corresponding SmtEngine functions. Those two commands don't fully initialize the solver anymore. Some operations in SygusInterpol::solveInterpolation, which creates an interpolation sub-solver, depend on the solver being fully initialized and were affected by this change. Those operations are now executed by the main solver instead of the sub-solver, which is not fully initialized by the time they are needed.

3 years agoAdd missing methods involving datatype sorts to the API (#5290)
Andrew Reynolds [Tue, 27 Oct 2020 16:46:20 +0000 (11:46 -0500)]
Add missing methods involving datatype sorts to the API (#5290)

This is required for migrating the parser's symbol table from Expr -> Term.

3 years agoDisable --nl-cad option by default (#5350)
Gereon Kremer [Tue, 27 Oct 2020 16:16:06 +0000 (17:16 +0100)]
Disable --nl-cad option by default (#5350)

This PR disables the `--nl-cad` option by default. It was erroneously enabled with #5345 but leads to errors on, e.g., QF_NIA. Enabling for QF_NRA is done in set_defaults.

3 years agoEnable --nl-cad by default (#5345)
Gereon Kremer [Tue, 27 Oct 2020 12:57:55 +0000 (13:57 +0100)]
Enable --nl-cad by default (#5345)

This PR enables `--nl-cad` for QF_NRA (and QF_UFNRA) by default to improve nonlinear arithmetic solving.
Furthermore, it takes care of disabling it when libpoly is not available. It also adds a fix to the CadSolver that avoids incorrect SATs in the presence of theory combination.

3 years agoAdd DUPICATE_REMOVAL operator to bags (#5336)
mudathirmahgoub [Tue, 27 Oct 2020 01:13:23 +0000 (20:13 -0500)]
Add DUPICATE_REMOVAL operator to bags (#5336)

This PR adds duplicate removal operator to bags (also known as delta or squash).
Other changes:

print MK_BAG operator as "bag" in smt2 instead of "mkBag"
renamed BAG_IS_INCLUDED operator to SUBBAG.

3 years ago(proof-new) Add datatypes proof checker (#5340)
Andrew Reynolds [Mon, 26 Oct 2020 17:33:01 +0000 (12:33 -0500)]
(proof-new) Add datatypes proof checker (#5340)

This adds the proof rules and proof checker for datatypes.

3 years agoSend external equalities from collapse selector as lemmas (#5346)
Andrew Reynolds [Mon, 26 Oct 2020 17:18:26 +0000 (12:18 -0500)]
Send external equalities from collapse selector as lemmas (#5346)

In 20e58d4, a policy change was made for datatypes to keep more inferences as internal facts.

This leads to a crash (issue #5344) where the equality status of two BV terms is asked by TheoryDatatypes, where the TheoryBV was not informed of the term, as datatypes kept it internal.

This refines the policy further such that the collapse selector rule is processed as a lemma for terms of external type. The reason is that this rule may generate new terms of external type. Other rules like unification retain the internal fact policy, as they do not generate new terms.

Fixes #5344.

FYI @barrettcw

3 years agoFix issue 5271 (#5335)
mudathirmahgoub [Sat, 24 Oct 2020 14:16:52 +0000 (09:16 -0500)]
Fix issue 5271 (#5335)

This PR fixes #5271 by splitting on the equality of set members which ensures members are distinct when collectModelInfo is called.
Co-authored-by: Andrew Reynolds andrew-reynolds@uiowa.edu
3 years ago[proof-new] Fix n-ary kind handling in EqEngine explanations (#5332)
Haniel Barbosa [Sat, 24 Oct 2020 00:20:42 +0000 (21:20 -0300)]
[proof-new] Fix n-ary kind handling in EqEngine explanations (#5332)

Adding missing cases of kinds that are n-ary but whose partial applications are
not true terms in the equality engine. This in the case not only for APPLY_UF
but also for the APPLY_* kinds for datatypes.

3 years agoApply alpha equivalence to annotated quantified formulas (#5324)
Andrew Reynolds [Fri, 23 Oct 2020 18:37:59 +0000 (13:37 -0500)]
Apply alpha equivalence to annotated quantified formulas (#5324)

Previously, alpha equivalence was not applied to quantified formulas with attributes, likely motivated by keeping alpha equivalent quantified formulas with different user patterns. It's not clear this is a good a idea. Moreover, this also implies that quantified formulas with user-provided names (which happens in e.g. Boogie benchmarks) also do not have alpha equivalence applied.

This makes it so that we apply alpha equivalence regardless of annotations.

FYI @barrettcw

3 years agoChange datatypes lemma policy for equalities not coming from instantiate (#5325)
Andrew Reynolds [Fri, 23 Oct 2020 18:24:05 +0000 (13:24 -0500)]
Change datatypes lemma policy for equalities not coming from instantiate (#5325)

Recently, the policy for lemma vs fact changed for instantiate rule in datatypes to ensure that other theories were notified of terms having external finite type. This PR further refines the policy so that the instantiate rule is the only rule whose conclusion is an equality that is sent out as a lemma.

This means that equalities from unification and collapsing selectors are always kept internal. The justification for this is that the instantiate rule is applied for all terms with the proper policy, and hence it already covers all cases where we may need to introduce new terms.

3 years agoFix related to preregistering boolean term variables in strings (#5331)
Andrew Reynolds [Fri, 23 Oct 2020 18:03:17 +0000 (13:03 -0500)]
Fix related to preregistering boolean term variables in strings (#5331)

We should only add trigger predicates for string predicates, and not arbitrary Boolean terms (which can now occur since we are handling parametric sequences).

This avoids a debug assertion failure reported on as a followup to #4370. In that benchmark BOOLEAN_TERM_VARIABLE was being added as a trigger predicate.

3 years agoUse theoryof-mode=type for QF_NRA (#5326)
Gereon Kremer [Thu, 22 Oct 2020 18:06:51 +0000 (20:06 +0200)]
Use theoryof-mode=type for QF_NRA (#5326)

We've observed that our QF_NRA solving benefits significantly from --theoryof-mode=type across the board (of other options that influence QF_NRA solving). This PR sets type as the new default for QF_NRA solving.

3 years agoRemove unused equality engine types (#5319)
Andrew Reynolds [Thu, 22 Oct 2020 17:24:53 +0000 (12:24 -0500)]
Remove unused equality engine types (#5319)

This is leftover from the old proof infrastructure.

3 years agoFix issue 5309 (#5327)
mudathirmahgoub [Thu, 22 Oct 2020 16:48:25 +0000 (11:48 -0500)]
Fix issue 5309 (#5327)

This PR fixes #5309 by ensuring singleton terms are added to the model builder as representatives.

Co-authored-by: Andrew Reynolds andrew-reynolds@uiowa.edu
3 years ago(proof-new) Make theory preprocessor user-context dependent (#5296)
Andrew Reynolds [Thu, 22 Oct 2020 02:21:42 +0000 (21:21 -0500)]
(proof-new) Make theory preprocessor user-context dependent (#5296)

Previously, theory preprocessing cache was manually cleared whenever the theory preprocess pass was run. However, proofs for theory preprocessing required to be alive for the remainder of the user context. This PR changes theory preprocessing so that both the cache and proofs in theory preprocessing are user-context dependent.

This PR also makes the theory preprocess pass proof producing.

3 years ago(proof-new) Make circuit propagator proof producing (#5318)
Gereon Kremer [Wed, 21 Oct 2020 23:19:24 +0000 (01:19 +0200)]
(proof-new) Make circuit propagator proof producing (#5318)

This PR uses the proofs from #5301 to actually produce proofs from the circuit propagator.

3 years agoImplement bags evaluator (#5322)
mudathirmahgoub [Wed, 21 Oct 2020 22:33:57 +0000 (17:33 -0500)]
Implement bags evaluator (#5322)

This PR implements NormalForm::evaluate for bags

3 years ago(proof-new) Add arith proof macros file to CMake (#5321)
Alex Ozdemir [Wed, 21 Oct 2020 18:53:20 +0000 (11:53 -0700)]
(proof-new) Add arith proof macros file to CMake (#5321)