When :check was executed on a function accepting words as arguments
cryptol would generate mostly small words. This strategy failed to find
counter-examples in formulas such as:
(\a b -> (((a : [16]) + b) % 17) == ( (a % 17 + b %17) % 17 ) )
This failure is particularly egregious considering 50% of the inputs
result in False. We now generate a better distribution of words and are
discussing use of a smart-check like strategy or an evaluation of the
logic to tailor generation in a future release (see issue #87).
In layout mode, setting cfgModuleScope to true ensures that the lexer
will generate virtual open/close braces and virtual semicolons between
decls.
This is a follow-up to c689a15cfc.
The fix for #81 ignored a case where a layout block was started by ParenL
symbol. In that case, the layout level wouldn't be pushed on the stack, and a
parse error would eventually result. This adds the check into the ParenL
special case, starting an explicit block terminated by a ParenR, as well as a
new virtual layout block.
Also missing from the original patch was the full offsides check, which must
be repeated in the ParenL special case. I think that we should probably do some
refactoring of the layout processor, as I doubt that this is the only case that
will produce this behavior.
Additionally, the BraceL/BraceR cases were removed, as explicitly delimited
layout is not currently supported.
E.g. "True && if True then True else True" is now accepted without parens.
The grammar now relies on the relatively low precedence of 'else', '->',
and ':' relative to other infix operators to disambiguate parsing. This
addresses issue #74.
The layout processor didn't account for layout blocks that were terminated by
parens or braces, so this accounts for that in the context stack that is kept by
the layout processor. Fixes#81
Previously, 'take'ing a finite prefix of an infinite stream would
incorrectly yield a 'VStream' value, which would normally indicate
an infinite result. Now it correctly returns a 'VSeq' value.
See #66 for more discussion. Basically we don't want the type of `it` to be different for unsat or sat results, so we put undefined values in there instead. Also, instead of using tuples and different field names to distinguish formula arguments of various arities, we use a convention of fields `arg1`, `arg2`, ...
Per @weaversa's suggestions in #66, we now bind records to `it` for sat results, leading to less ambiguity about the meaning of those results. There is still some weirdness to this; the fields present in the record change based on the result and the arity of the formula, but this seems like a reasonable approach given that it's not an expression that needs a type.
Similar to what @weaversa requested in #66, we bind `it` to `False`
when we can't find a sat assignment, and `it` to `True` when we've
proved a theorem.
Also adds some simple tests for the sat/prove result binding, and let
binding at the repl.
Conflicts:
cryptol/REPL/Command.hs
src/Cryptol/Symbolic.hs
Fixed up Value -> Expr conversion to account for a change in those
types. Reworked sat and prove results to account for changes in that
API.
If the solver returns values for :sat or :prove, we now bind them at
the repl to `it`. If more than one argument is part of the cex/sat
answer, we tuple up/uncurry the arguments.
Since :let was clashing with :load for :l, and for consistency with
ghci, you can now enter bare let expressions at the repl:
> let x = 5
Also, the grammar for the repl parser disallows type bindings, which
were possible in the previous :let.
Semicolons no longer needed, though we can only bind one thing at a
time.
For now, you can only enter one binding at a time at the REPL, and can
only enter expression bindings rather than type signatures or type
synonyms. It wouldn't be too hard to add type synonyms, but the value
is questionable.
This just makes for a more consistent API; the "dynamic" environment
as extended by REPL commands is now part of the ModuleEnv. It's
actually more general than just for the REPL. We can use it in general
to add bindings on top of a loaded module context.
This change fixes the issue where `getVars` in the REPL would return
names with the `#Uniq_...` prefix. This was confusing, and also
messing up tab-completion.
This works by adding an extended environment to some of the
ModuleSystem functions. This extended environment contains
declarations entered interactively, a naming environment that maps
parsed names to the unique names we use to ensure lexical scope, and
an evaluation environment containing the values of the let-bound
expressions.