cvc5.git
5 years agoAdd option to print BV constants in binary (#2805)
Andres Noetzli [Thu, 17 Jan 2019 00:38:38 +0000 (16:38 -0800)]
Add option to print BV constants in binary (#2805)

This commit adds the option `--bv-print-consts-in-binary` to print
bit-vector constants in binary, e.g. `#b0001`, instead of decimal, e.g.
`(_ bv1 4)`). The option is on by default to match the behavior of Z3
and Boolector.

5 years agoUpdate NEWS file (#2804)
Andres Noetzli [Wed, 16 Jan 2019 20:27:05 +0000 (12:27 -0800)]
Update NEWS file (#2804)

5 years agoBugfix: LFSC clause equality (#2801)
Alex Ozdemir [Wed, 16 Jan 2019 17:52:42 +0000 (09:52 -0800)]
Bugfix: LFSC clause equality (#2801)

* Bugfix: LFSC clause equality

My implementation of clause equality had an undocumented assumption that
the clauses didn't have any duplicate literals. Now that assumption is
gone, and the tests suite has been expanded.

* Added an empty clause test

* Typo fix: Yoni

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Address Yoni's comments

* Remove a duplicate clause_eq test.
* Add an ordering clause_eq test.
* Improve the documentation of clause_eq.

5 years agoExtended Resolution Signature (#2788)
Alex Ozdemir [Wed, 16 Jan 2019 07:55:29 +0000 (23:55 -0800)]
Extended Resolution Signature (#2788)

* Extended Resolution Signature

While extended resolution is a fairly general technique, the paper
"Extended Resolution Simulates DRAT" / the drat2er uses exactly one new
type of rule: definitions of the form

    new <=> old v (~l_1 ^ ~l_2 ^ ... ^ ~l_n)

This PR adds axioms supporting this kind of definition, and adds a test
making use of those new axioms. The axioms support the following ideas:

   1. Introducing a **fresh** variable, defined in the form above
   2. Clausifying that definition to produce proofs of $$ n + 2 $$ new
      clauses in the form of two clauses, and a cnf with $$ n $$ clauses
   3. An axiom for unrolling the proof of the cnf into proofs of the
      original clauses.

* Addressing Yoni's comments

1. Added a new (trivial) test
2. Improved a bunch of documentation

* Update proofs/signatures/er.plf

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Removed references to RATs from the signature

There are still a few references in the header comment.

* Aside on continuations

* Scrap the elision annotations

5 years agoFix constant contains ITOS rewrite (#2799)
Andrew Reynolds [Wed, 16 Jan 2019 05:15:27 +0000 (23:15 -0600)]
Fix constant contains ITOS rewrite (#2799)

5 years agoCMake: Fix search for static libraries (#2798)
Andres Noetzli [Wed, 16 Jan 2019 03:14:06 +0000 (19:14 -0800)]
CMake: Fix search for static libraries (#2798)

When configuring CVC4 with `--static`, we change
`CMAKE_FIND_LIBRARY_SUFFIXES` to prefer static libraries (`*.a`) over
shared ones. However, instead of prepending `.a` to the list of
`CMAKE_FIND_LIBRARY_SUFFIXES`, we created a single element with `.a` and
the previous list.

Output of `message("${CMAKE_FIND_LIBRARY_SUFFIXES}")` before the change:

```
.a .tbd;.dylib;.so;.a
```

After the change:

```
.a;.tbd;.dylib;.so;.a
```

On macOS, both the static and the shared library of GMP are available
(when installed via homebrew) and before the change, CMake would pick the
shared library when compiling with `--static --no-static-binary`. This
commit fixes that issue.

5 years agoStrings: Add option to change loop process mode (#2794)
Andres Noetzli [Tue, 15 Jan 2019 18:28:47 +0000 (10:28 -0800)]
Strings: Add option to change loop process mode (#2794)

This commit adds an option `--strings-process-loop-mode` that allows
finer-grained control over CVC4 processes looping word equation. In
particular, performing normal loop breaking sometimes leads to worse
performance. The "simple" mode disables that inference.

5 years ago Fix unsound double abs rewrite rule for FP (#2792)
Andrew Reynolds [Tue, 15 Jan 2019 16:54:02 +0000 (10:54 -0600)]
 Fix unsound double abs rewrite rule for FP (#2792)

5 years ago Only check disequal terms with sygus-rr-verify (#2793)
Andrew Reynolds [Tue, 15 Jan 2019 01:12:59 +0000 (19:12 -0600)]
 Only check disequal terms with sygus-rr-verify (#2793)

5 years agoClausalBitvectorProof (#2786)
Alex Ozdemir [Mon, 14 Jan 2019 18:53:31 +0000 (10:53 -0800)]
ClausalBitvectorProof (#2786)

* [DRAT] ClausalBitvectorProof

Created a class, `ClausalBitvectorProof`, which represents a bitvector
proof of UNSAT using an underlying clausal technique (DRAT, LRAT, etc)

It fits into the `BitvectorProof` class hierarchy like this:

```
              BitvectorProof
              /            \
             /              \
ClausalBitvectorProof  ResolutionBitvectorProof
```

This change is a painful one because all of the following BV subsystems
referenced ResolutionBitvectorProof (subsequently RBVP) or
BitvectorProof (subsequently BVP):
   * CnfStream
   * SatSolver (specifically the BvSatSolver)
   * CnfProof
   * TheoryProof
   * TheoryBV
   * Both bitblasters

And in particular, ResolutionBitvectorProof, the CnfStream, and the
SatSolvers were tightly coupled.

This means that references to and interactions with (R)BVP were
pervasive.

Nevertheless, an SMT developer must persist.

The change summary:
  * Create a subclass of BVP, called ClausalBitvectorProof, which has
    most methods stubbed out.
  * Make a some modifications to BVP and ResolutionBitvectorProof as the
    natural division of labor between the different classes becomes
    clear.
  * Go through all the components in the first list and try to figure
    out which kind of BVP they should **actually** be interacting with,
    and how. Make tweaks accordingly.
  * Add a hook from CryptoMinisat which pipes the produced DRAT proof
    into the new ClausalBitvectorProof.
  * Add a debug statement to ClausalBitvectorProof which parses and
    prints that DRAT proof, for testing purposes.

Test:
  * `make check` to verify that we didn't break any old stuff, including
    lazy BB, and eager BB when using bvminisat.
  * `cvc4 --dump-proofs --bv-sat-solver=cryptominisat --bitblast=eager
  -d bv::clausal test/regress/regress0/bv/ackermann2.smt2`, and see that
     1. It crashed with "Unimplemented"
     2. Right before that it prints out the (textual) DRAT proof.

* Remove 2 unneeded methods

* Missed a rename

* Typos

Thanks Andres!

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Address Andres comments

* Reorder members of TBitblaster

5 years agoLFSC LRAT Output (#2787)
Alex Ozdemir [Sun, 13 Jan 2019 21:21:24 +0000 (13:21 -0800)]
LFSC LRAT Output (#2787)

* LFSC ouput & unit test

* Renamed lrat unit test file

* s/DRAT/LRAT/

Thanks Andres!

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Addressed Andres' comments

1. Extracted a filter whitespace function.
2. Added @param annotations.

* Addressing Yoni's comments

Tweaked the test method name for LRAT output as LFSC
Added assertions for verifying that clause index lists are sorted during
LFSC LRAT output.

5 years agoLratInstruction inheritance (#2784)
Alex Ozdemir [Sat, 12 Jan 2019 00:04:56 +0000 (16:04 -0800)]
LratInstruction inheritance (#2784)

While implementing and testing LRAT proof output as LFSC, I discovered
that my implementation of LratInstruction as a tagged union was subtly
broken for reasons related to move/copy assignment/constructors.

While I could have figured out how to fix it, I decided to stop fighting
the system and use inheritance.

This PR will be followed by one using the inheritance-based
LratInstruction to implement output to LFSC.

5 years agoFixed linking against drat2er, and use drat2er (#2785)
Alex Ozdemir [Fri, 11 Jan 2019 20:48:13 +0000 (12:48 -0800)]
Fixed linking against drat2er, and use drat2er (#2785)

* Fixed linking against drat2er/drat-trim

We have machinery for linking against drat2er. However, this machinery
didn't quite work because libdrat2er.a contains an (undefined) reference
to `run_drat_trim` from libdrat-trim.a.

Thus, when linking against libdrat2er.a, we also need to link against
libdrat-trim.a.

I made this change, and then tested it by actually calling a function
from the drat2er library (CheckAndConvertToLRAT) which relies on
`run_drat_trim`. Since this invocation compiles, we know that the
linking is working properly now.

* Combined the two libs, per Mathias

* drat2er configured gaurds

5 years agoNew C++ API: Add unit tests for setInfo, setLogic, setOption. (#2782)
Aina Niemetz [Fri, 11 Jan 2019 20:06:03 +0000 (12:06 -0800)]
New C++ API: Add unit tests for setInfo, setLogic, setOption. (#2782)

5 years agoNew C++ API: Get rid of mkConst functions (simplify API). (#2783)
Aina Niemetz [Thu, 10 Jan 2019 18:47:53 +0000 (10:47 -0800)]
New C++ API: Get rid of mkConst functions (simplify API). (#2783)

5 years agoDo not rewrite 1-constructor sygus testers to true (#2780)
Andrew Reynolds [Wed, 9 Jan 2019 21:39:07 +0000 (15:39 -0600)]
Do not rewrite 1-constructor sygus testers to true (#2780)

5 years ago[BV Proofs] Option for proof format (#2777)
Alex Ozdemir [Wed, 9 Jan 2019 18:19:22 +0000 (19:19 +0100)]
[BV Proofs] Option for proof format (#2777)

We're building out a system whereby (eager) BV proofs can be emitted in
one of three formats. Let's add an option for specifying which!

My testing mechanism was not very thorough: I verified that I could specify each of the following option values:
* `er`
* `lrat`
* `drat`
* `help`

and that I could not provide random other option values.

5 years agoClause proof printing (#2779)
Alex Ozdemir [Wed, 9 Jan 2019 08:18:29 +0000 (09:18 +0100)]
Clause proof printing (#2779)

* Print LFSC proofs of CNF formulas

* Unit Test for clause printing

* Added SAT input proof printing unit test

* Fixed cnf_holds reference. Proofs of CMap_holds

There were references to clauses_hold, which should have been references
to cnf_holds.

Also added a function for printing a value of type CMap_holds, and a
test for this function.

5 years agoLFSC drat output (#2776)
Alex Ozdemir [Wed, 9 Jan 2019 07:29:12 +0000 (08:29 +0100)]
LFSC drat output (#2776)

* LFSC drat output

* Addressed Mathias' review

Addressing Mathias' review with the following changes:
* Added a few blank lines
* Added a unit test for LRAT output as LFSC

5 years agoNew C++ API: Add missing getType() calls to kick off type checking. (#2773)
Aina Niemetz [Mon, 7 Jan 2019 17:02:02 +0000 (09:02 -0800)]
New C++ API: Add missing getType() calls to kick off type checking. (#2773)

5 years ago[DRAT] DRAT data structure (#2767)
Alex Ozdemir [Sun, 6 Jan 2019 18:32:42 +0000 (19:32 +0100)]
[DRAT] DRAT data structure  (#2767)

* Copied old DRAT data-structure files.

Next step: clean up the code, and adapt them to our current usage plans.

* Polished the DRAT class.

Notably, removed the idea of lazy-parsing, this is now just a DRAT
wrapper class.

More explicit about whether methods handle binary or text.

Better constructor patterns

* Added implementation of textual DRAT output

* reordered the DratInstruction structure.
* removed the public modifier from the above struct
* removed the operator << implementation for DratInstruction

* use emplace_back

* Addressing Yoni's first review

* Extracted "write literal in DIMACS format" idea as a function
* Replaced some spurious Debug streams with `os`. (they were left over
from an earlier refactor)
* Improved some documentation

* Removed aside about std::string

* Addressed Mathias' comments

Specifically
* SCREAMING_SNAKE_CASED enum variants.
* Extracted some common logic from two branches of a conditional.
* Cleaned out some undefined behavior from bit manipulation.

* Unit tests for binary DRAT parsing

* Added text output test

* s/white/black/ derp

5 years agocmake: Disable unit tests for static builds. (#2775)
Mathias Preiner [Sat, 5 Jan 2019 04:21:10 +0000 (20:21 -0800)]
cmake: Disable unit tests for static builds. (#2775)

--static now implies --no-unit-testing.

Fixes #2672.

5 years agoC++ API: Fix OOB read in unit test (#2774)
Andres Noetzli [Fri, 4 Jan 2019 21:26:08 +0000 (13:26 -0800)]
C++ API: Fix OOB read in unit test (#2774)

There were two typos in the unit tests that caused OOB accesses. Instead
of doing `d_solver.mkConst(CONST_BITVECTOR, std::string("101"), 6)`, the
closing parenthesis was in the wrong place resulting in
`std::string("101", 6)`. The second argument to `std::string(const
char*, size_t)` says how many characters to copy and results in
undefined behavior if the number is greater than the length of the
string, thus the OOB access. The commit fixes the typo and removes one
of the tests because it should not actually fail (16 is an accepted
base).

5 years ago[LRAT] A C++ data structure for LRAT. (#2737)
Alex Ozdemir [Fri, 4 Jan 2019 08:57:27 +0000 (09:57 +0100)]
[LRAT] A C++ data structure for LRAT. (#2737)

* [LRAT] A C++ data structure for LRAT.

Added a data structure for storing (abstract) LRAT proofs.

The constructor will take a drat binary proof and convert it to LRAT
using drat-trim. However, this is unimplemented in this PR.

Subsequent PRs will add:
   * LFSC representation of LRAT
   * Bitvector Proofs based on LRAT
   * Enabled tests for those proofs

* Documenting LRAT constructors

* Apply suggestions from code review

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Responding to Andres' review

Consisting of
   * Naming nits
   * Closed fds
   * Better implementation of disjoint union for LratInstruction
   * DRAT -> LRAT conversion is no longer an LratProof constructor

* include reorder

* Update src/proof/lrat/lrat_proof.h

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Addressed Andres' comments

* ANonymous namespaces and name resolution?

* Remove inlines, fix i negation

Thanks Andres!

* Use `std::abs`

Credit to Andres

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Remove uneeded public

5 years agoNew C++ API: Add missing catch blocks for std::invalid_argument. (#2772)
Aina Niemetz [Fri, 4 Jan 2019 03:29:43 +0000 (19:29 -0800)]
New C++ API: Add missing catch blocks for std::invalid_argument. (#2772)

5 years agoAPI/Smt2 parser: refactor termAtomic (#2674)
Andres Noetzli [Thu, 3 Jan 2019 22:48:18 +0000 (14:48 -0800)]
API/Smt2 parser: refactor termAtomic (#2674)

5 years agoC++ API: Reintroduce zero-value mkBitVector method (#2770)
Andres Noetzli [Thu, 3 Jan 2019 16:55:45 +0000 (17:55 +0100)]
C++ API: Reintroduce zero-value mkBitVector method (#2770)

PR #2764 removed `Solver::mkBitVector(uint32_t)` (returns a bit-vector
of a given size with value zero), which made the build fail when SymFPU
was enabled because solver_black used it for SymFPU-enabled builds. This
commit simply adds a zero default argument to `mkBitVector(uint32_t,
uint64_t)` to allow users to create zero-valued bit-vectors without
explicitly specifying the value again. Additionally, the commit replaces
the use of the `CVC4_USE_SYMFPU` macro by a call to
`Configuration::isBuiltWithSymFPU()`, making sure that we can catch
compile-time errors regardless of configuration. Finally,
`Solver::mkConst(Kind, uint32_t, uint32_t, Term)` now checks whether
CVC4 has been compiled with SymFPU when creating a `CONST_FLOATINGPOINT`
and throws an exception otherwise (solver_black has been updated
correspondingly).

5 years ago[LRA proof] Recording & Printing LRA Proofs (#2758)
Alex Ozdemir [Thu, 3 Jan 2019 14:39:35 +0000 (15:39 +0100)]
[LRA proof] Recording & Printing LRA Proofs (#2758)

* [LRA proof] Recording & Printing LRA Proofs

Now we use the ArithProofRecorder to record and later print arithmetic
proofs.

If an LRA lemma can be proven by a single farkas proof, then that is
done. Otherwise, we `trust` the lemma.

I haven't **really** enabled LRA proofs yet, so `--check-proofs` still
is a no-op for LRA.

To test, do
```
lfsccvc4 <(./bin/cvc4 --dump-proofs ../test/regress/regress0/lemmas/mode_cntrl.induction.smt | tail -n +2)
```

where `lfsccvc4` is an alias invoking `lfscc` with all the necessary
signatures. On my machine that is:

```
alias lfsccvc4="/home/aozdemir/repos/LFSC/build/src/lfscc \
/home/aozdemir/repos/CVC4/proofs/signatures/sat.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/smt.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/lrat.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/th_base.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/th_bv.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/th_bv_bitblast.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/th_arrays.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/th_int.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/th_quant.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/th_real.plf \
/home/aozdemir/repos/CVC4/proofs/signatures/th_real.plf"

```

* Added guards to proof recording

Also reverted some small, unintentional changes.

Also had to add printing for STRING_SUBSTR??

* Responding to Yoni's review

* SimpleFarkasProof examples

* Respond to Aina's comments

* Reorder Constraint declarations

* fix build

* Moved friend declaration in Constraint

* Trichotomy example

* Lift getNumChildren invocation in PLUS case

Credits to aina for spotting it.

* Clang-format

5 years agoNew C++ API: Add tests for mk-functions in solver object. (#2764)
Aina Niemetz [Thu, 3 Jan 2019 04:07:43 +0000 (20:07 -0800)]
New C++ API: Add tests for mk-functions in solver object. (#2764)

5 years agoClean up BV kinds and type rules. (#2766)
Aina Niemetz [Thu, 20 Dec 2018 22:48:07 +0000 (14:48 -0800)]
Clean up BV kinds and type rules. (#2766)

5 years agoAdd missing type rules for parameterized operator kinds. (#2766)
Aina Niemetz [Thu, 20 Dec 2018 21:44:51 +0000 (13:44 -0800)]
Add missing type rules for parameterized operator kinds. (#2766)

5 years agoFix issues with REWRITE_DONE in floating point rewriter (#2762)
Andrew Reynolds [Wed, 19 Dec 2018 17:58:52 +0000 (11:58 -0600)]
Fix issues with REWRITE_DONE in floating point rewriter (#2762)

5 years agoRemove noop. (#2763)
Aina Niemetz [Tue, 18 Dec 2018 00:16:16 +0000 (16:16 -0800)]
Remove noop. (#2763)

5 years ago Configured for linking against drat2er (#2754)
Alex Ozdemir [Mon, 17 Dec 2018 23:01:23 +0000 (15:01 -0800)]
 Configured for linking against drat2er (#2754)

drat2er is a C/C++ project which includes support for
   * Checking DRAT proofs
   * Converting DRAT proofs to LRAT proofs
   * Converting DRAT proofs to ER proofs

It does the first 2 by using drat-trim under the hood.

I've modified our CMake configuration to allow drat2er to be linked into
CVC4, and I added a contrib script.

5 years agoNew C++ API: Add tests for term object. (#2755)
Aina Niemetz [Mon, 17 Dec 2018 22:11:37 +0000 (14:11 -0800)]
New C++ API: Add tests for term object. (#2755)

5 years agoDRAT Signature (#2757)
Alex Ozdemir [Mon, 17 Dec 2018 01:49:34 +0000 (17:49 -0800)]
DRAT Signature (#2757)

* DRAT signature

Added the DRAT signature to CVC4.

We'll need this in order to compare three BV proof pipelines:
   1. DRAT -> Resolution -> Check
   2. DRAT -> LRAT -> Check
   3. DRAT -> Check (this one!)

Tested the signature using the attached test file. i.e. running
```
lfscc sat.plf smt.plf lrat.plf drat.plf drat_test.plf
```

* Added type annotations for tests

* Respond to Yoni's review

* Apply Yoni's suggestions from code review

Documentation polish

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Whoops, missed a spot or two

5 years agoRevert "Move ss-combine rewrite to extended rewriter (#2703)" (#2759)
Andres Noetzli [Sat, 15 Dec 2018 16:40:03 +0000 (16:40 +0000)]
Revert "Move ss-combine rewrite to extended rewriter (#2703)" (#2759)

5 years ago [LRA Proof] Storage for LRA proofs (#2747)
Alex Ozdemir [Sat, 15 Dec 2018 01:44:39 +0000 (17:44 -0800)]
 [LRA Proof] Storage for LRA proofs  (#2747)

* [LRA Proof] Storage for LRA proofs

During LRA solving the `ConstraintDatabase` contains the reasoning
behind different constraints. Combinations of constraints are
periodically used to justify lemmas (conflict clauses, propegations, ...
?). `ConstraintDatabase` is SAT context-dependent.

ArithProofRecorder will be used to store concise representations of the
proof for each lemma raised by the (LR)A theory. The (LR)A theory will
write to it, and the ArithProof class will read from it to produce LFSC
proofs.

Right now, it's pretty simplistic -- it allows for only Farkas proofs.

In future PRs I'll:
   1. add logic that stores proofs therein
   2. add logic that retrieves and prints proofs
   3. enable LRA proof production, checking, and testing

* Document ArithProofRecorder use-sites

* Update src/proof/arith_proof_recorder.cpp

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Yoni's review

* clang-format

* Response to Mathias' review.

5 years agoFixed typos.
Aina Niemetz [Fri, 14 Dec 2018 23:12:27 +0000 (15:12 -0800)]
Fixed typos.

5 years agoNew C++ API: Add tests for opterm object. (#2756)
Aina Niemetz [Fri, 14 Dec 2018 18:25:15 +0000 (10:25 -0800)]
New C++ API: Add tests for opterm object. (#2756)

5 years ago Fix extended rewriter for binary associative operators. (#2751)
Andrew Reynolds [Fri, 14 Dec 2018 02:17:50 +0000 (20:17 -0600)]
 Fix extended rewriter for binary associative operators. (#2751)

This was causing assertion failures when using Sets + Sygus.

5 years agoMake single invocation and invariant pre/post condition templates independent (#2749)
Andrew Reynolds [Fri, 14 Dec 2018 00:39:26 +0000 (18:39 -0600)]
Make single invocation and invariant pre/post condition templates independent (#2749)

--cegqi-si=none previously disabled pre/post-condition templates for invariant synthesis. This PR eliminates this dependency.

There are no major code changes in this PR, unfortunately a large block of code changed indentation so I refactored it to be more up to date with the coding guidelines.

5 years agoNew C++ API: Add tests for sort functions of solver object. (#2752)
Aina Niemetz [Thu, 13 Dec 2018 21:17:22 +0000 (13:17 -0800)]
New C++ API: Add tests for sort functions of solver object. (#2752)

5 years agoRemove spurious map (#2750)
Andrew Reynolds [Thu, 13 Dec 2018 18:03:16 +0000 (12:03 -0600)]
Remove spurious map (#2750)

5 years agoFix compiler warnings. (#2748)
Aina Niemetz [Thu, 13 Dec 2018 00:37:59 +0000 (16:37 -0800)]
Fix compiler warnings. (#2748)

5 years agoAPI: Add simple empty/sigma regexp unit tests (#2746)
Andres Noetzli [Wed, 12 Dec 2018 23:19:30 +0000 (23:19 +0000)]
API: Add simple empty/sigma regexp unit tests (#2746)

5 years ago[LRA proof] More complete LRA example proofs. (#2722)
Alex Ozdemir [Wed, 12 Dec 2018 01:35:26 +0000 (17:35 -0800)]
[LRA proof] More complete LRA example proofs. (#2722)

* [LRA proof] Refine "poly" and "term Real" distinction

Short Version:

Refined the LRA signature and used the refined version to write two new
test proofs which are close to interface compatible with the LRA proofs
that CVC4 will produce.

Love Version:

LRA proofs have the following interface:
   * Given predicates between real terms
   * Prove bottom

However, even though the type of the interface does not express this,
the predicates are **linear bounds**, not arbitrary real bounds. Thus
LRA proofs have the following structure:

   1. Prove that the input predicates are equivalent to a set of linear
      bounds.
   2. Use the linear bounds to prove bottom using farkas coefficients.

Notice that the distinction between linear bounds (associated in the
signature with the string "poly") and real predicates (which relate
"term Real"s to one another) matters quite a bit. We have certain inds
of axioms for one, and other axioms for the other.

The signature used to muddy this distinction using a constructor called
"term_poly" which converted between them. I decided it was better to buy
into the distinction fully.

Now all of the axioms for step (2) use the linear bounds and axioms for
step (1) use both kinds of bounds, which makes sense because step (1) is
basically a conversion.

Also had to add an axiom or two, because some were missing.

* Update proofs/signatures/th_lra.plf

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Improved test readability, removed unused axioms

The LRA proof tests did not have appropriate documentation, and did not
specify **what** they proved. Now they each have a header comment
stating their premises and conclusion, and that conclusion is enforced
by a type annotation in the test.

The LRA signature included some unused axioms concerning `poly_term`.
Now they've been removed.

Credits to Yoni for noticing both problems.

5 years ago[LRAT] signature robust against duplicate literals (#2743)
Alex Ozdemir [Wed, 12 Dec 2018 01:19:07 +0000 (17:19 -0800)]
[LRAT] signature robust against duplicate literals (#2743)

* [LRAT] signature robust against duplicate literals

The LRAT signature previously had complex, surprising, and occasionally
incorrect behavior when given clauses with duplicate literals.

Now it does not. Now clauses have true set semantics, and clauses with
duplicate literals are treated identically to those without.

* Test with logically = but structurally != clauses.

5 years agoRemove alternate versions of mbqi (#2742)
Andrew Reynolds [Tue, 11 Dec 2018 22:38:00 +0000 (16:38 -0600)]
Remove alternate versions of mbqi (#2742)

5 years agoLRAT signature (#2731)
Alex Ozdemir [Tue, 11 Dec 2018 19:46:38 +0000 (11:46 -0800)]
LRAT signature (#2731)

* LRAT signature

Added an LRAT signature. It is almost entirely side-conditions, but it
works.

There is also a collection of tests for it. You can run them by invoking

```
lfscc smt.plf sat.plf lrat.plf lrat_test.plf
```

* Update proofs/signatures/lrat.plf per Yoni's suggestion.

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Responding to Yoni's comments.

* Removed unused varaibles

Some tests declared `var`s which were unused.
Now they don't.

5 years agoBoolToBV modes (off, ite, all) (#2530)
makaimann [Mon, 10 Dec 2018 16:37:11 +0000 (08:37 -0800)]
BoolToBV modes (off, ite, all) (#2530)

5 years agoStrings: Make EXTF_d inference more conservative (#2740)
Andres Noetzli [Fri, 7 Dec 2018 15:48:38 +0000 (07:48 -0800)]
Strings: Make EXTF_d inference more conservative (#2740)

5 years agoArith Constraint Proof Loggin (#2732)
Alex Ozdemir [Fri, 7 Dec 2018 04:00:03 +0000 (20:00 -0800)]
Arith Constraint Proof Loggin (#2732)

* Arith Constraint Proof Logging

Also a tiny documentation update.

* Debug.isOn check around iterated output

* reference iteratees

5 years agoEnable BV proofs when using an eager bitblaster (#2733)
Alex Ozdemir [Fri, 7 Dec 2018 02:56:56 +0000 (18:56 -0800)]
Enable BV proofs when using an eager bitblaster (#2733)

* Enable BV proofs when using and eager bitblaster

Specifically:
   * Removed assertions that blocked them.
   * Made sure that only bitvectors were stored in the BV const let-map
   * Prevented true/false from being bit-blasted by the eager bitblaster

Also:
   * uncommented "no-check-proofs" from relevant tests

* Option handler logic for BV proofs

BV eager proofs only work when minisat is the sat solver being used by
the BV theory.

Added logic to the --proof hanlder to  verify this or throw an option
exception.

* Bugfix for proof options handler

I forgot that proofEnabledBuild runs even if the --proof option is
negated. In my handler I now check that proofs are enabled.

* Clang-format

5 years agoFix use-after-free due to destruction order (#2739)
Andres Noetzli [Thu, 6 Dec 2018 23:23:00 +0000 (15:23 -0800)]
Fix use-after-free due to destruction order (#2739)

A test for PR #2737 was failing even though the PR only added dead code.
This PR fixes the issue by fixing two use-after-free bugs:

- `ResolutionBitVectorProof` has a `Context` and a
`std::unique_ptr<BVSatProof>` member. The `BVSatProof` depends on the
`Context` and tries to access it (indirectly) in its constructor but
because the context was declared after the proof, the context was
destroyed before the proof, leading to a use-after-free in a method
called from the proof's destructor. This commit reorders the two
members.
- `TLazyBitblaster` was destroyed before the `LFSCCnfProof` in
`BitVectorProof` because `SmtEngine`'s destructor first destroyed the
theory engine and then the proof manager. This lead to a use-after-free
because `LFSCCnfProof` was using the `d_nullContext` of
`TLazyBitblaster`, which got indirectly accessed in `LFSCCnfProof`'s
destructor. This commit moves the destruction of `ProofManager` above
the destruction of the theory engine.

The issues were likely introduced by #2599. They went undetected because
our nightlies' ASAN check does not use proofs due to known memory leaks
in the proof module of CVC4.

I have tested this PR up to regression level 2 with ASAN with leak
detection disabled.

5 years ago Take into account minimality and types for cached PBE solutions (#2738)
Andrew Reynolds [Thu, 6 Dec 2018 16:38:05 +0000 (10:38 -0600)]
 Take into account minimality and types for cached PBE solutions (#2738)

5 years agoApply extended rewriting on PBE static symmetry breaking. (#2735)
Andrew Reynolds [Tue, 4 Dec 2018 22:04:47 +0000 (16:04 -0600)]
Apply extended rewriting on PBE static symmetry breaking. (#2735)

5 years agoEnable regular expression elimination by default. (#2736)
Andrew Reynolds [Tue, 4 Dec 2018 19:52:17 +0000 (13:52 -0600)]
Enable regular expression elimination by default. (#2736)

Seems to have no impact on Norn, and is helpful for a number of applications.

5 years ago Skip non-cardinality types in sets min card inference (#2734)
Andrew Reynolds [Mon, 3 Dec 2018 23:00:58 +0000 (17:00 -0600)]
 Skip non-cardinality types in sets min card inference (#2734)

5 years agoBit vector proof superclass (#2599)
Alex Ozdemir [Mon, 3 Dec 2018 19:56:47 +0000 (11:56 -0800)]
Bit vector proof superclass (#2599)

* Split BitvectorProof into a sub/superclass

The superclass contains general printing knowledge.

The subclass contains CNF or Resolution-specific knowledge.

* Renames & code moves

* Nits cleaned in prep for PR

* Moved CNF-proof from ResolutionBitVectorProof to BitVectorProof

Since DRAT BV proofs will also contain a CNF-proof, the CNF proof should
be stored in `BitVectorProof`.

* Unique pointers, comments, and code movement.

Adjusted the distribution of code between BVP and RBVP.
  Notably, put the CNF proof in BVP because it isn't
  resolution-specific.
Added comments to the headers of both files -- mostly BVP.
Changed two owned pointers into unique_ptr.
  BVP's pointer to a CNF proof
  RBVP's pointer to a resolution proof

BVP: `BitVectorProof`
RBVP: `ResolutionBitVectorProof`

* clang-format

* Undo manual copyright modification

* s/superclass/base class/

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* make LFSCBitVectorProof::printOwnedSort public

* Andres's Comments

Mostly cleaning up (or trying to clean up) includes.

* Cleaned up one header cycle

However, this only allowed me to move the forward-decl, not eliminate
it, because there were actually two underlying include cycles that the
forward-decl solved.

* Added single _s to header gaurds

* Fix Class name in debug output

Credits to Andres

Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Reordered methods in BitVectorProof per original  ordering

5 years agoOptimizations for PBE strings (#2728)
Andrew Reynolds [Sun, 2 Dec 2018 14:49:17 +0000 (08:49 -0600)]
Optimizations for PBE strings (#2728)

5 years ago Infrastructure for sygus side conditions (#2729)
Andrew Reynolds [Thu, 29 Nov 2018 18:09:19 +0000 (12:09 -0600)]
 Infrastructure for sygus side conditions (#2729)

5 years agoCombine sygus stream with PBE (#2726)
Andrew Reynolds [Thu, 29 Nov 2018 06:17:14 +0000 (00:17 -0600)]
Combine sygus stream with PBE (#2726)

5 years agoImprove interface for sygus grammar cons (#2727)
Andrew Reynolds [Wed, 28 Nov 2018 23:57:18 +0000 (17:57 -0600)]
Improve interface for sygus grammar cons (#2727)

5 years agoInformation gain heuristic for PBE (#2719)
Andrew Reynolds [Wed, 28 Nov 2018 21:49:56 +0000 (15:49 -0600)]
Information gain heuristic for PBE (#2719)

5 years agoOptimize re-elim for re.allchar components (#2725)
Andrew Reynolds [Wed, 28 Nov 2018 20:58:33 +0000 (14:58 -0600)]
Optimize re-elim for re.allchar components (#2725)

5 years agoImprove skolem caching by normalizing skolem args (#2723)
Andres Noetzli [Wed, 28 Nov 2018 20:33:55 +0000 (12:33 -0800)]
Improve skolem caching by normalizing skolem args (#2723)

In certain cases, we can share skolems between similar reductions, e.g.
`(str.replace x y z)` and `(str.replace (str.substr x 0 n) y z)` because the
first occurrence of `y` in `x` has to be the first occurrence
of `y` in `(str.substr x 0 n)` (assuming that `y` appears in both, otherwise the value of
the skolems does not matter). This commit adds a helper function in the
skolem cache that does some of those simplifications.

5 years agoGeneralize sygus stream solution filtering to logical strength (#2697)
Andrew Reynolds [Wed, 28 Nov 2018 17:06:32 +0000 (11:06 -0600)]
Generalize sygus stream solution filtering to logical strength (#2697)

5 years agoImprove cegqi engine trace. (#2714)
Andrew Reynolds [Wed, 28 Nov 2018 01:27:57 +0000 (19:27 -0600)]
Improve cegqi engine trace. (#2714)

5 years agoMake (T)NodeTrie a general utility (#2489)
Andrew Reynolds [Tue, 27 Nov 2018 21:39:13 +0000 (15:39 -0600)]
Make (T)NodeTrie a general utility (#2489)

This moves quantifiers::TermArgTrie in src/theory/quantifiers/term_database to (T)NodeTrie in src/expr, and cleans up all references to it.

5 years agoFix coverity warnings in datatypes (#2553)
Andrew Reynolds [Tue, 27 Nov 2018 21:19:32 +0000 (15:19 -0600)]
Fix coverity warnings in datatypes (#2553)

This caches some information regarding tester applications and changes int -> size_t in a few places.

5 years agoLazy model construction in TheoryEngine (#2633)
Andrew Reynolds [Tue, 27 Nov 2018 16:56:27 +0000 (10:56 -0600)]
Lazy model construction in TheoryEngine (#2633)

5 years agoReduce lookahead when parsing string literals (#2721)
Andres Noetzli [Tue, 27 Nov 2018 16:10:36 +0000 (08:10 -0800)]
Reduce lookahead when parsing string literals (#2721)

5 years agoLRA proof signature fixes and a first proof for linear polynomials (#2713)
Alex Ozdemir [Tue, 27 Nov 2018 08:59:22 +0000 (00:59 -0800)]
LRA proof signature fixes and a first proof for linear polynomials (#2713)

* LRA proof signature fixes and a first proof

The existing LRA signature had a few problems (e.g. referencing symbols
that didn't exist, extra parentheses, etc). I patched it up and wrote an
first example LRA proof. load `th_lra_test.plf` last to run that test.

* Add dependency info to signatures

I chose to indicate shallow dependencies only.

5 years agoUse https for antlr3.org downloads (#2701)
Tom Smeding [Fri, 23 Nov 2018 07:31:21 +0000 (08:31 +0100)]
Use https for antlr3.org downloads (#2701)

This commit changes the two www,antlr3.org URL's in contrib/get-antlr-3.4 to use https instead of http, which is more secure.

5 years agoMove ss-combine rewrite to extended rewriter (#2703)
Andres Noetzli [Thu, 22 Nov 2018 01:44:50 +0000 (17:44 -0800)]
Move ss-combine rewrite to extended rewriter (#2703)

We found that the `ss-combine` rewrite hurts solving performance, so
this commit is moving it to the extended rewriter.

5 years agoAdd rewrite for (str.substr s x y) --> "" (#2695)
Andres Noetzli [Thu, 22 Nov 2018 00:47:57 +0000 (16:47 -0800)]
Add rewrite for (str.substr s x y) --> "" (#2695)

This commit adds the rewrite `(str.substr s x y) --> "" if x >= 0 |= 0
>= str.len(s)`.

5 years agoCache evaluations for PBE (#2699)
Andrew Reynolds [Wed, 21 Nov 2018 23:07:17 +0000 (17:07 -0600)]
Cache evaluations for PBE (#2699)

5 years agoQuickly recognize when PBE conjectures are infeasible (#2718)
Andrew Reynolds [Wed, 21 Nov 2018 22:24:16 +0000 (16:24 -0600)]
Quickly recognize when PBE conjectures are infeasible (#2718)

Recognizes when the conjecture has conflicting I/O pairs. Also includes a minor change to the default behavior of PBE.

This change broke a delicate regression array_search_2, which I fixed by adding some additional options to make it more robust.

After this PR, we immediately find 4/7 unsolved in PBE strings of sygusComp 2018 to be infeasible.

5 years agoObvious rewrites to floating-point < and <=. (#2706)
Martin [Wed, 21 Nov 2018 21:59:51 +0000 (21:59 +0000)]
Obvious rewrites to floating-point < and <=. (#2706)

5 years agoSupport string replace all (#2704)
Andrew Reynolds [Wed, 21 Nov 2018 20:44:44 +0000 (14:44 -0600)]
Support string replace all (#2704)

5 years ago Fix type enumerator for FP (#2717)
Andrew Reynolds [Wed, 21 Nov 2018 14:59:51 +0000 (08:59 -0600)]
 Fix type enumerator for FP (#2717)

5 years agoFix real2int regression. (#2716)
Andrew Reynolds [Tue, 20 Nov 2018 16:48:41 +0000 (10:48 -0600)]
Fix real2int regression. (#2716)

5 years agoChange lemma proof step storage & iterators (#2712)
Alex Ozdemir [Tue, 20 Nov 2018 05:46:29 +0000 (21:46 -0800)]
Change lemma proof step storage & iterators (#2712)

Proof steps were in a std::list, which is a linked list, but really, we
only needed a stack, so I changed it to a vector, because LL's are
usually slower.

Also added an iterator for the proof steps, and << implementations

5 years ago Clausify context-dependent simplifications in ext theory (#2711)
Andrew Reynolds [Tue, 20 Nov 2018 01:18:38 +0000 (19:18 -0600)]
 Clausify context-dependent simplifications in ext theory (#2711)

5 years agoFix E-matching for case where candidate generator is not properly initialized (#2708)
Andrew Reynolds [Mon, 19 Nov 2018 23:29:44 +0000 (17:29 -0600)]
Fix E-matching for case where candidate generator is not properly initialized (#2708)

5 years ago Expand definitions prior to model core computation (#2707)
Andrew Reynolds [Thu, 15 Nov 2018 22:40:37 +0000 (16:40 -0600)]
 Expand definitions prior to model core computation (#2707)

5 years agocmake: Require boost 1.50.0 for examples. (#2710)
Mathias Preiner [Wed, 14 Nov 2018 19:48:49 +0000 (11:48 -0800)]
cmake: Require boost 1.50.0 for examples. (#2710)

5 years agocmake: Add option to explicitely enable/disable static binaries. (#2698)
Mathias Preiner [Thu, 8 Nov 2018 19:10:16 +0000 (11:10 -0800)]
cmake: Add option to explicitely enable/disable static binaries. (#2698)

5 years agoEvaluator: add support for str.code (#2696)
Andres Noetzli [Thu, 8 Nov 2018 01:04:52 +0000 (17:04 -0800)]
Evaluator: add support for str.code (#2696)

5 years agoAdding default SyGuS grammar construction for arrays (#2685)
Haniel Barbosa [Wed, 7 Nov 2018 23:12:38 +0000 (17:12 -0600)]
Adding default SyGuS grammar construction for arrays (#2685)

5 years agoFix collectEmptyEqs in string rewriter (#2692)
Andres Noetzli [Wed, 7 Nov 2018 18:28:25 +0000 (10:28 -0800)]
Fix collectEmptyEqs in string rewriter (#2692)

5 years ago Fix for itos reduction (#2691)
Andrew Reynolds [Wed, 7 Nov 2018 16:52:51 +0000 (10:52 -0600)]
 Fix for itos reduction (#2691)

5 years agoIncorporate static PBE symmetry breaking lemmas into SygusEnumerator (#2690)
Andrew Reynolds [Tue, 6 Nov 2018 23:28:41 +0000 (17:28 -0600)]
Incorporate static PBE symmetry breaking lemmas into SygusEnumerator (#2690)

5 years agoChange default sygus enumeration mode to auto (#2689)
Andrew Reynolds [Mon, 5 Nov 2018 22:50:48 +0000 (16:50 -0600)]
Change default sygus enumeration mode to auto (#2689)

5 years agoFix coverity warnings in sygus enumerator (#2687)
Andrew Reynolds [Mon, 5 Nov 2018 22:16:31 +0000 (16:16 -0600)]
Fix coverity warnings in sygus enumerator (#2687)

5 years agoNew C++ API: Split unit tests. (#2688)
Aina Niemetz [Mon, 5 Nov 2018 17:43:29 +0000 (09:43 -0800)]
New C++ API: Split unit tests. (#2688)

5 years agoIncreasing coverage (#2683)
yoni206 [Mon, 5 Nov 2018 17:25:09 +0000 (09:25 -0800)]
Increasing coverage (#2683)

This PR adds/revises tests in order to increase coverage in some preprocessing passes and in proofs done with --fewer-preprocessing-holes flag.

5 years agoAPI: Fix assignment operators (#2680)
Andres Noetzli [Mon, 5 Nov 2018 17:01:03 +0000 (09:01 -0800)]
API: Fix assignment operators (#2680)

The assignment operators of `Term`, `OpTerm`, and `Sort` currently have
an issue. The operators dereference their `shared_ptr` member and assign
the corresponding member of the other object. This is problematic
because if we have for example two `Term`s pointing to the same `Expr`,
then the assignment changes both `Term`s even though we only assign to
one, which is not what we want (see the unit test in this commit for a
concrete example of the desired behavior). To fix the issue, the
assignment operator should just copy the pointer of the other object.
This happens to be the behavior of the default assignment operator, so
this commit simply removes the overloaded assignment operators.

Testing: I did `make check` with an ASAN build and no errors other than
the one fixed in #2607 were reported.

5 years agoconfigure.sh: Fix option parsing to match --help (#2611)
Andres Noetzli [Mon, 5 Nov 2018 16:42:21 +0000 (08:42 -0800)]
configure.sh: Fix option parsing to match --help (#2611)