Commit Graph

51 Commits

Author SHA1 Message Date
Ryan Scott
c46f802d12 Support building with GHC 9.6
This patch contains a variety of fixes needed to build the libraries in the
`what4` repo with GHC 9.6:

* GHC 9.6 bundles `mtl-2.3.*`, which no longer re-exports `Control.Monad`,
  `Control.Monad.IO.Class`, and similar modules from `mtl`-related modules.
  To accommodate this, various imports have been made more explicit.
* `MonadTrans t` now has a quantified `forall m. Monad m => Monad (t m)`
  superclass in `mtl-2.3.*`. As a result, the `MonadTrans (PartialT sym)`
  instance must now have an `IsExpr (SymExpr sym)` instance context in order
  for it to typecheck, as this is the same instance context that `PartialT`'s
  `Monad` instance has.

  This is technically a breaking change, so I have noted it in the `what4`
  changelog. That being said, this change is unlikely to affect many people
  in practice, considering that the `MonadTrans` instance for `PartialT` is
  usually used in tandem with the `Monad` instance.
* Various upper version bounds on `base` have been lifted to allow building
  with `base-4.18`.
* The `aig` submodule has been bumped to bring in the changes from
  GaloisInc/aig#15, which allows it to build with GHC 9.6.
2023-07-28 15:13:12 -04:00
Ryan Scott
6c85dbbd04 Support building with GHC 9.4
This contains a varity of changes needed to make the libraries in the `what4`
repo compile with GHC 9.4:

