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
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