-
Notifications
You must be signed in to change notification settings - Fork 7
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
No shrinking happening when checking a DL formula #31
Comments
Hm, this is a bit of a thorny one. We would certainly like to shrink this test case as the This is a bit of a problem here because fundamentally speaking I see no exact reason why this has to be the case. It's just a feature of how qc-d shrinks stuff. I guess we could try to change that so that if you remove actions from I think the offending code is here: However, fixing this might require a serious rework of the shrinking implementation. But it might well be worth doing. |
Thanks a lot for the clarification! I was puzzled because simply tracing the calls I could see |
Actually, I was being stupid: I used |
That's good! But we should still try to fix this behaviour! I have a minial failing example of this that showcases it nicely! |
Ok, we have a nice example of this now on branch
The latter counterexample is minimal but because there is a tight coupling between the number of calls to |
I was wondering if we could not apply a strategy similar to Brozowski's Regular Languages derivatives, eg. compute a new expression by "deriving" it w.r.t. to some event it produces. |
That's actually what we currently do in shrinking in quite an ingenious way. The code currently shrinks counterexamples without reference to the DL formula and then checks that they are OK (and completes them) by taking the Brozowski derivative and doing the minimal work to complete the formula (the last bit is IIRC, or we just drop the ones that don't have derivative epsilon). The problem with that is that if your action depends on the state and your old counterexample contains an action that depends on the state in the old counterexample then the derivative will fail. You can't derive the DL formula |
Ah, I did not realise that you were using this technique. I must admit the code is a bit dense for me :) |
I must admit the code is a bit dense for me too. I'm working on finding the time to go over it and re-work the whole thing. That's something for when I fix this bug... |
I have updated related branch to |
That might help materialize the dependency yes, the problem is that we have getModelStateDL :: DL s s
getModelStateDL = DL $ \s k -> k (underlyingState s) s Changing this to materialize the fact that we are looking at the state at this point might help because that would mean we'd be shrinking not an action that uses the old state (from generation time) but one that uses the new state (in the continuation of the new In fact, I wonder if this can be used to entirely eliminate the |
I am experimenting with this, added a |
|
It looks like this in the DL:
I am bit lost in the maze of continuations, and cannot convince the engine to properly "shrink" the |
The problem with that is that the continuation-in-monad approach is really cumbersome to work with and it doesn't buy you much. It also breaks a bunch of functionality you really need - like deciding what the rest of the DL property will look like depending on the state. |
With |
Note that my |
Right, my point is just that the first part shouldn't be necessary. Also whoever invented the |
I felt the need to add this in order to be able to have a different action depending on the state, whereas in the |
Not quite, the problem is that the action in the |
I am surprised by the fact I don't see any trace of shrinking happening with some property I am checking, although I implemented
shrinkAction
.precondition = const True
Here is the DL property I am checking:
and the resulting failure:
I would expect this part
*** Failed! Assertion failed (after 8 tests):
to tell me it tried some shrinking.I am using q-d v 2.0.0.
The text was updated successfully, but these errors were encountered: