Commit Graph

129 Commits

Author SHA1 Message Date
Rob Dockins
7b0f69de28 Implement an experimental parmap operation.
This is semantically the same as `map` on finite sequences,
but forks a separate Haskell thread for each element of the sequence.
When the GHC runtime is instructed to use multiple OS threads,
data-parallel exeuction can be achieved.
2020-07-09 10:54:03 -07:00
robdockins
87d5edab00
Documentation updates (#779)
* Add docstrings for all prelude functions and fix minor style issues.

Fixes #771

* Update `CryptolPrims` documentation

* Minor updates to the prelude

* Update CHANGES

* Updates to the cryptol book and CryptolPrims

* Fix several additional docstrings

* Specify and document properties of signed bitvector division.

Fixes #677

* Fixup test

* typos and style

* Regenerate PDFs
2020-06-30 10:58:25 -07:00
Iavor Diatchki
0047eaf77a Initial support for floating point computation 2020-06-29 15:31:34 -07:00
Rob Dockins
d2490e724f Implement roundToEven and roundAway.
The old `round` operation is renamed into `roundAway` to make its
semantics more obvious.
2020-06-25 13:52:36 -07:00
Rob Dockins
332a0a3fdc Add an assert combinator to the prelude.
Fix up fragile test outputs.
2020-06-19 12:11:29 -07:00
Rob Dockins
6bedcbb4b3 Add a new Eq typeclass for types that have equality tests.
The `(==)` and `(!=)` operators move into the new `Eq` typeclass,
which becomes a superclass of `Cmp` and `SignedCmp`.
2020-06-19 12:00:12 -07:00
Rob Dockins
88c98c4c03 Merge remote-tracking branch 'origin/master' into split-arith
Minor merge conflicts resolved.
2020-06-03 13:35:04 -07:00
Andrei Stefanescu
2ff4d4c031
Fix Array.cry comment. (#748) 2020-06-02 20:26:49 -07:00
Andrei Stefanescu
c1bdd77ff0
Add SMT Array primitives. (#732)
* Add SMT Array primitives.

* Move SMT Array primitives in Array.cry.

* Minor.
2020-06-02 15:00:25 -07:00
Rob Dockins
542debdb67 Documentation tweaks 2020-05-27 14:21:17 -07:00
Rob Dockins
8c6f8dcbe9 Reimplement (^^) as a primitive taking the exponent in class Integral 2020-05-26 15:13:08 -07:00
Rob Dockins
7f7fc813e6 Add a Literal first a constraint to fromTo.
This more clearly communicates the intent, which is that both
endpoints of the enumeration must be literals of the type
being enumerated.
2020-05-26 11:43:48 -07:00
Rob Dockins
e78757199e remove Z n types from class Integral 2020-05-26 11:38:59 -07:00
Rob Dockins
85e49a92db Rearrange the Cryptol prelude according to the new typeclass system 2020-05-22 15:39:38 -07:00
Rob Dockins
cfe790c13b Implement a new primitive type Rational.
Rational numbers are implemented as a pair of integers via the usual construction.
2020-05-14 17:48:54 -07:00
Rob Dockins
3eb31b904a Tweak the prelude 2020-05-14 16:08:01 -07:00
Rob Dockins
f6b929ace4 Implement (^^) via square-and-multiply rather than making it a primitive. 2020-05-14 09:23:58 -07:00
Rob Dockins
ada7f8ee9c Fix errors in prelude modifications 2020-05-13 13:25:37 -07:00
Rob Dockins
941f5a6b02 Revert "Remove the SignedCmp class and specialize the signed comparison operations"
This reverts commit ba99cc4924.
2020-05-13 09:39:29 -07:00
Rob Dockins
ba99cc4924 Remove the SignedCmp class and specialize the signed comparison operations
to bitvector types.
2020-05-12 17:42:52 -07:00
Rob Dockins
fdf52a64a5 Update Cryptol.cry based on discussions 2020-05-12 17:41:45 -07:00
Rob Dockins
625ee990dc Update Cryptol.cry with concrete design changes to support splitting the Arith class 2020-05-12 12:46:09 -07:00
Iavor Diatchki
c3eca4f22a Check that the declared type of prims matches the expected one.
Fixes #711
2020-05-05 14:30:25 -07:00
Brian Huffman
0203244cd6 Redefine prelude function iterate to preserve sharing.
Fixes #707.
2020-04-18 08:12:40 -07:00
Rob Dockins
f016a9a9fc Define carry and scarry instead of making them primitive. 2020-03-17 13:25:39 -07:00
Iavor Diatchki
a0b4b14f86 Make constraints on type constructors/functions explicit.
This is mostly working, but I still need to update the help on the REPL
to show the constraints.
2019-07-03 17:03:31 -07:00
Iavor Diatchki
971897d9ca Use 'Prop' instead of '@' to write the kind of a constraint.
This is more consistent with how we've been printing kinds for a while,
so no need to change the notation.
2019-07-03 10:21:04 -07:00
Iavor Diatchki
72068cb961 Move type-level primitives to the Prelude.
For the time being, there is still some information about them that
is duplicated in Cryptol.TypeCheck.TCon, but we at least the parsed syntax
does not depend on the typechecked syntax.
2019-07-02 17:34:36 -07:00
Brian Huffman
1e11ff6b8b Add type constraint synonyms (<) and (>).
Fixes #400.
2019-06-26 20:44:13 -07:00
Brian Huffman
10da255fd1 Re-implement infix type constraint (<=) as a constraint synonym.
Also removed special-case hack for (<=) in the renamer.

Also adapted test case output to account for the new prelude declaration.
2019-06-26 18:04:16 -07:00
Brian Huffman
69ebb77a56 Support indexing on the left-hand sides of declarations.
The declaration `xs @ i = e` is syntactic sugar for
`xs = generate (\i -> e)`.
2019-06-18 16:11:01 -07:00
Brian Huffman
2df66aa7c1 Add function generate to Cryptol prelude.
generate : {n, ix, a}
  (fin ix, n >= 1, ix >= width (n - 1)) => ([ix] -> a) -> [n]a
generate f = [ f i | i <- [0 .. n-1] ]
2019-06-18 15:39:13 -07:00
Brian Huffman
97fadf2c58 Update doc-strings for Cryptol prelude arithmetic operators.
Fixes #601.
2019-05-30 18:48:03 -07:00
Brian Huffman
7ea4884fdd Remove unused primitive type operator lengthFromThen. 2019-02-27 17:11:18 -08:00
Brian Huffman
24fb6c9511 Remove unused primitive fromThen. 2019-02-27 16:57:00 -08:00
Iavor Diatchki
5bad18d3d7 Fix broken library: constants must start with an identifier! :) 2019-01-09 11:31:25 -08:00
Iavor Diatchki
f0e9dcf471 Just a different example.
This used to work with Z3 4.7.1 but does not with 4.8.4
2019-01-09 11:26:53 -08:00
Iavor Diatchki
454dd58fbd Name some of the big numbers. 2019-01-09 11:26:14 -08:00
Brian Huffman
20b9b1c193 Rename prelude function width to length, and generalize its type.
Fixes #550.
2018-10-10 16:21:38 -07:00
Iavor Diatchki
ad766b3aa7 Reformulate the property, so that Z3 can still find models.
With the other formulation, Z3  became really bad at finding any kind
of model.  Basically, it would always answer `unsat` or `unknown`.

This is undesirable, because we use models when instantiating things
at the command line.  In those cases, however, we probably don't
need the rule at all...  Perhaps, we should provide a way to disable
the axioms when we are looking for models?
2018-09-15 11:04:37 +03:00
Iavor Diatchki
a8d5963bfa Add another property of width.
Fixes #548
2018-09-14 22:50:30 +03:00
Iavor Diatchki
4e843a3435 More consistent statement of axioms for cryWidthUnknown 2018-09-14 10:21:08 +03:00
Brian Huffman
9b97c74b48 Polishing of :help output.
:help with primitive types now uses vertical whitespace to match
the :help output for other types.

Help text for REPL commands can now contain linebreaks.

For quoted Cryptol syntax in docstrings, consistently use singlequotes
(') instead of backquotes (`). Backquotes are sometimes used within
the quoted code, so it's probably best to avoid using them for quotes.

Consistently capitalize and put a period at the end of docstrings.
2018-07-31 11:33:50 -07:00
Brian Huffman
9e7ae9f9ce Reintroduce demote as a copy of number for backward compatibility. 2018-07-27 14:01:18 -07:00
Brian Huffman
f609b36225 Rename primitive demote to the more self-explanatory name number.
The name "demote" is only meaningful to those who already know what
the Cryptol primitive does. Also, due to recent changes in the error
and warning messages, the name "demote" is showing up much more often
in REPL output. For example:

    Defaulting type argument 'rep' of 'demote' to [2]

    Showing a specific instance of polymorphic result:
      * Using 'Integer' for type argument 'rep' of 'Cryptol::demote'

These messages will hopefully be made less confusing to non-experts
if the name "demote" is replaced with "number".
2018-07-27 13:52:57 -07:00
Brian Huffman
ed757860bf Fix typos in Cryptol prelude docstrings. 2018-07-20 15:34:13 -07:00
Brian Huffman
95cedc3135 Send symbolic typechecking goals involving != to the SMT solver.
Fixes #528.
2018-07-18 18:35:50 -07:00
Brian Huffman
56824291b2 Add inequality constraints to types of fromThen and fromThenTo.
This ensures that all applications of partial type functions are
well-defined.

Fixes #416.
2018-07-11 12:58:49 -07:00
Brian Huffman
836771aded Tweak names and order of type variables on Cryptol prelude functions.
Also update test output for new type variable names.

See #517.
2018-06-28 14:14:44 -07:00
Brian Huffman
a4a3207f9f Swap type argument order for zext and sext.
The new argument order works better for partial type application,
so e.g. zext`{32} extends its argument to 32 bits.
2018-06-28 10:40:37 -07:00