Commit Graph

1789 Commits

Author SHA1 Message Date
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
defadf8730 Fix cut-and-paste error. 2017-09-28 09:45:40 -07:00
Brian Huffman
1e41541405 Let type checker discharge fin (blocks x y) and fin (padding x y).
Both of these type operators are always either finite or undefined.
2017-09-28 09:28:07 -07:00
Fabian Beuke
ab75f152d1 Update copyright notice year from 2016 to 2017 2017-09-28 16:18:00 +02:00
Iavor Diatchki
3f80cc92f9 Checkpoint: not complete, commit to continue WFH 2017-09-27 16:43:00 -07:00
Brian Huffman
f04908a551 Adapt example code to use new blocks and padding operators. 2017-09-27 13:55:55 -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
Iavor Diatchki
aab03be26a More wibbles 2017-09-27 10:24:30 -07:00
Iavor Diatchki
208119fbbf Merge branch 'master' of github.com:GaloisInc/cryptol 2017-09-27 10:17:06 -07:00
Iavor Diatchki
6018af3537 Just documentation 2017-09-27 10:16:58 -07:00
Iavor Diatchki
920cb58ad0 Some cleanup and doubt that I've enconded the algorithm correctly 2017-09-27 09:50:47 -07:00
brianhuffman
c32d68dade Merge pull request #445 from GaloisInc/logic-class
Introduce a `Logic` class for bitwise logical operations
2017-09-27 09:10:47 -07:00
Brian Huffman
1ed5640339 Merge branch 'master' into logic-class
# Conflicts:
#	tests/mono-binds/test05.icry.stdout
2017-09-26 16:50:53 -07:00
Iavor Diatchki
8ea27a3c24 Keep track of tparam types; make bound vars be just tparams.
The two are very similar anyway, so it makes sense to merge the types.
This also helps display module type parameters using their name, rather
than treating them as unknown variables.

The whole printing of names system is still quite confusing, so maybe
there is a better way to do this, but keeping track of the source of
type parameters seems potentially useful information anyway...
2017-09-26 16:30:02 -07:00
Iavor Diatchki
b8707033d7 Add module parameters as extra vars---prints nicer error messages. 2017-09-26 15:29:23 -07:00
Iavor Diatchki
83d0132e50 Add module-level constraints to assumptions when proving implications. 2017-09-26 15:21:40 -07:00
Iavor Diatchki
12ee62ff9d Merge branch 'master' into abstract-types
# Conflicts:
#	src/Cryptol/TypeCheck/Solver/SMT.hs
2017-09-26 15:21:18 -07:00
Iavor Diatchki
60523d5986 Delete old solver stuff.
The main user visible effect of this might be that sometime things on
the Cryptol command line are instantiated in a slightly different way:
we get `inf` sometimes when we got a finite example before.

