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
Robert Dockins
cefc67a149
Implement signed division and remainder as methods of the Arith class.
...
Clarify the documentation that division is "round toward 0" division.
2017-08-16 17:34:22 -07:00
Robert Dockins
987e4a0c3b
Implement the type-level support required for the new SignedCmp
class.
...
This class will represent types that can be meaningfully compared for
signed bitvector equality. It lifts the comparison operations on
nonempty bitvectors through tuples, records and finite sequences via
lexicographic order.
2017-08-07 12:37:46 -07:00
Robert Dockins
2b9e5a2421
Add signed and unsigned bitvector extensions
2017-08-04 17:04:29 -07:00
Robert Dockins
9a3b64e088
Fix the definition of the signed borrow function
2017-08-04 17:03:23 -07:00
Robert Dockins
e3dd83066e
Rename signed bitvector operations to put the $
at the end
2017-08-04 17:02:10 -07:00
Robert Dockins
a68b835d51
Add operations for signed arithmetic, and carry condition testing.
2017-08-02 16:39:07 -07:00
Iavor Diatchki
e5fa174cbb
Add some axioms about width.
...
Fixes #387
2017-07-10 16:59:03 -07:00
Iavor S. Diatchki
0985508bbc
Add fin
constraints on the message mart of trace.
2017-06-16 09:58:11 -07:00
Brian Huffman
9a267b1f0c
Removed definition of binary infix (~) from Cryptol prelude. Fixes #423 .
...
This change partially reverts changeset c620cbf2
, which fixed #296 ,
which was about supporting `:t (~)` in the REPL.
As of this change, `:t (~)` will no longer work in the REPL.
The regression test for issue #296 is removed.
2017-05-24 09:39:50 -07:00
Brian Huffman
007c74cd97
Update doc-strings to mention syntactic sugar for complement and sequences.
2017-05-24 09:09:28 -07:00
Trevor Elliott
4dc5eda23a
Expand the width table, and fix a bug in CryptoBox (Thanks @tommd)
...
The width table in CryptolTC.z3 wasn't large enough to solve constraints
about the width of 64-bit words. This change is a bit of a band-aid, as
larger words will expose the same problem. Longer-term, we should try to
solve these constraints after the SMT-based phase, using some other
approach.
The constraints in CryptoBox were too permissive, and when adjusted to
represent the true intent (that values fit within 64-bits), and the
width table was updated, the example will type-check again.
Thanks to @tommd for tracking both of these down.
2017-03-27 13:45:50 -07:00
Iavor S. Diatchki
41131fe7ed
Redo the export to SMT story in a much simpler way.
2017-02-16 16:46:38 -08:00
Brian Huffman
67e730a07c
Merge branch 'master' into integer
2016-09-20 16:04:02 -07:00
Brian Huffman
dafd48cad0
Simplify type of primitive function 'pmult'. Fixes #366 .
...
Old: (fin a, fin b) => [a] -> [b] -> [max 1 (a + b) - 1]
New: (fin a, fin b) => [1 + a] -> [1 + b] -> [1 + a + b]
2016-09-20 15:13:40 -07:00
Brian Huffman
e4f958fbfa
Add primitives 'toInteger' and 'fromInteger'
...
These do not yet work with symbolic arguments. We will
need to first add support for these to SBV.
2016-08-19 10:17:36 -07:00
Brian Huffman
cb53109f33
Add primitive integer : {val} (fin val) => Integer
2016-08-18 14:26:29 -07:00
Robert Dockins
28d4f1d3fe
Modify 'updates' and 'updatesEnd' to take the indices and values
...
as separate vector arguments, rather than as a single vector
argument of pairs.
2016-08-16 14:36:46 -07:00
Robert Dockins
64267f51ac
Add the short-cutting boolean operators (/\), (\/), and (==>)
...
to the Cryptol prelude. This is in service of eventually addressing
issue #241 .
2016-08-12 17:12:34 -07:00
Robert Dockins
af0db1af38
Fix minor typo in the Cryptol prelude that was messing up the
...
help text for (!!)
2016-08-12 16:13:32 -07:00
Robert Dockins
785687a67f
Add new vector update primitives 'update' and 'updateEnd' which update
...
vectors at indices starting from the beginning/end of the vector,
respectively.
Included in this patch are implementations of these primitives
for the concrete evaluator. Symbolic primitives are TODO.
2016-08-12 12:10:48 -07:00
Brian Huffman
5b63ea2ad0
Add infix precedence declaration for (%). Fixes #362 .
2016-08-09 08:25:26 -07:00
Austin Seipp
e197497059
lib/extras: add iterate
...
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2016-07-18 09:01:45 +00:00
Robert Dockins
e0611c250d
More explict comments for the 'trace' and 'traceVal' Prelude operations.
2016-07-13 14:16:33 -07:00
Robert Dockins
998bddc7a7
Merge remote-tracking branch 'origin/master' into new-eval
...
Fix some minor conflicts in the test suite.
Conflicts:
tests/issues/issue002.icry.fails
tests/issues/issue148.icry.stdout
tests/issues/issue198.icry.stdout
tests/issues/issue214.icry.stdout
tests/issues/issue290v2.icry.stdout
tests/issues/issue312.icry.fails
2016-07-12 14:58:53 -07:00
Adam C. Foltzer
2c428804bc
remove splitBy
and update documentation
...
Closes #291
2016-07-05 09:58:49 -07:00
Robert Dockins
e31b4ba57d
WIP. Improve performance of the new evaluator.
...
To get acceptable performance, we need to be pretty aggressive about
using word representations instead of list-of-bits. Unfortunately,
with the new evaluator, this means we force things to be more strict
than is correct.
We are also still slower than the current evaluator. It is not
clear where the problems are.
2016-05-13 17:21:51 -07:00
Robert Dockins
7e968d2d18
WIP. New monadic Cryptol interpreter.
...
The concrete evaluator now seems to be working correctly,
but seems to suffer from major performace problems.
2016-05-12 18:44:06 -07:00
Robert Dockins
38946745c3
Add the 'lg2' type function as a synonym.
...
Fixes #248
2016-05-04 17:54:08 -07:00
Robert Dockins
c620cbf237
Update the parser to allow prefix operators in more places.
...
This allows us to define (~) as a prefix operator symbol synonym
for `complement`.
Fixes #296 .
2016-05-04 16:26:36 -07:00
Brian Huffman
1322156d28
Remove trailing whitespace
2016-02-19 10:08:20 -08:00
Adam C. Foltzer
4d3fc9a413
Update copyright dates and add missing headers
2016-01-19 18:19:35 -08:00
Adam C. Foltzer
da6916702b
split new Prelude definitions into Extras module
...
The definitions added in #299 cause a regression in Prelude typechecking
performance. Until we sort out the performance, we'll keep these
definitions in the module `Cryptol::Extras`.
2016-01-19 18:19:24 -08:00
Adam C. Foltzer
07da2018b7
switch to more portable seeding for random
...
The `random` primitive previously took a `[32]` seed, but this causes
inconsistency between 32-bit and 64-bit platforms when the seed is large
enough to wrap around in GHC's representation of an `Int`. This patch
switches to an API that seeds directly with four 64-bit words, and so
should behave the same way on our supported platforms.
2016-01-19 18:17:34 -08:00
Thomas M. DuBuisson
68f71ed3b3
Add some Haskell-like prelude functions.
...
Implication (==>), not, and, or, all, any, map, foldl, sum, scanl, extend,
extendSigned, foldr, scanr, zip, zipWith, repeat, curry, uncurry, and elem.
Rationale:
I've had to implement these functions several times for different problems.
While my problems were admittedly toy, not cryptographic, the functions are
generally applicable and unlikely to clash with many, if any, preexisting
operations of different semantic meaning.
2016-01-19 18:15:49 -08:00
Brian Huffman
e87d0469ab
Fix incorrect docstrings for polynomial operations
...
pmult, pdiv, and pmod are not specific to GF(2^^8);
they work on polynomials of arbitrary size with
elements drawn from GF(2).
2015-12-31 09:46:13 -08:00
Thomas M. DuBuisson
6a7477ba6c
Half-fix but not quite issue #256 (Bool ~> Bit).
...
We should probably discuss why we want to call things "Bool" if this was
more concious than incidental. That and change the documentation to
match.
2015-07-03 14:19:56 -07:00
Trevor Elliott
9b7e46724c
Give 100 fixity levels, and fix prelude fixity again
...
Also fix issue198, which had been accidentally updated while failing
2015-06-10 11:55:54 -07:00
Trevor Elliott
9305e769d4
Properly resolve constraint fixity
2015-06-09 14:18:25 -07:00
Trevor Elliott
3fc9d66fc1
Change the precedence of xor
2015-06-09 09:35:35 -07:00
Trevor Elliott
e119b72efd
More fixity, and add back special error messages
2015-06-08 17:54:02 -07:00
Trevor Elliott
0eefd18437
More consistent output in the REPL
2015-06-08 17:36:41 -07:00
Trevor Elliott
4b323b8446
Remove primitives
2015-06-08 16:00:14 -07:00
Trevor Elliott
745ea639af
Start migrating primitives to the prelude
2015-06-05 15:47:12 -07:00
Trevor Elliott
a736f740f9
Parse doc strings, and attach them to declarations
2015-06-04 18:35:12 -07:00
Trevor Elliott
b96859ba5f
Implement + as a primitive in the prelude
2015-06-03 22:29:36 -07:00
Adam C. Foltzer
0536d0f15a
update copyright years
2015-03-24 11:19:52 -07:00
Adam C. Foltzer
ba0a0e8576
Initial import from internal repo
2014-04-17 15:34:25 -07:00