-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for type invariants #197
Add support for type invariants #197
Conversation
This PR is still a draft as the type invariants are placed in an |
This should close #186 |
e9490b9
to
d718ed2
Compare
Checking for type invariant regaring |
11c3244
to
5bf542e
Compare
5bf542e
to
cda7ce7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks very good, well done!
Still, I managed to find a couple of suggestions 😄
- Is the fact that the function is named
wrapped_init_state
part of a bigger plan, because, as this PR stands, it is used only to check the initial state and its result is always discarded. In the present state, I would then suggest renaming it ascheck_init_state
and giving it the typeunit -> unit
.agree_prop
could then use a simple sequencecheck_init_state (); ...
. - I noticed that
invariants_errors.expected
appears before theinvariants.mli
is created. I would suggest squashing the “Check type invariants ininit_state
” and “Add some tests” commits.
I also put smaller comments on some lines, they were harder to describe without context.
@@ -383,8 +377,8 @@ let ghost_functions = | |||
let run sigs config = | |||
let open Reserr in | |||
let open Ir in | |||
let* state = state config sigs in | |||
let* state, invariants = state config sigs in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line reads a bit funny. I suggest renaming the state
function as state_and_invariants
.
@@ -159,7 +159,15 @@ module Spec = | |||
match cmd__010_ with | Get -> Res (int, (get sut__011_)) | |||
end | |||
module STMTests = (STM_sequential.Make)(Spec) | |||
let wrapped_init_state () = | |||
let __state__012_ = Spec.init_state in | |||
if true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me wonder: should the test deciding to generate a non-trivial wrapped_init_state
rather be whether we have some invariants to test after translation, rather than Option.is_some
at the beginning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
plugins/qcheck-stm/src/stm_of_ir.ml
Outdated
@@ -843,11 +895,16 @@ let stm include_ config ir = | |||
let descr = estring (module_name ^ " STM tests") in | |||
[%stri | |||
let _ = | |||
let open QCheck in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is QCheck
necessary for more than just Test.make
? If not, I would rather go with QCheck.Test.make
.
Mostly add `list_or` and `enot` that will soon be needed, but take the opportunity to move `qualify` and redefine some functions that where worngfully using `evar` on qualified names.
This will guarantee preservation of type invariants for `sut`
cda7ce7
to
15bfd2c
Compare
Thanks for your suggestions @shym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it is nicer now, thanks!
This PR proposes to add checks for type invariants (for sut) in:
postcond
in order to guarantee preservation of invariantsinit_state
in order to check that the user-provided value respects the invariants.The second one is done in
init_state
and notinit_sut
as Gospel invariants are supposed to be talking about the model, not the actual value.