Commit Graph

1291 Commits

Author SHA1 Message Date
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
2e1dbad005 Improve tab completion for :set command. Fixes #154.
Tab now completes option names after `:help :set`.

Tab also completes `:help` with names of primitive types
and type classes (cf. #504).
2018-07-30 18:11:14 -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
35ccec83ce Fix some typos in comments/docs. 2018-07-27 13:17:45 -07:00
Iavor Diatchki
30b281dbff Fix build on older GHCs 2018-07-27 09:09:45 +03:00
Iavor Diatchki
6d789a1d64 Preserve prefix - and ~ until the renamer.
This allows to print back expressions in a form that looks more like what
the user typed.  Fixes #541
2018-07-26 22:04:45 +03:00
Iavor Diatchki
fb4080a22e Merge branch 'master' of github.com:GaloisInc/cryptol 2018-07-26 09:28:06 +03:00
Iavor Diatchki
96539178d4 Display help for built-in types in REPL.
Fixes #504
2018-07-26 09:27:11 +03:00
Iavor Diatchki
19c71fa4aa Move all built-in types to the same place; add precedence and documentaiton 2018-07-26 09:06:37 +03:00
Brian Huffman
2f53f364b5 Add stderrLogger to go with stdoutLogger. 2018-07-25 10:10:52 -07:00
Iavor Diatchki
f4e7100e59 Merge branch 'master' of github.com:GaloisInc/cryptol 2018-07-25 13:27:14 +03:00
Iavor Diatchki
5a720e6695 Use proveModuleTopLevel instead simplifyAllConstraints.
The difference is that the one does defaulting as well.  Fixes #540
2018-07-25 13:27:01 +03:00
Brian Huffman
165674710b Fix typo in comment. 2018-07-24 15:42:16 -07:00
Brian Huffman
1af977873e Make :browse <interactive> work with tab-completion, no warnings. 2018-07-24 15:29:58 -07:00
Iavor Diatchki
e55436eaa7 Keep track of user vs. system names.
This makes it possible to hide system names from the users,
as they are not really meaningful.  Fixes #535
2018-07-24 18:19:17 +03:00
Iavor Diatchki
125a2a4d32 After defaulting, nub the resulting fin constraints.
Fixes #531
2018-07-24 16:52:15 +03:00
Iavor Diatchki
d1b5439b4c Remove defSu, this is already part of totSu, as we've extended it 2018-07-24 16:51:28 +03:00
Iavor Diatchki
83ece9e3fb Fixes #532 2018-07-24 16:00:55 +03:00
Iavor Diatchki
9f94dd0eba Merge branch 'master' of github.com:GaloisInc/cryptol 2018-07-24 15:29:27 +03:00
Iavor Diatchki
b6d6ead7f1 Fixes related to generalization in recursive groups, where some bindings are monomorphic.
This is tricky stuff, hopefully this better.  Fixes #534
2018-07-24 15:29:06 +03:00
Brian Huffman
3cee1b037e Memoize wordValLogicOp on BitsVal arguments.
This fixes the exponential runtime for the example in #537.
2018-07-23 14:44:48 -07:00
Iavor Diatchki
9a9e9c977c A bit of refactoring.
This should help us hide top-level generated names that are
not of interest to the user.
2018-07-23 03:34:04 -07:00
Iavor Diatchki
bd0d3ccf35 Remove unused code, add explicit exports 2018-07-23 03:32:31 -07:00
Iavor Diatchki
f398a68fad When applying a defaulting substitution, keep going even if value found.
Since our substitutions are idempotent, normally this would be just wasted
work, but when we are defaulting, we must make sure that we default the
varibales in the looked up thing also.

This fixes #534
2018-07-23 03:30:52 -07:00
Brian Huffman
09bb438021 Avoid type mismatch panic when printing counterexamples. Fixes #533. 2018-07-20 12:03:51 -07:00
Brian Huffman
5def499908 Capitalize sentences in output of :check and :exhaust. 2018-07-20 10:55:24 -07:00
Brian Huffman
409e544772 Restrict polynomial literals to bitvector types. Fixes #530. 2018-07-20 10:06:16 -07:00
Brian Huffman
abbce5405c Tweak fix for #494: it should never say an equation is unsolvable. 2018-07-19 18:01:12 -07:00
Brian Huffman
b19cac5fab Add simplification rule: t1 == min (K + t1) t2 ~> t1 == t2, if K >= 1.
Fixes #494.
2018-07-19 15:07:21 -07:00
Brian Huffman
a66338293a Memoize result of binary logic operators on LargeBitsVal arguments.
Fixes #446.

This fix is very similar to the one for #514, which added memoization
for symbolic if-then-else on sequences. This is another instance where
a SeqMap is created where each lookup triggers two further lookups,
causing exponential runtime behavior in the worst case.
2018-07-18 23:02:27 -07:00
Brian Huffman
ec7c44d36e Fix typo in comment. 2018-07-18 22:57:12 -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
f98903e739 Fix typo in comment. 2018-07-18 18:34:56 -07:00
Brian Huffman
f4ce1a46f0 Fix typo in comment. 2018-07-18 17:53:47 -07:00
Brian Huffman
7259507d04 Unifier now returns a substitution even on unification failure.
For example, when type checking `[1..10]:[6][8]`, `mgu` would be called
on [10]?a and [6][8], and `mgu` would return the substitution `?a = [8]`
and the mismatch error `10 != 6`.

Fixes #525.
2018-07-18 14:01:30 -07:00
Brian Huffman
7a307a704d Add bounds assumptions for solver queries about type Z n.
Fixes #526.
2018-07-17 16:20:26 -07:00
Brian Huffman
c925a82dce Update function toExpr for new type of demote primitive.
Also avoid using removed primitive `integer`.

Previously this caused a panic when printing counterexamples
of type Integer.
2018-07-17 16:00:50 -07:00
Brian Huffman
751bb4e7e1 Further avoid printing constructors "Nat" and "Inf" in error messages. 2018-07-17 14:56:04 -07:00
Brian Huffman
3ed98578de Avoid printing constructor names "Nat" and "Inf" in error messages. 2018-07-13 12:09:24 -07:00
Brian Huffman
531be1145e Merge branch 'master' of github.com:GaloisInc/cryptol 2018-07-13 11:57:37 -07:00
Iavor Diatchki
6f67924894 Add some more simplification on user defined signatures.
This is not great, but since we do it, we should do it more consistently.
Avoids a panic in the bench mark suite (more generally, when users write
trivial things in their type signatures, eg. see `pad` in SHA512)
2018-07-13 11:00:21 -07:00
Iavor Diatchki
021e71bd82 Add some missing cases. 2018-07-12 14:28:45 -07:00
Iavor Diatchki
6f3c855ef6 Tuples are now indexed from 0, so selector 3 is really the 4th field of a tuple 2018-07-12 14:28:35 -07:00
Iavor Diatchki
7c74ed2daf Fixes #524 2018-07-12 14:27:54 -07:00
Brian Huffman
5f795d4644 Restrict output number base to 2, 8, 10 and 16.
The output bases now match the possible input bases for
numeric literals.

Fixes #179.
2018-07-12 09:57:41 -07:00
Brian Huffman
a1bb918840 Command ":help :set <option-name>" prints help text for settable option.
This mostly takes care of #154, but we still need tab-completion.
2018-07-12 09:27:44 -07:00
Brian Huffman
844e80085d Print ambiguous command warning for :help with ambiguous command name.
For example:

Cryptol> :help :c
:c is ambiguous, it could mean one of:
	:cd, :check

Previously we would print the help text for all matching commands,
which was a bit much.
2018-07-12 08:07:23 -07:00
Brian Huffman
b302dc044e Make :help print documentation for other REPL commands.
For example, `:help :sat` prints documentation for the :sat command.
2018-07-11 17:51:37 -07:00
Iavor Diatchki
0739448933 Do and-goal splitting in more places.
This alleviates some of the problems in #522
2018-07-11 15:18:08 -07:00
Brian Huffman
5ba712bde3 Add concrete type-level syntax m != n for inequality constraints. 2018-07-11 12:52:32 -07:00
Brian Huffman
b8ecb4abbe Fix typo in comment. 2018-07-11 04:52:55 -07:00
Iavor Diatchki
1666ea3bd0 Merge branch 'master' of github.com:GaloisInc/cryptol 2018-07-10 17:05:37 -07:00
Iavor Diatchki
2f00384038 Fixes #521 2018-07-10 17:05:31 -07:00
Brian Huffman
be8c334efe Reference interpreter uses base and infLength printing options.
Fixes #412.
2018-07-10 09:58:37 -07:00
Brian Huffman
186e2a0a82 Reference evaluator tracks lengths of list values. 2018-07-10 09:35:06 -07:00
Brian Huffman
ca62acc727 Remove non-primitives @@ and !! from reference evaluator prims. 2018-07-10 09:30:49 -07:00
Brian Huffman
ee2d2ec9c4 Fix typo in comment. 2018-07-10 08:47:53 -07:00
Brian Huffman
f3a9a7ceb7 Fix typo in typechecker error message. 2018-07-09 18:30:38 -07:00
Brian Huffman
fe4b2d9f70 Update tab-completion for :help to also complete type names. 2018-06-29 16:28:52 -07:00
Brian Huffman
99773d71b7 Memoize result of symbolic if-then-else on sequence types.
It is important that we memoize `mergeSeqMap`: Because one
lookup into the merged sequence leads to two other sequence
lookups, the lack of memoization could led to exponential runtime
behavior in the worst case.

Fixes #514.
2018-06-29 14:16:35 -07:00
Brian Huffman
debe4df76d Fix broken compilation on ghc 8.2. 2018-06-28 19:34:10 -07:00
Iavor Diatchki
4c6a69c0cf Improvements to naming of variables.
This does a bunch of small changes, that should improve the usability
of Cryptol.  Namely:
  * When we are forced to make up a name, pick something derived from
    the source of the variable, annotated with the unique.
  * When pretty printing a schema, use "n,m,i,j,k" for numeric variables
    and "a,b,c,d,e" for value type vairable.
  * When generalizing, put numeric vairables first.
2018-06-28 15:58:11 -07:00
Iavor Diatchki
cf6e7161f5 Bugfix: Remember the results of defaulting. 2018-06-28 14:23:13 -07:00
Iavor Diatchki
75b56e251e Complain when we spot invalid literals. Fixes #519 2018-06-28 14:13:07 -07:00
Iavor Diatchki
3560161490 Use the existing test for numeric predicates. Fixes #518 2018-06-28 13:56:01 -07:00
Iavor Diatchki
0bf36808ed Improve various defaulting/instantiatiation warnings and error messages. 2018-06-25 16:48:10 -07:00
Brian Huffman
9597082be4 Fix definition of demote in reference interpreter.
It is now generalized to the `Literal` class.

Also delete implementation of removed primitive `integer`.
2018-06-22 06:31:36 -07:00
Brian Huffman
107e4ae646 Fix primitives for list enumerations in reference interpreter.
The types of `fromTo`, `fromThenTo`, `infFrom`, and `infFromThen`
have been generalized to work with classes `Literal` or `Arith`.
2018-06-22 06:27:21 -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
83de4c7a81 Merge remote-tracking branch 'origin/master' into literal-class 2018-06-20 16:30:59 -07:00
Brian Huffman
3cdfa62908 Fix implementation of negate and lg2 for types Integer and Z n.
`lg2` now throws the new `LogNegative` error on negative integer inputs.

Fixes #515 and #516.
2018-06-20 15:44:19 -07:00
Iavor Diatchki
29cef7008a Merge remote-tracking branch 'origin/master' into literal-class 2018-06-20 15:10:21 -07:00
Iavor Diatchki
b179a6aad7 Merge remote-tracking branch 'origin/master' into literal-class 2018-06-20 15:06:43 -07:00
Brian Huffman
29f401bbcb Tweak unification algorithm to preserve old behavior more.
(This fixes lots of trivially-broken regression tests.)
2018-06-20 15:06:27 -07:00
Iavor Diatchki
0d81f0ba25 Implement defaulting in the presence of overloaded literals. 2018-06-20 15:06:19 -07:00
Brian Huffman
ae091dbaa9 Fix unification algorithm to avoid returning invalid Subst values.
When unifying a variable with a type, we now pay attention to the
scope of type parameters upon which the unification variables in the
type may depend. When two unification variables are unified with each
other, we may need to construct the substitution in the reverse
direction, if the parameter scopes of the two variables are different.
2018-06-20 14:52:52 -07:00
Brian Huffman
5e4b1565bf Document invariant on Subst type; redo checking of the invariant.
The "captured variable" check on `instance TVars Schema` is
now considered excessive and has been removed.

Fixes #323.
2018-06-20 13:53:58 -07:00
Brian Huffman
6364c172ee Remove debugging output. 2018-06-20 11:11:51 -07:00
Brian Huffman
ea9e15b8b9 Add checks for instantiating type schemas containing unification vars.
When instantiating a type schema like `{a} [?n][a]`, if the unification
variable `?n` has a dependency on type parameter `a`, then we require
that the type variables can only be instantiated to themselves. This
avoids problems where (after substitution) the unification variable ?n
could be instantiated to a type containing variable `a`.

The user-visible result of this is that recursive declarations with
partial type signatures like `{a} [_][a]` cannot be use polymorphic
recursion; any recursive calls must be at the same type instance.

Fixes #513.
2018-06-20 11:06:55 -07:00
Brian Huffman
48ceb5dd9a Fix typos in comments. 2018-06-20 10:40:17 -07:00
Brian Huffman
5d4dd3fc38 Specialize type of TVFree constructor argument for type variable scope.
It had always contained only `TVBound` values.
2018-06-20 10:25:18 -07:00
Brian Huffman
ba9ccf6f1a Further specialize type of lazyTVars table.
The lazyTVars table only ever contained TVars of the form `TVBound tp`.
2018-06-20 09:52:26 -07:00
Brian Huffman
ebece48a36 Specialize type of lazyTVars table in state of Kind-checking monad.
The lazyTVars table only ever contained types of the form `TVar v`.
2018-06-20 09:35:32 -07:00
Iavor Diatchki
e579113d05 Merge remote-tracking branch 'origin/master' into literal-class
# Conflicts:
#	tests/mono-binds/test04.icry.stdout
#	tests/regression/check01.icry.stdout
#	tests/regression/check16-tab.icry.stdout
#	tests/regression/check16.icry.stdout
#	tests/regression/check21.icry.stdout
#	tests/regression/check22.icry.stdout
2018-06-20 09:14:17 -07:00
Iavor Diatchki
287abbf19f Merge branch 'master' of github.com:GaloisInc/cryptol 2018-06-19 17:29:09 -07:00
Iavor Diatchki
33f0ab3979 Improved locations for defaulting warnings. 2018-06-19 17:28:59 -07:00
Brian Huffman
3e90de49de Use existing function isBoundTV instead of redefining a new one. 2018-06-19 17:18:30 -07:00
Iavor Diatchki
13187ab13c Redo using the pattern. Ugly. We should switch back to pattern synonyms. 2018-06-19 11:35:51 -07:00
Iavor Diatchki
c24ca27167 Eagerly simplify 'Literal' constraints. 2018-06-19 11:13:11 -07:00
Iavor Diatchki
43461f1764 Typo 2018-06-19 11:12:40 -07:00
Brian Huffman
c1c80ce316 Explicitly check that extendSubst preserves InferM invariant.
We ensure that the bound `TVar`s in the current substitution are
always a subset of the bound `TVar`s in scope.

The regression test for #146 now fails earlier due to this check.
On the other hand, issue #323 never fails the `extendSubst` check.
2018-06-18 18:54:15 -07:00
Brian Huffman
fe4e5d9e3c Fix typos in comments. 2018-06-18 18:11:00 -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
9cbda930c7 Fix compiler warnings. 2018-06-15 11:12:50 -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
59104829a0 Rename Cryptol.Utils.PP.<> to avoid clash with Semigroup operator.
The pretty-printing operator `<>` is now called `<.>`.

Cryptol now compiles without warnings on both ghc 8.2 and 8.4.
2018-06-14 10:17:49 -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
daac41fdec Fix implementation of ^^ on type Z n in symbolic backend. 2018-06-14 06:16:04 -07:00
Brian Huffman
a8f3e189e0 Remove unused import. 2018-06-13 11:57:51 -07:00
Brian Huffman
ea9b0a9194 Make type Z n an instance of class Literal.
instance (fin val, fin m, m >= val + 1) => Literal val (Z m)
2018-06-13 11:55:26 -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
4f1a743585 Remove special cases in evaluator for types Z 0 and Z inf.
These types are now forbidden by the type checker.
2018-06-13 11:32:23 -07:00
Brian Huffman
ec19538a3b Make type Z n a partial type operator, requiring (fin n, n >= 1). 2018-06-13 11:16:46 -07:00
Brian Huffman
9a2437b727 Use size parameter in random value generator for type Integer. 2018-06-13 10:50:58 -07:00
Brian Huffman
30ba719343 Fix exhaustive and random testing for integers-mod-n type. 2018-06-13 09:35:12 -07:00
Brian Huffman
7da2219caf Initial implementation of type Z n (integers mod n).
This covers most of #510, including the type itself and the
class instances, but not any of the new primitive functions.
2018-06-11 18:03:18 -07:00
Brian Huffman
e11806f64a Reimplement comparison primitives by recursion on the TValue. 2018-06-11 16:40:57 -07:00
Brian Huffman
f7b8373a4a Fix incomplete pattern match warnings. 2018-06-11 15:33:46 -07:00
Brian Huffman
4adb4bc13a Remove unused constructors from Parser.AST.Type datatype. 2018-06-11 15:23:09 -07:00
Brian Huffman
9188878c4e Renamer handles built-in types like Integer and Bit using TApp. 2018-06-11 15:03:12 -07:00
Brian Huffman
d5c9a030da Split new modules Fixity and Selector from Cryptol.Parser.AST. 2018-06-11 14:28:49 -07:00
Brian Huffman
7cf26f8653 Remove dead code. 2018-06-11 11:10:53 -07:00
Brian Huffman
083d42ad30 Remove integer-based arguments to logicUnary and logicBinary.
Type `Integer` is not an instance of class `Logic`, so we don't need
to implement logic operations for this type.
2018-06-11 11:04:56 -07:00
Brian Huffman
2228c03565 Simplify case expression. 2018-06-10 12:42:10 -07:00
Brian Huffman
6b3dc6d9d4 For quick-checking integer properties, use a randomized bit width.
The distribution is unbounded, but is biased to smaller bit widths,
and is designed to have an average bit-width of 64.
2018-05-25 11:07:19 -07:00
Brian Huffman
c7d5f51240 Report "untestable type" error when using :exhaust with type Integer. 2018-05-24 17:24:11 -07:00
Aaron Tomb
99f3fdbf37 Merge Cryptol/Extras.cry with Cryptol.cry
Closes #427.
2018-05-23 15:55:05 -07:00
Brian Huffman
3a4bc6a2af Allow ":set <boolean-flag> = false" and ":set <boolean-flag> = true".
Previously we only allowed enable/disable, on/off, or yes/no.
2018-05-22 15:17:15 -07:00
Iavor Diatchki
9e3f7ec13f Merge branch 'master' of github.com:GaloisInc/cryptol 2018-05-22 14:27:12 -07:00
Iavor Diatchki
a0c15874e2 Factor out panic code into its own little package. 2018-05-22 14:27:03 -07:00
Brian Huffman
9fccc00867 Remove obsolete GF(2) polynomial primitives from reference interpreter. 2018-05-14 17:32:09 -07:00
Brian Huffman
26acdd0dad Pass pretty printing options to printer for reference interpreter.
(The options are not actually used yet.)
2018-05-14 17:03:00 -07:00
Iavor Diatchki
52f335deaa Asllow writing fancier kinds. This is in preparation for type primitives/abstract types. 2018-05-11 16:05:20 -07:00
Iavor Diatchki
e0cbfb1531 Fixup and clean-up checking of non-builting type applications.
Fixes #506
2018-05-11 10:38:00 -07:00
Iavor Diatchki
35ece3c3ed Use a datatype instead of Bool, to be more explicit about what it means. 2018-05-11 10:37:18 -07:00
Iavor Diatchki
2e2ac8c09d Just comments and layout 2018-05-11 10:07:12 -07:00
Iavor Diatchki
812ecec79c Fail if a built-in type has been applied to some arguments.
Fixes #507
2018-05-11 10:05:39 -07:00
Brian Huffman
13363c4c9b fastTypeOf doesn't perform any simplification when substituting types.
This makes it more useful for the saw-core translation, because we
can notice when type coercions need to be applied.
2018-05-10 15:23:53 -07:00
Iavor Diatchki
ec5e84dd37 Add a fin constraint on following matches in a comprehension.
Fixes #505.   It doesn't really make sense to have infinite things
following a finite thing in a comprehension, as there would be a whole
lot of unreachable elements.  Since this is likely an error, we try
to catch it with the types.
2018-05-07 11:52:43 -07:00
Iavor Diatchki
59aa5f11d0 Fix typos 2018-05-07 11:50:51 -07:00
Brian Huffman
42e89b11ae Make :check work for tests involving type Integer. 2018-04-20 16:00:32 -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
Iavor Diatchki
849cee862b Fix up binding of it to values. 2018-04-02 09:49:17 -07:00
Iavor Diatchki
47ed3b57ad Make :check and :exhaust bind the counter example in it
Fixes #449
2018-03-30 17:10:38 -07:00
Iavor Diatchki
bfb3290e9b Improve display ordering on names and group constraint synonyms separately.
See #503
2018-03-30 15:28:22 -07:00
Aaron Tomb
9d344bb452 Fix build with GHC 8.4.1 2018-03-23 15:08:09 -07:00
Brian Huffman
fccf55f30f Remove obsolete cvs-era $Header$ keywords. 2018-03-22 13:33:12 -07:00
Brian Huffman
c1949586c2 Thunk elements of EList expressions of type Bit during evaluation.
Fixes #488.
2018-03-21 17:55:11 -07:00
Brian Huffman
d84d697aae Fix compiler warnings and remove dead code. 2018-03-21 11:21:48 -07:00
Brian Huffman
83442f5049 Implement signed shift (>>$) and less-than (<$) in reference interpreter.
Fixes #469.
2018-03-21 09:58:48 -07:00
Brian Huffman
134d8cca4c Thunk elements of EList, ETuple, and ERec expressions during evaluation.
Fixes #432.
2018-03-07 18:21:16 -08:00
Brian Huffman
ff86d02600 Fix typo in docstring. 2018-01-11 10:24:26 -08:00
Brian Huffman
60e03d7313 Suppress unused-variable warning for names that are defined externally.
Previously names were considered "local" if they have the same module
name as the module name that we are performing renaming on (the idea
being that all "external" names would have been imported from a different
module).

However, this assumption doesn't hold for the "<interactive>" module,
which is used for REPL declarations. Names from earlier REPL declarations
should be considered "external" when renaming later REPL expressions, even
though they have the same "<interactive>" module name.

The problem is fixed by checking whether a name was already present in the
old naming environment; if so, then it is considered "external" and will
not generate an unused-variable warning.
2018-01-11 10:23:19 -08:00
Iavor Diatchki
79e6f83c70 Report proper errors instead of panicing.
Previously I erroneously thought this would be reported by the renamer,
so I turned the errors into panics.

Fixes #493
2018-01-04 15:27:37 -08:00
Iavor Diatchki
4aa68c9cf4 Add a note for another useful rule 2018-01-04 10:59:33 -08:00
Iavor Diatchki
762b31597f Add a case to solve things like: 4 == 2 ^^ x 2018-01-04 10:57:05 -08:00
Iavor Diatchki
bc45e751d1 Fixes #492 incorrect simplification for tMax 2018-01-03 09:56:47 -08:00
Iavor Diatchki
989e5734ef Move defaulting code to a separate module. 2017-12-22 16:01:19 -08:00
Iavor Diatchki
7bf0fa8222 Remove evaluator cases that should not occur.
These are translated away in the solver.
2017-12-22 11:24:44 -08:00
Iavor Diatchki
c481fbc6e8 Handle lifted selectors in the solver, so they are not visible in evaluator. 2017-12-22 11:23:54 -08:00
Iavor Diatchki
defb9b0598 When things go wrong, give us a hint as to where they did. 2017-12-22 11:23:26 -08:00
Iavor Diatchki
b9957e49ce Make location more precise 2017-12-21 14:39:58 -08:00
Iavor Diatchki
2dff60fb0e Allow some errors to subsume others. 2017-12-21 14:34:37 -08:00
Iavor Diatchki
978b3b232b Remove errors that should have been handled by the renamer. 2017-12-21 14:28:58 -08:00
Iavor Diatchki
9c06f07223 Move errors to their own module. 2017-12-21 13:59:53 -08:00
Iavor Diatchki
8bf780b969 Print even when malformed. Useful for printing before renamer. 2017-12-21 13:32:17 -08:00
Iavor Diatchki
89d453a6fa Print location under, as it was before. 2017-12-21 10:21:53 -08:00
Iavor Diatchki
c093d05659 Don't print file locations twice. 2017-12-21 10:19:04 -08:00
Iavor Diatchki
32fb511ced Add location more generally. 2017-12-15 14:12:38 -08:00
Iavor Diatchki
7db18e817c Improve error message for ambiguous types. 2017-12-15 14:05:15 -08:00
Iavor Diatchki
2272a59314 Rename type synonyms properly. 2017-12-01 10:29:42 -08:00
Iavor Diatchki
5cd90d0045 Fix up scoping when instantiating modules. 2017-12-01 09:51:28 -08:00
Iavor Diatchki
c0b4ddd608 Keep track of the order in which type parameters are declared in the file. 2017-11-28 14:07:14 -08:00
Iavor Diatchki
9de90e5752 Slightly better parser messages. 2017-11-15 15:36:45 -08:00
Brian Huffman
79fbb61aa7 Require doc-strings to start with "/**" with exactly 2 asterisks.
Things like "/******* WARNING ********/" are now parsed as ordinary
comments. See #438.
2017-11-15 11:36:25 -08:00
Brian Huffman
511e97767f Disallow spaces inside qualified names (e.g. Foo::x). Fixes #381. 2017-11-15 10:52:36 -08:00
Iavor Diatchki
2b396f0d66 Buble up Error in the first argument of Literal 2017-11-14 17:14:42 -08:00
Iavor Diatchki
d517193296 Default types of kind * to Integer. 2017-11-14 17:14:24 -08:00
Iavor Diatchki
8700ad6832 Run warning check whenever we do some renaming, instead of just in the module.
Hopefully this fixes #483 properly this time.
2017-11-14 16:11:00 -08:00
Iavor Diatchki
5ccb0bb4ad Warn for unused type names.
Fixes #483.
2017-11-14 15:57:15 -08:00
Brian Huffman
00d07cfbb9 Fix implementation of demote primitive in reference interpreter. 2017-11-10 08:35:19 -08:00
Brian Huffman
231c5713c4 Adapt internal uses of demote primitive to its new type 2017-11-10 08:34:58 -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
Iavor Diatchki
c4b156e499 Don't add an empty record, if the module has not value parameters.
Fixes #484
2017-11-08 14:19:40 -08:00
Iavor Diatchki
a8d5c5c602 Add some better cancellation of common constants. 2017-11-08 14:13:49 -08:00
Iavor Diatchki
7e964aa1cd Add a simplification rule for subtraction. 2017-11-07 15:51:05 -08:00
Iavor Diatchki
e1b9e0b5bf Merge branch 'master' of github.com:GaloisInc/cryptol 2017-11-07 13:59:28 -08:00
Iavor Diatchki
0adcddb792 Remember edit path. 2017-11-07 11:27:50 -08:00
Iavor Diatchki
f71ba16345 Fix order of type applications. 2017-11-07 11:27:37 -08:00
Brian Huffman
30b7d2918a Implement signed operators (/$) and (%$) in reference interpreter.
This partially addresses ticket #469.
2017-11-06 16:55:32 -08:00
Brian Huffman
8f94daf783 Catch calls to error coming from SBV library. Fixes #479. 2017-11-06 14:10:01 -08:00
Brian Huffman
c587d3fcb4 Allow underscores in numeric literals. Implements #477.
The implementation allows any number of underscores between
digits, or between the base specifier and digits. Underscores
are not allowed at the beginning or end of a numeric literal.

0x1234_5678  (OK)
0b_0110_1001 (OK)
0xff______ff (OK)
5_000_000    (OK)
2_________3  (OK)
0_x1234      (BAD)
_0xff        (BAD)
52_          (BAD)
_5           (BAD)
2017-11-02 17:00:46 -07:00
Iavor Diatchki
d6d8ab1d35 Try to shrink the model, when defaulting at the REPL. Fixes #476 2017-10-30 17:26:18 -07:00
Iavor Diatchki
d7d1f21434 Cancel out finite positive variables. 2017-10-30 14:25:15 -07:00
Iavor Diatchki
07eac47989 Merge remote-tracking branch 'origin/abstract-types' 2017-10-27 15:12:22 -07:00
Iavor Diatchki
3f8a8b8874 Add forgotten file 2017-10-27 15:07:15 -07:00
Iavor Diatchki
2d3e146766 Allow evaluation in parameterized module, as long as parameters are not used. 2017-10-27 14:59:32 -07:00
Iavor Diatchki
4cf83a3c3d Keep track of the file that cause an error.
Also, now we automatically switch to working on this file, which
is sometimes nice, and sometimes confusing...
2017-10-27 11:02:08 -07:00
Brian Huffman
bc5fe0e4c9 Add combinators tIsRec and aRec for matching record types (TRec). 2017-10-27 10:54:32 -07:00
Iavor Diatchki
35a3843685 Remember the path when editing. 2017-10-27 10:21:50 -07:00
Iavor S. Diatchki
65ebbb5956 Extend core linter with support for parameterized modules. 2017-10-26 14:20:29 -07:00
Iavor S. Diatchki
26240742a4 Pretty print when panicing, makes it easier to see 2017-10-26 11:50:48 -07:00
Iavor S. Diatchki
8627945ade Fix up transformation 2017-10-26 11:50:36 -07:00
Iavor Diatchki
b87f387d38 Add param in the correct place, but there's still something wrong. 2017-10-25 17:00:11 -07:00
Iavor Diatchki
3f4cc570cf Use a record for all module parameters at the value level. Also improve PP 2017-10-25 16:39:29 -07:00
Iavor Diatchki
ee7506b32a Only drop common stars or space at the beginning of a comment. 2017-10-25 11:28:30 -07:00
Iavor Diatchki
5c51d32a4e Fix up html syntax highlighting. 2017-10-25 11:12:37 -07:00
Iavor Diatchki
c666731495 Print help for type parameters. 2017-10-24 16:12:12 -07:00
Iavor Diatchki
6056eaad4b Use proper types for module parameters; allows for stroing metadata
For example, documentaiton.
2017-10-24 15:43:32 -07:00
Iavor Diatchki
2f53602749 We need to instantiate constraints, not parameterize them! 2017-10-24 14:04:30 -07:00
Iavor Diatchki
e2d74066d8 Only load by module name, if we have a special module name.
Otherwise, scripts tend to fail to reload, as they have no module name,
which defaults to `Main`, but the file name is called something else.
2017-10-24 13:46:48 -07:00
Iavor Diatchki
fd0e6258fc More fixes to rewriting code. 2017-10-24 13:41:37 -07:00
Iavor Diatchki
2de8eff416 Fix up translation, to change the type of name to Parameter 2017-10-24 11:59:59 -07:00
Iavor Diatchki
c2ca8f30a7 Fix displaying of parameters. 2017-10-24 11:44:44 -07:00
Iavor Diatchki
8472cfb0db Fix editing and reloading for generated modules. 2017-10-24 11:16:13 -07:00
Iavor Diatchki
4c9d25bf39 Fix up browsing for module with added params. 2017-10-24 11:09:57 -07:00
Iavor Diatchki
ca6b34f621 Refactor module system things; better loading of `A modules. 2017-10-23 15:12:12 -07:00
Iavor Diatchki
05e3a84cd1 Plug in adding parameters to each definition. XXX: fix repl :m :load 2017-10-20 16:33:02 -07:00
Iavor Diatchki
d52c5f5938 Merge remote-tracking branch 'origin/master' into abstract-types
# Conflicts:
#	src/Cryptol/Parser/ParserUtils.hs
2017-10-20 14:07:47 -07:00
Iavor Diatchki
1e17bd03cf Make parser use strict text (XXX: does this affect performance +ve or -ve)
Also makes module names into their own newtype
2017-10-20 12:00:00 -07:00
Brian Huffman
e3ea9335c8 Put correct VWord width tag on result of symbolic index operation.
Fixes #474.

Previously, applying (@) at type `[a][b] -> [i] -> [b]` would tag the
result value as having width `a` instead of width `b`. This is now fixed.
2017-10-20 11:09:32 -07:00
Iavor S. Diatchki
300383772f Just a clarification 2017-10-19 15:17:39 -07:00
Iavor S. Diatchki
095a7718d9 Add a pass to rewrite a param. module, into a non-param module
All definitions are parameterized by all parameters.
2017-10-19 13:45:40 -07:00
Iavor Diatchki
c3d8b4b3f8 Allow focusing of parameterized modules; disable evaluation in such contexts. 2017-10-18 14:33:12 -07:00
Iavor Diatchki
432638a77a Allow a value parameter to be defined by another value parameter. 2017-10-18 13:36:37 -07:00
Iavor Diatchki
1cbbba7c32 More functionality 2017-10-17 16:26:05 -07:00
Iavor Diatchki
dda54aa016 More progress 2017-10-16 15:54:42 -07:00
Iavor Diatchki
acacd0b53d Merge remote-tracking branch 'origin/master' into abstract-types
# Conflicts:
#	src/Cryptol/TypeCheck/Monad.hs
2017-10-16 14:25:08 -07:00
Iavor Diatchki
942173b7f9 Add comments and fixes #473 2017-10-16 14:09:52 -07:00
Iavor Diatchki
a85ff3a54b Add comments 2017-10-16 14:05:46 -07:00
Iavor Diatchki
6ba8849216 Just reformat 2017-10-16 14:05:31 -07:00
Iavor Diatchki
ec456b9447 Fix typo 2017-10-16 14:05:01 -07:00
Iavor S. Diatchki
15f236d42b More loading of instances (incomplete) 2017-10-13 15:27:42 -07:00
Iavor S. Diatchki
2b21610796 Better integration of module parameters with module system and REPL 2017-10-13 11:35:46 -07:00
Iavor S. Diatchki
7dc7be45bb Merge remote-tracking branch 'origin/master' into abstract-types
# Conflicts:
#	src/Cryptol/REPL/Monad.hs
2017-10-13 10:45:35 -07:00
Iavor S. Diatchki
3f2ac1171c Comments 2017-10-13 10:40:24 -07:00
Iavor Diatchki
51808bbf23 More comments 2017-10-06 16:24:10 -07:00
Iavor Diatchki
f71b951108 Some documentation. 2017-10-06 15:57:45 -07:00
Iavor Diatchki
b5ef48dcd7 Fix-up the benchmarking code. 2017-10-06 11:55:48 -07:00
Iavor S. Diatchki
13ac2d9f05 wibble 2017-10-05 15:52:50 -07:00
Brian Huffman
fd0fc99418 Update some Integer-related stuff in the reference interpreter. 2017-10-05 15:13:37 -07:00
Iavor S. Diatchki
4e65ad03f9 Almost complete module instantiation 2017-10-05 15:10:25 -07:00
Iavor S. Diatchki
f64f051842 Now wild cards in the types of module parameters 2017-10-05 13:49:25 -07:00
Iavor S. Diatchki
f7adf8f4ba Validate schemas properly 2017-10-05 13:46:24 -07:00
Iavor S. Diatchki
933e2cd2ee Merge branch 'abstract-types' of github.com:GaloisInc/cryptol into abstract-types
# Conflicts:
#	src/Cryptol/ModuleSystem/InstantiateModule.hs
2017-10-05 12:45:11 -07:00
Brian Huffman
4b386477ec Avoid creating a new option when :set is used with a prefix of a name.
Fixes #450.
2017-10-04 21:22:59 -07:00
Brian Huffman
a9de74ed5d Implement module-name completion and validation for :browse.
Fixes #396.
2017-10-04 19:17:42 -07:00
Iavor Diatchki
1f2cacbae5 Merge branch 'master' of github.com:GaloisInc/cryptol 2017-10-04 15:50:41 -07:00
Iavor Diatchki
5208739653 Don't print directly to stdout. Fixes #166 2017-10-04 15:50:31 -07:00
Brian Huffman
d025108bd2 Make :browse filter declarations by module name instead of value name.
See #396.
2017-10-04 15:45:25 -07:00
Brian Huffman
2b568897da Remove implicit Bit type signature on rhs of property declarations.
Fixes #224.

It might be desirable to add some other check for `property` declarations
to make sure that their types are predicates of some arity.
2017-10-04 15:26:17 -07:00
Brian Huffman
c7380d35d4 Fix symbolic indexing function indexFront to avoid indexing past the end.
Previously it would create a lookup table with 2^w entries, where w is
the bit-width of the index. Now the lookup table has min(2^w, n) entries,
where n is the length of the indexed vector.

Fixes #463.
2017-10-04 13:46:58 -07:00
Iavor Diatchki
f74ad3c29d Fix haddock comment, should restore build process. 2017-10-04 10:09:01 -07:00