* GHC 9.4 is pickier about undecidable instance checking. See
  [this section](https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.4?version_id=24540b698481cf2b0bd11029b58eaddc0fbfbb31#stricter-undecidableinstances-checking)
  of the GHC 9.4 Migration Guide. As a result, I had to explicitly enable
  `UndecidableInstances` in `What4.Utils.AbstractDomains` to make it compile.
* `ST` no longer has a `MonadFail` instance. See
  [this section](https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.4?version_id=b60e52482a666d25638d59cd7e86851ddf971dc1#st-is-no-longer-an-instance-of-monadfail)
  of the GHC 9.4 Migration Guide. To adapt to this change, I removed the
  `MonadFail` instance for `VarRecorder`, which was built on top of `ST`'s
  `MonadFail` instance. Accordingly, all uses of `fail` at type `VarRecorder`
  have now been replaced with `error`.
* I bumped the `aig` submodule to bring in the changes from
  https://github.com/GaloisInc/aig/pull/13, which are required to make `aig`
  build with GHC 9.4.
* I bumped the upper version bounds of various dependencies to allow them to
  build with GHC 9.4.

Fixes #224.
2023-01-23 14:10:00 -05:00
Ryan Scott
aa61bf7579 Allow building with GHC 9.2
This contains a variety of changes needed to make the libraries in the `what4`
compile warning-free with GHC 9.2:

* GHC 9.2 includes `-Woperator-whitespace-ext-conflict` as a part of `-Wall`,
  which causes `Test.Verification` to warn when built with GHC 9.2. The fix is
  simple: just add spaces after certain uses of the `$` character.
* GHC 9.2 includes `-Wincomplete-uni-patterns` as a part of `-Wall`, which
  causes `GenWhat4Expr` to warn when built with GHC 9.2. I fixed the warnings
  by introducing new `from{Bool,Int,BV8,BV16,BV32,BV64}TestExpr` functions to
  extract the payloads of different `TestExpr` constructors. This is no less
  partial than before, but at least this way any accidental partiality will
  result in a more descriptive error message than
  `Non-exhaustive patterns in ...`.
* In `base-4.16.*`, `Nat` is now a type synonym for `Natural`, and
  `GHC.TypeNats` now re-exports `Natural`. This causes an import of
  `Numeric.Natural` in `What4.SemiRing` (previously required to bring `Natural`
  into scope) trigger an `-Wunused-imports` warning. I fixed the warning by
  using explicit imports from `GHC.TypeNats` and `Numeric.Natural`.
* The `aig` and `abcBridge` submodules were bumped to bring in the changes
  from GaloisInc/aig#12 and GaloisInc/abcBridge#19, respectively, which allows
  them to build with `base-4.16.*`.
* The upper version bounds on `base` were raised in `what4-abc`, `what4-blt`,
  and `what4-transition-system` to allow them to build with `base-4.16.*`.
2022-04-12 05:24:50 -04:00
Rob Dockins
f3fbaeab11 Fix compile errors in what4-abc
Fixes #154
2021-09-27 17:11:19 -07:00
Ryan Scott
a1adde9685 Support building with GHC 9.0
This contains a variety of tweaks needed to make `what4`, `what4-abc`, and
`what4-blt` build warning-free on GHC 9.0:

* GHC's constraint solver now solves constraints in each top-level group
  sooner (see
  [here](https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.0?version_id=5fcd0a50e0872efb3c38a32db140506da8310d87#the-order-of-th-splices-is-more-important)).
  This affects `what4`'s `What4.Expr.App` module, as it separates top-level
  groups with a Template Haskell `$(return [])` splice. The previous location
  of this splice made it so that the TH-generated instances in that module
  (e.g., the `TraversableFC` instance for `App`) were not available to any code
  before the splice, resulting in type errors when compiled with GHC 9.0.

  I implemented a fairly involved fix of moving each of the affected data
  types, as well as their corresponding TH-generated instances, to the top of
  the module to ensure that subsequent top-level groups have access to this
  code.
* GHC 9.0 implements simplified subsumption (see
  [here](https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.0?version_id=5fcd0a50e0872efb3c38a32db140506da8310d87#simplified-subsumption)).
  This affects the use of the `freshBoundTermFn` function in `what4`'s
  `What4.Protocol.SMTWriter` module, as `freshBoundTermFn`'s type signature
  contains a nested `forall`. Fortunately, repairing this code is as simple as
  a single eta expansion.
* Raise the upper version bounds on `base` in `what4-abc` and `what4-blt` to
  permit building with `base-4.15` (bundled with GHC 9.0).
* Bump the `aig` submodule commit so that it does not emit `-Wstar-is-type`
  warnings when built with GHC 9.0, where `-Wall` implies `-Wstar-is-type`.
  Bump the `language-sally` submodule commit to allow building with
  `base-4.15` (see GaloisInc/language-sally#6).
2021-05-18 09:11:19 -04:00
Ryan Scott
af466fc8ba
Adapt what4-{abc,blt} to SolverEndSATQuery changes (#120)
This updates `what4-{abc,blt}` to use the new `SolverStartSATQueryRec`
and `SolverEndSATQueryRec` data types introduced in #111.

Fixes #119.
2021-05-10 16:04:09 -04:00
Kevin Quick
95f5b65f4d
[what4-abc] Update cabal for more recent specification version. 2021-03-14 10:19:28 -07:00
Rob Dockins
37b0fda645 Remove Nat base type from what4-abc 2021-02-08 09:49:14 -08:00
Rob Dockins
c2db803bb0 update what4-abc with changes to the floating-point terms 2021-02-04 12:01:25 -08:00
Brian Huffman
add42eeabc Avoid locally-defined text functions in favor of pretty. 2020-11-24 15:33:32 -08:00
Brian Huffman
0a1ec94056 Switch from ansi-wl-pprint to the prettyprinter package.
This patch converts packages `what4`, `what4-abc`, and `what4-blt`.
2020-11-23 06:39:59 -08:00
Rob Dockins
2fe09d5fd9 Various metadata updates.
* Update/imporove Haddock comments and bump copyright years

* Bump copyright dates in LICENSE files

* Add .cabal package lower bounds. These appear to be reasonable, but
I haven't exhaustively tested the various configurations.

* Bump copyright dates in .cabal files

* Start a basic changelog
2020-07-21 17:43:47 -07:00
Rob Dockins
72d105fd4e Add realTrunc and realRoundEven operations to fill out the
standard rounding modes.

Add test cases that prove the rounding operations satisfy their specifications.

Fixes #46
2020-06-15 17:09:19 -07:00
Ben Selfridge
213b23099c
migration to bv-sized representation (#34)
Update all `what4`-related packages to to concrete computation using the `bv-sized` library for fixed (but arbitrary) sized bitvector values.

Currently, the bitvector abstract domain computations are still being done directly on raw integers; we can revisit this in the future.

Co-authored-by: Ben Selfridge <benselfridge@000279.local>
Co-authored-by: Rob Dockins <rdockins@galois.com>
2020-06-04 15:07:57 -07:00
Rob Dockins
eeabb06e1a Update what4-abc with new abstract domain representation. 2020-05-08 08:49:36 -07:00
Rob Dockins
0a44276206 Relax base bounds for what4-abc and what4-blt 2020-05-07 13:09:38 -07:00
Rob Dockins
6340e3ad0c Add an Annotation term former to the NonceApp type,
and propigate changes to downstream packages.

Pipe the new annotation operation through the what4 interface
2020-04-02 10:27:02 -07:00
Rob Dockins
e9b5430a94 Update various .cabal files to upgrade certain warnings
to errors. These are: incomplete-patterns, overlapping-patterns, and
missing-methods.
2020-04-02 10:27:02 -07:00
Brian Huffman
60bb045365 what4: Remove DisjPred constructor.
We now represent disjunctions as negated conjunctions with negated
elements. This change makes it possible to significantly simplify
the definitions of the andPred and orPred operations.
2020-01-22 17:02:50 -08:00
Rob Dockins
2fb6f0c483 Fixes for GHC 8.8 builds. Mostly MonadFail related changes,
but a few other odds and ends as well.
2020-01-22 09:35:15 -08:00
Rob Dockins
f353e46be3 Use a custom datastructure for the bitwise OR of bitvectors rather
than abusing the structure for semiring products.
2020-01-13 14:55:44 -08:00
Rob Dockins
7b3ea17a91 Update what4 translators for SAW and ABC to fail on string operations 2019-11-14 17:08:45 -08:00
Rob Dockins
2941e6f07b Update downstream packages with String type updates 2019-11-14 17:08:44 -08:00
Rob Dockins
c5e7278af2 Add rotate operations to the ABC backend 2019-05-28 09:46:01 -07:00
Rob Dockins
7b7c79a632 Generalize the predToBV expression to bvFill, which construts a bitvector
of arbitrary length where every bit is defined by the input predicate.
2019-05-23 15:21:20 -07:00
Langston Barrett
3f37377ce3 Merge remote-tracking branch 'upstream/master' into travis-hlint-2 2019-05-08 09:53:58 -07:00
Langston Barrett
04a6db91e7 Fix additional language pragma whitespace, remove a few more 2019-05-01 14:44:56 -07:00
Langston Barrett
230502c784 (partially) fix hlint warning: Unused LANGUAGE pragma 2019-04-30 15:38:36 -07:00
Langston Barrett
c0e5e8305e fix hlint warning: Redundant $! 2019-04-30 13:15:54 -07:00
Rob Dockins
e55f5100c1 Add explicit representation for disjunction to What4 rather than
using negations and conjunction only.
2019-03-15 16:05:29 -07:00
Rob Dockins
7488b58fa1 Implement n-way conjunctions instead of a binary AND operator for
boolean formulae in What4.  This datastructure automatically implements
associative-commutative-idempotent rewriting as well as recognizing
resolution opportunities (i.e. A /\ ~A = False).
2019-03-15 12:38:20 -07:00
Rob Dockins
1e7dee2792 Enhance the representation of semiring products. We now explicitly
gather products.

In addition, use similar machenery to represent bitwise disjunction.
This gives additional boolean lattice reductions, including absorption
and idempotency.
2019-03-14 16:15:47 -07:00
Rob Dockins
5e6b187a31 Reorganize quite a few pieces of the What4 bitvector representation,
and generalize equality and if/then/else to work over all base types.

Bitvectors now are paricipants in two different semiring instances:
the usual arithmetic one and a bitwise one based on XOR and AND.
This allows automatic term gathering, XOR-canceling and other
similar simplifications to occur automatically.
2019-03-11 18:41:41 -07:00
Rob Dockins
4015ec8381 Continue refactoring to use Natural instead of Integer in
places where it makes sense.
2019-02-07 16:44:05 -08:00
Rob Dockins
772d3c2f2f Add popCount, countTrailingZeros and countLeadingZeros as new
bitvector operations in `what4`.

Solvers don't generally have primitives for these, but it is nonethess useful,
I think, to provide them as operations.  A collection of useful rewrites
could probably be added (e.g., interesting interaction with concat).
2018-12-20 14:35:58 -08:00
Rob Dockins
db251dc763 Update BLT and ABC support for what4 to handle cases where
variables are declared with bounds.
2018-12-13 14:25:32 -08:00
Kevin Quick
cdd3bb4476 Merge branch 'master' of github.com:GaloisInc/crucible 2018-11-15 12:22:42 -08:00
Jennifer Paykin
bf09ca6ff0 Updated remaining modules to work with updated LogData interface to what4 solvers 2018-11-13 18:51:02 -08:00
Kevin Quick
d51a6f96f7 Bump upper limits on base to allow GHC 8.6 compilation. 2018-11-06 13:18:54 -08:00
Rob Dockins
88c65dd54a Update to the text-interaction mode for SMT solvers.
This update fixes a variety of issues with solver interaction involving
the named assertion and unsat core updates.  CVC4, Z3 and Yices now will
properly issue queries and return resuts.

In addition, a variety of refactorings were made to the interaction code
that should make things more uniform going forward.  As part of these
refactorings, it is now possible to pass an "auxiliary output" file handle
when interacting with solvers.  If provided, solver commands and responses
will be echoed into this file for debugging purposes.
2018-10-31 10:39:43 -07:00
Rob Dockins
c64675f2f7 Modify the API for solver queries so that they take a list of predicates
instead of just a single predicate.  The semantics of the query is
just the conjunction of the given predicates.  However, for the purposes
of computing unsatisfiable cores, the list of given predicates
will be the atomic units that will either appear (or not) in the
generated unsat cores, for those solvers which support computing
unsat cores.
2018-10-08 10:52:27 -07:00
Rob Dockins
b13e0f36dc Add a new parameter to the SatResult data type for reporting
unsatisfiable cores when we get an UNSAT result.  Propigate
the minimum necessary changes.
2018-10-05 10:01:02 -07:00
Rob Dockins
e911897d72 Update what4 and crucible packages to make use of the new
solver event logging facilities.
2018-09-17 16:15:03 -07:00
Rob Dockins
e04f4878fe Remove the BVTrunc constructor from crucible-saw and what4-abc. 2018-09-11 14:22:30 -07:00
Rob Dockins
774902ef2d Fix incomplete pattern warning 2018-08-29 18:09:10 -07:00
Andrei Stefanescu
fe06682fe7 Floating-point improvements. 2018-08-28 14:00:21 -07:00
Rob Dockins
d7d601a872 Update crucible libraries to track what4 changes.
Additionally, minor related fixes in the SAWCore backend.
2018-08-14 16:19:47 -07:00
Rob Dockins
acda0fa7cb Stub-out and provide error messages for floating-point expressions in
ABC and Yices.
2018-08-13 13:40:40 -07:00
Rob Dockins
6716b6f45f Change the predToBV operation so that it is a full-fledged operator
in the expression builder.  That way, it can be fully elminated when
it encounters a `bvNonzero` or `bvTestBit` operation, etc.

This should remove some of the noisy patterns that otherwise arise,
especially from the LLVM translation, which uses length 1 bitvectors
as a stand-in for boolean values.
2018-08-08 15:10:36 -07:00
Rob Dockins
fd34b7e1d9 Various updates to the what4 integer, natural nubmer and bitvector theories.
This commit mainly does two things:

* Add more robust support for the integer theory, including `div`, `mod`, `abs` and `divisible`.
* Audit the semantics of the `integerToBV` operations, and fix lingering bugs.

In the past, there were two different integer->BV operations, because we used a clamping semantics,
and it made sense to have a signed versus unsigned distinction.  Now, however, we are using
a modulo `2^n` semantics, and there is only one operation.  However, some places in the code were
still using the clamped semantics.  These placses have now been cleaned up, and everywhere should
be using the modular arithmetic view.

In addition, I've reduced the need to use the expensive BV->Integer and Integer->BV coersions somewhat
by noticing when we round trip through those coercions more often and translating the result into
statements of modular arithmetic instead.

Along the way, I improved the abstract domain definitions for division and modulus.
2018-08-07 11:53:02 -07:00