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
Brian Huffman
9fcb481161
Generalize [x,y...]
(infFromThen
primitive) to class Arith
.
2018-06-21 18:24:12 -07:00
Brian Huffman
4697683ac4
Generalize [x...]
(i.e. infFrom
primitive) to class Arith
.
2018-06-21 17:57:13 -07:00
Brian Huffman
86898c1076
Remove now-redundant primitive toZ
; use fromInteger
instead.
2018-06-21 17:05:33 -07:00
Brian Huffman
dbd05b5acc
Generalize prelude function fromInteger
to class Arith
.
2018-06-21 16:59:01 -07:00
Iavor Diatchki
0d81f0ba25
Implement defaulting in the presence of overloaded literals.
2018-06-20 15:06:19 -07:00
Brian Huffman
47df3e69b9
Remove obsolete primitives integer
and intmod
.
...
Use the generalized `demote` instead.
2018-06-18 18:09:03 -07:00
Brian Huffman
7424731e3f
Generalize [a,b..c]
to work for types in class Literal
.
2018-06-15 17:45:57 -07:00
Brian Huffman
cbba44f692
Generalize [a..b]
to work for types in class Literal
.
2018-06-15 17:17:54 -07:00
Brian Huffman
01667d8486
Merge branch 'master' into literal-class
...
# Conflicts:
# lib/Cryptol.cry
2018-06-15 11:10:11 -07:00
Brian Huffman
a7b69892f1
Add primitives toZ
and fromZ
for converting integers to/from Z n
.
2018-06-15 10:13:09 -07:00
Brian Huffman
570f0be2ea
Remove redundant fin
constraint from the type of demote
.
...
`fin bits` and `bits >= width val` together imply `fin val`.
2018-06-14 12:33:20 -07:00
Brian Huffman
dda5d34131
Fix constraints on type of primitive intmod
.
...
The old type did not forbid literals of the invalid type `Z inf`.
2018-06-14 12:24:32 -07:00
Brian Huffman
5ac32d1ad5
Add a variant of the demote
primitive for type Z n
.
...
intmod : {val, mn} (fin val, n >= val + 1) => Z n
2018-06-14 06:17:51 -07:00
Brian Huffman
b3d2851923
Merge branch 'master' into literal-class
...
# Conflicts:
# src/Cryptol/TypeCheck/Kind.hs
# src/Cryptol/TypeCheck/Solve.hs
2018-06-13 11:41:35 -07:00
Brian Huffman
ab000984d2
Remove redundant prelude functions not
, extend
, and extendSigned
.
...
These were recently moved here from Cryptol::Extras. They are duplicates
of existing functions `complement`, `zext`, and `sext`.
See #427 .
2018-05-24 14:41:09 -07:00
Brian Huffman
960143668d
Formatting code and comments in Cryptol.cry.
2018-05-24 13:23:26 -07:00
Aaron Tomb
99f3fdbf37
Merge Cryptol/Extras.cry with Cryptol.cry
...
Closes #427 .
2018-05-23 15:55:05 -07:00
Brian Huffman
e8a941ecbd
Add prelude docstrings for 'head' and 'last'.
2018-04-18 17:01:24 -07:00
Brian Huffman
3be72ae2cb
Replace indexing primitives (!!) and (@@) with cryptol implementations.
2018-04-18 16:50:39 -07:00
Brian Huffman
2cdf9bd159
Replace primitives pmult, pmod, pdiv with cryptol implementations.
2018-04-15 06:56:20 -07:00
Brian Huffman
5cd9141fe7
Add functions head
and last
to Cryptol prelude. Fixes #465 .
...
Also fix regression test output.
2018-03-16 15:10:36 -07:00
Brian Huffman
951eebb8e2
Add more documentation of Cryptol prelude primitives.
2017-11-15 11:37:06 -08:00
Brian Huffman
5eb67c0513
Introduce class Literal
and generalize primitive demote
to use it.
...
demote : {val, a} Literal val a => a
instance (fin val) => Literal val Integer
instance (fin val, fin bits, bits >= width val) => Literal val [bits]
2017-11-08 15:23:08 -08:00
Brian Huffman
3b03545552
Merge branch 'master' into blocks-padding
2017-10-03 13:44:32 -07:00
Rob Dockins
c0699e2d62
Change the fixity levels of (||) and (&&).
...
This advances the next step in the plan described in issue #241 .
2017-10-02 14:56:33 -07:00
Brian Huffman
cce32a4868
Merge branch 'master' into integer
...
This brings the Logic and Zero type classes into the integer branch.
2017-09-28 13:18:27 -07:00
Brian Huffman
7e34c25e4d
Switch to infix syntax for blocks
and padding
operators.
...
"x /^ y" is x/y rounded up, i.e. the least n such that x <= y*n.
"x %^ y" is the least k such that x+k is a multiple of y.
For comparison,
"x / y" is x/y rounded down, i.e. the greatest n such that x >= y*n.
"x % y" is the least k such that x-k is a multiple of y.
The new syntax is much more suggestive of the relation to "/" and "%".
2017-09-28 10:26:31 -07:00
Brian Huffman
9bc6d02019
Implement blocks
and padding
operators for numeric types.
...
The design is as described in issue #96 :
blocks msgLen blockSize = the least n such that msgLen <= blockSize * n
padding msgLen blockSize = least k such that msgLen + k divides blockSize
or alternatively:
msgLen + padding msgLen blockSize = blocks msgLen blockSize * blockSize
2017-09-27 13:43:26 -07:00
Brian Huffman
b03f1ae0c2
Add class Zero
with zero :: {a} (Zero a) => a
.
...
Shift operators also have a `Zero` constraint on the element type.
2017-09-15 16:37:44 -07:00
Brian Huffman
a52510e56b
Add 'Logic' class constraints to Cryptol::Extras
2017-09-15 13:38:43 -07:00
Brian Huffman
d1305b2860
Add 'Logic' typeclass with operations complement, &&, ||, ^, zero.
...
Left and right shift operations also gain a Logic constraint,
since they shift in zero values.
2017-09-15 13:33:56 -07:00
Brian Huffman
5d73b5d405
Merge branch 'master' into integer
...
This involved plenty of non-trivial merge edits to fix compilation errors.
# Conflicts:
# src/Cryptol/Eval.hs
# src/Cryptol/Eval/Value.hs
# src/Cryptol/Prims/Eval.hs
# src/Cryptol/Symbolic/Prims.hs
# src/Cryptol/Symbolic/Value.hs
# src/Cryptol/TypeCheck/AST.hs
2017-09-13 14:28:04 -07:00