We could work around this if it is an issue, but I am not sure which
behavior is more reasonable.
2017-09-26 14:02:52 -07:00
Iavor Diatchki
8e7aff62b4 Checkpoint, adding constraints 2017-09-26 10:23:34 -07:00
Iavor Diatchki
7dc1ffc456 Some support for constraints on parameters. 2017-09-25 15:37:50 -07:00
Iavor Diatchki
2c07a55d15 Add call stacks here and there 2017-09-25 15:37:22 -07:00
Iavor Diatchki
9f3f592a2f Add a 5 second time-out to calls to z3 2017-09-25 11:41:20 -07:00
Iavor Diatchki
ccc4b828c2 Represent type parameters as just type variables. 2017-09-25 11:41:00 -07:00
Iavor Diatchki
019d935c2f Merge branch 'master' into abstract-types
# Conflicts:
#	src/Cryptol/Parser/Lexer.x
#	src/Cryptol/Parser/LexerUtils.hs
#	src/Cryptol/TypeCheck/Depends.hs
#	src/Cryptol/TypeCheck/Infer.hs
#	src/Cryptol/TypeCheck/Kind.hs
#	src/Cryptol/TypeCheck/Solver/SMT.hs
2017-09-22 16:23:12 -07:00
Brian Huffman
36f8fff3ca Support Integer type in reference evaluator (:eval). 2017-09-22 15:45:43 -07:00
Iavor Diatchki
0cc5151e6d Correct the handling of TCAnd in the SMT translation 2017-09-22 10:43:02 -07:00
Iavor Diatchki
9432f33ca1 Add some missing method defintions 2017-09-22 10:10:04 -07:00
Brian Huffman
1d71fa141c Merge branch 'master' into integer 2017-09-21 17:05:00 -07:00
Brian Huffman
d545abceec Fix incomplete pattern match warning caused by merge. 2017-09-21 16:47:36 -07:00
Brian Huffman
2c4157ecd4 Merge branch 'master' into logic-class 2017-09-21 16:44:39 -07:00
Iavor S. Diatchki
bec59d2faa On my computer this is only trustworthy. strange 2017-09-21 14:58:12 -07:00
Iavor S. Diatchki
d1abac0cec Update design; handle numeric type parameters in type checking SMT 2017-09-21 14:57:53 -07:00
Brian Huffman
2ce1ca3eca Change constraint synonym syntax from "constraint" to "type constraint".
For example:

type constraint NonZero n = (fin n, 1 <= n)

last : {n, a} NonZero n => [n]a -> a
last xs = xs!0
2017-09-21 13:21:51 -07:00
Brian Huffman
393a11e170 Implement constraint synonyms (#373).
The syntax is just as described in ticket #373: We have a new
declaration form consisting of the keyword 'constraint' followed
by a identifier and optionally a list of type parameters; the
right-hand side is either a single constraint or a parenthesized,
comma-separated list of type constraints. For example:

constraint NonZero n = (fin n, 1 <= n)

last : {n, a} NonZero n => [n]a -> a
last xs = xs!0
2017-09-21 09:40:22 -07:00
Iavor Diatchki
f7e1a941e2 checkpoint 2017-09-21 09:28:01 -07:00
Brian Huffman
c4af07a053 Remove unused TokenKW constructors. 2017-09-20 11:38:36 -07:00
Iavor Diatchki
c3882a79b5 Named instantiations 2017-09-19 14:47:40 -07:00
Iavor Diatchki
9f2a2ac3a4 Incomplete example of using 'abstract' types. 2017-09-19 14:28:08 -07:00
Iavor Diatchki
9d0092cfd9 Typos and language fixes 2017-09-19 10:32:08 -07:00
Iavor Diatchki
dd46e174e0 Another iteration of the design. 2017-09-19 10:25:17 -07:00
Brian Huffman
b4cf793e7f Adapt fastSchemaOf function to avoid simplifying when instantiating props.
Previously, checking the type of e.g. "(&&) `{[2]b}" would not return
"(Logic [2]b) => [2]b -> [2]b -> [2]b" as expected, but
"Logic b => [2]b -> [2]b -> [2]b". This made it impossible to reconstruct
the instances necessary to produce the required Logic dictionary when
translating to saw-core.
2017-09-18 15:54:35 -07:00
Iavor Diatchki
4bbf2fbb5a Some notes no how the design might work. 2017-09-18 15:04:08 -07:00
Brian Huffman
c6db409837 Add type-matching functions pIsZero and pIsLogic. 2017-09-15 21:50:21 -07:00
Brian Huffman
35423d0243 Update test output. 2017-09-15 16:38:03 -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
Iavor Diatchki
b5196dfb44 Remove warnings, moudule is safe 2017-09-15 16:05:26 -07:00
Iavor Diatchki
f3a3b1cbd0 Start on implementing abstract types/constants (module parameters) 2017-09-15 16:05:16 -07:00
Brian Huffman
860060c085 Fix test output. 2017-09-15 14:05:27 -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